summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2017-05-08 22:56:41 +0200
committerEmilio Cobos Álvarez <emilio@crisal.io>2017-05-08 23:00:20 +0200
commit912f4a6a11573ee08b5e83f9aa6c060ca0bec413 (patch)
tree48dab808c65bb3348bcf2c2c1c9517c5b2f0c44c
parent12f985283f30dc9867d0b608f2bbf3007f0898b3 (diff)
ir: Don't assume template instantiation argument with vtable implies vtable.
-rw-r--r--src/ir/template.rs3
-rw-r--r--tests/expectations/tests/issue-691-template-parameter-virtual.rs60
-rw-r--r--tests/headers/issue-691-template-parameter-virtual.hpp12
3 files changed, 73 insertions, 2 deletions
diff --git a/src/ir/template.rs b/src/ir/template.rs
index d2996330..5861929f 100644
--- a/src/ir/template.rs
+++ b/src/ir/template.rs
@@ -279,8 +279,7 @@ impl TemplateInstantiation {
/// Does this instantiation have a vtable?
pub fn has_vtable(&self, ctx: &BindgenContext) -> bool {
- ctx.resolve_type(self.definition).has_vtable(ctx) ||
- self.args.iter().any(|arg| ctx.resolve_type(*arg).has_vtable(ctx))
+ ctx.resolve_type(self.definition).has_vtable(ctx)
}
/// Does this instantiation have a destructor?
diff --git a/tests/expectations/tests/issue-691-template-parameter-virtual.rs b/tests/expectations/tests/issue-691-template-parameter-virtual.rs
new file mode 100644
index 00000000..8333f1f7
--- /dev/null
+++ b/tests/expectations/tests/issue-691-template-parameter-virtual.rs
@@ -0,0 +1,60 @@
+/* automatically generated by rust-bindgen */
+
+
+#![allow(non_snake_case)]
+
+
+#[repr(C)]
+pub struct VirtualMethods__bindgen_vtable(::std::os::raw::c_void);
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct VirtualMethods {
+ pub vtable_: *const VirtualMethods__bindgen_vtable,
+}
+#[test]
+fn bindgen_test_layout_VirtualMethods() {
+ assert_eq!(::std::mem::size_of::<VirtualMethods>() , 8usize , concat ! (
+ "Size of: " , stringify ! ( VirtualMethods ) ));
+ assert_eq! (::std::mem::align_of::<VirtualMethods>() , 8usize , concat ! (
+ "Alignment of " , stringify ! ( VirtualMethods ) ));
+}
+impl Clone for VirtualMethods {
+ fn clone(&self) -> Self { *self }
+}
+impl Default for VirtualMethods {
+ fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+}
+#[repr(C)]
+#[derive(Debug, Default, Copy, Clone)]
+pub struct Set {
+ pub bar: ::std::os::raw::c_int,
+}
+#[repr(C)]
+#[derive(Debug, Copy)]
+pub struct ServoElementSnapshotTable {
+ pub _base: Set,
+}
+#[test]
+fn bindgen_test_layout_ServoElementSnapshotTable() {
+ assert_eq!(::std::mem::size_of::<ServoElementSnapshotTable>() , 4usize ,
+ concat ! (
+ "Size of: " , stringify ! ( ServoElementSnapshotTable ) ));
+ assert_eq! (::std::mem::align_of::<ServoElementSnapshotTable>() , 4usize ,
+ concat ! (
+ "Alignment of " , stringify ! ( ServoElementSnapshotTable )
+ ));
+}
+impl Clone for ServoElementSnapshotTable {
+ fn clone(&self) -> Self { *self }
+}
+impl Default for ServoElementSnapshotTable {
+ fn default() -> Self { unsafe { ::std::mem::zeroed() } }
+}
+#[test]
+fn __bindgen_test_layout_Set_instantiation_13() {
+ assert_eq!(::std::mem::size_of::<Set>() , 4usize , concat ! (
+ "Size of template specialization: " , stringify ! ( Set ) ));
+ assert_eq!(::std::mem::align_of::<Set>() , 4usize , concat ! (
+ "Alignment of template specialization: " , stringify ! ( Set )
+ ));
+}
diff --git a/tests/headers/issue-691-template-parameter-virtual.hpp b/tests/headers/issue-691-template-parameter-virtual.hpp
new file mode 100644
index 00000000..f80e058d
--- /dev/null
+++ b/tests/headers/issue-691-template-parameter-virtual.hpp
@@ -0,0 +1,12 @@
+class VirtualMethods {
+ virtual void foo();
+};
+
+template<typename K>
+class Set {
+ int bar;
+};
+
+class ServoElementSnapshotTable
+ : public Set<VirtualMethods>
+{};