qa: Replace [[fallthrough]] by [[clang::fallthrough]]
authorManuel Nickschas <sputnick@quassel-irc.org>
Tue, 27 Feb 2018 10:33:03 +0000 (11:33 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Fri, 6 Apr 2018 16:23:52 +0000 (18:23 +0200)
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
src/core/eventstringifier.cpp
src/core/sqlitestorage.cpp
src/qtui/bufferwidget.cpp
src/qtui/chatscene.cpp
src/uisupport/networkmodelcontroller.cpp
src/uisupport/tabcompleter.cpp

index b97b532..47b1673 100644 (file)
@@ -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;
     }
index ae1b2b0..a8a4f53 100644 (file)
@@ -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;
     }
index a07c2fa..dd51ee3 100644 (file)
@@ -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);
index 86d3e2e..f6c2495 100644 (file)
@@ -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
index 00a6bb0..cfebf37 100644 (file)
@@ -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;
index c9a1594..5e4216d 100644 (file)
@@ -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();
index 5d6e889..d681340 100644 (file)
@@ -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();