summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/parser.rs10
-rw-r--r--src/types.rs7
-rw-r--r--tests/expectations/template.rs27
-rw-r--r--tests/headers/template.hpp26
4 files changed, 63 insertions, 7 deletions
diff --git a/src/parser.rs b/src/parser.rs
index 1a740bd6..3fc03d57 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -360,8 +360,18 @@ fn conv_decl_ty_resolving_typedefs(ctx: &mut ClangParserCtx,
// it's important not to override
if !args.is_empty() {
ci.borrow_mut().args = args;
+ // XXX: This is a super-dumb way to get the spesialisation,
+ // but it seems to be the only one that'd work here...
+ cursor.visit(|c, _: &Cursor| {
+ if c.kind() == CXCursor_TemplateRef {
+ let decl = decl_name(ctx, &c.referenced());
+ ci.borrow_mut().ref_template = Some(decl.to_type());
+ }
+ CXChildVisit_Continue
+ });
}
+
TComp(ci)
}
CXCursor_EnumDecl => {
diff --git a/src/types.rs b/src/types.rs
index 5bf8693d..cc335d41 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -538,7 +538,6 @@ impl CompInfo {
}
}
- // We only
pub fn can_derive_copy(&self) -> bool {
match self.kind {
CompKind::Union => true,
@@ -547,12 +546,6 @@ impl CompInfo {
return false;
}
- // Anything not destructible and with template parameters
- // is copiable
- if self.args.is_empty() {
- return true;
- }
-
// With template args, use a safe subset of the types,
// since copyability depends on the types itself.
self.ref_template.as_ref().map_or(true, |t| t.can_derive_copy()) &&
diff --git a/tests/expectations/template.rs b/tests/expectations/template.rs
index d3200440..63f2d952 100644
--- a/tests/expectations/template.rs
+++ b/tests/expectations/template.rs
@@ -47,6 +47,33 @@ fn bindgen_test_layout_Struct_RootedContainer() {
assert_eq!(::std::mem::size_of::<Struct_RootedContainer>() , 24usize);
assert_eq!(::std::mem::align_of::<Struct_RootedContainer>() , 8usize);
}
+pub type WithDtorIntFwd = Struct_WithDtor<::std::os::raw::c_int>;
+#[repr(C)]
+#[derive(Debug)]
+pub struct Struct_WithDtor<T> {
+ pub member: T,
+}
+#[repr(C)]
+#[derive(Debug)]
+pub struct Struct_PODButContainsDtor {
+ pub member: WithDtorIntFwd,
+}
+#[test]
+fn bindgen_test_layout_Struct_PODButContainsDtor() {
+ assert_eq!(::std::mem::size_of::<Struct_PODButContainsDtor>() , 4usize);
+ assert_eq!(::std::mem::align_of::<Struct_PODButContainsDtor>() , 4usize);
+}
+#[repr(C)]
+pub struct Opaque;
+#[repr(C)]
+pub struct Struct_POD {
+ pub opaque_member: u32,
+}
+#[test]
+fn bindgen_test_layout_Struct_POD() {
+ assert_eq!(::std::mem::size_of::<Struct_POD>() , 4usize);
+ assert_eq!(::std::mem::align_of::<Struct_POD>() , 4usize);
+}
extern "C" {
#[link_name = "_Z3bar3FooIiiE"]
pub fn bar(foo: Struct_Foo<::std::os::raw::c_int, ::std::os::raw::c_int>);
diff --git a/tests/headers/template.hpp b/tests/headers/template.hpp
index d70459ad..e53ecbc8 100644
--- a/tests/headers/template.hpp
+++ b/tests/headers/template.hpp
@@ -29,3 +29,29 @@ class Rooted {
class RootedContainer {
Rooted<void*> root;
};
+
+template<typename T>
+class WithDtor;
+
+typedef WithDtor<int> WithDtorIntFwd;
+
+template<typename T>
+class WithDtor {
+ T member;
+ ~WithDtor() {}
+};
+
+class PODButContainsDtor {
+ WithDtorIntFwd member;
+};
+
+
+/** <div rustbindgen opaque> */
+template<typename T>
+class Opaque {
+ T member;
+};
+
+class POD {
+ Opaque<int> opaque_member;
+};