[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Sema / bitfield-layout_1.c
blob24277c3911495855ba8814217b0d8f7fb879b3da
1 // RUN: %clang_cc1 %s -fsyntax-only -verify -triple=i686-apple-darwin9
2 // RUN: %clang_cc1 %s -fsyntax-only -verify -triple=arm-linux-gnueabihf
3 // RUN: %clang_cc1 %s -fsyntax-only -verify -triple=aarch64-linux-gnu
4 // RUN: %clang_cc1 %s -fsyntax-only -verify -triple=x86_64-pc-linux-gnu
5 // expected-no-diagnostics
7 #define CHECK_SIZE(name, size) \
8 extern int name##_1[sizeof(name) == size ? 1 : -1];
11 struct __attribute__((packed)) {
12 int a;
13 int b : 4;
14 int c : 32;
15 } s0;
16 CHECK_SIZE(s0,9)
18 #pragma pack (1)
19 struct {
20 int a;
21 int b : 4;
22 int c : 32;
23 } s1;
24 CHECK_SIZE(s1,9)
26 #pragma pack (2)
27 struct {
28 int a;
29 int b : 4;
30 int c : 32;
31 } s2;
32 CHECK_SIZE(s2,10)
34 #pragma pack (2)
35 struct __attribute__((packed)) {
36 int a;
37 int b : 4;
38 int c : 32;
39 } s3;
40 CHECK_SIZE(s3,10)
42 #pragma pack (4)
43 struct __attribute__((packed)) {
44 int a;
45 int b : 4;
46 int c : 32;
47 } s4;
48 CHECK_SIZE(s4,12)
50 #pragma pack (16)
51 struct {
52 int a;
53 int __attribute__((packed)) b : 4;
54 int __attribute__((packed)) c : 32;
55 } s41;
56 CHECK_SIZE(s41,12)
58 #pragma pack (16)
59 struct {
60 int a;
61 int b : 4;
62 int c : 32;
63 } s5;
64 CHECK_SIZE(s5,12)
66 #pragma pack (1)
67 struct __attribute__((aligned(4))) {
68 int a;
69 int b : 4;
70 int c : 32;
71 } s6;
72 CHECK_SIZE(s6,12)
74 #pragma pack (2)
75 struct {
76 char a;
77 int b : 4;
78 int c : 32;
79 char s;
80 } s7;
81 CHECK_SIZE(s7,8)
83 #pragma pack (1)
84 struct {
85 char a;
86 int b : 4;
87 int c : 28;
88 char s;
89 } s8;
90 CHECK_SIZE(s8,6)
92 #pragma pack (8)
93 struct {
94 char a;
95 int b : 4;
96 int c : 28;
97 char s;
98 } s9;
99 CHECK_SIZE(s9,8)
101 #pragma pack (8)
102 struct {
103 char a;
104 char s;
105 } s10;
106 CHECK_SIZE(s10,2)
108 #pragma pack(4)
109 struct {
110 char a;
111 int b : 4;
112 int c : 28;
113 char s1;
114 char s2;
115 char s3;
116 } s11;
117 CHECK_SIZE(s11,8)
119 #pragma pack(4)
120 struct {
121 short s1;
122 int a1 : 17;
123 int a2 : 17;
124 int a3 : 30;
125 short s2;
126 } s12;
127 CHECK_SIZE(s12,12)
129 #pragma pack(4)
130 struct {
131 char c1;
132 int i1 : 17;
133 int i2 : 17;
134 int i3 : 30;
135 char c2;
136 } s13;
137 CHECK_SIZE(s13,12)
139 #pragma pack(2)
140 struct {
141 char a;
142 int s;
143 } s14;
144 CHECK_SIZE(s14,6)
146 #pragma pack(4)
147 struct {
148 char a;
149 short s;
150 } s15;
151 CHECK_SIZE(s15,4)
153 #pragma pack(2)
154 struct {
155 char a;
156 int b : 4;
157 int c : 28;
158 char s1;
159 char s2;
160 char s3;
161 } s16;
162 CHECK_SIZE(s16,8)
164 #pragma pack (16)
165 struct {
166 int __attribute__((packed)) a;
167 int __attribute__((packed)) b : 4;
168 int __attribute__((packed)) c : 32;
169 } s17;
170 CHECK_SIZE(s17,12)
172 #pragma pack (16)
173 struct {
174 int __attribute__((aligned(8))) a;
175 int __attribute__((aligned(8))) b : 4;
176 int __attribute__((aligned(8))) c : 32;
177 } s18;
178 CHECK_SIZE(s18,24)
180 #pragma pack (16)
181 struct {
182 int __attribute__((aligned(1))) a;
183 int __attribute__((aligned(1))) b : 4;
184 int __attribute__((aligned(1))) c : 32;
185 } s19;
186 CHECK_SIZE(s19,12)
188 #pragma pack (1)
189 struct __attribute__((aligned(8))) {
190 int a;
191 int b : 4;
192 int c : 32;
193 } s20;
194 CHECK_SIZE(s20,16)
196 #pragma pack (2)
197 struct {
198 int __attribute__((aligned(8))) a;
199 int __attribute__((aligned(8))) b : 4;
200 int __attribute__((aligned(8))) c : 32;
201 } s21;
202 CHECK_SIZE(s21,10)