[flang-commits] [flang] [flang] Skip over fixed form spaces when prescanning exponents & kind… (PR #145347)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Mon Jun 23 08:56:34 PDT 2025
https://github.com/klausler created https://github.com/llvm/llvm-project/pull/145347
… suffixes
When performing conditional tokenization of exponents and numeric kind suffixes, be sure to skip over spaces in fixed form source.
Fixes https://github.com/llvm/llvm-project/issues/145333.
>From 521c61a648869c50ae8ef292609887163e7661db Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Mon, 23 Jun 2025 08:52:52 -0700
Subject: [PATCH] [flang] Skip over fixed form spaces when prescanning
exponents & kind suffixes
When performing conditional tokenization of exponents and numeric
kind suffixes, be sure to skip over spaces in fixed form source.
Fixes https://github.com/llvm/llvm-project/issues/145333.
---
flang/lib/Parser/prescan.cpp | 18 ++++++++++++++++++
flang/test/Preprocessing/bug518.F | 2 +-
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/flang/lib/Parser/prescan.cpp b/flang/lib/Parser/prescan.cpp
index 9aef0c9981e3c..ed5184b0aa13d 100644
--- a/flang/lib/Parser/prescan.cpp
+++ b/flang/lib/Parser/prescan.cpp
@@ -915,12 +915,21 @@ bool Prescanner::HandleExponent(TokenSequence &tokens) {
int startColumn{column_};
TokenSequence possible;
EmitCharAndAdvance(possible, *at_);
+ if (InFixedFormSource()) {
+ SkipSpaces();
+ }
if (*at_ == '+' || *at_ == '-') {
EmitCharAndAdvance(possible, *at_);
+ if (InFixedFormSource()) {
+ SkipSpaces();
+ }
}
if (IsDecimalDigit(*at_)) { // it's an exponent; scan it
while (IsDecimalDigit(*at_)) {
EmitCharAndAdvance(possible, *at_);
+ if (InFixedFormSource()) {
+ SkipSpaces();
+ }
}
possible.CloseToken();
tokens.AppendRange(possible, 0); // appends to current token
@@ -940,13 +949,22 @@ bool Prescanner::HandleKindSuffix(TokenSequence &tokens) {
TokenSequence withUnderscore, separate;
EmitChar(withUnderscore, '_');
EmitCharAndAdvance(separate, '_');
+ if (InFixedFormSource()) {
+ SkipSpaces();
+ }
if (IsLegalInIdentifier(*at_)) {
separate.CloseToken();
EmitChar(withUnderscore, *at_);
EmitCharAndAdvance(separate, *at_);
+ if (InFixedFormSource()) {
+ SkipSpaces();
+ }
while (IsLegalInIdentifier(*at_)) {
EmitChar(withUnderscore, *at_);
EmitCharAndAdvance(separate, *at_);
+ if (InFixedFormSource()) {
+ SkipSpaces();
+ }
}
}
withUnderscore.CloseToken();
diff --git a/flang/test/Preprocessing/bug518.F b/flang/test/Preprocessing/bug518.F
index 0b680dd5751b9..beb33564e4232 100644
--- a/flang/test/Preprocessing/bug518.F
+++ b/flang/test/Preprocessing/bug518.F
@@ -1,5 +1,5 @@
! RUN: %flang_fc1 -fdebug-unparse %s 2>&1 | FileCheck %s
! CHECK: k=1_4
k= 1_99999999
- &4
+ & 4
end
More information about the flang-commits
mailing list