forked from OSchip/llvm-project
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:
parent
75eda5e913
commit
ce90329824
|
@ -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);
|
||||||
|
|
||||||
|
|
|
@ -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());
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
|
Loading…
Reference in New Issue