diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,10 +112,12 @@ # Turn off missing-field-initializers warning for GCC to avoid noise from false positives with empty {} # See discussion: http://mail.kde.org/pipermail/kdevelop-devel/2014-February/046910.html add_compile_flag_if_supported(-Wno-missing-field-initializers) +add_compile_flag_if_supported(-Werror=switch) add_compile_flag_if_supported(-Werror=undefined-bool-conversion) add_compile_flag_if_supported(-Werror=tautological-undefined-compare) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_flag_if_supported(-Wdocumentation) + add_compile_flag_if_supported(-Wcovered-switch-default) # This warning is triggered by every call to qCDebug() add_compile_flag_if_supported(-Wno-gnu-zero-variadic-macro-arguments) endif() diff --git a/kdevplatform/language/duchain/navigation/abstractdeclarationnavigationcontext.cpp b/kdevplatform/language/duchain/navigation/abstractdeclarationnavigationcontext.cpp --- a/kdevplatform/language/duchain/navigation/abstractdeclarationnavigationcontext.cpp +++ b/kdevplatform/language/duchain/navigation/abstractdeclarationnavigationcontext.cpp @@ -568,9 +568,6 @@ case ClassDeclarationData::Trait: modifyHtml() += QStringLiteral("trait "); break; - default: - modifyHtml() += QStringLiteral(" "); - break; } eventuallyMakeTypeLinks( klass.cast() ); diff --git a/kdevplatform/outputview/outputexecutejob.cpp b/kdevplatform/outputview/outputexecutejob.cpp --- a/kdevplatform/outputview/outputexecutejob.cpp +++ b/kdevplatform/outputview/outputexecutejob.cpp @@ -344,7 +344,6 @@ errorValue = i18n("Waiting for the process has timed out"); break; - default: case QProcess::UnknownError: errorValue = i18n("Exit code %1", d->m_process->exitCode()); break; diff --git a/kdevplatform/outputview/tests/test_filteringstrategy.cpp b/kdevplatform/outputview/tests/test_filteringstrategy.cpp --- a/kdevplatform/outputview/tests/test_filteringstrategy.cpp +++ b/kdevplatform/outputview/tests/test_filteringstrategy.cpp @@ -63,9 +63,8 @@ return QTest::newRow(QString(QLatin1String(dataTag)+QLatin1String("-windows-ns")).toUtf8().constData()); case WindowsFilePathWithSpaces: return QTest::newRow(QString(QLatin1String(dataTag)+QLatin1String("-windows-ws")).toUtf8().constData()); - default: - return QTest::newRow(dataTag); } + Q_UNREACHABLE(); } } diff --git a/kdevplatform/outputview/tests/testlinebuilderfunctions.h b/kdevplatform/outputview/tests/testlinebuilderfunctions.h --- a/kdevplatform/outputview/tests/testlinebuilderfunctions.h +++ b/kdevplatform/outputview/tests/testlinebuilderfunctions.h @@ -50,10 +50,8 @@ return QStringLiteral("/some/path/to/a/project"); case UnixFilePathWithSpaces: return QStringLiteral("/some/path with spaces/to/a/project"); - default: - Q_ASSERT(0); - return QStringLiteral("/we/should/never/end/up/here"); } + Q_UNREACHABLE(); } QString buildCppCheckErrorLine(TestPathType pathType = UnixFilePathNoSpaces) diff --git a/plugins/debuggercommon/midebugger.cpp b/plugins/debuggercommon/midebugger.cpp --- a/plugins/debuggercommon/midebugger.cpp +++ b/plugins/debuggercommon/midebugger.cpp @@ -281,9 +281,6 @@ // On-going status information about progress of a slow operation; may be ignored break; } - - default: - Q_ASSERT(false); } break; } diff --git a/plugins/debuggercommon/widgets/disassemblewidget.cpp b/plugins/debuggercommon/widgets/disassemblewidget.cpp --- a/plugins/debuggercommon/widgets/disassemblewidget.cpp +++ b/plugins/debuggercommon/widgets/disassemblewidget.cpp @@ -134,7 +134,6 @@ { switch(flavor) { - default: case DisassemblyFlavorUnknown: m_disassemblyFlavorAtt->setChecked(false); m_disassemblyFlavorIntel->setChecked(false); diff --git a/plugins/documentview/kdevdocumentmodel.cpp b/plugins/documentview/kdevdocumentmodel.cpp --- a/plugins/documentview/kdevdocumentmodel.cpp +++ b/plugins/documentview/kdevdocumentmodel.cpp @@ -45,9 +45,8 @@ return QIcon::fromTheme(QStringLiteral("document-revert")); case IDocument::DirtyAndModified: return QIcon::fromTheme(QStringLiteral("edit-delete")); - default: - return QIcon(); } + Q_UNREACHABLE(); } IDocument::DocumentState KDevDocumentItem::documentState() const diff --git a/plugins/filetemplates/overridespage.cpp b/plugins/filetemplates/overridespage.cpp --- a/plugins/filetemplates/overridespage.cpp +++ b/plugins/filetemplates/overridespage.cpp @@ -51,11 +51,8 @@ return i18n("Protected"); case Declaration::Private: return i18n("Private"); - default: - qCritical("Unexpected value for Declaration::AccessPolicy: %d", accessPolicy); - Q_ASSERT(false); - return QString(); } + Q_UNREACHABLE(); } static QString functionPropertiesToString(ClassFunctionDeclaration* decl) diff --git a/plugins/testview/testview.cpp b/plugins/testview/testview.cpp --- a/plugins/testview/testview.cpp +++ b/plugins/testview/testview.cpp @@ -217,10 +217,8 @@ case TestResult::Error: return QIcon::fromTheme(QStringLiteral("dialog-cancel")); - - default: - return QIcon::fromTheme(QLatin1String("")); } + Q_UNREACHABLE(); } QStandardItem* TestView::itemForSuite(ITestSuite* suite)