Reenable error for gotos into or out of finally blocks.

This commit is contained in:
Christian Kamm 2009-03-28 19:16:53 +01:00
parent b2e601bd74
commit 0ef57dcfbe
4 changed files with 10 additions and 9 deletions

View file

@ -772,7 +772,7 @@ void AsmBlockStatement::toIR(IRState* p)
sw->addCase(llvm::ConstantInt::get(llvm::IntegerType::get(32), it->second), casebb); sw->addCase(llvm::ConstantInt::get(llvm::IntegerType::get(32), it->second), casebb);
p->scope() = IRScope(casebb,bb); p->scope() = IRScope(casebb,bb);
DtoGoto(loc, it->first); DtoGoto(loc, it->first, enclosingFinally);
} }
p->scope() = IRScope(bb,oldend); p->scope() = IRScope(bb,oldend);

View file

@ -172,7 +172,7 @@ LabelStatement* DtoLabelStatement(Identifier* ident)
/*//////////////////////////////////////////////////////////////////////////////////////// /*////////////////////////////////////////////////////////////////////////////////////////
// GOTO HELPER // GOTO HELPER
////////////////////////////////////////////////////////////////////////////////////////*/ ////////////////////////////////////////////////////////////////////////////////////////*/
void DtoGoto(Loc loc, Identifier* target) void DtoGoto(Loc loc, Identifier* target, TryFinallyStatement* sourceFinally)
{ {
assert(!gIR->scopereturned()); assert(!gIR->scopereturned());
@ -199,11 +199,10 @@ void DtoGoto(Loc loc, Identifier* target)
// goto into finally blocks is forbidden by the spec // goto into finally blocks is forbidden by the spec
// but should work fine // but should work fine
/* if(lblstmt->enclosingFinally != sourceFinally) {
if(lblstmt->tf != sourcetf) { error(loc, "spec disallows goto into or out of finally block");
error(loc, "spec disallows goto into finally block");
fatal(); fatal();
}*/ }
llvm::BranchInst::Create(targetBB, gIR->scopebb()); llvm::BranchInst::Create(targetBB, gIR->scopebb());
} }

View file

@ -45,8 +45,10 @@ void DtoAssert(Module* M, Loc loc, DValue* msg);
// return the LabelStatement from the current function with the given identifier or NULL if not found // return the LabelStatement from the current function with the given identifier or NULL if not found
LabelStatement* DtoLabelStatement(Identifier* ident); LabelStatement* DtoLabelStatement(Identifier* ident);
// emit goto
void DtoGoto(Loc loc, Identifier* target); /// emits goto to LabelStatement with the target identifier
/// the sourceFinally is only used for error checking
void DtoGoto(Loc loc, Identifier* target, TryFinallyStatement* sourceFinally);
// Generates IR for enclosing handlers between the current state and // Generates IR for enclosing handlers between the current state and
// the scope created by the 'target' statement. // the scope created by the 'target' statement.

View file

@ -1288,7 +1288,7 @@ void GotoStatement::toIR(IRState* p)
llvm::BasicBlock* oldend = gIR->scopeend(); llvm::BasicBlock* oldend = gIR->scopeend();
llvm::BasicBlock* bb = llvm::BasicBlock::Create("aftergoto", p->topfunc(), oldend); llvm::BasicBlock* bb = llvm::BasicBlock::Create("aftergoto", p->topfunc(), oldend);
DtoGoto(loc, label->ident); DtoGoto(loc, label->ident, enclosingFinally);
p->scope() = IRScope(bb,oldend); p->scope() = IRScope(bb,oldend);
} }