diff options
-rw-r--r-- | src/codegen/mod.rs | 3 | ||||
-rw-r--r-- | tests/expectations/tests/bitfield-large.rs | 32 | ||||
-rw-r--r-- | tests/headers/bitfield-large.hpp | 9 |
3 files changed, 42 insertions, 2 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs index ee4a9d4e..8151a676 100644 --- a/src/codegen/mod.rs +++ b/src/codegen/mod.rs @@ -924,8 +924,7 @@ fn flush_bitfields<'a, I>(ctx: &BindgenContext, 4 => quote_ty!(ctx.ext_cx(), u32), 2 => quote_ty!(ctx.ext_cx(), u16), 1 => quote_ty!(ctx.ext_cx(), u8), - _ => panic!("physical field containing bitfields should be sized \ - 8, 4, 2, or 1 bytes") + _ => return field }; let bitfield_int_ty = BlobTyBuilder::new(bitfield_layout).build(); diff --git a/tests/expectations/tests/bitfield-large.rs b/tests/expectations/tests/bitfield-large.rs new file mode 100644 index 00000000..d4fe9694 --- /dev/null +++ b/tests/expectations/tests/bitfield-large.rs @@ -0,0 +1,32 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(non_snake_case)] + + +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct HasBigBitfield { + pub _bitfield_1: [u8; 16usize], +} +#[test] +fn bindgen_test_layout_HasBigBitfield() { + assert_eq!(::std::mem::size_of::<HasBigBitfield>() , 16usize , concat ! ( + "Size of: " , stringify ! ( HasBigBitfield ) )); +} +impl Clone for HasBigBitfield { + fn clone(&self) -> Self { *self } +} +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct HasTwoBigBitfields { + pub _bitfield_1: [u8; 16usize], +} +#[test] +fn bindgen_test_layout_HasTwoBigBitfields() { + assert_eq!(::std::mem::size_of::<HasTwoBigBitfields>() , 16usize , concat + ! ( "Size of: " , stringify ! ( HasTwoBigBitfields ) )); +} +impl Clone for HasTwoBigBitfields { + fn clone(&self) -> Self { *self } +} diff --git a/tests/headers/bitfield-large.hpp b/tests/headers/bitfield-large.hpp new file mode 100644 index 00000000..2e349279 --- /dev/null +++ b/tests/headers/bitfield-large.hpp @@ -0,0 +1,9 @@ +struct HasBigBitfield { + __int128 x : 128; +}; + + +struct HasTwoBigBitfields { + __int128 x : 80; + __int128 y : 48; +}; |