[flang-commits] [flang] dfbc80f - [flang] Fix continuation when line begins with empty macro expansion (#117407)
via flang-commits
flang-commits at lists.llvm.org
Mon Dec 2 12:26:10 PST 2024
Author: Peter Klausler
Date: 2024-12-02T12:26:07-08:00
New Revision: dfbc80febb45544710b12cc05f268f40ef88cd6e
URL: https://github.com/llvm/llvm-project/commit/dfbc80febb45544710b12cc05f268f40ef88cd6e
DIFF: https://github.com/llvm/llvm-project/commit/dfbc80febb45544710b12cc05f268f40ef88cd6e.diff
LOG: [flang] Fix continuation when line begins with empty macro expansion (#117407)
A free form source line that begins with a macro should still be
classified as a source line, and have its continuation lines work, even
if the macro expands to an empty replacement.
Fixes https://github.com/llvm/llvm-project/issues/117297.
Added:
flang/test/Preprocessing/bug117297.F90
Modified:
flang/lib/Parser/prescan.cpp
Removed:
################################################################################
diff --git a/flang/lib/Parser/prescan.cpp b/flang/lib/Parser/prescan.cpp
index 34e660f8d26646..3cd32d7e6c92e8 100644
--- a/flang/lib/Parser/prescan.cpp
+++ b/flang/lib/Parser/prescan.cpp
@@ -234,7 +234,7 @@ void Prescanner::Statement() {
directiveSentinel_ = newLineClass.sentinel;
disableSourceContinuation_ = false;
} else {
- disableSourceContinuation_ =
+ disableSourceContinuation_ = !replaced->empty() &&
newLineClass.kind != LineClassification::Kind::Source;
}
}
diff --git a/flang/test/Preprocessing/bug117297.F90 b/flang/test/Preprocessing/bug117297.F90
new file mode 100644
index 00000000000000..88b54000f04630
--- /dev/null
+++ b/flang/test/Preprocessing/bug117297.F90
@@ -0,0 +1,7 @@
+! RUN: %flang -E %s 2>&1 | FileCheck %s
+!CHECK: CALL myfunc( 'hello ' // 'world' // 'again')
+#define NOCOMMENT
+NOCOMMENT CALL myfunc( 'hello ' // &
+NOCOMMENT 'world' // &
+NOCOMMENT 'again' )
+end
More information about the flang-commits
mailing list