Skip to content

Commit 38811be

Browse files
[Flang] [OpenMP] Add support for spaces in between the name (#168311)
Supports the fixed form syntax which has spaces in between the identifier
1 parent 17cbb48 commit 38811be

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

flang/lib/Parser/prescan.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,9 @@ bool Prescanner::NextToken(TokenSequence &tokens) {
845845
if (InFixedFormSource()) {
846846
SkipSpaces();
847847
}
848+
if (inFixedForm_ && (IsOpenMPDirective() && parenthesisNesting_ > 0)) {
849+
SkipSpaces();
850+
}
848851
if ((*at_ == '\'' || *at_ == '"') &&
849852
tokens.CharAt(tokens.SizeInChars() - 1) == '_') { // kind_"..."
850853
QuotedCharacterLiteral(tokens, start);

flang/lib/Parser/prescan.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ class Prescanner {
183183
bool InConditionalLine() const {
184184
return InOpenMPConditionalLine() || InOpenACCOrCUDAConditionalLine();
185185
}
186+
bool IsOpenMPDirective() const {
187+
return directiveSentinel_ && std::strcmp(directiveSentinel_, "$omp") == 0;
188+
}
186189
bool InFixedFormSource() const {
187190
return inFixedForm_ && !inPreprocessorDirective_ && !InCompilerDirective();
188191
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
! RUN: %flang_fc1 -fopenmp -fdebug-unparse-no-sema %s 2>&1 | FileCheck %s
2+
3+
program name_with_space
4+
!CHECK: !$OMP THREADPRIVATE(/cc/, var1)
5+
!$omp threadprivate(/c c/, var 1)
6+
7+
!CHECK: !$OMP PARALLEL PRIVATE(somevar,expr1,expr2) IF(expr2>expr1)
8+
!$omp parallel private(some var, expr 1, ex pr2)
9+
!$omp+ if (exp r2 > ex pr1)
10+
!$omp critical (x_x)
11+
print '(a)', 'Hello World'
12+
!CHECK: !$OMP END CRITICAL(x_x)
13+
!$omp end critical (x _x)
14+
!$omp end parallel
15+
end program name_with_space

0 commit comments

Comments
 (0)