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