aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Keane <ekeane@nvidia.com>2025-09-03 13:27:40 -0700
committerGitHub <noreply@github.com>2025-09-03 20:27:40 +0000
commit15e9306f6d97c743b6d3fc80cda2fe37b09f4961 (patch)
treea81fe23fefb41cc4c9cd7948b8957f57593b9158
parent30e5d87e5ecad25603349412556aa4284c2ad8bb (diff)
downloadllvm-15e9306f6d97c743b6d3fc80cda2fe37b09f4961.zip
llvm-15e9306f6d97c743b6d3fc80cda2fe37b09f4961.tar.gz
llvm-15e9306f6d97c743b6d3fc80cda2fe37b09f4961.tar.bz2
[OpenACC] Fix crash because of miscalculated dependence. (#156745)
We were causing ANY dependence to cause the return type of the array section to be dependent, when in reality it should only be so if one of its Bounds/Base are dependent. This patch fixes that.
-rw-r--r--clang/lib/Sema/SemaExpr.cpp7
-rw-r--r--clang/lib/Sema/SemaOpenACC.cpp4
-rw-r--r--clang/test/SemaOpenACC/combined-construct-copy-clause.cpp3
-rw-r--r--clang/test/SemaOpenACC/combined-construct-copyin-clause.cpp3
-rw-r--r--clang/test/SemaOpenACC/combined-construct-copyout-clause.cpp3
-rw-r--r--clang/test/SemaOpenACC/combined-construct-create-clause.cpp3
-rw-r--r--clang/test/SemaOpenACC/combined-construct-firstprivate-clause.cpp3
-rw-r--r--clang/test/SemaOpenACC/combined-construct-no_create-clause.cpp3
-rw-r--r--clang/test/SemaOpenACC/combined-construct-present-clause.cpp3
-rw-r--r--clang/test/SemaOpenACC/compute-construct-copy-clause.cpp3
-rw-r--r--clang/test/SemaOpenACC/compute-construct-copyin-clause.cpp3
-rw-r--r--clang/test/SemaOpenACC/compute-construct-copyout-clause.cpp3
-rw-r--r--clang/test/SemaOpenACC/compute-construct-create-clause.cpp3
-rw-r--r--clang/test/SemaOpenACC/compute-construct-firstprivate-clause.cpp3
-rw-r--r--clang/test/SemaOpenACC/compute-construct-no_create-clause.cpp3
-rw-r--r--clang/test/SemaOpenACC/compute-construct-present-clause.cpp3
-rw-r--r--clang/test/SemaOpenACC/compute-construct-private-clause.cpp14
17 files changed, 35 insertions, 32 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 55a21aa..317b7ca 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -21476,8 +21476,11 @@ ExprResult Sema::CheckPlaceholderExpr(Expr *E) {
// Expressions of unknown type.
case BuiltinType::ArraySection:
- Diag(E->getBeginLoc(), diag::err_array_section_use)
- << cast<ArraySectionExpr>(E)->isOMPArraySection();
+ // If we've already diagnosed something on the array section type, we
+ // shouldn't need to do any further diagnostic here.
+ if (!E->containsErrors())
+ Diag(E->getBeginLoc(), diag::err_array_section_use)
+ << cast<ArraySectionExpr>(E)->isOMPArraySection();
return ExprError();
// Expressions of unknown type.
diff --git a/clang/lib/Sema/SemaOpenACC.cpp b/clang/lib/Sema/SemaOpenACC.cpp
index 023be4e..5082e2c 100644
--- a/clang/lib/Sema/SemaOpenACC.cpp
+++ b/clang/lib/Sema/SemaOpenACC.cpp
@@ -1020,8 +1020,8 @@ ExprResult SemaOpenACC::ActOnArraySectionExpr(Expr *Base, SourceLocation LBLoc,
// If any part of the expression is dependent, return a dependent sub-array.
QualType ArrayExprTy = Context.ArraySectionTy;
if (Base->isTypeDependent() ||
- (LowerBound && LowerBound->isInstantiationDependent()) ||
- (Length && Length->isInstantiationDependent()))
+ (LowerBound && LowerBound->isTypeDependent()) ||
+ (Length && Length->isTypeDependent()))
ArrayExprTy = Context.DependentTy;
return new (Context)
diff --git a/clang/test/SemaOpenACC/combined-construct-copy-clause.cpp b/clang/test/SemaOpenACC/combined-construct-copy-clause.cpp
index 043a7ec..61c3c6a 100644
--- a/clang/test/SemaOpenACC/combined-construct-copy-clause.cpp
+++ b/clang/test/SemaOpenACC/combined-construct-copy-clause.cpp
@@ -47,8 +47,7 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos
#pragma acc parallel loop copy(ArrayParam[2:5])
for(int i = 0; i < 5; ++i);
- // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
- // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
+ // expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
#pragma acc parallel loop copy((float*)ArrayParam[2:5])
for(int i = 0; i < 5; ++i);
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
diff --git a/clang/test/SemaOpenACC/combined-construct-copyin-clause.cpp b/clang/test/SemaOpenACC/combined-construct-copyin-clause.cpp
index 9f9c2aa..c300fdb 100644
--- a/clang/test/SemaOpenACC/combined-construct-copyin-clause.cpp
+++ b/clang/test/SemaOpenACC/combined-construct-copyin-clause.cpp
@@ -47,8 +47,7 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos
#pragma acc parallel loop copyin(ArrayParam[2:5])
for(int i = 0; i < 5; ++i);
- // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
- // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
+ // expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
#pragma acc parallel loop copyin((float*)ArrayParam[2:5])
for(int i = 0; i < 5; ++i);
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
diff --git a/clang/test/SemaOpenACC/combined-construct-copyout-clause.cpp b/clang/test/SemaOpenACC/combined-construct-copyout-clause.cpp
index cc91ea4..a6eed4b 100644
--- a/clang/test/SemaOpenACC/combined-construct-copyout-clause.cpp
+++ b/clang/test/SemaOpenACC/combined-construct-copyout-clause.cpp
@@ -47,8 +47,7 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos
#pragma acc parallel loop copyout(ArrayParam[2:5])
for(int i = 0; i < 5; ++i);
- // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
- // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
+ // expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
#pragma acc parallel loop copyout((float*)ArrayParam[2:5])
for(int i = 0; i < 5; ++i);
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
diff --git a/clang/test/SemaOpenACC/combined-construct-create-clause.cpp b/clang/test/SemaOpenACC/combined-construct-create-clause.cpp
index 0c8f90e..c72c9b1 100644
--- a/clang/test/SemaOpenACC/combined-construct-create-clause.cpp
+++ b/clang/test/SemaOpenACC/combined-construct-create-clause.cpp
@@ -48,8 +48,7 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos
#pragma acc parallel loop create(ArrayParam[2:5])
for(int i = 0; i < 5; ++i);
- // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
- // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
+ // expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
#pragma acc parallel loop create((float*)ArrayParam[2:5])
for(int i = 0; i < 5; ++i);
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
diff --git a/clang/test/SemaOpenACC/combined-construct-firstprivate-clause.cpp b/clang/test/SemaOpenACC/combined-construct-firstprivate-clause.cpp
index 1b888ae..85bc3a2 100644
--- a/clang/test/SemaOpenACC/combined-construct-firstprivate-clause.cpp
+++ b/clang/test/SemaOpenACC/combined-construct-firstprivate-clause.cpp
@@ -48,8 +48,7 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos
#pragma acc parallel loop firstprivate(ArrayParam[2:5])
for (int i = 5; i < 10; ++i);
- // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
- // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
+ // expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
#pragma acc serial loop firstprivate((float*)ArrayParam[2:5])
for (int i = 5; i < 10; ++i);
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
diff --git a/clang/test/SemaOpenACC/combined-construct-no_create-clause.cpp b/clang/test/SemaOpenACC/combined-construct-no_create-clause.cpp
index f01c46e..e8b6b6e 100644
--- a/clang/test/SemaOpenACC/combined-construct-no_create-clause.cpp
+++ b/clang/test/SemaOpenACC/combined-construct-no_create-clause.cpp
@@ -47,8 +47,7 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos
#pragma acc parallel loop no_create(ArrayParam[2:5])
for (unsigned i = 0; i < 5; ++i);
- // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
- // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
+ // expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
#pragma acc parallel loop no_create((float*)ArrayParam[2:5])
for (unsigned i = 0; i < 5; ++i);
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
diff --git a/clang/test/SemaOpenACC/combined-construct-present-clause.cpp b/clang/test/SemaOpenACC/combined-construct-present-clause.cpp
index 814acf2..64d171b 100644
--- a/clang/test/SemaOpenACC/combined-construct-present-clause.cpp
+++ b/clang/test/SemaOpenACC/combined-construct-present-clause.cpp
@@ -47,8 +47,7 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos
#pragma acc parallel loop present(ArrayParam[2:5])
for(unsigned I = 0; I < 5; ++I);
- // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
- // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
+ // expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
#pragma acc parallel loop present((float*)ArrayParam[2:5])
for(unsigned I = 0; I < 5; ++I);
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
diff --git a/clang/test/SemaOpenACC/compute-construct-copy-clause.cpp b/clang/test/SemaOpenACC/compute-construct-copy-clause.cpp
index 2797927..eb35a21 100644
--- a/clang/test/SemaOpenACC/compute-construct-copy-clause.cpp
+++ b/clang/test/SemaOpenACC/compute-construct-copy-clause.cpp
@@ -47,8 +47,7 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos
#pragma acc parallel copy(ArrayParam[2:5])
while(1);
- // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
- // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
+ // expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
#pragma acc parallel copy((float*)ArrayParam[2:5])
while(1);
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
diff --git a/clang/test/SemaOpenACC/compute-construct-copyin-clause.cpp b/clang/test/SemaOpenACC/compute-construct-copyin-clause.cpp
index 74ce74a..8897e46 100644
--- a/clang/test/SemaOpenACC/compute-construct-copyin-clause.cpp
+++ b/clang/test/SemaOpenACC/compute-construct-copyin-clause.cpp
@@ -47,8 +47,7 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos
#pragma acc parallel copyin(ArrayParam[2:5])
while(1);
- // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
- // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
+ // expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
#pragma acc parallel copyin((float*)ArrayParam[2:5])
while(1);
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
diff --git a/clang/test/SemaOpenACC/compute-construct-copyout-clause.cpp b/clang/test/SemaOpenACC/compute-construct-copyout-clause.cpp
index c01dc1a..fae89b7 100644
--- a/clang/test/SemaOpenACC/compute-construct-copyout-clause.cpp
+++ b/clang/test/SemaOpenACC/compute-construct-copyout-clause.cpp
@@ -47,8 +47,7 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos
#pragma acc parallel copyout(ArrayParam[2:5])
while(1);
- // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
- // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
+ // expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
#pragma acc parallel copyout((float*)ArrayParam[2:5])
while(1);
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
diff --git a/clang/test/SemaOpenACC/compute-construct-create-clause.cpp b/clang/test/SemaOpenACC/compute-construct-create-clause.cpp
index 3ed1e1e..7d88785 100644
--- a/clang/test/SemaOpenACC/compute-construct-create-clause.cpp
+++ b/clang/test/SemaOpenACC/compute-construct-create-clause.cpp
@@ -47,8 +47,7 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos
#pragma acc parallel create(ArrayParam[2:5])
while(1);
- // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
- // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
+ // expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
#pragma acc parallel create((float*)ArrayParam[2:5])
while(1);
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
diff --git a/clang/test/SemaOpenACC/compute-construct-firstprivate-clause.cpp b/clang/test/SemaOpenACC/compute-construct-firstprivate-clause.cpp
index 4bee515..eab8629 100644
--- a/clang/test/SemaOpenACC/compute-construct-firstprivate-clause.cpp
+++ b/clang/test/SemaOpenACC/compute-construct-firstprivate-clause.cpp
@@ -48,8 +48,7 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos
#pragma acc parallel firstprivate(ArrayParam[2:5])
while(1);
- // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
- // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
+ // expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
#pragma acc parallel firstprivate((float*)ArrayParam[2:5])
while(1);
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
diff --git a/clang/test/SemaOpenACC/compute-construct-no_create-clause.cpp b/clang/test/SemaOpenACC/compute-construct-no_create-clause.cpp
index fa84b1f..9f9f1a9 100644
--- a/clang/test/SemaOpenACC/compute-construct-no_create-clause.cpp
+++ b/clang/test/SemaOpenACC/compute-construct-no_create-clause.cpp
@@ -47,8 +47,7 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos
#pragma acc parallel no_create(ArrayParam[2:5])
while(1);
- // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
- // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
+ // expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
#pragma acc parallel no_create((float*)ArrayParam[2:5])
while(1);
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
diff --git a/clang/test/SemaOpenACC/compute-construct-present-clause.cpp b/clang/test/SemaOpenACC/compute-construct-present-clause.cpp
index db230d0..2dedc61 100644
--- a/clang/test/SemaOpenACC/compute-construct-present-clause.cpp
+++ b/clang/test/SemaOpenACC/compute-construct-present-clause.cpp
@@ -47,8 +47,7 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos
#pragma acc parallel present(ArrayParam[2:5])
while(1);
- // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
- // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
+ // expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
#pragma acc parallel present((float*)ArrayParam[2:5])
while(1);
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
diff --git a/clang/test/SemaOpenACC/compute-construct-private-clause.cpp b/clang/test/SemaOpenACC/compute-construct-private-clause.cpp
index fb9e89a..88f0a68 100644
--- a/clang/test/SemaOpenACC/compute-construct-private-clause.cpp
+++ b/clang/test/SemaOpenACC/compute-construct-private-clause.cpp
@@ -158,3 +158,17 @@ void Inst() {
TemplUses(i, Arr, C); // #TEMPL_USES_INST
NTTP<5, NTTP_REFed>(); // #NTTP_INST
}
+
+template<typename T>
+void ThisCrashed(unsigned A, unsigned B) {
+ T ***ThreePtr;
+ // expected-error@+1 2{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}}
+#pragma acc parallel private(ThreePtr[A:B][B][B])
+ ;
+}
+
+void inst_crash() {
+ // expected-note@+1{{in instantiation}}
+ ThisCrashed<int>(1, 2);
+}
+