From 03888f4b0766da795e6a2b373ba6d05c0377941c Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Sun, 15 Jun 2008 18:37:23 +0200 Subject: [PATCH] [svn r288] Let return statements start a new basic block after terminating the current one. This fixes problems such as void main() { return; return; } --- gen/statements.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gen/statements.cpp b/gen/statements.cpp index 88eab17e..5c8a706a 100644 --- a/gen/statements.cpp +++ b/gen/statements.cpp @@ -140,6 +140,11 @@ void ReturnStatement::toIR(IRState* p) if (global.params.symdebug) DtoDwarfFuncEnd(p->func()->decl); llvm::ReturnInst::Create(p->scopebb()); } + + // the return terminated this basicblock, start a new one + llvm::BasicBlock* oldend = gIR->scopeend(); + llvm::BasicBlock* bb = llvm::BasicBlock::Create("afterreturn", p->topfunc(), oldend); + p->scope() = IRScope(bb,oldend); } //////////////////////////////////////////////////////////////////////////////