diff options
Diffstat (limited to 'lib/Parse/ParseStmt.cpp')
-rw-r--r-- | lib/Parse/ParseStmt.cpp | 48 |
1 files changed, 40 insertions, 8 deletions
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp index 6f6c495dde..1e8c4a69d8 100644 --- a/lib/Parse/ParseStmt.cpp +++ b/lib/Parse/ParseStmt.cpp @@ -424,11 +424,27 @@ StmtResult Parser::ParseSEHTryBlock() { /// seh-finally-block /// StmtResult Parser::ParseSEHTryBlockCommon(SourceLocation TryLoc) { - if(Tok.isNot(tok::l_brace)) + if (Tok.isNot(tok::l_brace)) return StmtError(Diag(Tok, diag::err_expected) << tok::l_brace); - StmtResult TryBlock(ParseCompoundStatement(/*isStmtExpr=*/false, - Scope::DeclScope | Scope::SEHTryScope)); + int SEHTryIndex, SEHTryParentIndex; + StmtResult TryBlock; + { + assert(Tok.is(tok::l_brace) && "Not a compount stmt!"); + + // Enter a scope to hold everything within the compound stmt. Compound + // statements can always hold declarations. + ParseScope CompoundScope(this, Scope::DeclScope | Scope::SEHTryScope); + SEHTryIndex = getCurScope()->getSEHTryIndex(); + SEHTryParentIndex = getCurScope()->getSEHTryParentIndex(); + + // Parse the statements in the body. + TryBlock = ParseCompoundStatementBody(); + } + + //StmtResult TryBlock(ParseCompoundStatement(/*isStmtExpr=*/false, + // Scope::DeclScope | Scope::SEHTryScope)); + if(TryBlock.isInvalid()) return TryBlock; @@ -450,7 +466,9 @@ StmtResult Parser::ParseSEHTryBlockCommon(SourceLocation TryLoc) { return Actions.ActOnSEHTryBlock(false /* IsCXXTry */, TryLoc, TryBlock.get(), - Handler.get()); + Handler.get(), + SEHTryIndex, + SEHTryParentIndex); } /// ParseSEHExceptBlock - Handle __except @@ -1961,9 +1979,21 @@ StmtResult Parser::ParseCXXTryBlockCommon(SourceLocation TryLoc, bool FnTry) { return StmtError(Diag(Tok, diag::err_expected) << tok::l_brace); // FIXME: Possible draft standard bug: attribute-specifier should be allowed? - StmtResult TryBlock(ParseCompoundStatement(/*isStmtExpr=*/false, - Scope::DeclScope | Scope::TryScope | - (FnTry ? Scope::FnTryCatchScope : 0))); + int SEHTryIndex, SEHTryParentIndex; + StmtResult TryBlock; + { + assert(Tok.is(tok::l_brace) && "Not a compount stmt!"); + + // Enter a scope to hold everything within the compound stmt. Compound + // statements can always hold declarations. + ParseScope CompoundScope(this, Scope::DeclScope | Scope::TryScope | + (FnTry ? Scope::FnTryCatchScope : 0)); + SEHTryIndex = getCurScope()->getSEHTryIndex(); + SEHTryParentIndex = getCurScope()->getSEHTryParentIndex(); + + // Parse the statements in the body. + TryBlock = ParseCompoundStatementBody(); + } if (TryBlock.isInvalid()) return TryBlock; @@ -1988,7 +2018,9 @@ StmtResult Parser::ParseCXXTryBlockCommon(SourceLocation TryLoc, bool FnTry) { return Actions.ActOnSEHTryBlock(true /* IsCXXTry */, TryLoc, TryBlock.get(), - Handler.get()); + Handler.get(), + SEHTryIndex, + SEHTryParentIndex); } else { StmtVector Handlers; |