1054f7c05Serichkeane // RUN: %clang_cc1 %s -fopenacc -verify
2054f7c05Serichkeane
3054f7c05Serichkeane enum SomeE{};
4054f7c05Serichkeane typedef struct IsComplete {
5054f7c05Serichkeane struct S { int A; } CompositeMember;
6054f7c05Serichkeane int ScalarMember;
7054f7c05Serichkeane float ArrayMember[5];
8054f7c05Serichkeane SomeE EnumMember;
9054f7c05Serichkeane char *PointerMember;
10054f7c05Serichkeane } Complete;
11054f7c05Serichkeane
uses(int IntParam,char * PointerParam,float ArrayParam[5],Complete CompositeParam,int & IntParamRef)12054f7c05Serichkeane void uses(int IntParam, char *PointerParam, float ArrayParam[5], Complete CompositeParam, int &IntParamRef) {
13054f7c05Serichkeane int LocalInt;
14054f7c05Serichkeane char *LocalPointer;
15054f7c05Serichkeane float LocalArray[5];
16054f7c05Serichkeane // Check Appertainment:
17054f7c05Serichkeane #pragma acc parallel copy(LocalInt)
18054f7c05Serichkeane while(1);
19054f7c05Serichkeane #pragma acc serial copy(LocalInt)
20054f7c05Serichkeane while(1);
21054f7c05Serichkeane #pragma acc kernels copy(LocalInt)
22054f7c05Serichkeane while(1);
23054f7c05Serichkeane
24054f7c05Serichkeane // Valid cases:
25054f7c05Serichkeane #pragma acc parallel copy(LocalInt, LocalPointer, LocalArray)
26054f7c05Serichkeane while(1);
27054f7c05Serichkeane #pragma acc parallel copy(LocalArray[2:1])
28054f7c05Serichkeane while(1);
29054f7c05Serichkeane
30054f7c05Serichkeane Complete LocalComposite2;
31054f7c05Serichkeane #pragma acc parallel copy(LocalComposite2.ScalarMember, LocalComposite2.ScalarMember)
32054f7c05Serichkeane while(1);
33054f7c05Serichkeane
34*a15b685cSErich 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}}
35054f7c05Serichkeane #pragma acc parallel copy(1 + IntParam)
36054f7c05Serichkeane while(1);
37054f7c05Serichkeane
38*a15b685cSErich 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}}
39054f7c05Serichkeane #pragma acc parallel copy(+IntParam)
40054f7c05Serichkeane while(1);
41054f7c05Serichkeane
42054f7c05Serichkeane // expected-error@+1{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}}
43054f7c05Serichkeane #pragma acc parallel copy(PointerParam[2:])
44054f7c05Serichkeane while(1);
45054f7c05Serichkeane
46054f7c05Serichkeane // expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
47054f7c05Serichkeane #pragma acc parallel copy(ArrayParam[2:5])
48054f7c05Serichkeane while(1);
49054f7c05Serichkeane
50054f7c05Serichkeane // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
51*a15b685cSErich 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}}
52054f7c05Serichkeane #pragma acc parallel copy((float*)ArrayParam[2:5])
53054f7c05Serichkeane while(1);
54*a15b685cSErich 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}}
55054f7c05Serichkeane #pragma acc parallel copy((float)ArrayParam[2])
56054f7c05Serichkeane while(1);
57054f7c05Serichkeane }
58054f7c05Serichkeane
59054f7c05Serichkeane template<typename T, unsigned I, typename V>
TemplUses(T t,T (& arrayT)[I],V TemplComp)60054f7c05Serichkeane void TemplUses(T t, T (&arrayT)[I], V TemplComp) {
61*a15b685cSErich 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}}
62054f7c05Serichkeane #pragma acc parallel copy(+t)
63054f7c05Serichkeane while(true);
64054f7c05Serichkeane
65054f7c05Serichkeane // NTTP's are only valid if it is a reference to something.
66*a15b685cSErich 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}}
67054f7c05Serichkeane // expected-note@#TEMPL_USES_INST{{in instantiation of}}
68054f7c05Serichkeane #pragma acc parallel copy(I)
69054f7c05Serichkeane while(true);
70054f7c05Serichkeane
71*a15b685cSErich 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}}
72054f7c05Serichkeane #pragma acc parallel copy(t, I)
73054f7c05Serichkeane while(true);
74054f7c05Serichkeane
75054f7c05Serichkeane #pragma acc parallel copy(arrayT)
76054f7c05Serichkeane while(true);
77054f7c05Serichkeane
78054f7c05Serichkeane #pragma acc parallel copy(TemplComp)
79054f7c05Serichkeane while(true);
80054f7c05Serichkeane
81054f7c05Serichkeane #pragma acc parallel copy(TemplComp.PointerMember[5])
82054f7c05Serichkeane while(true);
83054f7c05Serichkeane int *Pointer;
84054f7c05Serichkeane #pragma acc parallel copy(Pointer[:I])
85054f7c05Serichkeane while(true);
86054f7c05Serichkeane #pragma acc parallel copy(Pointer[:t])
87054f7c05Serichkeane while(true);
88054f7c05Serichkeane // expected-error@+1{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}}
89054f7c05Serichkeane #pragma acc parallel copy(Pointer[1:])
90054f7c05Serichkeane while(true);
91054f7c05Serichkeane }
92054f7c05Serichkeane
93054f7c05Serichkeane template<unsigned I, auto &NTTP_REF>
NTTP()94054f7c05Serichkeane void NTTP() {
95054f7c05Serichkeane // NTTP's are only valid if it is a reference to something.
96*a15b685cSErich 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}}
97054f7c05Serichkeane // expected-note@#NTTP_INST{{in instantiation of}}
98054f7c05Serichkeane #pragma acc parallel copy(I)
99054f7c05Serichkeane while(true);
100054f7c05Serichkeane
101054f7c05Serichkeane #pragma acc parallel copy(NTTP_REF)
102054f7c05Serichkeane while(true);
103054f7c05Serichkeane }
104054f7c05Serichkeane
Inst()105054f7c05Serichkeane void Inst() {
106054f7c05Serichkeane static constexpr int NTTP_REFed = 1;
107054f7c05Serichkeane int i;
108054f7c05Serichkeane int Arr[5];
109054f7c05Serichkeane Complete C;
110054f7c05Serichkeane TemplUses(i, Arr, C); // #TEMPL_USES_INST
111054f7c05Serichkeane NTTP<5, NTTP_REFed>(); // #NTTP_INST
112054f7c05Serichkeane }
113