diff options
author | Peter Klausler <pklausler@nvidia.com> | 2023-05-11 16:00:14 -0700 |
---|---|---|
committer | Peter Klausler <pklausler@nvidia.com> | 2023-05-16 09:56:22 -0700 |
commit | a6569e578eb4b54d48af53282d176e227f36f05d (patch) | |
tree | 2fe0e607c28001322c4835b9bcf3a59eaa2be0fd /flang | |
parent | 48c3ae5cc3d4612283018ea597db3f7214aabfd9 (diff) | |
download | llvm-a6569e578eb4b54d48af53282d176e227f36f05d.tar.gz |
[flang] Don't mistakenly tokenize a Hollerith literal from "DO 100 H=..." (bug #58732)
After tokenizing an identifier, don't allow the next token to be a
Hollerith literal.
Fixes https://github.com/llvm/llvm-project/issues/58732.
Differential Revision: https://reviews.llvm.org/D150406
Diffstat (limited to 'flang')
-rw-r--r-- | flang/lib/Parser/prescan.cpp | 11 | ||||
-rw-r--r-- | flang/test/Parser/do100h.f | 7 |
2 files changed, 15 insertions, 3 deletions
diff --git a/flang/lib/Parser/prescan.cpp b/flang/lib/Parser/prescan.cpp index be5e6037cac3..19a70f1f6e06 100644 --- a/flang/lib/Parser/prescan.cpp +++ b/flang/lib/Parser/prescan.cpp @@ -594,13 +594,18 @@ bool Prescanner::NextToken(TokenSequence &tokens) { } preventHollerith_ = false; } else if (IsLegalInIdentifier(*at_)) { - do { - } while (IsLegalInIdentifier(EmitCharAndAdvance(tokens, *at_))); + while (IsLegalInIdentifier(EmitCharAndAdvance(tokens, *at_))) { + } + if (InFixedFormSource()) { + SkipSpaces(); + } if ((*at_ == '\'' || *at_ == '"') && tokens.CharAt(tokens.SizeInChars() - 1) == '_') { // kind_"..." QuotedCharacterLiteral(tokens, start); + preventHollerith_ = false; + } else { + preventHollerith_ = true; // DO 10 H = ... } - preventHollerith_ = false; } else if (*at_ == '*') { if (EmitCharAndAdvance(tokens, '*') == '*') { EmitCharAndAdvance(tokens, '*'); diff --git a/flang/test/Parser/do100h.f b/flang/test/Parser/do100h.f new file mode 100644 index 000000000000..8fac8e97cb50 --- /dev/null +++ b/flang/test/Parser/do100h.f @@ -0,0 +1,7 @@ +! RUN: %flang_fc1 -E %s | FileCheck %s +! Test that Hollerith is not mistakenly tokenized here +!CHECK: do 100 h=1,10 + do 100 h=1,10 +100 continue + end + |