Mercurial > projects > ldc
diff gen/statements.c @ 78:2332006e1fa4 trunk
[svn r82] Fixed: Fall-through switch cases were broken.
author | lindquist |
---|---|
date | Wed, 31 Oct 2007 20:50:21 +0100 |
parents | b706170e24a9 |
children | 875617f89c51 |
line wrap: on
line diff
--- a/gen/statements.c Wed Oct 31 09:34:18 2007 +0100 +++ b/gen/statements.c Wed Oct 31 20:50:21 2007 +0100 @@ -255,6 +255,7 @@ // create while blocks llvm::BasicBlock* oldend = gIR->scopeend(); llvm::BasicBlock* whilebb = new llvm::BasicBlock("whilecond", gIR->topfunc(), oldend); + llvm::BasicBlock* whilebodybb = new llvm::BasicBlock("whilebody", gIR->topfunc(), oldend); llvm::BasicBlock* endbb = new llvm::BasicBlock("endwhile", gIR->topfunc(), oldend); // move into the while block @@ -269,11 +270,8 @@ llvm::Value* cond_val = LLVM_DtoBoolean(cond_e->getValue()); delete cond_e; - // while body block - llvm::BasicBlock* whilebodybb = new llvm::BasicBlock("whilebody", gIR->topfunc(), endbb); - // conditional branch - llvm::Value* ifbreak = new llvm::BranchInst(whilebodybb, endbb, cond_val, whilebb); + llvm::Value* ifbreak = new llvm::BranchInst(whilebodybb, endbb, cond_val, p->scopebb()); // rewrite scope gIR->scope() = IRScope(whilebodybb,endbb); @@ -580,7 +578,7 @@ p->loopbbs.pop_back(); llvm::BasicBlock* curbb = p->scopebb(); - if (!curbb->empty() && !curbb->back().isTerminator()) + if (curbb->empty() || !curbb->back().isTerminator()) { new llvm::BranchInst(nextbb, curbb); } @@ -591,11 +589,12 @@ { p->scope() = IRScope(defbb,endbb); p->loopbbs.push_back(IRScope(defbb,endbb)); + Logger::println("doing default statement"); sdefault->statement->toIR(p); p->loopbbs.pop_back(); llvm::BasicBlock* curbb = p->scopebb(); - if (!curbb->empty() && !curbb->back().isTerminator()) + if (curbb->empty() || !curbb->back().isTerminator()) { new llvm::BranchInst(endbb, curbb); }