Skip to content

Commit 6c79da3

Browse files
committed
test(clang-cl): more bitfield padding tests
1 parent f722c6e commit 6c79da3

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

clang/test/SemaCXX/windows-Wpadded-bitfield.cpp

+21
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,27 @@ struct __attribute__((ms_struct)) BitfieldStruct { // expected-warning {{padding
66
char i;
77
};
88

9+
struct __attribute__((ms_struct)) SevenBitfieldStruct { // expected-warning {{padding size of 'SevenBitfieldStruct' with 3 bytes to alignment boundary}}
10+
char c : 7;
11+
int : 0; // expected-warning {{padding struct 'SevenBitfieldStruct' with 25 bits to align anonymous bit-field}}
12+
char i;
13+
};
14+
15+
struct __attribute__((ms_struct)) SameUnitSizeBitfield {
16+
char c : 7;
17+
char : 1; // Same unit size attributes fall in the same unit + they fill the unit -> no padding
18+
char i;
19+
};
20+
21+
struct __attribute__((ms_struct)) DifferentUnitSizeBitfield { // expected-warning {{padding size of 'DifferentUnitSizeBitfield' with 3 bytes to alignment boundary}}
22+
char c : 7;
23+
int : 1; // expected-warning {{padding struct 'DifferentUnitSizeBitfield' with 25 bits to align anonymous bit-field}}
24+
char i; // expected-warning {{padding struct 'DifferentUnitSizeBitfield' with 31 bits to align 'i'}}
25+
};
26+
927
int main() {
1028
BitfieldStruct b;
29+
SevenBitfieldStruct s;
30+
SameUnitSizeBitfield su;
31+
DifferentUnitSizeBitfield du;
1132
}

0 commit comments

Comments
 (0)