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>
Thu, 5 Apr 2018 21:45:17 +0000 (23:45 +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

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 ff1d241..ec87569 100644 (file)
@@ -985,13 +985,13 @@ void CoreSessionEventProcessor::processIrcEvent322(IrcEvent *e)
     switch (e->params().count()) {
     case 3:
         topic = e->params()[2];
     switch (e->params().count()) {
     case 3:
         topic = e->params()[2];
-        [[fallthrough]];
+        [[clang::fallthrough]];
     case 2:
         userCount = e->params()[1].toUInt();
     case 2:
         userCount = e->params()[1].toUInt();
-        [[fallthrough]];
+        [[clang::fallthrough]];
     case 1:
         channelName = e->params()[0];
     case 1:
         channelName = e->params()[0];
-        [[fallthrough]];
+        [[clang::fallthrough]];
     default:
         break;
     }
     default:
         break;
     }
index b0f9d30..0e5c669 100644 (file)
@@ -598,13 +598,13 @@ void EventStringifier::processIrcEvent322(IrcEvent *e)
     switch (e->params().count()) {
     case 3:
         topic = e->params()[2];
     switch (e->params().count()) {
     case 3:
         topic = e->params()[2];
-        [[fallthrough]];
+        [[clang::fallthrough]];
     case 2:
         userCount = e->params()[1].toUInt();
     case 2:
         userCount = e->params()[1].toUInt();
-        [[fallthrough]];
+        [[clang::fallthrough]];
     case 1:
         channelName = e->params()[0];
     case 1:
         channelName = e->params()[0];
-        [[fallthrough]];
+        [[clang::fallthrough]];
     default:
         break;
     }
     default:
         break;
     }
index 473f66e..5c483e3 100644 (file)
@@ -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 */
 
     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);
     case 6: // SQLITE_LOCKED       6   /* A table in the database is locked */
         if (retryCount < _maxRetryCount)
             return safeExec(query, retryCount + 1);
index f11094b..2a92b52 100644 (file)
@@ -232,7 +232,7 @@ bool BufferWidget::eventFilter(QObject *watched, QEvent *event)
     case Qt::Key_Down:
         if (!(keyEvent->modifiers() & Qt::ShiftModifier))
             return false;
     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
     case Qt::Key_PageUp:
     case Qt::Key_PageDown:
         // static cast to access public qobject::event
index 1588f4d..1a5ba1b 100644 (file)
@@ -1295,8 +1295,8 @@ void ChatScene::webPreviewNextStep()
         qWarning() << "removing preview";
         if (webPreview.previewItem && webPreview.previewItem->scene())
             removeItem(webPreview.previewItem);
         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;
     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);
         }
             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;
     case WebPreview::DelayPreview:
         // we're just loading, so haven't shown the preview yet.
         webPreview.previewState = WebPreview::HidePreview;
index 88e48e3..6d2409f 100644 (file)
@@ -362,7 +362,7 @@ void NetworkModelController::handleHideAction(ActionType type, QAction *action)
         return;
     case HideApplyToAll:
         BufferSettings().setMessageFilter(filter);
         return;
     case HideApplyToAll:
         BufferSettings().setMessageFilter(filter);
-        [[fallthrough]];
+        [[clang::fallthrough]];
     case HideUseDefaults:
         if (_messageFilter)
             BufferSettings(_messageFilter->idString()).removeFilter();
     case HideUseDefaults:
         if (_messageFilter)
             BufferSettings(_messageFilter->idString()).removeFilter();
index 46d8a8d..faad451 100644 (file)
@@ -109,7 +109,7 @@ void TabCompleter::buildCompletionList()
         case BufferInfo::QueryBuffer:
             if (regex.indexIn(_currentBufferName) > -1)
                 _completionMap[_currentBufferName.toLower()] = _currentBufferName;
         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();
         case BufferInfo::StatusBuffer:
             if (!_currentNetwork->myNick().isEmpty() && regex.indexIn(_currentNetwork->myNick()) > -1)
                 _completionMap[_currentNetwork->myNick().toLower()] = _currentNetwork->myNick();