diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-11-01 01:06:21 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-01 01:06:21 -0500 |
commit | ddb680b27db6581070b7b4fb03ea1119167a0bd3 (patch) | |
tree | e5c385a8060cddda62009b9d4f979757c93bf1fb /tests | |
parent | 55cf63c08c539df2a8c5437c062dda5fb57a8b18 (diff) | |
parent | e17bd8df3fbd686fa0857b2e09d6e38c9fb6262c (diff) |
Auto merge of #1130 - fitzgen:issue-1076, r=pepyakin
Unnamed bit-fields and alignment
r? @pepyakin or @emilio
Diffstat (limited to 'tests')
-rw-r--r-- | tests/expectations/tests/issue-1034.rs | 7 | ||||
-rw-r--r-- | tests/expectations/tests/issue-1076-unnamed-bitfield-alignment.rs | 31 | ||||
-rw-r--r-- | tests/headers/issue-1076-unnamed-bitfield-alignment.h | 4 |
3 files changed, 39 insertions, 3 deletions
diff --git a/tests/expectations/tests/issue-1034.rs b/tests/expectations/tests/issue-1034.rs index b0c4b529..b5c7d6bb 100644 --- a/tests/expectations/tests/issue-1034.rs +++ b/tests/expectations/tests/issue-1034.rs @@ -4,10 +4,11 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] -#[repr(C, packed)] +#[repr(C)] #[derive(Debug, Default, Copy, Clone)] pub struct S2 { - pub _bitfield_1: u16, + pub _bitfield_1: u8, + pub __bindgen_padding_0: u8, } #[test] fn bindgen_test_layout_S2() { @@ -24,7 +25,7 @@ fn bindgen_test_layout_S2() { } impl S2 { #[inline] - pub fn new_bitfield_1() -> u16 { + pub fn new_bitfield_1() -> u8 { 0 } } diff --git a/tests/expectations/tests/issue-1076-unnamed-bitfield-alignment.rs b/tests/expectations/tests/issue-1076-unnamed-bitfield-alignment.rs new file mode 100644 index 00000000..00b3f11b --- /dev/null +++ b/tests/expectations/tests/issue-1076-unnamed-bitfield-alignment.rs @@ -0,0 +1,31 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] + + +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct S1 { + pub _bitfield_1: [u8; 2usize], + pub __bindgen_padding_0: u8, +} +#[test] +fn bindgen_test_layout_S1() { + assert_eq!( + ::std::mem::size_of::<S1>(), + 3usize, + concat!("Size of: ", stringify!(S1)) + ); + assert_eq!( + ::std::mem::align_of::<S1>(), + 1usize, + concat!("Alignment of ", stringify!(S1)) + ); +} +impl S1 { + #[inline] + pub fn new_bitfield_1() -> u16 { + 0 + } +} diff --git a/tests/headers/issue-1076-unnamed-bitfield-alignment.h b/tests/headers/issue-1076-unnamed-bitfield-alignment.h new file mode 100644 index 00000000..876ec174 --- /dev/null +++ b/tests/headers/issue-1076-unnamed-bitfield-alignment.h @@ -0,0 +1,4 @@ +struct S1 { + signed : 15; + unsigned : 6 +}; |