[flang-commits] [flang] 38811be - [Flang] [OpenMP] Add support for spaces in between the name (#168311)
via flang-commits
flang-commits at lists.llvm.org
Mon Nov 17 07:54:59 PST 2025
Author: Thirumalai Shaktivel
Date: 2025-11-17T21:24:54+05:30
New Revision: 38811bea5a567b8b848735af7ed6bacd52d3a3dc
URL: https://github.com/llvm/llvm-project/commit/38811bea5a567b8b848735af7ed6bacd52d3a3dc
DIFF: https://github.com/llvm/llvm-project/commit/38811bea5a567b8b848735af7ed6bacd52d3a3dc.diff
LOG: [Flang] [OpenMP] Add support for spaces in between the name (#168311)
Supports the fixed form syntax which has spaces in between the
identifier
Added:
flang/test/Parser/OpenMP/name-with-space.f
Modified:
flang/lib/Parser/prescan.cpp
flang/lib/Parser/prescan.h
Removed:
################################################################################
diff --git a/flang/lib/Parser/prescan.cpp b/flang/lib/Parser/prescan.cpp
index 8cccd84f9fa19..5e8d50be277a0 100644
--- a/flang/lib/Parser/prescan.cpp
+++ b/flang/lib/Parser/prescan.cpp
@@ -845,6 +845,9 @@ bool Prescanner::NextToken(TokenSequence &tokens) {
if (InFixedFormSource()) {
SkipSpaces();
}
+ if (inFixedForm_ && (IsOpenMPDirective() && parenthesisNesting_ > 0)) {
+ SkipSpaces();
+ }
if ((*at_ == '\'' || *at_ == '"') &&
tokens.CharAt(tokens.SizeInChars() - 1) == '_') { // kind_"..."
QuotedCharacterLiteral(tokens, start);
diff --git a/flang/lib/Parser/prescan.h b/flang/lib/Parser/prescan.h
index 5e7481781d944..4f691d56975a9 100644
--- a/flang/lib/Parser/prescan.h
+++ b/flang/lib/Parser/prescan.h
@@ -183,6 +183,9 @@ class Prescanner {
bool InConditionalLine() const {
return InOpenMPConditionalLine() || InOpenACCOrCUDAConditionalLine();
}
+ bool IsOpenMPDirective() const {
+ return directiveSentinel_ && std::strcmp(directiveSentinel_, "$omp") == 0;
+ }
bool InFixedFormSource() const {
return inFixedForm_ && !inPreprocessorDirective_ && !InCompilerDirective();
}
diff --git a/flang/test/Parser/OpenMP/name-with-space.f b/flang/test/Parser/OpenMP/name-with-space.f
new file mode 100644
index 0000000000000..603ebc40c9f4c
--- /dev/null
+++ b/flang/test/Parser/OpenMP/name-with-space.f
@@ -0,0 +1,15 @@
+! RUN: %flang_fc1 -fopenmp -fdebug-unparse-no-sema %s 2>&1 | FileCheck %s
+
+ program name_with_space
+!CHECK: !$OMP THREADPRIVATE(/cc/, var1)
+!$omp threadprivate(/c c/, var 1)
+
+!CHECK: !$OMP PARALLEL PRIVATE(somevar,expr1,expr2) IF(expr2>expr1)
+!$omp parallel private(some var, expr 1, ex pr2)
+!$omp+ if (exp r2 > ex pr1)
+!$omp critical (x_x)
+ print '(a)', 'Hello World'
+!CHECK: !$OMP END CRITICAL(x_x)
+!$omp end critical (x _x)
+!$omp end parallel
+ end program name_with_space
More information about the flang-commits
mailing list