xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGen/arm-aapcs-zerolength-bitfield.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // REQUIRES: arm-registered-target
2*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -target-abi aapcs -triple armv7-apple-darwin10 %s -verify
3*f4a2713aSLionel Sambuc // expected-no-diagnostics
4*f4a2713aSLionel Sambuc 
5*f4a2713aSLionel Sambuc #include <stddef.h>
6*f4a2713aSLionel Sambuc 
7*f4a2713aSLionel Sambuc struct t1
8*f4a2713aSLionel Sambuc {
9*f4a2713aSLionel Sambuc   int foo : 1;
10*f4a2713aSLionel Sambuc   char : 0;
11*f4a2713aSLionel Sambuc   char bar;
12*f4a2713aSLionel Sambuc };
13*f4a2713aSLionel Sambuc static int arr1_offset[(offsetof(struct t1, bar) == 1) ? 0 : -1];
14*f4a2713aSLionel Sambuc static int arr1_sizeof[(sizeof(struct t1) == 4) ? 0 : -1];
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc struct t2
17*f4a2713aSLionel Sambuc {
18*f4a2713aSLionel Sambuc   int foo : 1;
19*f4a2713aSLionel Sambuc   short : 0;
20*f4a2713aSLionel Sambuc   char bar;
21*f4a2713aSLionel Sambuc };
22*f4a2713aSLionel Sambuc static int arr2_offset[(offsetof(struct t2, bar) == 2) ? 0 : -1];
23*f4a2713aSLionel Sambuc static int arr2_sizeof[(sizeof(struct t2) == 4) ? 0 : -1];
24*f4a2713aSLionel Sambuc 
25*f4a2713aSLionel Sambuc struct t3
26*f4a2713aSLionel Sambuc {
27*f4a2713aSLionel Sambuc   int foo : 1;
28*f4a2713aSLionel Sambuc   int : 0;
29*f4a2713aSLionel Sambuc   char bar;
30*f4a2713aSLionel Sambuc };
31*f4a2713aSLionel Sambuc static int arr3_offset[(offsetof(struct t3, bar) == 4) ? 0 : -1];
32*f4a2713aSLionel Sambuc static int arr3_sizeof[(sizeof(struct t3) == 8) ? 0 : -1];
33*f4a2713aSLionel Sambuc 
34*f4a2713aSLionel Sambuc struct t4
35*f4a2713aSLionel Sambuc {
36*f4a2713aSLionel Sambuc   int foo : 1;
37*f4a2713aSLionel Sambuc   long : 0;
38*f4a2713aSLionel Sambuc   char bar;
39*f4a2713aSLionel Sambuc };
40*f4a2713aSLionel Sambuc static int arr4_offset[(offsetof(struct t4, bar) == 4) ? 0 : -1];
41*f4a2713aSLionel Sambuc static int arr4_sizeof[(sizeof(struct t4) == 8) ? 0 : -1];
42*f4a2713aSLionel Sambuc 
43*f4a2713aSLionel Sambuc struct t5
44*f4a2713aSLionel Sambuc {
45*f4a2713aSLionel Sambuc   int foo : 1;
46*f4a2713aSLionel Sambuc   long long : 0;
47*f4a2713aSLionel Sambuc   char bar;
48*f4a2713aSLionel Sambuc };
49*f4a2713aSLionel Sambuc static int arr5_offset[(offsetof(struct t5, bar) == 8) ? 0 : -1];
50*f4a2713aSLionel Sambuc static int arr5_sizeof[(sizeof(struct t5) == 16) ? 0 : -1];
51*f4a2713aSLionel Sambuc 
52*f4a2713aSLionel Sambuc struct t6
53*f4a2713aSLionel Sambuc {
54*f4a2713aSLionel Sambuc   int foo : 1;
55*f4a2713aSLionel Sambuc   char : 0;
56*f4a2713aSLionel Sambuc   char bar : 1;
57*f4a2713aSLionel Sambuc   char bar2;
58*f4a2713aSLionel Sambuc };
59*f4a2713aSLionel Sambuc static int arr6_offset[(offsetof(struct t6, bar2) == 2) ? 0 : -1];
60*f4a2713aSLionel Sambuc static int arr6_sizeof[(sizeof(struct t6) == 4) ? 0 : -1];
61*f4a2713aSLionel Sambuc 
62*f4a2713aSLionel Sambuc struct t7
63*f4a2713aSLionel Sambuc {
64*f4a2713aSLionel Sambuc   int foo : 1;
65*f4a2713aSLionel Sambuc   short : 0;
66*f4a2713aSLionel Sambuc   char bar1 : 1;
67*f4a2713aSLionel Sambuc   char bar2;
68*f4a2713aSLionel Sambuc };
69*f4a2713aSLionel Sambuc static int arr7_offset[(offsetof(struct t7, bar2) == 3) ? 0 : -1];
70*f4a2713aSLionel Sambuc static int arr7_sizeof[(sizeof(struct t7) == 4) ? 0 : -1];
71*f4a2713aSLionel Sambuc 
72*f4a2713aSLionel Sambuc struct t8
73*f4a2713aSLionel Sambuc {
74*f4a2713aSLionel Sambuc   int foo : 1;
75*f4a2713aSLionel Sambuc   int : 0;
76*f4a2713aSLionel Sambuc   char bar1 : 1;
77*f4a2713aSLionel Sambuc   char bar2;
78*f4a2713aSLionel Sambuc };
79*f4a2713aSLionel Sambuc static int arr8_offset[(offsetof(struct t8, bar2) == 5) ? 0 : -1];
80*f4a2713aSLionel Sambuc static int arr8_sizeof[(sizeof(struct t8) == 8) ? 0 : -1];
81*f4a2713aSLionel Sambuc 
82*f4a2713aSLionel Sambuc struct t9
83*f4a2713aSLionel Sambuc {
84*f4a2713aSLionel Sambuc   int foo : 1;
85*f4a2713aSLionel Sambuc   long : 0;
86*f4a2713aSLionel Sambuc   char bar1 : 1;
87*f4a2713aSLionel Sambuc   char bar2;
88*f4a2713aSLionel Sambuc };
89*f4a2713aSLionel Sambuc static int arr9_offset[(offsetof(struct t9, bar2) == 5) ? 0 : -1];
90*f4a2713aSLionel Sambuc static int arr9_sizeof[(sizeof(struct t9) == 8) ? 0 : -1];
91*f4a2713aSLionel Sambuc 
92*f4a2713aSLionel Sambuc struct t10
93*f4a2713aSLionel Sambuc {
94*f4a2713aSLionel Sambuc   int foo : 1;
95*f4a2713aSLionel Sambuc   long long : 0;
96*f4a2713aSLionel Sambuc   char bar1 : 1;
97*f4a2713aSLionel Sambuc   char bar2;
98*f4a2713aSLionel Sambuc };
99*f4a2713aSLionel Sambuc static int arr10_offset[(offsetof(struct t10, bar2) == 9) ? 0 : -1];
100*f4a2713aSLionel Sambuc static int arr10_sizeof[(sizeof(struct t10) == 16) ? 0 : -1];
101*f4a2713aSLionel Sambuc 
102*f4a2713aSLionel Sambuc struct t11
103*f4a2713aSLionel Sambuc {
104*f4a2713aSLionel Sambuc   int foo : 1;
105*f4a2713aSLionel Sambuc   long long : 0;
106*f4a2713aSLionel Sambuc   char : 0;
107*f4a2713aSLionel Sambuc   char bar1 : 1;
108*f4a2713aSLionel Sambuc   char bar2;
109*f4a2713aSLionel Sambuc };
110*f4a2713aSLionel Sambuc static int arr11_offset[(offsetof(struct t11, bar2) == 9) ? 0 : -1];
111*f4a2713aSLionel Sambuc static int arr11_sizeof[(sizeof(struct t11) == 16) ? 0 : -1];
112*f4a2713aSLionel Sambuc 
113*f4a2713aSLionel Sambuc struct t12
114*f4a2713aSLionel Sambuc {
115*f4a2713aSLionel Sambuc   int foo : 1;
116*f4a2713aSLionel Sambuc   char : 0;
117*f4a2713aSLionel Sambuc   long long : 0;
118*f4a2713aSLionel Sambuc   char : 0;
119*f4a2713aSLionel Sambuc   char bar;
120*f4a2713aSLionel Sambuc };
121*f4a2713aSLionel Sambuc static int arr12_offset[(offsetof(struct t12, bar) == 8) ? 0 : -1];
122*f4a2713aSLionel Sambuc static int arr12_sizeof[(sizeof(struct t12) == 16) ? 0 : -1];
123*f4a2713aSLionel Sambuc 
124*f4a2713aSLionel Sambuc struct t13
125*f4a2713aSLionel Sambuc {
126*f4a2713aSLionel Sambuc   char foo;
127*f4a2713aSLionel Sambuc   long : 0;
128*f4a2713aSLionel Sambuc   char bar;
129*f4a2713aSLionel Sambuc };
130*f4a2713aSLionel Sambuc static int arr13_offset[(offsetof(struct t13, bar) == 4) ? 0 : -1];
131*f4a2713aSLionel Sambuc static int arr13_sizeof[(sizeof(struct t13) == 8) ? 0 : -1];
132*f4a2713aSLionel Sambuc 
133*f4a2713aSLionel Sambuc struct t14
134*f4a2713aSLionel Sambuc {
135*f4a2713aSLionel Sambuc   char foo1;
136*f4a2713aSLionel Sambuc   int : 0;
137*f4a2713aSLionel Sambuc   char foo2 : 1;
138*f4a2713aSLionel Sambuc   short foo3 : 16;
139*f4a2713aSLionel Sambuc   char : 0;
140*f4a2713aSLionel Sambuc   short foo4 : 16;
141*f4a2713aSLionel Sambuc   char bar1;
142*f4a2713aSLionel Sambuc   int : 0;
143*f4a2713aSLionel Sambuc   char bar2;
144*f4a2713aSLionel Sambuc };
145*f4a2713aSLionel Sambuc static int arr14_bar1_offset[(offsetof(struct t14, bar1) == 10) ? 0 : -1];
146*f4a2713aSLionel Sambuc static int arr14_bar2_offset[(offsetof(struct t14, bar2) == 12) ? 0 : -1];
147*f4a2713aSLionel Sambuc static int arr14_sizeof[(sizeof(struct t14) == 16) ? 0 : -1];
148*f4a2713aSLionel Sambuc 
149*f4a2713aSLionel Sambuc struct t15
150*f4a2713aSLionel Sambuc {
151*f4a2713aSLionel Sambuc   char foo;
152*f4a2713aSLionel Sambuc   char : 0;
153*f4a2713aSLionel Sambuc   int : 0;
154*f4a2713aSLionel Sambuc   char bar;
155*f4a2713aSLionel Sambuc   long : 0;
156*f4a2713aSLionel Sambuc   char : 0;
157*f4a2713aSLionel Sambuc };
158*f4a2713aSLionel Sambuc static int arr15_offset[(offsetof(struct t15, bar) == 4) ? 0 : -1];
159*f4a2713aSLionel Sambuc static int arr15_sizeof[(sizeof(struct t15) == 8) ? 0 : -1];
160*f4a2713aSLionel Sambuc 
161*f4a2713aSLionel Sambuc struct t16
162*f4a2713aSLionel Sambuc {
163*f4a2713aSLionel Sambuc   long : 0;
164*f4a2713aSLionel Sambuc   char bar;
165*f4a2713aSLionel Sambuc };
166*f4a2713aSLionel Sambuc static int arr16_offset[(offsetof(struct t16, bar) == 0) ? 0 : -1];
167*f4a2713aSLionel Sambuc static int arr16_sizeof[(sizeof(struct t16) == 4) ? 0 : -1];
168*f4a2713aSLionel Sambuc 
169*f4a2713aSLionel Sambuc struct t17
170*f4a2713aSLionel Sambuc {
171*f4a2713aSLionel Sambuc   char foo;
172*f4a2713aSLionel Sambuc   long : 0;
173*f4a2713aSLionel Sambuc   long : 0;
174*f4a2713aSLionel Sambuc   char : 0;
175*f4a2713aSLionel Sambuc   char bar;
176*f4a2713aSLionel Sambuc };
177*f4a2713aSLionel Sambuc static int arr17_offset[(offsetof(struct t17, bar) == 4) ? 0 : -1];
178*f4a2713aSLionel Sambuc static int arr17_sizeof[(sizeof(struct t17) == 8) ? 0 : -1];
179*f4a2713aSLionel Sambuc 
180*f4a2713aSLionel Sambuc struct t18
181*f4a2713aSLionel Sambuc {
182*f4a2713aSLionel Sambuc   long : 0;
183*f4a2713aSLionel Sambuc   long : 0;
184*f4a2713aSLionel Sambuc   char : 0;
185*f4a2713aSLionel Sambuc };
186*f4a2713aSLionel Sambuc static int arr18_sizeof[(sizeof(struct t18) == 0) ? 0 : -1];
187*f4a2713aSLionel Sambuc 
188*f4a2713aSLionel Sambuc struct t19
189*f4a2713aSLionel Sambuc {
190*f4a2713aSLionel Sambuc   char foo1;
191*f4a2713aSLionel Sambuc   long foo2 : 1;
192*f4a2713aSLionel Sambuc   char : 0;
193*f4a2713aSLionel Sambuc   long foo3 : 32;
194*f4a2713aSLionel Sambuc   char bar;
195*f4a2713aSLionel Sambuc };
196*f4a2713aSLionel Sambuc static int arr19_offset[(offsetof(struct t19, bar) == 8) ? 0 : -1];
197*f4a2713aSLionel Sambuc static int arr19_sizeof[(sizeof(struct t19) == 12) ? 0 : -1];
198*f4a2713aSLionel Sambuc 
199*f4a2713aSLionel Sambuc struct t20
200*f4a2713aSLionel Sambuc {
201*f4a2713aSLionel Sambuc   short : 0;
202*f4a2713aSLionel Sambuc   int foo : 1;
203*f4a2713aSLionel Sambuc   long : 0;
204*f4a2713aSLionel Sambuc   char bar;
205*f4a2713aSLionel Sambuc };
206*f4a2713aSLionel Sambuc static int arr20_offset[(offsetof(struct t20, bar) == 4) ? 0 : -1];
207*f4a2713aSLionel Sambuc static int arr20_sizeof[(sizeof(struct t20) == 8) ? 0 : -1];
208*f4a2713aSLionel Sambuc 
209*f4a2713aSLionel Sambuc struct t21
210*f4a2713aSLionel Sambuc {
211*f4a2713aSLionel Sambuc   short : 0;
212*f4a2713aSLionel Sambuc   int foo1 : 1;
213*f4a2713aSLionel Sambuc   char : 0;
214*f4a2713aSLionel Sambuc   int foo2 : 16;
215*f4a2713aSLionel Sambuc   long : 0;
216*f4a2713aSLionel Sambuc   char bar1;
217*f4a2713aSLionel Sambuc   int bar2;
218*f4a2713aSLionel Sambuc   long bar3;
219*f4a2713aSLionel Sambuc   char foo3 : 8;
220*f4a2713aSLionel Sambuc   char : 0;
221*f4a2713aSLionel Sambuc   long : 0;
222*f4a2713aSLionel Sambuc   int foo4 : 32;
223*f4a2713aSLionel Sambuc   short foo5: 1;
224*f4a2713aSLionel Sambuc   long bar4;
225*f4a2713aSLionel Sambuc   short foo6: 16;
226*f4a2713aSLionel Sambuc   short foo7: 16;
227*f4a2713aSLionel Sambuc   short foo8: 16;
228*f4a2713aSLionel Sambuc };
229*f4a2713aSLionel Sambuc static int arr21_bar1_offset[(offsetof(struct t21, bar1) == 4) ? 0 : -1];
230*f4a2713aSLionel Sambuc static int arr21_bar2_offset[(offsetof(struct t21, bar2) == 8) ? 0 : -1];
231*f4a2713aSLionel Sambuc static int arr21_bar3_offset[(offsetof(struct t21, bar3) == 12) ? 0 : -1];
232*f4a2713aSLionel Sambuc static int arr21_bar4_offset[(offsetof(struct t21, bar4) == 28) ? 0 : -1];
233*f4a2713aSLionel Sambuc static int arr21_sizeof[(sizeof(struct t21) == 40) ? 0 : -1];
234*f4a2713aSLionel Sambuc 
main()235*f4a2713aSLionel Sambuc int main() {
236*f4a2713aSLionel Sambuc   return 0;
237*f4a2713aSLionel Sambuc }
238*f4a2713aSLionel Sambuc 
239