xref: /llvm-project/flang/test/Semantics/OpenMP/do15.f90 (revision 502bea25bdc07d1811b8bfea1c2e6bfa8617f72f)
1! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
2! OpenMP Version 4.5
3! 2.7.1 Loop Construct
4
5program omp
6  integer i, j, k
7
8  !ERROR: The value of the parameter in the COLLAPSE or ORDERED clause must not be larger than the number of nested loops following the construct.
9  !$omp do  collapse(3)
10  do i = 0, 10
11    if (i .lt. 1) then
12      !ERROR: CYCLE statement to non-innermost associated loop of an OpenMP DO construct
13      cycle
14    end if
15    do j = 0, 10
16      do k  = 0, 10
17        print *, i, j, k
18      end do
19    end do
20  end do
21  !$omp end do
22
23  !ERROR: The value of the parameter in the COLLAPSE or ORDERED clause must not be larger than the number of nested loops following the construct.
24  !$omp do  collapse(3)
25  do i = 0, 10
26    do j = 0, 10
27      if (i .lt. 1) then
28        !ERROR: CYCLE statement to non-innermost associated loop of an OpenMP DO construct
29        cycle
30      end if
31      do k  = 0, 10
32        print *, i, j, k
33      end do
34    end do
35  end do
36  !$omp end do
37
38  !!ERROR: The value of the parameter in the COLLAPSE or ORDERED clause must not be larger than the number of nested loops following the construct.
39  !$omp do  collapse(2)
40  foo: do i = 0, 10
41    foo1: do j = 0, 10
42      if (i .lt. 1) then
43        !ERROR: CYCLE statement to non-innermost associated loop of an OpenMP DO construct
44        cycle foo
45      else if (i .gt. 3) then
46        cycle foo1
47      end if
48      do k  = 0, 10
49        print *, i, j, k
50      end do
51    end do foo1
52  end do foo
53  !$omp end do
54
55
56  !ERROR: The value of the parameter in the COLLAPSE or ORDERED clause must not be larger than the number of nested loops following the construct.
57  !$omp do  collapse(3)
58  foo: do i = 0, 10
59    foo1: do j = 0, 10
60      if (i .lt. 1) then
61        !ERROR: CYCLE statement to non-innermost associated loop of an OpenMP DO construct
62        cycle foo
63      else if (i .gt. 3) then
64        !ERROR: CYCLE statement to non-innermost associated loop of an OpenMP DO construct
65        cycle foo1
66      end if
67         foo2:  do k  = 0, 10
68             print *, i, j, k
69           end do foo2
70         end do foo1
71  end do foo
72  !$omp end do
73
74  !$omp do  ordered(3)
75  foo: do i = 0, 10
76    foo1: do j = 0, 10
77         foo2:  do k  = 0, 10
78           if (i .lt. 1) then
79             !ERROR: CYCLE statement to non-innermost associated loop of an OpenMP DO construct
80             cycle foo
81           else if (i .gt. 3) then
82             !ERROR: CYCLE statement to non-innermost associated loop of an OpenMP DO construct
83             cycle foo1
84          else
85             !ERROR: CYCLE statement to non-innermost associated loop of an OpenMP DO construct
86             cycle foo
87          end if
88             print *, i, j, k
89           end do foo2
90         end do foo1
91  end do foo
92  !$omp end do
93
94end program omp
95