[flang-commits] [flang] [flang] Fix continuation when line begins with empty macro expansion (PR #117407)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Fri Nov 22 16:27:10 PST 2024
https://github.com/klausler created https://github.com/llvm/llvm-project/pull/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.
>From 3bbdbf7a06e381ea7a526244298cf14c4fe4391a Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Fri, 22 Nov 2024 16:24:18 -0800
Subject: [PATCH] [flang] Fix continuation when line begins with empty macro
expansion
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.
---
flang/lib/Parser/prescan.cpp | 2 +-
flang/test/Preprocessing/bug117297.F90 | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
create mode 100644 flang/test/Preprocessing/bug117297.F90
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