[flang-commits] [flang] [flang] Fix issue when macro is followed by OpenMP pragma (PR #123035)

via flang-commits flang-commits at lists.llvm.org
Wed Jan 15 03:37:19 PST 2025


https://github.com/shivaramaarao updated https://github.com/llvm/llvm-project/pull/123035

>From 4265517cf597dfaed7b4f9ca4131bc4226b80de9 Mon Sep 17 00:00:00 2001
From: Shivarama Rao <shivarama.rao at amd.com>
Date: Wed, 15 Jan 2025 09:44:04 +0000
Subject: [PATCH] When calling IsCompilerDirectiveSentinel,the prefix comment
 character need to be skipped.

Fixes #117693
---
 flang/lib/Parser/prescan.cpp           |  2 +-
 flang/test/Preprocessing/bug117693.f90 | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
 create mode 100644 flang/test/Preprocessing/bug117693.f90

diff --git a/flang/lib/Parser/prescan.cpp b/flang/lib/Parser/prescan.cpp
index c5939a1e0b6c2c..b928ed03a2493c 100644
--- a/flang/lib/Parser/prescan.cpp
+++ b/flang/lib/Parser/prescan.cpp
@@ -511,7 +511,7 @@ bool Prescanner::MustSkipToEndOfLine() const {
   if (inFixedForm_ && column_ > fixedFormColumnLimit_ && !tabInCurrentLine_) {
     return true; // skip over ignored columns in right margin (73:80)
   } else if (*at_ == '!' && !inCharLiteral_) {
-    return !IsCompilerDirectiveSentinel(at_);
+    return !IsCompilerDirectiveSentinel(at_ + 1);
   } else {
     return false;
   }
diff --git a/flang/test/Preprocessing/bug117693.f90 b/flang/test/Preprocessing/bug117693.f90
new file mode 100644
index 00000000000000..ced7927606e623
--- /dev/null
+++ b/flang/test/Preprocessing/bug117693.f90
@@ -0,0 +1,14 @@
+! RUN: %flang -fopenmp -E %s 2>&1 | FileCheck %s
+!CHECK: !$OMP DO SCHEDULE(STATIC)
+program main
+IMPLICIT NONE
+INTEGER:: I
+#define OMPSUPPORT
+!$ INTEGER :: omp_id
+!$OMP PARALLEL DO
+OMPSUPPORT !$OMP DO SCHEDULE(STATIC)
+DO I=1,100
+print *, omp_id
+ENDDO
+!$OMP END PARALLEL DO
+end program



More information about the flang-commits mailing list