| 1 |
// RUN: %clang_cc1 %s -fopenacc -verify |
| 2 |
|
| 3 |
struct Incomplete; |
| 4 |
enum SomeE{}; |
| 5 |
typedef struct IsComplete { |
| 6 |
struct S { int A; } CompositeMember; |
| 7 |
int ScalarMember; |
| 8 |
float ArrayMember[5]; |
| 9 |
SomeE EnumMember; |
| 10 |
char *PointerMember; |
| 11 |
} Complete; |
| 12 |
|
| 13 |
int GlobalInt; |
| 14 |
float GlobalArray[5]; |
| 15 |
char *GlobalPointer; |
| 16 |
Complete GlobalComposite; |
| 17 |
|
| 18 |
void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete CompositeParam, int &IntParamRef) { |
| 19 |
int LocalInt; |
| 20 |
char *LocalPointer; |
| 21 |
float LocalArray[5]; |
| 22 |
Complete LocalComposite; |
| 23 |
|
| 24 |
// Valid cases: |
| 25 |
#pragma acc parallel loop private(LocalInt, LocalPointer, LocalArray) |
| 26 |
for(int i = 0; i < 5; ++i); |
| 27 |
#pragma acc serial loop private(LocalArray) |
| 28 |
for(int i = 0; i < 5; ++i); |
| 29 |
#pragma acc kernels loop private(LocalArray[2]) |
| 30 |
for(int i = 0; i < 5; ++i); |
| 31 |
#pragma acc parallel loop private(LocalComposite) |
| 32 |
for(int i = 0; i < 5; ++i); |
| 33 |
#pragma acc serial loop private(LocalComposite.EnumMember) |
| 34 |
for(int i = 0; i < 5; ++i); |
| 35 |
#pragma acc kernels loop private(LocalComposite.ScalarMember) |
| 36 |
for(int i = 0; i < 5; ++i); |
| 37 |
#pragma acc parallel loop private(LocalComposite.ArrayMember) |
| 38 |
for(int i = 0; i < 5; ++i); |
| 39 |
#pragma acc serial loop private(LocalComposite.ArrayMember[5]) |
| 40 |
for(int i = 0; i < 5; ++i); |
| 41 |
#pragma acc kernels loop private(LocalComposite.PointerMember) |
| 42 |
for(int i = 0; i < 5; ++i); |
| 43 |
#pragma acc parallel loop private(GlobalInt, GlobalArray, GlobalPointer, GlobalComposite) |
| 44 |
for(int i = 0; i < 5; ++i); |
| 45 |
#pragma acc serial loop private(GlobalArray[2], GlobalPointer[2], GlobalComposite.CompositeMember.A) |
| 46 |
for(int i = 0; i < 5; ++i); |
| 47 |
#pragma acc kernels loop private(LocalComposite, GlobalComposite) |
| 48 |
for(int i = 0; i < 5; ++i); |
| 49 |
#pragma acc parallel loop private(IntParam, PointerParam, ArrayParam, CompositeParam) private(IntParamRef) |
| 50 |
for(int i = 0; i < 5; ++i); |
| 51 |
#pragma acc serial loop private(PointerParam[IntParam], ArrayParam[IntParam], CompositeParam.CompositeMember.A) |
| 52 |
for(int i = 0; i < 5; ++i); |
| 53 |
|
| 54 |
|
| 55 |
// Invalid cases, arbitrary expressions. |
| 56 |
Incomplete *I; |
| 57 |
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} |
| 58 |
#pragma acc kernels loop private(*I) |
| 59 |
for(int i = 0; i < 5; ++i); |
| 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 private(GlobalInt + IntParam) |
| 62 |
for(int i = 0; i < 5; ++i); |
| 63 |
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} |
| 64 |
#pragma acc serial loop private(+GlobalInt) |
| 65 |
for(int i = 0; i < 5; ++i); |
| 66 |
} |
| 67 |
|
| 68 |
template<typename T, unsigned I, typename V> |
| 69 |
void TemplUses(T t, T (&arrayT)[I], V TemplComp) { |
| 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 kernels loop private(+t) |
| 72 |
for(int i = 0; i < 5; ++i); |
| 73 |
|
| 74 |
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} |
| 75 |
#pragma acc parallel loop private(+I) |
| 76 |
for(int i = 0; i < 5; ++i); |
| 77 |
|
| 78 |
// NTTP's are only valid if it is a reference to something. |
| 79 |
// expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} |
| 80 |
// expected-note@#TEMPL_USES_INST{{in instantiation of}} |
| 81 |
#pragma acc serial loop private(I) |
| 82 |
for(int i = 0; i < 5; ++i); |
| 83 |
|
| 84 |
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} |
| 85 |
#pragma acc kernels loop private(t, I) |
| 86 |
for(int i = 0; i < 5; ++i); |
| 87 |
|
| 88 |
#pragma acc parallel loop private(arrayT) |
| 89 |
for(int i = 0; i < 5; ++i); |
| 90 |
|
| 91 |
#pragma acc serial loop private(TemplComp) |
| 92 |
for(int i = 0; i < 5; ++i); |
| 93 |
|
| 94 |
#pragma acc kernels loop private(TemplComp.PointerMember[5]) |
| 95 |
for(int i = 0; i < 5; ++i); |
| 96 |
|
| 97 |
#pragma acc parallel loop private(TemplComp.PointerMember[5]) private(TemplComp) |
| 98 |
for(int i = 0; i < 5; ++i); |
| 99 |
|
| 100 |
int *Pointer; |
| 101 |
#pragma acc serial loop private(Pointer[:I]) |
| 102 |
for(int i = 0; i < 5; ++i); |
| 103 |
#pragma acc kernels loop private(Pointer[:t]) |
| 104 |
for(int i = 0; i < 5; ++i); |
| 105 |
// expected-error@+1{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}} |
| 106 |
#pragma acc parallel loop private(Pointer[1:]) |
| 107 |
for(int i = 0; i < 5; ++i); |
| 108 |
} |
| 109 |
|
| 110 |
template<unsigned I, auto &NTTP_REF> |
| 111 |
void NTTP() { |
| 112 |
// NTTP's are only valid if it is a reference to something. |
| 113 |
// expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} |
| 114 |
// expected-note@#NTTP_INST{{in instantiation of}} |
| 115 |
#pragma acc serial loop private(I) |
| 116 |
for(int i = 0; i < 5; ++i); |
| 117 |
|
| 118 |
#pragma acc kernels loop private(NTTP_REF) |
| 119 |
for(int i = 0; i < 5; ++i); |
| 120 |
} |
| 121 |
|
| 122 |
struct S { |
| 123 |
int ThisMember; |
| 124 |
int ThisMemberArray[5]; |
| 125 |
|
| 126 |
void foo(); |
| 127 |
}; |
| 128 |
|
| 129 |
void S::foo() { |
| 130 |
#pragma acc parallel loop private(ThisMember, this->ThisMemberArray[1]) |
| 131 |
for(int i = 0; i < 5; ++i); |
| 132 |
|
| 133 |
#pragma acc serial loop private(ThisMemberArray[1:2]) |
| 134 |
for(int i = 0; i < 5; ++i); |
| 135 |
|
| 136 |
#pragma acc kernels loop private(this) |
| 137 |
for(int i = 0; i < 5; ++i); |
| 138 |
|
| 139 |
#pragma acc parallel loop private(ThisMember, this->ThisMember) |
| 140 |
for(int i = 0; i < 5; ++i); |
| 141 |
} |
| 142 |
|
| 143 |
void Inst() { |
| 144 |
static constexpr int NTTP_REFed = 1; |
| 145 |
int i; |
| 146 |
int Arr[5]; |
| 147 |
Complete C; |
| 148 |
TemplUses(i, Arr, C); // #TEMPL_USES_INST |
| 149 |
NTTP<5, NTTP_REFed>(); // #NTTP_INST |
| 150 |
} |