mirror of
https://github.com/intel/llvm.git
synced 2026-01-18 16:50:51 +08:00
[OpenACC] Reject pointers in reduction and reduction composites
Pointers don't have a valid way of comparing them/multiplying/etc, so we are just going to disallow them.
This commit is contained in:
@@ -1968,7 +1968,8 @@ ExprResult SemaOpenACC::CheckReductionVar(OpenACCDirectiveKind DirectiveKind,
|
||||
}
|
||||
|
||||
auto IsValidMemberOfComposite = [](QualType Ty) {
|
||||
return Ty->isDependentType() || Ty->isScalarType();
|
||||
return Ty->isDependentType() ||
|
||||
(Ty->isScalarType() && !Ty->isPointerType());
|
||||
};
|
||||
|
||||
auto EmitDiags = [&](SourceLocation Loc, PartialDiagnostic PD) {
|
||||
|
||||
@@ -386,27 +386,18 @@ void foo() {
|
||||
#pragma acc serial loop vector
|
||||
for(int i = 0;i<5;++i);
|
||||
|
||||
//CHECK: #pragma acc parallel loop reduction(+: iPtr)
|
||||
#pragma acc parallel loop reduction(+: iPtr)
|
||||
for(int i = 0;i<5;++i);
|
||||
//CHECK: #pragma acc serial loop reduction(*: i)
|
||||
#pragma acc serial loop reduction(*: i)
|
||||
for(int i = 0;i<5;++i);
|
||||
//CHECK: #pragma acc kernels loop reduction(max: SomeB)
|
||||
#pragma acc kernels loop reduction(max: SomeB)
|
||||
for(int i = 0;i<5;++i);
|
||||
//CHECK: #pragma acc parallel loop reduction(min: iPtr)
|
||||
#pragma acc parallel loop reduction(min: iPtr)
|
||||
for(int i = 0;i<5;++i);
|
||||
//CHECK: #pragma acc serial loop reduction(&: i)
|
||||
#pragma acc serial loop reduction(&: i)
|
||||
for(int i = 0;i<5;++i);
|
||||
//CHECK: #pragma acc kernels loop reduction(|: SomeB)
|
||||
#pragma acc kernels loop reduction(|: SomeB)
|
||||
for(int i = 0;i<5;++i);
|
||||
//CHECK: #pragma acc parallel loop reduction(^: iPtr)
|
||||
#pragma acc parallel loop reduction(^: iPtr)
|
||||
for(int i = 0;i<5;++i);
|
||||
//CHECK: #pragma acc serial loop reduction(&&: i)
|
||||
#pragma acc serial loop reduction(&&: i)
|
||||
for(int i = 0;i<5;++i);
|
||||
|
||||
@@ -135,27 +135,18 @@ void foo() {
|
||||
#pragma acc parallel device_type (host)
|
||||
while(true);
|
||||
|
||||
//CHECK: #pragma acc parallel reduction(+: iPtr)
|
||||
#pragma acc parallel reduction(+: iPtr)
|
||||
while(true);
|
||||
//CHECK: #pragma acc parallel reduction(*: i)
|
||||
#pragma acc parallel reduction(*: i)
|
||||
while(true);
|
||||
//CHECK: #pragma acc parallel reduction(max: SomeB)
|
||||
#pragma acc parallel reduction(max: SomeB)
|
||||
while(true);
|
||||
//CHECK: #pragma acc parallel reduction(min: iPtr)
|
||||
#pragma acc parallel reduction(min: iPtr)
|
||||
while(true);
|
||||
//CHECK: #pragma acc parallel reduction(&: i)
|
||||
#pragma acc parallel reduction(&: i)
|
||||
while(true);
|
||||
//CHECK: #pragma acc parallel reduction(|: SomeB)
|
||||
#pragma acc parallel reduction(|: SomeB)
|
||||
while(true);
|
||||
//CHECK: #pragma acc parallel reduction(^: iPtr)
|
||||
#pragma acc parallel reduction(^: iPtr)
|
||||
while(true);
|
||||
//CHECK: #pragma acc parallel reduction(&&: i)
|
||||
#pragma acc parallel reduction(&&: i)
|
||||
while(true);
|
||||
|
||||
@@ -291,30 +291,20 @@ void foo() {
|
||||
#pragma acc loop vector
|
||||
for(int i = 0;i<5;++i);
|
||||
|
||||
int *iPtr;
|
||||
bool SomeB;
|
||||
|
||||
//CHECK: #pragma acc loop reduction(+: iPtr)
|
||||
#pragma acc loop reduction(+: iPtr)
|
||||
for(int i = 0;i<5;++i);
|
||||
//CHECK: #pragma acc loop reduction(*: i)
|
||||
#pragma acc loop reduction(*: i)
|
||||
for(int i = 0;i<5;++i);
|
||||
//CHECK: #pragma acc loop reduction(max: SomeB)
|
||||
#pragma acc loop reduction(max: SomeB)
|
||||
for(int i = 0;i<5;++i);
|
||||
//CHECK: #pragma acc loop reduction(min: iPtr)
|
||||
#pragma acc loop reduction(min: iPtr)
|
||||
for(int i = 0;i<5;++i);
|
||||
//CHECK: #pragma acc loop reduction(&: i)
|
||||
#pragma acc loop reduction(&: i)
|
||||
for(int i = 0;i<5;++i);
|
||||
//CHECK: #pragma acc loop reduction(|: SomeB)
|
||||
#pragma acc loop reduction(|: SomeB)
|
||||
for(int i = 0;i<5;++i);
|
||||
//CHECK: #pragma acc loop reduction(^: iPtr)
|
||||
#pragma acc loop reduction(^: iPtr)
|
||||
for(int i = 0;i<5;++i);
|
||||
//CHECK: #pragma acc loop reduction(&&: i)
|
||||
#pragma acc loop reduction(&&: i)
|
||||
for(int i = 0;i<5;++i);
|
||||
|
||||
@@ -723,7 +723,7 @@ void VarListClauses() {
|
||||
}
|
||||
|
||||
void ReductionClauseParsing() {
|
||||
char *Begin, *End;
|
||||
char Begin, End;
|
||||
// expected-error@+1{{expected '('}}
|
||||
#pragma acc serial reduction
|
||||
for(int i = 0; i < 5;++i) {}
|
||||
|
||||
@@ -112,6 +112,39 @@ void uses(unsigned Parm) {
|
||||
// expected-note@+1{{OpenACC 'reduction' variable reference must be a scalar variable or a composite of scalars, or an array, sub-array, or element of scalar types}}
|
||||
#pragma acc parallel reduction(+:CoCArr[1:1])
|
||||
while (1);
|
||||
|
||||
int *IPtr;
|
||||
// expected-error@+2{{invalid type 'int *' used in OpenACC 'reduction' variable reference; type is not a scalar value, or array of scalars, or composite of scalars}}
|
||||
// expected-note@+1{{OpenACC 'reduction' variable reference must be a scalar variable or a composite of scalars, or an array, sub-array, or element of scalar types}}
|
||||
#pragma acc parallel reduction(+:IPtr)
|
||||
while (1);
|
||||
#pragma acc parallel reduction(+:IPtr[1])
|
||||
while (1);
|
||||
#pragma acc parallel reduction(+:IPtr[1:1])
|
||||
while (1);
|
||||
|
||||
int *IPtrArr[5];
|
||||
// expected-error@+3{{invalid type 'int *' used in OpenACC 'reduction' variable reference; type is not a scalar value, or array of scalars, or composite of scalars}}
|
||||
// expected-note@+2{{used as element type of array type 'int *'}}
|
||||
// expected-note@+1{{OpenACC 'reduction' variable reference must be a scalar variable or a composite of scalars, or an array, sub-array, or element of scalar types}}
|
||||
#pragma acc parallel reduction(+:IPtrArr)
|
||||
while (1);
|
||||
|
||||
struct HasPtr { int *I; }; // #HASPTR
|
||||
HasPtr HP;
|
||||
// expected-error@+3{{invalid type 'int *' used in OpenACC 'reduction' variable reference; type is not a scalar value}}
|
||||
// expected-note@#HASPTR{{used as field 'I' of composite 'HasPtr'}}
|
||||
// expected-note@+1{{OpenACC 'reduction' variable reference must be a scalar variable or a composite of scalars, or an array, sub-array, or element of scalar types}}
|
||||
#pragma acc parallel reduction(+:HP)
|
||||
while (1);
|
||||
|
||||
HasPtr HPArr[5];
|
||||
// expected-error@+4{{invalid type 'int *' used in OpenACC 'reduction' variable reference; type is not a scalar value}}
|
||||
// expected-note@+3{{used as element type of array type 'HasPtr'}}
|
||||
// expected-note@#HASPTR{{used as field 'I' of composite 'HasPtr'}}
|
||||
// expected-note@+1{{OpenACC 'reduction' variable reference must be a scalar variable or a composite of scalars, or an array, sub-array, or element of scalar types}}
|
||||
#pragma acc parallel reduction(+:HPArr)
|
||||
while (1);
|
||||
}
|
||||
|
||||
template<typename T, typename U, typename V>
|
||||
|
||||
Reference in New Issue
Block a user