From 9ba2ca5186c8598e33910a7df95bbdbf812a1a3d 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 --- 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 ff1d2415..ec875690 100644 --- a/src/core/coresessioneventprocessor.cpp +++ b/src/core/coresessioneventprocessor.cpp @@ -985,13 +985,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 b0f9d307..0e5c669e 100644 --- a/src/core/eventstringifier.cpp +++ b/src/core/eventstringifier.cpp @@ -598,13 +598,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 473f66e5..5c483e3d 100644 --- a/src/core/sqlitestorage.cpp +++ b/src/core/sqlitestorage.cpp @@ -1836,7 +1836,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 f11094ba..2a92b529 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 1588f4df..1a5ba1bb 100644 --- a/src/qtui/chatscene.cpp +++ b/src/qtui/chatscene.cpp @@ -1295,8 +1295,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; @@ -1323,8 +1323,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 88e48e31..6d2409f6 100644 --- a/src/uisupport/networkmodelcontroller.cpp +++ b/src/uisupport/networkmodelcontroller.cpp @@ -362,7 +362,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 46d8a8df..faad451c 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