1 // RUN: %clang_cc1 -std=c++11 -verify -fopenmp %s -Wuninitialized
2 // RUN: %clang_cc1 -std=c++11 -verify=expected,omp4 -fopenmp -fopenmp-version=45 %s -Wuninitialized
3
4 // RUN: %clang_cc1 -std=c++11 -verify -fopenmp-simd %s -Wuninitialized
5 // RUN: %clang_cc1 -std=c++11 -verify=expected,omp4 -fopenmp-simd -fopenmp-version=45 %s -Wuninitialized
6
7 struct ST {
8 int *a;
9 };
10 typedef int arr[10];
11 typedef ST STarr[10];
12 struct SA {
13 const int d = 5;
14 const int da[5] = { 0 };
15 ST e;
16 ST g[10];
17 STarr &rg = g;
18 int i;
19 int &j = i;
20 int *k = &j;
21 int *&z = k;
22 int aa[10];
23 arr &raa = aa;
funcSA24 void func(int arg) {
25 #pragma omp target teams distribute parallel for simd is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}}
26 for (int i=0; i<100; i++)
27 ;
28 #pragma omp target teams distribute parallel for simd is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
29 for (int i=0; i<100; i++)
30 ;
31 #pragma omp target teams distribute parallel for simd is_device_ptr() // expected-error {{expected expression}}
32 for (int i=0; i<100; i++)
33 ;
34 #pragma omp target teams distribute parallel for simd is_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
35 for (int i=0; i<100; i++)
36 ;
37 #pragma omp target teams distribute parallel for simd is_device_ptr(arg // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
38 for (int i=0; i<100; i++)
39 ;
40 #pragma omp target teams distribute parallel for simd is_device_ptr(i) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
41 for (int i=0; i<100; i++)
42 ;
43 #pragma omp target teams distribute parallel for simd is_device_ptr(j) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
44 for (int i=0; i<100; i++)
45 ;
46 #pragma omp target teams distribute parallel for simd is_device_ptr(k) // OK
47 for (int i=0; i<100; i++)
48 ;
49 #pragma omp target teams distribute parallel for simd is_device_ptr(z) // OK
50 for (int i=0; i<100; i++)
51 ;
52 #pragma omp target teams distribute parallel for simd is_device_ptr(aa) // OK
53 for (int i=0; i<100; i++)
54 ;
55 #pragma omp target teams distribute parallel for simd is_device_ptr(raa) // OK
56 for (int i=0; i<100; i++)
57 ;
58 #pragma omp target teams distribute parallel for simd is_device_ptr(e) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
59 for (int i=0; i<100; i++)
60 ;
61 #pragma omp target teams distribute parallel for simd is_device_ptr(g) // OK
62 for (int i=0; i<100; i++)
63 ;
64 #pragma omp target teams distribute parallel for simd is_device_ptr(rg) // OK
65 for (int i=0; i<100; i++)
66 ;
67 #pragma omp target teams distribute parallel for simd is_device_ptr(k,i,j) // expected-error2 {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
68 for (int i=0; i<100; i++)
69 ;
70 #pragma omp target teams distribute parallel for simd is_device_ptr(d) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
71 for (int i=0; i<100; i++)
72 ;
73 #pragma omp target teams distribute parallel for simd is_device_ptr(da) // OK
74 for (int i=0; i<100; i++)
75 ;
76 return;
77 }
78 };
79 struct SB {
80 unsigned A;
81 unsigned B;
82 float Arr[100];
83 float *Ptr;
fooSB84 float *foo() {
85 return &Arr[0];
86 }
87 };
88
89 struct SC {
90 unsigned A : 2;
91 unsigned B : 3;
92 unsigned C;
93 unsigned D;
94 float Arr[100];
95 SB S;
96 SB ArrS[100];
97 SB *PtrS;
98 SB *&RPtrS;
99 float *Ptr;
100
SCSC101 SC(SB *&_RPtrS) : RPtrS(_RPtrS) {}
102 };
103
104 union SD {
105 unsigned A;
106 float B;
107 };
108
109 struct S1;
110 extern S1 a;
111 class S2 {
112 mutable int a;
113 public:
S2()114 S2():a(0) { }
S2(S2 & s2)115 S2(S2 &s2):a(s2.a) { }
116 static float S2s;
117 static const float S2sc;
118 };
119 const float S2::S2sc = 0;
120 const S2 b;
121 const S2 ba[5];
122 class S3 {
123 int a;
124 public:
S3()125 S3():a(0) { }
S3(S3 & s3)126 S3(S3 &s3):a(s3.a) { }
127 };
128 const S3 c;
129 const S3 ca[5];
130 extern const int f;
131 class S4 {
132 int a;
133 S4();
134 S4(const S4 &s4);
135 public:
S4(int v)136 S4(int v):a(v) { }
137 };
138 class S5 {
139 int a;
S5()140 S5():a(0) {}
S5(const S5 & s5)141 S5(const S5 &s5):a(s5.a) { }
142 public:
S5(int v)143 S5(int v):a(v) { }
144 };
145
146 S3 h;
147 #pragma omp threadprivate(h)
148
149 typedef struct {
150 int a;
151 } S6;
152
153 template <typename T, int I>
154 T tmain(T argc) {
155 const T d = 5;
156 const T da[5] = { 0 };
157 S4 e(4);
158 S5 g(5);
159 S6 h[10];
160 auto &rh = h;
161 T i;
162 T &j = i;
163 T *k = &j;
164 T *&z = k;
165 T aa[10];
166 auto &raa = aa;
167 S6 *ps;
168 #pragma omp target teams distribute parallel for simd is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}}
169 for (int i=0; i<100; i++)
170 ;
171 #pragma omp target teams distribute parallel for simd is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
172 for (int i=0; i<100; i++)
173 ;
174 #pragma omp target teams distribute parallel for simd is_device_ptr() // expected-error {{expected expression}}
175 for (int i=0; i<100; i++)
176 ;
177 #pragma omp target teams distribute parallel for simd is_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
178 for (int i=0; i<100; i++)
179 ;
180 #pragma omp target teams distribute parallel for simd is_device_ptr(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
181 for (int i=0; i<100; i++)
182 ;
183 #pragma omp target teams distribute parallel for simd is_device_ptr(i) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
184 for (int i=0; i<100; i++)
185 ;
186 #pragma omp target teams distribute parallel for simd is_device_ptr(j) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
187 for (int i=0; i<100; i++)
188 ;
189 #pragma omp target teams distribute parallel for simd is_device_ptr(k) // OK
190 for (int i=0; i<100; i++)
191 ;
192 #pragma omp target teams distribute parallel for simd is_device_ptr(z) // OK
193 for (int i=0; i<100; i++)
194 ;
195 #pragma omp target teams distribute parallel for simd is_device_ptr(aa) // OK
196 for (int i=0; i<100; i++)
197 ;
198 #pragma omp target teams distribute parallel for simd is_device_ptr(raa) // OK
199 for (int i=0; i<100; i++)
200 ;
201 #pragma omp target teams distribute parallel for simd is_device_ptr(e) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
202 for (int i=0; i<100; i++)
203 ;
204 #pragma omp target teams distribute parallel for simd is_device_ptr(g) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
205 for (int i=0; i<100; i++)
206 ;
207 #pragma omp target teams distribute parallel for simd is_device_ptr(h) // OK
208 for (int i=0; i<100; i++)
209 ;
210 #pragma omp target teams distribute parallel for simd is_device_ptr(rh) // OK
211 for (int i=0; i<100; i++)
212 ;
213 #pragma omp target teams distribute parallel for simd is_device_ptr(k,i,j) // expected-error2 {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
214 for (int i=0; i<100; i++)
215 ;
216 #pragma omp target teams distribute parallel for simd is_device_ptr(d) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
217 for (int i=0; i<100; i++)
218 ;
219 #pragma omp target teams distribute parallel for simd is_device_ptr(da) // OK
220 for (int i=0; i<100; i++)
221 ;
222 #pragma omp target teams distribute parallel for simd map(ps) is_device_ptr(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
223 for (int i=0; i<100; i++)
224 ;
225 #pragma omp target teams distribute parallel for simd is_device_ptr(ps) map(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
226 for (int i=0; i<100; i++)
227 ;
228 #pragma omp target teams distribute parallel for simd map(ps->a) is_device_ptr(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
229 for (int i=0; i<100; i++)
230 ;
231 #pragma omp target teams distribute parallel for simd is_device_ptr(ps) map(ps->a) // expected-error{{pointer cannot be mapped along with a section derived from itself}} expected-note{{used here}}
232 for (int i=0; i<100; i++)
233 ;
234 #pragma omp target teams distribute parallel for simd is_device_ptr(ps) firstprivate(ps) // omp4-error{{firstprivate variable cannot be in a is_device_ptr clause in '#pragma omp target teams distribute parallel for simd' directive}}
235 for (int i=0; i<100; i++)
236 ;
237 #pragma omp target teams distribute parallel for simd firstprivate(ps) is_device_ptr(ps) // expected-error{{firstprivate variable cannot be in a is_device_ptr clause in '#pragma omp target teams distribute parallel for simd' directive}} expected-note{{defined as firstprivate}}
238 for (int i=0; i<100; i++)
239 ;
240 #pragma omp target teams distribute parallel for simd is_device_ptr(ps) private(ps) // omp4-error{{private variable cannot be in a is_device_ptr clause in '#pragma omp target teams distribute parallel for simd' directive}}
241 for (int i=0; i<100; i++)
242 ;
243 #pragma omp target teams distribute parallel for simd private(ps) is_device_ptr(ps) // expected-error{{private variable cannot be in a is_device_ptr clause in '#pragma omp target teams distribute parallel for simd' directive}} expected-note{{defined as private}}
244 for (int i=0; i<100; i++)
245 ;
246 return 0;
247 }
248
main(int argc,char ** argv)249 int main(int argc, char **argv) {
250 const int d = 5;
251 const int da[5] = { 0 };
252 S4 e(4);
253 S5 g(5);
254 S6 h[10];
255 auto &rh = h;
256 int i;
257 int &j = i;
258 int *k = &j;
259 int *&z = k;
260 int aa[10];
261 auto &raa = aa;
262 S6 *ps;
263 #pragma omp target teams distribute parallel for simd is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}}
264 for (int i=0; i<100; i++)
265 ;
266 #pragma omp target teams distribute parallel for simd is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
267 for (int i=0; i<100; i++)
268 ;
269 #pragma omp target teams distribute parallel for simd is_device_ptr() // expected-error {{expected expression}}
270 for (int i=0; i<100; i++)
271 ;
272 #pragma omp target teams distribute parallel for simd is_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
273 for (int i=0; i<100; i++)
274 ;
275 #pragma omp target teams distribute parallel for simd is_device_ptr(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
276 for (int i=0; i<100; i++)
277 ;
278 #pragma omp target teams distribute parallel for simd is_device_ptr(i) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
279 for (int i=0; i<100; i++)
280 ;
281 #pragma omp target teams distribute parallel for simd is_device_ptr(j) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
282 for (int i=0; i<100; i++)
283 ;
284 #pragma omp target teams distribute parallel for simd is_device_ptr(k) // OK
285 for (int i=0; i<100; i++)
286 ;
287 #pragma omp target teams distribute parallel for simd is_device_ptr(z) // OK
288 for (int i=0; i<100; i++)
289 ;
290 #pragma omp target teams distribute parallel for simd is_device_ptr(aa) // OK
291 for (int i=0; i<100; i++)
292 ;
293 #pragma omp target teams distribute parallel for simd is_device_ptr(raa) // OK
294 for (int i=0; i<100; i++)
295 ;
296 #pragma omp target teams distribute parallel for simd is_device_ptr(e) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
297 for (int i=0; i<100; i++)
298 ;
299 #pragma omp target teams distribute parallel for simd is_device_ptr(g) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
300 for (int i=0; i<100; i++)
301 ;
302 #pragma omp target teams distribute parallel for simd is_device_ptr(h) // OK
303 for (int i=0; i<100; i++)
304 ;
305 #pragma omp target teams distribute parallel for simd is_device_ptr(rh) // OK
306 for (int i=0; i<100; i++)
307 ;
308 #pragma omp target teams distribute parallel for simd is_device_ptr(k,i,j) // expected-error2 {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
309 for (int i=0; i<100; i++)
310 ;
311 #pragma omp target teams distribute parallel for simd is_device_ptr(d) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
312 for (int i=0; i<100; i++)
313 ;
314 #pragma omp target teams distribute parallel for simd is_device_ptr(da) // OK
315 for (int i=0; i<100; i++)
316 ;
317 #pragma omp target teams distribute parallel for simd map(ps) is_device_ptr(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
318 for (int i=0; i<100; i++)
319 ;
320 #pragma omp target teams distribute parallel for simd is_device_ptr(ps) map(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
321 for (int i=0; i<100; i++)
322 ;
323 #pragma omp target teams distribute parallel for simd map(ps->a) is_device_ptr(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
324 for (int i=0; i<100; i++)
325 ;
326 #pragma omp target teams distribute parallel for simd is_device_ptr(ps) map(ps->a) // expected-error{{pointer cannot be mapped along with a section derived from itself}} expected-note{{used here}}
327 for (int i=0; i<100; i++)
328 ;
329 #pragma omp target teams distribute parallel for simd is_device_ptr(ps) firstprivate(ps) // omp4-error{{firstprivate variable cannot be in a is_device_ptr clause in '#pragma omp target teams distribute parallel for simd' directive}}
330 for (int i=0; i<100; i++)
331 ;
332 #pragma omp target teams distribute parallel for simd firstprivate(ps) is_device_ptr(ps) // expected-error{{firstprivate variable cannot be in a is_device_ptr clause in '#pragma omp target teams distribute parallel for simd' directive}} expected-note{{defined as firstprivate}}
333 for (int i=0; i<100; i++)
334 ;
335 #pragma omp target teams distribute parallel for simd is_device_ptr(ps) private(ps) // omp4-error{{private variable cannot be in a is_device_ptr clause in '#pragma omp target teams distribute parallel for simd' directive}}
336 for (int i=0; i<100; i++)
337 ;
338 #pragma omp target teams distribute parallel for simd private(ps) is_device_ptr(ps) // expected-error{{private variable cannot be in a is_device_ptr clause in '#pragma omp target teams distribute parallel for simd' directive}} expected-note{{defined as private}}
339 for (int i=0; i<100; i++)
340 ;
341 return tmain<int, 3>(argc); // expected-note {{in instantiation of function template specialization 'tmain<int, 3>' requested here}}
342 }
343