| 1 |
// RUN: %clang_cc1 %s -fopenacc -verify |
| 2 |
|
| 3 |
typedef struct IsComplete { |
| 4 |
struct S { int A; } CompositeMember; |
| 5 |
int ScalarMember; |
| 6 |
float ArrayMember[5]; |
| 7 |
void *PointerMember; |
| 8 |
} Complete; |
| 9 |
void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete CompositeParam) { |
| 10 |
int LocalInt; |
| 11 |
short *LocalPointer; |
| 12 |
float LocalArray[5]; |
| 13 |
Complete LocalComposite; |
| 14 |
// Check Appertainment: |
| 15 |
#pragma acc parallel loop create(LocalInt) |
| 16 |
for(int i = 0; i < 5; ++i); |
| 17 |
#pragma acc serial loop create(LocalInt) |
| 18 |
for(int i = 0; i < 5; ++i); |
| 19 |
#pragma acc kernels loop create(LocalInt) |
| 20 |
for(int i = 0; i < 5; ++i); |
| 21 |
|
| 22 |
// expected-warning@+1{{OpenACC clause name 'pcreate' is a deprecated clause name and is now an alias for 'create'}} |
| 23 |
#pragma acc parallel loop pcreate(LocalInt) |
| 24 |
for(int i = 0; i < 5; ++i); |
| 25 |
|
| 26 |
// expected-warning@+1{{OpenACC clause name 'present_or_create' is a deprecated clause name and is now an alias for 'create'}} |
| 27 |
#pragma acc parallel loop present_or_create(LocalInt) |
| 28 |
for(int i = 0; i < 5; ++i); |
| 29 |
|
| 30 |
// Valid cases: |
| 31 |
#pragma acc parallel loop create(LocalInt, LocalPointer, LocalArray) |
| 32 |
for(int i = 0; i < 5; ++i); |
| 33 |
#pragma acc parallel loop create(LocalArray[2:1]) |
| 34 |
for(int i = 0; i < 5; ++i); |
| 35 |
#pragma acc parallel loop create(zero:LocalArray[2:1]) |
| 36 |
for(int i = 0; i < 5; ++i); |
| 37 |
|
| 38 |
#pragma acc parallel loop create(LocalComposite.ScalarMember, LocalComposite.ScalarMember) |
| 39 |
for(int i = 0; i < 5; ++i); |
| 40 |
|
| 41 |
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} |
| 42 |
#pragma acc parallel loop create(1 + IntParam) |
| 43 |
for(int i = 0; i < 5; ++i); |
| 44 |
|
| 45 |
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} |
| 46 |
#pragma acc parallel loop create(+IntParam) |
| 47 |
for(int i = 0; i < 5; ++i); |
| 48 |
|
| 49 |
// expected-error@+1{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}} |
| 50 |
#pragma acc parallel loop create(PointerParam[2:]) |
| 51 |
for(int i = 0; i < 5; ++i); |
| 52 |
|
| 53 |
// expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} |
| 54 |
#pragma acc parallel loop create(ArrayParam[2:5]) |
| 55 |
for(int i = 0; i < 5; ++i); |
| 56 |
|
| 57 |
// expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} |
| 58 |
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} |
| 59 |
#pragma acc parallel loop create((float*)ArrayParam[2:5]) |
| 60 |
for(int i = 0; i < 5; ++i); |
| 61 |
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} |
| 62 |
#pragma acc parallel loop create((float)ArrayParam[2]) |
| 63 |
for(int i = 0; i < 5; ++i); |
| 64 |
// expected-error@+2{{unknown modifier 'invalid' in OpenACC modifier-list on 'create' clause}} |
| 65 |
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} |
| 66 |
#pragma acc parallel loop create(invalid:(float)ArrayParam[2]) |
| 67 |
for(int i = 0; i < 5; ++i); |
| 68 |
|
| 69 |
// expected-error@+1{{OpenACC 'create' clause is not valid on 'loop' directive}} |
| 70 |
#pragma acc loop create(LocalInt) |
| 71 |
for(int i = 5; i < 10;++i); |
| 72 |
// expected-error@+1{{OpenACC 'pcreate' clause is not valid on 'loop' directive}} |
| 73 |
#pragma acc loop pcreate(LocalInt) |
| 74 |
for(int i = 5; i < 10;++i); |
| 75 |
// expected-error@+1{{OpenACC 'present_or_create' clause is not valid on 'loop' directive}} |
| 76 |
#pragma acc loop present_or_create(LocalInt) |
| 77 |
for(int i = 5; i < 10;++i); |
| 78 |
} |
| 79 |
|
| 80 |
void ModList() { |
| 81 |
int V1; |
| 82 |
// expected-error@+4{{OpenACC 'always' modifier not valid on 'create' clause}} |
| 83 |
// expected-error@+3{{OpenACC 'alwaysin' modifier not valid on 'create' clause}} |
| 84 |
// expected-error@+2{{OpenACC 'alwaysout' modifier not valid on 'create' clause}} |
| 85 |
// expected-error@+1{{OpenACC 'readonly' modifier not valid on 'create' clause}} |
| 86 |
#pragma acc parallel loop create(always, alwaysin, alwaysout, zero, readonly: V1) |
| 87 |
for(int i = 5; i < 10;++i); |
| 88 |
// expected-error@+1{{OpenACC 'always' modifier not valid on 'create' clause}} |
| 89 |
#pragma acc serial loop create(always: V1) |
| 90 |
for(int i = 5; i < 10;++i); |
| 91 |
// expected-error@+1{{OpenACC 'alwaysin' modifier not valid on 'create' clause}} |
| 92 |
#pragma acc kernels loop create(alwaysin: V1) |
| 93 |
for(int i = 5; i < 10;++i); |
| 94 |
// expected-error@+1{{OpenACC 'alwaysout' modifier not valid on 'create' clause}} |
| 95 |
#pragma acc parallel loop create(alwaysout: V1) |
| 96 |
for(int i = 5; i < 10;++i); |
| 97 |
// expected-error@+1{{OpenACC 'readonly' modifier not valid on 'create' clause}} |
| 98 |
#pragma acc serial loop create(readonly: V1) |
| 99 |
for(int i = 5; i < 10;++i); |
| 100 |
#pragma acc kernels loop create(zero: V1) |
| 101 |
for(int i = 5; i < 10;++i); |
| 102 |
#pragma acc parallel loop create(capture:V1) |
| 103 |
for(int i = 5; i < 10;++i); |
| 104 |
} |