| ... | @@ -2550,8 +2550,8 @@ static Error resolve_union_alignment(CodeGen *g, ZigType *union_type) { | ... | @@ -2550,8 +2550,8 @@ static Error resolve_union_alignment(CodeGen *g, ZigType *union_type) { |
| 2550 | union_type->data.unionation.gen_tag_index = 1; | 2550 | union_type->data.unionation.gen_tag_index = 1; |
| 2551 | } | 2551 | } |
| 2552 | } else { | 2552 | } else { |
| 2553 | assert(most_aligned_union_member != nullptr); | 2553 | union_type->abi_align = most_aligned_union_member? |
| 2554 | union_type->abi_align = most_aligned_union_member->align; | 2554 | most_aligned_union_member->align : 0; |
| 2555 | union_type->data.unionation.gen_union_index = SIZE_MAX; | 2555 | union_type->data.unionation.gen_union_index = SIZE_MAX; |
| 2556 | union_type->data.unionation.gen_tag_index = SIZE_MAX; | 2556 | union_type->data.unionation.gen_tag_index = SIZE_MAX; |
| 2557 | } | 2557 | } |
| ... | @@ -3535,33 +3535,13 @@ static Error resolve_union_zero_bits(CodeGen *g, ZigType *union_type) { | ... | @@ -3535,33 +3535,13 @@ static Error resolve_union_zero_bits(CodeGen *g, ZigType *union_type) { |
| 3535 | union_type->data.unionation.resolve_loop_flag_zero_bits = false; | 3535 | union_type->data.unionation.resolve_loop_flag_zero_bits = false; |
| 3536 | | 3536 | |
| 3537 | union_type->data.unionation.gen_field_count = gen_field_index; | 3537 | union_type->data.unionation.gen_field_count = gen_field_index; |
| 3538 | bool zero_bits = gen_field_index == 0 && (field_count < 2 || !src_have_tag); | 3538 | bool zero_bits = gen_field_index == 0 && |
| | 3539 | (tag_type == nullptr || !type_has_bits(g, tag_type)); |
| 3539 | if (!zero_bits) { | 3540 | if (!zero_bits) { |
| 3540 | union_type->abi_size = SIZE_MAX; | 3541 | union_type->abi_size = SIZE_MAX; |
| 3541 | union_type->size_in_bits = SIZE_MAX; | 3542 | union_type->size_in_bits = SIZE_MAX; |
| 3542 | } | 3543 | } |
| 3543 | | 3544 | |
| 3544 | if (zero_bits) { | | |
| 3545 | // Don't forget to resolve the types for each union member even though | | |
| 3546 | // the type is zero sized. | | |
| 3547 | // XXX: Do it in a nicer way in stage2. | | |
| 3548 | union_type->data.unionation.resolve_loop_flag_other = true; | | |
| 3549 | | | |
| 3550 | for (uint32_t i = 0; i < field_count; i += 1) { | | |
| 3551 | TypeUnionField *union_field = &union_type->data.unionation.fields[i]; | | |
| 3552 | ZigType *field_type = resolve_union_field_type(g, union_field); | | |
| 3553 | if (field_type == nullptr) { | | |
| 3554 | union_type->data.unionation.resolve_status = ResolveStatusInvalid; | | |
| 3555 | return ErrorSemanticAnalyzeFail; | | |
| 3556 | } | | |
| 3557 | } | | |
| 3558 | | | |
| 3559 | union_type->data.unionation.resolve_loop_flag_other = false; | | |
| 3560 | union_type->data.unionation.resolve_status = ResolveStatusSizeKnown; | | |
| 3561 | | | |
| 3562 | return ErrorNone; | | |
| 3563 | } | | |
| 3564 | | | |
| 3565 | union_type->data.unionation.resolve_status = ResolveStatusZeroBitsKnown; | 3545 | union_type->data.unionation.resolve_status = ResolveStatusZeroBitsKnown; |
| 3566 | | 3546 | |
| 3567 | return ErrorNone; | 3547 | return ErrorNone; |
| ... | @@ -8877,6 +8857,9 @@ static void resolve_llvm_types_union(CodeGen *g, ZigType *union_type, ResolveSta | ... | @@ -8877,6 +8857,9 @@ static void resolve_llvm_types_union(CodeGen *g, ZigType *union_type, ResolveSta |
| 8877 | union_type->llvm_type = get_llvm_type(g, tag_type); | 8857 | union_type->llvm_type = get_llvm_type(g, tag_type); |
| 8878 | union_type->llvm_di_type = get_llvm_di_type(g, tag_type); | 8858 | union_type->llvm_di_type = get_llvm_di_type(g, tag_type); |
| 8879 | } | 8859 | } |
| | 8860 | |
| | 8861 | union_type->data.unionation.gen_union_index = SIZE_MAX; |
| | 8862 | union_type->data.unionation.gen_tag_index = SIZE_MAX; |
| 8880 | union_type->data.unionation.resolve_status = ResolveStatusLLVMFull; | 8863 | union_type->data.unionation.resolve_status = ResolveStatusLLVMFull; |
| 8881 | return; | 8864 | return; |
| 8882 | } | 8865 | } |