summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Finkenauer <tmfinken@gmail.com>2017-06-18 20:08:59 -0700
committerTravis Finkenauer <tmfinken@gmail.com>2017-06-18 20:08:59 -0700
commit465e242752109591f6d8986c31761dda97ab43c7 (patch)
tree2fbbdc1f3f7ca7dc6e27e0f725c5f02372531312
parent4b10529701f89cc523c932bfe1a160864b3061ae (diff)
Test const mod enum variants shadowing "Type"
-rw-r--r--tests/expectations/tests/constify-module-enums-shadow-name.rs36
-rw-r--r--tests/headers/constify-module-enums-shadow-name.h12
2 files changed, 48 insertions, 0 deletions
diff --git a/tests/expectations/tests/constify-module-enums-shadow-name.rs b/tests/expectations/tests/constify-module-enums-shadow-name.rs
new file mode 100644
index 00000000..9b5fd7b8
--- /dev/null
+++ b/tests/expectations/tests/constify-module-enums-shadow-name.rs
@@ -0,0 +1,36 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
+
+
+pub mod foo {
+ pub type Type = ::std::os::raw::c_uint;
+ pub const Type: Type = 0;
+ pub const Type_: Type = 1;
+ pub const Type1: Type = 2;
+ pub const Type__: Type = 3;
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct bar {
+ pub member: foo::Type,
+}
+#[test]
+fn bindgen_test_layout_bar() {
+ assert_eq!(::std::mem::size_of::<bar>() , 4usize , concat ! (
+ "Size of: " , stringify ! ( bar ) ));
+ assert_eq! (::std::mem::align_of::<bar>() , 4usize , concat ! (
+ "Alignment of " , stringify ! ( bar ) ));
+ assert_eq! (unsafe {
+ & ( * ( 0 as * const bar ) ) . member as * const _ as usize }
+ , 0usize , concat ! (
+ "Alignment of field: " , stringify ! ( bar ) , "::" ,
+ stringify ! ( member ) ));
+}
+impl Clone for bar {
+ fn clone(&self) -> Self { *self }
+}
+impl Default for bar {
+ fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+}
diff --git a/tests/headers/constify-module-enums-shadow-name.h b/tests/headers/constify-module-enums-shadow-name.h
new file mode 100644
index 00000000..38b26106
--- /dev/null
+++ b/tests/headers/constify-module-enums-shadow-name.h
@@ -0,0 +1,12 @@
+// bindgen-flags: --constified-enum-module foo
+
+enum foo {
+ Type,
+ Type_,
+ Type1,
+ Type__,
+};
+
+struct bar {
+ enum foo member;
+};