1 // RUN: %clang_cc1 %s -fopenacc -verify
5 typedef struct IsComplete
{
6 struct S
{ int A
; } CompositeMember
;
16 Complete GlobalComposite
;
18 void uses(int IntParam
, char *PointerParam
, float ArrayParam
[5], Complete CompositeParam
, int &IntParamRef
) {
22 Complete LocalComposite
;
24 // Check Appertainment:
26 #pragma acc loop private(LocalInt)
30 #pragma acc loop private(LocalInt, LocalPointer, LocalArray)
32 #pragma acc loop private(LocalArray)
34 #pragma acc loop private(LocalArray[2])
36 #pragma acc loop private(LocalComposite)
38 #pragma acc loop private(LocalComposite.EnumMember)
40 #pragma acc loop private(LocalComposite.ScalarMember)
42 #pragma acc loop private(LocalComposite.ArrayMember)
44 #pragma acc loop private(LocalComposite.ArrayMember[5])
46 #pragma acc loop private(LocalComposite.PointerMember)
48 #pragma acc loop private(GlobalInt, GlobalArray, GlobalPointer, GlobalComposite)
50 #pragma acc loop private(GlobalArray[2], GlobalPointer[2], GlobalComposite.CompositeMember.A)
52 #pragma acc loop private(LocalComposite, GlobalComposite)
54 #pragma acc loop private(IntParam, PointerParam, ArrayParam, CompositeParam) private(IntParamRef)
56 #pragma acc loop private(PointerParam[IntParam], ArrayParam[IntParam], CompositeParam.CompositeMember.A)
60 // Invalid cases, arbitrary expressions.
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 loop private(*I)
65 // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
66 #pragma acc loop private(GlobalInt + IntParam)
68 // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
69 #pragma acc loop private(+GlobalInt)
73 template<typename T
, unsigned I
, typename V
>
74 void TemplUses(T t
, T (&arrayT
)[I
], V TemplComp
) {
75 // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
76 #pragma acc loop private(+t)
79 // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
80 #pragma acc loop private(+I)
83 // NTTP's are only valid if it is a reference to something.
84 // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
85 // expected-note@#TEMPL_USES_INST{{in instantiation of}}
86 #pragma acc loop private(I)
89 // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
90 #pragma acc loop private(t, I)
93 #pragma acc loop private(arrayT)
96 #pragma acc loop private(TemplComp)
99 #pragma acc loop private(TemplComp.PointerMember[5])
102 #pragma acc loop private(TemplComp.PointerMember[5]) private(TemplComp)
106 #pragma acc loop private(Pointer[:I])
108 #pragma acc loop private(Pointer[:t])
110 // expected-error@+1{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}}
111 #pragma acc loop private(Pointer[1:])
115 template<unsigned I
, auto &NTTP_REF
>
117 // NTTP's are only valid if it is a reference to something.
118 // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
119 // expected-note@#NTTP_INST{{in instantiation of}}
120 #pragma acc loop private(I)
123 #pragma acc loop private(NTTP_REF)
129 int ThisMemberArray
[5];
135 #pragma acc loop private(ThisMember, this->ThisMemberArray[1])
138 #pragma acc loop private(ThisMemberArray[1:2])
141 #pragma acc loop private(this)
144 #pragma acc loop private(ThisMember, this->ThisMember)
149 static constexpr int NTTP_REFed
= 1;
153 TemplUses(i
, Arr
, C
); // #TEMPL_USES_INST
154 NTTP
<5, NTTP_REFed
>(); // #NTTP_INST