From ce7e21da7ab4133dfc41c862271b4f21a71d0c77 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 12 Aug 2006 17:22:40 +0000 Subject: [PATCH] Implement ParseAssignmentExpression correctly llvm-svn: 38884 --- clang/Parse/ParseExpr.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/clang/Parse/ParseExpr.cpp b/clang/Parse/ParseExpr.cpp index 231ff3bdc188..98c043cab50d 100644 --- a/clang/Parse/ParseExpr.cpp +++ b/clang/Parse/ParseExpr.cpp @@ -45,11 +45,6 @@ Parser::ExprResult Parser::ParseInitializer() { -// Expr that doesn't include commas. -Parser::ExprResult Parser::ParseAssignmentExpression() { - return ParseExpression(); -} - /// PrecedenceLevels - These are precedences for the binary/ternary operators in /// the C99 grammar. These have been named to relate with the C99 grammar /// productions. Low precedences numbers bind more weakly than high numbers. @@ -117,7 +112,7 @@ static prec::Level getBinOpPrecedence(tok::TokenKind Kind) { } -/// ParseBinaryExpression - Simple precedence-based parser for binary/ternary +/// ParseExpression - Simple precedence-based parser for binary/ternary /// operators. /// /// Note: we diverge from the C99 grammar when parsing the assignment-expression @@ -200,6 +195,14 @@ Parser::ExprResult Parser::ParseExpression() { return ParseRHSOfBinaryExpression(LHS, prec::Comma); } +// Expr that doesn't include commas. +Parser::ExprResult Parser::ParseAssignmentExpression() { + ExprResult LHS = ParseCastExpression(false); + if (LHS.isInvalid) return LHS; + + return ParseRHSOfBinaryExpression(LHS, prec::Assignment); +} + /// ParseRHSOfBinaryExpression - Parse a binary expression that starts with /// LHS and has a precedence of at least MinPrec. Parser::ExprResult