diff --git a/gen/statements.c b/gen/statements.c index 739f4dba..1028a7f3 100644 --- a/gen/statements.c +++ b/gen/statements.c @@ -128,7 +128,7 @@ void ReturnStatement::toIR(IRState* p) new llvm::ReturnInst(p->scopebb()); } else { - new llvm::BranchInst(fin.back().bb); + new llvm::BranchInst(fin.back().bb, p->scopebb()); fin.back().ret = true; } } diff --git a/test/bug45.d b/test/bug45.d new file mode 100644 index 00000000..b873089c --- /dev/null +++ b/test/bug45.d @@ -0,0 +1,11 @@ +module bug45; + +void foo() { + int bar; + scope(exit) { bar++; } + if (bar) return; +} + +void main() { + foo(); +}