1 struct bfu {
2 unsigned int a:11;
3 unsigned int f:9;
4 unsigned int :2;
5 unsigned int z:3;
6 };
7
bfuu_init(unsigned int a)8 struct bfu bfuu_init(unsigned int a)
9 {
10 struct bfu bf = { .f = a, };
11 return bf;
12 }
13
bfus_init(int a)14 struct bfu bfus_init(int a)
15 {
16 struct bfu bf = { .f = a, };
17 return bf;
18 }
19
bfu_get0(void)20 unsigned int bfu_get0(void)
21 {
22 struct bfu bf = { };
23 return bf.f;
24 }
25
26
27 struct bfs {
28 signed int a:11;
29 signed int f:9;
30 signed int :2;
31 signed int z:3;
32 };
33
bfsu_init(unsigned int a)34 struct bfs bfsu_init(unsigned int a)
35 {
36 struct bfs bf = { .f = a, };
37 return bf;
38 }
39
bfss_init(int a)40 struct bfs bfss_init(int a)
41 {
42 struct bfs bf = { .f = a, };
43 return bf;
44 }
45
bfs_get0(void)46 int bfs_get0(void)
47 {
48 struct bfs bf = { };
49 return bf.f;
50 }
51
52 /*
53 * check-name: bitfield implicit init zero
54 * check-command: test-linearize -Wno-decl $file
55 *
56 * check-output-start
57 bfuu_init:
58 .L0:
59 <entry-point>
60 and.32 %r4 <- %arg1, $511
61 shl.32 %r5 <- %r4, $11
62 ret.32 %r5
63
64
65 bfus_init:
66 .L2:
67 <entry-point>
68 and.32 %r13 <- %arg1, $511
69 shl.32 %r14 <- %r13, $11
70 ret.32 %r14
71
72
73 bfu_get0:
74 .L4:
75 <entry-point>
76 ret.32 $0
77
78
79 bfsu_init:
80 .L6:
81 <entry-point>
82 and.32 %r27 <- %arg1, $511
83 shl.32 %r28 <- %r27, $11
84 ret.32 %r28
85
86
87 bfss_init:
88 .L8:
89 <entry-point>
90 and.32 %r36 <- %arg1, $511
91 shl.32 %r37 <- %r36, $11
92 ret.32 %r37
93
94
95 bfs_get0:
96 .L10:
97 <entry-point>
98 ret.32 $0
99
100
101 * check-output-end
102 */
103