Redefine how union tag size is calculated to match alignment of the union

This commit is contained in:
gingerBill
2018-11-29 23:00:16 +00:00
parent 008d8f25c8
commit 784c48c9e3
2 changed files with 17 additions and 0 deletions
+2
View File
@@ -7028,6 +7028,8 @@ irAddr ir_build_addr(irProcedure *proc, Ast *expr) {
Type *fet = ir_type(field_expr);
// HACK TODO(bill): THIS IS A MASSIVE HACK!!!!
if (is_type_union(ft) && !are_types_identical(fet, ft) && !is_type_untyped(fet)) {
GB_ASSERT_MSG(union_variant_index(ft, fet) > 0, "%s", type_to_string(fet));
irValue *gep = ir_emit_struct_ep(proc, v, cast(i32)index);
ir_emit_store_union_variant(proc, gep, field_expr, fet);
} else {