.. | .. |
---|
19 | 19 | /* |
---|
20 | 20 | *struct padded_explicitly { |
---|
21 | 21 | * int a; |
---|
22 | | - * int: 32; |
---|
| 22 | + * long: 0; |
---|
23 | 23 | * int b; |
---|
24 | 24 | *}; |
---|
25 | 25 | * |
---|
.. | .. |
---|
28 | 28 | |
---|
29 | 29 | struct padded_explicitly { |
---|
30 | 30 | int a; |
---|
31 | | - int: 1; /* algo will explicitly pad with full 32 bits here */ |
---|
| 31 | + int: 1; /* algo will emit aligning `long: 0;` here */ |
---|
32 | 32 | int b; |
---|
33 | 33 | }; |
---|
34 | 34 | |
---|
35 | 35 | /* ----- START-EXPECTED-OUTPUT ----- */ |
---|
36 | | -/* |
---|
37 | | - *struct padded_a_lot { |
---|
38 | | - * int a; |
---|
39 | | - * long: 32; |
---|
40 | | - * long: 64; |
---|
41 | | - * long: 64; |
---|
42 | | - * int b; |
---|
43 | | - *}; |
---|
44 | | - * |
---|
45 | | - */ |
---|
46 | | -/* ------ END-EXPECTED-OUTPUT ------ */ |
---|
47 | | - |
---|
48 | 36 | struct padded_a_lot { |
---|
49 | 37 | int a; |
---|
50 | | - /* 32 bit of implicit padding here, which algo will make explicit */ |
---|
51 | 38 | long: 64; |
---|
52 | 39 | long: 64; |
---|
53 | 40 | int b; |
---|
54 | 41 | }; |
---|
| 42 | + |
---|
| 43 | +/* ------ END-EXPECTED-OUTPUT ------ */ |
---|
55 | 44 | |
---|
56 | 45 | /* ----- START-EXPECTED-OUTPUT ----- */ |
---|
57 | 46 | /* |
---|
58 | 47 | *struct padded_cache_line { |
---|
59 | 48 | * int a; |
---|
60 | | - * long: 32; |
---|
61 | 49 | * long: 64; |
---|
62 | 50 | * long: 64; |
---|
63 | 51 | * long: 64; |
---|
64 | 52 | * int b; |
---|
65 | | - * long: 32; |
---|
66 | 53 | * long: 64; |
---|
67 | 54 | * long: 64; |
---|
68 | 55 | * long: 64; |
---|
.. | .. |
---|
85 | 72 | *struct zone { |
---|
86 | 73 | * int a; |
---|
87 | 74 | * short b; |
---|
88 | | - * short: 16; |
---|
| 75 | + * long: 0; |
---|
89 | 76 | * struct zone_padding __pad__; |
---|
90 | 77 | *}; |
---|
91 | 78 | * |
---|
.. | .. |
---|
102 | 89 | struct zone_padding __pad__; |
---|
103 | 90 | }; |
---|
104 | 91 | |
---|
| 92 | +/* ----- START-EXPECTED-OUTPUT ----- */ |
---|
| 93 | +struct padding_wo_named_members { |
---|
| 94 | + long: 64; |
---|
| 95 | + long: 64; |
---|
| 96 | +}; |
---|
| 97 | + |
---|
| 98 | +struct padding_weird_1 { |
---|
| 99 | + int a; |
---|
| 100 | + long: 64; |
---|
| 101 | + short: 16; |
---|
| 102 | + short b; |
---|
| 103 | +}; |
---|
| 104 | + |
---|
| 105 | +/* ------ END-EXPECTED-OUTPUT ------ */ |
---|
| 106 | + |
---|
| 107 | +/* ----- START-EXPECTED-OUTPUT ----- */ |
---|
| 108 | +/* |
---|
| 109 | + *struct padding_weird_2 { |
---|
| 110 | + * long: 56; |
---|
| 111 | + * char a; |
---|
| 112 | + * long: 56; |
---|
| 113 | + * char b; |
---|
| 114 | + * char: 8; |
---|
| 115 | + *}; |
---|
| 116 | + * |
---|
| 117 | + */ |
---|
| 118 | +/* ------ END-EXPECTED-OUTPUT ------ */ |
---|
| 119 | +struct padding_weird_2 { |
---|
| 120 | + int: 32; /* these paddings will be collapsed into `long: 56;` */ |
---|
| 121 | + short: 16; |
---|
| 122 | + char: 8; |
---|
| 123 | + char a; |
---|
| 124 | + int: 32; /* these paddings will be collapsed into `long: 56;` */ |
---|
| 125 | + short: 16; |
---|
| 126 | + char: 8; |
---|
| 127 | + char b; |
---|
| 128 | + char: 8; |
---|
| 129 | +}; |
---|
| 130 | + |
---|
| 131 | +/* ----- START-EXPECTED-OUTPUT ----- */ |
---|
| 132 | +struct exact_1byte { |
---|
| 133 | + char x; |
---|
| 134 | +}; |
---|
| 135 | + |
---|
| 136 | +struct padded_1byte { |
---|
| 137 | + char: 8; |
---|
| 138 | +}; |
---|
| 139 | + |
---|
| 140 | +struct exact_2bytes { |
---|
| 141 | + short x; |
---|
| 142 | +}; |
---|
| 143 | + |
---|
| 144 | +struct padded_2bytes { |
---|
| 145 | + short: 16; |
---|
| 146 | +}; |
---|
| 147 | + |
---|
| 148 | +struct exact_4bytes { |
---|
| 149 | + int x; |
---|
| 150 | +}; |
---|
| 151 | + |
---|
| 152 | +struct padded_4bytes { |
---|
| 153 | + int: 32; |
---|
| 154 | +}; |
---|
| 155 | + |
---|
| 156 | +struct exact_8bytes { |
---|
| 157 | + long x; |
---|
| 158 | +}; |
---|
| 159 | + |
---|
| 160 | +struct padded_8bytes { |
---|
| 161 | + long: 64; |
---|
| 162 | +}; |
---|
| 163 | + |
---|
| 164 | +struct ff_periodic_effect { |
---|
| 165 | + int: 32; |
---|
| 166 | + short magnitude; |
---|
| 167 | + long: 0; |
---|
| 168 | + short phase; |
---|
| 169 | + long: 0; |
---|
| 170 | + int: 32; |
---|
| 171 | + int custom_len; |
---|
| 172 | + short *custom_data; |
---|
| 173 | +}; |
---|
| 174 | + |
---|
| 175 | +struct ib_wc { |
---|
| 176 | + long: 64; |
---|
| 177 | + long: 64; |
---|
| 178 | + int: 32; |
---|
| 179 | + int byte_len; |
---|
| 180 | + void *qp; |
---|
| 181 | + union {} ex; |
---|
| 182 | + long: 64; |
---|
| 183 | + int slid; |
---|
| 184 | + int wc_flags; |
---|
| 185 | + long: 64; |
---|
| 186 | + char smac[6]; |
---|
| 187 | + long: 0; |
---|
| 188 | + char network_hdr_type; |
---|
| 189 | +}; |
---|
| 190 | + |
---|
| 191 | +struct acpi_object_method { |
---|
| 192 | + long: 64; |
---|
| 193 | + char: 8; |
---|
| 194 | + char type; |
---|
| 195 | + short reference_count; |
---|
| 196 | + char flags; |
---|
| 197 | + short: 0; |
---|
| 198 | + char: 8; |
---|
| 199 | + char sync_level; |
---|
| 200 | + long: 64; |
---|
| 201 | + void *node; |
---|
| 202 | + void *aml_start; |
---|
| 203 | + union {} dispatch; |
---|
| 204 | + long: 64; |
---|
| 205 | + int aml_length; |
---|
| 206 | +}; |
---|
| 207 | + |
---|
| 208 | +struct nested_unpacked { |
---|
| 209 | + int x; |
---|
| 210 | +}; |
---|
| 211 | + |
---|
| 212 | +struct nested_packed { |
---|
| 213 | + struct nested_unpacked a; |
---|
| 214 | + char c; |
---|
| 215 | +} __attribute__((packed)); |
---|
| 216 | + |
---|
| 217 | +struct outer_mixed_but_unpacked { |
---|
| 218 | + struct nested_packed b1; |
---|
| 219 | + short a1; |
---|
| 220 | + struct nested_packed b2; |
---|
| 221 | +}; |
---|
| 222 | + |
---|
| 223 | +/* ------ END-EXPECTED-OUTPUT ------ */ |
---|
| 224 | + |
---|
105 | 225 | int f(struct { |
---|
106 | 226 | struct padded_implicitly _1; |
---|
107 | 227 | struct padded_explicitly _2; |
---|
108 | 228 | struct padded_a_lot _3; |
---|
109 | 229 | struct padded_cache_line _4; |
---|
110 | 230 | struct zone _5; |
---|
| 231 | + struct padding_wo_named_members _6; |
---|
| 232 | + struct padding_weird_1 _7; |
---|
| 233 | + struct padding_weird_2 _8; |
---|
| 234 | + struct exact_1byte _100; |
---|
| 235 | + struct padded_1byte _101; |
---|
| 236 | + struct exact_2bytes _102; |
---|
| 237 | + struct padded_2bytes _103; |
---|
| 238 | + struct exact_4bytes _104; |
---|
| 239 | + struct padded_4bytes _105; |
---|
| 240 | + struct exact_8bytes _106; |
---|
| 241 | + struct padded_8bytes _107; |
---|
| 242 | + struct ff_periodic_effect _200; |
---|
| 243 | + struct ib_wc _201; |
---|
| 244 | + struct acpi_object_method _202; |
---|
| 245 | + struct outer_mixed_but_unpacked _203; |
---|
111 | 246 | } *_) |
---|
112 | 247 | { |
---|
113 | 248 | return 0; |
---|