1 // RUN: %clang_cc1 -fsyntax-only -fopenmp -triple x86_64-unknown-unknown -verify %s
2
3 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp taskloop'}}
4 #pragma omp taskloop
5
6 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp taskloop'}}
7 #pragma omp taskloop foo
8
test_no_clause()9 void test_no_clause() {
10 int i;
11 #pragma omp taskloop
12 for (i = 0; i < 16; ++i)
13 ;
14
15 // expected-error@+2 {{statement after '#pragma omp taskloop' must be a for loop}}
16 #pragma omp taskloop
17 ++i;
18 }
19
test_branch_protected_scope()20 void test_branch_protected_scope() {
21 int i = 0;
22 L1:
23 ++i;
24
25 int x[24];
26
27 #pragma omp parallel
28 #pragma omp taskloop
29 for (i = 0; i < 16; ++i) {
30 if (i == 5)
31 goto L1; // expected-error {{use of undeclared label 'L1'}}
32 else if (i == 6)
33 return; // expected-error {{cannot return from OpenMP region}}
34 else if (i == 7)
35 goto L2;
36 else if (i == 8) {
37 L2:
38 x[i]++;
39 }
40 }
41
42 if (x[0] == 0)
43 goto L2; // expected-error {{use of undeclared label 'L2'}}
44 else if (x[1] == 1)
45 goto L1;
46 }
47
test_invalid_clause()48 void test_invalid_clause() {
49 int i;
50 #pragma omp parallel
51 // expected-warning@+1 {{extra tokens at the end of '#pragma omp taskloop' are ignored}}
52 #pragma omp taskloop foo bar
53 for (i = 0; i < 16; ++i)
54 ;
55 // expected-error@+1 {{directive '#pragma omp taskloop' cannot contain more than one 'nogroup' clause}}
56 #pragma omp taskloop nogroup nogroup
57 for (i = 0; i < 16; ++i)
58 ;
59 }
60
test_non_identifiers()61 void test_non_identifiers() {
62 int i, x;
63
64 #pragma omp parallel
65 // expected-warning@+1 {{extra tokens at the end of '#pragma omp taskloop' are ignored}}
66 #pragma omp taskloop;
67 for (i = 0; i < 16; ++i)
68 ;
69 // expected-warning@+3 {{extra tokens at the end of '#pragma omp taskloop' are ignored}}
70 // expected-error@+2 {{unexpected OpenMP clause 'linear' in directive '#pragma omp taskloop'}}
71 #pragma omp parallel
72 #pragma omp taskloop linear(x);
73 for (i = 0; i < 16; ++i)
74 ;
75
76 #pragma omp parallel
77 // expected-warning@+1 {{extra tokens at the end of '#pragma omp taskloop' are ignored}}
78 #pragma omp taskloop private(x);
79 for (i = 0; i < 16; ++i)
80 ;
81
82 #pragma omp parallel
83 // expected-warning@+1 {{extra tokens at the end of '#pragma omp taskloop' are ignored}}
84 #pragma omp taskloop, private(x);
85 for (i = 0; i < 16; ++i)
86 ;
87 }
88
89 extern int foo();
90
test_collapse()91 void test_collapse() {
92 int i;
93 #pragma omp parallel
94 // expected-error@+1 {{expected '('}}
95 #pragma omp taskloop collapse
96 for (i = 0; i < 16; ++i)
97 ;
98 #pragma omp parallel
99 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
100 #pragma omp taskloop collapse(
101 for (i = 0; i < 16; ++i)
102 ;
103 #pragma omp parallel
104 // expected-error@+1 {{expected expression}}
105 #pragma omp taskloop collapse()
106 for (i = 0; i < 16; ++i)
107 ;
108 #pragma omp parallel
109 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
110 #pragma omp taskloop collapse(,
111 for (i = 0; i < 16; ++i)
112 ;
113 #pragma omp parallel
114 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
115 #pragma omp taskloop collapse(, )
116 for (i = 0; i < 16; ++i)
117 ;
118 #pragma omp parallel
119 // expected-warning@+2 {{extra tokens at the end of '#pragma omp taskloop' are ignored}}
120 // expected-error@+1 {{expected '('}}
121 #pragma omp taskloop collapse 4)
122 for (i = 0; i < 16; ++i)
123 ;
124 #pragma omp parallel
125 // expected-error@+2 {{expected ')'}}
126 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
127 #pragma omp taskloop collapse(4
128 for (i = 0; i < 16; ++i)
129 ; // expected-error {{expected 4 for loops after '#pragma omp taskloop', but found only 1}}
130 #pragma omp parallel
131 // expected-error@+2 {{expected ')'}}
132 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
133 #pragma omp taskloop collapse(4,
134 for (i = 0; i < 16; ++i)
135 ; // expected-error {{expected 4 for loops after '#pragma omp taskloop', but found only 1}}
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 taskloop collapse(4, )
140 for (i = 0; i < 16; ++i)
141 ; // expected-error {{expected 4 for loops after '#pragma omp taskloop', but found only 1}}
142 #pragma omp parallel
143 // expected-note@+1 {{as specified in 'collapse' clause}}
144 #pragma omp taskloop collapse(4)
145 for (i = 0; i < 16; ++i)
146 ; // expected-error {{expected 4 for loops after '#pragma omp taskloop', but found only 1}}
147 #pragma omp parallel
148 // expected-error@+2 {{expected ')'}}
149 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
150 #pragma omp taskloop collapse(4 4)
151 for (i = 0; i < 16; ++i)
152 ; // expected-error {{expected 4 for loops after '#pragma omp taskloop', but found only 1}}
153 #pragma omp parallel
154 // expected-error@+2 {{expected ')'}}
155 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
156 #pragma omp taskloop collapse(4, , 4)
157 for (i = 0; i < 16; ++i)
158 ; // expected-error {{expected 4 for loops after '#pragma omp taskloop', but found only 1}}
159 #pragma omp parallel
160 #pragma omp taskloop collapse(4)
161 for (int i1 = 0; i1 < 16; ++i1)
162 for (int i2 = 0; i2 < 16; ++i2)
163 for (int i3 = 0; i3 < 16; ++i3)
164 for (int i4 = 0; i4 < 16; ++i4)
165 foo();
166 #pragma omp parallel
167 // expected-error@+2 {{expected ')'}}
168 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
169 #pragma omp taskloop collapse(4, 8)
170 for (i = 0; i < 16; ++i)
171 ; // expected-error {{expected 4 for loops after '#pragma omp taskloop', but found only 1}}
172 #pragma omp parallel
173 // expected-error@+1 {{expression is not an integer constant expression}}
174 #pragma omp taskloop collapse(2.5)
175 for (i = 0; i < 16; ++i)
176 ;
177 #pragma omp parallel
178 // expected-error@+1 {{expression is not an integer constant expression}}
179 #pragma omp taskloop collapse(foo())
180 for (i = 0; i < 16; ++i)
181 ;
182 #pragma omp parallel
183 // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
184 #pragma omp taskloop collapse(-5)
185 for (i = 0; i < 16; ++i)
186 ;
187 #pragma omp parallel
188 // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
189 #pragma omp taskloop collapse(0)
190 for (i = 0; i < 16; ++i)
191 ;
192 #pragma omp parallel
193 // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
194 #pragma omp taskloop collapse(5 - 5)
195 for (i = 0; i < 16; ++i)
196 ;
197 }
198
test_private()199 void test_private() {
200 int i;
201 #pragma omp parallel
202 // expected-error@+2 {{expected expression}}
203 // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
204 #pragma omp taskloop private(
205 for (i = 0; i < 16; ++i)
206 ;
207 #pragma omp parallel
208 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
209 // expected-error@+1 2 {{expected expression}}
210 #pragma omp taskloop private(,
211 for (i = 0; i < 16; ++i)
212 ;
213 #pragma omp parallel
214 // expected-error@+1 2 {{expected expression}}
215 #pragma omp taskloop private(, )
216 for (i = 0; i < 16; ++i)
217 ;
218 #pragma omp parallel
219 // expected-error@+1 {{expected expression}}
220 #pragma omp taskloop private()
221 for (i = 0; i < 16; ++i)
222 ;
223 #pragma omp parallel
224 // expected-error@+1 {{expected expression}}
225 #pragma omp taskloop private(int)
226 for (i = 0; i < 16; ++i)
227 ;
228 #pragma omp parallel
229 // expected-error@+1 {{expected variable name}}
230 #pragma omp taskloop private(0)
231 for (i = 0; i < 16; ++i)
232 ;
233
234 int x, y, z;
235 #pragma omp parallel
236 #pragma omp taskloop private(x)
237 for (i = 0; i < 16; ++i)
238 ;
239 #pragma omp parallel
240 #pragma omp taskloop private(x, y)
241 for (i = 0; i < 16; ++i)
242 ;
243 #pragma omp parallel
244 #pragma omp taskloop private(x, y, z)
245 for (i = 0; i < 16; ++i) {
246 x = y * i + z;
247 }
248 }
249
test_lastprivate()250 void test_lastprivate() {
251 int i;
252 #pragma omp parallel
253 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
254 // expected-error@+1 {{expected expression}}
255 #pragma omp taskloop lastprivate(
256 for (i = 0; i < 16; ++i)
257 ;
258
259 #pragma omp parallel
260 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
261 // expected-error@+1 2 {{expected expression}}
262 #pragma omp taskloop lastprivate(,
263 for (i = 0; i < 16; ++i)
264 ;
265 #pragma omp parallel
266 // expected-error@+1 2 {{expected expression}}
267 #pragma omp taskloop lastprivate(, )
268 for (i = 0; i < 16; ++i)
269 ;
270 #pragma omp parallel
271 // expected-error@+1 {{expected expression}}
272 #pragma omp taskloop lastprivate()
273 for (i = 0; i < 16; ++i)
274 ;
275 #pragma omp parallel
276 // expected-error@+1 {{expected expression}}
277 #pragma omp taskloop lastprivate(int)
278 for (i = 0; i < 16; ++i)
279 ;
280 #pragma omp parallel
281 // expected-error@+1 {{expected variable name}}
282 #pragma omp taskloop lastprivate(0)
283 for (i = 0; i < 16; ++i)
284 ;
285
286 int x, y, z;
287 #pragma omp parallel
288 #pragma omp taskloop lastprivate(x)
289 for (i = 0; i < 16; ++i)
290 ;
291 #pragma omp parallel
292 #pragma omp taskloop lastprivate(x, y)
293 for (i = 0; i < 16; ++i)
294 ;
295 #pragma omp parallel
296 #pragma omp taskloop lastprivate(x, y, z)
297 for (i = 0; i < 16; ++i)
298 ;
299 }
300
test_firstprivate()301 void test_firstprivate() {
302 int i;
303 #pragma omp parallel
304 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
305 // expected-error@+1 {{expected expression}}
306 #pragma omp taskloop firstprivate(
307 for (i = 0; i < 16; ++i)
308 ;
309
310 #pragma omp parallel
311 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
312 // expected-error@+1 2 {{expected expression}}
313 #pragma omp taskloop firstprivate(,
314 for (i = 0; i < 16; ++i)
315 ;
316 #pragma omp parallel
317 // expected-error@+1 2 {{expected expression}}
318 #pragma omp taskloop firstprivate(, )
319 for (i = 0; i < 16; ++i)
320 ;
321 #pragma omp parallel
322 // expected-error@+1 {{expected expression}}
323 #pragma omp taskloop firstprivate()
324 for (i = 0; i < 16; ++i)
325 ;
326 #pragma omp parallel
327 // expected-error@+1 {{expected expression}}
328 #pragma omp taskloop firstprivate(int)
329 for (i = 0; i < 16; ++i)
330 ;
331 #pragma omp parallel
332 // expected-error@+1 {{expected variable name}}
333 #pragma omp taskloop firstprivate(0)
334 for (i = 0; i < 16; ++i)
335 ;
336
337 int x, y, z;
338 #pragma omp parallel
339 #pragma omp taskloop lastprivate(x) firstprivate(x)
340 for (i = 0; i < 16; ++i)
341 ;
342 #pragma omp parallel
343 #pragma omp taskloop lastprivate(x, y) firstprivate(x, y)
344 for (i = 0; i < 16; ++i)
345 ;
346 #pragma omp parallel
347 #pragma omp taskloop lastprivate(x, y, z) firstprivate(x, y, z)
348 for (i = 0; i < 16; ++i)
349 ;
350 }
351
test_loop_messages()352 void test_loop_messages() {
353 float a[100], b[100], c[100];
354 #pragma omp parallel
355 // expected-error@+2 {{variable must be of integer or pointer type}}
356 #pragma omp taskloop
357 for (float fi = 0; fi < 10.0; fi++) {
358 c[(int)fi] = a[(int)fi] + b[(int)fi];
359 }
360 #pragma omp parallel
361 // expected-error@+2 {{variable must be of integer or pointer type}}
362 #pragma omp taskloop
363 for (double fi = 0; fi < 10.0; fi++) {
364 c[(int)fi] = a[(int)fi] + b[(int)fi];
365 }
366
367 // expected-warning@+2 {{OpenMP loop iteration variable cannot have more than 64 bits size and will be narrowed}}
368 #pragma omp taskloop
369 for (__int128 ii = 0; ii < 10; ii++) {
370 c[ii] = a[ii] + b[ii];
371 }
372 }
373
374