[flang-commits] [flang] [flang][OpenMP] Allow 0 after directive sentinels (PR #217124)
Leandro Lupori via flang-commits
flang-commits at lists.llvm.org
Fri Aug 21 10:24:04 PDT 2026
https://github.com/luporl updated https://github.com/llvm/llvm-project/pull/217124
>From 5fd99432337075a7f901c2afd2cc1c758a72e57e Mon Sep 17 00:00:00 2001
From: Leandro Lupori <leandro.lupori at linaro.org>
Date: Tue, 18 Aug 2026 17:20:47 -0300
Subject: [PATCH] [flang][OpenMP] Allow 0 after directive sentinels
Fixes #199877
---
flang/lib/Parser/prescan.cpp | 16 +++++++++-------
flang/test/Parser/OpenMP/compiler-directive.f | 7 +++++++
2 files changed, 16 insertions(+), 7 deletions(-)
create mode 100644 flang/test/Parser/OpenMP/compiler-directive.f
diff --git a/flang/lib/Parser/prescan.cpp b/flang/lib/Parser/prescan.cpp
index 262954d32f266..8aa3a8b2a9096 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