forked from qt-creator/qt-creator
C++11: Don't fail on = default and = delete initializers.
These are converted to IdExpr(SimpleName(token)) initializers. Change-Id: I1e85c4b261ca028dc75ffe6c00e1090630c2957c Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
5
src/libs/3rdparty/cplusplus/Bind.cpp
vendored
5
src/libs/3rdparty/cplusplus/Bind.cpp
vendored
@@ -1901,7 +1901,10 @@ bool Bind::visit(SimpleDeclarationAST *ast)
|
||||
if (Function *funTy = decl->type()->asFunctionType()) {
|
||||
funTy->setMethodKey(methodKey);
|
||||
|
||||
if (funTy->isVirtual() && it->value->equal_token)
|
||||
bool pureVirtualInit = it->value->equal_token
|
||||
&& it->value->initializer
|
||||
&& it->value->initializer->asNumericLiteral();
|
||||
if (funTy->isVirtual() && pureVirtualInit)
|
||||
funTy->setPureVirtual(true);
|
||||
}
|
||||
}
|
||||
|
||||
13
src/libs/3rdparty/cplusplus/Parser.cpp
vendored
13
src/libs/3rdparty/cplusplus/Parser.cpp
vendored
@@ -2510,6 +2510,19 @@ bool Parser::parseInitDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_sp
|
||||
return true;
|
||||
}
|
||||
rewind(colon_token);
|
||||
} else if (isFunctionDeclarator && declaringClass && node->core_declarator && LA() == T_EQUAL && LA(3) == T_SEMICOLON) { // = 0, = delete, = default
|
||||
if (!_cxx0xEnabled || LA(2) == T_NUMERIC_LITERAL) {
|
||||
parseInitializer(node->initializer, &node->equal_token);
|
||||
} else {
|
||||
node->equal_token = consumeToken();
|
||||
|
||||
IdExpressionAST *id_expr = new (_pool) IdExpressionAST;
|
||||
node->initializer = id_expr;
|
||||
|
||||
SimpleNameAST *simple_name = new (_pool) SimpleNameAST;
|
||||
id_expr->name = simple_name;
|
||||
simple_name->identifier_token = consumeToken();
|
||||
}
|
||||
} else if (node->core_declarator && (LA() == T_EQUAL || (_cxx0xEnabled && !isFunctionDeclarator && LA() == T_LBRACE) || (! declaringClass && LA() == T_LPAREN))) {
|
||||
parseInitializer(node->initializer, &node->equal_token);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
class C {
|
||||
C() = default;
|
||||
C(const C &) = delete;
|
||||
C &operator=(const C &) = default;
|
||||
|
||||
void foo() = delete;
|
||||
template <class T> void bar(T) = delete;
|
||||
};
|
||||
@@ -40,10 +40,12 @@ using namespace CPlusPlus;
|
||||
|
||||
#define VERIFY_ERRORS() \
|
||||
do { \
|
||||
QFile e(testdata(errorFile)); \
|
||||
QByteArray expectedErrors; \
|
||||
if (!errorFile.isEmpty()) { \
|
||||
QFile e(testdata(errorFile)); \
|
||||
if (e.open(QFile::ReadOnly)) \
|
||||
expectedErrors = QTextStream(&e).readAll().toUtf8(); \
|
||||
} \
|
||||
QCOMPARE(QString::fromLatin1(errors), QString::fromLatin1(expectedErrors)); \
|
||||
} while (0)
|
||||
|
||||
@@ -135,6 +137,7 @@ void tst_cxx11::parse_data()
|
||||
QTest::newRow("staticAssert.1") << "staticAssert.1.cpp" << "staticAssert.1.errors.txt";
|
||||
QTest::newRow("noExcept.1") << "noExcept.1.cpp" << "noExcept.1.errors.txt";
|
||||
QTest::newRow("braceInitializers.1") << "braceInitializers.1.cpp" << "braceInitializers.1.errors.txt";
|
||||
QTest::newRow("defaultdeleteInitializer.1") << "defaultdeleteInitializer.1.cpp" << "";
|
||||
}
|
||||
|
||||
void tst_cxx11::parse()
|
||||
|
||||
Reference in New Issue
Block a user