Skip to content

Commit f3d5759

Browse files
authored
[flang] Skip over fixed form spaces when prescanning exponents & kind… (llvm#145347)
… suffixes When performing conditional tokenization of exponents and numeric kind suffixes, be sure to skip over spaces in fixed form source. Fixes llvm#145333.
1 parent a93d843 commit f3d5759

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

flang/lib/Parser/prescan.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,12 +915,21 @@ bool Prescanner::HandleExponent(TokenSequence &tokens) {
915915
int startColumn{column_};
916916
TokenSequence possible;
917917
EmitCharAndAdvance(possible, *at_);
918+
if (InFixedFormSource()) {
919+
SkipSpaces();
920+
}
918921
if (*at_ == '+' || *at_ == '-') {
919922
EmitCharAndAdvance(possible, *at_);
923+
if (InFixedFormSource()) {
924+
SkipSpaces();
925+
}
920926
}
921927
if (IsDecimalDigit(*at_)) { // it's an exponent; scan it
922928
while (IsDecimalDigit(*at_)) {
923929
EmitCharAndAdvance(possible, *at_);
930+
if (InFixedFormSource()) {
931+
SkipSpaces();
932+
}
924933
}
925934
possible.CloseToken();
926935
tokens.AppendRange(possible, 0); // appends to current token
@@ -940,13 +949,22 @@ bool Prescanner::HandleKindSuffix(TokenSequence &tokens) {
940949
TokenSequence withUnderscore, separate;
941950
EmitChar(withUnderscore, '_');
942951
EmitCharAndAdvance(separate, '_');
952+
if (InFixedFormSource()) {
953+
SkipSpaces();
954+
}
943955
if (IsLegalInIdentifier(*at_)) {
944956
separate.CloseToken();
945957
EmitChar(withUnderscore, *at_);
946958
EmitCharAndAdvance(separate, *at_);
959+
if (InFixedFormSource()) {
960+
SkipSpaces();
961+
}
947962
while (IsLegalInIdentifier(*at_)) {
948963
EmitChar(withUnderscore, *at_);
949964
EmitCharAndAdvance(separate, *at_);
965+
if (InFixedFormSource()) {
966+
SkipSpaces();
967+
}
950968
}
951969
}
952970
withUnderscore.CloseToken();

flang/test/Preprocessing/bug518.F

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
! RUN: %flang_fc1 -fdebug-unparse %s 2>&1 | FileCheck %s
22
! CHECK: k=1_4
33
k= 1_99999999
4-
&4
4+
& 4
55
end

0 commit comments

Comments
 (0)