Add support for zero sized types

This commit is contained in:
Dennis 2022-04-27 14:25:26 +02:00 committed by Eduard-Mihai Burtescu
parent b0328ed454
commit 03f89e8ba6
2 changed files with 21 additions and 0 deletions

View File

@ -412,6 +412,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
if field_ty_kind
.sizeof(self)
.map_or(true, |size| offset_in_field < size)
// If the field is a zero sized type, check the type to
// get the correct entry
|| offset_in_field == Size::ZERO && leaf_ty == field_ty
{
Some((i, field_ty, field_ty_kind, offset_in_field))
} else {

View File

@ -0,0 +1,18 @@
// build-pass
use spirv_std as _;
struct A;
struct B;
struct S {
x: A,
y: B,
}
fn f(x: &B) {}
#[spirv(fragment)]
pub fn main() {
let s = S { x: A, y: B };
f(&s.y);
}