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