Skip to content

Commit 009afe8

Browse files
committed
Return null expr when a negative array was created.
Fix #69198
1 parent 24060db commit 009afe8

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

clang/lib/AST/Expr.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4983,10 +4983,10 @@ QualType OMPArraySectionExpr::getBaseOriginalType(const Expr *Base) {
49834983
for (unsigned Cnt = 0; Cnt < ArraySectionCount; ++Cnt) {
49844984
if (OriginalTy->isAnyPointerType())
49854985
OriginalTy = OriginalTy->getPointeeType();
4986-
else {
4987-
assert (OriginalTy->isArrayType());
4986+
else if (OriginalTy->isArrayType())
49884987
OriginalTy = OriginalTy->castAsArrayTypeUnsafe()->getElementType();
4989-
}
4988+
else
4989+
return {};
49904990
}
49914991
return OriginalTy;
49924992
}

clang/lib/Sema/SemaOpenMP.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21014,6 +21014,8 @@ Sema::ActOnOpenMPDependClause(const OMPDependClause::DependDataTy &Data,
2101421014
if (OASE) {
2101521015
QualType BaseType =
2101621016
OMPArraySectionExpr::getBaseOriginalType(OASE->getBase());
21017+
if (BaseType.isNull())
21018+
return nullptr;
2101721019
if (const auto *ATy = BaseType->getAsArrayTypeUnsafe())
2101821020
ExprTy = ATy->getElementType();
2101921021
else

clang/test/OpenMP/bug69198.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 -x c -triple x86_64-apple-darwin10 %s
2+
// expected-no-diagnostics
3+
4+
int c[-1];
5+
6+
void foo (){
7+
#pragma omp task depend(inout: c[:][:])
8+
}

0 commit comments

Comments
 (0)