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