From fefbb186cc197295ce493322832cadf22ee1cefe Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Tue, 27 Feb 2018 11:33:03 +0100 Subject: [PATCH] qa: Replace [[fallthrough]] by [[clang::fallthrough]] The [[fallthrough]] attribute is a C++17 extension. It happens to work in GCC 7, but causes warnings or even failures in other compilers. In my quest to find a syntax that makes all compilers happy without having to disable the (useful) warning, I think I have finally found a way. Using the clang:: namespace seems to solve several issues: * It is marked as a compiler extension, so compilers not supporting it should simply ignore the attribute * It (obviously) works in Clang, which is nice when using a Clang-based IDE like Qt Creator * For some reason, it also seems to silence warnings in GCC; I guess one of GCC's fancy regexes somehow matches (cherry picked from commit 9ba2ca5186c8598e33910a7df95bbdbf812a1a3d) --- src/core/coresessioneventprocessor.cpp | 6 +++--- src/core/eventstringifier.cpp | 6 +++--- src/core/sqlitestorage.cpp | 2 +- src/qtui/bufferwidget.cpp | 2 +- src/qtui/chatscene.cpp | 8 ++++---- src/uisupport/networkmodelcontroller.cpp | 2 +- src/uisupport/tabcompleter.cpp | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/core/coresessioneventprocessor.cpp b/src/core/coresessioneventprocessor.cpp index b97b5328..47b16736 100644 --- a/src/core/coresessioneventprocessor.cpp +++ b/src/core/coresessioneventprocessor.cpp @@ -718,13 +718,13 @@ void CoreSessionEventProcessor::processIrcEvent322(IrcEvent *e) switch (e->params().count()) { case 3: topic = e->params()[2]; - [[fallthrough]]; + [[clang::fallthrough]]; case 2: userCount = e->params()[1].toUInt(); - [[fallthrough]]; + [[clang::fallthrough]]; case 1: channelName = e->params()[0]; - [[fallthrough]]; + [[clang::fallthrough]]; default: break; } diff --git a/src/core/eventstringifier.cpp b/src/core/eventstringifier.cpp index ae1b2b04..a8a4f53c 100644 --- a/src/core/eventstringifier.cpp +++ b/src/core/eventstringifier.cpp @@ -531,13 +531,13 @@ void EventStringifier::processIrcEvent322(IrcEvent *e) switch (e->params().count()) { case 3: topic = e->params()[2]; - [[fallthrough]]; + [[clang::fallthrough]]; case 2: userCount = e->params()[1].toUInt(); - [[fallthrough]]; + [[clang::fallthrough]]; case 1: channelName = e->params()[0]; - [[fallthrough]]; + [[clang::fallthrough]]; default: break; } diff --git a/src/core/sqlitestorage.cpp b/src/core/sqlitestorage.cpp index a07c2fa5..dd51ee31 100644 --- a/src/core/sqlitestorage.cpp +++ b/src/core/sqlitestorage.cpp @@ -1720,7 +1720,7 @@ bool SqliteStorage::safeExec(QSqlQuery &query, int retryCount) switch (query.lastError().number()) { case 5: // SQLITE_BUSY 5 /* The database file is locked */ - [[fallthrough]]; + [[clang::fallthrough]]; case 6: // SQLITE_LOCKED 6 /* A table in the database is locked */ if (retryCount < _maxRetryCount) return safeExec(query, retryCount + 1); diff --git a/src/qtui/bufferwidget.cpp b/src/qtui/bufferwidget.cpp index 86d3e2ed..f6c24951 100644 --- a/src/qtui/bufferwidget.cpp +++ b/src/qtui/bufferwidget.cpp @@ -232,7 +232,7 @@ bool BufferWidget::eventFilter(QObject *watched, QEvent *event) case Qt::Key_Down: if (!(keyEvent->modifiers() & Qt::ShiftModifier)) return false; - [[fallthrough]]; + [[clang::fallthrough]]; case Qt::Key_PageUp: case Qt::Key_PageDown: // static cast to access public qobject::event diff --git a/src/qtui/chatscene.cpp b/src/qtui/chatscene.cpp index 00a6bb07..cfebf37e 100644 --- a/src/qtui/chatscene.cpp +++ b/src/qtui/chatscene.cpp @@ -1257,8 +1257,8 @@ void ChatScene::webPreviewNextStep() qWarning() << "removing preview"; if (webPreview.previewItem && webPreview.previewItem->scene()) removeItem(webPreview.previewItem); - // Fall through to deletion! - [[fallthrough]]; + // Fall through to deletion! + [[clang::fallthrough]]; case WebPreview::HidePreview: if (webPreview.previewItem) { delete webPreview.previewItem; @@ -1285,8 +1285,8 @@ void ChatScene::clearWebPreview(ChatItem *parentItem) if (webPreview.previewItem && webPreview.previewItem->scene()) removeItem(webPreview.previewItem); } - // fall through into to set hidden state - [[fallthrough]]; + // fall through into to set hidden state + [[clang::fallthrough]]; case WebPreview::DelayPreview: // we're just loading, so haven't shown the preview yet. webPreview.previewState = WebPreview::HidePreview; diff --git a/src/uisupport/networkmodelcontroller.cpp b/src/uisupport/networkmodelcontroller.cpp index c9a1594f..5e4216dc 100644 --- a/src/uisupport/networkmodelcontroller.cpp +++ b/src/uisupport/networkmodelcontroller.cpp @@ -358,7 +358,7 @@ void NetworkModelController::handleHideAction(ActionType type, QAction *action) return; case HideApplyToAll: BufferSettings().setMessageFilter(filter); - [[fallthrough]]; + [[clang::fallthrough]]; case HideUseDefaults: if (_messageFilter) BufferSettings(_messageFilter->idString()).removeFilter(); diff --git a/src/uisupport/tabcompleter.cpp b/src/uisupport/tabcompleter.cpp index 5d6e889b..d6813400 100644 --- a/src/uisupport/tabcompleter.cpp +++ b/src/uisupport/tabcompleter.cpp @@ -109,7 +109,7 @@ void TabCompleter::buildCompletionList() case BufferInfo::QueryBuffer: if (regex.indexIn(_currentBufferName) > -1) _completionMap[_currentBufferName.toLower()] = _currentBufferName; - [[fallthrough]]; + [[clang::fallthrough]]; case BufferInfo::StatusBuffer: if (!_currentNetwork->myNick().isEmpty() && regex.indexIn(_currentNetwork->myNick()) > -1) _completionMap[_currentNetwork->myNick().toLower()] = _currentNetwork->myNick(); -- 2.20.1