[OpenACC] Fix Sema 'reduction' to allow arrays
Due to a mis-reading of the OpenACC spec, we weren't accepting arrays as a valid value to a reduction variable. This patch corrects that.
This commit is contained in:
parent
479ae4aa8f
commit
6cbcfb9a7c
@ -13318,8 +13318,9 @@ def err_acc_reduction_num_gangs_conflict
|
||||
"appear on a '%2' construct "
|
||||
"with a '%3' clause%select{ with more than 1 argument|}0">;
|
||||
def err_acc_reduction_type
|
||||
: Error<"OpenACC 'reduction' variable must be of scalar type, sub-array, or a "
|
||||
"composite of scalar types;%select{| sub-array base}1 type is %0">;
|
||||
: Error<"OpenACC 'reduction' variable must be of scalar type, aggregate, "
|
||||
"sub-array, or a composite of scalar types;%select{| sub-array "
|
||||
"base}1 type is %0">;
|
||||
def err_acc_reduction_composite_type
|
||||
: Error<"OpenACC 'reduction' variable must be a composite of scalar types; "
|
||||
"%1 %select{is not a class or struct|is incomplete|is not an "
|
||||
|
@ -1919,6 +1919,14 @@ ExprResult SemaOpenACC::CheckReductionVar(OpenACCDirectiveKind DirectiveKind,
|
||||
<< EltTy << /*Sub array base type*/ 1;
|
||||
return ExprError();
|
||||
}
|
||||
} else if (VarExpr->getType()->isArrayType()) {
|
||||
// Arrays are considered an 'aggregate variable' explicitly, so are OK, no
|
||||
// additional checking required.
|
||||
//
|
||||
// Glossary: Aggregate variables – a variable of any non-scalar datatype,
|
||||
// including array or composite variables.
|
||||
//
|
||||
// The next branch (record decl) checks for composite variables.
|
||||
} else if (auto *RD = VarExpr->getType()->getAsRecordDecl()) {
|
||||
if (!RD->isStruct() && !RD->isClass()) {
|
||||
Diag(VarExpr->getExprLoc(), diag::err_acc_reduction_composite_type)
|
||||
|
@ -68,7 +68,6 @@ void uses(unsigned Parm) {
|
||||
#pragma acc parallel reduction(&: ChC)
|
||||
while (1);
|
||||
|
||||
// expected-error@+1{{OpenACC 'reduction' variable must be of scalar type, sub-array, or a composite of scalar types; type is 'int[5]'}}
|
||||
#pragma acc parallel reduction(&: Array)
|
||||
while (1);
|
||||
|
||||
@ -76,7 +75,7 @@ void uses(unsigned Parm) {
|
||||
while (1);
|
||||
|
||||
struct CompositeHasComposite ChCArray[5];
|
||||
// expected-error@+1{{OpenACC 'reduction' variable must be of scalar type, sub-array, or a composite of scalar types; sub-array base type is 'struct CompositeHasComposite'}}
|
||||
// expected-error@+1{{OpenACC 'reduction' variable must be of scalar type, aggregate, sub-array, or a composite of scalar types; sub-array base type is 'struct CompositeHasComposite'}}
|
||||
#pragma acc parallel reduction(&: CoS, Array[I], ChCArray[0:I])
|
||||
while (1);
|
||||
|
||||
|
@ -70,7 +70,6 @@ void uses(unsigned Parm) {
|
||||
// expected-note@#COS_FIELD{{invalid field is here}}
|
||||
#pragma acc parallel reduction(&: ChC)
|
||||
while (1);
|
||||
// expected-error@+1{{OpenACC 'reduction' variable must be of scalar type, sub-array, or a composite of scalar types; type is 'int[5]'}}
|
||||
#pragma acc parallel reduction(&: Array)
|
||||
while (1);
|
||||
|
||||
@ -140,10 +139,8 @@ void TemplUses(T Parm, U CoS, V ChC) {
|
||||
// expected-note@#COS_FIELD{{invalid field is here}}
|
||||
#pragma acc parallel reduction(&: ChC)
|
||||
while (1);
|
||||
// expected-error@+1{{OpenACC 'reduction' variable must be of scalar type, sub-array, or a composite of scalar types; type is 'int[5]'}}
|
||||
#pragma acc parallel reduction(&: Array)
|
||||
while (1);
|
||||
// expected-error@+1{{OpenACC 'reduction' variable must be of scalar type, sub-array, or a composite of scalar types; type is 'int[5]'}}
|
||||
#pragma acc parallel reduction(&: NonDepArray)
|
||||
while (1);
|
||||
|
||||
|
@ -36,7 +36,6 @@ void uses() {
|
||||
|
||||
#pragma acc serial
|
||||
{
|
||||
// expected-error@+1{{OpenACC 'reduction' variable must be of scalar type, sub-array, or a composite of scalar types; type is 'int[5]'}}
|
||||
#pragma acc loop reduction(+:Array)
|
||||
for(int i = 0; i < 5; ++i){}
|
||||
}
|
||||
@ -172,7 +171,6 @@ void templ_uses() {
|
||||
|
||||
#pragma acc serial
|
||||
{
|
||||
// expected-error@+1{{OpenACC 'reduction' variable must be of scalar type, sub-array, or a composite of scalar types; type is 'int[5]'}}
|
||||
#pragma acc loop reduction(+:Array)
|
||||
for(int i = 0; i < 5; ++i){}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user