Skip to content

Commit 24697b9

Browse files
committed
Test typedefed anon structs in C++
1 parent 1aada62 commit 24697b9

File tree

2 files changed

+100
-0
lines changed

2 files changed

+100
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/* automatically generated by rust-bindgen */
2+
3+
4+
#![allow(non_snake_case)]
5+
6+
7+
pub mod root {
8+
#[allow(unused_imports)]
9+
use self::super::root;
10+
pub mod whatever {
11+
#[allow(unused_imports)]
12+
use self::super::super::root;
13+
#[repr(C)]
14+
#[derive(Debug, Default, Copy)]
15+
pub struct _bindgen_ty_1 {
16+
pub foo: ::std::os::raw::c_int,
17+
}
18+
#[test]
19+
fn bindgen_test_layout__bindgen_ty_1() {
20+
assert_eq!(::std::mem::size_of::<_bindgen_ty_1>() , 4usize ,
21+
concat ! ( "Size of: " , stringify ! ( _bindgen_ty_1 )
22+
));
23+
assert_eq! (::std::mem::align_of::<_bindgen_ty_1>() , 4usize ,
24+
concat ! (
25+
"Alignment of " , stringify ! ( _bindgen_ty_1 ) ));
26+
assert_eq! (unsafe {
27+
& ( * ( 0 as * const _bindgen_ty_1 ) ) . foo as *
28+
const _ as usize } , 0usize , concat ! (
29+
"Alignment of field: " , stringify ! ( _bindgen_ty_1 )
30+
, "::" , stringify ! ( foo ) ));
31+
}
32+
impl Clone for _bindgen_ty_1 {
33+
fn clone(&self) -> Self { *self }
34+
}
35+
pub type typedef_struct = root::whatever::_bindgen_ty_1;
36+
pub const whatever_BAR: root::whatever::_bindgen_ty_2 =
37+
_bindgen_ty_2::BAR;
38+
#[repr(u32)]
39+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
40+
pub enum _bindgen_ty_2 { BAR = 1, }
41+
pub use self::super::super::root::whatever::_bindgen_ty_2 as
42+
typedef_enum;
43+
}
44+
pub mod _bindgen_mod_id_12 {
45+
#[allow(unused_imports)]
46+
use self::super::super::root;
47+
#[repr(C)]
48+
#[derive(Debug, Default, Copy)]
49+
pub struct _bindgen_ty_1 {
50+
pub foo: ::std::os::raw::c_int,
51+
}
52+
#[test]
53+
fn bindgen_test_layout__bindgen_ty_1() {
54+
assert_eq!(::std::mem::size_of::<_bindgen_ty_1>() , 4usize ,
55+
concat ! ( "Size of: " , stringify ! ( _bindgen_ty_1 )
56+
));
57+
assert_eq! (::std::mem::align_of::<_bindgen_ty_1>() , 4usize ,
58+
concat ! (
59+
"Alignment of " , stringify ! ( _bindgen_ty_1 ) ));
60+
assert_eq! (unsafe {
61+
& ( * ( 0 as * const _bindgen_ty_1 ) ) . foo as *
62+
const _ as usize } , 0usize , concat ! (
63+
"Alignment of field: " , stringify ! ( _bindgen_ty_1 )
64+
, "::" , stringify ! ( foo ) ));
65+
}
66+
impl Clone for _bindgen_ty_1 {
67+
fn clone(&self) -> Self { *self }
68+
}
69+
pub type typedef_struct = root::_bindgen_mod_id_12::_bindgen_ty_1;
70+
pub const _bindgen_mod_id_12_BAR:
71+
root::_bindgen_mod_id_12::_bindgen_ty_2 =
72+
_bindgen_ty_2::BAR;
73+
#[repr(u32)]
74+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
75+
pub enum _bindgen_ty_2 { BAR = 1, }
76+
pub use self::super::super::root::_bindgen_mod_id_12::_bindgen_ty_2 as
77+
typedef_enum;
78+
}
79+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// bindgen-flags: --enable-cxx-namespaces
2+
3+
namespace whatever {
4+
typedef struct {
5+
int foo;
6+
} typedef_struct;
7+
8+
typedef enum {
9+
BAR=1
10+
} typedef_enum;
11+
}
12+
13+
namespace {
14+
typedef struct {
15+
int foo;
16+
} typedef_struct;
17+
18+
typedef enum {
19+
BAR=1
20+
} typedef_enum;
21+
}

0 commit comments

Comments
 (0)