summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbindgen/src/ir/comp.rs4
-rw-r--r--libbindgen/src/ir/item.rs3
-rw-r--r--libbindgen/tests/expectations/tests/var-tracing.rs48
-rw-r--r--libbindgen/tests/headers/var-tracing.hpp10
4 files changed, 65 insertions, 0 deletions
diff --git a/libbindgen/src/ir/comp.rs b/libbindgen/src/ir/comp.rs
index 70dfd4a6..6dfa1ece 100644
--- a/libbindgen/src/ir/comp.rs
+++ b/libbindgen/src/ir/comp.rs
@@ -971,6 +971,10 @@ impl TypeCollector for CompInfo {
types.insert(ty);
}
+ for &var in self.inner_vars() {
+ types.insert(var);
+ }
+
// FIXME(emilio): Methods, VTable?
}
}
diff --git a/libbindgen/src/ir/item.rs b/libbindgen/src/ir/item.rs
index 3810bc2f..df8fd222 100644
--- a/libbindgen/src/ir/item.rs
+++ b/libbindgen/src/ir/item.rs
@@ -202,6 +202,9 @@ impl TypeCollector for Item {
// be opaque, so we trace across it.
types.insert(fun.signature());
}
+ ItemKind::Var(ref var) => {
+ types.insert(var.ty());
+ }
_ => {} // FIXME.
}
}
diff --git a/libbindgen/tests/expectations/tests/var-tracing.rs b/libbindgen/tests/expectations/tests/var-tracing.rs
new file mode 100644
index 00000000..75c5ebe3
--- /dev/null
+++ b/libbindgen/tests/expectations/tests/var-tracing.rs
@@ -0,0 +1,48 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Bar {
+ pub m_baz: ::std::os::raw::c_int,
+}
+#[test]
+fn bindgen_test_layout_Bar() {
+ assert_eq!(::std::mem::size_of::<Bar>() , 4usize);
+ assert_eq!(::std::mem::align_of::<Bar>() , 4usize);
+}
+extern "C" {
+ #[link_name = "_ZN3BarC1Ei"]
+ pub fn Bar_Bar(this: *mut Bar, baz: ::std::os::raw::c_int);
+}
+impl Clone for Bar {
+ fn clone(&self) -> Self { *self }
+}
+impl Bar {
+ #[inline]
+ pub unsafe fn new(baz: ::std::os::raw::c_int) -> Self {
+ let mut __bindgen_tmp = ::std::mem::uninitialized();
+ Bar_Bar(&mut __bindgen_tmp, baz);
+ __bindgen_tmp
+ }
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct Baz {
+ pub _address: u8,
+}
+extern "C" {
+ #[link_name = "_ZN3Baz3FOOE"]
+ pub static mut Baz_FOO: *const Bar;
+}
+#[test]
+fn bindgen_test_layout_Baz() {
+ assert_eq!(::std::mem::size_of::<Baz>() , 1usize);
+ assert_eq!(::std::mem::align_of::<Baz>() , 1usize);
+}
+impl Clone for Baz {
+ fn clone(&self) -> Self { *self }
+}
diff --git a/libbindgen/tests/headers/var-tracing.hpp b/libbindgen/tests/headers/var-tracing.hpp
new file mode 100644
index 00000000..0d0b0cca
--- /dev/null
+++ b/libbindgen/tests/headers/var-tracing.hpp
@@ -0,0 +1,10 @@
+// bindgen-flags: --whitelist-type Baz
+
+struct Bar {
+ const int m_baz;
+ Bar(int baz);
+};
+
+class Baz {
+ static const Bar FOO[];
+};