diff options
author | Nico Weber <nicolasweber@gmx.de> | 2014-07-06 22:53:19 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2014-07-06 22:53:19 +0000 |
commit | f16104c81cd0dff21d9c4e48dd7f827683317bff (patch) | |
tree | 8e848041bee84993afefeca34231ba0ba7552543 /lib/Sema/SemaStmt.cpp | |
parent | 695370c70118fc7d19e5d6b1f709095c4f4768a7 (diff) |
Sema: Check that __leave is contained in a __try block.
Give scope a SEHTryScope bit, set that in ParseSEHTry(), and let Sema
walk the scope chain to find the SEHTry parent on __leave statements.
(They are rare enough that it seems better to do the walk instead of
giving Scope a SEHTryParent pointer -- this is similar to AtCatchScope.)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@212422 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaStmt.cpp')
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index 6090d6d14d..0b77891854 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -3279,6 +3279,12 @@ Sema::ActOnSEHFinallyBlock(SourceLocation Loc, StmtResult Sema::ActOnSEHLeaveStmt(SourceLocation Loc, Scope *CurScope) { + Scope *SEHTryParent = CurScope; + while (SEHTryParent && !SEHTryParent->isSEHTryScope()) + SEHTryParent = SEHTryParent->getParent(); + if (!SEHTryParent) + return StmtError(Diag(Loc, diag::err_ms___leave_not_in___try)); + return StmtError(Diag(Loc, diag::err_ms___leave_unimplemented)); } |