1 // RUN: %clang_cc1 %s -verify -fgnuc-version=4.2.1 -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_BOOL_LOCK_FREE == __CLANG_ATOMIC_BOOL_LOCK_FREE, "");
11 _Static_assert(__GCC_ATOMIC_CHAR_LOCK_FREE == 2, "");
12 _Static_assert(__GCC_ATOMIC_CHAR_LOCK_FREE == __CLANG_ATOMIC_CHAR_LOCK_FREE, "");
13 _Static_assert(__GCC_ATOMIC_CHAR16_T_LOCK_FREE == 2, "");
14 _Static_assert(__GCC_ATOMIC_CHAR16_T_LOCK_FREE == __CLANG_ATOMIC_CHAR16_T_LOCK_FREE, "");
15 _Static_assert(__GCC_ATOMIC_CHAR32_T_LOCK_FREE == 2, "");
16 _Static_assert(__GCC_ATOMIC_CHAR32_T_LOCK_FREE == __CLANG_ATOMIC_CHAR32_T_LOCK_FREE, "");
17 _Static_assert(__GCC_ATOMIC_WCHAR_T_LOCK_FREE == 2, "");
18 _Static_assert(__GCC_ATOMIC_WCHAR_T_LOCK_FREE == __CLANG_ATOMIC_WCHAR_T_LOCK_FREE, "");
19 _Static_assert(__GCC_ATOMIC_SHORT_LOCK_FREE == 2, "");
20 _Static_assert(__GCC_ATOMIC_SHORT_LOCK_FREE == __CLANG_ATOMIC_SHORT_LOCK_FREE, "");
21 _Static_assert(__GCC_ATOMIC_INT_LOCK_FREE == 2, "");
22 _Static_assert(__GCC_ATOMIC_INT_LOCK_FREE == __CLANG_ATOMIC_INT_LOCK_FREE, "");
23 _Static_assert(__GCC_ATOMIC_LONG_LOCK_FREE == 2, "");
24 _Static_assert(__GCC_ATOMIC_LONG_LOCK_FREE == __CLANG_ATOMIC_LONG_LOCK_FREE, "");
25 #ifdef __i386__
26 _Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 1, "");
27 #else
28 _Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == 2, "");
29 #endif
30 _Static_assert(__GCC_ATOMIC_LLONG_LOCK_FREE == __CLANG_ATOMIC_LLONG_LOCK_FREE, "");
31 _Static_assert(__GCC_ATOMIC_POINTER_LOCK_FREE == 2, "");
32 _Static_assert(__GCC_ATOMIC_POINTER_LOCK_FREE == __CLANG_ATOMIC_POINTER_LOCK_FREE, "");
33
34 _Static_assert(__c11_atomic_is_lock_free(1), "");
35 _Static_assert(__c11_atomic_is_lock_free(2), "");
36 _Static_assert(__c11_atomic_is_lock_free(3), ""); // expected-error {{not an integral constant expression}}
37 _Static_assert(__c11_atomic_is_lock_free(4), "");
38 _Static_assert(__c11_atomic_is_lock_free(8), "");
39 _Static_assert(__c11_atomic_is_lock_free(16), ""); // expected-error {{not an integral constant expression}}
40 _Static_assert(__c11_atomic_is_lock_free(17), ""); // expected-error {{not an integral constant expression}}
41
42 _Static_assert(__atomic_is_lock_free(1, 0), "");
43 _Static_assert(__atomic_is_lock_free(2, 0), "");
44 _Static_assert(__atomic_is_lock_free(3, 0), ""); // expected-error {{not an integral constant expression}}
45 _Static_assert(__atomic_is_lock_free(4, 0), "");
46 _Static_assert(__atomic_is_lock_free(8, 0), "");
47 _Static_assert(__atomic_is_lock_free(16, 0), ""); // expected-error {{not an integral constant expression}}
48 _Static_assert(__atomic_is_lock_free(17, 0), ""); // expected-error {{not an integral constant expression}}
49
50 _Static_assert(atomic_is_lock_free((atomic_char*)0), "");
51 _Static_assert(atomic_is_lock_free((atomic_short*)0), "");
52 _Static_assert(atomic_is_lock_free((atomic_int*)0), "");
53 _Static_assert(atomic_is_lock_free((atomic_long*)0), "");
54 // expected-error@+1 {{__int128 is not supported on this target}}
55 _Static_assert(atomic_is_lock_free((_Atomic(__int128)*)0), ""); // expected-error {{not an integral constant expression}}
56 _Static_assert(atomic_is_lock_free(0 + (atomic_char*)0), "");
57
58 char i8;
59 short i16;
60 int i32;
61 int __attribute__((vector_size(8))) i64;
62 struct Incomplete *incomplete; // expected-note {{forward declaration of 'struct Incomplete'}}
63
64 _Static_assert(__atomic_is_lock_free(1, &i8), "");
65 _Static_assert(__atomic_is_lock_free(1, &i64), "");
66 _Static_assert(__atomic_is_lock_free(2, &i8), ""); // expected-error {{not an integral constant expression}}
67 _Static_assert(__atomic_is_lock_free(2, &i16), "");
68 _Static_assert(__atomic_is_lock_free(2, &i64), "");
69 _Static_assert(__atomic_is_lock_free(4, &i16), ""); // expected-error {{not an integral constant expression}}
70 _Static_assert(__atomic_is_lock_free(4, &i32), "");
71 _Static_assert(__atomic_is_lock_free(4, &i64), "");
72 _Static_assert(__atomic_is_lock_free(8, &i32), ""); // expected-error {{not an integral constant expression}}
73 _Static_assert(__atomic_is_lock_free(8, &i64), "");
74
75 _Static_assert(__atomic_always_lock_free(1, 0), "");
76 _Static_assert(__atomic_always_lock_free(2, 0), "");
77 _Static_assert(!__atomic_always_lock_free(3, 0), "");
78 _Static_assert(__atomic_always_lock_free(4, 0), "");
79 _Static_assert(__atomic_always_lock_free(8, 0), "");
80 _Static_assert(!__atomic_always_lock_free(16, 0), "");
81 _Static_assert(!__atomic_always_lock_free(17, 0), "");
82
83 _Static_assert(__atomic_always_lock_free(1, incomplete), "");
84 _Static_assert(!__atomic_always_lock_free(2, incomplete), "");
85 _Static_assert(!__atomic_always_lock_free(4, incomplete), "");
86
87 _Static_assert(__atomic_always_lock_free(1, &i8), "");
88 _Static_assert(__atomic_always_lock_free(1, &i64), "");
89 _Static_assert(!__atomic_always_lock_free(2, &i8), "");
90 _Static_assert(__atomic_always_lock_free(2, &i16), "");
91 _Static_assert(__atomic_always_lock_free(2, &i64), "");
92 _Static_assert(!__atomic_always_lock_free(4, &i16), "");
93 _Static_assert(__atomic_always_lock_free(4, &i32), "");
94 _Static_assert(__atomic_always_lock_free(4, &i64), "");
95 _Static_assert(!__atomic_always_lock_free(8, &i32), "");
96 _Static_assert(__atomic_always_lock_free(8, &i64), "");
97
98 #define _AS1 __attribute__((address_space(1)))
99 #define _AS2 __attribute__((address_space(2)))
100
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)101 void f(_Atomic(int) *i, const _Atomic(int) *ci,
102 _Atomic(int*) *p, _Atomic(float) *d,
103 int *I, const int *CI,
104 int **P, float *D, struct S *s1, struct S *s2) {
105 __c11_atomic_init(I, 5); // expected-error {{pointer to _Atomic}}
106 __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)}}
107
108 __c11_atomic_load(0); // expected-error {{too few arguments to function}}
109 __c11_atomic_load(0,0,0); // expected-error {{too many arguments to function}}
110 __c11_atomic_store(0,0,0); // expected-error {{address argument to atomic builtin must be a pointer}}
111 __c11_atomic_store((int*)0,0,0); // expected-error {{address argument to atomic operation must be a pointer to _Atomic}}
112 __c11_atomic_store(i, 0, memory_order_relaxed);
113 __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)}}
114
115 __c11_atomic_load(i, memory_order_seq_cst);
116 __c11_atomic_load(p, memory_order_seq_cst);
117 __c11_atomic_load(d, memory_order_seq_cst);
118 __c11_atomic_load(ci, memory_order_seq_cst);
119
120 int load_n_1 = __atomic_load_n(I, memory_order_relaxed);
121 int *load_n_2 = __atomic_load_n(P, memory_order_relaxed);
122 float load_n_3 = __atomic_load_n(D, memory_order_relaxed); // expected-error {{must be a pointer to integer or pointer}}
123 __atomic_load_n(s1, memory_order_relaxed); // expected-error {{must be a pointer to integer or pointer}}
124 load_n_1 = __atomic_load_n(CI, memory_order_relaxed);
125
126 __atomic_load(i, I, memory_order_relaxed); // expected-error {{must be a pointer to a trivially-copyable type}}
127 __atomic_load(CI, I, memory_order_relaxed);
128
129 __atomic_load(I, i, memory_order_relaxed); // expected-warning {{passing '_Atomic(int) *' to parameter of type 'int *'}}
130 __atomic_load(I, *P, memory_order_relaxed);
131 __atomic_load(I, *P, memory_order_relaxed, 42); // expected-error {{too many arguments}}
132 (int)__atomic_load(I, I, memory_order_seq_cst); // expected-error {{operand of type 'void'}}
133 __atomic_load(s1, s2, memory_order_acquire);
134 __atomic_load(CI, I, memory_order_relaxed);
135 __atomic_load(I, CI, memory_order_relaxed); // expected-warning {{passing 'const int *' to parameter of type 'int *' discards qualifiers}}
136 __atomic_load(CI, CI, memory_order_relaxed); // expected-warning {{passing 'const int *' to parameter of type 'int *' discards qualifiers}}
137
138 __c11_atomic_store(i, 1, memory_order_seq_cst);
139 __c11_atomic_store(p, 1, memory_order_seq_cst); // expected-warning {{incompatible integer to pointer conversion}}
140 (int)__c11_atomic_store(d, 1, memory_order_seq_cst); // expected-error {{operand of type 'void'}}
141
142 __atomic_store_n(I, 4, memory_order_release);
143 __atomic_store_n(I, 4.0, memory_order_release);
144 __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)}}
145 __atomic_store_n(I, P, memory_order_release); // expected-warning {{parameter of type 'int'}}
146 __atomic_store_n(i, 1, memory_order_release); // expected-error {{must be a pointer to integer or pointer}}
147 __atomic_store_n(s1, *s2, memory_order_release); // expected-error {{must be a pointer to integer or pointer}}
148 __atomic_store_n(I, I, memory_order_release); // expected-warning {{incompatible pointer to integer conversion passing 'int *' to parameter of type 'int'; dereference with *}}
149
150 __atomic_store(I, *P, memory_order_release);
151 __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)}}
152 __atomic_store(s1, s2, memory_order_release);
153 __atomic_store(i, I, memory_order_release); // expected-error {{trivially-copyable}}
154
155 int exchange_1 = __c11_atomic_exchange(i, 1, memory_order_seq_cst);
156 int exchange_2 = __c11_atomic_exchange(I, 1, memory_order_seq_cst); // expected-error {{must be a pointer to _Atomic}}
157 int exchange_3 = __atomic_exchange_n(i, 1, memory_order_seq_cst); // expected-error {{must be a pointer to integer or pointer}}
158 int exchange_4 = __atomic_exchange_n(I, 1, memory_order_seq_cst);
159
160 __atomic_exchange(s1, s2, s2, memory_order_seq_cst);
161 __atomic_exchange(s1, I, P, memory_order_seq_cst); // expected-warning 2{{parameter of type 'struct S *'}}
162 (int)__atomic_exchange(s1, s2, s2, memory_order_seq_cst); // expected-error {{operand of type 'void'}}
163 __atomic_exchange(I, I, I, memory_order_seq_cst);
164 __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)}}
165 __atomic_exchange(I, I, CI, memory_order_seq_cst); // expected-warning {{passing 'const int *' to parameter of type 'int *' discards qualifiers}}
166
167 __c11_atomic_fetch_add(i, 1, memory_order_seq_cst);
168 __c11_atomic_fetch_add(p, 1, memory_order_seq_cst);
169 __c11_atomic_fetch_add(d, 1, memory_order_seq_cst); // expected-error {{must be a pointer to atomic integer or pointer}}
170
171 __atomic_fetch_add(i, 3, memory_order_seq_cst); // expected-error {{pointer to integer or pointer}}
172 __atomic_fetch_sub(I, 3, memory_order_seq_cst);
173 __atomic_fetch_sub(P, 3, memory_order_seq_cst);
174 __atomic_fetch_sub(D, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer or pointer}}
175 __atomic_fetch_sub(s1, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer or pointer}}
176 __atomic_fetch_min(D, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer}}
177 __atomic_fetch_max(P, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer}}
178 __atomic_fetch_max(p, 3); // expected-error {{too few arguments to function call, expected 3, have 2}}
179
180 __c11_atomic_fetch_and(i, 1, memory_order_seq_cst);
181 __c11_atomic_fetch_and(p, 1, memory_order_seq_cst); // expected-error {{must be a pointer to atomic integer}}
182 __c11_atomic_fetch_and(d, 1, memory_order_seq_cst); // expected-error {{must be a pointer to atomic integer}}
183
184 __atomic_fetch_and(i, 3, memory_order_seq_cst); // expected-error {{pointer to integer}}
185 __atomic_fetch_or(I, 3, memory_order_seq_cst);
186 __atomic_fetch_xor(P, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer}}
187 __atomic_fetch_or(D, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer}}
188 __atomic_fetch_and(s1, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer}}
189
190 _Bool cmpexch_1 = __c11_atomic_compare_exchange_strong(i, I, 1, memory_order_seq_cst, memory_order_seq_cst);
191 _Bool cmpexch_2 = __c11_atomic_compare_exchange_strong(p, P, (int*)1, memory_order_seq_cst, memory_order_seq_cst);
192 _Bool cmpexch_3 = __c11_atomic_compare_exchange_strong(d, I, 1, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{incompatible pointer types}}
193 (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}}
194
195 _Bool cmpexchw_1 = __c11_atomic_compare_exchange_weak(i, I, 1, memory_order_seq_cst, memory_order_seq_cst);
196 _Bool cmpexchw_2 = __c11_atomic_compare_exchange_weak(p, P, (int*)1, memory_order_seq_cst, memory_order_seq_cst);
197 _Bool cmpexchw_3 = __c11_atomic_compare_exchange_weak(d, I, 1, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{incompatible pointer types}}
198 (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}}
199
200 _Bool cmpexch_4 = __atomic_compare_exchange_n(I, I, 5, 1, memory_order_seq_cst, memory_order_seq_cst);
201 _Bool cmpexch_5 = __atomic_compare_exchange_n(I, P, 5, 0, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{; dereference with *}}
202 _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'}}
203 (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)}}
204 (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}}
205
206 _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 *'}}
207 _Bool cmpexch_8 = __atomic_compare_exchange(I, P, I, 0, memory_order_seq_cst, memory_order_seq_cst); // expected-warning {{; dereference with *}}
208 _Bool cmpexch_9 = __atomic_compare_exchange(I, I, I, 0, memory_order_seq_cst, memory_order_seq_cst);
209 (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)}}
210 (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}}
211
212 // Pointers to different address spaces are allowed.
213 _Bool cmpexch_10 = __c11_atomic_compare_exchange_strong((_Atomic int _AS1 *)0x308, (int _AS2 *)0x309, 1, memory_order_seq_cst, memory_order_seq_cst);
214
215 const volatile int flag_k = 0;
216 volatile int flag = 0;
217 (void)(int)__atomic_test_and_set(&flag_k, memory_order_seq_cst); // expected-warning {{passing 'const volatile int *' to parameter of type 'volatile void *'}}
218 (void)(int)__atomic_test_and_set(&flag, memory_order_seq_cst);
219 __atomic_clear(&flag_k, memory_order_seq_cst); // expected-warning {{passing 'const volatile int *' to parameter of type 'volatile void *'}}
220 __atomic_clear(&flag, memory_order_seq_cst);
221 (int)__atomic_clear(&flag, memory_order_seq_cst); // expected-error {{operand of type 'void'}}
222
223 __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)}}
224 __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)}}
225 __c11_atomic_load(ci, memory_order_acquire);
226
227 // Ensure the <stdatomic.h> macros behave appropriately.
228 atomic_int n = ATOMIC_VAR_INIT(123);
229 atomic_init(&n, 456);
230 atomic_init(&n, (void*)0); // expected-warning {{passing 'void *' to parameter of type 'int'}}
231
232 const atomic_wchar_t cawt;
233 atomic_init(&cawt, L'x'); // expected-error {{non-const}}
234 atomic_wchar_t awt;
235 atomic_init(&awt, L'x');
236
237 int x = kill_dependency(12);
238
239 atomic_thread_fence(); // expected-error {{too few arguments to function call}}
240 atomic_thread_fence(memory_order_seq_cst);
241 atomic_signal_fence(memory_order_seq_cst);
242 void (*pfn)(memory_order) = &atomic_thread_fence;
243 pfn = &atomic_signal_fence;
244
245 int k = atomic_load_explicit(&n, memory_order_relaxed);
246 atomic_store_explicit(&n, k, memory_order_relaxed);
247 atomic_store(&n, atomic_load(&n));
248
249 k = atomic_exchange(&n, 72);
250 k = atomic_exchange_explicit(&n, k, memory_order_release);
251
252 atomic_compare_exchange_strong(&n, k, k); // expected-warning {{take the address with &}}
253 atomic_compare_exchange_weak(&n, &k, k);
254 atomic_compare_exchange_strong_explicit(&n, &k, k, memory_order_seq_cst); // expected-error {{too few arguments}}
255 atomic_compare_exchange_weak_explicit(&n, &k, k, memory_order_seq_cst, memory_order_acquire);
256
257 atomic_fetch_add(&k, n); // expected-error {{must be a pointer to _Atomic}}
258 k = atomic_fetch_add(&n, k);
259 k = atomic_fetch_sub(&n, k);
260 k = atomic_fetch_and(&n, k);
261 k = atomic_fetch_or(&n, k);
262 k = atomic_fetch_xor(&n, k);
263 k = atomic_fetch_add_explicit(&n, k, memory_order_acquire);
264 k = atomic_fetch_sub_explicit(&n, k, memory_order_release);
265 k = atomic_fetch_and_explicit(&n, k, memory_order_acq_rel);
266 k = atomic_fetch_or_explicit(&n, k, memory_order_consume);
267 k = atomic_fetch_xor_explicit(&n, k, memory_order_relaxed);
268
269 // C11 7.17.1/4: atomic_flag is a structure type.
270 struct atomic_flag must_be_struct = ATOMIC_FLAG_INIT;
271 // C11 7.17.8/5 implies that it is also a typedef type.
272 atomic_flag guard = ATOMIC_FLAG_INIT;
273 _Bool old_val = atomic_flag_test_and_set(&guard);
274 if (old_val) atomic_flag_clear(&guard);
275
276 old_val = (atomic_flag_test_and_set)(&guard);
277 if (old_val) (atomic_flag_clear)(&guard);
278
279 const atomic_flag const_guard;
280 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)}}
281 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)}}
282 }
283
284 _Atomic(int*) PR12527_a;
PR12527()285 void PR12527() { int *b = PR12527_a; }
286
PR16931(int * x)287 void PR16931(int* x) { // expected-note {{passing argument to parameter 'x' here}}
288 typedef struct { _Atomic(_Bool) flag; } flag;
289 flag flagvar = { 0 };
290 PR16931(&flagvar); // expected-warning {{incompatible pointer types}}
291 }
292
memory_checks(_Atomic (int)* Ap,int * p,int val)293 void memory_checks(_Atomic(int) *Ap, int *p, int val) {
294 (void)__c11_atomic_load(Ap, memory_order_relaxed);
295 (void)__c11_atomic_load(Ap, memory_order_acquire);
296 (void)__c11_atomic_load(Ap, memory_order_consume);
297 (void)__c11_atomic_load(Ap, memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
298 (void)__c11_atomic_load(Ap, memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
299 (void)__c11_atomic_load(Ap, memory_order_seq_cst);
300 (void)__c11_atomic_load(Ap, val);
301 (void)__c11_atomic_load(Ap, -1); // expected-warning {{memory order argument to atomic operation is invalid}}
302 (void)__c11_atomic_load(Ap, 42); // expected-warning {{memory order argument to atomic operation is invalid}}
303
304 (void)__c11_atomic_store(Ap, val, memory_order_relaxed);
305 (void)__c11_atomic_store(Ap, val, memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}}
306 (void)__c11_atomic_store(Ap, val, memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}}
307 (void)__c11_atomic_store(Ap, val, memory_order_release);
308 (void)__c11_atomic_store(Ap, val, memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
309 (void)__c11_atomic_store(Ap, val, memory_order_seq_cst);
310
311 (void)__c11_atomic_fetch_add(Ap, 1, memory_order_relaxed);
312 (void)__c11_atomic_fetch_add(Ap, 1, memory_order_acquire);
313 (void)__c11_atomic_fetch_add(Ap, 1, memory_order_consume);
314 (void)__c11_atomic_fetch_add(Ap, 1, memory_order_release);
315 (void)__c11_atomic_fetch_add(Ap, 1, memory_order_acq_rel);
316 (void)__c11_atomic_fetch_add(Ap, 1, memory_order_seq_cst);
317
318 (void)__c11_atomic_fetch_add(
319 (struct Incomplete * _Atomic *)0, // expected-error {{incomplete type 'struct Incomplete'}}
320 1, memory_order_seq_cst);
321
322 (void)__c11_atomic_init(Ap, val);
323 (void)__c11_atomic_init(Ap, val);
324 (void)__c11_atomic_init(Ap, val);
325 (void)__c11_atomic_init(Ap, val);
326 (void)__c11_atomic_init(Ap, val);
327 (void)__c11_atomic_init(Ap, val);
328
329 (void)__c11_atomic_fetch_sub(Ap, val, memory_order_relaxed);
330 (void)__c11_atomic_fetch_sub(Ap, val, memory_order_acquire);
331 (void)__c11_atomic_fetch_sub(Ap, val, memory_order_consume);
332 (void)__c11_atomic_fetch_sub(Ap, val, memory_order_release);
333 (void)__c11_atomic_fetch_sub(Ap, val, memory_order_acq_rel);
334 (void)__c11_atomic_fetch_sub(Ap, val, memory_order_seq_cst);
335
336 (void)__c11_atomic_fetch_and(Ap, val, memory_order_relaxed);
337 (void)__c11_atomic_fetch_and(Ap, val, memory_order_acquire);
338 (void)__c11_atomic_fetch_and(Ap, val, memory_order_consume);
339 (void)__c11_atomic_fetch_and(Ap, val, memory_order_release);
340 (void)__c11_atomic_fetch_and(Ap, val, memory_order_acq_rel);
341 (void)__c11_atomic_fetch_and(Ap, val, memory_order_seq_cst);
342
343 (void)__c11_atomic_fetch_or(Ap, val, memory_order_relaxed);
344 (void)__c11_atomic_fetch_or(Ap, val, memory_order_acquire);
345 (void)__c11_atomic_fetch_or(Ap, val, memory_order_consume);
346 (void)__c11_atomic_fetch_or(Ap, val, memory_order_release);
347 (void)__c11_atomic_fetch_or(Ap, val, memory_order_acq_rel);
348 (void)__c11_atomic_fetch_or(Ap, val, memory_order_seq_cst);
349
350 (void)__c11_atomic_fetch_xor(Ap, val, memory_order_relaxed);
351 (void)__c11_atomic_fetch_xor(Ap, val, memory_order_acquire);
352 (void)__c11_atomic_fetch_xor(Ap, val, memory_order_consume);
353 (void)__c11_atomic_fetch_xor(Ap, val, memory_order_release);
354 (void)__c11_atomic_fetch_xor(Ap, val, memory_order_acq_rel);
355 (void)__c11_atomic_fetch_xor(Ap, val, memory_order_seq_cst);
356
357 (void)__c11_atomic_fetch_min(Ap, val, memory_order_relaxed);
358 (void)__c11_atomic_fetch_min(Ap, val, memory_order_acquire);
359 (void)__c11_atomic_fetch_min(Ap, val, memory_order_consume);
360 (void)__c11_atomic_fetch_min(Ap, val, memory_order_release);
361 (void)__c11_atomic_fetch_min(Ap, val, memory_order_acq_rel);
362 (void)__c11_atomic_fetch_min(Ap, val, memory_order_seq_cst);
363
364 (void)__c11_atomic_fetch_max(Ap, val, memory_order_relaxed);
365 (void)__c11_atomic_fetch_max(Ap, val, memory_order_acquire);
366 (void)__c11_atomic_fetch_max(Ap, val, memory_order_consume);
367 (void)__c11_atomic_fetch_max(Ap, val, memory_order_release);
368 (void)__c11_atomic_fetch_max(Ap, val, memory_order_acq_rel);
369 (void)__c11_atomic_fetch_max(Ap, val, memory_order_seq_cst);
370
371 (void)__c11_atomic_exchange(Ap, val, memory_order_relaxed);
372 (void)__c11_atomic_exchange(Ap, val, memory_order_acquire);
373 (void)__c11_atomic_exchange(Ap, val, memory_order_consume);
374 (void)__c11_atomic_exchange(Ap, val, memory_order_release);
375 (void)__c11_atomic_exchange(Ap, val, memory_order_acq_rel);
376 (void)__c11_atomic_exchange(Ap, val, memory_order_seq_cst);
377
378 (void)__c11_atomic_compare_exchange_strong(Ap, p, val, memory_order_relaxed, memory_order_relaxed);
379 (void)__c11_atomic_compare_exchange_strong(Ap, p, val, memory_order_acquire, memory_order_relaxed);
380 (void)__c11_atomic_compare_exchange_strong(Ap, p, val, memory_order_consume, memory_order_relaxed);
381 (void)__c11_atomic_compare_exchange_strong(Ap, p, val, memory_order_release, memory_order_relaxed);
382 (void)__c11_atomic_compare_exchange_strong(Ap, p, val, memory_order_acq_rel, memory_order_relaxed);
383 (void)__c11_atomic_compare_exchange_strong(Ap, p, val, memory_order_seq_cst, memory_order_relaxed);
384
385 (void)__c11_atomic_compare_exchange_weak(Ap, p, val, memory_order_relaxed, memory_order_relaxed);
386 (void)__c11_atomic_compare_exchange_weak(Ap, p, val, memory_order_acquire, memory_order_relaxed);
387 (void)__c11_atomic_compare_exchange_weak(Ap, p, val, memory_order_consume, memory_order_relaxed);
388 (void)__c11_atomic_compare_exchange_weak(Ap, p, val, memory_order_release, memory_order_relaxed);
389 (void)__c11_atomic_compare_exchange_weak(Ap, p, val, memory_order_acq_rel, memory_order_relaxed);
390 (void)__c11_atomic_compare_exchange_weak(Ap, p, val, memory_order_seq_cst, memory_order_relaxed);
391
392 (void)__atomic_load_n(p, memory_order_relaxed);
393 (void)__atomic_load_n(p, memory_order_acquire);
394 (void)__atomic_load_n(p, memory_order_consume);
395 (void)__atomic_load_n(p, memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
396 (void)__atomic_load_n(p, memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
397 (void)__atomic_load_n(p, memory_order_seq_cst);
398
399 (void)__atomic_load(p, p, memory_order_relaxed);
400 (void)__atomic_load(p, p, memory_order_acquire);
401 (void)__atomic_load(p, p, memory_order_consume);
402 (void)__atomic_load(p, p, memory_order_release); // expected-warning {{memory order argument to atomic operation is invalid}}
403 (void)__atomic_load(p, p, memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
404 (void)__atomic_load(p, p, memory_order_seq_cst);
405
406 (void)__atomic_store(p, p, memory_order_relaxed);
407 (void)__atomic_store(p, p, memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}}
408 (void)__atomic_store(p, p, memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}}
409 (void)__atomic_store(p, p, memory_order_release);
410 (void)__atomic_store(p, p, memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
411 (void)__atomic_store(p, p, memory_order_seq_cst);
412
413 (void)__atomic_store_n(p, val, memory_order_relaxed);
414 (void)__atomic_store_n(p, val, memory_order_acquire); // expected-warning {{memory order argument to atomic operation is invalid}}
415 (void)__atomic_store_n(p, val, memory_order_consume); // expected-warning {{memory order argument to atomic operation is invalid}}
416 (void)__atomic_store_n(p, val, memory_order_release);
417 (void)__atomic_store_n(p, val, memory_order_acq_rel); // expected-warning {{memory order argument to atomic operation is invalid}}
418 (void)__atomic_store_n(p, val, memory_order_seq_cst);
419
420 (void)__atomic_fetch_add(p, val, memory_order_relaxed);
421 (void)__atomic_fetch_add(p, val, memory_order_acquire);
422 (void)__atomic_fetch_add(p, val, memory_order_consume);
423 (void)__atomic_fetch_add(p, val, memory_order_release);
424 (void)__atomic_fetch_add(p, val, memory_order_acq_rel);
425 (void)__atomic_fetch_add(p, val, memory_order_seq_cst);
426
427 (void)__atomic_fetch_sub(p, val, memory_order_relaxed);
428 (void)__atomic_fetch_sub(p, val, memory_order_acquire);
429 (void)__atomic_fetch_sub(p, val, memory_order_consume);
430 (void)__atomic_fetch_sub(p, val, memory_order_release);
431 (void)__atomic_fetch_sub(p, val, memory_order_acq_rel);
432 (void)__atomic_fetch_sub(p, val, memory_order_seq_cst);
433
434 (void)__atomic_add_fetch(p, val, memory_order_relaxed);
435 (void)__atomic_add_fetch(p, val, memory_order_acquire);
436 (void)__atomic_add_fetch(p, val, memory_order_consume);
437 (void)__atomic_add_fetch(p, val, memory_order_release);
438 (void)__atomic_add_fetch(p, val, memory_order_acq_rel);
439 (void)__atomic_add_fetch(p, val, memory_order_seq_cst);
440
441 (void)__atomic_sub_fetch(p, val, memory_order_relaxed);
442 (void)__atomic_sub_fetch(p, val, memory_order_acquire);
443 (void)__atomic_sub_fetch(p, val, memory_order_consume);
444 (void)__atomic_sub_fetch(p, val, memory_order_release);
445 (void)__atomic_sub_fetch(p, val, memory_order_acq_rel);
446 (void)__atomic_sub_fetch(p, val, memory_order_seq_cst);
447
448 (void)__atomic_fetch_and(p, val, memory_order_relaxed);
449 (void)__atomic_fetch_and(p, val, memory_order_acquire);
450 (void)__atomic_fetch_and(p, val, memory_order_consume);
451 (void)__atomic_fetch_and(p, val, memory_order_release);
452 (void)__atomic_fetch_and(p, val, memory_order_acq_rel);
453 (void)__atomic_fetch_and(p, val, memory_order_seq_cst);
454
455 (void)__atomic_fetch_or(p, val, memory_order_relaxed);
456 (void)__atomic_fetch_or(p, val, memory_order_acquire);
457 (void)__atomic_fetch_or(p, val, memory_order_consume);
458 (void)__atomic_fetch_or(p, val, memory_order_release);
459 (void)__atomic_fetch_or(p, val, memory_order_acq_rel);
460 (void)__atomic_fetch_or(p, val, memory_order_seq_cst);
461
462 (void)__atomic_fetch_xor(p, val, memory_order_relaxed);
463 (void)__atomic_fetch_xor(p, val, memory_order_acquire);
464 (void)__atomic_fetch_xor(p, val, memory_order_consume);
465 (void)__atomic_fetch_xor(p, val, memory_order_release);
466 (void)__atomic_fetch_xor(p, val, memory_order_acq_rel);
467 (void)__atomic_fetch_xor(p, val, memory_order_seq_cst);
468
469 (void)__atomic_fetch_nand(p, val, memory_order_relaxed);
470 (void)__atomic_fetch_nand(p, val, memory_order_acquire);
471 (void)__atomic_fetch_nand(p, val, memory_order_consume);
472 (void)__atomic_fetch_nand(p, val, memory_order_release);
473 (void)__atomic_fetch_nand(p, val, memory_order_acq_rel);
474 (void)__atomic_fetch_nand(p, val, memory_order_seq_cst);
475
476 (void)__atomic_fetch_min(p, val, memory_order_relaxed);
477 (void)__atomic_fetch_min(p, val, memory_order_acquire);
478 (void)__atomic_fetch_min(p, val, memory_order_consume);
479 (void)__atomic_fetch_min(p, val, memory_order_release);
480 (void)__atomic_fetch_min(p, val, memory_order_acq_rel);
481 (void)__atomic_fetch_min(p, val, memory_order_seq_cst);
482
483 (void)__atomic_fetch_max(p, val, memory_order_relaxed);
484 (void)__atomic_fetch_max(p, val, memory_order_acquire);
485 (void)__atomic_fetch_max(p, val, memory_order_consume);
486 (void)__atomic_fetch_max(p, val, memory_order_release);
487 (void)__atomic_fetch_max(p, val, memory_order_acq_rel);
488 (void)__atomic_fetch_max(p, val, memory_order_seq_cst);
489
490 (void)__atomic_and_fetch(p, val, memory_order_relaxed);
491 (void)__atomic_and_fetch(p, val, memory_order_acquire);
492 (void)__atomic_and_fetch(p, val, memory_order_consume);
493 (void)__atomic_and_fetch(p, val, memory_order_release);
494 (void)__atomic_and_fetch(p, val, memory_order_acq_rel);
495 (void)__atomic_and_fetch(p, val, memory_order_seq_cst);
496
497 (void)__atomic_or_fetch(p, val, memory_order_relaxed);
498 (void)__atomic_or_fetch(p, val, memory_order_acquire);
499 (void)__atomic_or_fetch(p, val, memory_order_consume);
500 (void)__atomic_or_fetch(p, val, memory_order_release);
501 (void)__atomic_or_fetch(p, val, memory_order_acq_rel);
502 (void)__atomic_or_fetch(p, val, memory_order_seq_cst);
503
504 (void)__atomic_xor_fetch(p, val, memory_order_relaxed);
505 (void)__atomic_xor_fetch(p, val, memory_order_acquire);
506 (void)__atomic_xor_fetch(p, val, memory_order_consume);
507 (void)__atomic_xor_fetch(p, val, memory_order_release);
508 (void)__atomic_xor_fetch(p, val, memory_order_acq_rel);
509 (void)__atomic_xor_fetch(p, val, memory_order_seq_cst);
510
511 (void)__atomic_nand_fetch(p, val, memory_order_relaxed);
512 (void)__atomic_nand_fetch(p, val, memory_order_acquire);
513 (void)__atomic_nand_fetch(p, val, memory_order_consume);
514 (void)__atomic_nand_fetch(p, val, memory_order_release);
515 (void)__atomic_nand_fetch(p, val, memory_order_acq_rel);
516 (void)__atomic_nand_fetch(p, val, memory_order_seq_cst);
517
518 (void)__atomic_max_fetch(p, val, memory_order_relaxed);
519 (void)__atomic_max_fetch(p, val, memory_order_acquire);
520 (void)__atomic_max_fetch(p, val, memory_order_consume);
521 (void)__atomic_max_fetch(p, val, memory_order_release);
522 (void)__atomic_max_fetch(p, val, memory_order_acq_rel);
523 (void)__atomic_max_fetch(p, val, memory_order_seq_cst);
524
525 (void)__atomic_min_fetch(p, val, memory_order_relaxed);
526 (void)__atomic_min_fetch(p, val, memory_order_acquire);
527 (void)__atomic_min_fetch(p, val, memory_order_consume);
528 (void)__atomic_min_fetch(p, val, memory_order_release);
529 (void)__atomic_min_fetch(p, val, memory_order_acq_rel);
530 (void)__atomic_min_fetch(p, val, memory_order_seq_cst);
531
532 (void)__atomic_exchange_n(p, val, memory_order_relaxed);
533 (void)__atomic_exchange_n(p, val, memory_order_acquire);
534 (void)__atomic_exchange_n(p, val, memory_order_consume);
535 (void)__atomic_exchange_n(p, val, memory_order_release);
536 (void)__atomic_exchange_n(p, val, memory_order_acq_rel);
537 (void)__atomic_exchange_n(p, val, memory_order_seq_cst);
538
539 (void)__atomic_exchange(p, p, p, memory_order_relaxed);
540 (void)__atomic_exchange(p, p, p, memory_order_acquire);
541 (void)__atomic_exchange(p, p, p, memory_order_consume);
542 (void)__atomic_exchange(p, p, p, memory_order_release);
543 (void)__atomic_exchange(p, p, p, memory_order_acq_rel);
544 (void)__atomic_exchange(p, p, p, memory_order_seq_cst);
545
546 (void)__atomic_compare_exchange(p, p, p, 0, memory_order_relaxed, memory_order_relaxed);
547 (void)__atomic_compare_exchange(p, p, p, 0, memory_order_acquire, memory_order_relaxed);
548 (void)__atomic_compare_exchange(p, p, p, 0, memory_order_consume, memory_order_relaxed);
549 (void)__atomic_compare_exchange(p, p, p, 0, memory_order_release, memory_order_relaxed);
550 (void)__atomic_compare_exchange(p, p, p, 0, memory_order_acq_rel, memory_order_relaxed);
551 (void)__atomic_compare_exchange(p, p, p, 0, memory_order_seq_cst, memory_order_relaxed);
552
553 (void)__atomic_compare_exchange_n(p, p, val, 0, memory_order_relaxed, memory_order_relaxed);
554 (void)__atomic_compare_exchange_n(p, p, val, 0, memory_order_acquire, memory_order_relaxed);
555 (void)__atomic_compare_exchange_n(p, p, val, 0, memory_order_consume, memory_order_relaxed);
556 (void)__atomic_compare_exchange_n(p, p, val, 0, memory_order_release, memory_order_relaxed);
557 (void)__atomic_compare_exchange_n(p, p, val, 0, memory_order_acq_rel, memory_order_relaxed);
558 (void)__atomic_compare_exchange_n(p, p, val, 0, memory_order_seq_cst, memory_order_relaxed);
559 }
560
nullPointerWarning()561 void nullPointerWarning() {
562 volatile _Atomic(int) vai;
563 _Atomic(int) ai;
564 volatile int vi = 42;
565 int i = 42;
566 volatile _Atomic(int*) vap;
567 _Atomic(int*) ap;
568 volatile int* vp = NULL;
569 int* p = NULL;
570
571 __c11_atomic_init((volatile _Atomic(int)*)0, 42); // expected-warning {{null passed to a callee that requires a non-null argument}}
572 __c11_atomic_init((_Atomic(int)*)0, 42); // expected-warning {{null passed to a callee that requires a non-null argument}}
573 __c11_atomic_store((volatile _Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
574 __c11_atomic_store((_Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
575 (void)__c11_atomic_load((volatile _Atomic(int)*)0, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
576 (void)__c11_atomic_load((_Atomic(int)*)0, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
577 (void)__c11_atomic_exchange((volatile _Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
578 (void)__c11_atomic_exchange((_Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
579 (void)__c11_atomic_compare_exchange_weak((volatile _Atomic(int)*)0, &i, 42, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
580 (void)__c11_atomic_compare_exchange_weak((_Atomic(int)*)0, &i, 42, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
581 (void)__c11_atomic_compare_exchange_weak(&vai, (int*)0, 42, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
582 (void)__c11_atomic_compare_exchange_weak(&ai, (int*)0, 42, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
583 (void)__c11_atomic_compare_exchange_strong((volatile _Atomic(int)*)0, &i, 42, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
584 (void)__c11_atomic_compare_exchange_strong((_Atomic(int)*)0, &i, 42, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
585 (void)__c11_atomic_compare_exchange_strong(&vai, (int*)0, 42, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
586 (void)__c11_atomic_compare_exchange_strong(&ai, (int*)0, 42, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
587 (void)__c11_atomic_fetch_add((volatile _Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
588 (void)__c11_atomic_fetch_add((_Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
589 (void)__c11_atomic_fetch_sub((volatile _Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
590 (void)__c11_atomic_fetch_sub((_Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
591 (void)__c11_atomic_fetch_and((volatile _Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
592 (void)__c11_atomic_fetch_and((_Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
593 (void)__c11_atomic_fetch_or((volatile _Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
594 (void)__c11_atomic_fetch_or((_Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
595 (void)__c11_atomic_fetch_xor((volatile _Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
596 (void)__c11_atomic_fetch_xor((_Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
597
598 __atomic_store_n((volatile int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
599 __atomic_store_n((int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
600 __atomic_store((volatile int*)0, &i, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
601 __atomic_store((int*)0, &i, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
602 __atomic_store(&vi, (int*)0, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
603 __atomic_store(&i, (int*)0, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
604 (void)__atomic_load_n((volatile int*)0, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
605 (void)__atomic_load_n((int*)0, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
606 __atomic_load((volatile int*)0, &i, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
607 __atomic_load((int*)0, &i, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
608 __atomic_load(&vi, (int*)0, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
609 __atomic_load(&i, (int*)0, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
610 (void)__atomic_exchange_n((volatile int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
611 (void)__atomic_exchange_n((int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
612 __atomic_exchange((volatile int*)0, &i, &i, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
613 __atomic_exchange((int*)0, &i, &i, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
614 __atomic_exchange(&vi, (int*)0, &i, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
615 __atomic_exchange(&i, (int*)0, &i, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
616 __atomic_exchange(&vi, &i, (int*)0, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
617 __atomic_exchange(&i, &i, (int*)0, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
618 (void)__atomic_compare_exchange_n((volatile int*)0, &i, 42, /*weak=*/0, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
619 (void)__atomic_compare_exchange_n((int*)0, &i, 42, /*weak=*/0, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
620 (void)__atomic_compare_exchange_n(&vi, (int*)0, 42, /*weak=*/0, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
621 (void)__atomic_compare_exchange_n(&i, (int*)0, 42, /*weak=*/0, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
622 (void)__atomic_compare_exchange((volatile int*)0, &i, &i, /*weak=*/0, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
623 (void)__atomic_compare_exchange((int*)0, &i, &i, /*weak=*/0, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
624 (void)__atomic_compare_exchange(&vi, (int*)0, &i, /*weak=*/0, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
625 (void)__atomic_compare_exchange(&i, (int*)0, &i, /*weak=*/0, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
626 (void)__atomic_compare_exchange(&vi, &i, (int*)0, /*weak=*/0, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
627 (void)__atomic_compare_exchange(&i, &i, (int*)0, /*weak=*/0, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
628 (void)__atomic_fetch_add((volatile int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
629 (void)__atomic_fetch_add((int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
630 (void)__atomic_fetch_sub((volatile int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
631 (void)__atomic_fetch_sub((int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
632 (void)__atomic_fetch_and((volatile int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
633 (void)__atomic_fetch_and((int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
634 (void)__atomic_fetch_or((volatile int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
635 (void)__atomic_fetch_or((int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
636 (void)__atomic_fetch_xor((volatile int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
637 (void)__atomic_fetch_xor((int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
638 (void)__atomic_fetch_min((volatile int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
639 (void)__atomic_fetch_min((int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
640 (void)__atomic_fetch_max((volatile int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
641 (void)__atomic_fetch_max((int*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
642
643 // These don't warn: the "desired" parameter is passed by value. Even for
644 // atomic pointers the "desired" result can be NULL.
645 __c11_atomic_init(&vai, 0);
646 __c11_atomic_init(&ai, 0);
647 __c11_atomic_init(&vap, NULL);
648 __c11_atomic_init(&ap, NULL);
649 __c11_atomic_store(&vai, 0, memory_order_relaxed);
650 __c11_atomic_store(&ai, 0, memory_order_relaxed);
651 __c11_atomic_store(&vap, NULL, memory_order_relaxed);
652 __c11_atomic_store(&ap, NULL, memory_order_relaxed);
653 (void)__c11_atomic_exchange(&vai, 0, memory_order_relaxed);
654 (void)__c11_atomic_exchange(&ai, 0, memory_order_relaxed);
655 (void)__c11_atomic_exchange(&vap, NULL, memory_order_relaxed);
656 (void)__c11_atomic_exchange(&ap, NULL, memory_order_relaxed);
657 (void)__c11_atomic_compare_exchange_weak(&vai, &i, 0, memory_order_relaxed, memory_order_relaxed);
658 (void)__c11_atomic_compare_exchange_weak(&ai, &i, 0, memory_order_relaxed, memory_order_relaxed);
659 (void)__c11_atomic_compare_exchange_weak(&vap, &p, NULL, memory_order_relaxed, memory_order_relaxed);
660 (void)__c11_atomic_compare_exchange_weak(&ap, &p, NULL, memory_order_relaxed, memory_order_relaxed);
661 (void)__c11_atomic_compare_exchange_strong(&vai, &i, 0, memory_order_relaxed, memory_order_relaxed);
662 (void)__c11_atomic_compare_exchange_strong(&ai, &i, 0, memory_order_relaxed, memory_order_relaxed);
663 (void)__c11_atomic_compare_exchange_strong(&vap, &p, NULL, memory_order_relaxed, memory_order_relaxed);
664 (void)__c11_atomic_compare_exchange_strong(&ap, &p, NULL, memory_order_relaxed, memory_order_relaxed);
665 (void)__c11_atomic_fetch_add(&vai, 0, memory_order_relaxed);
666 (void)__c11_atomic_fetch_add(&ai, 0, memory_order_relaxed);
667 (void)__c11_atomic_fetch_sub(&vai, 0, memory_order_relaxed);
668 (void)__c11_atomic_fetch_sub(&ai, 0, memory_order_relaxed);
669 (void)__c11_atomic_fetch_and(&vai, 0, memory_order_relaxed);
670 (void)__c11_atomic_fetch_and(&ai, 0, memory_order_relaxed);
671 (void)__c11_atomic_fetch_or(&vai, 0, memory_order_relaxed);
672 (void)__c11_atomic_fetch_or(&ai, 0, memory_order_relaxed);
673 (void)__c11_atomic_fetch_xor(&vai, 0, memory_order_relaxed);
674 (void)__c11_atomic_fetch_xor(&ai, 0, memory_order_relaxed);
675
676 // Ditto.
677 __atomic_store_n(&vi, 0, memory_order_relaxed);
678 __atomic_store_n(&i, 0, memory_order_relaxed);
679 __atomic_store_n(&vp, NULL, memory_order_relaxed);
680 __atomic_store_n(&p, NULL, memory_order_relaxed);
681 (void)__atomic_exchange_n(&vi, 0, memory_order_relaxed);
682 (void)__atomic_exchange_n(&i, 0, memory_order_relaxed);
683 (void)__atomic_exchange_n(&vp, NULL, memory_order_relaxed);
684 (void)__atomic_exchange_n(&p, NULL, memory_order_relaxed);
685 (void)__atomic_compare_exchange_n(&vi, &i, 0, /*weak=*/0, memory_order_relaxed, memory_order_relaxed);
686 (void)__atomic_compare_exchange_n(&i, &i, 0, /*weak=*/0, memory_order_relaxed, memory_order_relaxed);
687 (void)__atomic_compare_exchange_n(&vp, &vp, NULL, /*weak=*/0, memory_order_relaxed, memory_order_relaxed);
688 (void)__atomic_compare_exchange_n(&p, &p, NULL, /*weak=*/0, memory_order_relaxed, memory_order_relaxed);
689 (void)__atomic_fetch_add(&vi, 0, memory_order_relaxed);
690 (void)__atomic_fetch_add(&i, 0, memory_order_relaxed);
691 (void)__atomic_fetch_sub(&vi, 0, memory_order_relaxed);
692 (void)__atomic_fetch_sub(&i, 0, memory_order_relaxed);
693 (void)__atomic_fetch_and(&vi, 0, memory_order_relaxed);
694 (void)__atomic_fetch_and(&i, 0, memory_order_relaxed);
695 (void)__atomic_fetch_or(&vi, 0, memory_order_relaxed);
696 (void)__atomic_fetch_or(&i, 0, memory_order_relaxed);
697 (void)__atomic_fetch_xor(&vi, 0, memory_order_relaxed);
698 (void)__atomic_fetch_xor(&i, 0, memory_order_relaxed);
699 (void)__atomic_fetch_min(&vi, 0, memory_order_relaxed);
700 (void)__atomic_fetch_min(&i, 0, memory_order_relaxed);
701 (void)__atomic_fetch_max(&vi, 0, memory_order_relaxed);
702 (void)__atomic_fetch_max(&i, 0, memory_order_relaxed);
703 }
704