forked from qt-creator/qt-creator
C++: Fix parsing enum specifier II
This amends the obviously wrong
de975aca4f
, which did not honored nameless
enum specifiers.
This fixes e.g. "Find Usages" for declarations following "enum {};".
Change-Id: Id98c074156f576b9a63e6c25dab38721ca34e496
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
4
src/libs/3rdparty/cplusplus/Parser.cpp
vendored
4
src/libs/3rdparty/cplusplus/Parser.cpp
vendored
@@ -1835,10 +1835,8 @@ bool Parser::parseEnumSpecifier(SpecifierListAST *&node)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (LA() == T_IDENTIFIER)
|
||||
if (LA() == T_COLON_COLON && LA() == T_IDENTIFIER)
|
||||
parseName(ast->name);
|
||||
else
|
||||
return false;
|
||||
|
||||
if (_languageFeatures.cxx11Enabled && LA() == T_COLON) {
|
||||
ast->colon_token = consumeToken();
|
||||
|
@@ -206,6 +206,7 @@ private slots:
|
||||
void invalidCode();
|
||||
void enumDeclaration();
|
||||
void invalidEnumClassDeclaration();
|
||||
void invalidEnumWithDestructorId();
|
||||
};
|
||||
|
||||
void tst_AST::gcc_attributes_1()
|
||||
@@ -2002,6 +2003,14 @@ void tst_AST::invalidEnumClassDeclaration()
|
||||
QVERIFY(diag.errorCount != 0);
|
||||
}
|
||||
|
||||
void tst_AST::invalidEnumWithDestructorId()
|
||||
{
|
||||
QSharedPointer<TranslationUnit> unit(parseStatement(
|
||||
"enum ~A {};", false));
|
||||
|
||||
QVERIFY(diag.errorCount != 0);
|
||||
}
|
||||
|
||||
void tst_AST::initTestCase()
|
||||
{
|
||||
control.setDiagnosticClient(&diag);
|
||||
|
Reference in New Issue
Block a user