forked from qt-creator/qt-creator
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:
5
src/libs/3rdparty/cplusplus/Parser.cpp
vendored
5
src/libs/3rdparty/cplusplus/Parser.cpp
vendored
@@ -5202,8 +5202,13 @@ void Parser::parseExpressionWithOperatorPrecedence(ExpressionAST *&lhs, int minP
|
|||||||
if (operPrecedence <= Prec::Conditional && isCPlusPlus) {
|
if (operPrecedence <= Prec::Conditional && isCPlusPlus) {
|
||||||
// in C++ you can put a throw in the right-most expression of a conditional expression,
|
// in C++ you can put a throw in the right-most expression of a conditional expression,
|
||||||
// or an assignment, so some special handling:
|
// or an assignment, so some special handling:
|
||||||
|
if (_cxx0xEnabled) {
|
||||||
|
if (!parseInitializerClause0x(rhs))
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
if (!parseAssignmentExpression(rhs))
|
if (!parseAssignmentExpression(rhs))
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// for C & all other expressions:
|
// for C & all other expressions:
|
||||||
if (!parseCastExpression(rhs))
|
if (!parseCastExpression(rhs))
|
||||||
|
|||||||
@@ -6,3 +6,9 @@ class C {
|
|||||||
Type var1 = {1, 2, 3};
|
Type var1 = {1, 2, 3};
|
||||||
Type var2{1, 2, 3};
|
Type var2{1, 2, 3};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
var1 = {1, 2, {3, 4} };
|
||||||
|
Type var2{{1, 2, 3}, 4};
|
||||||
|
var3 += {1, 2};
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user