From 362341d53448196369a9e2a6242a26c305527c6a Mon Sep 17 00:00:00 2001 From: Amanjeev Sethi Date: Mon, 19 Sep 2022 19:26:44 -0400 Subject: [PATCH] test: add test for GH-422 GitHub issue 422 was fixed but needs a test. https://github.com/rust-lang/rust-bindgen/issues/422 Signed-off-by: Amanjeev Sethi --- .../expectations/tests/inner-typedef-gh422.rs | 37 +++++++++++++++++++ tests/headers/inner-typedef-gh422.hpp | 11 ++++++ 2 files changed, 48 insertions(+) create mode 100644 tests/expectations/tests/inner-typedef-gh422.rs create mode 100644 tests/headers/inner-typedef-gh422.hpp diff --git a/tests/expectations/tests/inner-typedef-gh422.rs b/tests/expectations/tests/inner-typedef-gh422.rs new file mode 100644 index 0000000000..1cfa549c32 --- /dev/null +++ b/tests/expectations/tests/inner-typedef-gh422.rs @@ -0,0 +1,37 @@ +#![allow( + dead_code, + non_snake_case, + non_camel_case_types, + non_upper_case_globals +)] + +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct Foo { + pub _address: u8, +} +#[repr(C)] +#[derive(Debug, Copy, Clone)] +pub struct Foo_InnerType { + pub t: T, + pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell>, +} +impl Default for Foo_InnerType { + fn default() -> Self { + let mut s = ::std::mem::MaybeUninit::::uninit(); + unsafe { + ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); + s.assume_init() + } + } +} +pub type Bar = InnerType; +extern "C" { + #[link_name = "\u{1}_Z4funcv"] + pub fn func() -> Bar; +} +#[repr(C)] +#[derive(Debug, Default, Copy, Clone)] +pub struct InnerType { + pub _address: u8, +} diff --git a/tests/headers/inner-typedef-gh422.hpp b/tests/headers/inner-typedef-gh422.hpp new file mode 100644 index 0000000000..301630a5e0 --- /dev/null +++ b/tests/headers/inner-typedef-gh422.hpp @@ -0,0 +1,11 @@ +template +class Foo { +public: + class InnerType { + T t; + }; +}; + +typedef Foo::InnerType Bar; + +Bar func(); \ No newline at end of file