forked from qt-creator/qt-creator
CPlusPlus: Allow empty initializer lists in placement new
Fixes: QTCREATORBUG-30798 Change-Id: Ib9945e4e721aca5f88665bd8a289ae3c54c69e65 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
2
src/libs/3rdparty/cplusplus/Parser.cpp
vendored
2
src/libs/3rdparty/cplusplus/Parser.cpp
vendored
@@ -5838,7 +5838,7 @@ bool Parser::parseNewInitializer(ExpressionAST *&node)
|
|||||||
{
|
{
|
||||||
DEBUG_THIS_RULE();
|
DEBUG_THIS_RULE();
|
||||||
if (LA() == T_LPAREN)
|
if (LA() == T_LPAREN)
|
||||||
return parseExpressionListParen(node, false);
|
return parseExpressionListParen(node, true);
|
||||||
else if (_languageFeatures.cxx11Enabled && LA() == T_LBRACE)
|
else if (_languageFeatures.cxx11Enabled && LA() == T_LBRACE)
|
||||||
return parseBracedInitList0x(node);
|
return parseBracedInitList0x(node);
|
||||||
return false;
|
return false;
|
||||||
|
@@ -113,6 +113,7 @@ private slots:
|
|||||||
void templated_dtor_4();
|
void templated_dtor_4();
|
||||||
void templated_dtor_5();
|
void templated_dtor_5();
|
||||||
void emptyMemberInitialization();
|
void emptyMemberInitialization();
|
||||||
|
void placementNewWithEmptyConstructorArgs();
|
||||||
|
|
||||||
// possible declaration-or-expression statements
|
// possible declaration-or-expression statements
|
||||||
void call_call_1();
|
void call_call_1();
|
||||||
@@ -2070,6 +2071,15 @@ void tst_AST::emptyMemberInitialization()
|
|||||||
QCOMPARE(diag.errorCount, 0);
|
QCOMPARE(diag.errorCount, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_AST::placementNewWithEmptyConstructorArgs()
|
||||||
|
{
|
||||||
|
const std::shared_ptr<TranslationUnit> unit(parse(
|
||||||
|
"int main()\n{ int* i = new int;\n i = new(i) int();}",
|
||||||
|
TranslationUnit::ParseTranlationUnit));
|
||||||
|
QVERIFY(unit->ast());
|
||||||
|
QCOMPARE(diag.errorCount, 0);
|
||||||
|
}
|
||||||
|
|
||||||
void tst_AST::initTestCase()
|
void tst_AST::initTestCase()
|
||||||
{
|
{
|
||||||
control.setDiagnosticClient(&diag);
|
control.setDiagnosticClient(&diag);
|
||||||
|
Reference in New Issue
Block a user