| author | |
| committer | |
| log | 697c768730ad4c095c376079adbb97854db84cb9 |
| tree | aee759024d7e31fce2c70b076b0574848d605b95 |
| parent | bbf785bc1d5740488521b0cb90eeae31090e67ae |
2 files changed, 34 insertions(+), 2 deletions(-)
src/ir.cpp+3-2| ... | ... | @@ -630,6 +630,7 @@ static IrInstruction *ir_build_phi(IrBuilder *irb, AstNode *source_node, |
| 630 | 630 | phi_instruction->incoming_values = incoming_values; |
| 631 | 631 | |
| 632 | 632 | for (size_t i = 0; i < incoming_count; i += 1) { |
| 633 | ir_ref_bb(incoming_blocks[i]); | |
| 633 | 634 | ir_ref_instruction(incoming_values[i]); |
| 634 | 635 | } |
| 635 | 636 | |
| ... | ... | @@ -2784,8 +2785,8 @@ static void ir_start_bb(IrAnalyze *ira, IrBasicBlock *old_bb, IrBasicBlock *cons |
| 2784 | 2785 | ira->old_irb.current_basic_block = old_bb; |
| 2785 | 2786 | ira->const_predecessor_bb = const_predecessor_bb; |
| 2786 | 2787 | |
| 2787 | assert(old_bb->other); | |
| 2788 | ira->new_irb.exec->basic_block_list.append(old_bb->other); | |
| 2788 | if (old_bb->other) | |
| 2789 | ira->new_irb.exec->basic_block_list.append(old_bb->other); | |
| 2789 | 2790 | } |
| 2790 | 2791 | |
| 2791 | 2792 | static void ir_finish_bb(IrAnalyze *ira) { |
test/self_hosted2.zig+31| ... | ... | @@ -20,6 +20,35 @@ fn inlinedLoop() { |
| 20 | 20 | assert(sum == 15); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | fn switchWithNumbers() { | |
| 24 | testSwitchWithNumbers(13); | |
| 25 | } | |
| 26 | ||
| 27 | fn testSwitchWithNumbers(x: u32) { | |
| 28 | const result = switch (x) { | |
| 29 | 1, 2, 3, 4 ... 8 => false, | |
| 30 | 13 => true, | |
| 31 | else => false, | |
| 32 | }; | |
| 33 | assert(result); | |
| 34 | } | |
| 35 | ||
| 36 | fn switchWithAllRanges() { | |
| 37 | assert(testSwitchWithAllRanges(50, 3) == 1); | |
| 38 | assert(testSwitchWithAllRanges(101, 0) == 2); | |
| 39 | assert(testSwitchWithAllRanges(300, 5) == 3); | |
| 40 | assert(testSwitchWithAllRanges(301, 6) == 6); | |
| 41 | } | |
| 42 | ||
| 43 | fn testSwitchWithAllRanges(x: u32, y: u32) -> u32 { | |
| 44 | switch (x) { | |
| 45 | 0 ... 100 => 1, | |
| 46 | 101 ... 200 => 2, | |
| 47 | 201 ... 300 => 3, | |
| 48 | else => y, | |
| 49 | } | |
| 50 | } | |
| 51 | ||
| 23 | 52 | fn assert(ok: bool) { |
| 24 | 53 | if (!ok) |
| 25 | 54 | @unreachable(); |
| ... | ... | @@ -29,6 +58,8 @@ fn runAllTests() { |
| 29 | 58 | emptyFunctionWithComments(); |
| 30 | 59 | disabledExternFn(); |
| 31 | 60 | inlinedLoop(); |
| 61 | switchWithNumbers(); | |
| 62 | switchWithAllRanges(); | |
| 32 | 63 | } |
| 33 | 64 | |
| 34 | 65 | export nakedcc fn _start() -> unreachable { |