type: resolve packed union type layouts in bitSizeAdvanced

Before this change, packed structs containing packed unions could make it to codegen without having their layout resolved.
This commit is contained in:
kcbanner
2023-09-23 13:04:18 -04:00
parent f2a24b48e1
commit 4e9f5f25c8
3 changed files with 8 additions and 4 deletions

View File

@@ -1646,8 +1646,12 @@ pub const Type = struct {
},
.union_type => |union_type| {
if (opt_sema) |sema| try sema.resolveTypeFields(ty);
if (ty.containerLayout(mod) != .Packed) {
const is_packed = ty.containerLayout(mod) == .Packed;
if (opt_sema) |sema| {
try sema.resolveTypeFields(ty);
if (is_packed) try sema.resolveTypeLayout(ty);
}
if (!is_packed) {
return (try ty.abiSizeAdvanced(mod, strat)).scalar * 8;
}
const union_obj = ip.loadUnionType(union_type);