diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-02-26 23:40:27 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-02-26 23:40:27 +0000 |
commit | 9a6403a9ded5030aa12632afdfc89f59f4f43762 (patch) | |
tree | cac688a3bb43b8d3b3cb1cb3db1c432339510458 /clang/lib/Parse/ParseExpr.cpp | |
parent | ce50eec7c67c25d69ddbda702502d5ccd5ce04de (diff) | |
download | bcm5719-llvm-9a6403a9ded5030aa12632afdfc89f59f4f43762.tar.gz bcm5719-llvm-9a6403a9ded5030aa12632afdfc89f59f4f43762.zip |
Half of PR12088: parse braced-init-lists on the RHS of assignment operators.
If the assignment operator is a scalar type, we continue to incorrectly reject
the initializer, but semantic analysis (and codegen) is correct for overloaded
operators.
llvm-svn: 151508
Diffstat (limited to 'clang/lib/Parse/ParseExpr.cpp')
-rw-r--r-- | clang/lib/Parse/ParseExpr.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index fe8d464229d..26a2a11444c 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/lib/Parse/ParseExpr.cpp @@ -351,12 +351,23 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHS, prec::Level MinPrec) { // be a throw-expression, which is not a valid cast-expression. // Therefore we need some special-casing here. // Also note that the third operand of the conditional operator is - // an assignment-expression in C++. + // an assignment-expression in C++, and in C++11, we can have a + // braced-init-list on the RHS of an assignment. ExprResult RHS; - if (getLang().CPlusPlus && NextTokPrec <= prec::Conditional) + if (getLang().CPlusPlus0x && MinPrec == prec::Assignment && + Tok.is(tok::l_brace)) { + Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists); + RHS = ParseBraceInitializer(); + if (LHS.isInvalid() || RHS.isInvalid()) + return ExprError(); + // A braced-init-list can never be followed by more operators. + return Actions.ActOnBinOp(getCurScope(), OpToken.getLocation(), + OpToken.getKind(), LHS.take(), RHS.take()); + } else if (getLang().CPlusPlus && NextTokPrec <= prec::Conditional) { RHS = ParseAssignmentExpression(); - else + } else { RHS = ParseCastExpression(false); + } if (RHS.isInvalid()) LHS = ExprError(); |