Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Semantics / OpenMP / nested-cancel.f90
blobafd94a591a06747d2fd0678a7e4e3737c8e1c38b
1 ! RUN: %python %S/../test_errors.py %s %flang -fopenmp
3 ! OpenMP Version 5.0
4 ! Check OpenMP construct validity for the following directives:
5 ! 2.18.1 Cancel Construct
7 program main
8 integer :: i, N = 10
9 real :: a
11 !ERROR: CANCEL TASKGROUP directive is not closely nested inside TASK or TASKLOOP
12 !$omp cancel taskgroup
14 !ERROR: CANCEL SECTIONS directive is not closely nested inside SECTION or SECTIONS
15 !$omp cancel sections
17 !ERROR: CANCEL DO directive is not closely nested inside the construct that matches the DO clause type
18 !$omp cancel do
20 !ERROR: CANCEL PARALLEL directive is not closely nested inside the construct that matches the PARALLEL clause type
21 !$omp cancel parallel
23 !$omp parallel
24 !$omp sections
25 !$omp cancel sections
26 !$omp section
27 a = 3.14
28 !$omp end sections
29 !$omp end parallel
31 !$omp sections
32 !$omp section
33 !$omp cancel sections
34 a = 3.14
35 !$omp end sections
37 !$omp parallel
38 !ERROR: With SECTIONS clause, CANCEL construct cannot be closely nested inside PARALLEL construct
39 !$omp cancel sections
40 a = 3.14
41 !$omp end parallel
43 !$omp parallel sections
44 !$omp cancel sections
45 a = 3.14
46 !$omp end parallel sections
48 !$omp do
49 do i = 1, N
50 a = 3.14
51 !$omp cancel do
52 end do
53 !$omp end do
55 !$omp parallel do
56 do i = 1, N
57 a = 3.14
58 !$omp cancel do
59 end do
60 !$omp end parallel do
62 !$omp target
63 !$omp teams
64 !$omp distribute parallel do
65 do i = 1, N
66 a = 3.14
67 !$omp cancel do
68 end do
69 !$omp end distribute parallel do
70 !$omp end teams
71 !$omp end target
73 !$omp target
74 !$omp teams distribute parallel do
75 do i = 1, N
76 a = 3.14
77 !$omp cancel do
78 end do
79 !$omp end teams distribute parallel do
80 !$omp end target
82 !$omp target teams distribute parallel do
83 do i = 1, N
84 a = 3.14
85 !$omp cancel do
86 end do
87 !$omp end target teams distribute parallel do
89 !$omp target parallel do
90 do i = 1, N
91 a = 3.14
92 !$omp cancel do
93 end do
94 !$omp end target parallel do
96 !$omp parallel
97 do i = 1, N
98 a = 3.14
99 !ERROR: With DO clause, CANCEL construct cannot be closely nested inside PARALLEL construct
100 !$omp cancel do
101 end do
102 !$omp end parallel
104 !$omp parallel
105 do i = 1, N
106 a = 3.14
107 !$omp cancel parallel
108 end do
109 !$omp end parallel
111 !$omp target parallel
112 do i = 1, N
113 a = 3.14
114 !$omp cancel parallel
115 end do
116 !$omp end target parallel
118 !$omp target parallel do
119 do i = 1, N
120 a = 3.14
121 !ERROR: With PARALLEL clause, CANCEL construct cannot be closely nested inside TARGET PARALLEL DO construct
122 !$omp cancel parallel
123 end do
124 !$omp end target parallel do
126 !$omp do
127 do i = 1, N
128 a = 3.14
129 !ERROR: With PARALLEL clause, CANCEL construct cannot be closely nested inside DO construct
130 !$omp cancel parallel
131 end do
132 !$omp end do
134 contains
135 subroutine sub1()
136 !$omp task
137 !$omp cancel taskgroup
138 a = 3.14
139 !$omp end task
141 !$omp taskloop
142 do i = 1, N
143 !$omp parallel
144 !$omp end parallel
145 !$omp cancel taskgroup
146 a = 3.14
147 end do
148 !$omp end taskloop
150 !$omp taskloop nogroup
151 do i = 1, N
152 !$omp cancel taskgroup
153 a = 3.14
154 end do
156 !$omp parallel
157 !ERROR: With TASKGROUP clause, CANCEL construct must be closely nested inside TASK or TASKLOOP construct and CANCEL region must be closely nested inside TASKGROUP region
158 !$omp cancel taskgroup
159 a = 3.14
160 !$omp end parallel
162 !$omp do
163 do i = 1, N
164 !$omp task
165 !$omp cancel taskgroup
166 a = 3.14
167 !$omp end task
168 end do
169 !$omp end do
171 !$omp parallel
172 !$omp taskgroup
173 !$omp task
174 !$omp cancel taskgroup
175 a = 3.14
176 !$omp end task
177 !$omp end taskgroup
178 !$omp end parallel
180 !$omp parallel
181 !$omp task
182 !ERROR: With TASKGROUP clause, CANCEL construct must be closely nested inside TASK or TASKLOOP construct and CANCEL region must be closely nested inside TASKGROUP region
183 !$omp cancel taskgroup
184 a = 3.14
185 !$omp end task
186 !$omp end parallel
188 !$omp parallel
189 !$omp do
190 do i = 1, N
191 !$omp task
192 !ERROR: With TASKGROUP clause, CANCEL construct must be closely nested inside TASK or TASKLOOP construct and CANCEL region must be closely nested inside TASKGROUP region
193 !$omp cancel taskgroup
194 a = 3.14
195 !$omp end task
196 end do
197 !$omp end do
198 !$omp end parallel
200 !$omp target parallel
201 !$omp task
202 !ERROR: With TASKGROUP clause, CANCEL construct must be closely nested inside TASK or TASKLOOP construct and CANCEL region must be closely nested inside TASKGROUP region
203 !$omp cancel taskgroup
204 a = 3.14
205 !$omp end task
206 !$omp end target parallel
208 !$omp parallel
209 !$omp taskloop private(j) nogroup
210 do i = 1, N
211 !ERROR: With TASKGROUP clause, CANCEL construct must be closely nested inside TASK or TASKLOOP construct and CANCEL region must be closely nested inside TASKGROUP region
212 !$omp cancel taskgroup
213 a = 3.14
214 end do
215 !$omp end taskloop
216 !$omp end parallel
218 !$omp parallel
219 !$omp taskloop
220 do i = 1, N
221 !$omp cancel taskgroup
222 a = 3.14
223 end do
224 !$omp end taskloop
225 !$omp end parallel
227 !$omp parallel
228 !$omp taskgroup
229 !$omp taskloop nogroup
230 do i = 1, N
231 !$omp cancel taskgroup
232 a = 3.14
233 end do
234 !$omp end taskloop
235 !$omp end taskgroup
236 !$omp end parallel
238 !$omp target parallel
239 !$omp taskloop nogroup
240 do i = 1, N
241 !ERROR: With TASKGROUP clause, CANCEL construct must be closely nested inside TASK or TASKLOOP construct and CANCEL region must be closely nested inside TASKGROUP region
242 !$omp cancel taskgroup
243 a = 3.14
244 end do
245 !$omp end taskloop
246 !$omp end target parallel
247 end subroutine sub1
249 end program main