Skip to content

Commit 6b0f359

Browse files
committed
Fix signal during the call to checkOpenMPLoop.
The root problem is a null pointer is accessed during the call to checkOpenMPLoop, because loop up bound expr is an error expression due to error diagnostic was emit early. To fix this, in setLCDeclAndLB, setUB and setStep instead return false, return true when LB, UB or Step contains Error, so that the checking is stopped in checkOpenMPLoop. Differential Revision: https://reviews.llvm.org/D107385
1 parent 72661f3 commit 6b0f359

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

clang/lib/Sema/SemaOpenMP.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7342,7 +7342,7 @@ bool OpenMPIterationSpaceChecker::setLCDeclAndLB(ValueDecl *NewLCDecl,
73427342
// State consistency checking to ensure correct usage.
73437343
assert(LCDecl == nullptr && LB == nullptr && LCRef == nullptr &&
73447344
UB == nullptr && Step == nullptr && !TestIsLessOp && !TestIsStrictOp);
7345-
if (!NewLCDecl || !NewLB)
7345+
if (!NewLCDecl || !NewLB || NewLB->containsErrors())
73467346
return true;
73477347
LCDecl = getCanonicalDecl(NewLCDecl);
73487348
LCRef = NewLCRefExpr;
@@ -7365,7 +7365,7 @@ bool OpenMPIterationSpaceChecker::setUB(Expr *NewUB,
73657365
// State consistency checking to ensure correct usage.
73667366
assert(LCDecl != nullptr && LB != nullptr && UB == nullptr &&
73677367
Step == nullptr && !TestIsLessOp && !TestIsStrictOp);
7368-
if (!NewUB)
7368+
if (!NewUB || NewUB->containsErrors())
73697369
return true;
73707370
UB = NewUB;
73717371
if (LessOp)
@@ -7380,7 +7380,7 @@ bool OpenMPIterationSpaceChecker::setUB(Expr *NewUB,
73807380
bool OpenMPIterationSpaceChecker::setStep(Expr *NewStep, bool Subtract) {
73817381
// State consistency checking to ensure correct usage.
73827382
assert(LCDecl != nullptr && LB != nullptr && Step == nullptr);
7383-
if (!NewStep)
7383+
if (!NewStep || NewStep->containsErrors())
73847384
return true;
73857385
if (!NewStep->isValueDependent()) {
73867386
// Check that the step is integer expression.

clang/test/OpenMP/teams_distribute_loop_messages.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,4 +721,15 @@ void test_nowait() {
721721
for (int i = 0; i < 16; ++i)
722722
;
723723
}
724+
//expected-note@+1 {{candidate function not viable: requires single argument 'device_Id', but no arguments were provided}}
725+
int foo(int device_Id) {
726+
return 2;
727+
}
728+
729+
int main() {
730+
// expected-error@+1 {{no matching function for call to 'foo'}}
731+
const int globalWI{ foo() };
732+
#pragma omp target teams distribute
733+
for (int i=0 ; i<globalWI; i++) {}
734+
}
724735

0 commit comments

Comments
 (0)