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

via flang-commits flang-commits at lists.llvm.org
Fri Oct 13 00:37:23 PDT 2023


https://github.com/Z572 updated https://github.com/llvm/llvm-project/pull/68911

>From 1681881fd9e86a221c7794f5a4541d660034463b Mon Sep 17 00:00:00 2001
From: Zheng Junjie <zhengjunjie at iscas.ac.cn>
Date: Fri, 13 Oct 2023 14:37:54 +0800
Subject: [PATCH] [Flang][OpenMP] Fix comments that should not be Sentinels on
 fixed format.

---
 flang/lib/Parser/prescan.cpp         |  2 ++
 flang/test/Parser/OpenMP/sentinels.f | 43 ++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+)
 create mode 100644 flang/test/Parser/OpenMP/sentinels.f

diff --git a/flang/lib/Parser/prescan.cpp b/flang/lib/Parser/prescan.cpp
index 2f25b02bf7a323d..690e25d84318e06 100644
--- a/flang/lib/Parser/prescan.cpp
+++ b/flang/lib/Parser/prescan.cpp
@@ -1186,6 +1186,8 @@ Prescanner::IsFixedFormCompilerDirectiveLine(const char *start) const {
         break;
       }
       *sp++ = ToLowerCaseLetter(*p);
+    } else {
+      break;
     }
   }
   if (column == 6) {
diff --git a/flang/test/Parser/OpenMP/sentinels.f b/flang/test/Parser/OpenMP/sentinels.f
new file mode 100644
index 000000000000000..616f1e24b053a38
--- /dev/null
+++ b/flang/test/Parser/OpenMP/sentinels.f
@@ -0,0 +1,43 @@
+! RUN: %flang_fc1 -fopenmp -E %s | FileCheck %s
+! CHECK:      program main
+! CHECK:       interface
+! CHECK:        subroutine sub(a)
+! CHECK:!dir$ ignore_tkr a
+! CHECK:          real(4):: a
+! CHECK:        end subroutine
+! CHECK:       end interface
+! CHECK:
+! CHECK:
+! CHECK:
+! CHECK:
+! CHECK:      PRINT *, "Is '    '"
+! CHECK:  123 PRINT *, "Is '123 '"
+
+!@cuf subroutine atcuf;
+      program main
+       interface
+        subroutine sub(a)
+!dir$ ignore_tkr a
+          real(4):: a
+        end subroutine
+       end interface
+!
+!	comment line
+!@fp  PRINT *, "Is 'f p '"
+!@f p PRINT *, "Is 'f p '"
+!$    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