[flang][preprocessor] Directive continuation must skip empty macros (#134149)
When a compiler directive continuation line starts with keyword macro
names that have empty expansions, skip them.
diff --git a/flang/lib/Parser/prescan.cpp b/flang/lib/Parser/prescan.cpp
index 0df1e3e..809b728 100644
--- a/flang/lib/Parser/prescan.cpp
+++ b/flang/lib/Parser/prescan.cpp
@@ -1325,7 +1325,7 @@
if (p >= limit_) {
return nullptr;
}
- p = SkipWhiteSpace(p);
+ p = SkipWhiteSpaceIncludingEmptyMacros(p);
if (*p == '!') {
++p;
if (InCompilerDirective()) {
diff --git a/flang/test/Preprocessing/directive-contin-with-pp.F90 b/flang/test/Preprocessing/directive-contin-with-pp.F90
index 6e84c2b..f1cfafe 100644
--- a/flang/test/Preprocessing/directive-contin-with-pp.F90
+++ b/flang/test/Preprocessing/directive-contin-with-pp.F90
@@ -8,6 +8,7 @@
#define COMMENT !
#define OMP_START !$omp
#define OMP_CONT !$omp&
+#define EMPTY
module m
contains
@@ -50,6 +51,11 @@
OMP_CONT reduction(+:x)
do j3 = 1, n
end do
+
+EMPTY !$omp parallel &
+EMPTY !$omp do
+ do j4 = 1, n
+ end do
end
COMMENT &
@@ -79,6 +85,9 @@
!CHECK: !$OMP PARALLEL DO REDUCTION(+: x)
!CHECK: DO j3=1_4,n
!CHECK: END DO
+!CHECK: !$OMP PARALLEL DO
+!CHECK: DO j4=1_4,n
+!CHECK: END DO
!CHECK: END SUBROUTINE
!CHECK: SUBROUTINE s2
!CHECK: END SUBROUTINE