1 // RUN: %clang_cc1 %s -verify -ffreestanding -fsyntax-only -triple=i686-linux-gnu -std=c11
2
3 // Basic parsing/Sema tests for __c11_atomic_*
4
5 #include <stdatomic.h>
6
7 struct S { char c[3]; };
8
9 _Static_assert(__GCC_ATOMIC_BOOL_LOCK_FREE == 2, "");
10 _Static_assert(__GCC_ATOMIC_CHAR_LOCK_FREE == 2, "");
11 _Static_assert(__GCC_ATOMIC_CHAR16_T_LOCK_FREE == 2, "");
12 _Static_assert(__GCC_ATOMIC_CHAR32_T_LOCK_FREE == 2, "");
13 _Static_assert(__GCC_ATOMIC_WCHAR_T_LOCK_FREE == 2, "");
14 _Static_assert(__GCC_ATOMIC_SHORT_LOCK_FREE == 2, "");
15 _Static_assert(__GCC_ATOMIC_INT_LOCK_FREE == 2, "");
16 _Static_assert(__GCC_ATOMIC_LONG_LOCK_FREE == 2, "");
17 #ifdef __i386__
18 _Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 1, "");
19 #else
20 _Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 2, "");
21 #endif
22 _Static_assert(__GCC_ATOMIC_POINTER_LOCK_FREE == 2, "");
23
24 _Static_assert(__c11_atomic_is_lock_free(1), "");
25 _Static_assert(__c11_atomic_is_lock_free(2), "");
26 _Static_assert(__c11_atomic_is_lock_free(3), ""); // expected-error {{not an integral constant expression}}
27 _Static_assert(__c11_atomic_is_lock_free(4), "");
28 _Static_assert(__c11_atomic_is_lock_free(8), "");
29 _Static_assert(__c11_atomic_is_lock_free(16), ""); // expected-error {{not an integral constant expression}}
30 _Static_assert(__c11_atomic_is_lock_free(17), ""); // expected-error {{not an integral constant expression}}
31
32 _Static_assert(__atomic_is_lock_free(1, 0), "");
33 _Static_assert(__atomic_is_lock_free(2, 0), "");
34 _Static_assert(__atomic_is_lock_free(3, 0), ""); // expected-error {{not an integral constant expression}}
35 _Static_assert(__atomic_is_lock_free(4, 0), "");
36 _Static_assert(__atomic_is_lock_free(8, 0), "");
37 _Static_assert(__atomic_is_lock_free(16, 0), ""); // expected-error {{not an integral constant expression}}
38 _Static_assert(__atomic_is_lock_free(17, 0), ""); // expected-error {{not an integral constant expression}}
39
40 _Static_assert(atomic_is_lock_free((atomic_char*)0), "");
41 _Static_assert(atomic_is_lock_free((atomic_short*)0), "");
42 _Static_assert(atomic_is_lock_free((atomic_int*)0), "");
43 _Static_assert(atomic_is_lock_free((atomic_long*)0), "");
44 // expected-error@+1 {{__int128 is not supported on this target}}
45 _Static_assert(atomic_is_lock_free((_Atomic(__int128)*)0), ""); // expected-error {{not an integral constant expression}}
46 _Static_assert(atomic_is_lock_free(0 + (atomic_char*)0), "");
47
48 char i8;
49 short i16;
50 int i32;
51 int __attribute__((vector_size(8))) i64;
52 struct Incomplete *incomplete; // expected-note {{forward declaration of 'struct Incomplete'}}
53
54 _Static_assert(__atomic_is_lock_free(1, &i8), "");
55 _Static_assert(__atomic_is_lock_free(1, &i64), "");
56 _Static_assert(__atomic_is_lock_free(2, &i8), ""); // expected-error {{not an integral constant expression}}
57 _Static_assert(__atomic_is_lock_free(2, &i16), "");
58 _Static_assert(__atomic_is_lock_free(2, &i64), "");
59 _Static_assert(__atomic_is_lock_free(4, &i16), ""); // expected-error {{not an integral constant expression}}
60 _Static_assert(__atomic_is_lock_free(4, &i32), "");
61 _Static_assert(__atomic_is_lock_free(4, &i64), "");
62 _Static_assert(__atomic_is_lock_free(8, &i32), ""); // expected-error {{not an integral constant expression}}
63 _Static_assert(__atomic_is_lock_free(8, &i64), "");
64
65 _Static_assert(__atomic_always_lock_free(1, 0), "");
66 _Static_assert(__atomic_always_lock_free(2, 0), "");
67 _Static_assert(!__atomic_always_lock_free(3, 0), "");
68 _Static_assert(__atomic_always_lock_free(4, 0), "");
69 _Static_assert(__atomic_always_lock_free(8, 0), "");
70 _Static_assert(!__atomic_always_lock_free(16, 0), "");
71 _Static_assert(!__atomic_always_lock_free(17, 0), "");
72
73 _Static_assert(__atomic_always_lock_free(1, incomplete), "");
74 _Static_assert(!__atomic_always_lock_free(2, incomplete), "");
75 _Static_assert(!__atomic_always_lock_free(4, incomplete), "");
76
77 _Static_assert(__atomic_always_lock_free(1, &i8), "");
78 _Static_assert(__atomic_always_lock_free(1, &i64), "");
79 _Static_assert(!__atomic_always_lock_free(2, &i8), "");
80 _Static_assert(__atomic_always_lock_free(2, &i16), "");
81 _Static_assert(__atomic_always_lock_free(2, &i64), "");
82 _Static_assert(!__atomic_always_lock_free(4, &i16), "");
83 _Static_assert(__atomic_always_lock_free(4, &i32), "");
84 _Static_assert(__atomic_always_lock_free(4, &i64), "");
85 _Static_assert(!__atomic_always_lock_free(8, &i32), "");
86 _Static_assert(__atomic_always_lock_free(8, &i64), "");
87
f(_Atomic (int)* i,const _Atomic (int)* ci,_Atomic (int *)* p,_Atomic (float)* d,int * I,const int * CI,int ** P,float * D,struct S * s1,struct S * s2)88 void f(_Atomic(int) *i, const _Atomic(int) *ci,
89 _Atomic(int*) *p, _Atomic(float) *d,
90 int *I, const int *CI,
91 int **P, float *D, struct S *s1, struct S *s2) {
92 __c11_atomic_init(I, 5); // expected-error {{pointer to _Atomic}}
93 __c11_atomic_init(ci, 5); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}}
94
95 __c11_atomic_load(0); // expected-error {{too few arguments to function}}
96 __c11_atomic_load(0,0,0); // expected-error {{too many arguments to function}}
97 __c11_atomic_store(0,0,0); // expected-error {{address argument to atomic builtin must be a pointer}}
98 __c11_atomic_store((int*)0,0,0); // expected-error {{address argument to atomic operation must be a pointer to _Atomic}}
99 __c11_atomic_store(i, 0, memory_order_relaxed);
100 __c11_atomic_store(ci, 0, memory_order_relaxed); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}}
101
102 __c11_atomic_load(i, memory_order_seq_cst);
103 __c11_atomic_load(p, memory_order_seq_cst);
104 __c11_atomic_load(d, memory_order_seq_cst);
105 __c11_atomic_load(ci, memory_order_seq_cst); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}}
106
107 int load_n_1 = __atomic_load_n(I, memory_order_relaxed);
108 int *load_n_2 = __atomic_load_n(P, memory_order_relaxed);
109 float load_n_3 = __atomic_load_n(D, memory_order_relaxed); // expected-error {{must be a pointer to integer or pointer}}
110 __atomic_load_n(s1, memory_order_relaxed); // expected-error {{must be a pointer to integer or pointer}}
111 load_n_1 = __atomic_load_n(CI, memory_order_relaxed);
112
113 __atomic_load(i, I, memory_order_relaxed); // expected-error {{must be a pointer to a trivially-copyable type}}
114 __atomic_load(CI, I, memory_order_relaxed);
115
116 __atomic_load(I, i, memory_order_relaxed); // expected-warning {{passing '_Atomic(int) *' to parameter of type 'int *'}}
117 __atomic_load(I, *P, memory_order_relaxed);
118 __atomic_load(I, *P, memory_order_relaxed, 42); // expected-error {{too many arguments}}
119 (int)__atomic_load(I, I, memory_order_seq_cst); // expected-error {{operand of type 'void'}}
120 __atomic_load(s1, s2, memory_order_acquire);
121 (void)__atomic_load(I, CI, memory_order_relaxed); // expected-warning {{passing 'const int *' to parameter of type 'int *' discards qualifiers}}
122 __c11_atomic_store(i, 1, memory_order_seq_cst);
123 __c11_atomic_store(p, 1, memory_order_seq_cst); // expected-warning {{incompatible integer to pointer conversion}}
124 (int)__c11_atomic_store(d, 1, memory_order_seq_cst); // expected-error {{operand of type 'void'}}
125
126 __atomic_store_n(I, 4, memory_order_release);
127 __atomic_store_n(I, 4.0, memory_order_release);
128 __atomic_store_n(CI, 4, memory_order_release); // expected-error {{address argument to atomic operation must be a pointer to non-const type ('const int *' invalid)}}
129 __atomic_store_n(I, P, memory_order_release); // expected-warning {{parameter of type 'int'}}
130 __atomic_store_n(i, 1, memory_order_release); // expected-error {{must be a pointer to integer or pointer}}
131 __atomic_store_n(s1, *s2, memory_order_release); // expected-error {{must be a pointer to integer or pointer}}
132 __atomic_store_n(I, I, memory_order_release); // expected-warning {{incompatible pointer to integer conversion passing 'int *' to parameter of type 'int'; dereference with *}}
133
134 __atomic_store(I, *P, memory_order_release);
135 __atomic_store(CI, I, memory_order_release); // expected-error {{address argument to atomic operation must be a pointer to non-const type ('const int *' invalid)}}
136 __atomic_store(s1, s2, memory_order_release);
137 __atomic_store(i, I, memory_order_release); // expected-error {{trivially-copyable}}
138
139 int exchange_1 = __c11_atomic_exchange(i, 1, memory_order_seq_cst);
140 int exchange_2 = __c11_atomic_exchange(I, 1, memory_order_seq_cst); // expected-error {{must be a pointer to _Atomic}}
141 int exchange_3 = __atomic_exchange_n(i, 1, memory_order_seq_cst); // expected-error {{must be a pointer to integer or pointer}}
142 int exchange_4 = __atomic_exchange_n(I, 1, memory_order_seq_cst);
143
144 __atomic_exchange(s1, s2, s2, memory_order_seq_cst);
145 __atomic_exchange(s1, I, P, memory_order_seq_cst); // expected-warning 2{{parameter of type 'struct S *'}}
146 (int)__atomic_exchange(s1, s2, s2, memory_order_seq_cst); // expected-error {{operand of type 'void'}}
147 __atomic_exchange(I, I, I, memory_order_seq_cst);
148 __atomic_exchange(CI, I, I, memory_order_seq_cst); // expected-error {{address argument to atomic operation must be a pointer to non-const type ('const int *' invalid)}}
149 __atomic_exchange(I, I, CI, memory_order_seq_cst); // expected-warning {{passing 'const int *' to parameter of type 'int *' discards qualifiers}}
150
151 __c11_atomic_fetch_add(i, 1, memory_order_seq_cst);
152 __c11_atomic_fetch_add(p, 1, memory_order_seq_cst);
153 __c11_atomic_fetch_add(d, 1, memory_order_seq_cst); // expected-error {{must be a pointer to atomic integer or pointer}}
154
155 __atomic_fetch_add(i, 3, memory_order_seq_cst); // expected-error {{pointer to integer or pointer}}
156 __atomic_fetch_sub(I, 3, memory_order_seq_cst);
157 __atomic_fetch_sub(P, 3, memory_order_seq_cst);
158 __atomic_fetch_sub(D, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer or pointer}}
159 __atomic_fetch_sub(s1, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer or pointer}}
160
161 __c11_atomic_fetch_and(i, 1, memory_order_seq_cst);
162 __c11_atomic_fetch_and(p, 1, memory_order_seq_cst); // expected-error {{must be a pointer to atomic integer}}
163 __c11_atomic_fetch_and(d, 1, memory_order_seq_cst); // expected-error {{must be a pointer to atomic integer}}
164
165 __atomic_fetch_and(i, 3, memory_order_seq_cst); // expected-error {{pointer to integer}}
166 __atomic_fetch_or(I, 3, memory_order_seq_cst);
167 __atomic_fetch_xor(P, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer}}
168 __atomic_fetch_or(D, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer}}
169 __atomic_fetch_and(s1, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer}}
170
171 _Bool cmpexch_1 = __c11_atomic_compare_exchange_strong(i, 0, 1, memory_order_seq_cst, memory_order_seq_cst);
172 _Bool cmpexch_2 = __c11_atomic_compare_exchange_strong(p, 0, (int*)1, memory_order_seq_cst, memory_order_seq_cst);
173 _Bool cmpexch_3 = __c11_atomic_compare_exchange_strong(d, (int*)0, 1, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{incompatible pointer types}}
174 (void)__c11_atomic_compare_exchange_strong(i, CI, 1, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{passing 'const int *' to parameter of type 'int *' discards qualifiers}}
175
176 _Bool cmpexchw_1 = __c11_atomic_compare_exchange_weak(i, 0, 1, memory_order_seq_cst, memory_order_seq_cst);
177 _Bool cmpexchw_2 = __c11_atomic_compare_exchange_weak(p, 0, (int*)1, memory_order_seq_cst, memory_order_seq_cst);
178 _Bool cmpexchw_3 = __c11_atomic_compare_exchange_weak(d, (int*)0, 1, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{incompatible pointer types}}
179 (void)__c11_atomic_compare_exchange_weak(i, CI, 1, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{passing 'const int *' to parameter of type 'int *' discards qualifiers}}
180
181 _Bool cmpexch_4 = __atomic_compare_exchange_n(I, I, 5, 1, memory_order_seq_cst, memory_order_seq_cst);
182 _Bool cmpexch_5 = __atomic_compare_exchange_n(I, P, 5, 0, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{; dereference with *}}
183 _Bool cmpexch_6 = __atomic_compare_exchange_n(I, I, P, 0, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{passing 'int **' to parameter of type 'int'}}
184 (void)__atomic_compare_exchange_n(CI, I, 5, 1, memory_order_seq_cst, memory_order_seq_cst); // expected-error {{address argument to atomic operation must be a pointer to non-const type ('const int *' invalid)}}
185 (void)__atomic_compare_exchange_n(I, CI, 5, 1, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{passing 'const int *' to parameter of type 'int *' discards qualifiers}}
186
187 _Bool cmpexch_7 = __atomic_compare_exchange(I, I, 5, 1, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{passing 'int' to parameter of type 'int *'}}
188 _Bool cmpexch_8 = __atomic_compare_exchange(I, P, I, 0, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{; dereference with *}}
189 _Bool cmpexch_9 = __atomic_compare_exchange(I, I, I, 0, memory_order_seq_cst, memory_order_seq_cst);
190 (void)__atomic_compare_exchange(CI, I, I, 0, memory_order_seq_cst, memory_order_seq_cst); // expected-error {{address argument to atomic operation must be a pointer to non-const type ('const int *' invalid)}}
191 (void)__atomic_compare_exchange(I, CI, I, 0, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{passing 'const int *' to parameter of type 'int *' discards qualifiers}}
192
193 const volatile int flag_k = 0;
194 volatile int flag = 0;
195 (void)(int)__atomic_test_and_set(&flag_k, memory_order_seq_cst); // expected-warning {{passing 'const volatile int *' to parameter of type 'volatile void *'}}
196 (void)(int)__atomic_test_and_set(&flag, memory_order_seq_cst);
197 __atomic_clear(&flag_k, memory_order_seq_cst); // expected-warning {{passing 'const volatile int *' to parameter of type 'volatile void *'}}
198 __atomic_clear(&flag, memory_order_seq_cst);
199 (int)__atomic_clear(&flag, memory_order_seq_cst); // expected-error {{operand of type 'void'}}
200
201 __c11_atomic_init(ci, 0); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}}
202 __c11_atomic_store(ci, 0, memory_order_release); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}}
203 __c11_atomic_load(ci, memory_order_acquire); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' invalid)}}
204
205 // Ensure the <stdatomic.h> macros behave appropriately.
206 atomic_int n = ATOMIC_VAR_INIT(123);
207 atomic_init(&n, 456);
208 atomic_init(&n, (void*)0); // expected-warning {{passing 'void *' to parameter of type 'int'}}
209
210 const atomic_wchar_t cawt;
211 atomic_init(&cawt, L'x'); // expected-error {{non-const}}
212 atomic_wchar_t awt;
213 atomic_init(&awt, L'x');
214
215 int x = kill_dependency(12);
216
217 atomic_thread_fence(); // expected-error {{too few arguments to function call}}
218 atomic_thread_fence(memory_order_seq_cst);
219 atomic_signal_fence(memory_order_seq_cst);
220 void (*pfn)(memory_order) = &atomic_thread_fence;
221 pfn = &atomic_signal_fence;
222
223 int k = atomic_load_explicit(&n, memory_order_relaxed);
224 atomic_store_explicit(&n, k, memory_order_relaxed);
225 atomic_store(&n, atomic_load(&n));
226
227 k = atomic_exchange(&n, 72);
228 k = atomic_exchange_explicit(&n, k, memory_order_release);
229
230 atomic_compare_exchange_strong(&n, k, k); // expected-warning {{take the address with &}}
231 atomic_compare_exchange_weak(&n, &k, k);
232 atomic_compare_exchange_strong_explicit(&n, &k, k, memory_order_seq_cst); // expected-error {{too few arguments}}
233 atomic_compare_exchange_weak_explicit(&n, &k, k, memory_order_seq_cst, memory_order_acquire);
234
235 atomic_fetch_add(&k, n); // expected-error {{must be a pointer to _Atomic}}
236 k = atomic_fetch_add(&n, k);
237 k = atomic_fetch_sub(&n, k);
238 k = atomic_fetch_and(&n, k);
239 k = atomic_fetch_or(&n, k);
240 k = atomic_fetch_xor(&n, k);
241 k = atomic_fetch_add_explicit(&n, k, memory_order_acquire);
242 k = atomic_fetch_sub_explicit(&n, k, memory_order_release);
243 k = atomic_fetch_and_explicit(&n, k, memory_order_acq_rel);
244 k = atomic_fetch_or_explicit(&n, k, memory_order_consume);
245 k = atomic_fetch_xor_explicit(&n, k, memory_order_relaxed);
246
247 // C11 7.17.1/4: atomic_flag is a structure type.
248 struct atomic_flag must_be_struct = ATOMIC_FLAG_INIT;
249 // C11 7.17.8/5 implies that it is also a typedef type.
250 atomic_flag guard = ATOMIC_FLAG_INIT;
251 _Bool old_val = atomic_flag_test_and_set(&guard);
252 if (old_val) atomic_flag_clear(&guard);
253
254 old_val = (atomic_flag_test_and_set)(&guard);
255 if (old_val) (atomic_flag_clear)(&guard);
256
257 const atomic_flag const_guard;
258 atomic_flag_test_and_set(&const_guard); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const atomic_bool *' (aka 'const _Atomic(_Bool) *') invalid)}}
259 atomic_flag_clear(&const_guard); // expected-error {{address argument to atomic operation must be a pointer to non-const _Atomic type ('const atomic_bool *' (aka 'const _Atomic(_Bool) *') invalid)}}
260 }
261
262 _Atomic(int*) PR12527_a;
PR12527()263 void PR12527() { int *b = PR12527_a; }
264
PR16931(int * x)265 void PR16931(int* x) { // expected-note {{passing argument to parameter 'x' here}}
266 typedef struct { _Atomic(_Bool) flag; } flag;
267 flag flagvar = { 0 };
268 PR16931(&flagvar); // expected-warning {{incompatible pointer types}}
269 }
270
memory_checks(_Atomic (int)* Ap,int * p,int val)271 void memory_checks(_Atomic(int) *Ap, int *p, int val) {
272 (void)__c11_atomic_load(Ap, memory_order_relaxed);
273 (void)__c11_atomic_load(Ap, memory_order_acquire);
274 (void)__c11_atomic_load(Ap, memory_order_consume);
275 (void)__c11_atomic_load(Ap, memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
276 (void)__c11_atomic_load(Ap, memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
277 (void)__c11_atomic_load(Ap, memory_order_seq_cst);
278 (void)__c11_atomic_load(Ap, val);
279 (void)__c11_atomic_load(Ap, -1); // expected-warning {{memory order argument to atomic operation is invalid}}
280 (void)__c11_atomic_load(Ap, 42); // expected-warning {{memory order argument to atomic operation is invalid}}
281
282 (void)__c11_atomic_store(Ap, val, memory_order_relaxed);
283 (void)__c11_atomic_store(Ap, val, memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}}
284 (void)__c11_atomic_store(Ap, val, memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}}
285 (void)__c11_atomic_store(Ap, val, memory_order_release);
286 (void)__c11_atomic_store(Ap, val, memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
287 (void)__c11_atomic_store(Ap, val, memory_order_seq_cst);
288
289 (void)__c11_atomic_fetch_add(Ap, 1, memory_order_relaxed);
290 (void)__c11_atomic_fetch_add(Ap, 1, memory_order_acquire);
291 (void)__c11_atomic_fetch_add(Ap, 1, memory_order_consume);
292 (void)__c11_atomic_fetch_add(Ap, 1, memory_order_release);
293 (void)__c11_atomic_fetch_add(Ap, 1, memory_order_acq_rel);
294 (void)__c11_atomic_fetch_add(Ap, 1, memory_order_seq_cst);
295
296 (void)__c11_atomic_fetch_add(
297 (struct Incomplete * _Atomic *)0, // expected-error {{incomplete type 'struct Incomplete'}}
298 1, memory_order_seq_cst);
299
300 (void)__c11_atomic_init(Ap, val);
301 (void)__c11_atomic_init(Ap, val);
302 (void)__c11_atomic_init(Ap, val);
303 (void)__c11_atomic_init(Ap, val);
304 (void)__c11_atomic_init(Ap, val);
305 (void)__c11_atomic_init(Ap, val);
306
307 (void)__c11_atomic_fetch_sub(Ap, val, memory_order_relaxed);
308 (void)__c11_atomic_fetch_sub(Ap, val, memory_order_acquire);
309 (void)__c11_atomic_fetch_sub(Ap, val, memory_order_consume);
310 (void)__c11_atomic_fetch_sub(Ap, val, memory_order_release);
311 (void)__c11_atomic_fetch_sub(Ap, val, memory_order_acq_rel);
312 (void)__c11_atomic_fetch_sub(Ap, val, memory_order_seq_cst);
313
314 (void)__c11_atomic_fetch_and(Ap, val, memory_order_relaxed);
315 (void)__c11_atomic_fetch_and(Ap, val, memory_order_acquire);
316 (void)__c11_atomic_fetch_and(Ap, val, memory_order_consume);
317 (void)__c11_atomic_fetch_and(Ap, val, memory_order_release);
318 (void)__c11_atomic_fetch_and(Ap, val, memory_order_acq_rel);
319 (void)__c11_atomic_fetch_and(Ap, val, memory_order_seq_cst);
320
321 (void)__c11_atomic_fetch_or(Ap, val, memory_order_relaxed);
322 (void)__c11_atomic_fetch_or(Ap, val, memory_order_acquire);
323 (void)__c11_atomic_fetch_or(Ap, val, memory_order_consume);
324 (void)__c11_atomic_fetch_or(Ap, val, memory_order_release);
325 (void)__c11_atomic_fetch_or(Ap, val, memory_order_acq_rel);
326 (void)__c11_atomic_fetch_or(Ap, val, memory_order_seq_cst);
327
328 (void)__c11_atomic_fetch_xor(Ap, val, memory_order_relaxed);
329 (void)__c11_atomic_fetch_xor(Ap, val, memory_order_acquire);
330 (void)__c11_atomic_fetch_xor(Ap, val, memory_order_consume);
331 (void)__c11_atomic_fetch_xor(Ap, val, memory_order_release);
332 (void)__c11_atomic_fetch_xor(Ap, val, memory_order_acq_rel);
333 (void)__c11_atomic_fetch_xor(Ap, val, memory_order_seq_cst);
334
335 (void)__c11_atomic_exchange(Ap, val, memory_order_relaxed);
336 (void)__c11_atomic_exchange(Ap, val, memory_order_acquire);
337 (void)__c11_atomic_exchange(Ap, val, memory_order_consume);
338 (void)__c11_atomic_exchange(Ap, val, memory_order_release);
339 (void)__c11_atomic_exchange(Ap, val, memory_order_acq_rel);
340 (void)__c11_atomic_exchange(Ap, val, memory_order_seq_cst);
341
342 (void)__c11_atomic_compare_exchange_strong(Ap, p, val, memory_order_relaxed, memory_order_relaxed);
343 (void)__c11_atomic_compare_exchange_strong(Ap, p, val, memory_order_acquire, memory_order_relaxed);
344 (void)__c11_atomic_compare_exchange_strong(Ap, p, val, memory_order_consume, memory_order_relaxed);
345 (void)__c11_atomic_compare_exchange_strong(Ap, p, val, memory_order_release, memory_order_relaxed);
346 (void)__c11_atomic_compare_exchange_strong(Ap, p, val, memory_order_acq_rel, memory_order_relaxed);
347 (void)__c11_atomic_compare_exchange_strong(Ap, p, val, memory_order_seq_cst, memory_order_relaxed);
348
349 (void)__c11_atomic_compare_exchange_weak(Ap, p, val, memory_order_relaxed, memory_order_relaxed);
350 (void)__c11_atomic_compare_exchange_weak(Ap, p, val, memory_order_acquire, memory_order_relaxed);
351 (void)__c11_atomic_compare_exchange_weak(Ap, p, val, memory_order_consume, memory_order_relaxed);
352 (void)__c11_atomic_compare_exchange_weak(Ap, p, val, memory_order_release, memory_order_relaxed);
353 (void)__c11_atomic_compare_exchange_weak(Ap, p, val, memory_order_acq_rel, memory_order_relaxed);
354 (void)__c11_atomic_compare_exchange_weak(Ap, p, val, memory_order_seq_cst, memory_order_relaxed);
355
356 (void)__atomic_load_n(p, memory_order_relaxed);
357 (void)__atomic_load_n(p, memory_order_acquire);
358 (void)__atomic_load_n(p, memory_order_consume);
359 (void)__atomic_load_n(p, memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
360 (void)__atomic_load_n(p, memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
361 (void)__atomic_load_n(p, memory_order_seq_cst);
362
363 (void)__atomic_load(p, p, memory_order_relaxed);
364 (void)__atomic_load(p, p, memory_order_acquire);
365 (void)__atomic_load(p, p, memory_order_consume);
366 (void)__atomic_load(p, p, memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
367 (void)__atomic_load(p, p, memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
368 (void)__atomic_load(p, p, memory_order_seq_cst);
369
370 (void)__atomic_store(p, p, memory_order_relaxed);
371 (void)__atomic_store(p, p, memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}}
372 (void)__atomic_store(p, p, memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}}
373 (void)__atomic_store(p, p, memory_order_release);
374 (void)__atomic_store(p, p, memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
375 (void)__atomic_store(p, p, memory_order_seq_cst);
376
377 (void)__atomic_store_n(p, val, memory_order_relaxed);
378 (void)__atomic_store_n(p, val, memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}}
379 (void)__atomic_store_n(p, val, memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}}
380 (void)__atomic_store_n(p, val, memory_order_release);
381 (void)__atomic_store_n(p, val, memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
382 (void)__atomic_store_n(p, val, memory_order_seq_cst);
383
384 (void)__atomic_fetch_add(p, val, memory_order_relaxed);
385 (void)__atomic_fetch_add(p, val, memory_order_acquire);
386 (void)__atomic_fetch_add(p, val, memory_order_consume);
387 (void)__atomic_fetch_add(p, val, memory_order_release);
388 (void)__atomic_fetch_add(p, val, memory_order_acq_rel);
389 (void)__atomic_fetch_add(p, val, memory_order_seq_cst);
390
391 (void)__atomic_fetch_sub(p, val, memory_order_relaxed);
392 (void)__atomic_fetch_sub(p, val, memory_order_acquire);
393 (void)__atomic_fetch_sub(p, val, memory_order_consume);
394 (void)__atomic_fetch_sub(p, val, memory_order_release);
395 (void)__atomic_fetch_sub(p, val, memory_order_acq_rel);
396 (void)__atomic_fetch_sub(p, val, memory_order_seq_cst);
397
398 (void)__atomic_add_fetch(p, val, memory_order_relaxed);
399 (void)__atomic_add_fetch(p, val, memory_order_acquire);
400 (void)__atomic_add_fetch(p, val, memory_order_consume);
401 (void)__atomic_add_fetch(p, val, memory_order_release);
402 (void)__atomic_add_fetch(p, val, memory_order_acq_rel);
403 (void)__atomic_add_fetch(p, val, memory_order_seq_cst);
404
405 (void)__atomic_sub_fetch(p, val, memory_order_relaxed);
406 (void)__atomic_sub_fetch(p, val, memory_order_acquire);
407 (void)__atomic_sub_fetch(p, val, memory_order_consume);
408 (void)__atomic_sub_fetch(p, val, memory_order_release);
409 (void)__atomic_sub_fetch(p, val, memory_order_acq_rel);
410 (void)__atomic_sub_fetch(p, val, memory_order_seq_cst);
411
412 (void)__atomic_fetch_and(p, val, memory_order_relaxed);
413 (void)__atomic_fetch_and(p, val, memory_order_acquire);
414 (void)__atomic_fetch_and(p, val, memory_order_consume);
415 (void)__atomic_fetch_and(p, val, memory_order_release);
416 (void)__atomic_fetch_and(p, val, memory_order_acq_rel);
417 (void)__atomic_fetch_and(p, val, memory_order_seq_cst);
418
419 (void)__atomic_fetch_or(p, val, memory_order_relaxed);
420 (void)__atomic_fetch_or(p, val, memory_order_acquire);
421 (void)__atomic_fetch_or(p, val, memory_order_consume);
422 (void)__atomic_fetch_or(p, val, memory_order_release);
423 (void)__atomic_fetch_or(p, val, memory_order_acq_rel);
424 (void)__atomic_fetch_or(p, val, memory_order_seq_cst);
425
426 (void)__atomic_fetch_xor(p, val, memory_order_relaxed);
427 (void)__atomic_fetch_xor(p, val, memory_order_acquire);
428 (void)__atomic_fetch_xor(p, val, memory_order_consume);
429 (void)__atomic_fetch_xor(p, val, memory_order_release);
430 (void)__atomic_fetch_xor(p, val, memory_order_acq_rel);
431 (void)__atomic_fetch_xor(p, val, memory_order_seq_cst);
432
433 (void)__atomic_fetch_nand(p, val, memory_order_relaxed);
434 (void)__atomic_fetch_nand(p, val, memory_order_acquire);
435 (void)__atomic_fetch_nand(p, val, memory_order_consume);
436 (void)__atomic_fetch_nand(p, val, memory_order_release);
437 (void)__atomic_fetch_nand(p, val, memory_order_acq_rel);
438 (void)__atomic_fetch_nand(p, val, memory_order_seq_cst);
439
440 (void)__atomic_and_fetch(p, val, memory_order_relaxed);
441 (void)__atomic_and_fetch(p, val, memory_order_acquire);
442 (void)__atomic_and_fetch(p, val, memory_order_consume);
443 (void)__atomic_and_fetch(p, val, memory_order_release);
444 (void)__atomic_and_fetch(p, val, memory_order_acq_rel);
445 (void)__atomic_and_fetch(p, val, memory_order_seq_cst);
446
447 (void)__atomic_or_fetch(p, val, memory_order_relaxed);
448 (void)__atomic_or_fetch(p, val, memory_order_acquire);
449 (void)__atomic_or_fetch(p, val, memory_order_consume);
450 (void)__atomic_or_fetch(p, val, memory_order_release);
451 (void)__atomic_or_fetch(p, val, memory_order_acq_rel);
452 (void)__atomic_or_fetch(p, val, memory_order_seq_cst);
453
454 (void)__atomic_xor_fetch(p, val, memory_order_relaxed);
455 (void)__atomic_xor_fetch(p, val, memory_order_acquire);
456 (void)__atomic_xor_fetch(p, val, memory_order_consume);
457 (void)__atomic_xor_fetch(p, val, memory_order_release);
458 (void)__atomic_xor_fetch(p, val, memory_order_acq_rel);
459 (void)__atomic_xor_fetch(p, val, memory_order_seq_cst);
460
461 (void)__atomic_nand_fetch(p, val, memory_order_relaxed);
462 (void)__atomic_nand_fetch(p, val, memory_order_acquire);
463 (void)__atomic_nand_fetch(p, val, memory_order_consume);
464 (void)__atomic_nand_fetch(p, val, memory_order_release);
465 (void)__atomic_nand_fetch(p, val, memory_order_acq_rel);
466 (void)__atomic_nand_fetch(p, val, memory_order_seq_cst);
467
468 (void)__atomic_exchange_n(p, val, memory_order_relaxed);
469 (void)__atomic_exchange_n(p, val, memory_order_acquire);
470 (void)__atomic_exchange_n(p, val, memory_order_consume);
471 (void)__atomic_exchange_n(p, val, memory_order_release);
472 (void)__atomic_exchange_n(p, val, memory_order_acq_rel);
473 (void)__atomic_exchange_n(p, val, memory_order_seq_cst);
474
475 (void)__atomic_exchange(p, p, p, memory_order_relaxed);
476 (void)__atomic_exchange(p, p, p, memory_order_acquire);
477 (void)__atomic_exchange(p, p, p, memory_order_consume);
478 (void)__atomic_exchange(p, p, p, memory_order_release);
479 (void)__atomic_exchange(p, p, p, memory_order_acq_rel);
480 (void)__atomic_exchange(p, p, p, memory_order_seq_cst);
481
482 (void)__atomic_compare_exchange(p, p, p, 0, memory_order_relaxed, memory_order_relaxed);
483 (void)__atomic_compare_exchange(p, p, p, 0, memory_order_acquire, memory_order_relaxed);
484 (void)__atomic_compare_exchange(p, p, p, 0, memory_order_consume, memory_order_relaxed);
485 (void)__atomic_compare_exchange(p, p, p, 0, memory_order_release, memory_order_relaxed);
486 (void)__atomic_compare_exchange(p, p, p, 0, memory_order_acq_rel, memory_order_relaxed);
487 (void)__atomic_compare_exchange(p, p, p, 0, memory_order_seq_cst, memory_order_relaxed);
488
489 (void)__atomic_compare_exchange_n(p, p, val, 0, memory_order_relaxed, memory_order_relaxed);
490 (void)__atomic_compare_exchange_n(p, p, val, 0, memory_order_acquire, memory_order_relaxed);
491 (void)__atomic_compare_exchange_n(p, p, val, 0, memory_order_consume, memory_order_relaxed);
492 (void)__atomic_compare_exchange_n(p, p, val, 0, memory_order_release, memory_order_relaxed);
493 (void)__atomic_compare_exchange_n(p, p, val, 0, memory_order_acq_rel, memory_order_relaxed);
494 (void)__atomic_compare_exchange_n(p, p, val, 0, memory_order_seq_cst, memory_order_relaxed);
495 }
496
497
498