[clangd] Re-land "support outgoing calls in call hierarchy" (#117673)
[llvm-project.git] / flang / test / Semantics / OpenMP / if-clause.f90
blob23be4a751c89269bc83444bc6c42704b27cac0cd
1 ! RUN: %python %S/../test_errors.py %s %flang -fopenmp -fopenmp-version=52
2 ! Check OpenMP 'if' clause validity for all directives that can have it
4 program main
5 integer :: i
7 ! ----------------------------------------------------------------------------
8 ! DISTRIBUTE PARALLEL DO
9 ! ----------------------------------------------------------------------------
10 !$omp teams
11 !$omp distribute parallel do if(.true.)
12 do i = 1, 10
13 end do
14 !$omp end distribute parallel do
16 !$omp distribute parallel do if(parallel: .true.)
17 do i = 1, 10
18 end do
19 !$omp end distribute parallel do
21 !ERROR: TARGET is not a constituent of the DISTRIBUTE PARALLEL DO directive
22 !$omp distribute parallel do if(target: .true.)
23 do i = 1, 10
24 end do
25 !$omp end distribute parallel do
27 !ERROR: At most one IF clause can appear on the DISTRIBUTE PARALLEL DO directive
28 !$omp distribute parallel do if(.true.) if(parallel: .false.)
29 do i = 1, 10
30 end do
31 !$omp end distribute parallel do
32 !$omp end teams
34 ! ----------------------------------------------------------------------------
35 ! DISTRIBUTE PARALLEL DO SIMD
36 ! ----------------------------------------------------------------------------
37 !$omp teams
38 !$omp distribute parallel do simd if(.true.)
39 do i = 1, 10
40 end do
41 !$omp end distribute parallel do simd
43 !$omp distribute parallel do simd if(parallel: .true.) if(simd: .false.)
44 do i = 1, 10
45 end do
46 !$omp end distribute parallel do simd
48 !ERROR: TARGET is not a constituent of the DISTRIBUTE PARALLEL DO SIMD directive
49 !$omp distribute parallel do simd if(target: .true.)
50 do i = 1, 10
51 end do
52 !$omp end distribute parallel do simd
53 !$omp end teams
55 ! ----------------------------------------------------------------------------
56 ! DISTRIBUTE SIMD
57 ! ----------------------------------------------------------------------------
58 !$omp teams
59 !$omp distribute simd if(.true.)
60 do i = 1, 10
61 end do
62 !$omp end distribute simd
64 !$omp distribute simd if(simd: .true.)
65 do i = 1, 10
66 end do
67 !$omp end distribute simd
69 !ERROR: TARGET is not a constituent of the DISTRIBUTE SIMD directive
70 !$omp distribute simd if(target: .true.)
71 do i = 1, 10
72 end do
73 !$omp end distribute simd
75 !ERROR: At most one IF clause can appear on the DISTRIBUTE SIMD directive
76 !$omp distribute simd if(.true.) if(simd: .false.)
77 do i = 1, 10
78 end do
79 !$omp end distribute simd
80 !$omp end teams
82 ! ----------------------------------------------------------------------------
83 ! DO SIMD
84 ! ----------------------------------------------------------------------------
85 !$omp do simd if(.true.)
86 do i = 1, 10
87 end do
88 !$omp end do simd
90 !$omp do simd if(simd: .true.)
91 do i = 1, 10
92 end do
93 !$omp end do simd
95 !ERROR: TARGET is not a constituent of the DO SIMD directive
96 !$omp do simd if(target: .true.)
97 do i = 1, 10
98 end do
99 !$omp end do simd
101 !ERROR: At most one IF clause can appear on the DO SIMD directive
102 !$omp do simd if(.true.) if(simd: .false.)
103 do i = 1, 10
104 end do
105 !$omp end do simd
107 ! ----------------------------------------------------------------------------
108 ! PARALLEL
109 ! ----------------------------------------------------------------------------
110 !$omp parallel if(.true.)
111 !$omp end parallel
113 !$omp parallel if(parallel: .true.)
114 !$omp end parallel
116 !ERROR: TARGET is not a constituent of the PARALLEL directive
117 !$omp parallel if(target: .true.)
118 !$omp end parallel
120 !ERROR: At most one IF clause can appear on the PARALLEL directive
121 !$omp parallel if(.true.) if(parallel: .false.)
122 !$omp end parallel
124 ! ----------------------------------------------------------------------------
125 ! PARALLEL DO
126 ! ----------------------------------------------------------------------------
127 !$omp parallel do if(.true.)
128 do i = 1, 10
129 end do
130 !$omp end parallel do
132 !$omp parallel do if(parallel: .true.)
133 do i = 1, 10
134 end do
135 !$omp end parallel do
137 !ERROR: TARGET is not a constituent of the PARALLEL DO directive
138 !$omp parallel do if(target: .true.)
139 do i = 1, 10
140 end do
141 !$omp end parallel do
143 !ERROR: At most one IF clause can appear on the PARALLEL DO directive
144 !$omp parallel do if(.true.) if(parallel: .false.)
145 do i = 1, 10
146 end do
147 !$omp end parallel do
149 ! ----------------------------------------------------------------------------
150 ! PARALLEL DO SIMD
151 ! ----------------------------------------------------------------------------
152 !$omp parallel do simd if(.true.)
153 do i = 1, 10
154 end do
155 !$omp end parallel do simd
157 !$omp parallel do simd if(parallel: .true.) if(simd: .false.)
158 do i = 1, 10
159 end do
160 !$omp end parallel do simd
162 !ERROR: TARGET is not a constituent of the PARALLEL DO SIMD directive
163 !$omp parallel do simd if(target: .true.)
164 do i = 1, 10
165 end do
166 !$omp end parallel do simd
168 ! ----------------------------------------------------------------------------
169 ! PARALLEL SECTIONS
170 ! ----------------------------------------------------------------------------
171 !$omp parallel sections if(.true.)
172 !$omp end parallel sections
174 !$omp parallel sections if(parallel: .true.)
175 !$omp end parallel sections
177 !ERROR: TARGET is not a constituent of the PARALLEL SECTIONS directive
178 !$omp parallel sections if(target: .true.)
179 !$omp end parallel sections
181 !ERROR: At most one IF clause can appear on the PARALLEL SECTIONS directive
182 !$omp parallel sections if(.true.) if(parallel: .false.)
183 !$omp end parallel sections
185 ! ----------------------------------------------------------------------------
186 ! PARALLEL WORKSHARE
187 ! ----------------------------------------------------------------------------
188 !$omp parallel workshare if(.true.)
189 !$omp end parallel workshare
191 !$omp parallel workshare if(parallel: .true.)
192 !$omp end parallel workshare
194 !ERROR: TARGET is not a constituent of the PARALLEL WORKSHARE directive
195 !$omp parallel workshare if(target: .true.)
196 !$omp end parallel workshare
198 !ERROR: At most one IF clause can appear on the PARALLEL WORKSHARE directive
199 !$omp parallel workshare if(.true.) if(parallel: .false.)
200 !$omp end parallel workshare
202 ! ----------------------------------------------------------------------------
203 ! SIMD
204 ! ----------------------------------------------------------------------------
205 !$omp simd if(.true.)
206 do i = 1, 10
207 end do
208 !$omp end simd
210 !$omp simd if(simd: .true.)
211 do i = 1, 10
212 end do
213 !$omp end simd
215 !ERROR: TARGET is not a constituent of the SIMD directive
216 !$omp simd if(target: .true.)
217 do i = 1, 10
218 end do
219 !$omp end simd
221 !ERROR: At most one IF clause can appear on the SIMD directive
222 !$omp simd if(.true.) if(simd: .false.)
223 do i = 1, 10
224 end do
225 !$omp end simd
227 ! ----------------------------------------------------------------------------
228 ! TARGET
229 ! ----------------------------------------------------------------------------
230 !$omp target if(.true.)
231 !$omp end target
233 !$omp target if(target: .true.)
234 !$omp end target
236 !ERROR: PARALLEL is not a constituent of the TARGET directive
237 !$omp target if(parallel: .true.)
238 !$omp end target
240 !ERROR: At most one IF clause can appear on the TARGET directive
241 !$omp target if(.true.) if(target: .false.)
242 !$omp end target
244 ! ----------------------------------------------------------------------------
245 ! TARGET DATA
246 ! ----------------------------------------------------------------------------
247 !$omp target data map(tofrom: i) if(.true.)
248 !$omp end target data
250 !$omp target data map(tofrom: i) if(target data: .true.)
251 !$omp end target data
253 !ERROR: TARGET is not a constituent of the TARGET DATA directive
254 !$omp target data map(tofrom: i) if(target: .true.)
255 !$omp end target data
257 !ERROR: At most one IF clause can appear on the TARGET DATA directive
258 !$omp target data map(tofrom: i) if(.true.) if(target data: .false.)
259 !$omp end target data
261 ! ----------------------------------------------------------------------------
262 ! TARGET ENTER DATA
263 ! ----------------------------------------------------------------------------
264 !$omp target enter data map(to: i) if(.true.)
266 !$omp target enter data map(to: i) if(target enter data: .true.)
268 !ERROR: TARGET is not a constituent of the TARGET ENTER DATA directive
269 !$omp target enter data map(to: i) if(target: .true.)
271 !ERROR: At most one IF clause can appear on the TARGET ENTER DATA directive
272 !$omp target enter data map(to: i) if(.true.) if(target enter data: .false.)
274 ! ----------------------------------------------------------------------------
275 ! TARGET EXIT DATA
276 ! ----------------------------------------------------------------------------
277 !$omp target exit data map(from: i) if(.true.)
279 !$omp target exit data map(from: i) if(target exit data: .true.)
281 !ERROR: TARGET is not a constituent of the TARGET EXIT DATA directive
282 !$omp target exit data map(from: i) if(target: .true.)
284 !ERROR: At most one IF clause can appear on the TARGET EXIT DATA directive
285 !$omp target exit data map(from: i) if(.true.) if(target exit data: .false.)
287 ! ----------------------------------------------------------------------------
288 ! TARGET PARALLEL
289 ! ----------------------------------------------------------------------------
290 !$omp target parallel if(.true.)
291 !$omp end target parallel
293 !$omp target parallel if(target: .true.) if(parallel: .false.)
294 !$omp end target parallel
296 !ERROR: SIMD is not a constituent of the TARGET PARALLEL directive
297 !$omp target parallel if(simd: .true.)
298 !$omp end target parallel
300 ! ----------------------------------------------------------------------------
301 ! TARGET PARALLEL DO
302 ! ----------------------------------------------------------------------------
303 !$omp target parallel do if(.true.)
304 do i = 1, 10
305 end do
306 !$omp end target parallel do
308 !$omp target parallel do if(target: .true.) if(parallel: .false.)
309 do i = 1, 10
310 end do
311 !$omp end target parallel do
313 !ERROR: SIMD is not a constituent of the TARGET PARALLEL DO directive
314 !$omp target parallel do if(simd: .true.)
315 do i = 1, 10
316 end do
317 !$omp end target parallel do
319 ! ----------------------------------------------------------------------------
320 ! TARGET PARALLEL DO SIMD
321 ! ----------------------------------------------------------------------------
322 !$omp target parallel do simd if(.true.)
323 do i = 1, 10
324 end do
325 !$omp end target parallel do simd
327 !$omp target parallel do simd if(target: .true.) if(parallel: .false.) &
328 !$omp& if(simd: .true.)
329 do i = 1, 10
330 end do
331 !$omp end target parallel do simd
333 !ERROR: TEAMS is not a constituent of the TARGET PARALLEL DO SIMD directive
334 !$omp target parallel do simd if(teams: .true.)
335 do i = 1, 10
336 end do
337 !$omp end target parallel do simd
339 ! ----------------------------------------------------------------------------
340 ! TARGET SIMD
341 ! ----------------------------------------------------------------------------
342 !$omp target simd if(.true.)
343 do i = 1, 10
344 end do
345 !$omp end target simd
347 !$omp target simd if(target: .true.) if(simd: .false.)
348 do i = 1, 10
349 end do
350 !$omp end target simd
352 !ERROR: PARALLEL is not a constituent of the TARGET SIMD directive
353 !$omp target simd if(parallel: .true.)
354 do i = 1, 10
355 end do
356 !$omp end target simd
358 ! ----------------------------------------------------------------------------
359 ! TARGET TEAMS
360 ! ----------------------------------------------------------------------------
361 !$omp target teams if(.true.)
362 !$omp end target teams
364 !$omp target teams if(target: .true.) if(teams: .false.)
365 !$omp end target teams
367 !ERROR: PARALLEL is not a constituent of the TARGET TEAMS directive
368 !$omp target teams if(parallel: .true.)
369 !$omp end target teams
371 ! ----------------------------------------------------------------------------
372 ! TARGET TEAMS DISTRIBUTE
373 ! ----------------------------------------------------------------------------
374 !$omp target teams distribute if(.true.)
375 do i = 1, 10
376 end do
377 !$omp end target teams distribute
379 !$omp target teams distribute if(target: .true.) if(teams: .false.)
380 do i = 1, 10
381 end do
382 !$omp end target teams distribute
384 !ERROR: PARALLEL is not a constituent of the TARGET TEAMS DISTRIBUTE directive
385 !$omp target teams distribute if(parallel: .true.)
386 do i = 1, 10
387 end do
388 !$omp end target teams distribute
390 ! ----------------------------------------------------------------------------
391 ! TARGET TEAMS DISTRIBUTE PARALLEL DO
392 ! ----------------------------------------------------------------------------
393 !$omp target teams distribute parallel do if(.true.)
394 do i = 1, 10
395 end do
396 !$omp end target teams distribute parallel do
398 !$omp target teams distribute parallel do &
399 !$omp& if(target: .true.) if(teams: .false.) if(parallel: .true.)
400 do i = 1, 10
401 end do
402 !$omp end target teams distribute parallel do
404 !ERROR: SIMD is not a constituent of the TARGET TEAMS DISTRIBUTE PARALLEL DO directive
405 !$omp target teams distribute parallel do if(simd: .true.)
406 do i = 1, 10
407 end do
408 !$omp end target teams distribute parallel do
410 ! ----------------------------------------------------------------------------
411 ! TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD
412 ! ----------------------------------------------------------------------------
413 !$omp target teams distribute parallel do simd if(.true.)
414 do i = 1, 10
415 end do
416 !$omp end target teams distribute parallel do simd
418 !$omp target teams distribute parallel do simd &
419 !$omp& if(target: .true.) if(teams: .false.) if(parallel: .true.) &
420 !$omp& if(simd: .false.)
421 do i = 1, 10
422 end do
423 !$omp end target teams distribute parallel do simd
425 !ERROR: TASK is not a constituent of the TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD directive
426 !$omp target teams distribute parallel do simd if(task: .true.)
427 do i = 1, 10
428 end do
429 !$omp end target teams distribute parallel do simd
431 ! ----------------------------------------------------------------------------
432 ! TARGET TEAMS DISTRIBUTE SIMD
433 ! ----------------------------------------------------------------------------
434 !$omp target teams distribute simd if(.true.)
435 do i = 1, 10
436 end do
437 !$omp end target teams distribute simd
439 !$omp target teams distribute simd &
440 !$omp& if(target: .true.) if(teams: .false.) if(simd: .true.)
441 do i = 1, 10
442 end do
443 !$omp end target teams distribute simd
445 !ERROR: PARALLEL is not a constituent of the TARGET TEAMS DISTRIBUTE SIMD directive
446 !$omp target teams distribute simd if(parallel: .true.)
447 do i = 1, 10
448 end do
449 !$omp end target teams distribute simd
451 ! ----------------------------------------------------------------------------
452 ! TARGET UPDATE
453 ! ----------------------------------------------------------------------------
454 !$omp target update to(i) if(.true.)
456 !$omp target update to(i) if(target update: .true.)
458 !ERROR: TARGET is not a constituent of the TARGET UPDATE directive
459 !$omp target update to(i) if(target: .true.)
461 !ERROR: At most one IF clause can appear on the TARGET UPDATE directive
462 !$omp target update to(i) if(.true.) if(target update: .false.)
464 ! ----------------------------------------------------------------------------
465 ! TASK
466 ! ----------------------------------------------------------------------------
467 !$omp task if(.true.)
468 !$omp end task
470 !$omp task if(task: .true.)
471 !$omp end task
473 !ERROR: TARGET is not a constituent of the TASK directive
474 !$omp task if(target: .true.)
475 !$omp end task
477 !ERROR: At most one IF clause can appear on the TASK directive
478 !$omp task if(.true.) if(task: .false.)
479 !$omp end task
481 ! ----------------------------------------------------------------------------
482 ! TASKLOOP
483 ! ----------------------------------------------------------------------------
484 !$omp taskloop if(.true.)
485 do i = 1, 10
486 end do
487 !$omp end taskloop
489 !$omp taskloop if(taskloop: .true.)
490 do i = 1, 10
491 end do
492 !$omp end taskloop
494 !ERROR: TARGET is not a constituent of the TASKLOOP directive
495 !$omp taskloop if(target: .true.)
496 do i = 1, 10
497 end do
498 !$omp end taskloop
500 !ERROR: At most one IF clause can appear on the TASKLOOP directive
501 !$omp taskloop if(.true.) if(taskloop: .false.)
502 do i = 1, 10
503 end do
504 !$omp end taskloop
506 ! ----------------------------------------------------------------------------
507 ! TASKLOOP SIMD
508 ! ----------------------------------------------------------------------------
509 !$omp taskloop simd if(.true.)
510 do i = 1, 10
511 end do
512 !$omp end taskloop simd
514 !$omp taskloop simd if(taskloop: .true.) if(simd: .false.)
515 do i = 1, 10
516 end do
517 !$omp end taskloop simd
519 !ERROR: TARGET is not a constituent of the TASKLOOP SIMD directive
520 !$omp taskloop simd if(target: .true.)
521 do i = 1, 10
522 end do
523 !$omp end taskloop simd
525 ! ----------------------------------------------------------------------------
526 ! TEAMS
527 ! ----------------------------------------------------------------------------
528 !$omp teams if(.true.)
529 !$omp end teams
531 !$omp teams if(teams: .true.)
532 !$omp end teams
534 !ERROR: TARGET is not a constituent of the TEAMS directive
535 !$omp teams if(target: .true.)
536 !$omp end teams
538 !ERROR: At most one IF clause can appear on the TEAMS directive
539 !$omp teams if(.true.) if(teams: .false.)
540 !$omp end teams
542 ! ----------------------------------------------------------------------------
543 ! TEAMS DISTRIBUTE
544 ! ----------------------------------------------------------------------------
545 !$omp teams distribute if(.true.)
546 do i = 1, 10
547 end do
548 !$omp end teams distribute
550 !$omp teams distribute if(teams: .true.)
551 do i = 1, 10
552 end do
553 !$omp end teams distribute
555 !ERROR: TARGET is not a constituent of the TEAMS DISTRIBUTE directive
556 !$omp teams distribute if(target: .true.)
557 do i = 1, 10
558 end do
559 !$omp end teams distribute
561 !ERROR: At most one IF clause can appear on the TEAMS DISTRIBUTE directive
562 !$omp teams distribute if(.true.) if(teams: .true.)
563 do i = 1, 10
564 end do
565 !$omp end teams distribute
567 ! ----------------------------------------------------------------------------
568 ! TEAMS DISTRIBUTE PARALLEL DO
569 ! ----------------------------------------------------------------------------
570 !$omp teams distribute parallel do if(.true.)
571 do i = 1, 10
572 end do
573 !$omp end teams distribute parallel do
575 !$omp teams distribute parallel do if(teams: .true.) if(parallel: .false.)
576 do i = 1, 10
577 end do
578 !$omp end teams distribute parallel do
580 !ERROR: TARGET is not a constituent of the TEAMS DISTRIBUTE PARALLEL DO directive
581 !$omp teams distribute parallel do if(target: .true.)
582 do i = 1, 10
583 end do
584 !$omp end teams distribute parallel do
586 ! ----------------------------------------------------------------------------
587 ! TEAMS DISTRIBUTE PARALLEL DO SIMD
588 ! ----------------------------------------------------------------------------
589 !$omp teams distribute parallel do simd if(.true.)
590 do i = 1, 10
591 end do
592 !$omp end teams distribute parallel do simd
594 !$omp teams distribute parallel do simd &
595 !$omp& if(teams: .true.) if(parallel: .true.) if(simd: .true.)
596 do i = 1, 10
597 end do
598 !$omp end teams distribute parallel do simd
600 !ERROR: TARGET is not a constituent of the TEAMS DISTRIBUTE PARALLEL DO SIMD directive
601 !$omp teams distribute parallel do simd if(target: .true.)
602 do i = 1, 10
603 end do
604 !$omp end teams distribute parallel do simd
606 ! ----------------------------------------------------------------------------
607 ! TEAMS DISTRIBUTE SIMD
608 ! ----------------------------------------------------------------------------
609 !$omp teams distribute simd if(.true.)
610 do i = 1, 10
611 end do
612 !$omp end teams distribute simd
614 !$omp teams distribute simd if(teams: .true.) if(simd: .true.)
615 do i = 1, 10
616 end do
617 !$omp end teams distribute simd
619 !ERROR: TARGET is not a constituent of the TEAMS DISTRIBUTE SIMD directive
620 !$omp teams distribute simd if(target: .true.)
621 do i = 1, 10
622 end do
623 !$omp end teams distribute simd
624 end program main