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