Skip to content

Commit 6aae6d4

Browse files
committed
[OpenACC] Fix crash because of miscalculated dependence.
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.
1 parent 96b1dfb commit 6aae6d4

17 files changed

+35
-32
lines changed

clang/lib/Sema/SemaExpr.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21476,8 +21476,11 @@ ExprResult Sema::CheckPlaceholderExpr(Expr *E) {
2147621476

2147721477
// Expressions of unknown type.
2147821478
case BuiltinType::ArraySection:
21479-
Diag(E->getBeginLoc(), diag::err_array_section_use)
21480-
<< cast<ArraySectionExpr>(E)->isOMPArraySection();
21479+
// If we've already diagnosed something on the array section type, we
21480+
// shouldn't need to do any further diagnostic here.
21481+
if (!E->containsErrors())
21482+
Diag(E->getBeginLoc(), diag::err_array_section_use)
21483+
<< cast<ArraySectionExpr>(E)->isOMPArraySection();
2148121484
return ExprError();
2148221485

2148321486
// Expressions of unknown type.

clang/lib/Sema/SemaOpenACC.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,8 +1020,8 @@ ExprResult SemaOpenACC::ActOnArraySectionExpr(Expr *Base, SourceLocation LBLoc,
10201020
// If any part of the expression is dependent, return a dependent sub-array.
10211021
QualType ArrayExprTy = Context.ArraySectionTy;
10221022
if (Base->isTypeDependent() ||
1023-
(LowerBound && LowerBound->isInstantiationDependent()) ||
1024-
(Length && Length->isInstantiationDependent()))
1023+
(LowerBound && LowerBound->isTypeDependent()) ||
1024+
(Length && Length->isTypeDependent()))
10251025
ArrayExprTy = Context.DependentTy;
10261026

10271027
return new (Context)

clang/test/SemaOpenACC/combined-construct-copy-clause.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos
4747
#pragma acc parallel loop copy(ArrayParam[2:5])
4848
for(int i = 0; i < 5; ++i);
4949

50-
// expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
51-
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
50+
// expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
5251
#pragma acc parallel loop copy((float*)ArrayParam[2:5])
5352
for(int i = 0; i < 5; ++i);
5453
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}

clang/test/SemaOpenACC/combined-construct-copyin-clause.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos
4747
#pragma acc parallel loop copyin(ArrayParam[2:5])
4848
for(int i = 0; i < 5; ++i);
4949

50-
// expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
51-
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
50+
// expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
5251
#pragma acc parallel loop copyin((float*)ArrayParam[2:5])
5352
for(int i = 0; i < 5; ++i);
5453
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}

clang/test/SemaOpenACC/combined-construct-copyout-clause.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos
4747
#pragma acc parallel loop copyout(ArrayParam[2:5])
4848
for(int i = 0; i < 5; ++i);
4949

50-
// expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
51-
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
50+
// expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
5251
#pragma acc parallel loop copyout((float*)ArrayParam[2:5])
5352
for(int i = 0; i < 5; ++i);
5453
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}

clang/test/SemaOpenACC/combined-construct-create-clause.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos
4848
#pragma acc parallel loop create(ArrayParam[2:5])
4949
for(int i = 0; i < 5; ++i);
5050

51-
// expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
52-
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
51+
// expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
5352
#pragma acc parallel loop create((float*)ArrayParam[2:5])
5453
for(int i = 0; i < 5; ++i);
5554
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}

clang/test/SemaOpenACC/combined-construct-firstprivate-clause.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos
4848
#pragma acc parallel loop firstprivate(ArrayParam[2:5])
4949
for (int i = 5; i < 10; ++i);
5050

51-
// expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
52-
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
51+
// expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
5352
#pragma acc serial loop firstprivate((float*)ArrayParam[2:5])
5453
for (int i = 5; i < 10; ++i);
5554
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}

clang/test/SemaOpenACC/combined-construct-no_create-clause.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos
4747
#pragma acc parallel loop no_create(ArrayParam[2:5])
4848
for (unsigned i = 0; i < 5; ++i);
4949

50-
// expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
51-
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
50+
// expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
5251
#pragma acc parallel loop no_create((float*)ArrayParam[2:5])
5352
for (unsigned i = 0; i < 5; ++i);
5453
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}

clang/test/SemaOpenACC/combined-construct-present-clause.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos
4747
#pragma acc parallel loop present(ArrayParam[2:5])
4848
for(unsigned I = 0; I < 5; ++I);
4949

50-
// expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
51-
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
50+
// expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
5251
#pragma acc parallel loop present((float*)ArrayParam[2:5])
5352
for(unsigned I = 0; I < 5; ++I);
5453
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}

clang/test/SemaOpenACC/compute-construct-copy-clause.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete Compos
4747
#pragma acc parallel copy(ArrayParam[2:5])
4848
while(1);
4949

50-
// expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
51-
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
50+
// expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
5251
#pragma acc parallel copy((float*)ArrayParam[2:5])
5352
while(1);
5453
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}

0 commit comments

Comments
 (0)