Skip to content

Commit b89eb97

Browse files
authored
[Clang][OpenMP] Fix `!isNull() && "Cannot retrieve a NULL type pointer"' fail. (llvm#81015)
Fixes : llvm#69085 , llvm#69200 **PR SUMMARY**: "Added Null check for negative sized array and a test for the same"
1 parent 3115ad8 commit b89eb97

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

clang/lib/Sema/SemaOpenMP.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21124,6 +21124,8 @@ Sema::ActOnOpenMPDependClause(const OMPDependClause::DependDataTy &Data,
2112421124
ExprTy = ATy->getElementType();
2112521125
else
2112621126
ExprTy = BaseType->getPointeeType();
21127+
if (BaseType.isNull() || ExprTy.isNull())
21128+
return nullptr;
2112721129
ExprTy = ExprTy.getNonReferenceType();
2112821130
const Expr *Length = OASE->getLength();
2112921131
Expr::EvalResult Result;

clang/test/OpenMP/bug69085.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %clang_cc1 -verify -O0 -fopenmp-simd %s
2+
3+
int k[-1]; // expected-error {{'k' declared as an array with a negative size}}
4+
5+
void foo() {
6+
#pragma omp task depend(inout: k [:])
7+
{
8+
k[0] = 1;
9+
}
10+
}

0 commit comments

Comments
 (0)