1 | // RUN: %clang_cc1 -triple i386-apple-darwin10 -mms-bitfields -emit-llvm %s -o - | FileCheck %s |
2 | |
3 | struct s1 { |
4 | int f32; |
5 | long long f64; |
6 | } s1; |
7 | |
8 | // CHECK: %struct.s1 = type { i32, [4 x i8], i64 } |
9 | |
10 | struct s2 { |
11 | int f32; |
12 | long long f64[4]; |
13 | } s2; |
14 | |
15 | // CHECK: %struct.s2 = type { i32, [4 x i8], [4 x i64] } |
16 | |
17 | struct s3 { |
18 | int f32; |
19 | struct s1 s; |
20 | } s3; |
21 | |
22 | // CHECK: %struct.s3 = type { i32, [4 x i8], %struct.s1 } |
23 | |
24 | // PR32482: |
25 | |
26 | #pragma pack (push,1) |
27 | |
28 | typedef unsigned int UINT32; |
29 | |
30 | struct Inner { |
31 | UINT32 A : 1; |
32 | UINT32 B : 1; |
33 | UINT32 C : 1; |
34 | UINT32 D : 30; |
35 | } Inner; |
36 | |
37 | #pragma pack (pop) |
38 | |
39 | // CHECK: %struct.Inner = type { i32, i32 } |
40 | |
41 | // CHECK: %struct.A = type { i32, i32, i32 } |
42 | |
43 | #pragma pack(push, 1) |
44 | |
45 | union HEADER { |
46 | struct A { |
47 | int : 3; // Bits 2:0 |
48 | int a : 9; // Bits 11:3 |
49 | int : 12; // Bits 23:12 |
50 | int b : 17; // Bits 40:24 |
51 | int : 7; // Bits 47:41 |
52 | int c : 4; // Bits 51:48 |
53 | int : 4; // Bits 55:52 |
54 | int d : 3; // Bits 58:56 |
55 | int : 5; // Bits 63:59 |
56 | } Bits; |
57 | } HEADER; |
58 | |
59 | #pragma pack(pop) |
60 | |
61 | struct Inner variable = { 1,0,1, 21 }; |
62 | union HEADER hdr = {{1,2,3,4}}; |
63 | |
64 | // CHECK: @variable = global { i8, [3 x i8], i8, i8, i8, i8 } { i8 5, [3 x i8] undef, i8 21, i8 0, i8 0, i8 0 }, align 1 |
65 | // CHECK: @hdr = global { { i8, i8, [2 x i8], i8, i8, i8, i8, i8, [3 x i8] } } { { i8, i8, [2 x i8], i8, i8, i8, i8, i8, [3 x i8] } { i8 8, i8 0, [2 x i8] undef, i8 2, i8 0, i8 0, i8 3, i8 4, [3 x i8] undef } }, align 1 |
66 | |