Daily bump.
[official-gcc.git] / gcc / testsuite / gcc.dg / c11-atomic-2.c
blob34ee081d421e85f6e9fdfbc7030a5d91f5a3e85d
1 /* Test for _Atomic in C11. Test of valid assignment cases for
2 arithmetic types. */
3 /* { dg-do compile } */
4 /* { dg-options "-std=c11 -pedantic-errors" } */
6 #define TEST_ASSIGN(TYPE1, OP, TYPE2) \
7 do \
8 { \
9 _Atomic TYPE1 a = 0; \
10 TYPE2 b = 0; \
11 _Atomic TYPE2 c = 0; \
12 a OP b; \
13 a OP c; \
14 } \
15 while (0)
17 #define TEST_ASSIGN_ARITHR(TYPE1, OP) \
18 do \
19 { \
20 TEST_ASSIGN (TYPE1, OP, _Bool); \
21 TEST_ASSIGN (TYPE1, OP, char); \
22 TEST_ASSIGN (TYPE1, OP, signed char); \
23 TEST_ASSIGN (TYPE1, OP, unsigned char); \
24 TEST_ASSIGN (TYPE1, OP, signed short); \
25 TEST_ASSIGN (TYPE1, OP, unsigned short); \
26 TEST_ASSIGN (TYPE1, OP, signed int); \
27 TEST_ASSIGN (TYPE1, OP, unsigned int); \
28 TEST_ASSIGN (TYPE1, OP, signed long); \
29 TEST_ASSIGN (TYPE1, OP, unsigned long); \
30 TEST_ASSIGN (TYPE1, OP, signed long long); \
31 TEST_ASSIGN (TYPE1, OP, unsigned long long); \
32 TEST_ASSIGN (TYPE1, OP, float); \
33 TEST_ASSIGN (TYPE1, OP, double); \
34 TEST_ASSIGN (TYPE1, OP, long double); \
35 TEST_ASSIGN (TYPE1, OP, _Complex float); \
36 TEST_ASSIGN (TYPE1, OP, _Complex double); \
37 TEST_ASSIGN (TYPE1, OP, _Complex long double); \
38 } \
39 while (0)
41 #define TEST_ASSIGN_ARITHBOTH(OP) \
42 do \
43 { \
44 TEST_ASSIGN_ARITHR (_Bool, OP); \
45 TEST_ASSIGN_ARITHR (char, OP); \
46 TEST_ASSIGN_ARITHR (signed char, OP); \
47 TEST_ASSIGN_ARITHR (unsigned char, OP); \
48 TEST_ASSIGN_ARITHR (signed short, OP); \
49 TEST_ASSIGN_ARITHR (unsigned short, OP); \
50 TEST_ASSIGN_ARITHR (signed int, OP); \
51 TEST_ASSIGN_ARITHR (unsigned int, OP); \
52 TEST_ASSIGN_ARITHR (signed long, OP); \
53 TEST_ASSIGN_ARITHR (unsigned long, OP); \
54 TEST_ASSIGN_ARITHR (signed long long, OP); \
55 TEST_ASSIGN_ARITHR (unsigned long long, OP); \
56 TEST_ASSIGN_ARITHR (float, OP); \
57 TEST_ASSIGN_ARITHR (double, OP); \
58 TEST_ASSIGN_ARITHR (long double, OP); \
59 TEST_ASSIGN_ARITHR (_Complex float, OP); \
60 TEST_ASSIGN_ARITHR (_Complex double, OP); \
61 TEST_ASSIGN_ARITHR (_Complex long double, OP); \
62 } \
63 while (0)
65 #define TEST_ASSIGN_INTR(TYPE1, OP) \
66 do \
67 { \
68 TEST_ASSIGN (TYPE1, OP, _Bool); \
69 TEST_ASSIGN (TYPE1, OP, char); \
70 TEST_ASSIGN (TYPE1, OP, signed char); \
71 TEST_ASSIGN (TYPE1, OP, unsigned char); \
72 TEST_ASSIGN (TYPE1, OP, signed short); \
73 TEST_ASSIGN (TYPE1, OP, unsigned short); \
74 TEST_ASSIGN (TYPE1, OP, signed int); \
75 TEST_ASSIGN (TYPE1, OP, unsigned int); \
76 TEST_ASSIGN (TYPE1, OP, signed long); \
77 TEST_ASSIGN (TYPE1, OP, unsigned long); \
78 TEST_ASSIGN (TYPE1, OP, signed long long); \
79 TEST_ASSIGN (TYPE1, OP, unsigned long long); \
80 } \
81 while (0)
83 #define TEST_ASSIGN_INTBOTH(OP) \
84 do \
85 { \
86 TEST_ASSIGN_INTR (_Bool, OP); \
87 TEST_ASSIGN_INTR (char, OP); \
88 TEST_ASSIGN_INTR (signed char, OP); \
89 TEST_ASSIGN_INTR (unsigned char, OP); \
90 TEST_ASSIGN_INTR (signed short, OP); \
91 TEST_ASSIGN_INTR (unsigned short, OP); \
92 TEST_ASSIGN_INTR (signed int, OP); \
93 TEST_ASSIGN_INTR (unsigned int, OP); \
94 TEST_ASSIGN_INTR (signed long, OP); \
95 TEST_ASSIGN_INTR (unsigned long, OP); \
96 TEST_ASSIGN_INTR (signed long long, OP); \
97 TEST_ASSIGN_INTR (unsigned long long, OP); \
98 } \
99 while (0)
101 void
102 test_simple (void)
104 TEST_ASSIGN_ARITHBOTH (=);
107 void
108 test_mult (void)
110 TEST_ASSIGN_ARITHBOTH (*=);
113 void
114 test_div (void)
116 TEST_ASSIGN_ARITHBOTH (/=);
119 void
120 test_mod (void)
122 TEST_ASSIGN_INTBOTH (%=);
125 void
126 test_plus (void)
128 TEST_ASSIGN_ARITHBOTH (+=);
131 void
132 test_minus (void)
134 TEST_ASSIGN_ARITHBOTH (-=);
137 void
138 test_lshift (void)
140 TEST_ASSIGN_INTBOTH (<<=);
143 void
144 test_rshift (void)
146 TEST_ASSIGN_INTBOTH (>>=);
149 void
150 test_and (void)
152 TEST_ASSIGN_INTBOTH (&=);
155 void
156 test_xor (void)
158 TEST_ASSIGN_INTBOTH (^=);
161 void
162 test_or (void)
164 TEST_ASSIGN_INTBOTH (|=);