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)
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;
}
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;
}
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 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
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;
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;
return;
case HideApplyToAll:
BufferSettings().setMessageFilter(filter);
- [[fallthrough]];
+ [[clang::fallthrough]];
case HideUseDefaults:
if (_messageFilter)
BufferSettings(_messageFilter->idString()).removeFilter();
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();