authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-11-25 22:13:40+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-11-26 11:50:38-07:00
log36b8f5d194c1c88e25eee3da111000edbe9eb3ea
treead101a07d263219553def0715654771f15bc18a1
parent41d57b051ff9924da985cd0c2334fa2ae719d306

stage1: Force union member types to be resolved

No test case because I couldn't reduce the huuuge test case. Fixes the problem discovered by @ifreund.

1 files changed, 23 insertions(+), 1 deletions(-)

src/stage1/analyze.cpp+23-1
......@@ -3484,7 +3484,29 @@ static Error resolve_union_zero_bits(CodeGen *g, ZigType *union_type) {
34843484 union_type->abi_size = SIZE_MAX;
34853485 union_type->size_in_bits = SIZE_MAX;
34863486 }
3487 union_type->data.unionation.resolve_status = zero_bits ? ResolveStatusSizeKnown : ResolveStatusZeroBitsKnown;
3487
3488 if (zero_bits) {
3489 // Don't forget to resolve the types for each union member even though
3490 // the type is zero sized.
3491 // XXX: Do it in a nicer way in stage2.
3492 union_type->data.unionation.resolve_loop_flag_other = true;
3493
3494 for (uint32_t i = 0; i < field_count; i += 1) {
3495 TypeUnionField *union_field = &union_type->data.unionation.fields[i];
3496 ZigType *field_type = resolve_union_field_type(g, union_field);
3497 if (field_type == nullptr) {
3498 union_type->data.unionation.resolve_status = ResolveStatusInvalid;
3499 return ErrorSemanticAnalyzeFail;
3500 }
3501 }
3502
3503 union_type->data.unionation.resolve_loop_flag_other = false;
3504 union_type->data.unionation.resolve_status = ResolveStatusSizeKnown;
3505
3506 return ErrorNone;
3507 }
3508
3509 union_type->data.unionation.resolve_status = ResolveStatusZeroBitsKnown;
34883510
34893511 return ErrorNone;
34903512}