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 parallel private(LocalInt)
28 #pragma acc serial private(LocalInt)
30 // expected-error@+1{{OpenACC 'private' clause is not valid on 'kernels' directive}}
31 #pragma acc kernels private(LocalInt)
35 #pragma acc parallel private(LocalInt, LocalPointer, LocalArray)
37 #pragma acc parallel private(LocalArray)
39 #pragma acc parallel private(LocalArray[2])
41 #pragma acc parallel private(LocalComposite)
43 #pragma acc parallel private(LocalComposite.EnumMember)
45 #pragma acc parallel private(LocalComposite.ScalarMember)
47 #pragma acc parallel private(LocalComposite.ArrayMember)
49 #pragma acc parallel private(LocalComposite.ArrayMember[5])
51 #pragma acc parallel private(LocalComposite.PointerMember)
53 #pragma acc parallel private(GlobalInt, GlobalArray, GlobalPointer, GlobalComposite)
55 #pragma acc parallel private(GlobalArray[2], GlobalPointer[2], GlobalComposite.CompositeMember.A)
57 #pragma acc parallel private(LocalComposite, GlobalComposite)
59 #pragma acc parallel private(IntParam, PointerParam, ArrayParam, CompositeParam) private(IntParamRef)
61 #pragma acc parallel private(PointerParam[IntParam], ArrayParam[IntParam], CompositeParam.CompositeMember.A)
65 // Invalid cases, arbitrary expressions.
67 // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
68 #pragma acc parallel private(*I)
70 // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
71 #pragma acc parallel private(GlobalInt + IntParam)
73 // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
74 #pragma acc parallel private(+GlobalInt)
78 template<typename T
, unsigned I
, typename V
>
79 void TemplUses(T t
, T (&arrayT
)[I
], V TemplComp
) {
80 // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
81 #pragma acc parallel private(+t)
84 // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
85 #pragma acc parallel private(+I)
88 // NTTP's are only valid if it is a reference to something.
89 // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
90 // expected-note@#TEMPL_USES_INST{{in instantiation of}}
91 #pragma acc parallel private(I)
94 // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
95 #pragma acc parallel private(t, I)
98 #pragma acc parallel private(arrayT)
101 #pragma acc parallel private(TemplComp)
104 #pragma acc parallel private(TemplComp.PointerMember[5])
107 #pragma acc parallel private(TemplComp.PointerMember[5]) private(TemplComp)
111 #pragma acc parallel private(Pointer[:I])
113 #pragma acc parallel private(Pointer[:t])
115 // expected-error@+1{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}}
116 #pragma acc parallel private(Pointer[1:])
120 template<unsigned I
, auto &NTTP_REF
>
122 // NTTP's are only valid if it is a reference to something.
123 // expected-error@+2{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
124 // expected-note@#NTTP_INST{{in instantiation of}}
125 #pragma acc parallel private(I)
128 #pragma acc parallel private(NTTP_REF)
134 int ThisMemberArray
[5];
140 #pragma acc parallel private(ThisMember, this->ThisMemberArray[1])
143 #pragma acc parallel private(ThisMemberArray[1:2])
146 #pragma acc parallel private(this)
149 #pragma acc parallel private(ThisMember, this->ThisMember)
154 static constexpr int NTTP_REFed
= 1;
158 TemplUses(i
, Arr
, C
); // #TEMPL_USES_INST
159 NTTP
<5, NTTP_REFed
>(); // #NTTP_INST