[libc++] Refactor the sequence container benchmarks (#119763)
[llvm-project.git] / clang / test / SemaOpenACC / combined-construct-private-clause.c
blob1cd30db8f4aa792c9326de3302b6bc26f29f4248
1 // RUN: %clang_cc1 %s -fopenacc -verify
3 struct Incomplete;
4 enum SomeE{ A };
5 typedef struct IsComplete {
6 struct S { int A; } CompositeMember;
7 int ScalarMember;
8 float ArrayMember[5];
9 enum SomeE EnumMember;
10 void *PointerMember;
11 } Complete;
13 int GlobalInt;
14 float GlobalArray[5];
15 short *GlobalPointer;
16 Complete GlobalComposite;
18 void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete CompositeParam) {
19 int LocalInt;
20 short *LocalPointer;
21 float LocalArray[5];
22 Complete LocalComposite;
24 // Valid cases:
25 #pragma acc parallel loop private(LocalInt, LocalPointer, LocalArray)
26 for(int i = 0; i < 5; ++i);
27 #pragma acc serial loop private(LocalArray)
28 for(int i = 0; i < 5; ++i);
29 #pragma acc kernels loop private(LocalArray[:])
30 for(int i = 0; i < 5; ++i);
31 #pragma acc parallel loop private(LocalArray[:5])
32 for(int i = 0; i < 5; ++i);
33 #pragma acc serial loop private(LocalArray[2:])
34 for(int i = 0; i < 5; ++i);
35 #pragma acc kernels loop private(LocalArray[2:1])
36 for(int i = 0; i < 5; ++i);
37 #pragma acc parallel loop private(LocalArray[2])
38 for(int i = 0; i < 5; ++i);
39 #pragma acc serial loop private(LocalComposite)
40 for(int i = 0; i < 5; ++i);
41 #pragma acc kernels loop private(LocalComposite.EnumMember)
42 for(int i = 0; i < 5; ++i);
43 #pragma acc parallel loop private(LocalComposite.ScalarMember)
44 for(int i = 0; i < 5; ++i);
45 #pragma acc serial loop private(LocalComposite.ArrayMember)
46 for(int i = 0; i < 5; ++i);
47 #pragma acc parallel loop private(LocalComposite.ArrayMember[5])
48 for(int i = 0; i < 5; ++i);
49 #pragma acc kernels loop private(LocalComposite.PointerMember)
50 for(int i = 0; i < 5; ++i);
51 #pragma acc parallel loop private(GlobalInt, GlobalArray, GlobalPointer, GlobalComposite)
52 for(int i = 0; i < 5; ++i);
53 #pragma acc serial loop private(GlobalArray[2], GlobalPointer[2], GlobalComposite.CompositeMember.A)
54 for(int i = 0; i < 5; ++i);
55 #pragma acc kernels loop private(LocalComposite, GlobalComposite)
56 for(int i = 0; i < 5; ++i);
57 #pragma acc parallel loop private(IntParam, PointerParam, ArrayParam, CompositeParam)
58 for(int i = 0; i < 5; ++i);
59 #pragma acc serial loop private(PointerParam[IntParam], ArrayParam[IntParam], CompositeParam.CompositeMember.A)
60 for(int i = 0; i < 5; ++i);
62 #pragma acc parallel loop private(LocalArray) private(LocalArray[2])
63 for(int i = 0; i < 5; ++i);
65 #pragma acc serial loop private(LocalArray, LocalArray[2])
66 for(int i = 0; i < 5; ++i);
68 #pragma acc kernels loop private(LocalComposite, LocalComposite.ScalarMember)
69 for(int i = 0; i < 5; ++i);
71 #pragma acc parallel loop private(LocalComposite.CompositeMember.A, LocalComposite.ScalarMember)
72 for(int i = 0; i < 5; ++i);
74 #pragma acc serial loop private(LocalComposite.CompositeMember.A) private(LocalComposite.ScalarMember)
75 for(int i = 0; i < 5; ++i);
77 Complete LocalComposite2;
78 #pragma acc kernels loop private(LocalComposite2.ScalarMember, LocalComposite2.ScalarMember)
79 for(int i = 0; i < 5; ++i);
81 // Invalid cases, arbitrary expressions.
82 struct Incomplete *I;
83 // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
84 #pragma acc parallel loop private(*I)
85 for(int i = 0; i < 5; ++i);
86 // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
87 #pragma acc serial loop private(GlobalInt + IntParam)
88 for(int i = 0; i < 5; ++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 kernels loop private(+GlobalInt)
91 for(int i = 0; i < 5; ++i);
93 // expected-error@+1{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}}
94 #pragma acc parallel loop private(PointerParam[:])
95 for(int i = 0; i < 5; ++i);
96 #pragma acc serial loop private(PointerParam[:5])
97 for(int i = 0; i < 5; ++i);
98 #pragma acc kernels loop private(PointerParam[:IntParam])
99 for(int i = 0; i < 5; ++i);
100 // expected-error@+1{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}}
101 #pragma acc parallel loop private(PointerParam[2:])
102 for(int i = 0; i < 5; ++i);
103 #pragma acc serial loop private(PointerParam[2:5])
104 for(int i = 0; i < 5; ++i);
105 #pragma acc kernels loop private(PointerParam[2])
106 for(int i = 0; i < 5; ++i);
107 #pragma acc parallel loop private(ArrayParam[:])
108 for(int i = 0; i < 5; ++i);
109 #pragma acc serial loop private(ArrayParam[:5])
110 for(int i = 0; i < 5; ++i);
111 #pragma acc kernels loop private(ArrayParam[:IntParam])
112 for(int i = 0; i < 5; ++i);
113 #pragma acc parallel loop private(ArrayParam[2:])
114 for(int i = 0; i < 5; ++i);
115 // expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
116 #pragma acc serial loop private(ArrayParam[2:5])
117 for(int i = 0; i < 5; ++i);
118 #pragma acc kernels loop private(ArrayParam[2])
119 for(int i = 0; i < 5; ++i);
121 // expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
122 // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
123 #pragma acc parallel loop private((float*)ArrayParam[2:5])
124 for(int i = 0; i < 5; ++i);
125 // expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
126 #pragma acc kernels loop private((float)ArrayParam[2])
127 for(int i = 0; i < 5; ++i);