[LoopReroll] Add an extra defensive check to avoid SCEV assertion.
[llvm-project.git] / flang / test / Semantics / omp-atomic01.f90
blob8a8fa4211314d20404769eebfc97bf662e20894a
1 ! RUN: %S/test_errors.sh %s %t %flang_fc1 -fopenmp
2 ! REQUIRES: shell
3 ! Semantic checks for OpenMP 5.0 standard 2.17.7 atomic Construct.
5 use omp_lib
6 implicit none
7 integer :: i, j = 10, k=-100, a
8 ! 2.17.7.1
9 ! Handled inside parser.
10 ! OpenMP constructs may not be encountered during execution of an atomic region
12 ! 2.17.7.2
13 ! At most one memory-order-clause may appear on the construct.
15 !READ
16 !ERROR: At most one SEQ_CST clause can appear on the READ directive
17 !$omp atomic seq_cst seq_cst read
18 i = j
19 !ERROR: At most one SEQ_CST clause can appear on the READ directive
20 !$omp atomic read seq_cst seq_cst
21 i = j
22 !ERROR: At most one SEQ_CST clause can appear on the READ directive
23 !$omp atomic seq_cst read seq_cst
24 i = j
26 !ERROR: At most one ACQUIRE clause can appear on the READ directive
27 !$omp atomic acquire acquire read
28 i = j
29 !ERROR: At most one ACQUIRE clause can appear on the READ directive
30 !$omp atomic read acquire acquire
31 i = j
32 !ERROR: At most one ACQUIRE clause can appear on the READ directive
33 !$omp atomic acquire read acquire
34 i = j
36 !ERROR: At most one RELAXED clause can appear on the READ directive
37 !$omp atomic relaxed relaxed read
38 i = j
39 !ERROR: At most one RELAXED clause can appear on the READ directive
40 !$omp atomic read relaxed relaxed
41 i = j
42 !ERROR: At most one RELAXED clause can appear on the READ directive
43 !$omp atomic relaxed read relaxed
44 i = j
46 !UPDATE
47 !ERROR: At most one SEQ_CST clause can appear on the UPDATE directive
48 !$omp atomic seq_cst seq_cst update
49 i = j
50 !ERROR: At most one SEQ_CST clause can appear on the UPDATE directive
51 !$omp atomic update seq_cst seq_cst
52 i = j
53 !ERROR: At most one SEQ_CST clause can appear on the UPDATE directive
54 !$omp atomic seq_cst update seq_cst
55 i = j
57 !ERROR: At most one RELEASE clause can appear on the UPDATE directive
58 !$omp atomic release release update
59 i = j
60 !ERROR: At most one RELEASE clause can appear on the UPDATE directive
61 !$omp atomic update release release
62 i = j
63 !ERROR: At most one RELEASE clause can appear on the UPDATE directive
64 !$omp atomic release update release
65 i = j
67 !ERROR: At most one RELAXED clause can appear on the UPDATE directive
68 !$omp atomic relaxed relaxed update
69 i = j
70 !ERROR: At most one RELAXED clause can appear on the UPDATE directive
71 !$omp atomic update relaxed relaxed
72 i = j
73 !ERROR: At most one RELAXED clause can appear on the UPDATE directive
74 !$omp atomic relaxed update relaxed
75 i = j
77 !CAPTURE
78 !ERROR: At most one SEQ_CST clause can appear on the CAPTURE directive
79 !$omp atomic seq_cst seq_cst capture
80 i = j
81 j = k
82 !$omp end atomic
84 !ERROR: At most one SEQ_CST clause can appear on the CAPTURE directive
85 !$omp atomic capture seq_cst seq_cst
86 i = j
87 j = k
88 !$omp end atomic
90 !ERROR: At most one SEQ_CST clause can appear on the CAPTURE directive
91 !$omp atomic seq_cst capture seq_cst
92 i = j
93 j = k
94 !$omp end atomic
96 !ERROR: At most one RELEASE clause can appear on the CAPTURE directive
97 !$omp atomic release release capture
98 i = j
99 j = k
100 !$omp end atomic
102 !ERROR: At most one RELEASE clause can appear on the CAPTURE directive
103 !$omp atomic capture release release
104 i = j
105 j = k
106 !$omp end atomic
108 !ERROR: At most one RELEASE clause can appear on the CAPTURE directive
109 !$omp atomic release capture release
110 i = j
111 j = k
112 !$omp end atomic
114 !ERROR: At most one RELAXED clause can appear on the CAPTURE directive
115 !$omp atomic relaxed relaxed capture
116 i = j
117 j = k
118 !$omp end atomic
120 !ERROR: At most one RELAXED clause can appear on the CAPTURE directive
121 !$omp atomic capture relaxed relaxed
122 i = j
123 j = k
124 !$omp end atomic
126 !ERROR: At most one RELAXED clause can appear on the CAPTURE directive
127 !$omp atomic relaxed capture relaxed
128 i = j
129 j = k
130 !$omp end atomic
132 !ERROR: At most one ACQ_REL clause can appear on the CAPTURE directive
133 !$omp atomic acq_rel acq_rel capture
134 i = j
135 j = k
136 !$omp end atomic
138 !ERROR: At most one ACQ_REL clause can appear on the CAPTURE directive
139 !$omp atomic capture acq_rel acq_rel
140 i = j
141 j = k
142 !$omp end atomic
144 !ERROR: At most one ACQ_REL clause can appear on the CAPTURE directive
145 !$omp atomic acq_rel capture acq_rel
146 i = j
147 j = k
148 !$omp end atomic
150 !ERROR: At most one ACQUIRE clause can appear on the CAPTURE directive
151 !$omp atomic acquire acquire capture
152 i = j
153 j = k
154 !$omp end atomic
156 !ERROR: At most one ACQUIRE clause can appear on the CAPTURE directive
157 !$omp atomic capture acquire acquire
158 i = j
159 j = k
160 !$omp end atomic
162 !ERROR: At most one ACQUIRE clause can appear on the CAPTURE directive
163 !$omp atomic acquire capture acquire
164 i = j
165 j = k
166 !$omp end atomic
168 !WRITE
169 !ERROR: At most one SEQ_CST clause can appear on the WRITE directive
170 !$omp atomic seq_cst seq_cst write
171 i = j
172 !ERROR: At most one SEQ_CST clause can appear on the WRITE directive
173 !$omp atomic write seq_cst seq_cst
174 i = j
175 !ERROR: At most one SEQ_CST clause can appear on the WRITE directive
176 !$omp atomic seq_cst write seq_cst
177 i = j
179 !ERROR: At most one RELEASE clause can appear on the WRITE directive
180 !$omp atomic release release write
181 i = j
182 !ERROR: At most one RELEASE clause can appear on the WRITE directive
183 !$omp atomic write release release
184 i = j
185 !ERROR: At most one RELEASE clause can appear on the WRITE directive
186 !$omp atomic release write release
187 i = j
189 !ERROR: At most one RELAXED clause can appear on the WRITE directive
190 !$omp atomic relaxed relaxed write
191 i = j
192 !ERROR: At most one RELAXED clause can appear on the WRITE directive
193 !$omp atomic write relaxed relaxed
194 i = j
195 !ERROR: At most one RELAXED clause can appear on the WRITE directive
196 !$omp atomic relaxed write relaxed
197 i = j
199 !No atomic-clause
200 !ERROR: At most one RELAXED clause can appear on the ATOMIC directive
201 !$omp atomic relaxed relaxed
202 i = j
203 !ERROR: At most one SEQ_CST clause can appear on the ATOMIC directive
204 !$omp atomic seq_cst seq_cst
205 i = j
206 !ERROR: At most one RELEASE clause can appear on the ATOMIC directive
207 !$omp atomic release release
208 i = j
210 ! 2.17.7.3
211 ! At most one hint clause may appear on the construct.
213 !ERROR: At most one HINT clause can appear on the READ directive
214 !$omp atomic hint(omp_sync_hint_speculative) hint(omp_sync_hint_speculative) read
215 i = j
216 !ERROR: At most one HINT clause can appear on the READ directive
217 !$omp atomic hint(omp_sync_hint_nonspeculative) read hint(omp_sync_hint_nonspeculative)
218 i = j
219 !ERROR: At most one HINT clause can appear on the READ directive
220 !$omp atomic read hint(omp_sync_hint_uncontended) hint (omp_sync_hint_uncontended)
221 i = j
222 !ERROR: At most one HINT clause can appear on the WRITE directive
223 !$omp atomic hint(omp_sync_hint_contended) hint(omp_sync_hint_speculative) write
224 i = j
225 !ERROR: At most one HINT clause can appear on the WRITE directive
226 !$omp atomic hint(omp_sync_hint_nonspeculative) write hint(omp_sync_hint_nonspeculative)
227 i = j
228 !ERROR: At most one HINT clause can appear on the WRITE directive
229 !$omp atomic write hint(omp_sync_hint_none) hint (omp_sync_hint_uncontended)
230 i = j
231 !ERROR: At most one HINT clause can appear on the WRITE directive
232 !$omp atomic hint(omp_sync_hint_contended) hint(omp_sync_hint_speculative) write
233 i = j
234 !ERROR: At most one HINT clause can appear on the WRITE directive
235 !$omp atomic hint(omp_sync_hint_nonspeculative) write hint(omp_sync_hint_nonspeculative)
236 i = j
237 !ERROR: At most one HINT clause can appear on the WRITE directive
238 !$omp atomic write hint(omp_sync_hint_none) hint (omp_sync_hint_uncontended)
239 i = j
240 !ERROR: At most one HINT clause can appear on the UPDATE directive
241 !$omp atomic hint(omp_sync_hint_contended) hint(omp_sync_hint_speculative) update
242 i = j
243 !ERROR: At most one HINT clause can appear on the UPDATE directive
244 !$omp atomic hint(omp_sync_hint_nonspeculative) update hint(omp_sync_hint_nonspeculative)
245 i = j
246 !ERROR: At most one HINT clause can appear on the UPDATE directive
247 !$omp atomic update hint(omp_sync_hint_none) hint (omp_sync_hint_uncontended)
248 i = j
249 !ERROR: At most one HINT clause can appear on the ATOMIC directive
250 !$omp atomic hint(omp_sync_hint_contended) hint(omp_sync_hint_speculative)
251 i = j
252 !ERROR: At most one HINT clause can appear on the ATOMIC directive
253 !$omp atomic hint(omp_sync_hint_none) hint(omp_sync_hint_nonspeculative)
254 i = j
255 !ERROR: At most one HINT clause can appear on the ATOMIC directive
256 !$omp atomic hint(omp_sync_hint_none) hint (omp_sync_hint_uncontended)
257 i = j
259 !ERROR: At most one HINT clause can appear on the CAPTURE directive
260 !$omp atomic hint(omp_sync_hint_contended) hint(omp_sync_hint_speculative) capture
261 i = j
262 j = k
263 !$omp end atomic
264 !ERROR: At most one HINT clause can appear on the CAPTURE directive
265 !$omp atomic hint(omp_sync_hint_nonspeculative) capture hint(omp_sync_hint_nonspeculative)
266 i = j
267 j = k
268 !$omp end atomic
269 !ERROR: At most one HINT clause can appear on the CAPTURE directive
270 !$omp atomic capture hint(omp_sync_hint_none) hint (omp_sync_hint_uncontended)
271 i = j
272 j = k
273 !$omp end atomic
274 ! 2.17.7.4
275 ! If atomic-clause is read then memory-order-clause must not be acq_rel or release.
277 !ERROR: Clause ACQ_REL is not allowed if clause READ appears on the ATOMIC directive
278 !$omp atomic acq_rel read
279 i = j
280 !ERROR: Clause ACQ_REL is not allowed if clause READ appears on the ATOMIC directive
281 !$omp atomic read acq_rel
282 i = j
284 !ERROR: Clause RELEASE is not allowed if clause READ appears on the ATOMIC directive
285 !$omp atomic release read
286 i = j
287 !ERROR: Clause RELEASE is not allowed if clause READ appears on the ATOMIC directive
288 !$omp atomic read release
289 i = j
291 ! 2.17.7.5
292 ! If atomic-clause is write then memory-order-clause must not be acq_rel or acquire.
294 !ERROR: Clause ACQ_REL is not allowed if clause WRITE appears on the ATOMIC directive
295 !$omp atomic acq_rel write
296 i = j
297 !ERROR: Clause ACQ_REL is not allowed if clause WRITE appears on the ATOMIC directive
298 !$omp atomic write acq_rel
299 i = j
301 !ERROR: Clause ACQUIRE is not allowed if clause WRITE appears on the ATOMIC directive
302 !$omp atomic acquire write
303 i = j
304 !ERROR: Clause ACQUIRE is not allowed if clause WRITE appears on the ATOMIC directive
305 !$omp atomic write acquire
306 i = j
309 ! 2.17.7.6
310 ! If atomic-clause is update or not present then memory-order-clause must not be acq_rel or acquire.
312 !ERROR: Clause ACQ_REL is not allowed if clause UPDATE appears on the ATOMIC directive
313 !$omp atomic acq_rel update
314 i = j
315 !ERROR: Clause ACQ_REL is not allowed if clause UPDATE appears on the ATOMIC directive
316 !$omp atomic update acq_rel
317 i = j
319 !ERROR: Clause ACQUIRE is not allowed if clause UPDATE appears on the ATOMIC directive
320 !$omp atomic acquire update
321 i = j
323 !ERROR: Clause ACQUIRE is not allowed if clause UPDATE appears on the ATOMIC directive
324 !$omp atomic update acquire
325 i = j
327 !ERROR: Clause ACQ_REL is not allowed on the ATOMIC directive
328 !$omp atomic acq_rel
329 i = j
331 !ERROR: Clause ACQUIRE is not allowed on the ATOMIC directive
332 !$omp atomic acquire
333 i = j
334 end program