diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Parse/ParseStmt.cpp | 10 | ||||
-rw-r--r-- | lib/Parse/Parser.cpp | 10 |
2 files changed, 17 insertions, 3 deletions
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp index 3df761af44..8968a43480 100644 --- a/lib/Parse/ParseStmt.cpp +++ b/lib/Parse/ParseStmt.cpp @@ -355,7 +355,8 @@ StmtResult Parser::ParseSEHTryBlockCommon(SourceLocation TryLoc) { return move(TryBlock); StmtResult Handler; - if(Tok.is(tok::kw___except)) { + if (Tok.is(tok::identifier) && + Tok.getIdentifierInfo() == getSEHExceptKeyword()) { SourceLocation Loc = ConsumeToken(); Handler = ParseSEHExceptBlock(Loc); } else if (Tok.is(tok::kw___finally)) { @@ -2037,10 +2038,13 @@ StmtResult Parser::ParseCXXTryBlockCommon(SourceLocation TryLoc) { return move(TryBlock); // Borland allows SEH-handlers with 'try' - if(Tok.is(tok::kw___except) || Tok.is(tok::kw___finally)) { + + if((Tok.is(tok::identifier) && + Tok.getIdentifierInfo() == getSEHExceptKeyword()) || + Tok.is(tok::kw___finally)) { // TODO: Factor into common return ParseSEHHandlerCommon(...) StmtResult Handler; - if(Tok.is(tok::kw___except)) { + if(Tok.getIdentifierInfo() == getSEHExceptKeyword()) { SourceLocation Loc = ConsumeToken(); Handler = ParseSEHExceptBlock(Loc); } diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp index 2e0c46dbdb..2face304c0 100644 --- a/lib/Parse/Parser.cpp +++ b/lib/Parse/Parser.cpp @@ -23,6 +23,14 @@ #include "clang/AST/ASTConsumer.h" using namespace clang; +IdentifierInfo *Parser::getSEHExceptKeyword() { + // __except is accepted as a (contextual) keyword + if (!Ident__except && (getLang().MicrosoftExt || getLang().Borland)) + Ident__except = PP.getIdentifierInfo("__except"); + + return Ident__except; +} + Parser::Parser(Preprocessor &pp, Sema &actions) : PP(pp), Actions(actions), Diags(PP.getDiagnostics()), GreaterThanIsOperator(true), ColonIsSacred(false), @@ -431,6 +439,8 @@ void Parser::Initialize() { Ident_obsoleted = 0; Ident_unavailable = 0; + Ident__except = 0; + Ident__exception_code = Ident__exception_info = Ident__abnormal_termination = 0; Ident___exception_code = Ident___exception_info = Ident___abnormal_termination = 0; Ident_GetExceptionCode = Ident_GetExceptionInfo = Ident_AbnormalTermination = 0; |