diff --git a/src/ir/context.rs b/src/ir/context.rs index cc1baf90f9..b2c53aace3 100644 --- a/src/ir/context.rs +++ b/src/ir/context.rs @@ -680,7 +680,8 @@ impl BindgenContext { "where" | "while" | "yield" | - "bool" => true, + "bool" | + "_" => true, _ => false, } { diff --git a/tests/expectations/tests/underscore.rs b/tests/expectations/tests/underscore.rs new file mode 100644 index 0000000000..d1b0ccc23f --- /dev/null +++ b/tests/expectations/tests/underscore.rs @@ -0,0 +1,40 @@ +/* automatically generated by rust-bindgen */ + + +#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] + + +pub const __: ::std::os::raw::c_int = 10; +#[repr(C)] +#[derive(Debug, Default, Copy)] +pub struct ptr_t { + pub __: [::std::os::raw::c_uchar; 8usize], +} +#[test] +fn bindgen_test_layout_ptr_t() { + assert_eq!( + ::std::mem::size_of::(), + 8usize, + concat!("Size of: ", stringify!(ptr_t)) + ); + assert_eq!( + ::std::mem::align_of::(), + 1usize, + concat!("Alignment of ", stringify!(ptr_t)) + ); + assert_eq!( + unsafe { &(*(0 as *const ptr_t)).__ as *const _ as usize }, + 0usize, + concat!( + "Alignment of field: ", + stringify!(ptr_t), + "::", + stringify!(__) + ) + ); +} +impl Clone for ptr_t { + fn clone(&self) -> Self { + *self + } +} diff --git a/tests/headers/underscore.hpp b/tests/headers/underscore.hpp new file mode 100644 index 0000000000..1c9371f123 --- /dev/null +++ b/tests/headers/underscore.hpp @@ -0,0 +1,3 @@ +const int _ = 10; + +typedef struct { unsigned char _[8]; } ptr_t; \ No newline at end of file