[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / distribute_parallel_for_simd_shared_messages.cpp
blob6dc6e777fb33d4c79022b957589fdef68982ed5d
1 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized
3 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
6 struct S1; // expected-note 2 {{declared here}} // expected-note 2 {{forward declaration of 'S1'}}
7 extern S1 a;
8 class S2 {
9 mutable int a;
10 public:
11 S2():a(0) { }
12 S2(S2 &s2):a(s2.a) { }
14 const S2 b;
15 const S2 ba[5];
16 class S3 {
17 int a;
18 public:
19 S3():a(0) { }
20 S3(S3 &s3):a(s3.a) { }
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:
30 S4(int v):a(v) { }
32 class S5 {
33 int a;
34 S5():a(0) {}
35 S5(const S5 &s5):a(s5.a) { }
36 public:
37 S5(int v):a(v) { }
40 S3 h;
41 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
43 namespace A {
44 double x;
45 #pragma omp threadprivate(x) // expected-note 2 {{defined as threadprivate or thread local}}
47 namespace B {
48 using A::x;
51 template <class T, typename S, int N>
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, z;
58 int &j = i;
59 int acc = 0;
60 int n = 1000;
62 #pragma omp target
63 #pragma omp teams
64 #pragma omp distribute parallel for simd shared // expected-error {{expected '(' after 'shared'}}
65 for(int k = 0 ; k < n ; k++) {
66 acc++;
69 #pragma omp target
70 #pragma omp teams
71 #pragma omp distribute parallel for simd shared ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
72 for(int k = 0 ; k < n ; k++) {
73 acc++;
76 #pragma omp target
77 #pragma omp teams
78 #pragma omp distribute parallel for simd shared () // expected-error {{expected expression}}
79 for(int k = 0 ; k < n ; k++) {
80 acc++;
83 #pragma omp target
84 #pragma omp teams
85 #pragma omp distribute parallel for simd shared (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
86 for(int k = 0 ; k < n ; k++) {
87 acc++;
90 #pragma omp target
91 #pragma omp teams
92 #pragma omp distribute parallel for simd shared (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
93 for(int k = 0 ; k < n ; k++) {
94 acc++;
97 #pragma omp target
98 #pragma omp teams
99 #pragma omp distribute parallel for simd shared (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
100 for(int k = 0 ; k < n ; k++) {
101 acc++;
104 #pragma omp target
105 #pragma omp teams
106 #pragma omp distribute parallel for simd shared (argc, z)
107 for(int k = 0 ; k < n ; k++) {
108 acc++;
111 #pragma omp target
112 #pragma omp teams
113 #pragma omp distribute parallel for simd shared (S1) // expected-error {{'S1' does not refer to a value}}
114 for(int k = 0 ; k < n ; k++) {
115 acc++;
118 #pragma omp target
119 #pragma omp teams
120 #pragma omp distribute parallel for simd shared (a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} expected-warning {{type 'const S2' is not trivially copyable and not guaranteed to be mapped correctly}} expected-warning {{type 'const S3' is not trivially copyable and not guaranteed to be mapped correctly}}
121 for(int k = 0 ; k < n ; k++) {
122 acc++;
125 #pragma omp target
126 #pragma omp teams
127 #pragma omp distribute parallel for simd shared (argv[1]) // expected-error {{expected variable name}}
128 for(int k = 0 ; k < n ; k++) {
129 acc++;
132 #pragma omp target
133 #pragma omp teams
134 #pragma omp distribute parallel for simd shared(ba) // expected-warning {{type 'const S2[5]' is not trivially copyable and not guaranteed to be mapped correctly}}
135 for(int k = 0 ; k < n ; k++) {
136 acc++;
139 #pragma omp target
140 #pragma omp teams
141 #pragma omp distribute parallel for simd shared(ca) // expected-warning {{type 'const S3[5]' is not trivially copyable and not guaranteed to be mapped correctly}}
142 for(int k = 0 ; k < n ; k++) {
143 acc++;
146 #pragma omp target
147 #pragma omp teams
148 #pragma omp distribute parallel for simd shared(da)
149 for(int k = 0 ; k < n ; k++) {
150 acc++;
153 #pragma omp target
154 #pragma omp teams
155 #pragma omp distribute parallel for simd shared(e, g) // expected-warning {{type 'S4' is not trivially copyable and not guaranteed to be mapped correctly}} expected-warning {{type 'S5' is not trivially copyable and not guaranteed to be mapped correctly}}
156 for(int k = 0 ; k < n ; k++) {
157 acc++;
160 #pragma omp target
161 #pragma omp teams
162 #pragma omp distribute parallel for simd 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++;
167 #pragma omp target
168 #pragma omp teams
169 #pragma omp distribute parallel for simd 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++;
174 #pragma omp target
175 #pragma omp teams
176 #pragma omp distribute parallel for simd 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++;
181 #pragma omp target
182 #pragma omp teams
183 #pragma omp distribute parallel for simd private(i)
184 for(int k = 0 ; k < n ; k++) {
185 acc++;
188 #pragma omp target
189 #pragma omp teams
190 #pragma omp distribute parallel for simd shared(i)
191 for(int k = 0 ; k < n ; k++) {
192 acc++;
195 #pragma omp target
196 #pragma omp teams
197 #pragma omp distribute parallel for simd shared(j)
198 for(int k = 0 ; k < n ; k++) {
199 acc++;
202 #pragma omp target
203 #pragma omp teams
204 #pragma omp distribute parallel for simd firstprivate(i)
205 for(int k = 0 ; k < n ; k++) {
206 acc++;
209 #pragma omp target
210 #pragma omp teams
211 #pragma omp distribute parallel for simd shared(i)
212 for(int k = 0 ; k < n ; k++) {
213 acc++;
216 #pragma omp target
217 #pragma omp teams
218 #pragma omp distribute parallel for simd shared(j)
219 for(int k = 0 ; k < n ; k++) {
220 acc++;
222 return T();
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, z;
232 int &j = i;
233 int acc = 0;
234 int n = argc;
236 #pragma omp target
237 #pragma omp teams
238 #pragma omp distribute parallel for simd shared // expected-error {{expected '(' after 'shared'}}
239 for(int k = 0 ; k < n ; k++) {
240 acc++;
243 #pragma omp target
244 #pragma omp teams
245 #pragma omp distribute parallel for simd shared ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
246 for(int k = 0 ; k < n ; k++) {
247 acc++;
250 #pragma omp target
251 #pragma omp teams
252 #pragma omp distribute parallel for simd shared () // expected-error {{expected expression}}
253 for(int k = 0 ; k < n ; k++) {
254 acc++;
257 #pragma omp target
258 #pragma omp teams
259 #pragma omp distribute parallel for simd shared (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
260 for(int k = 0 ; k < n ; k++) {
261 acc++;
264 #pragma omp target
265 #pragma omp teams
266 #pragma omp distribute parallel for simd shared (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
267 for(int k = 0 ; k < n ; k++) {
268 acc++;
271 #pragma omp target
272 #pragma omp teams
273 #pragma omp distribute parallel for simd shared (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
274 for(int k = 0 ; k < n ; k++) {
275 acc++;
278 #pragma omp target
279 #pragma omp teams
280 #pragma omp distribute parallel for simd shared (argc, z)
281 for(int k = 0 ; k < n ; k++) {
282 acc++;
285 #pragma omp target
286 #pragma omp teams
287 #pragma omp distribute parallel for simd shared (S1) // expected-error {{'S1' does not refer to a value}}
288 for(int k = 0 ; k < n ; k++) {
289 acc++;
292 #pragma omp target
293 #pragma omp teams
294 #pragma omp distribute parallel for simd shared (a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} expected-warning {{type 'const S2' is not trivially copyable and not guaranteed to be mapped correctly}} expected-warning {{type 'const S3' is not trivially copyable and not guaranteed to be mapped correctly}}
295 for(int k = 0 ; k < n ; k++) {
296 acc++;
299 #pragma omp target
300 #pragma omp teams
301 #pragma omp distribute parallel for simd shared (argv[1]) // expected-error {{expected variable name}}
302 for(int k = 0 ; k < n ; k++) {
303 acc++;
306 #pragma omp target
307 #pragma omp teams
308 #pragma omp distribute parallel for simd shared(ba) // expected-warning {{type 'const S2[5]' is not trivially copyable and not guaranteed to be mapped correctly}}
309 for(int k = 0 ; k < n ; k++) {
310 acc++;
313 #pragma omp target
314 #pragma omp teams
315 #pragma omp distribute parallel for simd shared(ca) // expected-warning {{type 'const S3[5]' is not trivially copyable and not guaranteed to be mapped correctly}}
316 for(int k = 0 ; k < n ; k++) {
317 acc++;
320 #pragma omp target
321 #pragma omp teams
322 #pragma omp distribute parallel for simd shared(da)
323 for(int k = 0 ; k < n ; k++) {
324 acc++;
327 #pragma omp target
328 #pragma omp teams
329 #pragma omp distribute parallel for simd shared(e, g) // expected-warning {{type 'S4' is not trivially copyable and not guaranteed to be mapped correctly}} expected-warning {{type 'S5' is not trivially copyable and not guaranteed to be mapped correctly}}
330 for(int k = 0 ; k < n ; k++) {
331 acc++;
334 #pragma omp target
335 #pragma omp teams
336 #pragma omp distribute parallel for simd 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++;
341 #pragma omp target
342 #pragma omp teams
343 #pragma omp distribute parallel for simd 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++;
348 #pragma omp target
349 #pragma omp teams
350 #pragma omp distribute parallel for simd 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++;
355 #pragma omp target
356 #pragma omp teams
357 #pragma omp distribute parallel for simd private(i)
358 for(int k = 0 ; k < n ; k++) {
359 acc++;
362 #pragma omp target
363 #pragma omp teams
364 #pragma omp distribute parallel for simd shared(i)
365 for(int k = 0 ; k < n ; k++) {
366 acc++;
369 #pragma omp target
370 #pragma omp teams
371 #pragma omp distribute parallel for simd shared(j)
372 for(int k = 0 ; k < n ; k++) {
373 acc++;
376 #pragma omp target
377 #pragma omp teams
378 #pragma omp distribute parallel for simd firstprivate(i)
379 for(int k = 0 ; k < n ; k++) {
380 acc++;
383 #pragma omp target
384 #pragma omp teams
385 #pragma omp distribute parallel for simd shared(i)
386 for(int k = 0 ; k < n ; k++) {
387 acc++;
390 #pragma omp target
391 #pragma omp teams
392 #pragma omp distribute parallel for simd shared(j)
393 for(int k = 0 ; k < n ; k++) {
394 acc++;
397 return tmain<int, char, 1000>(argc, argv); // expected-note {{in instantiation of function template specialization 'tmain<int, char, 1000>' requested here}}