1 /* { dg-do compile } */
2
3 #define seq_cst __ATOMIC_SEQ_CST
4
5 extern int *i;
6 extern int *j;
7 extern const int *c;
8 extern volatile int *v;
9 extern const volatile int *cv;
10
11 void
12 load()
13 {
14 __atomic_load(c, i, seq_cst);
15 __atomic_load(cv, i, seq_cst);
16
17 __atomic_load(i, c, seq_cst);
18 /* { dg-error "argument 2 of '__atomic_load' must not be a pointer to a 'const' type" "" { target c++ } .-1 } */
19 /* { dg-warning "argument 2 of '__atomic_load' discards 'const' qualifier" "" { target c } .-2 } */
20 __atomic_load(i, v, seq_cst);
21 /* { dg-error "argument 2 of '__atomic_load' must not be a pointer to a 'volatile' type" "" { target c++ } .-1 } */
22 /* { dg-warning "argument 2 of '__atomic_load' discards 'volatile' qualifier" "" { target c } .-2 } */
23 __atomic_load(i, cv, seq_cst);
24 /* { dg-error "argument 2 of '__atomic_load' must not be a pointer to a 'const' type" "" { target c++ } .-1 } */
25 /* { dg-warning "argument 2 of '__atomic_load' discards 'const' qualifier" "" { target c } .-2 } */
26 /* { dg-warning "argument 2 of '__atomic_load' discards 'volatile' qualifier" "" { target c } .-3 } */
27 }
28
29 void
30 store()
31 {
32 __atomic_store(i, c, seq_cst);
33 __atomic_store(v, c, seq_cst);
34
35 __atomic_store(c, i, seq_cst);
36 /* { dg-error "argument 1 of '__atomic_store' must not be a pointer to a 'const' type" "" { target c++ } .-1 } */
37 /* { dg-warning "argument 1 of '__atomic_store' discards 'const' qualifier" "" { target c } .-2 } */
38 __atomic_store(cv, i, seq_cst);
39 /* { dg-error "argument 1 of '__atomic_store' must not be a pointer to a 'const' type" "" { target c++ } .-1 } */
40 /* { dg-warning "argument 1 of '__atomic_store' discards 'const' qualifier" "" { target c } .-2 } */
41
42 __atomic_store(i, v, seq_cst);
43 /* { dg-error "argument 2 of '__atomic_store' must not be a pointer to a 'volatile' type" "" { target c++ } .-1 } */
44 /* { dg-warning "argument 2 of '__atomic_store' discards 'volatile' qualifier" "" { target c } .-2 } */
45 }
46
47 void
48 exchange()
49 {
50 __atomic_exchange(i, c, j, seq_cst);
51 __atomic_exchange(v, i, j, seq_cst);
52 __atomic_exchange(v, c, j, seq_cst);
53
54 __atomic_exchange(c, i, j, seq_cst);
55 /* { dg-error "argument 1 of '__atomic_exchange' must not be a pointer to a 'const' type" "" { target c++ } .-1 } */
56 /* { dg-warning "argument 1 of '__atomic_exchange' discards 'const' qualifier" "" { target c } .-2 } */
57 __atomic_exchange(cv, i, j, seq_cst);
58 /* { dg-error "argument 1 of '__atomic_exchange' must not be a pointer to a 'const' type" "" { target c++ } .-1 } */
59 /* { dg-warning "argument 1 of '__atomic_exchange' discards 'const' qualifier" "" { target c } .-2 } */
60
61 __atomic_exchange(i, v, j, seq_cst);
62 /* { dg-error "argument 2 of '__atomic_exchange' must not be a pointer to a 'volatile' type" "" { target c++ } .-1 } */
63 /* { dg-warning "argument 2 of '__atomic_exchange' discards 'volatile' qualifier" "" { target c } .-2 } */
64 __atomic_exchange(i, cv, j, seq_cst);
65 /* { dg-error "argument 2 of '__atomic_exchange' must not be a pointer to a 'volatile' type" "" { target c++ } .-1 } */
66 /* { dg-warning "argument 2 of '__atomic_exchange' discards 'volatile' qualifier" "" { target c } .-2 } */
67
68 __atomic_exchange(i, j, c, seq_cst);
69 /* { dg-error "argument 3 of '__atomic_exchange' must not be a pointer to a 'const' type" "" { target c++ } .-1 } */
70 /* { dg-warning "argument 3 of '__atomic_exchange' discards 'const' qualifier" "" { target c } .-2 } */
71 __atomic_exchange(i, j, v, seq_cst);
72 /* { dg-error "argument 3 of '__atomic_exchange' must not be a pointer to a 'volatile' type" "" { target c++ } .-1 } */
73 /* { dg-warning "argument 3 of '__atomic_exchange' discards 'volatile' qualifier" "" { target c } .-2 } */
74 __atomic_exchange(i, j, cv, seq_cst);
75 /* { dg-error "argument 3 of '__atomic_exchange' must not be a pointer to a 'const' type" "" { target c++ } .-1 } */
76 /* { dg-warning "argument 3 of '__atomic_exchange' discards 'const' qualifier" "" { target c } .-2 } */
77 /* { dg-warning "argument 3 of '__atomic_exchange' discards 'volatile' qualifier" "" { target c } .-3 } */
78 }
79
80 void
81 compare_exchange()
82 {
83 __atomic_compare_exchange(i, j, c, 1, seq_cst, seq_cst);
84 __atomic_compare_exchange(v, i, j, 1, seq_cst, seq_cst);
85 __atomic_compare_exchange(v, i, c, 1, seq_cst, seq_cst);
86
87 __atomic_compare_exchange(c, i, j, 1, seq_cst, seq_cst);
88 /* { dg-error "argument 1 of '__atomic_compare_exchange' must not be a pointer to a 'const' type" "" { target c++ } .-1 } */
89 /* { dg-warning "argument 1 of '__atomic_compare_exchange' discards 'const' qualifier" "" { target c } .-2 } */
90 __atomic_compare_exchange(cv, i, j, 1, seq_cst, seq_cst);
91 /* { dg-error "argument 1 of '__atomic_compare_exchange' must not be a pointer to a 'const' type" "" { target c++ } .-1 } */
92 /* { dg-warning "argument 1 of '__atomic_compare_exchange' discards 'const' qualifier" "" { target c } .-2 } */
93
94 __atomic_compare_exchange(i, c, j, 1, seq_cst, seq_cst);
95 /* { dg-error "argument 2 of '__atomic_compare_exchange' must not be a pointer to a 'const' type" "" { target c++ } .-1 } */
96 /* { dg-warning "argument 2 of '__atomic_compare_exchange' discards 'const' qualifier" "" { target c } .-2 } */
97 __atomic_compare_exchange(i, v, j, 1, seq_cst, seq_cst);
98 /* { dg-error "argument 2 of '__atomic_compare_exchange' must not be a pointer to a 'volatile' type" "" { target c++ } .-1 } */
99 /* { dg-warning "argument 2 of '__atomic_compare_exchange' discards 'volatile' qualifier" "" { target c } .-2 } */
100 __atomic_compare_exchange(i, cv, j, 1, seq_cst, seq_cst);
101 /* { dg-error "argument 2 of '__atomic_compare_exchange' must not be a pointer to a 'const' type" "" { target c++ } .-1 } */
102 /* { dg-warning "argument 2 of '__atomic_compare_exchange' discards 'const" "" { target c } .-2 } */
103 /* { dg-warning "argument 2 of '__atomic_compare_exchange' discards 'volatile' qualifier" "" { target c } .-3 } */
104
105 __atomic_compare_exchange(i, j, v, 1, seq_cst, seq_cst);
106 /* { dg-error "argument 3 of '__atomic_compare_exchange' must not be a pointer to a 'volatile' type" "" { target c++ } .-1 } */
107 /* { dg-warning "argument 3 of '__atomic_compare_exchange' discards 'volatile' qualifier" "" { target c } .-2 } */
108 __atomic_compare_exchange(i, j, cv, 1, seq_cst, seq_cst);
109 /* { dg-error "argument 3 of '__atomic_compare_exchange' must not be a pointer to a 'volatile' type" "" { target c++ } .-1 } */
110 /* { dg-warning "argument 3 of '__atomic_compare_exchange' discards 'volatile' qualifier" "" { target c } .-2 } */
111 }