1 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
2
3 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
4
5
6 struct S1; // expected-note 2 {{declared here}}
7 extern S1 a;
8 class S2 {
9 mutable int a;
10 public:
S2()11 S2():a(0) { }
S2(S2 & s2)12 S2(S2 &s2):a(s2.a) { }
13 };
14 const S2 b;
15 const S2 ba[5];
16 class S3 {
17 int a;
18 public:
S3()19 S3():a(0) { }
S3(S3 & s3)20 S3(S3 &s3):a(s3.a) { }
21 };
22 const S3 c;
23 const S3 ca[5];
24 extern const int f;
25 class S4 {
26 int a;
27 S4();
28 S4(const S4 &s4);
29 public:
S4(int v)30 S4(int v):a(v) { }
31 };
32 class S5 {
33 int a;
S5()34 S5():a(0) {}
S5(const S5 & s5)35 S5(const S5 &s5):a(s5.a) { }
36 public:
S5(int v)37 S5(int v):a(v) { }
38 };
39
40 S3 h;
41 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
42
43 namespace A {
44 double x;
45 #pragma omp threadprivate(x) // expected-note 2 {{defined as threadprivate or thread local}}
46 }
47 namespace B {
48 using A::x;
49 }
50
51 template <class T, typename S, int N>
tmain(T argc,S ** argv)52 T tmain(T argc, S **argv) {
53 const int d = 5;
54 const int da[5] = { 0 };
55 S4 e(4);
56 S5 g(5);
57 int i;
58 int &j = i;
59 int acc = 0;
60 int n = 1000;
61
62 #pragma omp target
63 #pragma omp teams
64 #pragma omp distribute parallel for shared // expected-error {{expected '(' after 'shared'}}
65 for(int k = 0 ; k < n ; k++) {
66 acc++;
67 }
68
69 #pragma omp target
70 #pragma omp teams
71 #pragma omp distribute parallel for shared ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
72 for(int k = 0 ; k < n ; k++) {
73 acc++;
74 }
75
76 #pragma omp target
77 #pragma omp teams
78 #pragma omp distribute parallel for shared () // expected-error {{expected expression}}
79 for(int k = 0 ; k < n ; k++) {
80 acc++;
81 }
82
83 #pragma omp target
84 #pragma omp teams
85 #pragma omp distribute parallel for shared (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
86 for(int k = 0 ; k < n ; k++) {
87 acc++;
88 }
89
90 #pragma omp target
91 #pragma omp teams
92 #pragma omp distribute parallel for shared (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
93 for(int k = 0 ; k < n ; k++) {
94 acc++;
95 }
96
97 #pragma omp target
98 #pragma omp teams
99 #pragma omp distribute parallel for shared (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
100 for(int k = 0 ; k < n ; k++) {
101 acc++;
102 }
103
104 #pragma omp target
105 #pragma omp teams
106 #pragma omp distribute parallel for shared (argc)
107 for(int k = 0 ; k < n ; k++) {
108 acc++;
109 }
110
111 #pragma omp target
112 #pragma omp teams
113 #pragma omp distribute parallel for shared (S1) // expected-error {{'S1' does not refer to a value}}
114 for(int k = 0 ; k < n ; k++) {
115 acc++;
116 }
117
118 #pragma omp target
119 #pragma omp teams
120 #pragma omp distribute parallel for shared (a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}}
121 for(int k = 0 ; k < n ; k++) {
122 acc++;
123 }
124
125 #pragma omp target
126 #pragma omp teams
127 #pragma omp distribute parallel for shared (argv[1]) // expected-error {{expected variable name}}
128 for(int k = 0 ; k < n ; k++) {
129 acc++;
130 }
131
132 #pragma omp target
133 #pragma omp teams
134 #pragma omp distribute parallel for shared(ba)
135 for(int k = 0 ; k < n ; k++) {
136 acc++;
137 }
138
139 #pragma omp target
140 #pragma omp teams
141 #pragma omp distribute parallel for shared(ca)
142 for(int k = 0 ; k < n ; k++) {
143 acc++;
144 }
145
146 #pragma omp target
147 #pragma omp teams
148 #pragma omp distribute parallel for shared(da)
149 for(int k = 0 ; k < n ; k++) {
150 acc++;
151 }
152
153 #pragma omp target
154 #pragma omp teams
155 #pragma omp distribute parallel for shared(e, g)
156 for(int k = 0 ; k < n ; k++) {
157 acc++;
158 }
159
160 #pragma omp target
161 #pragma omp teams
162 #pragma omp distribute parallel for shared(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be shared}}
163 for(int k = 0 ; k < n ; k++) {
164 acc++;
165 }
166
167 #pragma omp target
168 #pragma omp teams
169 #pragma omp distribute parallel for private(i), shared(i) // expected-error {{private variable cannot be shared}} expected-note {{defined as private}}
170 for(int k = 0 ; k < n ; k++) {
171 acc++;
172 }
173
174 #pragma omp target
175 #pragma omp teams
176 #pragma omp distribute parallel for firstprivate(i), shared(i) // expected-error {{firstprivate variable cannot be shared}} expected-note {{defined as firstprivate}}
177 for(int k = 0 ; k < n ; k++) {
178 acc++;
179 }
180
181 #pragma omp target
182 #pragma omp teams
183 #pragma omp distribute parallel for private(i)
184 for(int k = 0 ; k < n ; k++) {
185 acc++;
186 }
187
188 #pragma omp target
189 #pragma omp teams
190 #pragma omp distribute parallel for shared(i)
191 for(int k = 0 ; k < n ; k++) {
192 acc++;
193 }
194
195 #pragma omp target
196 #pragma omp teams
197 #pragma omp distribute parallel for shared(j)
198 for(int k = 0 ; k < n ; k++) {
199 acc++;
200 }
201
202 #pragma omp target
203 #pragma omp teams
204 #pragma omp distribute parallel for firstprivate(i)
205 for(int k = 0 ; k < n ; k++) {
206 acc++;
207 }
208
209 #pragma omp target
210 #pragma omp teams
211 #pragma omp distribute parallel for shared(i)
212 for(int k = 0 ; k < n ; k++) {
213 acc++;
214 }
215
216 #pragma omp target
217 #pragma omp teams
218 #pragma omp distribute parallel for shared(j)
219 for(int k = 0 ; k < n ; k++) {
220 acc++;
221 }
222 return T();
223 }
224
225
main(int argc,char ** argv)226 int main(int argc, char **argv) {
227 const int d = 5;
228 const int da[5] = { 0 };
229 S4 e(4);
230 S5 g(5);
231 int i;
232 int &j = i;
233 int acc = 0;
234 int n = argc;
235
236 #pragma omp target
237 #pragma omp teams
238 #pragma omp distribute parallel for shared // expected-error {{expected '(' after 'shared'}}
239 for(int k = 0 ; k < n ; k++) {
240 acc++;
241 }
242
243 #pragma omp target
244 #pragma omp teams
245 #pragma omp distribute parallel for shared ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
246 for(int k = 0 ; k < n ; k++) {
247 acc++;
248 }
249
250 #pragma omp target
251 #pragma omp teams
252 #pragma omp distribute parallel for shared () // expected-error {{expected expression}}
253 for(int k = 0 ; k < n ; k++) {
254 acc++;
255 }
256
257 #pragma omp target
258 #pragma omp teams
259 #pragma omp distribute parallel for shared (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
260 for(int k = 0 ; k < n ; k++) {
261 acc++;
262 }
263
264 #pragma omp target
265 #pragma omp teams
266 #pragma omp distribute parallel for shared (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
267 for(int k = 0 ; k < n ; k++) {
268 acc++;
269 }
270
271 #pragma omp target
272 #pragma omp teams
273 #pragma omp distribute parallel for shared (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
274 for(int k = 0 ; k < n ; k++) {
275 acc++;
276 }
277
278 #pragma omp target
279 #pragma omp teams
280 #pragma omp distribute parallel for shared (argc)
281 for(int k = 0 ; k < n ; k++) {
282 acc++;
283 }
284
285 #pragma omp target
286 #pragma omp teams
287 #pragma omp distribute parallel for shared (S1) // expected-error {{'S1' does not refer to a value}}
288 for(int k = 0 ; k < n ; k++) {
289 acc++;
290 }
291
292 #pragma omp target
293 #pragma omp teams
294 #pragma omp distribute parallel for shared (a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}}
295 for(int k = 0 ; k < n ; k++) {
296 acc++;
297 }
298
299 #pragma omp target
300 #pragma omp teams
301 #pragma omp distribute parallel for shared (argv[1]) // expected-error {{expected variable name}}
302 for(int k = 0 ; k < n ; k++) {
303 acc++;
304 }
305
306 #pragma omp target
307 #pragma omp teams
308 #pragma omp distribute parallel for shared(ba)
309 for(int k = 0 ; k < n ; k++) {
310 acc++;
311 }
312
313 #pragma omp target
314 #pragma omp teams
315 #pragma omp distribute parallel for shared(ca)
316 for(int k = 0 ; k < n ; k++) {
317 acc++;
318 }
319
320 #pragma omp target
321 #pragma omp teams
322 #pragma omp distribute parallel for shared(da)
323 for(int k = 0 ; k < n ; k++) {
324 acc++;
325 }
326
327 #pragma omp target
328 #pragma omp teams
329 #pragma omp distribute parallel for shared(e, g)
330 for(int k = 0 ; k < n ; k++) {
331 acc++;
332 }
333
334 #pragma omp target
335 #pragma omp teams
336 #pragma omp distribute parallel for shared(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be shared}}
337 for(int k = 0 ; k < n ; k++) {
338 acc++;
339 }
340
341 #pragma omp target
342 #pragma omp teams
343 #pragma omp distribute parallel for private(i), shared(i) // expected-error {{private variable cannot be shared}} expected-note {{defined as private}}
344 for(int k = 0 ; k < n ; k++) {
345 acc++;
346 }
347
348 #pragma omp target
349 #pragma omp teams
350 #pragma omp distribute parallel for firstprivate(i), shared(i) // expected-error {{firstprivate variable cannot be shared}} expected-note {{defined as firstprivate}}
351 for(int k = 0 ; k < n ; k++) {
352 acc++;
353 }
354
355 #pragma omp target
356 #pragma omp teams
357 #pragma omp distribute parallel for private(i)
358 for(int k = 0 ; k < n ; k++) {
359 acc++;
360 }
361
362 #pragma omp target
363 #pragma omp teams
364 #pragma omp distribute parallel for shared(i)
365 for(int k = 0 ; k < n ; k++) {
366 acc++;
367 }
368
369 #pragma omp target
370 #pragma omp teams
371 #pragma omp distribute parallel for shared(j)
372 for(int k = 0 ; k < n ; k++) {
373 acc++;
374 }
375
376 #pragma omp target
377 #pragma omp teams
378 #pragma omp distribute parallel for firstprivate(i)
379 for(int k = 0 ; k < n ; k++) {
380 acc++;
381 }
382
383 #pragma omp target
384 #pragma omp teams
385 #pragma omp distribute parallel for shared(i)
386 for(int k = 0 ; k < n ; k++) {
387 acc++;
388 }
389
390 #pragma omp target
391 #pragma omp teams
392 #pragma omp distribute parallel for shared(j)
393 for(int k = 0 ; k < n ; k++) {
394 acc++;
395 }
396
397 return tmain<int, char, 1000>(argc, argv); // expected-note {{in instantiation of function template specialization 'tmain<int, char, 1000>' requested here}}
398 }
399