From 490cafe2c5a62585fd80245a0f6fa5cff4f52dba Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Sun, 25 Oct 2020 23:17:32 +0100 Subject: stage1: Error out when trying to execute `unreachable` Closes #6802 --- src/stage1/ir.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/stage1/ir.cpp b/src/stage1/ir.cpp index 62d466fa88..98422ef578 100644 --- a/src/stage1/ir.cpp +++ b/src/stage1/ir.cpp @@ -21592,6 +21592,11 @@ static IrInstGen *ir_analyze_instruction_cond_br(IrAnalyze *ira, IrInstSrcCondBr static IrInstGen *ir_analyze_instruction_unreachable(IrAnalyze *ira, IrInstSrcUnreachable *unreachable_instruction) { + if (ir_should_inline(ira->old_irb.exec, unreachable_instruction->base.base.scope)) { + ir_add_error(ira, &unreachable_instruction->base.base, buf_sprintf("reached unreachable code")); + return ir_unreach_error(ira); + } + IrInstGen *result = ir_build_unreachable_gen(ira, &unreachable_instruction->base.base); return ir_finish_anal(ira, result); } -- cgit v1.2.3