C++11: Allow brace initializers in assignment expressions.

Like:
var += {1, 2};
in a function context.

Change-Id: I3936c97c4fcb6b3dcac2979e0508d422d47fddfc
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
Christian Kamm
2012-09-12 13:45:36 +02:00
committed by hjk
parent 342709a9cc
commit 9b7d1901ba
2 changed files with 13 additions and 2 deletions

View File

@@ -5202,8 +5202,13 @@ void Parser::parseExpressionWithOperatorPrecedence(ExpressionAST *&lhs, int minP
if (operPrecedence <= Prec::Conditional && isCPlusPlus) {
// in C++ you can put a throw in the right-most expression of a conditional expression,
// or an assignment, so some special handling:
if (_cxx0xEnabled) {
if (!parseInitializerClause0x(rhs))
return;
} else {
if (!parseAssignmentExpression(rhs))
return;
}
} else {
// for C & all other expressions:
if (!parseCastExpression(rhs))

View File

@@ -6,3 +6,9 @@ class C {
Type var1 = {1, 2, 3};
Type var2{1, 2, 3};
};
void main() {
var1 = {1, 2, {3, 4} };
Type var2{{1, 2, 3}, 4};
var3 += {1, 2};
}