From: Peter Klausler Date: Thu, 11 May 2023 23:00:14 +0000 (-0700) Subject: [flang] Don't mistakenly tokenize a Hollerith literal from "DO 100 H=..." (bug #58732) X-Git-Tag: upstream/17.0.6~8311 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a6569e578eb4b54d48af53282d176e227f36f05d;p=platform%2Fupstream%2Fllvm.git [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 --- diff --git a/flang/lib/Parser/prescan.cpp b/flang/lib/Parser/prescan.cpp index be5e603..19a70f1 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 0000000..8fac8e9 --- /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 +