[flang-commits] [flang] 507ce46 - [flang][preprocessor] Directive continuation must skip empty macros (#134149)

via flang-commits flang-commits at lists.llvm.org
Fri Apr 4 08:43:58 PDT 2025


Author: Peter Klausler
Date: 2025-04-04T08:43:56-07:00
New Revision: 507ce46b6fb0271c82df1352e82d592c0cbf9aaf

URL: https://github.com/llvm/llvm-project/commit/507ce46b6fb0271c82df1352e82d592c0cbf9aaf
DIFF: https://github.com/llvm/llvm-project/commit/507ce46b6fb0271c82df1352e82d592c0cbf9aaf.diff

LOG: [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.

Added: 
    

Modified: 
    flang/lib/Parser/prescan.cpp
    flang/test/Preprocessing/directive-contin-with-pp.F90

Removed: 
    


################################################################################
diff  --git a/flang/lib/Parser/prescan.cpp b/flang/lib/Parser/prescan.cpp
index 0df1e3e291923..809b728c47ffe 100644
--- a/flang/lib/Parser/prescan.cpp
+++ b/flang/lib/Parser/prescan.cpp
@@ -1325,7 +1325,7 @@ const char *Prescanner::FreeFormContinuationLine(bool ampersand) {
   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 6e84c2bde52f9..f1cfafe0bdf14 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 @@ subroutine s1(x1, x2, x3, x4, x5, x6, x7)
 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 @@ subroutine s3
 !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


        


More information about the flang-commits mailing list