Skip to content

Commit 55d50a0

Browse files
committed
[clang][OpenMP] Treat "workshare" as unknown OpenMP directive
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 195fe59 commit 55d50a0

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
@@ -2738,6 +2738,11 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective(
27382738
Diag(Tok, diag::err_omp_unknown_directive);
27392739
return StmtError();
27402740
}
2741+
if (DKind == OMPD_workshare) {
2742+
// "workshare" is an executable, Fortran-only directive. Treat it
2743+
// as unknown.
2744+
DKind = OMPD_unknown;
2745+
}
27412746

27422747
StmtResult Directive = StmtError();
27432748

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)