blob: 4b16e0c832b9db552bb01dc55d548c481e6e8160 [file] [log] [blame]
Chad Rosier4ab00242011-08-04 00:19:13 +00001// RUN: %clang_cc1 -target-abi apcs-gnu -triple armv7-apple-darwin10 %s -verify
Chad Rosier61a62212011-08-04 01:21:14 +00002//
3// Note: gcc forces the alignment to 4 bytes, regardless of the type of the
4// zero length bitfield.
5// rdar://9859156
Chad Rosier4ab00242011-08-04 00:19:13 +00006
7#include <stddef.h>
8
9struct t1
10{
11 int foo : 1;
12 char : 0;
13 char bar;
14};
Chad Rosier61a62212011-08-04 01:21:14 +000015static int arr1_offset[(offsetof(struct t1, bar) == 4) ? 0 : -1];
16static int arr1_sizeof[(sizeof(struct t1) == 8) ? 0 : -1];
Chad Rosier4ab00242011-08-04 00:19:13 +000017
18struct t2
19{
20 int foo : 1;
21 short : 0;
22 char bar;
23};
Chad Rosier61a62212011-08-04 01:21:14 +000024static int arr2_offset[(offsetof(struct t2, bar) == 4) ? 0 : -1];
25static int arr2_sizeof[(sizeof(struct t2) == 8) ? 0 : -1];
Chad Rosier4ab00242011-08-04 00:19:13 +000026
27struct t3
28{
29 int foo : 1;
30 int : 0;
31 char bar;
32};
Chad Rosier61a62212011-08-04 01:21:14 +000033static int arr3_offset[(offsetof(struct t3, bar) == 4) ? 0 : -1];
34static int arr3_sizeof[(sizeof(struct t3) == 8) ? 0 : -1];
Chad Rosier4ab00242011-08-04 00:19:13 +000035
36struct t4
37{
38 int foo : 1;
39 long : 0;
40 char bar;
41};
Chad Rosier61a62212011-08-04 01:21:14 +000042static int arr4_offset[(offsetof(struct t4, bar) == 4) ? 0 : -1];
43static int arr4_sizeof[(sizeof(struct t4) == 8) ? 0 : -1];
Chad Rosier4ab00242011-08-04 00:19:13 +000044
45struct t5
46{
47 int foo : 1;
48 long long : 0;
49 char bar;
50};
Chad Rosier61a62212011-08-04 01:21:14 +000051static int arr5_offset[(offsetof(struct t5, bar) == 4) ? 0 : -1];
52static int arr5_sizeof[(sizeof(struct t5) == 8) ? 0 : -1];
Chad Rosier4ab00242011-08-04 00:19:13 +000053
54struct t6
55{
56 int foo : 1;
57 char : 0;
58 char bar : 1;
59 char bar2;
60};
61static int arr6_offset[(offsetof(struct t6, bar2) == 1) ? 0 : -1];
62static int arr6_sizeof[(sizeof(struct t6) == 2) ? 0 : -1];
63
64struct t7
65{
66 int foo : 1;
67 short : 0;
68 char bar1 : 1;
69 char bar2;
70};
71static int arr7_offset[(offsetof(struct t7, bar2) == 1) ? 0 : -1];
72static int arr7_sizeof[(sizeof(struct t7) == 2) ? 0 : -1];
73
74struct t8
75{
76 int foo : 1;
77 int : 0;
78 char bar1 : 1;
79 char bar2;
80};
81static int arr8_offset[(offsetof(struct t8, bar2) == 1) ? 0 : -1];
82static int arr8_sizeof[(sizeof(struct t8) == 2) ? 0 : -1];
83
84struct t9
85{
86 int foo : 1;
87 long : 0;
88 char bar1 : 1;
89 char bar2;
90};
91static int arr9_offset[(offsetof(struct t9, bar2) == 1) ? 0 : -1];
92static int arr9_sizeof[(sizeof(struct t9) == 2) ? 0 : -1];
93
94struct t10
95{
96 int foo : 1;
97 long long : 0;
98 char bar1 : 1;
99 char bar2;
100};
101static int arr10_offset[(offsetof(struct t10, bar2) == 1) ? 0 : -1];
102static int arr10_sizeof[(sizeof(struct t10) == 2) ? 0 : -1];
103
104
105struct t11
106{
107 int foo : 1;
108 long long : 0;
109 char : 0;
110 char bar1 : 1;
111 char bar2;
112};
113static int arr11_offset[(offsetof(struct t11, bar2) == 1) ? 0 : -1];
114static int arr11_sizeof[(sizeof(struct t11) == 2) ? 0 : -1];
115
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 Rosier4ab00242011-08-04 00:19:13 +0000127int main() {
128 return 0;
129}
130