| 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 |
// Check Appertainment: |
| 25 |
|
| 26 |
#pragma acc parallel private(LocalInt) |
| 27 |
while(true); |
| 28 |
#pragma acc serial private(LocalInt) |
| 29 |
while(true); |
| 30 |
// expected-error@+1{{OpenACC 'private' clause is not valid on 'kernels' directive}} |
| 31 |
#pragma acc kernels private(LocalInt) |
| 32 |
while(true); |
| 33 |
|
| 34 |
// Valid cases: |
| 35 |
#pragma acc parallel private(LocalInt, LocalPointer, LocalArray) |
| 36 |
while(true); |
| 37 |
#pragma acc parallel private(LocalArray) |
| 38 |
while(true); |
| 39 |
#pragma acc parallel private(LocalArray[2]) |
| 40 |
while(true); |
| 41 |
#pragma acc parallel private(LocalComposite) |
| 42 |
while(true); |
| 43 |
#pragma acc parallel private(LocalComposite.EnumMember) |
| 44 |
while(true); |
| 45 |
#pragma acc parallel private(LocalComposite.ScalarMember) |
| 46 |
while(true); |
| 47 |
#pragma acc parallel private(LocalComposite.ArrayMember) |
| 48 |
while(true); |
| 49 |
#pragma acc parallel private(LocalComposite.ArrayMember[5]) |
| 50 |
while(true); |
| 51 |
#pragma acc parallel private(LocalComposite.PointerMember) |
| 52 |
while(true); |
| 53 |
#pragma acc parallel private(GlobalInt, GlobalArray, GlobalPointer, GlobalComposite) |
| 54 |
while(true); |
| 55 |
#pragma acc parallel private(GlobalArray[2], GlobalPointer[2], GlobalComposite.CompositeMember.A) |
| 56 |
while(true); |
| 57 |
#pragma acc parallel private(LocalComposite, GlobalComposite) |
| 58 |
while(true); |
| 59 |
#pragma acc parallel private(IntParam, PointerParam, ArrayParam, CompositeParam) private(IntParamRef) |
| 60 |
while(true); |
| 61 |
#pragma acc parallel private(PointerParam[IntParam], ArrayParam[IntParam], CompositeParam.CompositeMember.A) |
| 62 |
while(true); |
| 63 |
|
| 64 |
|
| 65 |
// Invalid cases, arbitrary expressions. |
| 66 |
Incomplete *I; |
| 67 |
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} |
| 68 |
#pragma acc parallel private(*I) |
| 69 |
while(true); |
| 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 private(GlobalInt + IntParam) |
| 72 |
while(true); |
| 73 |
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} |
| 74 |
#pragma acc parallel private(+GlobalInt) |
| 75 |
while(true); |
| 76 |
} |
| 77 |
|
| 78 |
template<typename T, unsigned I, typename V> |
| 79 |
void TemplUses(T t, T (&arrayT)[I], V TemplComp) { |
| 80 |
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} |
| 81 |
#pragma acc parallel private(+t) |
| 82 |
while(true); |
| 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 parallel private(+I) |
| 86 |
while(true); |
| 87 |
|
| 88 |
// NTTP's are only valid if it is a reference to something. |
| 89 |
// expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} |
| 90 |
// expected-note@#TEMPL_USES_INST{{in instantiation of}} |
| 91 |
#pragma acc parallel private(I) |
| 92 |
while(true); |
| 93 |
|
| 94 |
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} |
| 95 |
#pragma acc parallel private(t, I) |
| 96 |
while(true); |
| 97 |
|
| 98 |
#pragma acc parallel private(arrayT) |
| 99 |
while(true); |
| 100 |
|
| 101 |
#pragma acc parallel private(TemplComp) |
| 102 |
while(true); |
| 103 |
|
| 104 |
#pragma acc parallel private(TemplComp.PointerMember[5]) |
| 105 |
while(true); |
| 106 |
|
| 107 |
#pragma acc parallel private(TemplComp.PointerMember[5]) private(TemplComp) |
| 108 |
while(true); |
| 109 |
|
| 110 |
int *Pointer; |
| 111 |
#pragma acc parallel private(Pointer[:I]) |
| 112 |
while(true); |
| 113 |
#pragma acc parallel private(Pointer[:t]) |
| 114 |
while(true); |
| 115 |
// expected-error@+1{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}} |
| 116 |
#pragma acc parallel private(Pointer[1:]) |
| 117 |
while(true); |
| 118 |
} |
| 119 |
|
| 120 |
template<unsigned I, auto &NTTP_REF> |
| 121 |
void NTTP() { |
| 122 |
// NTTP's are only valid if it is a reference to something. |
| 123 |
// expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}} |
| 124 |
// expected-note@#NTTP_INST{{in instantiation of}} |
| 125 |
#pragma acc parallel private(I) |
| 126 |
while(true); |
| 127 |
|
| 128 |
#pragma acc parallel private(NTTP_REF) |
| 129 |
while(true); |
| 130 |
} |
| 131 |
|
| 132 |
struct S { |
| 133 |
int ThisMember; |
| 134 |
int ThisMemberArray[5]; |
| 135 |
|
| 136 |
void foo(); |
| 137 |
}; |
| 138 |
|
| 139 |
void S::foo() { |
| 140 |
#pragma acc parallel private(ThisMember, this->ThisMemberArray[1]) |
| 141 |
while(true); |
| 142 |
|
| 143 |
#pragma acc parallel private(ThisMemberArray[1:2]) |
| 144 |
while(true); |
| 145 |
|
| 146 |
#pragma acc parallel private(this) |
| 147 |
while(true); |
| 148 |
|
| 149 |
#pragma acc parallel private(ThisMember, this->ThisMember) |
| 150 |
while(true); |
| 151 |
} |
| 152 |
|
| 153 |
void Inst() { |
| 154 |
static constexpr int NTTP_REFed = 1; |
| 155 |
int i; |
| 156 |
int Arr[5]; |
| 157 |
Complete C; |
| 158 |
TemplUses(i, Arr, C); // #TEMPL_USES_INST |
| 159 |
NTTP<5, NTTP_REFed>(); // #NTTP_INST |
| 160 |
} |
| 161 |
|
| 162 |
template<typename T> |
| 163 |
void ThisCrashed(unsigned A, unsigned B) { |
| 164 |
T ***ThreePtr; |
| 165 |
// expected-error@+1 2{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}} |
| 166 |
#pragma acc parallel private(ThreePtr[A:B][B][B]) |
| 167 |
; |
| 168 |
} |
| 169 |
|
| 170 |
void inst_crash() { |
| 171 |
// expected-note@+1{{in instantiation}} |
| 172 |
ThisCrashed<int>(1, 2); |
| 173 |
} |
| 174 |
|