| ... | @@ -476,7 +476,8 @@ static void destroy_instruction_src(IrInstSrc *inst) { | ... | @@ -476,7 +476,8 @@ static void destroy_instruction_src(IrInstSrc *inst) { |
| 476 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcIntToErr *>(inst)); | 476 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcIntToErr *>(inst)); |
| 477 | case IrInstSrcIdErrToInt: | 477 | case IrInstSrcIdErrToInt: |
| 478 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcErrToInt *>(inst)); | 478 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcErrToInt *>(inst)); |
| 479 | case IrInstSrcIdCheckSwitchProngs: | 479 | case IrInstSrcIdCheckSwitchProngsUnderNo: |
| | 480 | case IrInstSrcIdCheckSwitchProngsUnderYes: |
| 480 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCheckSwitchProngs *>(inst)); | 481 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCheckSwitchProngs *>(inst)); |
| 481 | case IrInstSrcIdCheckStatementIsVoid: | 482 | case IrInstSrcIdCheckStatementIsVoid: |
| 482 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCheckStatementIsVoid *>(inst)); | 483 | return heap::c_allocator.destroy(reinterpret_cast<IrInstSrcCheckStatementIsVoid *>(inst)); |
| ... | @@ -1471,10 +1472,6 @@ static constexpr IrInstSrcId ir_inst_id(IrInstSrcErrToInt *) { | ... | @@ -1471,10 +1472,6 @@ static constexpr IrInstSrcId ir_inst_id(IrInstSrcErrToInt *) { |
| 1471 | return IrInstSrcIdErrToInt; | 1472 | return IrInstSrcIdErrToInt; |
| 1472 | } | 1473 | } |
| 1473 | | 1474 | |
| 1474 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCheckSwitchProngs *) { | | |
| 1475 | return IrInstSrcIdCheckSwitchProngs; | | |
| 1476 | } | | |
| 1477 | | | |
| 1478 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCheckStatementIsVoid *) { | 1475 | static constexpr IrInstSrcId ir_inst_id(IrInstSrcCheckStatementIsVoid *) { |
| 1479 | return IrInstSrcIdCheckStatementIsVoid; | 1476 | return IrInstSrcIdCheckStatementIsVoid; |
| 1480 | } | 1477 | } |
| ... | @@ -4351,13 +4348,19 @@ static IrInstSrc *ir_build_check_switch_prongs(IrBuilderSrc *irb, Scope *scope, | ... | @@ -4351,13 +4348,19 @@ static IrInstSrc *ir_build_check_switch_prongs(IrBuilderSrc *irb, Scope *scope, |
| 4351 | IrInstSrc *target_value, IrInstSrcCheckSwitchProngsRange *ranges, size_t range_count, | 4348 | IrInstSrc *target_value, IrInstSrcCheckSwitchProngsRange *ranges, size_t range_count, |
| 4352 | AstNode* else_prong, bool have_underscore_prong) | 4349 | AstNode* else_prong, bool have_underscore_prong) |
| 4353 | { | 4350 | { |
| 4354 | IrInstSrcCheckSwitchProngs *instruction = ir_build_instruction<IrInstSrcCheckSwitchProngs>( | 4351 | IrInstSrcCheckSwitchProngs *instruction = heap::c_allocator.create<IrInstSrcCheckSwitchProngs>(); |
| 4355 | irb, scope, source_node); | 4352 | instruction->base.id = have_underscore_prong ? |
| | 4353 | IrInstSrcIdCheckSwitchProngsUnderYes : IrInstSrcIdCheckSwitchProngsUnderNo; |
| | 4354 | instruction->base.base.scope = scope; |
| | 4355 | instruction->base.base.source_node = source_node; |
| | 4356 | instruction->base.base.debug_id = exec_next_debug_id(irb->exec); |
| | 4357 | instruction->base.owner_bb = irb->current_basic_block; |
| | 4358 | ir_instruction_append(irb->current_basic_block, &instruction->base); |
| | 4359 | |
| 4356 | instruction->target_value = target_value; | 4360 | instruction->target_value = target_value; |
| 4357 | instruction->ranges = ranges; | 4361 | instruction->ranges = ranges; |
| 4358 | instruction->range_count = range_count; | 4362 | instruction->range_count = range_count; |
| 4359 | instruction->else_prong = else_prong; | 4363 | instruction->else_prong = else_prong; |
| 4360 | instruction->have_underscore_prong = have_underscore_prong; | | |
| 4361 | | 4364 | |
| 4362 | ir_ref_instruction(target_value, irb->current_basic_block); | 4365 | ir_ref_instruction(target_value, irb->current_basic_block); |
| 4363 | for (size_t i = 0; i < range_count; i += 1) { | 4366 | for (size_t i = 0; i < range_count; i += 1) { |
| ... | @@ -29706,7 +29709,7 @@ static IrInstGen *ir_analyze_instruction_test_comptime(IrAnalyze *ira, IrInstSrc | ... | @@ -29706,7 +29709,7 @@ static IrInstGen *ir_analyze_instruction_test_comptime(IrAnalyze *ira, IrInstSrc |
| 29706 | } | 29709 | } |
| 29707 | | 29710 | |
| 29708 | static IrInstGen *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | 29711 | static IrInstGen *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 29709 | IrInstSrcCheckSwitchProngs *instruction) | 29712 | IrInstSrcCheckSwitchProngs *instruction, bool have_underscore_prong) |
| 29710 | { | 29713 | { |
| 29711 | IrInstGen *target_value = instruction->target_value->child; | 29714 | IrInstGen *target_value = instruction->target_value->child; |
| 29712 | ZigType *switch_type = target_value->value->type; | 29715 | ZigType *switch_type = target_value->value->type; |
| ... | @@ -29771,7 +29774,7 @@ static IrInstGen *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, | ... | @@ -29771,7 +29774,7 @@ static IrInstGen *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, |
| 29771 | bigint_incr(&field_index); | 29774 | bigint_incr(&field_index); |
| 29772 | } | 29775 | } |
| 29773 | } | 29776 | } |
| 29774 | if (instruction->have_underscore_prong) { | 29777 | if (have_underscore_prong) { |
| 29775 | if (!switch_type->data.enumeration.non_exhaustive) { | 29778 | if (!switch_type->data.enumeration.non_exhaustive) { |
| 29776 | ir_add_error(ira, &instruction->base.base, | 29779 | ir_add_error(ira, &instruction->base.base, |
| 29777 | buf_sprintf("switch on exhaustive enum has `_` prong")); | 29780 | buf_sprintf("switch on exhaustive enum has `_` prong")); |
| ... | @@ -32347,8 +32350,10 @@ static IrInstGen *ir_analyze_instruction_base(IrAnalyze *ira, IrInstSrc *instruc | ... | @@ -32347,8 +32350,10 @@ static IrInstGen *ir_analyze_instruction_base(IrAnalyze *ira, IrInstSrc *instruc |
| 32347 | return ir_analyze_instruction_fn_proto(ira, (IrInstSrcFnProto *)instruction); | 32350 | return ir_analyze_instruction_fn_proto(ira, (IrInstSrcFnProto *)instruction); |
| 32348 | case IrInstSrcIdTestComptime: | 32351 | case IrInstSrcIdTestComptime: |
| 32349 | return ir_analyze_instruction_test_comptime(ira, (IrInstSrcTestComptime *)instruction); | 32352 | return ir_analyze_instruction_test_comptime(ira, (IrInstSrcTestComptime *)instruction); |
| 32350 | case IrInstSrcIdCheckSwitchProngs: | 32353 | case IrInstSrcIdCheckSwitchProngsUnderNo: |
| 32351 | return ir_analyze_instruction_check_switch_prongs(ira, (IrInstSrcCheckSwitchProngs *)instruction); | 32354 | return ir_analyze_instruction_check_switch_prongs(ira, (IrInstSrcCheckSwitchProngs *)instruction, false); |
| | 32355 | case IrInstSrcIdCheckSwitchProngsUnderYes: |
| | 32356 | return ir_analyze_instruction_check_switch_prongs(ira, (IrInstSrcCheckSwitchProngs *)instruction, true); |
| 32352 | case IrInstSrcIdCheckStatementIsVoid: | 32357 | case IrInstSrcIdCheckStatementIsVoid: |
| 32353 | return ir_analyze_instruction_check_statement_is_void(ira, (IrInstSrcCheckStatementIsVoid *)instruction); | 32358 | return ir_analyze_instruction_check_statement_is_void(ira, (IrInstSrcCheckStatementIsVoid *)instruction); |
| 32354 | case IrInstSrcIdDeclRef: | 32359 | case IrInstSrcIdDeclRef: |
| ... | @@ -32745,7 +32750,8 @@ bool ir_inst_src_has_side_effects(IrInstSrc *instruction) { | ... | @@ -32745,7 +32750,8 @@ bool ir_inst_src_has_side_effects(IrInstSrc *instruction) { |
| 32745 | case IrInstSrcIdMemcpy: | 32750 | case IrInstSrcIdMemcpy: |
| 32746 | case IrInstSrcIdBreakpoint: | 32751 | case IrInstSrcIdBreakpoint: |
| 32747 | case IrInstSrcIdOverflowOp: // TODO when we support multiple returns this can be side effect free | 32752 | case IrInstSrcIdOverflowOp: // TODO when we support multiple returns this can be side effect free |
| 32748 | case IrInstSrcIdCheckSwitchProngs: | 32753 | case IrInstSrcIdCheckSwitchProngsUnderNo: |
| | 32754 | case IrInstSrcIdCheckSwitchProngsUnderYes: |
| 32749 | case IrInstSrcIdCheckStatementIsVoid: | 32755 | case IrInstSrcIdCheckStatementIsVoid: |
| 32750 | case IrInstSrcIdCheckRuntimeScope: | 32756 | case IrInstSrcIdCheckRuntimeScope: |
| 32751 | case IrInstSrcIdPanic: | 32757 | case IrInstSrcIdPanic: |