Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / parallel_master_taskloop_misc_messages.c
blob8232e902a96e41d88edeef510755641e3800f62c
1 // RUN: %clang_cc1 -fsyntax-only -fopenmp -triple x86_64-unknown-unknown -verify %s -Wuninitialized
3 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -triple x86_64-unknown-unknown -verify %s -Wuninitialized
5 void xxx(int argc) {
6 int x; // expected-note {{initialize the variable 'x' to silence this warning}}
7 #pragma omp parallel master taskloop
8 for (int i = 0; i < 10; ++i)
9 argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
12 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp parallel master taskloop'}}
13 #pragma omp parallel master taskloop
15 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp parallel master taskloop'}}
16 #pragma omp parallel master taskloop foo
18 void test_no_clause(void) {
19 int i;
20 #pragma omp parallel master taskloop
21 for (i = 0; i < 16; ++i)
24 // expected-error@+2 {{statement after '#pragma omp parallel master taskloop' must be a for loop}}
25 #pragma omp parallel master taskloop
26 ++i;
29 void test_branch_protected_scope(void) {
30 int i = 0;
31 L1:
32 ++i;
34 int x[24];
36 #pragma omp parallel
37 #pragma omp parallel master taskloop
38 for (i = 0; i < 16; ++i) {
39 if (i == 5)
40 goto L1; // expected-error {{use of undeclared label 'L1'}}
41 else if (i == 6)
42 return; // expected-error {{cannot return from OpenMP region}}
43 else if (i == 7)
44 goto L2;
45 else if (i == 8) {
46 L2:
47 x[i]++;
51 if (x[0] == 0)
52 goto L2; // expected-error {{use of undeclared label 'L2'}}
53 else if (x[1] == 1)
54 goto L1;
57 void test_invalid_clause(void) {
58 int i, a;
59 // expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel master taskloop' are ignored}}
60 #pragma omp parallel master taskloop foo bar
61 for (i = 0; i < 16; ++i)
63 // expected-error@+1 {{directive '#pragma omp parallel master taskloop' cannot contain more than one 'nogroup' clause}}
64 #pragma omp parallel master taskloop nogroup nogroup
65 for (i = 0; i < 16; ++i)
67 // expected-error@+1 {{unexpected OpenMP clause 'in_reduction' in directive '#pragma omp parallel master taskloop'}}
68 #pragma omp parallel master taskloop in_reduction(+:a)
69 for (i = 0; i < 16; ++i)
73 void test_non_identifiers(void) {
74 int i, x;
76 #pragma omp parallel
77 // expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel master taskloop' are ignored}}
78 #pragma omp parallel master taskloop;
79 for (i = 0; i < 16; ++i)
81 // expected-warning@+3 {{extra tokens at the end of '#pragma omp parallel master taskloop' are ignored}}
82 // expected-error@+2 {{unexpected OpenMP clause 'linear' in directive '#pragma omp parallel master taskloop'}}
83 #pragma omp parallel
84 #pragma omp parallel master taskloop linear(x);
85 for (i = 0; i < 16; ++i)
88 #pragma omp parallel
89 // expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel master taskloop' are ignored}}
90 #pragma omp parallel master taskloop private(x);
91 for (i = 0; i < 16; ++i)
94 #pragma omp parallel
95 // expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel master taskloop' are ignored}}
96 #pragma omp parallel master taskloop, private(x);
97 for (i = 0; i < 16; ++i)
101 extern int foo(void);
103 void test_collapse(void) {
104 int i;
105 #pragma omp parallel
106 // expected-error@+1 {{expected '('}}
107 #pragma omp parallel master taskloop collapse
108 for (i = 0; i < 16; ++i)
110 #pragma omp parallel
111 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
112 #pragma omp parallel master taskloop collapse(
113 for (i = 0; i < 16; ++i)
115 #pragma omp parallel
116 // expected-error@+1 {{expected expression}}
117 #pragma omp parallel master taskloop collapse()
118 for (i = 0; i < 16; ++i)
120 #pragma omp parallel
121 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
122 #pragma omp parallel master taskloop collapse(,
123 for (i = 0; i < 16; ++i)
125 #pragma omp parallel
126 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
127 #pragma omp parallel master taskloop collapse(, )
128 for (i = 0; i < 16; ++i)
130 #pragma omp parallel
131 // expected-warning@+2 {{extra tokens at the end of '#pragma omp parallel master taskloop' are ignored}}
132 // expected-error@+1 {{expected '('}}
133 #pragma omp parallel master taskloop collapse 4)
134 for (i = 0; i < 16; ++i)
136 #pragma omp parallel
137 // expected-error@+2 {{expected ')'}}
138 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
139 #pragma omp parallel master taskloop collapse(4
140 for (i = 0; i < 16; ++i)
141 ; // expected-error {{expected 4 for loops after '#pragma omp parallel master taskloop', but found only 1}}
142 #pragma omp parallel
143 // expected-error@+2 {{expected ')'}}
144 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
145 #pragma omp parallel master taskloop collapse(4,
146 for (i = 0; i < 16; ++i)
147 ; // expected-error {{expected 4 for loops after '#pragma omp parallel master taskloop', but found only 1}}
148 #pragma omp parallel
149 // expected-error@+2 {{expected ')'}}
150 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
151 #pragma omp parallel master taskloop collapse(4, )
152 for (i = 0; i < 16; ++i)
153 ; // expected-error {{expected 4 for loops after '#pragma omp parallel master taskloop', but found only 1}}
154 #pragma omp parallel
155 // expected-note@+1 {{as specified in 'collapse' clause}}
156 #pragma omp parallel master taskloop collapse(4)
157 for (i = 0; i < 16; ++i)
158 ; // expected-error {{expected 4 for loops after '#pragma omp parallel master taskloop', but found only 1}}
159 #pragma omp parallel
160 // expected-error@+2 {{expected ')'}}
161 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
162 #pragma omp parallel master taskloop collapse(4 4)
163 for (i = 0; i < 16; ++i)
164 ; // expected-error {{expected 4 for loops after '#pragma omp parallel master taskloop', but found only 1}}
165 #pragma omp parallel
166 // expected-error@+2 {{expected ')'}}
167 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
168 #pragma omp parallel master taskloop collapse(4, , 4)
169 for (i = 0; i < 16; ++i)
170 ; // expected-error {{expected 4 for loops after '#pragma omp parallel master taskloop', but found only 1}}
171 #pragma omp parallel
172 #pragma omp parallel master taskloop collapse(4)
173 for (int i1 = 0; i1 < 16; ++i1)
174 for (int i2 = 0; i2 < 16; ++i2)
175 for (int i3 = 0; i3 < 16; ++i3)
176 for (int i4 = 0; i4 < 16; ++i4)
177 foo();
178 #pragma omp parallel
179 // expected-error@+2 {{expected ')'}}
180 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
181 #pragma omp parallel master taskloop collapse(4, 8)
182 for (i = 0; i < 16; ++i)
183 ; // expected-error {{expected 4 for loops after '#pragma omp parallel master taskloop', but found only 1}}
184 #pragma omp parallel
185 // expected-error@+1 {{integer constant expression}}
186 #pragma omp parallel master taskloop collapse(2.5)
187 for (i = 0; i < 16; ++i)
189 #pragma omp parallel
190 // expected-error@+1 {{integer constant expression}}
191 #pragma omp parallel master taskloop collapse(foo())
192 for (i = 0; i < 16; ++i)
194 #pragma omp parallel
195 // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
196 #pragma omp parallel master taskloop collapse(-5)
197 for (i = 0; i < 16; ++i)
199 #pragma omp parallel
200 // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
201 #pragma omp parallel master taskloop collapse(0)
202 for (i = 0; i < 16; ++i)
204 #pragma omp parallel
205 // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
206 #pragma omp parallel master taskloop collapse(5 - 5)
207 for (i = 0; i < 16; ++i)
211 void test_private(void) {
212 int i;
213 #pragma omp parallel
214 // expected-error@+2 {{expected expression}}
215 // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
216 #pragma omp parallel master taskloop private(
217 for (i = 0; i < 16; ++i)
219 #pragma omp parallel
220 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
221 // expected-error@+1 2 {{expected expression}}
222 #pragma omp parallel master taskloop private(,
223 for (i = 0; i < 16; ++i)
225 #pragma omp parallel
226 // expected-error@+1 2 {{expected expression}}
227 #pragma omp parallel master taskloop private(, )
228 for (i = 0; i < 16; ++i)
230 #pragma omp parallel
231 // expected-error@+1 {{expected expression}}
232 #pragma omp parallel master taskloop private()
233 for (i = 0; i < 16; ++i)
235 #pragma omp parallel
236 // expected-error@+1 {{expected expression}}
237 #pragma omp parallel master taskloop private(int)
238 for (i = 0; i < 16; ++i)
240 #pragma omp parallel
241 // expected-error@+1 {{expected variable name}}
242 #pragma omp parallel master taskloop private(0)
243 for (i = 0; i < 16; ++i)
246 int x, y, z;
247 #pragma omp parallel
248 #pragma omp parallel master taskloop private(x)
249 for (i = 0; i < 16; ++i)
251 #pragma omp parallel
252 #pragma omp parallel master taskloop private(x, y)
253 for (i = 0; i < 16; ++i)
255 #pragma omp parallel
256 #pragma omp parallel master taskloop private(x, y, z)
257 for (i = 0; i < 16; ++i) {
258 x = y * i + z;
262 void test_lastprivate(void) {
263 int i;
264 #pragma omp parallel
265 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
266 // expected-error@+1 {{expected expression}}
267 #pragma omp parallel master taskloop lastprivate(
268 for (i = 0; i < 16; ++i)
271 #pragma omp parallel
272 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
273 // expected-error@+1 2 {{expected expression}}
274 #pragma omp parallel master taskloop lastprivate(,
275 for (i = 0; i < 16; ++i)
277 #pragma omp parallel
278 // expected-error@+1 2 {{expected expression}}
279 #pragma omp parallel master taskloop lastprivate(, )
280 for (i = 0; i < 16; ++i)
282 #pragma omp parallel
283 // expected-error@+1 {{expected expression}}
284 #pragma omp parallel master taskloop lastprivate()
285 for (i = 0; i < 16; ++i)
287 #pragma omp parallel
288 // expected-error@+1 {{expected expression}}
289 #pragma omp parallel master taskloop lastprivate(int)
290 for (i = 0; i < 16; ++i)
292 #pragma omp parallel
293 // expected-error@+1 {{expected variable name}}
294 #pragma omp parallel master taskloop lastprivate(0)
295 for (i = 0; i < 16; ++i)
298 int x, y, z;
299 #pragma omp parallel
300 #pragma omp parallel master taskloop lastprivate(x)
301 for (i = 0; i < 16; ++i)
303 #pragma omp parallel
304 #pragma omp parallel master taskloop lastprivate(x, y)
305 for (i = 0; i < 16; ++i)
307 #pragma omp parallel
308 #pragma omp parallel master taskloop lastprivate(x, y, z)
309 for (i = 0; i < 16; ++i)
313 void test_firstprivate(void) {
314 int i;
315 #pragma omp parallel
316 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
317 // expected-error@+1 {{expected expression}}
318 #pragma omp parallel master taskloop firstprivate(
319 for (i = 0; i < 16; ++i)
322 #pragma omp parallel
323 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
324 // expected-error@+1 2 {{expected expression}}
325 #pragma omp parallel master taskloop firstprivate(,
326 for (i = 0; i < 16; ++i)
328 #pragma omp parallel
329 // expected-error@+1 2 {{expected expression}}
330 #pragma omp parallel master taskloop firstprivate(, )
331 for (i = 0; i < 16; ++i)
333 #pragma omp parallel
334 // expected-error@+1 {{expected expression}}
335 #pragma omp parallel master taskloop firstprivate()
336 for (i = 0; i < 16; ++i)
338 #pragma omp parallel
339 // expected-error@+1 {{expected expression}}
340 #pragma omp parallel master taskloop firstprivate(int)
341 for (i = 0; i < 16; ++i)
343 #pragma omp parallel
344 // expected-error@+1 {{expected variable name}}
345 #pragma omp parallel master taskloop firstprivate(0)
346 for (i = 0; i < 16; ++i)
349 int x, y, z;
350 #pragma omp parallel
351 #pragma omp parallel master taskloop lastprivate(x) firstprivate(x)
352 for (i = 0; i < 16; ++i)
354 #pragma omp parallel
355 #pragma omp parallel master taskloop lastprivate(x, y) firstprivate(x, y)
356 for (i = 0; i < 16; ++i)
358 #pragma omp parallel
359 #pragma omp parallel master taskloop lastprivate(x, y, z) firstprivate(x, y, z)
360 for (i = 0; i < 16; ++i)
364 void test_loop_messages(void) {
365 float a[100], b[100], c[100];
366 #pragma omp parallel
367 // expected-error@+2 {{variable must be of integer or pointer type}}
368 #pragma omp parallel master taskloop
369 for (float fi = 0; fi < 10.0; fi++) {
370 c[(int)fi] = a[(int)fi] + b[(int)fi];
372 #pragma omp parallel
373 // expected-error@+2 {{variable must be of integer or pointer type}}
374 #pragma omp parallel master taskloop
375 for (double fi = 0; fi < 10.0; fi++) {
376 c[(int)fi] = a[(int)fi] + b[(int)fi];
379 // expected-warning@+2 {{OpenMP loop iteration variable cannot have more than 64 bits size and will be narrowed}}
380 #pragma omp parallel master taskloop
381 for (__int128 ii = 0; ii < 10; ii++) {
382 c[ii] = a[ii] + b[ii];