diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-03-15 23:52:11 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-03-15 23:52:11 -0400 |
| commit | 4a5cd0b895d0c6093fa710ed4ecb819726b58c25 (patch) | |
| tree | 4f503a89800bb6b7feb75e951fe4f28d7f87e670 /src/ir.cpp | |
| parent | 01fb42103115a58c4b693a600dc5379fedb4ea86 (diff) | |
| download | zig-4a5cd0b895d0c6093fa710ed4ecb819726b58c25.tar.gz zig-4a5cd0b895d0c6093fa710ed4ecb819726b58c25.zip | |
fix while continue block not checking for ignored expression
closes #957
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index dc6118f453..076aadb9c8 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -5462,8 +5462,10 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n IrInstruction *expr_result = ir_gen_node(irb, continue_expr_node, payload_scope); if (expr_result == irb->codegen->invalid_instruction) return expr_result; - if (!instr_is_unreachable(expr_result)) + if (!instr_is_unreachable(expr_result)) { + ir_mark_gen(ir_build_check_statement_is_void(irb, payload_scope, continue_expr_node, expr_result)); ir_mark_gen(ir_build_br(irb, payload_scope, node, cond_block, is_comptime)); + } } ir_set_cursor_at_end_and_append_block(irb, else_block); @@ -5544,8 +5546,10 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n IrInstruction *expr_result = ir_gen_node(irb, continue_expr_node, child_scope); if (expr_result == irb->codegen->invalid_instruction) return expr_result; - if (!instr_is_unreachable(expr_result)) + if (!instr_is_unreachable(expr_result)) { + ir_mark_gen(ir_build_check_statement_is_void(irb, child_scope, continue_expr_node, expr_result)); ir_mark_gen(ir_build_br(irb, child_scope, node, cond_block, is_comptime)); + } } IrInstruction *else_result = nullptr; @@ -5609,8 +5613,10 @@ static IrInstruction *ir_gen_while_expr(IrBuilder *irb, Scope *scope, AstNode *n IrInstruction *expr_result = ir_gen_node(irb, continue_expr_node, subexpr_scope); if (expr_result == irb->codegen->invalid_instruction) return expr_result; - if (!instr_is_unreachable(expr_result)) + if (!instr_is_unreachable(expr_result)) { + ir_mark_gen(ir_build_check_statement_is_void(irb, scope, continue_expr_node, expr_result)); ir_mark_gen(ir_build_br(irb, scope, node, cond_block, is_comptime)); + } } IrInstruction *else_result = nullptr; |
