diff options
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Parse/ParseStmt.cpp')
-rw-r--r-- | contrib/llvm/tools/clang/lib/Parse/ParseStmt.cpp | 70 |
1 files changed, 44 insertions, 26 deletions
diff --git a/contrib/llvm/tools/clang/lib/Parse/ParseStmt.cpp b/contrib/llvm/tools/clang/lib/Parse/ParseStmt.cpp index 2a5f840..b658cef 100644 --- a/contrib/llvm/tools/clang/lib/Parse/ParseStmt.cpp +++ b/contrib/llvm/tools/clang/lib/Parse/ParseStmt.cpp @@ -119,15 +119,12 @@ namespace { class StatementFilterCCC : public CorrectionCandidateCallback { public: StatementFilterCCC(Token nextTok) : NextToken(nextTok) { - WantTypeSpecifiers = nextTok.is(tok::l_paren) || nextTok.is(tok::less) || - nextTok.is(tok::identifier) || nextTok.is(tok::star) || - nextTok.is(tok::amp) || nextTok.is(tok::l_square); - WantExpressionKeywords = nextTok.is(tok::l_paren) || - nextTok.is(tok::identifier) || - nextTok.is(tok::arrow) || nextTok.is(tok::period); - WantRemainingKeywords = nextTok.is(tok::l_paren) || nextTok.is(tok::semi) || - nextTok.is(tok::identifier) || - nextTok.is(tok::l_brace); + WantTypeSpecifiers = nextTok.isOneOf(tok::l_paren, tok::less, tok::l_square, + tok::identifier, tok::star, tok::amp); + WantExpressionKeywords = + nextTok.isOneOf(tok::l_paren, tok::identifier, tok::arrow, tok::period); + WantRemainingKeywords = + nextTok.isOneOf(tok::l_paren, tok::semi, tok::identifier, tok::l_brace); WantCXXNamedCasts = false; } @@ -408,12 +405,6 @@ StmtResult Parser::ParseExprStatement() { return Actions.ActOnExprStmt(Expr); } -StmtResult Parser::ParseSEHTryBlock() { - assert(Tok.is(tok::kw___try) && "Expected '__try'"); - SourceLocation Loc = ConsumeToken(); - return ParseSEHTryBlockCommon(Loc); -} - /// ParseSEHTryBlockCommon /// /// seh-try-block: @@ -423,8 +414,11 @@ StmtResult Parser::ParseSEHTryBlock() { /// seh-except-block /// seh-finally-block /// -StmtResult Parser::ParseSEHTryBlockCommon(SourceLocation TryLoc) { - if(Tok.isNot(tok::l_brace)) +StmtResult Parser::ParseSEHTryBlock() { + assert(Tok.is(tok::kw___try) && "Expected '__try'"); + SourceLocation TryLoc = ConsumeToken(); + + if (Tok.isNot(tok::l_brace)) return StmtError(Diag(Tok, diag::err_expected) << tok::l_brace); StmtResult TryBlock(ParseCompoundStatement(/*isStmtExpr=*/false, @@ -441,7 +435,7 @@ StmtResult Parser::ParseSEHTryBlockCommon(SourceLocation TryLoc) { SourceLocation Loc = ConsumeToken(); Handler = ParseSEHFinallyBlock(Loc); } else { - return StmtError(Diag(Tok,diag::err_seh_expected_handler)); + return StmtError(Diag(Tok, diag::err_seh_expected_handler)); } if(Handler.isInvalid()) @@ -466,14 +460,21 @@ StmtResult Parser::ParseSEHExceptBlock(SourceLocation ExceptLoc) { if (ExpectAndConsume(tok::l_paren)) return StmtError(); - ParseScope ExpectScope(this, Scope::DeclScope | Scope::ControlScope); + ParseScope ExpectScope(this, Scope::DeclScope | Scope::ControlScope | + Scope::SEHExceptScope); if (getLangOpts().Borland) { Ident__exception_info->setIsPoisoned(false); Ident___exception_info->setIsPoisoned(false); Ident_GetExceptionInfo->setIsPoisoned(false); } - ExprResult FilterExpr(ParseExpression()); + + ExprResult FilterExpr; + { + ParseScopeFlags FilterScope(this, getCurScope()->getFlags() | + Scope::SEHFilterScope); + FilterExpr = Actions.CorrectDelayedTyposInExpr(ParseExpression()); + } if (getLangOpts().Borland) { Ident__exception_info->setIsPoisoned(true); @@ -487,6 +488,9 @@ StmtResult Parser::ParseSEHExceptBlock(SourceLocation ExceptLoc) { if (ExpectAndConsume(tok::r_paren)) return StmtError(); + if (Tok.isNot(tok::l_brace)) + return StmtError(Diag(Tok, diag::err_expected) << tok::l_brace); + StmtResult Block(ParseCompoundStatement()); if(Block.isInvalid()) @@ -500,16 +504,24 @@ 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); + 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()) + if(Block.isInvalid()) { + Actions.ActOnAbortSEHFinallyBlock(); return Block; + } - return Actions.ActOnSEHFinallyBlock(FinallyBlock,Block.get()); + return Actions.ActOnFinishSEHFinallyBlock(FinallyLoc, Block.get()); } /// Handle __leave @@ -1253,7 +1265,7 @@ StmtResult Parser::ParseSwitchStatement(SourceLocation *TrailingElseLoc) { // We have incremented the mangling number for the SwitchScope and the // InnerScope, which is one too many. if (C99orCXX) - getCurScope()->decrementMSLocalManglingNumber(); + getCurScope()->decrementMSManglingNumber(); // Read the body statement. StmtResult Body(ParseStatement(TrailingElseLoc)); @@ -1412,7 +1424,7 @@ bool Parser::isForRangeIdentifier() { if (Next.is(tok::colon)) return true; - if (Next.is(tok::l_square) || Next.is(tok::kw_alignas)) { + if (Next.isOneOf(tok::l_square, tok::kw_alignas)) { TentativeParsingAction PA(*this); ConsumeToken(); SkipCXX11Attributes(); @@ -1674,6 +1686,12 @@ StmtResult Parser::ParseForStatement(SourceLocation *TrailingElseLoc) { FirstPart.get(), Collection.get(), T.getCloseLocation()); + } else { + // In OpenMP loop region loop control variable must be captured and be + // private. Perform analysis of first part (if any). + if (getLangOpts().OpenMP && FirstPart.isUsable()) { + Actions.ActOnOpenMPLoopInitialization(ForLoc, FirstPart.get()); + } } // C99 6.8.5p5 - In C99, the body of the for statement is a scope, even if @@ -1695,7 +1713,7 @@ StmtResult Parser::ParseForStatement(SourceLocation *TrailingElseLoc) { // It will only be incremented if the body contains other things that would // normally increment the mangling number (like a compound statement). if (C99orCXXorObjC) - getCurScope()->decrementMSLocalManglingNumber(); + getCurScope()->decrementMSManglingNumber(); // Read the body statement. StmtResult Body(ParseStatement(TrailingElseLoc)); |