Skip to content

Commit 3e0b91b

Browse files
authored
[OpenMP][clang] Fix CaptureRegion for message clause (#156525)
Fixes llvm/llvm-project#156232
1 parent 665e875 commit 3e0b91b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

clang/lib/Sema/SemaOpenMP.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16479,9 +16479,13 @@ OMPClause *SemaOpenMP::ActOnOpenMPMessageClause(Expr *ME,
1647916479

1648016480
Stmt *HelperValStmt = nullptr;
1648116481

16482+
// Depending on whether this clause appears in an executable context or not,
16483+
// we may or may not build a capture.
1648216484
OpenMPDirectiveKind DKind = DSAStack->getCurrentDirective();
16483-
OpenMPDirectiveKind CaptureRegion = getOpenMPCaptureRegionForClause(
16484-
DKind, OMPC_message, getLangOpts().OpenMP);
16485+
OpenMPDirectiveKind CaptureRegion =
16486+
DKind == OMPD_unknown ? OMPD_unknown
16487+
: getOpenMPCaptureRegionForClause(
16488+
DKind, OMPC_message, getLangOpts().OpenMP);
1648516489
if (CaptureRegion != OMPD_unknown &&
1648616490
!SemaRef.CurContext->isDependentContext()) {
1648716491
ME = SemaRef.MakeFullExpr(ME).get();

clang/test/OpenMP/error_message.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=51 -ferror-limit 100 %s -Wuninitialized
55
// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=60 -ferror-limit 100 %s -Wuninitialized
66

7+
// Test outside of an executable context.
8+
#pragma omp error severity(warning) message("msg") at(compilation) // expected-warning {{msg}}
9+
710
template <class T>
811
T tmain(T argc) {
912
if (argc)

0 commit comments

Comments
 (0)