From 5fe6d482e5dc073e7f6daf5af7a4e6893b19fa14 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 16 Jun 2023 15:08:16 +0200 Subject: [PATCH] Fix test again. --- .../tests/libclang-5/issue-2556.rs | 44 ++++++++++++++++++- bindgen-tests/tests/headers/issue-2556.h | 2 +- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/bindgen-tests/tests/expectations/tests/libclang-5/issue-2556.rs b/bindgen-tests/tests/expectations/tests/libclang-5/issue-2556.rs index 996b877e50..7722b851e2 100644 --- a/bindgen-tests/tests/expectations/tests/libclang-5/issue-2556.rs +++ b/bindgen-tests/tests/expectations/tests/libclang-5/issue-2556.rs @@ -1 +1,43 @@ -/* error generating bindings */ +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] +pub mod root { + #[allow(unused_imports)] + use self::super::root; + #[repr(C)] + #[derive(Debug, Default, Copy, Clone)] + pub struct nsSize { + pub width: ::std::os::raw::c_int, + pub height: ::std::os::raw::c_int, + } + #[test] + fn bindgen_test_layout_nsSize() { + const UNINIT: ::std::mem::MaybeUninit = ::std::mem::MaybeUninit::uninit(); + let ptr = UNINIT.as_ptr(); + assert_eq!( + ::std::mem::size_of:: < nsSize > (), 8usize, concat!("Size of: ", + stringify!(nsSize)) + ); + assert_eq!( + ::std::mem::align_of:: < nsSize > (), 4usize, concat!("Alignment of ", + stringify!(nsSize)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((* ptr).width) as usize - ptr as usize }, + 0usize, concat!("Offset of field: ", stringify!(nsSize), "::", + stringify!(width)) + ); + assert_eq!( + unsafe { ::std::ptr::addr_of!((* ptr).height) as usize - ptr as usize }, + 4usize, concat!("Offset of field: ", stringify!(nsSize), "::", + stringify!(height)) + ); + } + pub mod foo { + #[allow(unused_imports)] + use self::super::super::root; + extern "C" { + #[link_name = "\u{1}_ZN3fooL22kFallbackIntrinsicSizeE"] + pub static kFallbackIntrinsicSize: root::nsSize; + } + } +} diff --git a/bindgen-tests/tests/headers/issue-2556.h b/bindgen-tests/tests/headers/issue-2556.h index bbb1b874ec..88a559e191 100644 --- a/bindgen-tests/tests/headers/issue-2556.h +++ b/bindgen-tests/tests/headers/issue-2556.h @@ -1,4 +1,4 @@ -// bindgen-flags: --enable-cxx-namespaces -- -x c++ -Itests/headers -include tests/headers/issue-2556/nsStyleStruct.h -include tests/headers/issue-2556/LayoutConstants.h +// bindgen-flags: --enable-cxx-namespaces -- -x c++ -std=c++11 -Itests/headers -include tests/headers/issue-2556/nsStyleStruct.h -include tests/headers/issue-2556/LayoutConstants.h #include "issue-2556/nsSize.h" #include "issue-2556/nsStyleStruct.h"