[flang-commits] [flang] 22b52ce - [flang][OpenMP] Allow 0 after directive sentinels (#217124)

via flang-commits flang-commits at lists.llvm.org
Fri Aug 21 11:52:49 PDT 2026


Author: Leandro Lupori
Date: 2026-08-21T15:52:43-03:00
New Revision: 22b52ce03edf197019a1b137d9cec2a80fa90ff6

URL: https://github.com/llvm/llvm-project/commit/22b52ce03edf197019a1b137d9cec2a80fa90ff6
DIFF: https://github.com/llvm/llvm-project/commit/22b52ce03edf197019a1b137d9cec2a80fa90ff6.diff

LOG: [flang][OpenMP] Allow 0 after directive sentinels (#217124)

Fixes #199877

Added: 
    flang/test/Parser/OpenMP/compiler-directive.f

Modified: 
    flang/lib/Parser/prescan.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Parser/prescan.cpp b/flang/lib/Parser/prescan.cpp
index cc58c5bd2c5e2..a545b8a807c6f 100644
--- a/flang/lib/Parser/prescan.cpp
+++ b/flang/lib/Parser/prescan.cpp
@@ -196,19 +196,21 @@ void Prescanner::Statement() {
       }
       tokens.CloseToken();
       SkipSpaces();
-      if (InConditionalLine() && inFixedForm_ && !tabInCurrentLine_ &&
-          column_ == 6 && *at_ != '\n') {
-        // !$   0   - turn '0' into a space
-        // !$   1   - turn '1' into '&'
+      if ((InConditionalLine() || IsOpenMPDirective()) && inFixedForm_ &&
+          !tabInCurrentLine_ && column_ == 6 && *at_ != '\n') {
         if (int n{IsSpace(at_)}; n || *at_ == '0') {
+          // !$   0   - turn '0' into a space
           at_ += n ? n : 1;
-        } else {
+          ++column_;
+          SkipSpaces();
+        } else if (InConditionalLine()) {
+          // !$   1   - turn '1' into '&'
           ++at_;
           EmitChar(tokens, '&');
           tokens.CloseToken();
+          ++column_;
+          SkipSpaces();
         }
-        ++column_;
-        SkipSpaces();
       }
     }
     break;

diff  --git a/flang/test/Parser/OpenMP/compiler-directive.f b/flang/test/Parser/OpenMP/compiler-directive.f
new file mode 100644
index 0000000000000..eaea3805b8a58
--- /dev/null
+++ b/flang/test/Parser/OpenMP/compiler-directive.f
@@ -0,0 +1,7 @@
+! RUN: %flang_fc1 -fopenmp -fdebug-unparse %s 2>&1 | FileCheck %s
+
+! CHECK: !$OMP PARALLEL
+! CHECK: !$OMP END PARALLEL
+c$omp0parallel
+c$omp0endparallel
+      end


        


More information about the flang-commits mailing list