diff options
| author | Chris Lattner <sabre@nondot.org> | 2008-06-02 21:31:07 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2008-06-02 21:31:07 +0000 |
| commit | fd2fe8270ecccdebf834e3eefe217b1e629d136c (patch) | |
| tree | 30e7b321a228724caa99053599feb725a8a1a627 /clang/lib/Parse | |
| parent | 4e8a512f80cf89e1190c4f541ad87ec1b22ac21d (diff) | |
| download | bcm5719-llvm-fd2fe8270ecccdebf834e3eefe217b1e629d136c.tar.gz bcm5719-llvm-fd2fe8270ecccdebf834e3eefe217b1e629d136c.zip | |
handle the full assignment-expression grammar when using an
objc message send in an initializer expression.
llvm-svn: 51882
Diffstat (limited to 'clang/lib/Parse')
| -rw-r--r-- | clang/lib/Parse/ParseExpr.cpp | 21 | ||||
| -rw-r--r-- | clang/lib/Parse/ParseInit.cpp | 9 |
2 files changed, 25 insertions, 5 deletions
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index 523f6473417..4bccc382664 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/lib/Parse/ParseExpr.cpp @@ -200,6 +200,27 @@ Parser::ExprResult Parser::ParseAssignmentExpression() { return ParseRHSOfBinaryExpression(LHS, prec::Assignment); } +/// ParseAssignmentExprWithObjCMessageExprStart - Parse an assignment expression +/// where part of an objc message send has already been parsed. In this case +/// LBracLoc indicates the location of the '[' of the message send, and either +/// ReceiverName or ReceiverExpr is non-null indicating the receiver of the +/// message. +/// +/// Since this handles full assignment-expression's, it handles postfix +/// expressions and other binary operators for these expressions as well. +Parser::ExprResult +Parser::ParseAssignmentExprWithObjCMessageExprStart(SourceLocation LBracLoc, + IdentifierInfo *ReceiverName, + ExprTy *ReceiverExpr) { + ExprResult R = ParseObjCMessageExpressionBody(LBracLoc, ReceiverName, + ReceiverExpr); + if (R.isInvalid) return R; + R = ParsePostfixExpressionSuffix(R); + if (R.isInvalid) return R; + return ParseRHSOfBinaryExpression(R, 2); +} + + Parser::ExprResult Parser::ParseConstantExpression() { ExprResult LHS = ParseCastExpression(false); if (LHS.isInvalid) return LHS; diff --git a/clang/lib/Parse/ParseInit.cpp b/clang/lib/Parse/ParseInit.cpp index c40fe88c217..a1fe04b7312 100644 --- a/clang/lib/Parse/ParseInit.cpp +++ b/clang/lib/Parse/ParseInit.cpp @@ -98,8 +98,7 @@ Parser::ExprResult Parser::ParseInitializerWithPotentialDesignator() { // [4][foo bar]. IdentifierInfo *Name = Tok.getIdentifierInfo(); ConsumeToken(); - ExprResult R = ParseObjCMessageExpressionBody(StartLoc, Name, 0); - return ParsePostfixExpressionSuffix(R); + return ParseAssignmentExprWithObjCMessageExprStart(StartLoc, Name, 0); } // Note that we parse this as an assignment expression, not a constant @@ -113,13 +112,13 @@ Parser::ExprResult Parser::ParseInitializerWithPotentialDesignator() { // Given an expression, we could either have a designator (if the next // tokens are '...' or ']' or an objc message send. If this is an objc - // message send, handle it now. + // message send, handle it now. An objc-message send is the start of + // an assignment-expression production. if (getLang().ObjC1 && Tok.isNot(tok::ellipsis) && Tok.isNot(tok::r_square)) { // FIXME: Emit ext_gnu_missing_equal_designator for inits like // [4][foo bar]. - ExprResult R = ParseObjCMessageExpressionBody(StartLoc, 0, Idx.Val); - return ParsePostfixExpressionSuffix(R); + return ParseAssignmentExprWithObjCMessageExprStart(StartLoc, 0,Idx.Val); } // Handle the gnu array range extension. |

