diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -123,9 +123,11 @@ 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) +add_compile_flag_if_supported(-Werror=implicit-fallthrough) # Use Q_FALLTHROUGH for false positives. if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_flag_if_supported(-Wdocumentation) add_compile_flag_if_supported(-Wcovered-switch-default) + add_compile_flag_if_supported(-Wunreachable-code-break) # 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/codecompletion/normaldeclarationcompletionitem.cpp b/kdevplatform/language/codecompletion/normaldeclarationcompletionitem.cpp --- a/kdevplatform/language/codecompletion/normaldeclarationcompletionitem.cpp +++ b/kdevplatform/language/codecompletion/normaldeclarationcompletionitem.cpp @@ -194,7 +194,6 @@ break; case CodeCompletionModel::BestMatchesCount: return QVariant(normalBestMatchesCount); - break; case CodeCompletionModel::IsExpandable: return QVariant(createsExpandingWidget()); case CodeCompletionModel::ExpandingWidget: { diff --git a/kdevplatform/language/duchain/navigation/abstractnavigationcontext.cpp b/kdevplatform/language/duchain/navigation/abstractnavigationcontext.cpp --- a/kdevplatform/language/duchain/navigation/abstractnavigationcontext.cpp +++ b/kdevplatform/language/duchain/navigation/abstractnavigationcontext.cpp @@ -210,7 +210,7 @@ if( ctx && ctx->declaration() == action.decl ) return NavigationContextPointer(d->m_previousContext); return registerChild(action.decl); - } break; + } case NavigationAction::NavigateUses: { IContextBrowser* browser = ICore::self()->pluginController()->extensionForPlugin(); diff --git a/kdevplatform/language/duchain/stringhelpers.cpp b/kdevplatform/language/duchain/stringhelpers.cpp --- a/kdevplatform/language/duchain/stringhelpers.cpp +++ b/kdevplatform/language/duchain/stringhelpers.cpp @@ -191,7 +191,6 @@ a++; } continue; - break; case '\'': last = str[a]; a++; @@ -201,7 +200,6 @@ a++; } continue; - break; } last = str[a]; diff --git a/kdevplatform/outputview/outputmodel.cpp b/kdevplatform/outputview/outputmodel.cpp --- a/kdevplatform/outputview/outputmodel.cpp +++ b/kdevplatform/outputview/outputmodel.cpp @@ -260,15 +260,10 @@ { case Qt::DisplayRole: return d->m_filteredItems.at( idx.row() ).originalLine; - break; case OutputModel::OutputItemTypeRole: return static_cast(d->m_filteredItems.at( idx.row() ).type); - break; case Qt::FontRole: return QFontDatabase::systemFont(QFontDatabase::FixedFont); - break; - default: - break; } } return QVariant(); diff --git a/kdevplatform/project/projectbuildsetmodel.cpp b/kdevplatform/project/projectbuildsetmodel.cpp --- a/kdevplatform/project/projectbuildsetmodel.cpp +++ b/kdevplatform/project/projectbuildsetmodel.cpp @@ -266,10 +266,8 @@ { case 0: return d->items.at(idx.row()).itemName(); - break; case 1: return KDevelop::joinWithEscaping(d->items.at(idx.row()).itemPath(), QLatin1Char('/'), QLatin1Char('\\')); - break; } } else if(role == Qt::DecorationRole && idx.column()==0) { KDevelop::ProjectBaseItem* item = d->items.at(idx.row()).findItem(); @@ -290,10 +288,8 @@ { case 0: return i18nc("@title:column buildset item name", "Name"); - break; case 1: return i18nc("@title:column buildset item path", "Path"); - break; } return QVariant(); } diff --git a/kdevplatform/shell/sessionlock.cpp b/kdevplatform/shell/sessionlock.cpp --- a/kdevplatform/shell/sessionlock.cpp +++ b/kdevplatform/shell/sessionlock.cpp @@ -208,13 +208,11 @@ switch( ret ) { case KMessageBox::Yes: return sessionId; - break; case KMessageBox::No: { QString errmsg = i18nc("@info", "The session %1 is already active in another running instance.", sessionName); return SessionController::showSessionChooserDialog(errmsg); - break; } case KMessageBox::Cancel: diff --git a/kdevplatform/vcs/vcsrevision.cpp b/kdevplatform/vcs/vcsrevision.cpp --- a/kdevplatform/vcs/vcsrevision.cpp +++ b/kdevplatform/vcs/vcsrevision.cpp @@ -131,36 +131,26 @@ case GlobalNumber: case FileNumber: return (revisionValue().type() == QVariant::String ? revisionValue().toString() : QString::number(revisionValue().toLongLong())); - break; case Special: switch( revisionValue().value( ) ) { case VcsRevision::Head: return QStringLiteral("Head"); - break; case VcsRevision::Base: return QStringLiteral("Base"); - break; case VcsRevision::Working: return QStringLiteral("Working"); - break; case VcsRevision::Previous: return QStringLiteral("Previous"); - break; case VcsRevision::Start: return QStringLiteral("Start"); - break; default: return QStringLiteral("User"); - break; } - break; case Date: return revisionValue().toDateTime().toString( Qt::LocalDate ); - break; default: return revisionValue().toString(); - break; } } @@ -174,16 +164,12 @@ case VcsRevision::FileNumber: return (revisionValue.type() == QVariant::String ? ::qHash(revisionValue.toString()) : ::qHash(revisionValue.toULongLong())); - break; case VcsRevision::Special: return ::qHash(static_cast(revisionValue.value())); - break; case VcsRevision::Date: return ::qHash(revisionValue.toDateTime()); - break; default: - break; + return ::qHash(revisionValue.toString()); } - return ::qHash(revisionValue.toString()); } diff --git a/plugins/clang/duchain/clangdiagnosticevaluator.cpp b/plugins/clang/duchain/clangdiagnosticevaluator.cpp --- a/plugins/clang/duchain/clangdiagnosticevaluator.cpp +++ b/plugins/clang/duchain/clangdiagnosticevaluator.cpp @@ -119,13 +119,10 @@ switch (diagnosticType(diagnostic)) { case IncludeFileNotFoundProblem: return new MissingIncludePathProblem(diagnostic, unit); - break; case UnknownDeclarationProblem: return new class UnknownDeclarationProblem(diagnostic, unit); - break; default: return new ClangProblem(diagnostic, unit); - break; } } diff --git a/plugins/clang/duchain/clangproblem.cpp b/plugins/clang/duchain/clangproblem.cpp --- a/plugins/clang/duchain/clangproblem.cpp +++ b/plugins/clang/duchain/clangproblem.cpp @@ -47,7 +47,6 @@ return IProblem::Hint; } return IProblem::Warning; - break; default: return IProblem::Hint; } diff --git a/plugins/custom-definesandincludes/kcm_widget/projectpathsmodel.cpp b/plugins/custom-definesandincludes/kcm_widget/projectpathsmodel.cpp --- a/plugins/custom-definesandincludes/kcm_widget/projectpathsmodel.cpp +++ b/plugins/custom-definesandincludes/kcm_widget/projectpathsmodel.cpp @@ -45,27 +45,20 @@ switch( role ) { case IncludesDataRole: return pathConfig.includes; - break; case DefinesDataRole: return QVariant::fromValue(pathConfig.defines); - break; case Qt::EditRole: return sanitizePath( pathConfig.path, true, false ); - break; case Qt::DisplayRole: { const QString& path = pathConfig.path; return (path == QLatin1String(".")) ? QStringLiteral("(project root)") : path; - break; } case FullUrlDataRole: return QVariant::fromValue(QUrl::fromUserInput( sanitizePath( pathConfig.path, true, false ) )); - break; case CompilerDataRole: return QVariant::fromValue(pathConfig.compiler); - break; case ParserArgumentsRole: return QVariant::fromValue(pathConfig.parserArguments); - break; default: break; } @@ -126,7 +119,6 @@ break; default: return false; - break; } emit dataChanged( index, index ); return true; diff --git a/plugins/ghprovider/ghproviderwidget.cpp b/plugins/ghprovider/ghproviderwidget.cpp --- a/plugins/ghprovider/ghproviderwidget.cpp +++ b/plugins/ghprovider/ghproviderwidget.cpp @@ -40,6 +40,8 @@ #include #include +#include + using namespace KDevelop; namespace gh { @@ -163,6 +165,7 @@ case 2: /* Known organization */ text = m_combo->currentText(); enabled = false; + Q_FALLTHROUGH(); default:/* Looking for some organization's repo. */ uri = QStringLiteral("/orgs/%1/repos").arg(text); break; diff --git a/plugins/makebuilder/makejob.cpp b/plugins/makebuilder/makejob.cpp --- a/plugins/makebuilder/makejob.cpp +++ b/plugins/makebuilder/makejob.cpp @@ -158,7 +158,6 @@ case KDevelop::ProjectBaseItem::Folder: case KDevelop::ProjectBaseItem::BuildFolder: return static_cast(item)->path().toUrl(); - break; case KDevelop::ProjectBaseItem::Target: case KDevelop::ProjectBaseItem::File: break; diff --git a/plugins/perforce/perforceplugin.cpp b/plugins/perforce/perforceplugin.cpp --- a/plugins/perforce/perforceplugin.cpp +++ b/plugins/perforce/perforceplugin.cpp @@ -329,6 +329,7 @@ default: break; } + break; default: break; }