diff --git a/src/libs/3rdparty/cplusplus/Bind.cpp b/src/libs/3rdparty/cplusplus/Bind.cpp index 801349c872c..605bd768b45 100644 --- a/src/libs/3rdparty/cplusplus/Bind.cpp +++ b/src/libs/3rdparty/cplusplus/Bind.cpp @@ -3176,7 +3176,10 @@ bool Bind::visit(EnumSpecifierAST *ast) } (void) switchScope(previousScope); - _type.setType(control()->namedType(this->name(ast->name))); + if (ast->name) + _type.setType(control()->namedType(this->name(ast->name))); + else + _type.setType(ast->symbol); return false; } diff --git a/src/plugins/cppeditor/cppquickfix_test.cpp b/src/plugins/cppeditor/cppquickfix_test.cpp index afb6f87aec9..0e0ccfccfc5 100644 --- a/src/plugins/cppeditor/cppquickfix_test.cpp +++ b/src/plugins/cppeditor/cppquickfix_test.cpp @@ -394,6 +394,31 @@ void CppEditorPlugin::test_quickfix_data() "}\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. QTest::newRow("CompleteSwitchCaseStatement_basic2") << CppQuickFixFactoryPtr(new CompleteSwitchCaseStatement) << _(