Skip to content

Commit aa9849b

Browse files
committed
codegen: Do generate field offset checks for classes with multiple bases.
The bug only affects virtual inheritance, so instead disable layout tests in the test that we know is broken. Not generating layout tests is wrong anyways, because the offset would be wrong.
1 parent a9d4198 commit aa9849b

File tree

5 files changed

+148
-87
lines changed

5 files changed

+148
-87
lines changed

bindgen-tests/tests/expectations/tests/inherit_multiple_interfaces.rs

+130
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindgen-tests/tests/expectations/tests/virtual_inheritance.rs

-76
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class A {
2+
virtual void Foo();
3+
4+
int member;
5+
};
6+
7+
class B {
8+
virtual void Bar();
9+
10+
void* member2;
11+
};
12+
13+
class C : public A, public B {
14+
float member3;
15+
};

bindgen-tests/tests/headers/virtual_inheritance.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
1+
// bindgen-flags: --no-layout-tests
2+
// FIXME: Enable layout tests when #465 is fixed.
23
class A {
34
int foo;
45
};

bindgen/codegen/mod.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -2193,16 +2193,7 @@ impl CodeGenerator for CompInfo {
21932193
})
21942194
};
21952195

2196-
// FIXME when [issue #465](https://github.com/rust-lang/rust-bindgen/issues/465) ready
2197-
let too_many_base_vtables = self
2198-
.base_members()
2199-
.iter()
2200-
.filter(|base| base.ty.has_vtable(ctx))
2201-
.count() >
2202-
1;
2203-
2204-
let should_skip_field_offset_checks =
2205-
is_opaque || too_many_base_vtables;
2196+
let should_skip_field_offset_checks = is_opaque;
22062197

22072198
let check_field_offset = if should_skip_field_offset_checks
22082199
{

0 commit comments

Comments
 (0)