Fix -Wimplicit-fallthrough for clang

Clang's `-Wimplicit-fallthrough` warnings are a little stricter than
gcc's interpretation:

switch (i) {
case 0:
    foo();
case 4:
    break;
}

While gcc accepts the implicit fallthrough, if the following statement
is a trivial `break`, clang will warn about it.

Change-Id: I38e0817f1bc034fbb552aeac21de1516edcbcbb0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit c26994ff1551aa5450383cc51bed9b4d39f973f7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tim Blechmann 2024-02-29 09:30:24 +08:00 committed by Qt Cherry-pick Bot
parent 91fa8748a1
commit 137568c920
29 changed files with 31 additions and 1 deletions

View File

@ -232,7 +232,7 @@ static CborError preparse_value(CborValue *it)
case SinglePrecisionFloat:
case DoublePrecisionFloat:
it->flags |= CborIteratorFlag_IntegerValueTooLarge;
/* fall through */
Q_FALLTHROUGH();
case TrueValue:
case NullValue:
case UndefinedValue:

View File

@ -1355,6 +1355,7 @@ static qsizetype indic_nextSyllableBoundary(QChar::Script script, const char16_t
// ### needs proper testing for correct two/three part matras
break;
}
Q_FALLTHROUGH();
case IndependentVowel:
case Invalid:
case Other:

View File

@ -709,6 +709,7 @@ int QDateTimeParser::sectionMaxSize(Section s, int count) const
case DaySectionMask:
qWarning("QDateTimeParser::sectionMaxSize: Invalid section %s",
SectionNode::name(s).toLatin1().constData());
break;
case NoSectionIndex:
case FirstSectionIndex:

View File

@ -2027,6 +2027,7 @@ bool QGuiApplication::event(QEvent *e)
return true;
}
}
break;
default:
break;
}

View File

@ -268,6 +268,7 @@ void qDrawEdge(QPainter *p, qreal x1, qreal y1, qreal x2, qreal y2, qreal dw1, q
default:
break;
}
break;
}
default:
break;

View File

@ -1234,6 +1234,7 @@ const uchar *QFontEngine::getCMap(const uchar *table, uint tableSize, bool *isSy
default:
break;
}
break;
default:
break;
}

View File

@ -135,6 +135,7 @@ FrameStatus Frame::validateHeader() const
// 6.6 PUSH_PROMISE
if (framePayloadSize < 4)
return FrameStatus::sizeError;
break;
default:
// DATA/HEADERS/CONTINUATION will be verified
// when we have payload.

View File

@ -436,6 +436,7 @@ bool QNativeSocketEnginePrivate::nativeConnect(const QHostAddress &addr, quint16
case EFAULT:
case ENOTSOCK:
socketState = QAbstractSocket::UnconnectedState;
break;
default:
break;
}

View File

@ -194,6 +194,7 @@ QEvdevTouchScreenHandler::QEvdevTouchScreenHandler(const QString &device, const
case 180:
case 270:
rotationAngle = argValue;
break;
default:
break;
}

View File

@ -59,6 +59,7 @@ QTuioHandler::QTuioHandler(const QString &specification)
case 180:
case 270:
rotationAngle = argValue;
break;
default:
break;
}

View File

@ -1146,6 +1146,7 @@ void QJpegHandler::setOption(ImageOption option, const QVariant &value)
int transformation = value.toInt();
if (transformation > 0 && transformation < 8)
d->transformation = QImageIOHandler::Transformations(transformation);
break;
}
default:
break;

View File

@ -135,6 +135,7 @@ void QXcbWindow::setImageFormatForVisual(const xcb_visualtype_t *visual)
case 16:
qWarning("Using RGB16 fallback, if this works your X11 server is reporting a bad screen format.");
m_imageFormat = QImage::Format_RGB16;
break;
default:
break;
}

View File

@ -352,6 +352,7 @@ bool QAccessibleTable::unselectRow(int row)
//the ones which are down the current row will be deselected
selection = QItemSelection(index, theModel->index(rowCount() - 1, 0, rootIndex));
}
break;
default:
break;
}
@ -392,6 +393,7 @@ bool QAccessibleTable::unselectColumn(int column)
//of the current rown, the ones which are at the right will be deselected
selection = QItemSelection(index, theModel->index(0, columnCount() - 1, rootIndex));
}
break;
default:
break;
}

View File

@ -2768,6 +2768,7 @@ QPixmap QMessageBoxPrivate::standardIcon(QMessageBox::Icon icon, QMessageBox *mb
break;
case QMessageBox::Question:
tmpIcon = style->standardIcon(QStyle::SP_MessageBoxQuestion, nullptr, mb);
break;
default:
break;
}

View File

@ -3253,6 +3253,7 @@ bool QGraphicsScene::event(QEvent *event)
// ### this should only be cleared if we received a new mouse move event,
// which relies on us fixing the replay mechanism in QGraphicsView.
d->cachedItemsUnderMouse.clear();
break;
default:
break;
}

View File

@ -4301,6 +4301,7 @@ QItemSelectionModel::SelectionFlags QAbstractItemViewPrivate::extendedSelectionC
default:
break;
}
break;
}
default:
break;

View File

@ -2645,6 +2645,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
Q_FALLTHROUGH();
case QEvent::Leave:
d->toolTipWakeUp.stop();
break;
default:
break;
}
@ -2669,6 +2670,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
|| key == Qt::Key_Up
|| key == Qt::Key_Right
|| key == Qt::Key_Down);
break;
}
default:
break;

View File

@ -329,6 +329,7 @@ bool QTipLabel::eventFilter(QObject *o, QEvent *e)
case QEvent::MouseMove:
if (o == widget && !rect.isNull() && !rect.contains(static_cast<QMouseEvent*>(e)->position().toPoint()))
hideTip();
break;
default:
break;
}

View File

@ -4224,6 +4224,7 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex
break;
case SC_SpinBoxFrame:
ret = spinbox->rect;
break;
default:
break;
}

View File

@ -3309,6 +3309,7 @@ QRect QFusionStyle::subControlRect(ComplexControl control, const QStyleOptionCom
break;
case SC_SpinBoxFrame:
rect = spinbox->rect;
break;
default:
break;
}

View File

@ -256,6 +256,7 @@ static QImage blendedImage(const QImage &start, const QImage &end, float alpha)
front_data += bpl;
}
}
break;
default:
break;
}

View File

@ -4871,6 +4871,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op
w = w->parentWidget(); //match on the QTabBar instead of the CloseButton
}
pseudoElement = PseudoElement_TabBarTabCloseButton;
break;
#endif
default:

View File

@ -2043,6 +2043,7 @@ QVariant operator-(const QVariant &arg1, const QVariant &arg2)
dt.setTime(dt.time().addMSecs(msecs));
ret = QVariant(dt);
}
break;
}
default: break;
}

View File

@ -3099,6 +3099,7 @@ bool QCalendarWidget::event(QEvent *event)
case QEvent::StyleChange:
d->cachedSizeHint = QSize();
d->m_view->updateGeometry();
break;
default:
break;
}

View File

@ -1331,6 +1331,7 @@ void QDateTimeEdit::focusInEvent(QFocusEvent *event)
case Qt::ActiveWindowFocusReason:
if (oldHasHadFocus)
return;
break;
case Qt::ShortcutFocusReason:
case Qt::TabFocusReason:
default:

View File

@ -292,6 +292,7 @@ void QAlphaWidget::alphaBlend()
back_data += bpl;
front_data += bpl;
}
break;
}
default:
break;

View File

@ -338,6 +338,7 @@ bool QDockWidgetGroupWindow::event(QEvent *e)
case QEvent::Resize:
updateCurrentGapRect();
emit resized();
break;
default:
break;
}

View File

@ -1084,6 +1084,7 @@ bool QToolBar::event(QEvent *event)
d->layout->setExpanded(false);
break;
}
break;
default:
break;
}

View File

@ -1638,6 +1638,7 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event)
setText(m_completer->currentCompletion());
inlineCompletionAccepted = true;
}
break;
default:
break; // normal key processing
}