Fix a theoretical bug when ParseCompoundStatement() returns StmtError.

ParseCompoundStatement() currently never returns StmtError, but if it did,
Sema would keep the __finally scope on its stack indefinitely.  Explicitly
add an error callback that clears it.

llvm-svn: 231625
This commit is contained in:
Nico Weber 2015-03-09 03:17:15 +00:00
parent 75eda5e913
commit ce90329824
3 changed files with 8 additions and 1 deletions

View File

@ -3297,6 +3297,7 @@ public:
Expr *FilterExpr, Expr *FilterExpr,
Stmt *Block); Stmt *Block);
void ActOnStartSEHFinallyBlock(); void ActOnStartSEHFinallyBlock();
void ActOnAbortSEHFinallyBlock();
StmtResult ActOnFinishSEHFinallyBlock(SourceLocation Loc, Stmt *Block); StmtResult ActOnFinishSEHFinallyBlock(SourceLocation Loc, Stmt *Block);
StmtResult ActOnSEHLeaveStmt(SourceLocation Loc, Scope *CurScope); StmtResult ActOnSEHLeaveStmt(SourceLocation Loc, Scope *CurScope);

View File

@ -519,8 +519,10 @@ StmtResult Parser::ParseSEHFinallyBlock(SourceLocation FinallyLoc) {
Actions.ActOnStartSEHFinallyBlock(); Actions.ActOnStartSEHFinallyBlock();
StmtResult Block(ParseCompoundStatement()); StmtResult Block(ParseCompoundStatement());
if(Block.isInvalid()) if(Block.isInvalid()) {
Actions.ActOnAbortSEHFinallyBlock();
return Block; return Block;
}
return Actions.ActOnFinishSEHFinallyBlock(FinallyLoc, Block.get()); return Actions.ActOnFinishSEHFinallyBlock(FinallyLoc, Block.get());
} }

View File

@ -3422,6 +3422,10 @@ void Sema::ActOnStartSEHFinallyBlock() {
CurrentSEHFinally.push_back(CurScope); CurrentSEHFinally.push_back(CurScope);
} }
void Sema::ActOnAbortSEHFinallyBlock() {
CurrentSEHFinally.pop_back();
}
StmtResult Sema::ActOnFinishSEHFinallyBlock(SourceLocation Loc, Stmt *Block) { StmtResult Sema::ActOnFinishSEHFinallyBlock(SourceLocation Loc, Stmt *Block) {
assert(Block); assert(Block);
CurrentSEHFinally.pop_back(); CurrentSEHFinally.pop_back();