diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/expectations/tests/stdint_typedef.rs | 41 | ||||
-rw-r--r-- | tests/headers/stdint_typedef.h | 10 |
2 files changed, 51 insertions, 0 deletions
diff --git a/tests/expectations/tests/stdint_typedef.rs b/tests/expectations/tests/stdint_typedef.rs new file mode 100644 index 00000000..a52db496 --- /dev/null +++ b/tests/expectations/tests/stdint_typedef.rs @@ -0,0 +1,41 @@ +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] + +extern "C" { + pub fn fun() -> u64; +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct Struct { + pub field: u64, +} +#[test] +fn bindgen_test_layout_Struct() { + const UNINIT: ::std::mem::MaybeUninit<Struct> = + ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of::<Struct>(), + 8usize, + concat!("Size of: ", stringify!(Struct)) + ); + assert_eq!( + ::std::mem::align_of::<Struct>(), + 8usize, + concat!("Alignment of ", stringify!(Struct)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((*ptr).field) as usize - ptr as usize }, + 0usize, + concat!( + "Offset of field: ", + stringify!(Struct), + "::", + stringify!(field) + ) + ); +} diff --git a/tests/headers/stdint_typedef.h b/tests/headers/stdint_typedef.h new file mode 100644 index 00000000..f716a7f1 --- /dev/null +++ b/tests/headers/stdint_typedef.h @@ -0,0 +1,10 @@ +// bindgen-flags: --allowlist-type="Struct" --allowlist-function="fun" + +// no typedef should be emitted for `__uint64_t` +typedef unsigned long long __uint64_t; +typedef __uint64_t uint64_t; + +uint64_t fun(); +struct Struct { + uint64_t field; +}; |