diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Parse/ParseExpr.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index 79f826653eb..d1d8507af8c 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/lib/Parse/ParseExpr.cpp @@ -315,6 +315,19 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHS, prec::Level MinPrec) { return LHS; } + // In Objective-C++, alternative operator tokens can be used as keyword args + // in message expressions. Unconsume the token so that it can reinterpreted + // as an identifier in ParseObjCMessageExpressionBody. i.e., we support: + // [foo meth:0 and:0]; + // [foo not_eq]; + if (getLangOpts().ObjC1 && getLangOpts().CPlusPlus && + Tok.isOneOf(tok::colon, tok::r_square) && + OpToken.getIdentifierInfo() != nullptr) { + PP.EnterToken(Tok); + Tok = OpToken; + return LHS; + } + // Special case handling for the ternary operator. ExprResult TernaryMiddle(true); if (NextTokPrec == prec::Conditional) { |