[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CodeGen / ms_struct-bitfield-init.c
blob7490bbb5d091d09489fa103431576c99f3226459
1 // RUN: %clang_cc1 -emit-llvm-only -triple x86_64-apple-darwin9 %s
3 extern void abort(void);
4 #define ATTR __attribute__((__ms_struct__))
6 struct
8 char foo;
9 long : 0;
10 char : 0;
11 int : 0;
12 char bar;
13 } ATTR t1 = {'a', 'b'};
15 struct
17 char bar0;
18 long : 0;
19 int : 0;
20 char bar1;
21 char bar2;
22 long : 0;
23 char bar3;
24 char bar4;
25 char : 0;
26 char bar5;
27 char bar6;
28 char : 0;
29 char bar7;
30 char bar8;
31 } ATTR t2 = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'};
33 struct {
34 int : 0;
35 int i1;
36 int : 0;
37 int i2;
38 int : 0;
39 int i3;
40 int : 0;
41 int i4;
42 } t3 = {1,2,3,4};
44 int main(void) {
45 if (sizeof(t1) != 2)
46 abort();
47 if (t1.foo != 'a')
48 abort();
49 if (t1.bar != 'b')
50 abort();
51 t1.foo = 'c';
52 t1.bar = 'd';
53 if (t1.foo != 'c')
54 abort();
55 if (t1.bar != 'd')
56 abort();
57 if (sizeof(t2) != 9)
58 abort();
59 if (t2.bar0 != 'a' || t2.bar8 != 'i')
60 abort();
61 if (sizeof(t3) != 16)
62 abort();
63 if (t3.i1 != 1 || t3.i4 != 4)
64 abort();
65 return 0;