[flang-commits] [flang] 7de70e0 - [Flang][OpenMP] Fix comments that should not be Sentinels on fixed format. (#68911)

via flang-commits flang-commits at lists.llvm.org
Mon Oct 30 09:20:04 PDT 2023


Author: Z572
Date: 2023-10-31T00:20:00+08:00
New Revision: 7de70e0f724f7d0aec7ab0f78c648982989efc5b

URL: https://github.com/llvm/llvm-project/commit/7de70e0f724f7d0aec7ab0f78c648982989efc5b
DIFF: https://github.com/llvm/llvm-project/commit/7de70e0f724f7d0aec7ab0f78c648982989efc5b.diff

LOG: [Flang][OpenMP] Fix comments that should not be Sentinels on fixed format. (#68911)

Fixes #68653

Added: 
    flang/test/Parser/OpenMP/sentinels.f

Modified: 
    flang/lib/Parser/prescan.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Parser/prescan.cpp b/flang/lib/Parser/prescan.cpp
index 2f25b02bf7a323d..f61eff5b0dd6aa9 100644
--- a/flang/lib/Parser/prescan.cpp
+++ b/flang/lib/Parser/prescan.cpp
@@ -1177,16 +1177,14 @@ Prescanner::IsFixedFormCompilerDirectiveLine(const char *start) const {
   char sentinel[5], *sp{sentinel};
   int column{2};
   for (; column < 6; ++column, ++p) {
-    if (*p != ' ') {
-      if (*p == '\n' || *p == '\t') {
-        break;
-      }
-      if (sp == sentinel + 1 && sentinel[0] == '$' && IsDecimalDigit(*p)) {
-        // OpenMP conditional compilation line: leave the label alone
-        break;
-      }
-      *sp++ = ToLowerCaseLetter(*p);
+    if (*p == ' ' || *p == '\n' || *p == '\t') {
+      break;
+    }
+    if (sp == sentinel + 1 && sentinel[0] == '$' && IsDecimalDigit(*p)) {
+      // OpenMP conditional compilation line: leave the label alone
+      break;
     }
+    *sp++ = ToLowerCaseLetter(*p);
   }
   if (column == 6) {
     if (*p == ' ' || *p == '\t' || *p == '0') {

diff  --git a/flang/test/Parser/OpenMP/sentinels.f b/flang/test/Parser/OpenMP/sentinels.f
new file mode 100644
index 000000000000000..98d4bad19f6a274
--- /dev/null
+++ b/flang/test/Parser/OpenMP/sentinels.f
@@ -0,0 +1,42 @@
+! RUN: %flang_fc1 -fopenmp -E %s | FileCheck %s
+! CHECK:      program main
+! CHECK:       interface
+! CHECK:        subroutine sub(a, b)
+! CHECK:!dir$ ignore_tkr a
+! CHECK:!dir$ ignore_tkr b
+! CHECK:          real(4):: a, b
+! CHECK:        end subroutine
+! CHECK:       end interface
+! CHECK:      PRINT *, "Is '    '"
+! CHECK:  123 PRINT *, "Is '123 '"
+
+!@cuf subroutine atcuf;
+      program main
+       interface
+        subroutine sub(a, b)
+!dir$ ignore_tkr a
+!dir$ ignore_tkr
+!dir$+ b
+          real(4):: a, b
+        end subroutine
+       end interface
+!
+!	comment line
+!@fp  PRINT *, "This is a comment line"
+!@f p PRINT *, "This is a comment line"
+!$    PRINT *, "Is '    '"
+!$123 PRINT *, "Is '123 '"
+!$ABC PRINT *, "Is 'ABC '"
+! $    PRINT *, "This is a comment line 6"
+c    $This is a comment line
+!0$110This is a comment line
+
+! $ This is a comment line
+! $  0This is a comment line
+!    &This is a comment line
+!  $  This is a comment line
+! $   This is a comment line
+C $   This is a comment line
+c $   his is a comment line
+* $   This is a comment line
+      end


        


More information about the flang-commits mailing list