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