[cfe-commits] r151508 - /cfe/trunk/lib/Parse/ParseExpr.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Sun Feb 26 15:40:27 PST 2012
Author: rsmith
Date: Sun Feb 26 17:40:27 2012
New Revision: 151508
URL: http://llvm.org/viewvc/llvm-project?rev=151508&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Parse/ParseExpr.cpp
Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=151508&r1=151507&r2=151508&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Sun Feb 26 17:40:27 2012
@@ -351,12 +351,23 @@
// 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();
More information about the cfe-commits
mailing list