Skip to content

Commit 3abd77a

Browse files
authored
[clang][OpenMP] Treat "workshare" as unknown OpenMP directive (#139793)
The "workshare" construct is only present in Fortran. The common OpenMP code does treat it as any other directive, but in clang we need to reject it, and do so gracefully before it encounters an internal assertion. Fixes #139424
1 parent b96c5df commit 3abd77a

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

clang/lib/Parse/ParseOpenMP.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2613,6 +2613,11 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective(
26132613
Diag(Tok, diag::err_omp_unknown_directive);
26142614
return StmtError();
26152615
}
2616+
if (DKind == OMPD_workshare) {
2617+
// "workshare" is an executable, Fortran-only directive. Treat it
2618+
// as unknown.
2619+
DKind = OMPD_unknown;
2620+
}
26162621

26172622
StmtResult Directive = StmtError();
26182623

clang/test/OpenMP/openmp_workshare.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - %s
2+
3+
// Workshare is a Fortran-only directive.
4+
5+
void foo() {
6+
#pragma omp workshare // expected-error {{expected an OpenMP directive}}
7+
}
8+

0 commit comments

Comments
 (0)