summaryrefslogtreecommitdiffstats
path: root/clang/lib/Parse/ParseStmt.cpp
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2015-03-09 02:47:59 +0000
committerNico Weber <nicolasweber@gmx.de>2015-03-09 02:47:59 +0000
commitd64657f2989f0e1e279f1ad8a03f627b4b60f407 (patch)
tree771755984c567efb57fd15d7c16b463fbd2501e7 /clang/lib/Parse/ParseStmt.cpp
parent9af63b22a5e5e3f5dc921dc987ccf96dabb87b43 (diff)
downloadbcm5719-llvm-d64657f2989f0e1e279f1ad8a03f627b4b60f407.tar.gz
bcm5719-llvm-d64657f2989f0e1e279f1ad8a03f627b4b60f407.zip
Warn when jumping out of a __finally block via continue, break, return, __leave.
Since continue, break, return are much more common than __finally, this tries to keep the work for continue, break, return O(1). Sema keeps a stack of active __finally scopes (to do this, ActOnSEHFinally() is split into ActOnStartSEHFinally() and ActOnFinishSEHFinally()), and the various jump statements then check if the current __finally scope (if present) is deeper than then destination scope of the jump. The same warning for goto statements is still missing. This is the moral equivalent of MSVC's C4532. llvm-svn: 231623
Diffstat (limited to 'clang/lib/Parse/ParseStmt.cpp')
-rw-r--r--clang/lib/Parse/ParseStmt.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index e77f07ab030..9028e4ac2dd 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -507,7 +507,7 @@ StmtResult Parser::ParseSEHExceptBlock(SourceLocation ExceptLoc) {
/// seh-finally-block:
/// '__finally' compound-statement
///
-StmtResult Parser::ParseSEHFinallyBlock(SourceLocation FinallyBlock) {
+StmtResult Parser::ParseSEHFinallyBlock(SourceLocation FinallyLoc) {
PoisonIdentifierRAIIObject raii(Ident__abnormal_termination, false),
raii2(Ident___abnormal_termination, false),
raii3(Ident_AbnormalTermination, false);
@@ -515,11 +515,14 @@ StmtResult Parser::ParseSEHFinallyBlock(SourceLocation FinallyBlock) {
if (Tok.isNot(tok::l_brace))
return StmtError(Diag(Tok, diag::err_expected) << tok::l_brace);
+ ParseScope FinallyScope(this, 0);
+ Actions.ActOnStartSEHFinallyBlock();
+
StmtResult Block(ParseCompoundStatement());
if(Block.isInvalid())
return Block;
- return Actions.ActOnSEHFinallyBlock(FinallyBlock,Block.get());
+ return Actions.ActOnFinishSEHFinallyBlock(FinallyLoc, Block.get());
}
/// Handle __leave
OpenPOWER on IntegriCloud