diff --git a/bindgen-tests/tests/expectations/tests/libclang-9/float16.rs b/bindgen-tests/tests/expectations/tests/libclang-9/float16.rs index 6f7823ae15..8683c297aa 100644 --- a/bindgen-tests/tests/expectations/tests/libclang-9/float16.rs +++ b/bindgen-tests/tests/expectations/tests/libclang-9/float16.rs @@ -1,93 +1,61 @@ #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] #[derive(PartialEq, Copy, Clone, Hash, Debug, Default)] #[repr(C)] -pub struct __BindgenComplex { - pub re: T, - pub im: T, -} -#[derive(PartialEq, Copy, Clone, Hash, Debug, Default)] -#[repr(C)] pub struct __BindgenFloat16(pub u16); extern "C" { pub static mut global: __BindgenFloat16; } #[repr(C)] #[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct A { +pub struct Test__Float16 { pub f: __BindgenFloat16, } #[test] -fn bindgen_test_layout_A() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); +fn bindgen_test_layout_Test__Float16() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); let ptr = UNINIT.as_ptr(); - assert_eq!(::std::mem::size_of::(), 2usize, concat!("Size of: ", stringify!(A))); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::size_of::(), 2usize, - concat!("Alignment of ", stringify!(A)), + concat!("Size of: ", stringify!(Test__Float16)), ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).f) as usize - ptr as usize }, - 0usize, - concat!("Offset of field: ", stringify!(A), "::", stringify!(f)), - ); -} -#[repr(C)] -#[derive(Debug, Default, Copy, Clone, PartialEq)] -pub struct Test_Float16 { - pub mMember: __BindgenComplex, -} -#[test] -fn bindgen_test_layout_Test_Float16() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); - let ptr = UNINIT.as_ptr(); - assert_eq!( - ::std::mem::size_of::(), - 8usize, - concat!("Size of: ", stringify!(Test_Float16)), - ); - assert_eq!( - ::std::mem::align_of::(), - 4usize, - concat!("Alignment of ", stringify!(Test_Float16)), + ::std::mem::align_of::(), + 2usize, + concat!("Alignment of ", stringify!(Test__Float16)), ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).mMember) as usize - ptr as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).f) as usize - ptr as usize }, 0usize, - concat!("Offset of field: ", stringify!(Test_Float16), "::", stringify!(mMember)), + concat!("Offset of field: ", stringify!(Test__Float16), "::", stringify!(f)), ); } #[repr(C)] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub struct Test_Float16Ptr { - pub mMember: *mut __BindgenComplex, +pub struct Test__Float16Ref { + pub f: *mut __BindgenFloat16, } #[test] -fn bindgen_test_layout_Test_Float16Ptr() { - const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); +fn bindgen_test_layout_Test__Float16Ref() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); let ptr = UNINIT.as_ptr(); assert_eq!( - ::std::mem::size_of::(), + ::std::mem::size_of::(), 8usize, - concat!("Size of: ", stringify!(Test_Float16Ptr)), + concat!("Size of: ", stringify!(Test__Float16Ref)), ); assert_eq!( - ::std::mem::align_of::(), + ::std::mem::align_of::(), 8usize, - concat!("Alignment of ", stringify!(Test_Float16Ptr)), + concat!("Alignment of ", stringify!(Test__Float16Ref)), ); assert_eq!( - unsafe { ::std::ptr::addr_of!((*ptr).mMember) as usize - ptr as usize }, + unsafe { ::std::ptr::addr_of!((*ptr).f) as usize - ptr as usize }, 0usize, - concat!( - "Offset of field: ", - stringify!(Test_Float16Ptr), - "::", - stringify!(mMember), - ), + concat!("Offset of field: ", stringify!(Test__Float16Ref), "::", stringify!(f)), ); } -impl Default for Test_Float16Ptr { +impl Default for Test__Float16Ref { fn default() -> Self { let mut s = ::std::mem::MaybeUninit::::uninit(); unsafe { @@ -96,6 +64,3 @@ impl Default for Test_Float16Ptr { } } } -extern "C" { - pub static mut globalValueHalf: __BindgenComplex<__BindgenFloat16>; -} diff --git a/bindgen-tests/tests/headers/float16.h b/bindgen-tests/tests/headers/float16.h index daa7f94753..3b1058591d 100644 --- a/bindgen-tests/tests/headers/float16.h +++ b/bindgen-tests/tests/headers/float16.h @@ -1,22 +1,36 @@ // bindgen-flags: --with-derive-hash --with-derive-partialeq --with-derive-eq -static _Float16 global; +static __fp16 global; -struct A +struct Test__Float16 { - _Float16 f; + __fp16 f; }; -#define COMPLEX_TEST(ty_, name_) \ - struct Test##name_ \ - { \ - ty_ _Complex mMember; \ - }; \ - struct Test##name_##Ptr \ - { \ - ty_ _Complex *mMember; \ - }; +struct Test__Float16Ref +{ + __fp16 *f; +}; + +/* +// This options are currently supported only on specific targets (eg. x86 with sse2) +_Float16 returns_f16(); + +void gets_f16(_Float16 arg); + +struct Test__Float16_Complex +{ + _Float16 _Complex mMember; +}; + +struct Test__Float16_ComplexPtr +{ + _Float16 _Complex *mMember; +}; + +_Float16 _Complex globalValueHalf; -COMPLEX_TEST(float, _Float16) +_Float16 _Complex returns_f16_complex(); -_Float16 _Complex globalValueHalf; \ No newline at end of file +void gets_f16_complex(_Float16 _Complex arg); +*/ \ No newline at end of file