[Parser] Support alternative operator token keyword args in Objective-C++
rdar://30741878
Differential revision: https://reviews.llvm.org/D50527
llvm-svn: 340301
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 79f8266..d1d8507 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -315,6 +315,19 @@
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) {