| 1 |
// RUN: %clang_cc1 %s -fopenacc -verify |
| 2 |
|
| 3 |
enum SomeE{}; |
| 4 |
typedef struct IsComplete { |
| 5 |
struct S { int A; } CompositeMember; |
| 6 |
int ScalarMember; |
| 7 |
float ArrayMember[5]; |
| 8 |
SomeE EnumMember; |
| 9 |
char *PointerMember; |
| 10 |
} Complete; |
| 11 |
|
| 12 |
void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete CompositeParam, int &IntParamRef) { |
| 13 |
int LocalInt; |
| 14 |
char *LocalPointer; |
| 15 |
float LocalArray[5]; |
| 16 |
// Check Appertainment: |
| 17 |
#pragma acc parallel loop copyin(LocalInt) |
| 18 |
for(int i = 0; i < 5; ++i); |
| 19 |
#pragma acc serial loop copyin(LocalInt) |
| 20 |
for(int i = 0; i < 5; ++i); |
| 21 |
#pragma acc kernels loop copyin(LocalInt) |
| 22 |
for(int i = 0; i < 5; ++i); |
| 23 |
|
| 24 |
// Valid cases: |
| 25 |
#pragma acc parallel loop copyin(LocalInt, LocalPointer, LocalArray) |
| 26 |
for(int i = 0; i < 5; ++i); |
| 27 |
#pragma acc parallel loop copyin(LocalArray[2:1]) |
| 28 |
for(int i = 0; i < 5; ++i); |
| 29 |
|
| 30 |
Complete LocalComposite2; |
| 31 |
#pragma acc parallel loop copyin(LocalComposite2.ScalarMember, LocalComposite2.ScalarMember) |
| 32 |
for(int i = 0; i < 5; ++i); |
| 33 |
|
| 34 |
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} |
| 35 |
#pragma acc parallel loop copyin(1 + IntParam) |
| 36 |
for(int i = 0; i < 5; ++i); |
| 37 |
|
| 38 |
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} |
| 39 |
#pragma acc parallel loop copyin(+IntParam) |
| 40 |
for(int i = 0; i < 5; ++i); |
| 41 |
|
| 42 |
// expected-error@+1{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}} |
| 43 |
#pragma acc parallel loop copyin(PointerParam[2:]) |
| 44 |
for(int i = 0; i < 5; ++i); |
| 45 |
|
| 46 |
// expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} |
| 47 |
#pragma acc parallel loop copyin(ArrayParam[2:5]) |
| 48 |
for(int i = 0; i < 5; ++i); |
| 49 |
|
| 50 |
// expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}} |
| 51 |
#pragma acc parallel loop copyin((float*)ArrayParam[2:5]) |
| 52 |
for(int i = 0; i < 5; ++i); |
| 53 |
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} |
| 54 |
#pragma acc parallel loop copyin((float)ArrayParam[2]) |
| 55 |
for(int i = 0; i < 5; ++i); |
| 56 |
} |
| 57 |
|
| 58 |
template<typename T, unsigned I, typename V> |
| 59 |
void TemplUses(T t, T (&arrayT)[I], V TemplComp) { |
| 60 |
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} |
| 61 |
#pragma acc parallel loop copyin(+t) |
| 62 |
for(int i = 0; i < 5; ++i); |
| 63 |
|
| 64 |
// NTTP's are only valid if it is a reference to something. |
| 65 |
// expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} |
| 66 |
// expected-note@#TEMPL_USES_INST{{in instantiation of}} |
| 67 |
#pragma acc parallel loop copyin(I) |
| 68 |
for(int i = 0; i < 5; ++i); |
| 69 |
|
| 70 |
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} |
| 71 |
#pragma acc parallel loop copyin(t, I) |
| 72 |
for(int i = 0; i < 5; ++i); |
| 73 |
|
| 74 |
#pragma acc parallel loop copyin(arrayT) |
| 75 |
for(int i = 0; i < 5; ++i); |
| 76 |
|
| 77 |
#pragma acc parallel loop copyin(TemplComp) |
| 78 |
for(int i = 0; i < 5; ++i); |
| 79 |
|
| 80 |
#pragma acc parallel loop copyin(TemplComp.PointerMember[5]) |
| 81 |
for(int i = 0; i < 5; ++i); |
| 82 |
int *Pointer; |
| 83 |
#pragma acc parallel loop copyin(Pointer[:I]) |
| 84 |
for(int i = 0; i < 5; ++i); |
| 85 |
#pragma acc parallel loop copyin(Pointer[:t]) |
| 86 |
for(int i = 0; i < 5; ++i); |
| 87 |
// expected-error@+1{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}} |
| 88 |
#pragma acc parallel loop copyin(Pointer[1:]) |
| 89 |
for(int i = 0; i < 5; ++i); |
| 90 |
} |
| 91 |
|
| 92 |
template<unsigned I, auto &NTTP_REF> |
| 93 |
void NTTP() { |
| 94 |
// NTTP's are only valid if it is a reference to something. |
| 95 |
// expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} |
| 96 |
// expected-note@#NTTP_INST{{in instantiation of}} |
| 97 |
#pragma acc parallel loop copyin(I) |
| 98 |
for(int i = 0; i < 5; ++i); |
| 99 |
|
| 100 |
#pragma acc parallel loop copyin(NTTP_REF) |
| 101 |
for(int i = 0; i < 5; ++i); |
| 102 |
} |
| 103 |
|
| 104 |
void Inst() { |
| 105 |
static constexpr int NTTP_REFed = 1; |
| 106 |
int i; |
| 107 |
int Arr[5]; |
| 108 |
Complete C; |
| 109 |
TemplUses(i, Arr, C); // #TEMPL_USES_INST |
| 110 |
NTTP<5, NTTP_REFed>(); // #NTTP_INST |
| 111 |
} |