blob: 049ffae4dc6f00a71933d1feb2f3d38754542fdb [file] [log] [blame]
Jim Grosbachf7947052012-07-09 18:34:21 +00001// REQUIRES: arm-registered-target
Chad Rosier4ab00242011-08-04 00:19:13 +00002// RUN: %clang_cc1 -target-abi apcs-gnu -triple armv7-apple-darwin10 %s -verify
Chad Rosier61a62212011-08-04 01:21:14 +00003//
4// Note: gcc forces the alignment to 4 bytes, regardless of the type of the
5// zero length bitfield.
6// rdar://9859156
Chad Rosier4ab00242011-08-04 00:19:13 +00007
8#include <stddef.h>
9
10struct t1
11{
12 int foo : 1;
13 char : 0;
14 char bar;
15};
Chad Rosier61a62212011-08-04 01:21:14 +000016static int arr1_offset[(offsetof(struct t1, bar) == 4) ? 0 : -1];
17static int arr1_sizeof[(sizeof(struct t1) == 8) ? 0 : -1];
Chad Rosier4ab00242011-08-04 00:19:13 +000018
19struct t2
20{
21 int foo : 1;
22 short : 0;
23 char bar;
24};
Chad Rosier61a62212011-08-04 01:21:14 +000025static int arr2_offset[(offsetof(struct t2, bar) == 4) ? 0 : -1];
26static int arr2_sizeof[(sizeof(struct t2) == 8) ? 0 : -1];
Chad Rosier4ab00242011-08-04 00:19:13 +000027
28struct t3
29{
30 int foo : 1;
31 int : 0;
32 char bar;
33};
Chad Rosier61a62212011-08-04 01:21:14 +000034static int arr3_offset[(offsetof(struct t3, bar) == 4) ? 0 : -1];
35static int arr3_sizeof[(sizeof(struct t3) == 8) ? 0 : -1];
Chad Rosier4ab00242011-08-04 00:19:13 +000036
37struct t4
38{
39 int foo : 1;
40 long : 0;
41 char bar;
42};
Chad Rosier61a62212011-08-04 01:21:14 +000043static int arr4_offset[(offsetof(struct t4, bar) == 4) ? 0 : -1];
44static int arr4_sizeof[(sizeof(struct t4) == 8) ? 0 : -1];
Chad Rosier4ab00242011-08-04 00:19:13 +000045
46struct t5
47{
48 int foo : 1;
49 long long : 0;
50 char bar;
51};
Chad Rosier61a62212011-08-04 01:21:14 +000052static int arr5_offset[(offsetof(struct t5, bar) == 4) ? 0 : -1];
53static int arr5_sizeof[(sizeof(struct t5) == 8) ? 0 : -1];
Chad Rosier4ab00242011-08-04 00:19:13 +000054
55struct t6
56{
57 int foo : 1;
58 char : 0;
59 char bar : 1;
60 char bar2;
61};
Chad Rosierb8fca902011-08-05 22:38:04 +000062static int arr6_offset[(offsetof(struct t6, bar2) == 5) ? 0 : -1];
63static int arr6_sizeof[(sizeof(struct t6) == 8) ? 0 : -1];
Chad Rosier4ab00242011-08-04 00:19:13 +000064
65struct t7
66{
67 int foo : 1;
68 short : 0;
69 char bar1 : 1;
70 char bar2;
71};
Chad Rosierb8fca902011-08-05 22:38:04 +000072static int arr7_offset[(offsetof(struct t7, bar2) == 5) ? 0 : -1];
73static int arr7_sizeof[(sizeof(struct t7) == 8) ? 0 : -1];
Chad Rosier4ab00242011-08-04 00:19:13 +000074
75struct t8
76{
77 int foo : 1;
78 int : 0;
79 char bar1 : 1;
80 char bar2;
81};
Chad Rosierb8fca902011-08-05 22:38:04 +000082static int arr8_offset[(offsetof(struct t8, bar2) == 5) ? 0 : -1];
83static int arr8_sizeof[(sizeof(struct t8) == 8) ? 0 : -1];
Chad Rosier4ab00242011-08-04 00:19:13 +000084
85struct t9
86{
87 int foo : 1;
88 long : 0;
89 char bar1 : 1;
90 char bar2;
91};
Chad Rosierb8fca902011-08-05 22:38:04 +000092static int arr9_offset[(offsetof(struct t9, bar2) == 5) ? 0 : -1];
93static int arr9_sizeof[(sizeof(struct t9) == 8) ? 0 : -1];
Chad Rosier4ab00242011-08-04 00:19:13 +000094
95struct t10
96{
97 int foo : 1;
98 long long : 0;
99 char bar1 : 1;
100 char bar2;
101};
Chad Rosierb8fca902011-08-05 22:38:04 +0000102static int arr10_offset[(offsetof(struct t10, bar2) == 5) ? 0 : -1];
103static int arr10_sizeof[(sizeof(struct t10) == 8) ? 0 : -1];
Chad Rosier4ab00242011-08-04 00:19:13 +0000104
105struct t11
106{
107 int foo : 1;
108 long long : 0;
109 char : 0;
110 char bar1 : 1;
111 char bar2;
112};
Chad Rosierb8fca902011-08-05 22:38:04 +0000113static int arr11_offset[(offsetof(struct t11, bar2) == 5) ? 0 : -1];
114static int arr11_sizeof[(sizeof(struct t11) == 8) ? 0 : -1];
Chad Rosier4ab00242011-08-04 00:19:13 +0000115
Chad Rosier61a62212011-08-04 01:21:14 +0000116struct t12
117{
118 int foo : 1;
119 char : 0;
120 long long : 0;
121 char : 0;
122 char bar;
123};
124static int arr12_offset[(offsetof(struct t12, bar) == 4) ? 0 : -1];
125static int arr12_sizeof[(sizeof(struct t12) == 8) ? 0 : -1];
126
Chad Rosierb8fca902011-08-05 22:38:04 +0000127struct t13
128{
129 char foo;
130 long : 0;
131 char bar;
132};
133static int arr13_offset[(offsetof(struct t13, bar) == 4) ? 0 : -1];
134static int arr13_sizeof[(sizeof(struct t13) == 8) ? 0 : -1];
135
136struct t14
137{
138 char foo1;
139 int : 0;
140 char foo2 : 1;
141 short foo3 : 16;
142 char : 0;
143 short foo4 : 16;
144 char bar1;
145 int : 0;
146 char bar2;
147};
148static int arr14_bar1_offset[(offsetof(struct t14, bar1) == 10) ? 0 : -1];
149static int arr14_bar2_offset[(offsetof(struct t14, bar2) == 12) ? 0 : -1];
150static int arr14_sizeof[(sizeof(struct t14) == 16) ? 0 : -1];
151
152struct t15
153{
154 char foo;
155 char : 0;
156 int : 0;
157 char bar;
158 long : 0;
159 char : 0;
160};
161static int arr15_offset[(offsetof(struct t15, bar) == 4) ? 0 : -1];
162static int arr15_sizeof[(sizeof(struct t15) == 8) ? 0 : -1];
163
164struct t16
165{
166 long : 0;
167 char bar;
168};
169static int arr16_offset[(offsetof(struct t16, bar) == 0) ? 0 : -1];
170static int arr16_sizeof[(sizeof(struct t16) == 4) ? 0 : -1];
171
172struct t17
173{
174 char foo;
175 long : 0;
176 long : 0;
177 char : 0;
178 char bar;
179};
180static int arr17_offset[(offsetof(struct t17, bar) == 4) ? 0 : -1];
181static int arr17_sizeof[(sizeof(struct t17) == 8) ? 0 : -1];
182
183struct t18
184{
185 long : 0;
186 long : 0;
187 char : 0;
188};
189static int arr18_sizeof[(sizeof(struct t18) == 0) ? 0 : -1];
190
191struct t19
192{
193 char foo1;
194 long foo2 : 1;
195 char : 0;
196 long foo3 : 32;
197 char bar;
198};
199static int arr19_offset[(offsetof(struct t19, bar) == 8) ? 0 : -1];
200static int arr19_sizeof[(sizeof(struct t19) == 12) ? 0 : -1];
201
202struct t20
203{
204 short : 0;
205 int foo : 1;
206 long : 0;
207 char bar;
208};
209static int arr20_offset[(offsetof(struct t20, bar) == 4) ? 0 : -1];
210static int arr20_sizeof[(sizeof(struct t20) == 8) ? 0 : -1];
211
212struct t21
213{
214 short : 0;
215 int foo1 : 1;
216 char : 0;
217 int foo2 : 16;
218 long : 0;
219 char bar1;
220 int bar2;
221 long bar3;
222 char foo3 : 8;
223 char : 0;
224 long : 0;
225 int foo4 : 32;
226 short foo5: 1;
227 long bar4;
228 short foo6: 16;
229 short foo7: 16;
230 short foo8: 16;
231};
232static int arr21_bar1_offset[(offsetof(struct t21, bar1) == 8) ? 0 : -1];
233static int arr21_bar2_offset[(offsetof(struct t21, bar2) == 12) ? 0 : -1];
234static int arr21_bar3_offset[(offsetof(struct t21, bar3) == 16) ? 0 : -1];
235static int arr21_bar4_offset[(offsetof(struct t21, bar4) == 32) ? 0 : -1];
236static int arr21_sizeof[(sizeof(struct t21) == 44) ? 0 : -1];
237
Chad Rosier4ab00242011-08-04 00:19:13 +0000238int main() {
239 return 0;
240}
241