authorgravatar for thejoshwolfe@gmail.comJosh Wolfe <thejoshwolfe@gmail.com> 2017-04-23 08:34:18-07:00
committergravatar for thejoshwolfe@gmail.comJosh Wolfe <thejoshwolfe@gmail.com> 2017-04-23 08:36:21-07:00
log14dfbd6ad39dadbd8505957b031f67bcd1a7b8a4
tree5aa31909123e29936445082720c9521b6a1c8443
parent8299fe19c056e9bae6f87a8281741d1e90019993

remove redundant unreachable code error


2 files changed, 2 insertions(+), 11 deletions(-)

src/ir.cpp+1-10
...@@ -3387,15 +3387,6 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode...@@ -3387,15 +3387,6 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode
3387 continue;3387 continue;
3388 }3388 }
33893389
3390 if (is_continuation_unreachable) {
3391 // if you put a semicolon after a return statement,
3392 // then we get a void statement in the unreachable area.
3393 // this is fine. ignore any void blocks we get from this happening.
3394 if (statement_node->type == NodeTypeBlock && statement_node->data.block.statements.length == 0)
3395 continue;
3396 add_node_error(irb->codegen, statement_node, buf_sprintf("unreachable code"));
3397 }
3398
3399 IrInstruction *statement_value = ir_gen_node(irb, statement_node, child_scope);3390 IrInstruction *statement_value = ir_gen_node(irb, statement_node, child_scope);
3400 is_continuation_unreachable = instr_is_unreachable(statement_value);3391 is_continuation_unreachable = instr_is_unreachable(statement_value);
3401 if (is_continuation_unreachable)3392 if (is_continuation_unreachable)
...@@ -3411,7 +3402,7 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode...@@ -3411,7 +3402,7 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode
3411 IrInstructionDeclVar *decl_var_instruction = (IrInstructionDeclVar *)statement_value;3402 IrInstructionDeclVar *decl_var_instruction = (IrInstructionDeclVar *)statement_value;
3412 child_scope = decl_var_instruction->var->child_scope;3403 child_scope = decl_var_instruction->var->child_scope;
3413 } else {3404 } else {
3414 // label, defer, variable declaration will never be the last statement3405 // label, defer, variable declaration will never be the result expression
3415 if (block_node->data.block.last_statement_is_result_expression &&3406 if (block_node->data.block.last_statement_is_result_expression &&
3416 i == block_node->data.block.statements.length - 1) {3407 i == block_node->data.block.statements.length - 1) {
3417 // this is the result value statement3408 // this is the result value statement
test/compile_errors.zig+1-1
...@@ -254,7 +254,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) {...@@ -254,7 +254,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) {
254 \\}254 \\}
255 \\255 \\
256 \\fn b() {}256 \\fn b() {}
257 , ".tmp_source.zig:3:6: error: unreachable code");257 , ".tmp_source.zig:3:5: error: unreachable code");
258258
259 cases.add("bad import",259 cases.add("bad import",
260 \\const bogus = @import("bogus-does-not-exist.zig");260 \\const bogus = @import("bogus-does-not-exist.zig");