diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-09-15 15:09:43 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-09-15 15:09:43 +0000 |
commit | fa885c11e33ca1140e3cf376eb43cb70bbf96962 (patch) | |
tree | be3c0d71ce677059cfbc1d8ef5eb44a637cf47fd /lib/Parse/ParseExpr.cpp | |
parent | b65042da3aa4dc2f9fc1c606fa6817089fd86cd6 (diff) |
Extend bracket insertion to message sends to "super", e.g.,
super method:arg]
will now recover nicely and insert the '[' before 'super'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113971 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseExpr.cpp')
-rw-r--r-- | lib/Parse/ParseExpr.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index e466af2d61..0f9154827e 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -663,6 +663,18 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression, break; } + // In an Objective-C method, if we have "super" followed by an identifier, + // the token sequence is ill-fomed. However, if there's a ':' or ']' after + // that identifier, this is probably a message send with a missing open + // bracket. Treat it as such. + if (getLang().ObjC1 && &II == Ident_super && Tok.is(tok::identifier) && + getCurScope()->isInObjcMethodScope() && + (NextToken().is(tok::colon) || NextToken().is(tok::r_square))) { + Res = ParseObjCMessageExpressionBody(SourceLocation(), ILoc, ParsedType(), + 0); + break; + } + // Make sure to pass down the right value for isAddressOfOperand. if (isAddressOfOperand && isPostfixExpressionSuffixStart()) isAddressOfOperand = false; |