[LoopReroll] Add an extra defensive check to avoid SCEV assertion.
[llvm-project.git] / flang / test / Semantics / omp-do13.f90
blob6e3ac626360c52c1311e3712d184b4ac82e38381
1 ! RUN: %S/test_errors.sh %s %t %flang_fc1 -fopenmp
2 ! REQUIRES: shell
3 ! OpenMP Version 4.5
4 ! 2.7.1 Loop Construct
6 program omp
7 integer i, j, k
9 !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.
10 !$omp do collapse(3)
11 do i = 0, 10
12 !ERROR: CYCLE statement to non-innermost associated loop of an OpenMP DO construct
13 cycle
14 do j = 0, 10
15 do k = 0, 10
16 print *, i, j, k
17 end do
18 end do
19 end do
20 !$omp end do
22 !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.
23 !$omp do collapse(3)
24 do i = 0, 10
25 do j = 0, 10
26 !ERROR: CYCLE statement to non-innermost associated loop of an OpenMP DO construct
27 cycle
28 do k = 0, 10
29 print *, i, j, k
30 end do
31 end do
32 end do
33 !$omp end do
35 !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.
36 !$omp do collapse(2)
37 do i = 0, 10
38 !ERROR: CYCLE statement to non-innermost associated loop of an OpenMP DO construct
39 cycle
40 do j = 0, 10
41 do k = 0, 10
42 print *, i, j, k
43 end do
44 end do
45 end do
46 !$omp end do
49 !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.
50 !$omp do collapse(2)
51 foo: do i = 0, 10
52 !ERROR: CYCLE statement to non-innermost associated loop of an OpenMP DO construct
53 cycle foo
54 do j = 0, 10
55 do k = 0, 10
56 print *, i, j, k
57 end do
58 end do
59 end do foo
60 !$omp end do
63 !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.
64 !$omp do collapse(3)
65 do 60 i=1,10
66 do j=1,10
67 !ERROR: CYCLE statement to non-innermost associated loop of an OpenMP DO construct
68 cycle
69 do k=1,10
70 print *,i
71 end do
72 end do
73 60 continue
74 !$omp end do
76 !$omp do collapse(3)
77 foo: do i = 0, 10
78 foo1: do j = 0, 10
79 foo2: do k = 0, 10
80 !ERROR: CYCLE statement to non-innermost associated loop of an OpenMP DO construct
81 cycle foo
82 print *, i, j, k
83 end do foo2
84 end do foo1
85 end do foo
86 !$omp end do
88 !$omp do collapse(3)
89 foo: do i = 0, 10
90 foo1: do j = 0, 10
91 foo2: do k = 0, 10
92 !ERROR: CYCLE statement to non-innermost associated loop of an OpenMP DO construct
93 cycle foo1
94 print *, i, j, k
95 end do foo2
96 end do foo1
97 end do foo
98 !$omp end do
101 !$omp do collapse(2)
102 foo: do i = 0, 10
103 foo1: do j = 0, 10
104 foo2: do k = 0, 10
105 !ERROR: CYCLE statement to non-innermost associated loop of an OpenMP DO construct
106 cycle foo
107 print *, i, j, k
108 end do foo2
109 end do foo1
110 end do foo
111 !$omp end do
114 !$omp do collapse(2)
115 foo: do i = 0, 10
116 foo1: do j = 0, 10
117 !ERROR: CYCLE statement to non-innermost associated loop of an OpenMP DO construct
118 cycle foo
119 foo2: do k = 0, 10
120 print *, i, j, k
121 end do foo2
122 end do foo1
123 end do foo
124 !$omp end do
126 !$omp do ordered(2)
127 foo: do i = 0, 10
128 foo1: do j = 0, 10
129 !ERROR: CYCLE statement to non-innermost associated loop of an OpenMP DO construct
130 cycle foo
131 !ERROR: A worksharing region may not be closely nested inside a worksharing, explicit task, taskloop, critical, ordered, atomic, or master region
132 !$omp do collapse(1)
133 foo2: do k = 0, 10
134 print *, i, j, k
135 end do foo2
136 !$omp end do
137 end do foo1
138 end do foo
139 !$omp end do
141 !$omp parallel
142 !$omp do collapse(2)
143 foo: do i = 0, 10
144 foo1: do j = 0, 10
145 !ERROR: CYCLE statement to non-innermost associated loop of an OpenMP DO construct
146 cycle foo
147 !$omp parallel
148 !$omp do collapse(2)
149 foo2: do k = 0, 10
150 foo3: do l = 0, 10
151 print *, i, j, k, l
152 !ERROR: CYCLE statement to non-innermost associated loop of an OpenMP DO construct
153 cycle foo2
154 end do foo3
155 end do foo2
156 !$omp end do
157 !$omp end parallel
158 end do foo1
159 end do foo
160 !$omp end do
161 !$omp end parallel
163 !$omp parallel
164 !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.
165 !$omp parallel do ordered(3) collapse(2)
166 foo: do i = 0, 10
167 foo1: do j = 0, 10
168 !ERROR: CYCLE statement to non-innermost associated loop of an OpenMP DO construct
169 cycle foo
170 !$omp parallel
171 !$omp parallel do collapse(2)
172 foo2: do k = 0, 10
173 foo3: do l = 0, 10
174 print *, i, j, k, l
175 !ERROR: CYCLE statement to non-innermost associated loop of an OpenMP DO construct
176 cycle foo2
177 end do foo3
178 end do foo2
179 !$omp end parallel do
180 !$omp end parallel
181 end do foo1
182 end do foo
183 !$omp end parallel do
184 !$omp end parallel
186 end program omp