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
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) {
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
29 void test_branch_protected_scope(void) {
37 #pragma omp parallel master taskloop
38 for (i
= 0; i
< 16; ++i
) {
40 goto L1
; // expected-error {{use of undeclared label 'L1'}}
42 return; // expected-error {{cannot return from OpenMP region}}
52 goto L2
; // expected-error {{use of undeclared label 'L2'}}
57 void test_invalid_clause(void) {
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) {
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'}}
84 #pragma omp parallel master taskloop linear(x);
85 for (i
= 0; i
< 16; ++i
)
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
)
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) {
106 // expected-error@+1 {{expected '('}}
107 #pragma omp parallel master taskloop collapse
108 for (i
= 0; i
< 16; ++i
)
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
)
116 // expected-error@+1 {{expected expression}}
117 #pragma omp parallel master taskloop collapse()
118 for (i
= 0; i
< 16; ++i
)
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
)
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
)
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
)
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}}
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}}
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}}
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}}
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}}
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}}
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
)
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}}
185 // expected-error@+1 {{integer constant expression}}
186 #pragma omp parallel master taskloop collapse(2.5)
187 for (i
= 0; i
< 16; ++i
)
190 // expected-error@+1 {{integer constant expression}}
191 #pragma omp parallel master taskloop collapse(foo())
192 for (i
= 0; i
< 16; ++i
)
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
)
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
)
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) {
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
)
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
)
226 // expected-error@+1 2 {{expected expression}}
227 #pragma omp parallel master taskloop private(, )
228 for (i
= 0; i
< 16; ++i
)
231 // expected-error@+1 {{expected expression}}
232 #pragma omp parallel master taskloop private()
233 for (i
= 0; i
< 16; ++i
)
236 // expected-error@+1 {{expected expression}}
237 #pragma omp parallel master taskloop private(int)
238 for (i
= 0; i
< 16; ++i
)
241 // expected-error@+1 {{expected variable name}}
242 #pragma omp parallel master taskloop private(0)
243 for (i
= 0; i
< 16; ++i
)
248 #pragma omp parallel master taskloop private(x)
249 for (i
= 0; i
< 16; ++i
)
252 #pragma omp parallel master taskloop private(x, y)
253 for (i
= 0; i
< 16; ++i
)
256 #pragma omp parallel master taskloop private(x, y, z)
257 for (i
= 0; i
< 16; ++i
) {
262 void test_lastprivate(void) {
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
)
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
)
278 // expected-error@+1 2 {{expected expression}}
279 #pragma omp parallel master taskloop lastprivate(, )
280 for (i
= 0; i
< 16; ++i
)
283 // expected-error@+1 {{expected expression}}
284 #pragma omp parallel master taskloop lastprivate()
285 for (i
= 0; i
< 16; ++i
)
288 // expected-error@+1 {{expected expression}}
289 #pragma omp parallel master taskloop lastprivate(int)
290 for (i
= 0; i
< 16; ++i
)
293 // expected-error@+1 {{expected variable name}}
294 #pragma omp parallel master taskloop lastprivate(0)
295 for (i
= 0; i
< 16; ++i
)
300 #pragma omp parallel master taskloop lastprivate(x)
301 for (i
= 0; i
< 16; ++i
)
304 #pragma omp parallel master taskloop lastprivate(x, y)
305 for (i
= 0; i
< 16; ++i
)
308 #pragma omp parallel master taskloop lastprivate(x, y, z)
309 for (i
= 0; i
< 16; ++i
)
313 void test_firstprivate(void) {
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
)
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
)
329 // expected-error@+1 2 {{expected expression}}
330 #pragma omp parallel master taskloop firstprivate(, )
331 for (i
= 0; i
< 16; ++i
)
334 // expected-error@+1 {{expected expression}}
335 #pragma omp parallel master taskloop firstprivate()
336 for (i
= 0; i
< 16; ++i
)
339 // expected-error@+1 {{expected expression}}
340 #pragma omp parallel master taskloop firstprivate(int)
341 for (i
= 0; i
< 16; ++i
)
344 // expected-error@+1 {{expected variable name}}
345 #pragma omp parallel master taskloop firstprivate(0)
346 for (i
= 0; i
< 16; ++i
)
351 #pragma omp parallel master taskloop lastprivate(x) firstprivate(x)
352 for (i
= 0; i
< 16; ++i
)
355 #pragma omp parallel master taskloop lastprivate(x, y) firstprivate(x, y)
356 for (i
= 0; i
< 16; ++i
)
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];
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
];
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
];