Skip to content

Commit 1d594fd

Browse files
[Clang][OpenMP] Fixing Clang error for metadirective with multiple when clauses and no otherwise (#148583)
Fixing - #147336
1 parent ff8b4f8 commit 1d594fd

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

clang/lib/Parse/ParseOpenMP.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2704,7 +2704,7 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective(
27042704
// If no match is found and no otherwise clause is present, skip
27052705
// OMP5.2 Chapter 7.4: If no otherwise clause is specified the effect is as
27062706
// if one was specified without an associated directive variant.
2707-
if (BestIdx == -1 && Idx == 1) {
2707+
if (BestIdx == -1 && Idx > 0) {
27082708
assert(Tok.is(tok::annot_pragma_openmp_end) &&
27092709
"Expecting the end of the pragma here");
27102710
ConsumeAnnotationToken();

clang/test/OpenMP/metadirective_messages.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ void foo() {
4747
;
4848
#pragma omp metadirective when(device = {arch(nvptx)} : parallel) xyz() //expected-error {{expected at least one clause on '#pragma omp metadirective' directive}}
4949
;
50+
int a = 0;
51+
int b = 1;
52+
#pragma omp metadirective when(user={condition(a)}: parallel for simd) when(user={condition(b)}: target teams distribute parallel for simd)
53+
for (int i = 0; i < 10; ++i) {}
5054
#endif
5155
}
5256

0 commit comments

Comments
 (0)