summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2017-01-29 13:37:07 +0100
committerEmilio Cobos Álvarez <emilio@crisal.io>2017-01-30 00:17:29 +0100
commitfedca4883881b3d589df06a8808fef22ce205808 (patch)
treee88b1005701d46c0271435d79e5e00d0c753733d /tests
parentbe02472fced1b558262c6bbbc0f92f6a0c95ca70 (diff)
Force copy for incomplete arrays.
These aren't extremely great, since this usually requires extra bookkeeping. But C allows it, so let's keep the same semantics.
Diffstat (limited to 'tests')
-rw-r--r--tests/expectations/tests/class.rs15
-rw-r--r--tests/headers/class.hpp5
2 files changed, 20 insertions, 0 deletions
diff --git a/tests/expectations/tests/class.rs b/tests/expectations/tests/class.rs
index 29d1e904..e55a9fe3 100644
--- a/tests/expectations/tests/class.rs
+++ b/tests/expectations/tests/class.rs
@@ -31,6 +31,11 @@ impl <T> ::std::fmt::Debug for __IncompleteArrayField<T> {
fmt.write_str("__IncompleteArrayField")
}
}
+impl <T> ::std::clone::Clone for __IncompleteArrayField<T> {
+ #[inline]
+ fn clone(&self) -> Self { Self::new() }
+}
+impl <T> ::std::marker::Copy for __IncompleteArrayField<T> { }
#[repr(C)]
pub struct __BindgenUnionField<T>(::std::marker::PhantomData<T>);
impl <T> __BindgenUnionField<T> {
@@ -112,6 +117,16 @@ fn bindgen_test_layout_WithDtor() {
assert_eq!(::std::mem::align_of::<WithDtor>() , 4usize);
}
#[repr(C)]
+pub struct IncompleteArrayNonCopiable {
+ pub whatever: *mut ::std::os::raw::c_void,
+ pub incomplete_array: __IncompleteArrayField<C>,
+}
+#[test]
+fn bindgen_test_layout_IncompleteArrayNonCopiable() {
+ assert_eq!(::std::mem::size_of::<IncompleteArrayNonCopiable>() , 8usize);
+ assert_eq!(::std::mem::align_of::<IncompleteArrayNonCopiable>() , 8usize);
+}
+#[repr(C)]
#[derive(Debug, Copy)]
pub struct Union {
pub d: __BindgenUnionField<f32>,
diff --git a/tests/headers/class.hpp b/tests/headers/class.hpp
index 67ecb37b..1de16471 100644
--- a/tests/headers/class.hpp
+++ b/tests/headers/class.hpp
@@ -32,6 +32,11 @@ class WithDtor {
~WithDtor() {}
};
+class IncompleteArrayNonCopiable {
+ void* whatever;
+ C incomplete_array[];
+};
+
union Union {
float d;
int i;