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}}
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 taskloop'}}
15 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp taskloop'}}
16 #pragma omp taskloop foo
18 void test_no_clause(void) {
21 for (i
= 0; i
< 16; ++i
)
24 // expected-error@+2 {{statement after '#pragma omp taskloop' must be a for loop}}
29 void test_branch_protected_scope(void) {
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) {
60 // expected-warning@+1 {{extra tokens at the end of '#pragma omp taskloop' are ignored}}
61 #pragma omp taskloop foo bar
62 for (i
= 0; i
< 16; ++i
)
64 // expected-error@+1 {{directive '#pragma omp taskloop' cannot contain more than one 'nogroup' clause}}
65 #pragma omp taskloop nogroup nogroup
66 for (i
= 0; i
< 16; ++i
)
70 void test_non_identifiers(void) {
74 // expected-warning@+1 {{extra tokens at the end of '#pragma omp taskloop' are ignored}}
76 for (i
= 0; i
< 16; ++i
)
78 // expected-warning@+3 {{extra tokens at the end of '#pragma omp taskloop' are ignored}}
79 // expected-error@+2 {{unexpected OpenMP clause 'linear' in directive '#pragma omp taskloop'}}
81 #pragma omp taskloop linear(x);
82 for (i
= 0; i
< 16; ++i
)
86 // expected-warning@+1 {{extra tokens at the end of '#pragma omp taskloop' are ignored}}
87 #pragma omp taskloop private(x);
88 for (i
= 0; i
< 16; ++i
)
92 // expected-warning@+1 {{extra tokens at the end of '#pragma omp taskloop' are ignored}}
93 #pragma omp taskloop, private(x);
94 for (i
= 0; i
< 16; ++i
)
100 void test_collapse(void) {
103 // expected-error@+1 {{expected '('}}
104 #pragma omp taskloop collapse
105 for (i
= 0; i
< 16; ++i
)
108 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
109 #pragma omp taskloop collapse(
110 for (i
= 0; i
< 16; ++i
)
113 // expected-error@+1 {{expected expression}}
114 #pragma omp taskloop collapse()
115 for (i
= 0; i
< 16; ++i
)
118 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
119 #pragma omp taskloop collapse(,
120 for (i
= 0; i
< 16; ++i
)
123 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
124 #pragma omp taskloop collapse(, )
125 for (i
= 0; i
< 16; ++i
)
128 // expected-warning@+2 {{extra tokens at the end of '#pragma omp taskloop' are ignored}}
129 // expected-error@+1 {{expected '('}}
130 #pragma omp taskloop collapse 4)
131 for (i
= 0; i
< 16; ++i
)
134 // expected-error@+2 {{expected ')'}}
135 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
136 #pragma omp taskloop collapse(4
137 for (i
= 0; i
< 16; ++i
)
138 ; // expected-error {{expected 4 for loops after '#pragma omp taskloop', but found only 1}}
140 // expected-error@+2 {{expected ')'}}
141 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
142 #pragma omp taskloop collapse(4,
143 for (i
= 0; i
< 16; ++i
)
144 ; // expected-error {{expected 4 for loops after '#pragma omp taskloop', but found only 1}}
146 // expected-error@+2 {{expected ')'}}
147 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
148 #pragma omp taskloop collapse(4, )
149 for (i
= 0; i
< 16; ++i
)
150 ; // expected-error {{expected 4 for loops after '#pragma omp taskloop', but found only 1}}
152 // expected-note@+1 {{as specified in 'collapse' clause}}
153 #pragma omp taskloop collapse(4)
154 for (i
= 0; i
< 16; ++i
)
155 ; // expected-error {{expected 4 for loops after '#pragma omp taskloop', but found only 1}}
157 // expected-error@+2 {{expected ')'}}
158 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
159 #pragma omp taskloop collapse(4 4)
160 for (i
= 0; i
< 16; ++i
)
161 ; // expected-error {{expected 4 for loops after '#pragma omp taskloop', but found only 1}}
163 // expected-error@+2 {{expected ')'}}
164 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
165 #pragma omp taskloop collapse(4, , 4)
166 for (i
= 0; i
< 16; ++i
)
167 ; // expected-error {{expected 4 for loops after '#pragma omp taskloop', but found only 1}}
169 #pragma omp taskloop collapse(4)
170 for (int i1
= 0; i1
< 16; ++i1
)
171 for (int i2
= 0; i2
< 16; ++i2
)
172 for (int i3
= 0; i3
< 16; ++i3
)
173 for (int i4
= 0; i4
< 16; ++i4
)
176 // expected-error@+2 {{expected ')'}}
177 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
178 #pragma omp taskloop collapse(4, 8)
179 for (i
= 0; i
< 16; ++i
)
180 ; // expected-error {{expected 4 for loops after '#pragma omp taskloop', but found only 1}}
182 // expected-error@+1 {{integer constant expression}}
183 #pragma omp taskloop collapse(2.5)
184 for (i
= 0; i
< 16; ++i
)
187 // expected-error@+1 {{integer constant expression}}
188 #pragma omp taskloop collapse(foo())
189 for (i
= 0; i
< 16; ++i
)
192 // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
193 #pragma omp taskloop collapse(-5)
194 for (i
= 0; i
< 16; ++i
)
197 // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
198 #pragma omp taskloop collapse(0)
199 for (i
= 0; i
< 16; ++i
)
202 // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
203 #pragma omp taskloop collapse(5 - 5)
204 for (i
= 0; i
< 16; ++i
)
208 void test_private(void) {
211 // expected-error@+2 {{expected expression}}
212 // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
213 #pragma omp taskloop private(
214 for (i
= 0; i
< 16; ++i
)
217 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
218 // expected-error@+1 2 {{expected expression}}
219 #pragma omp taskloop private(,
220 for (i
= 0; i
< 16; ++i
)
223 // expected-error@+1 2 {{expected expression}}
224 #pragma omp taskloop private(, )
225 for (i
= 0; i
< 16; ++i
)
228 // expected-error@+1 {{expected expression}}
229 #pragma omp taskloop private()
230 for (i
= 0; i
< 16; ++i
)
233 // expected-error@+1 {{expected expression}}
234 #pragma omp taskloop private(int)
235 for (i
= 0; i
< 16; ++i
)
238 // expected-error@+1 {{expected variable name}}
239 #pragma omp taskloop private(0)
240 for (i
= 0; i
< 16; ++i
)
245 #pragma omp taskloop private(x)
246 for (i
= 0; i
< 16; ++i
)
249 #pragma omp taskloop private(x, y)
250 for (i
= 0; i
< 16; ++i
)
253 #pragma omp taskloop private(x, y, z)
254 for (i
= 0; i
< 16; ++i
) {
259 void test_lastprivate(void) {
262 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
263 // expected-error@+1 {{expected expression}}
264 #pragma omp taskloop lastprivate(
265 for (i
= 0; i
< 16; ++i
)
269 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
270 // expected-error@+1 2 {{expected expression}}
271 #pragma omp taskloop lastprivate(,
272 for (i
= 0; i
< 16; ++i
)
275 // expected-error@+1 2 {{expected expression}}
276 #pragma omp taskloop lastprivate(, )
277 for (i
= 0; i
< 16; ++i
)
280 // expected-error@+1 {{expected expression}}
281 #pragma omp taskloop lastprivate()
282 for (i
= 0; i
< 16; ++i
)
285 // expected-error@+1 {{expected expression}}
286 #pragma omp taskloop lastprivate(int)
287 for (i
= 0; i
< 16; ++i
)
290 // expected-error@+1 {{expected variable name}}
291 #pragma omp taskloop lastprivate(0)
292 for (i
= 0; i
< 16; ++i
)
297 #pragma omp taskloop lastprivate(x)
298 for (i
= 0; i
< 16; ++i
)
301 #pragma omp taskloop lastprivate(x, y)
302 for (i
= 0; i
< 16; ++i
)
305 #pragma omp taskloop lastprivate(x, y, z)
306 for (i
= 0; i
< 16; ++i
)
310 void test_firstprivate(void) {
313 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
314 // expected-error@+1 {{expected expression}}
315 #pragma omp taskloop firstprivate(
316 for (i
= 0; i
< 16; ++i
)
320 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
321 // expected-error@+1 2 {{expected expression}}
322 #pragma omp taskloop firstprivate(,
323 for (i
= 0; i
< 16; ++i
)
326 // expected-error@+1 2 {{expected expression}}
327 #pragma omp taskloop firstprivate(, )
328 for (i
= 0; i
< 16; ++i
)
331 // expected-error@+1 {{expected expression}}
332 #pragma omp taskloop firstprivate()
333 for (i
= 0; i
< 16; ++i
)
336 // expected-error@+1 {{expected expression}}
337 #pragma omp taskloop firstprivate(int)
338 for (i
= 0; i
< 16; ++i
)
341 // expected-error@+1 {{expected variable name}}
342 #pragma omp taskloop firstprivate(0)
343 for (i
= 0; i
< 16; ++i
)
348 #pragma omp taskloop lastprivate(x) firstprivate(x)
349 for (i
= 0; i
< 16; ++i
)
352 #pragma omp taskloop lastprivate(x, y) firstprivate(x, y)
353 for (i
= 0; i
< 16; ++i
)
356 #pragma omp taskloop lastprivate(x, y, z) firstprivate(x, y, z)
357 for (i
= 0; i
< 16; ++i
)
361 void test_loop_messages(void) {
362 float a
[100], b
[100], c
[100];
364 // expected-error@+2 {{variable must be of integer or pointer type}}
366 for (float fi
= 0; fi
< 10.0; fi
++) {
367 c
[(int)fi
] = a
[(int)fi
] + b
[(int)fi
];
370 // expected-error@+2 {{variable must be of integer or pointer type}}
372 for (double fi
= 0; fi
< 10.0; fi
++) {
373 c
[(int)fi
] = a
[(int)fi
] + b
[(int)fi
];
376 // expected-warning@+2 {{OpenMP loop iteration variable cannot have more than 64 bits size and will be narrowed}}
378 for (__int128 ii
= 0; ii
< 10; ii
++) {
379 c
[ii
] = a
[ii
] + b
[ii
];