diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2021-04-03 12:57:19 +0200 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2021-04-03 13:05:04 +0200 |
commit | 4faaf9a5f3962f1548824cb42fb8559dc6baac7d (patch) | |
tree | e1fadf196fba1da7a4152aa40a95bbb1e8a8472e /tests | |
parent | b21086cc3ba5aaeea53082e0618733a1b354daab (diff) |
codegen: Deal with overloads in method code generation.
Fixes #2019
Diffstat (limited to 'tests')
-rw-r--r-- | tests/expectations/tests/issue-2019.rs | 73 | ||||
-rw-r--r-- | tests/headers/issue-2019.hpp | 10 |
2 files changed, 83 insertions, 0 deletions
diff --git a/tests/expectations/tests/issue-2019.rs b/tests/expectations/tests/issue-2019.rs new file mode 100644 index 00000000..383bd57e --- /dev/null +++ b/tests/expectations/tests/issue-2019.rs @@ -0,0 +1,73 @@ +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] + +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct A { + pub a: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_A() { + assert_eq!( + ::std::mem::size_of::<A>(), + 4usize, + concat!("Size of: ", stringify!(A)) + ); + assert_eq!( + ::std::mem::align_of::<A>(), + 4usize, + concat!("Alignment of ", stringify!(A)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<A>())).a as *const _ as usize }, + 0usize, + concat!("Offset of field: ", stringify!(A), "::", stringify!(a)) + ); +} +extern "C" { + #[link_name = "\u{1}_ZN1A4makeEv"] + pub fn make() -> A; +} +impl A { + #[inline] + pub unsafe fn make() -> A { + make() + } +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct B { + pub b: ::std::os::raw::c_int, +} +#[test] +fn bindgen_test_layout_B() { + assert_eq!( + ::std::mem::size_of::<B>(), + 4usize, + concat!("Size of: ", stringify!(B)) + ); + assert_eq!( + ::std::mem::align_of::<B>(), + 4usize, + concat!("Alignment of ", stringify!(B)) + ); + assert_eq!( + unsafe { &(*(::std::ptr::null::<B>())).b as *const _ as usize }, + 0usize, + concat!("Offset of field: ", stringify!(B), "::", stringify!(b)) + ); +} +extern "C" { + #[link_name = "\u{1}_ZN1B4makeEv"] + pub fn make1() -> B; +} +impl B { + #[inline] + pub unsafe fn make() -> B { + make1() + } +} diff --git a/tests/headers/issue-2019.hpp b/tests/headers/issue-2019.hpp new file mode 100644 index 00000000..2e9a3ffd --- /dev/null +++ b/tests/headers/issue-2019.hpp @@ -0,0 +1,10 @@ +// bindgen-flags: --disable-nested-struct-naming + +struct A { + static A make(); + int a; +}; +struct B { + static B make(); + int b; +}; |