diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-07-22 13:04:22 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-07-22 13:04:22 -0400 |
| commit | 650e07ebd96d6c476cadc1f7c19856e950ceef9c (patch) | |
| tree | 67135acf7f3b8e2d83fc80b2d60feef5e5a521cf /src/ir.cpp | |
| parent | 5b69a9cd83d3ec7d3e54ac4c2c4635838aafe0de (diff) | |
| download | zig-650e07ebd96d6c476cadc1f7c19856e950ceef9c.tar.gz zig-650e07ebd96d6c476cadc1f7c19856e950ceef9c.zip | |
fix suspend at end of function
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index d0a11c2f1e..6f9f582c6f 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -3212,7 +3212,6 @@ static IrInstruction *ir_build_suspend_br(IrBuilder *irb, Scope *scope, AstNode IrBasicBlock *resume_block) { IrInstructionSuspendBr *instruction = ir_build_instruction<IrInstructionSuspendBr>(irb, scope, source_node); - instruction->base.value.type = irb->codegen->builtin_types.entry_unreachable; instruction->resume_block = resume_block; ir_ref_bb(resume_block); @@ -7744,6 +7743,7 @@ static IrInstruction *ir_gen_suspend(IrBuilder *irb, Scope *parent_scope, AstNod } IrInstruction *result = ir_build_suspend_br(irb, parent_scope, node, resume_block); + result->value.type = irb->codegen->builtin_types.entry_void; ir_set_cursor_at_end_and_append_block(irb, resume_block); return result; } @@ -10279,7 +10279,7 @@ static IrBasicBlock *ir_get_new_bb_runtime(IrAnalyze *ira, IrBasicBlock *old_bb, } static void ir_start_bb(IrAnalyze *ira, IrBasicBlock *old_bb, IrBasicBlock *const_predecessor_bb) { - ir_assert(!old_bb->suspended, old_bb->instruction_list.at(0)); + ir_assert(!old_bb->suspended, (old_bb->instruction_list.length != 0) ? old_bb->instruction_list.at(0) : nullptr); ira->instruction_index = 0; ira->old_irb.current_basic_block = old_bb; ira->const_predecessor_bb = const_predecessor_bb; @@ -22547,7 +22547,7 @@ static IrInstruction *ir_analyze_instruction_check_statement_is_void(IrAnalyze * if (type_is_invalid(statement_type)) return ira->codegen->invalid_instruction; - if (statement_type->id != ZigTypeIdVoid) { + if (statement_type->id != ZigTypeIdVoid && statement_type->id != ZigTypeIdUnreachable) { ir_add_error(ira, &instruction->base, buf_sprintf("expression value is ignored")); } @@ -24147,6 +24147,7 @@ static IrInstruction *ir_analyze_instruction_suspend_br(IrAnalyze *ira, IrInstru IrInstruction *result = ir_build_suspend_br(&ira->new_irb, instruction->base.scope, instruction->base.source_node, new_bb); + result->value.type = ira->codegen->builtin_types.entry_unreachable; return ir_finish_anal(ira, result); } |
