forked from qt-creator/qt-creator
CplusPlus: Fix type information for anonymous enums
Variables declared like this: enum { E1, E2 } e; would not get assigned a proper type. Task-number: QTCREATORBUG-7487 Change-Id: I4362f22feb0f2e4e1e754e9c623e5576fa31f4bc Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
3
src/libs/3rdparty/cplusplus/Bind.cpp
vendored
3
src/libs/3rdparty/cplusplus/Bind.cpp
vendored
@@ -3176,7 +3176,10 @@ bool Bind::visit(EnumSpecifierAST *ast)
|
|||||||
}
|
}
|
||||||
|
|
||||||
(void) switchScope(previousScope);
|
(void) switchScope(previousScope);
|
||||||
|
if (ast->name)
|
||||||
_type.setType(control()->namedType(this->name(ast->name)));
|
_type.setType(control()->namedType(this->name(ast->name)));
|
||||||
|
else
|
||||||
|
_type.setType(ast->symbol);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -394,6 +394,31 @@ void CppEditorPlugin::test_quickfix_data()
|
|||||||
"}\n"
|
"}\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Checks: All enum values are added as case statements for a blank switch
|
||||||
|
// for anonymous enums.
|
||||||
|
QTest::newRow("CompleteSwitchCaseStatement_basic1_anonymous_enum")
|
||||||
|
<< CppQuickFixFactoryPtr(new CompleteSwitchCaseStatement) << _(
|
||||||
|
"enum { V1, V2 } t;\n"
|
||||||
|
"\n"
|
||||||
|
"void f()\n"
|
||||||
|
"{\n"
|
||||||
|
" @switch (t) {\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
) << _(
|
||||||
|
"enum { V1, V2 } t;\n"
|
||||||
|
"\n"
|
||||||
|
"void f()\n"
|
||||||
|
"{\n"
|
||||||
|
" switch (t) {\n"
|
||||||
|
" case V1:\n"
|
||||||
|
" break;\n"
|
||||||
|
" case V2:\n"
|
||||||
|
" break;\n"
|
||||||
|
" }\n"
|
||||||
|
"}\n"
|
||||||
|
);
|
||||||
|
|
||||||
// Checks: All enum values are added as case statements for a blank switch with a default case.
|
// Checks: All enum values are added as case statements for a blank switch with a default case.
|
||||||
QTest::newRow("CompleteSwitchCaseStatement_basic2")
|
QTest::newRow("CompleteSwitchCaseStatement_basic2")
|
||||||
<< CppQuickFixFactoryPtr(new CompleteSwitchCaseStatement) << _(
|
<< CppQuickFixFactoryPtr(new CompleteSwitchCaseStatement) << _(
|
||||||
|
Reference in New Issue
Block a user