From 9f888d2fde9c5413e5519e0914e9b13638760985 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 27 Jun 2016 15:43:33 +0200 Subject: Support C++17 fallthrough attribute Replaces our mix of comments for annotating intended absence of break in switches with the C++17 attribute [[fallthrough]], or its earlier a clang extension counterpart. Change-Id: I4b2d0b9b5e4425819c7f1bf01608093c536b6d14 Reviewed-by: Thiago Macieira --- qmake/library/qmakebuiltins.cpp | 2 +- qmake/library/qmakeevaluator.cpp | 6 +++--- src/corelib/codecs/qiconvcodec.cpp | 2 +- src/corelib/codecs/qjiscodec.cpp | 2 +- src/corelib/global/qcompilerdetection.h | 12 +++++++++++ src/corelib/global/qglobal.cpp | 14 +++++++++++++ src/corelib/io/qsettings.cpp | 2 +- src/corelib/io/qsettings_win.cpp | 2 +- src/corelib/json/qjson.cpp | 4 ++-- src/corelib/kernel/qmimedata.cpp | 2 +- src/corelib/kernel/qsystemerror.cpp | 3 ++- src/corelib/kernel/qtimerinfo_unix.cpp | 3 +-- src/corelib/kernel/qvariant.cpp | 6 +++--- src/corelib/tools/qdatetime.cpp | 2 +- src/corelib/tools/qdatetimeparser.cpp | 11 +++++----- src/corelib/tools/qregexp.cpp | 6 +++--- src/corelib/tools/qunicodetools.cpp | 4 ++-- src/corelib/xml/qxmlstream.cpp | 24 +++++++++++----------- src/corelib/xml/qxmlstream_p.h | 14 ++++++------- src/dbus/qdbusmarshaller.cpp | 8 ++++---- src/dbus/qdbusmetatype.cpp | 2 +- src/gui/image/qimage.cpp | 4 ++-- src/gui/image/qimagereader.cpp | 2 +- src/gui/image/qpixmap_blitter.cpp | 4 ++-- src/gui/kernel/qplatformgraphicsbufferhelper.cpp | 4 ++-- src/gui/painting/qcssutil.cpp | 2 +- src/gui/painting/qpathclipper.cpp | 4 ++-- src/gui/painting/qpdf.cpp | 4 ++-- src/gui/painting/qplatformbackingstore.cpp | 4 ++-- src/gui/painting/qtransform.cpp | 12 +++++------ src/gui/painting/qtriangulator.cpp | 6 +++--- src/gui/text/qfontsubset.cpp | 2 +- src/gui/text/qtextcursor.cpp | 8 ++++---- src/gui/text/qtextdocumentfragment.cpp | 2 +- src/gui/text/qtextengine.cpp | 14 ++++++------- src/gui/text/qtexthtmlparser.cpp | 6 +++--- src/network/access/qftp.cpp | 2 +- .../access/qhttpnetworkconnectionchannel.cpp | 3 ++- src/network/access/qhttpprotocolhandler.cpp | 7 ++++--- src/network/access/qnetworkcookie.cpp | 2 +- src/network/kernel/qhostaddress.cpp | 2 +- src/network/socket/qnativesocketengine_win.cpp | 2 +- src/network/socket/qsocks5socketengine.cpp | 4 ++-- src/platformsupport/fbconvenience/qfbvthandler.cpp | 2 +- src/plugins/bearer/qnetworksession_impl.cpp | 4 ++-- .../platforms/android/qandroidplatformtheme.cpp | 2 +- src/plugins/platforms/cocoa/qprintengine_mac.mm | 2 +- .../direct2d/qwindowsdirect2dpaintengine.cpp | 2 +- src/plugins/platforms/windows/qwindowscontext.cpp | 3 ++- src/plugins/platforms/windows/qwindowstheme.cpp | 6 +++--- src/printsupport/kernel/qprintengine_pdf.cpp | 2 +- src/printsupport/kernel/qprintengine_win.cpp | 2 +- src/testlib/qtestmouse.h | 4 ++-- src/tools/moc/moc.cpp | 2 +- src/tools/moc/preprocessor.cpp | 10 ++++----- src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp | 8 ++++---- src/widgets/dialogs/qmessagebox.cpp | 3 ++- src/widgets/graphicsview/qgraphicsitem.cpp | 2 +- src/widgets/itemviews/qheaderview.cpp | 4 ++-- src/widgets/itemviews/qtreewidget.cpp | 4 ++-- src/widgets/kernel/qwhatsthis.cpp | 2 +- src/widgets/kernel/qwidget.cpp | 10 ++++----- src/widgets/styles/qcommonstyle.cpp | 6 ++---- src/widgets/styles/qstylesheetstyle.cpp | 2 +- src/widgets/styles/qwindowsstyle.cpp | 5 +++-- src/widgets/styles/qwindowsxpstyle.cpp | 14 ++++++------- src/widgets/util/qflickgesture.cpp | 10 ++++----- src/widgets/widgets/qabstractbutton.cpp | 2 +- src/widgets/widgets/qabstractslider.cpp | 2 +- src/widgets/widgets/qcombobox.cpp | 4 ++-- src/widgets/widgets/qmenu.cpp | 3 ++- 71 files changed, 191 insertions(+), 162 deletions(-) diff --git a/qmake/library/qmakebuiltins.cpp b/qmake/library/qmakebuiltins.cpp index 628210b55b..616b05e82d 100644 --- a/qmake/library/qmakebuiltins.cpp +++ b/qmake/library/qmakebuiltins.cpp @@ -321,7 +321,7 @@ QMakeEvaluator::quoteValue(const ProString &val) break; case 32: quote = true; - // fallthrough + Q_FALLTHROUGH(); default: ret += c; break; diff --git a/qmake/library/qmakeevaluator.cpp b/qmake/library/qmakeevaluator.cpp index 9d7ed2099b..789d6d77f0 100644 --- a/qmake/library/qmakeevaluator.cpp +++ b/qmake/library/qmakeevaluator.cpp @@ -318,7 +318,7 @@ ProStringList QMakeEvaluator::split_value_list(const QStringRef &vals, const Pro --x; } } - // fallthrough + Q_FALLTHROUGH(); default: hadWord = true; break; @@ -1643,7 +1643,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::expandVariableReferences( tokPtr++; continue; } - // fallthrough + Q_FALLTHROUGH(); default: Q_ASSERT_X(false, "expandVariableReferences", "Unrecognized token"); break; @@ -2109,7 +2109,7 @@ QString QMakeEvaluator::formatValue(const ProString &val, bool forceQuote) break; case 32: quote = true; - // fallthrough + Q_FALLTHROUGH(); default: ret += c; break; diff --git a/src/corelib/codecs/qiconvcodec.cpp b/src/corelib/codecs/qiconvcodec.cpp index 96f1ee16ac..845155dce0 100644 --- a/src/corelib/codecs/qiconvcodec.cpp +++ b/src/corelib/codecs/qiconvcodec.cpp @@ -411,7 +411,7 @@ QByteArray QIconvCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt switch (errno) { case EILSEQ: ++invalidCount; - // fall through + Q_FALLTHROUGH(); case EINVAL: { inBytes += sizeof(QChar); diff --git a/src/corelib/codecs/qjiscodec.cpp b/src/corelib/codecs/qjiscodec.cpp index 9c628c6012..a8625db054 100644 --- a/src/corelib/codecs/qjiscodec.cpp +++ b/src/corelib/codecs/qjiscodec.cpp @@ -288,7 +288,7 @@ QString QJisCodec::convertToUnicode(const char* chars, int len, ConverterState * result += QLatin1Char(ch); break; } - /* fall through */ + Q_FALLTHROUGH(); case JISX0201_Latin: u = conv->jisx0201ToUnicode(ch); result += QValidChar(u); diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 70c9e97c13..085e3063b4 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -1341,6 +1341,18 @@ Q_ASSUME_IMPL(valueOfExpression);\ } while (0) +#if QT_HAS_CPP_ATTRIBUTE(fallthrough) +# define Q_FALLTHROUGH() [[fallthrough]] +#elif defined(__cplusplus) +/* Clang can not parse namespaced attributes in C mode, but defines __has_cpp_attribute */ +# if QT_HAS_CPP_ATTRIBUTE(clang::fallthrough) +# define Q_FALLTHROUGH() [[clang::fallthrough]] +# endif +#endif +#ifndef Q_FALLTHROUGH +# define Q_FALLTHROUGH() (void)0 +#endif + /* Sanitize compiler feature availability diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 03216358aa..170dd757d3 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2949,6 +2949,20 @@ QString QSysInfo::machineHostName() \sa Q_ASSERT(), Q_ASSUME(), qFatal() */ +/*! + \macro void Q_FALLTHROUGH() + \relates + \since 5.8 + + Can be used in switch statements at the end of case block to tell the compiler + and other developers that that the lack of a break statement is intentional. + + This is useful since a missing break statement is often a bug, and some + compilers can be configured to emit warnings when one is not found. + + \sa Q_UNREACHABLE() +*/ + /*! \macro void Q_CHECK_PTR(void *pointer) \relates diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index 856108e417..11f201344e 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -813,7 +813,7 @@ StNormal: ++i; goto StSkipSpaces; } - // fallthrough + Q_FALLTHROUGH(); default: { int j = i + 1; while (j < to) { diff --git a/src/corelib/io/qsettings_win.cpp b/src/corelib/io/qsettings_win.cpp index 7c6b782acd..3f06ab7043 100644 --- a/src/corelib/io/qsettings_win.cpp +++ b/src/corelib/io/qsettings_win.cpp @@ -742,7 +742,7 @@ void QWinSettingsPrivate::set(const QString &uKey, const QVariant &value) } case QVariant::ByteArray: - // fallthrough intended + Q_FALLTHROUGH(); default: { // If the string does not contain '\0', we can use REG_SZ, the native registry diff --git a/src/corelib/json/qjson.cpp b/src/corelib/json/qjson.cpp index 4b98ef076c..e9a1366af0 100644 --- a/src/corelib/json/qjson.cpp +++ b/src/corelib/json/qjson.cpp @@ -339,7 +339,7 @@ bool Value::isValid(const Base *b) const case QJsonValue::Double: if (latinOrIntValue) break; - // fall through + Q_FALLTHROUGH(); case QJsonValue::String: case QJsonValue::Array: case QJsonValue::Object: @@ -418,7 +418,7 @@ uint Value::valueToStore(const QJsonValue &v, uint offset) if (c != INT_MAX) return c; } - // fall through + Q_FALLTHROUGH(); case QJsonValue::String: case QJsonValue::Array: case QJsonValue::Object: diff --git a/src/corelib/kernel/qmimedata.cpp b/src/corelib/kernel/qmimedata.cpp index 95153f8fa9..a550ca6ca1 100644 --- a/src/corelib/kernel/qmimedata.cpp +++ b/src/corelib/kernel/qmimedata.cpp @@ -167,7 +167,7 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Ty case QVariant::List: { if (format != QLatin1String("text/uri-list")) break; - // fall through + Q_FALLTHROUGH(); } case QVariant::Url: { QByteArray ba = data.toByteArray(); diff --git a/src/corelib/kernel/qsystemerror.cpp b/src/corelib/kernel/qsystemerror.cpp index f38daec4f8..3899f24d3b 100644 --- a/src/corelib/kernel/qsystemerror.cpp +++ b/src/corelib/kernel/qsystemerror.cpp @@ -149,12 +149,13 @@ QString QSystemError::toString() const return windowsErrorString(errorCode); #else //unix: fall through as native and standard library are the same + Q_FALLTHROUGH(); #endif case StandardLibraryError: return standardLibraryErrorString(errorCode); default: qWarning("invalid error scope"); - //fall through + Q_FALLTHROUGH(); case NoError: return QLatin1String("No error"); } diff --git a/src/corelib/kernel/qtimerinfo_unix.cpp b/src/corelib/kernel/qtimerinfo_unix.cpp index 56337bdb45..c3b8c86063 100644 --- a/src/corelib/kernel/qtimerinfo_unix.cpp +++ b/src/corelib/kernel/qtimerinfo_unix.cpp @@ -468,7 +468,6 @@ void QTimerInfoList::registerTimer(int timerId, int interval, Qt::TimerType time // above 20 s, 5% inaccuracy is above 1 s, so we convert to VeryCoarseTimer if (interval >= 20000) { t->timerType = Qt::VeryCoarseTimer; - // fall through } else { t->timeout = expected; if (interval <= 20) { @@ -479,7 +478,7 @@ void QTimerInfoList::registerTimer(int timerId, int interval, Qt::TimerType time } break; } - // fall through + Q_FALLTHROUGH(); case Qt::VeryCoarseTimer: // the very coarse timer is based on full second precision, // so we keep the interval in seconds (round to closest second) diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index f1d38db96c..d21529d124 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -203,7 +203,7 @@ static qlonglong qConvertToNumber(const QVariant::Private *d, bool *ok) case QMetaType::QJsonValue: if (!v_cast(d)->isDouble()) break; - // no break + Q_FALLTHROUGH(); #endif case QVariant::Double: case QVariant::Int: @@ -278,7 +278,7 @@ static qulonglong qConvertToUnsignedNumber(const QVariant::Private *d, bool *ok) case QMetaType::QJsonValue: if (!v_cast(d)->isDouble()) break; - // no break + Q_FALLTHROUGH(); #endif case QVariant::Double: case QVariant::Int: @@ -3119,7 +3119,7 @@ bool QVariant::canConvert(int targetTypeId) const case QVariant::Int: if (currentType == QVariant::KeySequence) return true; - // fall through + Q_FALLTHROUGH(); case QVariant::UInt: case QVariant::LongLong: case QVariant::ULongLong: diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index ee5ee5c362..a2c92835fe 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -2656,7 +2656,7 @@ static void setTimeSpec(QDateTimeData &d, Qt::TimeSpec spec, int offsetSeconds) case Qt::TimeZone: // Use system time zone instead spec = Qt::LocalTime; - // fallthrough + Q_FALLTHROUGH(); case Qt::UTC: case Qt::LocalTime: offsetSeconds = 0; diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp index 9c9009d636..ac973b047f 100644 --- a/src/corelib/tools/qdatetimeparser.cpp +++ b/src/corelib/tools/qdatetimeparser.cpp @@ -602,7 +602,7 @@ int QDateTimeParser::sectionMaxSize(Section s, int count) const return 2; #else mcount = 7; - // fall through + Q_FALLTHROUGH(); #endif case MonthSection: #ifdef QT_NO_TEXTDATE @@ -770,7 +770,8 @@ int QDateTimeParser::parseSection(const QDateTime ¤tValue, int sectionInde state = Intermediate; } break; - } // else: fall through + } + Q_FALLTHROUGH(); case DaySection: case YearSection: case YearSection2Digits: @@ -1155,7 +1156,7 @@ end: done = true; break; } - // fallthrough + Q_FALLTHROUGH(); default: { int toMin; int toMax; @@ -1489,7 +1490,7 @@ QDateTimeParser::FieldInfo QDateTimeParser::fieldInfo(int index) const switch (sn.type) { case MSecSection: ret |= Fraction; - // fallthrough + Q_FALLTHROUGH(); case SecondSection: case MinuteSection: case Hour24Section: @@ -1509,7 +1510,7 @@ QDateTimeParser::FieldInfo QDateTimeParser::fieldInfo(int index) const switch (sn.count) { case 2: ret |= FixedWidth; - // fallthrough + Q_FALLTHROUGH(); case 1: ret |= (Numeric|AllowPartial); break; diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp index f8f3347786..96ddca56af 100644 --- a/src/corelib/tools/qregexp.cpp +++ b/src/corelib/tools/qregexp.cpp @@ -3011,7 +3011,7 @@ int QRegExpEngine::getEscape() case 'I': if (xmlSchemaExtensions) { yyCharClass->setNegative(!yyCharClass->negative()); - // fall through + Q_FALLTHROUGH(); } else { break; } @@ -3051,7 +3051,7 @@ int QRegExpEngine::getEscape() case 'C': if (xmlSchemaExtensions) { yyCharClass->setNegative(!yyCharClass->negative()); - // fall through + Q_FALLTHROUGH(); } else { break; } @@ -3097,7 +3097,7 @@ int QRegExpEngine::getEscape() case 'P': if (xmlSchemaExtensions) { yyCharClass->setNegative(!yyCharClass->negative()); - // fall through + Q_FALLTHROUGH(); } else { break; } diff --git a/src/corelib/tools/qunicodetools.cpp b/src/corelib/tools/qunicodetools.cpp index fad4267edc..be1d88e260 100644 --- a/src/corelib/tools/qunicodetools.cpp +++ b/src/corelib/tools/qunicodetools.cpp @@ -522,13 +522,13 @@ static void getLineBreaks(const ushort *string, quint32 len, QCharAttributes *at // do not change breaks before and after the expression for (quint32 j = nestart + 1; j < pos; ++j) attributes[j].lineBreak = false; - // fall through + Q_FALLTHROUGH(); case LB::NS::None: nelast = LB::NS::XX; // reset state break; case LB::NS::Start: nestart = i; - // fall through + Q_FALLTHROUGH(); default: nelast = necur; break; diff --git a/src/corelib/xml/qxmlstream.cpp b/src/corelib/xml/qxmlstream.cpp index 83b26d50ab..1ffaeca852 100644 --- a/src/corelib/xml/qxmlstream.cpp +++ b/src/corelib/xml/qxmlstream.cpp @@ -976,11 +976,11 @@ bool QXmlStreamReaderPrivate::scanUntil(const char *str, short tokenToInject) case '\r': if ((c = filterCarriageReturn()) == 0) break; - // fall through + Q_FALLTHROUGH(); case '\n': ++lineNumber; lastLineStart = characterOffset + readBufferPos; - // fall through + Q_FALLTHROUGH(); case '\t': textBuffer += QChar(c); continue; @@ -1158,11 +1158,11 @@ inline int QXmlStreamReaderPrivate::fastScanLiteralContent() case '\r': if (filterCarriageReturn() == 0) return n; - // fall through + Q_FALLTHROUGH(); case '\n': ++lineNumber; lastLineStart = characterOffset + readBufferPos; - // fall through + Q_FALLTHROUGH(); case ' ': case '\t': if (normalizeLiterals) @@ -1179,7 +1179,7 @@ inline int QXmlStreamReaderPrivate::fastScanLiteralContent() putChar(c); return n; } - // fall through + Q_FALLTHROUGH(); default: if (c < 0x20) { putChar(c); @@ -1201,11 +1201,11 @@ inline int QXmlStreamReaderPrivate::fastScanSpace() case '\r': if ((c = filterCarriageReturn()) == 0) return n; - // fall through + Q_FALLTHROUGH(); case '\n': ++lineNumber; lastLineStart = characterOffset + readBufferPos; - // fall through + Q_FALLTHROUGH(); case ' ': case '\t': textBuffer += QChar(c); @@ -1259,11 +1259,11 @@ inline int QXmlStreamReaderPrivate::fastScanContentCharList() case '\r': if ((c = filterCarriageReturn()) == 0) return n; - // fall through + Q_FALLTHROUGH(); case '\n': ++lineNumber; lastLineStart = characterOffset + readBufferPos; - // fall through + Q_FALLTHROUGH(); case ' ': case '\t': textBuffer += QChar(ushort(c)); @@ -1275,7 +1275,7 @@ inline int QXmlStreamReaderPrivate::fastScanContentCharList() putChar(c); return n; } - // fall through + Q_FALLTHROUGH(); default: if (c < 0x20) { putChar(c); @@ -1339,7 +1339,7 @@ inline int QXmlStreamReaderPrivate::fastScanName(int *prefix) putChar(c); return n; } - // fall through + Q_FALLTHROUGH(); default: textBuffer += QChar(c); ++n; @@ -2123,7 +2123,7 @@ QString QXmlStreamReader::readElementText(ReadElementTextBehaviour behaviour) result += readElementText(behaviour); break; } - // Fall through (for ErrorOnUnexpectedElement) + Q_FALLTHROUGH(); default: if (d->error || behaviour == ErrorOnUnexpectedElement) { if (!d->error) diff --git a/src/corelib/xml/qxmlstream_p.h b/src/corelib/xml/qxmlstream_p.h index c68d6f0f53..b62cc9ac39 100644 --- a/src/corelib/xml/qxmlstream_p.h +++ b/src/corelib/xml/qxmlstream_p.h @@ -1048,7 +1048,7 @@ bool QXmlStreamReaderPrivate::parse() dtdName.clear(); dtdPublicId.clear(); dtdSystemId.clear(); - // fall through + Q_FALLTHROUGH(); case QXmlStreamReader::Comment: case QXmlStreamReader::Characters: isCDATA = false; @@ -1080,7 +1080,7 @@ bool QXmlStreamReaderPrivate::parse() return false; } #endif - // fall through + Q_FALLTHROUGH(); default: clearTextBuffer(); ; @@ -1124,7 +1124,7 @@ bool QXmlStreamReaderPrivate::parse() } else { break; } - // fall through + Q_FALLTHROUGH(); case ~0U: { token = EOF_SYMBOL; if (!tagsDone && !inParseEntity) { @@ -1338,7 +1338,7 @@ bool QXmlStreamReaderPrivate::parse() case 17: case 18: dtdName = symString(3); - // fall through + Q_FALLTHROUGH(); case 19: case 20: @@ -1480,7 +1480,7 @@ bool QXmlStreamReaderPrivate::parse() if (entityDeclaration.parameter) raiseWellFormedError(QXmlStream::tr("NDATA in parameter entity declaration.")); } - //fall through + Q_FALLTHROUGH(); case 94: case 95: { @@ -1588,7 +1588,7 @@ bool QXmlStreamReaderPrivate::parse() case 129: isWhitespace = false; - // fall through + Q_FALLTHROUGH(); case 130: sym(1).len += fastScanContentCharList(); @@ -1760,7 +1760,7 @@ bool QXmlStreamReaderPrivate::parse() case 236: isEmptyElement = true; - // fall through + Q_FALLTHROUGH(); case 237: setType(QXmlStreamReader::StartElement); diff --git a/src/dbus/qdbusmarshaller.cpp b/src/dbus/qdbusmarshaller.cpp index 7ba7c79808..4ea6cefff6 100644 --- a/src/dbus/qdbusmarshaller.cpp +++ b/src/dbus/qdbusmarshaller.cpp @@ -318,7 +318,7 @@ void QDBusMarshaller::open(QDBusMarshaller &sub, int code, const char *signature case DBUS_TYPE_ARRAY: *ba += char(code); *ba += signature; - // fall through + Q_FALLTHROUGH(); case DBUS_TYPE_DICT_ENTRY: sub.closeCode = 0; @@ -495,9 +495,9 @@ bool QDBusMarshaller::appendVariantInternal(const QVariant &arg) return true; default: - ; // fall through + ; } - // fall through + Q_FALLTHROUGH(); case DBUS_TYPE_STRUCT: case DBUS_STRUCT_BEGIN_CHAR: @@ -513,7 +513,7 @@ bool QDBusMarshaller::appendVariantInternal(const QVariant &arg) append(qvariant_cast(arg)); return true; } - // fall through + Q_FALLTHROUGH(); default: qWarning("QDBusMarshaller::appendVariantInternal: Found unknown D-BUS type '%s'", diff --git a/src/dbus/qdbusmetatype.cpp b/src/dbus/qdbusmetatype.cpp index 59a71ade3e..fb2b407997 100644 --- a/src/dbus/qdbusmetatype.cpp +++ b/src/dbus/qdbusmetatype.cpp @@ -373,7 +373,7 @@ int QDBusMetaType::signatureToType(const char *signature) return qMetaTypeId >(); } - // fall through + Q_FALLTHROUGH(); default: return QMetaType::UnknownType; } diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index bd32ca7bee..9b14500e7a 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -1888,7 +1888,7 @@ void QImage::invertPixels(InvertMode mode) case QImage::Format_RGBA8888: if (mode == InvertRgba) break; - // no break + Q_FALLTHROUGH(); case QImage::Format_RGBX8888: #if Q_BYTE_ORDER == Q_BIG_ENDIAN xorbits = 0xffffff00; @@ -1900,7 +1900,7 @@ void QImage::invertPixels(InvertMode mode) case QImage::Format_ARGB32: if (mode == InvertRgba) break; - // no break + Q_FALLTHROUGH(); case QImage::Format_RGB32: xorbits = 0x00ffffff; break; diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp index 45d57856aa..0320d032b0 100644 --- a/src/gui/image/qimagereader.cpp +++ b/src/gui/image/qimagereader.cpp @@ -1151,7 +1151,7 @@ bool QImageReader::autoTransform() const case QImageReaderPrivate::UsePluginDefault: if (d->initHandler()) return d->handler->supportsOption(QImageIOHandler::TransformedByDefault); - // no break + Q_FALLTHROUGH(); default: break; } diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index 4032176efc..950695a9d7 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -113,10 +113,10 @@ int QBlittablePlatformPixmap::metric(QPaintDevice::PaintDeviceMetric metric) con return qRound(h * 25.4 / qt_defaultDpiY()); case QPaintDevice::PdmDepth: return 32; - case QPaintDevice::PdmDpiX: // fall-through + case QPaintDevice::PdmDpiX: case QPaintDevice::PdmPhysicalDpiX: return qt_defaultDpiX(); - case QPaintDevice::PdmDpiY: // fall-through + case QPaintDevice::PdmDpiY: case QPaintDevice::PdmPhysicalDpiY: return qt_defaultDpiY(); case QPaintDevice::PdmDevicePixelRatio: diff --git a/src/gui/kernel/qplatformgraphicsbufferhelper.cpp b/src/gui/kernel/qplatformgraphicsbufferhelper.cpp index 82a88eca04..2afb5e6ba5 100644 --- a/src/gui/kernel/qplatformgraphicsbufferhelper.cpp +++ b/src/gui/kernel/qplatformgraphicsbufferhelper.cpp @@ -154,14 +154,14 @@ bool QPlatformGraphicsBufferHelper::bindSWToTexture(const QPlatformGraphicsBuffe switch (imageformat) { case QImage::Format_ARGB32_Premultiplied: premultiplied = true; - // no break + Q_FALLTHROUGH(); case QImage::Format_RGB32: case QImage::Format_ARGB32: swizzle = true; break; case QImage::Format_RGBA8888_Premultiplied: premultiplied = true; - // no break + Q_FALLTHROUGH(); case QImage::Format_RGBX8888: case QImage::Format_RGBA8888: break; diff --git a/src/gui/painting/qcssutil.cpp b/src/gui/painting/qcssutil.cpp index a826532b43..2d514e14e0 100644 --- a/src/gui/painting/qcssutil.cpp +++ b/src/gui/painting/qcssutil.cpp @@ -197,7 +197,7 @@ void qDrawEdge(QPainter *p, qreal x1, qreal y1, qreal x2, qreal y2, qreal dw1, q if ((style == BorderStyle_Outset && (edge == TopEdge || edge == LeftEdge)) || (style == BorderStyle_Inset && (edge == BottomEdge || edge == RightEdge))) c = c.color().lighter(); - // fall through! + Q_FALLTHROUGH(); case BorderStyle_Solid: { p->setPen(Qt::NoPen); p->setBrush(c); diff --git a/src/gui/painting/qpathclipper.cpp b/src/gui/painting/qpathclipper.cpp index 4f2b59c775..f92a681eca 100644 --- a/src/gui/painting/qpathclipper.cpp +++ b/src/gui/painting/qpathclipper.cpp @@ -1760,7 +1760,7 @@ static bool bool_op(bool a, bool b, QPathClipper::Operation op) switch (op) { case QPathClipper::BoolAnd: return a && b; - case QPathClipper::BoolOr: // fall-through + case QPathClipper::BoolOr: case QPathClipper::Simplify: return a || b; case QPathClipper::BoolSub: @@ -1956,7 +1956,7 @@ QPointF intersectLine(const QPointF &a, const QPointF &b, qreal t) { QLineF line(a, b); switch (edge) { - case Left: // fall-through + case Left: case Right: return line.pointAt((t - a.x()) / (b.x() - a.x())); default: diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 34f1c51f6d..d246c96da6 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -2091,7 +2091,7 @@ int QPdfEnginePrivate::generateLinearGradientShader(const QLinearGradient *gradi break; case QGradient::ReflectSpread: reflect = true; - // fall through + Q_FALLTHROUGH(); case QGradient::RepeatSpread: { // calculate required bounds QRectF pageRect = m_pageLayout.fullRectPixels(resolution); @@ -2154,7 +2154,7 @@ int QPdfEnginePrivate::generateRadialGradientShader(const QRadialGradient *gradi break; case QGradient::ReflectSpread: reflect = true; - // fall through + Q_FALLTHROUGH(); case QGradient::RepeatSpread: { Q_ASSERT(qFuzzyIsNull(r0)); // QPainter emulates if this is not 0 diff --git a/src/gui/painting/qplatformbackingstore.cpp b/src/gui/painting/qplatformbackingstore.cpp index e2c5a82ffc..0c5de36981 100644 --- a/src/gui/painting/qplatformbackingstore.cpp +++ b/src/gui/painting/qplatformbackingstore.cpp @@ -471,14 +471,14 @@ GLuint QPlatformBackingStore::toTexture(const QRegion &dirtyRegion, QSize *textu switch (image.format()) { case QImage::Format_ARGB32_Premultiplied: *flags |= TexturePremultiplied; - // no break + Q_FALLTHROUGH(); case QImage::Format_RGB32: case QImage::Format_ARGB32: *flags |= TextureSwizzle; break; case QImage::Format_RGBA8888_Premultiplied: *flags |= TexturePremultiplied; - // no break + Q_FALLTHROUGH(); case QImage::Format_RGBX8888: case QImage::Format_RGBA8888: break; diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp index 6058811176..2d841b2953 100644 --- a/src/gui/painting/qtransform.cpp +++ b/src/gui/painting/qtransform.cpp @@ -446,7 +446,7 @@ QTransform &QTransform::translate(qreal dx, qreal dy) break; case TxProject: m_33 += dx*m_13 + dy*m_23; - // Fall through + Q_FALLTHROUGH(); case TxShear: case TxRotate: affine._dx += dx*affine._m11 + dy*affine._m21; @@ -508,12 +508,12 @@ QTransform & QTransform::scale(qreal sx, qreal sy) case TxProject: m_13 *= sx; m_23 *= sy; - // fall through + Q_FALLTHROUGH(); case TxRotate: case TxShear: affine._m12 *= sx; affine._m21 *= sy; - // fall through + Q_FALLTHROUGH(); case TxScale: affine._m11 *= sx; affine._m22 *= sy; @@ -581,7 +581,7 @@ QTransform & QTransform::shear(qreal sh, qreal sv) m_13 += tm13; m_23 += tm23; } - // fall through + Q_FALLTHROUGH(); case TxRotate: case TxShear: { qreal tm11 = sv*affine._m21; @@ -663,7 +663,7 @@ QTransform & QTransform::rotate(qreal a, Qt::Axis axis) qreal tm23 = -sina*m_13 + cosa*m_23; m_13 = tm13; m_23 = tm23; - // fall through + Q_FALLTHROUGH(); } case TxRotate: case TxShear: { @@ -742,7 +742,7 @@ QTransform & QTransform::rotateRadians(qreal a, Qt::Axis axis) qreal tm23 = -sina*m_13 + cosa*m_23; m_13 = tm13; m_23 = tm23; - // fall through + Q_FALLTHROUGH(); } case TxRotate: case TxShear: { diff --git a/src/gui/painting/qtriangulator.cpp b/src/gui/painting/qtriangulator.cpp index 7906011cd2..6604d407f0 100644 --- a/src/gui/painting/qtriangulator.cpp +++ b/src/gui/painting/qtriangulator.cpp @@ -874,7 +874,7 @@ void QTriangulator::initialize(const QVectorPath &path, const QTransform &mat case QPainterPath::MoveToElement: if (!m_indices.isEmpty()) m_indices.push_back(T(-1)); // Q_TRIANGULATE_END_OF_POLYGON - // Fall through. + Q_FALLTHROUGH(); case QPainterPath::LineToElement: m_indices.push_back(T(m_vertices.size())); m_vertices.resize(m_vertices.size() + 1); @@ -2100,7 +2100,7 @@ void QTriangulator::SimpleToMonotone::monotoneDecomposition() } else { qWarning("Inconsistent polygon. (#3)"); } - // Fall through. + Q_FALLTHROUGH(); case StartVertex: if (m_clockwiseOrder) { leftEdgeNode = searchEdgeLeftOfEdge(j); @@ -2129,7 +2129,7 @@ void QTriangulator::SimpleToMonotone::monotoneDecomposition() } else { qWarning("Inconsistent polygon. (#4)"); } - // Fall through. + Q_FALLTHROUGH(); case EndVertex: if (m_clockwiseOrder) { if (m_edges.at(m_edges.at(i).helper).type == MergeVertex) diff --git a/src/gui/text/qfontsubset.cpp b/src/gui/text/qfontsubset.cpp index c8f0393084..49638832e0 100644 --- a/src/gui/text/qfontsubset.cpp +++ b/src/gui/text/qfontsubset.cpp @@ -740,7 +740,7 @@ static void convertPath(const QPainterPath &path, QVector *points, QV points->takeLast(); endPoints->append(points->size() - 1); } - // fall through + Q_FALLTHROUGH(); case QPainterPath::LineToElement: p.flags = OnCurve; break; diff --git a/src/gui/text/qtextcursor.cpp b/src/gui/text/qtextcursor.cpp index f824d1b369..f32c31d18e 100644 --- a/src/gui/text/qtextcursor.cpp +++ b/src/gui/text/qtextcursor.cpp @@ -438,7 +438,7 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor if (relativePos < blockIt.length()-1) ++position; - // FALL THROUGH! + Q_FALLTHROUGH(); } case QTextCursor::PreviousWord: case QTextCursor::WordLeft: @@ -590,9 +590,9 @@ bool QTextCursorPrivate::movePosition(QTextCursor::MoveOperation op, QTextCursor adjustX = false; break; } - case QTextCursor::NextCell: // fall through - case QTextCursor::PreviousCell: // fall through - case QTextCursor::NextRow: // fall through + case QTextCursor::NextCell: + case QTextCursor::PreviousCell: + case QTextCursor::NextRow: case QTextCursor::PreviousRow: { QTextTable *table = qobject_cast(priv->frameAt(position)); if (!table) diff --git a/src/gui/text/qtextdocumentfragment.cpp b/src/gui/text/qtextdocumentfragment.cpp index 5727b34e86..079b2e01f7 100644 --- a/src/gui/text/qtextdocumentfragment.cpp +++ b/src/gui/text/qtextdocumentfragment.cpp @@ -827,7 +827,7 @@ bool QTextHtmlImporter::closeTag() case Html_div: if (closedNode->children.isEmpty()) break; - // fall through + Q_FALLTHROUGH(); default: if (closedNode->isBlock()) blockTagClosed = true; diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index d9b648b170..1aaacdd00d 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -508,7 +508,7 @@ static bool bidiItemize(QTextEngine *engine, QScriptAnalysis *analysis, QBidiCon case QChar::DirAN: if (eor >= 0) appendItems(analysis, sor, eor, control, dir); - // fall through + Q_FALLTHROUGH(); case QChar::DirR: case QChar::DirAL: dir = QChar::DirR; eor = current; status.eor = QChar::DirR; break; @@ -564,7 +564,7 @@ static bool bidiItemize(QTextEngine *engine, QScriptAnalysis *analysis, QBidiCon status.eor = QChar::DirON; dir = QChar::DirAN; } - // fall through + Q_FALLTHROUGH(); case QChar::DirEN: case QChar::DirL: eor = current; @@ -744,7 +744,7 @@ static bool bidiItemize(QTextEngine *engine, QScriptAnalysis *analysis, QBidiCon status.last = QChar::DirL; break; } - // fall through + Q_FALLTHROUGH(); default: status.last = dirCurrent; } @@ -1663,7 +1663,7 @@ void QTextEngine::itemize() const analysis->bidiLevel = control.baseLevel(); break; } - // fall through + Q_FALLTHROUGH(); default: analysis->flags = QScriptAnalysis::None; break; @@ -2250,7 +2250,6 @@ void QTextEngine::justify(const QScriptLine &line) case Justification_Prohibited: break; case Justification_Space: - // fall through case Justification_Arabic_Space: if (kashida_pos >= 0) { // qDebug("kashida position at %d in word", kashida_pos); @@ -2263,7 +2262,7 @@ void QTextEngine::justify(const QScriptLine &line) } kashida_pos = -1; kashida_type = Justification_Arabic_Normal; - // fall through + Q_FALLTHROUGH(); case Justification_Character: set(&justificationPoints[nPoints++], justification, g.mid(i), fontEngine(si)); maxJustify = qMax(maxJustify, justification); @@ -2966,9 +2965,8 @@ QFixed QTextEngine::calculateTabWidth(int item, QFixed x) const switch (tabSpec.type) { case QTextOption::CenterTab: length /= 2; - // fall through + Q_FALLTHROUGH(); case QTextOption::DelimiterTab: - // fall through case QTextOption::RightTab: tab = QFixed::fromReal(tabSpec.position) * dpiScale - length; if (tab < x) // default to tab taking no space diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp index 7bca50325c..7fac3331f1 100644 --- a/src/gui/text/qtexthtmlparser.cpp +++ b/src/gui/text/qtexthtmlparser.cpp @@ -1871,7 +1871,7 @@ QVector standardDeclarationForNode(const QTextHtmlParserNode decls << decl; if (node.id == Html_b || node.id == Html_strong) break; - // Delibrate fall through + Q_FALLTHROUGH(); case Html_big: case Html_small: if (node.id != Html_th) { @@ -1892,7 +1892,7 @@ QVector standardDeclarationForNode(const QTextHtmlParserNode decls << decl; break; } - // Delibrate fall through + Q_FALLTHROUGH(); case Html_center: case Html_td: decl = QCss::Declaration(); @@ -1969,7 +1969,7 @@ QVector standardDeclarationForNode(const QTextHtmlParserNode } if (node.id != Html_pre) break; - // Delibrate fall through + Q_FALLTHROUGH(); case Html_br: case Html_nobr: decl = QCss::Declaration(); diff --git a/src/network/access/qftp.cpp b/src/network/access/qftp.cpp index 7b6f830333..52b9dd9169 100644 --- a/src/network/access/qftp.cpp +++ b/src/network/access/qftp.cpp @@ -1121,7 +1121,7 @@ bool QFtpPI::processReply() case Success: // success handling state = Idle; - // no break! + Q_FALLTHROUGH(); case Idle: if (dtp.hasError()) { emit error(QFtp::UnknownError, dtp.errorMessage()); diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 3a780f636b..87f88aad5f 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -1036,7 +1036,7 @@ void QHttpNetworkConnectionChannel::_q_encrypted() if (!protocolHandler) { switch (sslSocket->sslConfiguration().nextProtocolNegotiationStatus()) { - case QSslConfiguration::NextProtocolNegotiationNegotiated: /* fall through */ + case QSslConfiguration::NextProtocolNegotiationNegotiated: case QSslConfiguration::NextProtocolNegotiationUnsupported: { QByteArray nextProtocol = sslSocket->sslConfiguration().nextNegotiatedProtocol(); if (nextProtocol == QSslConfiguration::NextProtocolHttp1_1) { @@ -1056,6 +1056,7 @@ void QHttpNetworkConnectionChannel::_q_encrypted() "detected unknown Next Protocol Negotiation protocol"); break; } + Q_FALLTHROUGH(); } case QSslConfiguration::NextProtocolNegotiationNone: protocolHandler.reset(new QHttpProtocolHandler(this)); diff --git a/src/network/access/qhttpprotocolhandler.cpp b/src/network/access/qhttpprotocolhandler.cpp index b486b75449..37e8b9bed8 100644 --- a/src/network/access/qhttpprotocolhandler.cpp +++ b/src/network/access/qhttpprotocolhandler.cpp @@ -99,7 +99,7 @@ void QHttpProtocolHandler::_q_receiveReply() switch (state) { case QHttpNetworkReplyPrivate::NothingDoneState: { m_reply->d_func()->state = QHttpNetworkReplyPrivate::ReadingStatusState; - // fallthrough + Q_FALLTHROUGH(); } case QHttpNetworkReplyPrivate::ReadingStatusState: { qint64 statusBytes = m_reply->d_func()->readStatus(m_socket); @@ -213,7 +213,8 @@ void QHttpProtocolHandler::_q_receiveReply() if (replyPrivate->state == QHttpNetworkReplyPrivate::ReadingDataState) break; - // everything done, fall through + // everything done + Q_FALLTHROUGH(); } case QHttpNetworkReplyPrivate::AllDoneState: m_channel->allDone(); @@ -428,7 +429,7 @@ bool QHttpProtocolHandler::sendRequest() } case QHttpNetworkConnectionChannel::ReadingState: // ignore _q_bytesWritten in these states - // fall through + Q_FALLTHROUGH(); default: break; } diff --git a/src/network/access/qnetworkcookie.cpp b/src/network/access/qnetworkcookie.cpp index 7a538cbf08..b7cf989477 100644 --- a/src/network/access/qnetworkcookie.cpp +++ b/src/network/access/qnetworkcookie.cpp @@ -644,7 +644,7 @@ static QDateTime parseDateString(const QByteArray &dateString) switch (end - 1) { case 4: minutes = atoi(dateString.mid(at + 3, 2).constData()); - // fall through + Q_FALLTHROUGH(); case 2: hours = atoi(dateString.mid(at + 1, 2).constData()); break; diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp index 95f90af49e..7e3d2c5d6e 100644 --- a/src/network/kernel/qhostaddress.cpp +++ b/src/network/kernel/qhostaddress.cpp @@ -536,7 +536,7 @@ QHostAddress::QHostAddress(SpecialAddress address) case LocalHostIPv6: ip6[15] = 1; - // fall through + Q_FALLTHROUGH(); case AnyIPv6: d->setAddress(ip6); return; diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp index 9ae2d8ba8f..5a9641a9fe 100644 --- a/src/network/socket/qnativesocketengine_win.cpp +++ b/src/network/socket/qnativesocketengine_win.cpp @@ -712,7 +712,7 @@ bool QNativeSocketEnginePrivate::nativeConnect(const QHostAddress &address, quin if (errorDetected) break; - // fall through + Q_FALLTHROUGH(); } case WSAEINPROGRESS: setError(QAbstractSocket::UnfinishedSocketOperationError, InvalidSocketErrorString); diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp index 518ec21f90..a1a8e4649d 100644 --- a/src/network/socket/qsocks5socketengine.cpp +++ b/src/network/socket/qsocks5socketengine.cpp @@ -618,7 +618,7 @@ void QSocks5SocketEnginePrivate::setErrorState(Socks5State state, const QString QSocks5SocketEngine::tr("Connection to proxy timed out")); break; } - /* fall through */ + Q_FALLTHROUGH(); default: q->setError(controlSocketError, data->controlSocket->errorString()); break; @@ -1205,7 +1205,7 @@ void QSocks5SocketEnginePrivate::_q_controlSocketReadNotification() break; } - // fall through + Q_FALLTHROUGH(); default: qWarning("QSocks5SocketEnginePrivate::_q_controlSocketReadNotification: " "Unexpectedly received data while in state=%d and mode=%d", diff --git a/src/platformsupport/fbconvenience/qfbvthandler.cpp b/src/platformsupport/fbconvenience/qfbvthandler.cpp index 4c4a01a82e..2429cb7c5c 100644 --- a/src/platformsupport/fbconvenience/qfbvthandler.cpp +++ b/src/platformsupport/fbconvenience/qfbvthandler.cpp @@ -171,7 +171,7 @@ void QFbVtHandler::handleSignal() char sigNo; if (QT_READ(m_sigFd[1], &sigNo, sizeof(sigNo)) == sizeof(sigNo)) { switch (sigNo) { - case SIGINT: // fallthrough + case SIGINT: case SIGTERM: handleInt(); break; diff --git a/src/plugins/bearer/qnetworksession_impl.cpp b/src/plugins/bearer/qnetworksession_impl.cpp index 426cca139d..85942b56f1 100644 --- a/src/plugins/bearer/qnetworksession_impl.cpp +++ b/src/plugins/bearer/qnetworksession_impl.cpp @@ -111,10 +111,10 @@ void QNetworkSessionPrivateImpl::syncStateWithInterface() case QNetworkConfiguration::ServiceNetwork: serviceConfig = publicConfig; // Defer setting engine and signals until open(). - // fall through + Q_FALLTHROUGH(); case QNetworkConfiguration::UserChoice: // Defer setting serviceConfig and activeConfig until open(). - // fall through + Q_FALLTHROUGH(); default: engine = 0; } diff --git a/src/plugins/platforms/android/qandroidplatformtheme.cpp b/src/plugins/platforms/android/qandroidplatformtheme.cpp index 3949113240..b9009fe704 100644 --- a/src/plugins/platforms/android/qandroidplatformtheme.cpp +++ b/src/plugins/platforms/android/qandroidplatformtheme.cpp @@ -489,7 +489,7 @@ QVariant QAndroidPlatformTheme::themeHint(ThemeHint hint) const if (ret > 0) return ret; - // fall through + Q_FALLTHROUGH(); } default: return QPlatformTheme::themeHint(hint); diff --git a/src/plugins/platforms/cocoa/qprintengine_mac.mm b/src/plugins/platforms/cocoa/qprintengine_mac.mm index 3d0c91c36c..0b5b06c44f 100644 --- a/src/plugins/platforms/cocoa/qprintengine_mac.mm +++ b/src/plugins/platforms/cocoa/qprintengine_mac.mm @@ -200,7 +200,7 @@ int QMacPrintEngine::metric(QPaintDevice::PaintDeviceMetric m) const val = (int)resolution.vRes; break; } - //otherwise fall through + Q_FALLTHROUGH(); } case QPaintDevice::PdmDpiY: val = (int)d->resolution.vRes; diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp index 730d5de450..0ea2fcfa74 100644 --- a/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp +++ b/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp @@ -563,7 +563,7 @@ public: if (newPen.widthF() <= 1.0) props.startCap = props.endCap = props.dashCap = D2D1_CAP_STYLE_FLAT; - // fall through + Q_FALLTHROUGH(); default: props.dashStyle = D2D1_DASH_STYLE_CUSTOM; break; diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 3a683bd7a0..d4cdf3ef3c 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -945,7 +945,8 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, switch (et) { case QtWindows::KeyboardLayoutChangeEvent: if (QWindowsInputContext *wic = windowsInputContext()) - wic->handleInputLanguageChanged(wParam, lParam); // fallthrough intended. + wic->handleInputLanguageChanged(wParam, lParam); + Q_FALLTHROUGH(); case QtWindows::KeyDownEvent: case QtWindows::KeyEvent: case QtWindows::InputMethodKeyEvent: diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index 79befc56c2..841464391d 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -551,14 +551,14 @@ QPixmap QWindowsTheme::standardPixmap(StandardPixmap sp, const QSizeF &pixmapSiz break; case FileLinkIcon: stockFlags = SHGSI_LINKOVERLAY; - // Fall through + Q_FALLTHROUGH(); case FileIcon: stockId = SIID_DOCNOASSOC; resourceId = 1; break; case DirLinkIcon: stockFlags = SHGSI_LINKOVERLAY; - // Fall through + Q_FALLTHROUGH(); case DirClosedIcon: case DirIcon: stockId = SIID_FOLDER; @@ -572,7 +572,7 @@ QPixmap QWindowsTheme::standardPixmap(StandardPixmap sp, const QSizeF &pixmapSiz break; case DirLinkOpenIcon: stockFlags = SHGSI_LINKOVERLAY; - // Fall through + Q_FALLTHROUGH(); case DirOpenIcon: stockId = SIID_FOLDEROPEN; resourceId = 5; diff --git a/src/printsupport/kernel/qprintengine_pdf.cpp b/src/printsupport/kernel/qprintengine_pdf.cpp index ed0422468d..278bb044e1 100644 --- a/src/printsupport/kernel/qprintengine_pdf.cpp +++ b/src/printsupport/kernel/qprintengine_pdf.cpp @@ -150,7 +150,7 @@ void QPdfPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &va else d->m_pageLayout.setMode(QPageLayout::StandardMode); break; - case PPK_CopyCount: // fallthrough + case PPK_CopyCount: case PPK_NumberOfCopies: d->copies = value.toInt(); break; diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp index b3dc33895b..b0f85dc825 100644 --- a/src/printsupport/kernel/qprintengine_win.cpp +++ b/src/printsupport/kernel/qprintengine_win.cpp @@ -1141,7 +1141,7 @@ void QWin32PrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant & #endif // QT_DEBUG_METRICS break; - case PPK_CopyCount: // fallthrough + case PPK_CopyCount: case PPK_NumberOfCopies: if (!d->devMode) break; diff --git a/src/testlib/qtestmouse.h b/src/testlib/qtestmouse.h index 632b801221..1143361323 100644 --- a/src/testlib/qtestmouse.h +++ b/src/testlib/qtestmouse.h @@ -115,14 +115,14 @@ namespace QTest case MouseDClick: qt_handleMouseEvent(w, pos, global, button, stateKey, ++lastMouseTimestamp); qt_handleMouseEvent(w, pos, global, Qt::NoButton, stateKey, ++lastMouseTimestamp); - // fall through + Q_FALLTHROUGH(); case MousePress: case MouseClick: qt_handleMouseEvent(w, pos, global, button, stateKey, ++lastMouseTimestamp); lastMouseButton = button; if (action == MousePress) break; - // fall through + Q_FALLTHROUGH(); case MouseRelease: qt_handleMouseEvent(w, pos, global, Qt::NoButton, stateKey, ++lastMouseTimestamp); lastMouseTimestamp += 500; // avoid double clicks being generated diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 87fb1318f9..afe64bb889 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -163,7 +163,7 @@ Type Moc::parseType() case SIGNED: case UNSIGNED: hasSignedOrUnsigned = true; - // fall through + Q_FALLTHROUGH(); case CONST: case VOLATILE: type.name += lexem(); diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp index 415003e6b1..5ce28d931b 100644 --- a/src/tools/moc/preprocessor.cpp +++ b/src/tools/moc/preprocessor.cpp @@ -251,7 +251,7 @@ Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocesso } token = FLOATING_LITERAL; ++data; - // fall through + Q_FALLTHROUGH(); case FLOATING_LITERAL: while (is_digit_char(*data)) ++data; @@ -321,7 +321,7 @@ Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocesso ++data; } token = WHITESPACE; // one comment, one whitespace - // fall through; + Q_FALLTHROUGH(); case WHITESPACE: if (column == 1) column = 0; @@ -428,7 +428,7 @@ Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocesso } token = PP_FLOATING_LITERAL; ++data; - // fall through + Q_FALLTHROUGH(); case PP_FLOATING_LITERAL: while (is_digit_char(*data)) ++data; @@ -482,7 +482,7 @@ Symbols Preprocessor::tokenize(const QByteArray& input, int lineNum, Preprocesso ++data; } token = PP_WHITESPACE; // one comment, one whitespace - // fall through; + Q_FALLTHROUGH(); case PP_WHITESPACE: while (*data && (*data == ' ' || *data == '\t')) ++data; @@ -1177,7 +1177,7 @@ void Preprocessor::preprocess(const QByteArray &filename, Symbols &preprocessed) case PP_ELIF: case PP_ELSE: skipUntilEndif(); - // fall through + Q_FALLTHROUGH(); case PP_ENDIF: until(PP_NEWLINE); continue; diff --git a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp index 083187555d..26e7b086d9 100644 --- a/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp +++ b/src/tools/qdbuscpp2xml/qdbuscpp2xml.cpp @@ -335,28 +335,28 @@ static void parseCmdLine(QStringList &arguments) switch (c) { case 'P': flags |= QDBusConnection::ExportNonScriptableProperties; - // fall through + Q_FALLTHROUGH(); case 'p': flags |= QDBusConnection::ExportScriptableProperties; break; case 'S': flags |= QDBusConnection::ExportNonScriptableSignals; - // fall through + Q_FALLTHROUGH(); case 's': flags |= QDBusConnection::ExportScriptableSignals; break; case 'M': flags |= QDBusConnection::ExportNonScriptableSlots; - // fall through + Q_FALLTHROUGH(); case 'm': flags |= QDBusConnection::ExportScriptableSlots; break; case 'A': flags |= QDBusConnection::ExportNonScriptableContents; - // fall through + Q_FALLTHROUGH(); case 'a': flags |= QDBusConnection::ExportScriptableContents; break; diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index 689704884f..96046b7ff4 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -1379,7 +1379,7 @@ void QMessageBox::changeEvent(QEvent *ev) d->buttonBox->setCenterButtons(style()->styleHint(QStyle::SH_MessageBox_CenterButtons, 0, this)); if (d->informativeLabel) d->informativeLabel->setTextInteractionFlags(flags); - // intentional fall through + Q_FALLTHROUGH(); } case QEvent::FontChange: case QEvent::ApplicationFontChange: @@ -1390,6 +1390,7 @@ void QMessageBox::changeEvent(QEvent *ev) d->label->setFont(f); } #endif + Q_FALLTHROUGH(); default: break; } diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index 4b5e380f4b..5492862287 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -9570,7 +9570,7 @@ public: shape = qt_regionToPath(QRegion(mask).translated(offset.toPoint())); break; } - // FALL THROUGH + Q_FALLTHROUGH(); } case QGraphicsPixmapItem::BoundingRectShape: shape.addRect(QRectF(offset.x(), offset.y(), pixmap.width(), pixmap.height())); diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index 7b393463a6..6f1e301d4f 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -2563,7 +2563,7 @@ void QHeaderView::mouseReleaseEvent(QMouseEvent *e) int section = logicalIndexAt(pos); updateSection(section); } - // fall through + Q_FALLTHROUGH(); case QHeaderViewPrivate::NoState: if (d->clickableSections) { int section = logicalIndexAt(pos); @@ -2669,7 +2669,7 @@ bool QHeaderView::viewportEvent(QEvent *e) case QEvent::FontChange: case QEvent::StyleChange: d->invalidateCachedSizeHint(); - // Fall through + Q_FALLTHROUGH(); case QEvent::Hide: case QEvent::Show: { QAbstractScrollArea *parent = qobject_cast(parentWidget()); diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp index 74ca7d2827..5e0f13277c 100644 --- a/src/widgets/itemviews/qtreewidget.cpp +++ b/src/widgets/itemviews/qtreewidget.cpp @@ -1737,7 +1737,7 @@ void QTreeWidgetItem::setData(int column, int role, const QVariant &value) } } } - // Don't break, but fall through + Q_FALLTHROUGH(); default: if (column < values.count()) { bool found = false; @@ -1787,7 +1787,7 @@ QVariant QTreeWidgetItem::data(int column, int role) const // special case for check state in tristate if (children.count() && (itemFlags & Qt::ItemIsAutoTristate)) return childrenCheckState(column); - // fallthrough intended + Q_FALLTHROUGH(); default: if (column >= 0 && column < values.size()) { const QVector &column_values = values.at(column); diff --git a/src/widgets/kernel/qwhatsthis.cpp b/src/widgets/kernel/qwhatsthis.cpp index 66b622911a..32fe5f5e64 100644 --- a/src/widgets/kernel/qwhatsthis.cpp +++ b/src/widgets/kernel/qwhatsthis.cpp @@ -450,8 +450,8 @@ bool QWhatsThisPrivate::eventFilter(QObject *o, QEvent *e) QApplication::changeOverrideCursor((!sentEvent || !e.isAccepted())? Qt::ForbiddenCursor:Qt::WhatsThisCursor); #endif + Q_FALLTHROUGH(); } - // fall through case QEvent::MouseButtonRelease: case QEvent::MouseButtonDblClick: if (leaveOnMouseRelease && e->type() == QEvent::MouseButtonRelease) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 25874e9bcc..e0b8024f9a 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -8835,7 +8835,7 @@ bool QWidget::event(QEvent *event) case QEvent::KeyRelease: keyReleaseEvent((QKeyEvent*)event); - // fall through + Q_FALLTHROUGH(); case QEvent::ShortcutOverride: break; @@ -8954,7 +8954,7 @@ bool QWidget::event(QEvent *event) 0, this); break; } - // fall through + Q_FALLTHROUGH(); #endif default: event->ignore(); @@ -9193,7 +9193,7 @@ bool QWidget::event(QEvent *event) } if (windowHandle() && !qstrncmp(propName, "_q_platform_", 12)) windowHandle()->setProperty(propName, property(propName)); - // fall through + Q_FALLTHROUGH(); } #endif default: @@ -11194,13 +11194,13 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) d->enforceNativeChildren(); } #endif - // fall through + Q_FALLTHROUGH(); case Qt::WA_OpaquePaintEvent: d->updateIsOpaque(); break; case Qt::WA_NoSystemBackground: d->updateIsOpaque(); - // fall through... + Q_FALLTHROUGH(); case Qt::WA_UpdatesDisabled: d->updateSystemBackground(); break; diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 6cdfc061e1..140f0ad2f3 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -4232,7 +4232,6 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast(opt)) { switch (sc) { case SC_GroupBoxFrame: - // FALL THROUGH case SC_GroupBoxContents: { int topMargin = 0; int topHeight = 0; @@ -4261,7 +4260,6 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex break; } case SC_GroupBoxCheckBox: - // FALL THROUGH case SC_GroupBoxLabel: { QFontMetrics fontMetrics = groupBox->fontMetrics; int h = fontMetrics.height(); @@ -4327,7 +4325,7 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex if (numSubControls == 1) break; offset += buttonWidth + 2; - //FALL THROUGH + Q_FALLTHROUGH(); case SC_MdiNormalButton: // No offset needed if // 1) There's only one sub control @@ -4895,7 +4893,7 @@ QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, case CT_ProgressBar: case CT_TabBarTab: // just return the contentsSize for now - // fall through intended + Q_FALLTHROUGH(); default: break; } diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 44555c3058..c5904a5a96 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -1100,7 +1100,7 @@ void QRenderRule::fixupBorder(int nativeWidth) case BorderStyle_Native: if (bd->borders[i] == 0) bd->borders[i] = nativeWidth; - // intentional fall through + Q_FALLTHROUGH(); default: if (bd->colors[i].style() == Qt::NoBrush) // auto-acquire 'color' bd->colors[i] = color; diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index c3a50968e2..e3bf28608c 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -808,7 +808,8 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, p->setPen(opt->palette.dark().color()); else p->setPen(opt->palette.text().color()); - } // Fall through! + } + Q_FALLTHROUGH(); case PE_IndicatorViewItemCheck: if (!doRestore) { p->save(); @@ -2383,7 +2384,7 @@ QSize QWindowsStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, case CT_ToolButton: if (qstyleoption_cast(opt)) return sz += QSize(7, 6); - // Otherwise, fall through + Q_FALLTHROUGH(); default: sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget); diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index ffedc37edb..f3a8544d96 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -3465,13 +3465,13 @@ QRect QWindowsXPStyle::subControlRect(ComplexControl cc, const QStyleOptionCompl case SC_TitleBarContextHelpButton: if (tb->titleBarFlags & Qt::WindowContextHelpButtonHint) offset += delta; - //fall through + Q_FALLTHROUGH(); case SC_TitleBarMinButton: if (!isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint)) offset += delta; else if (subControl == SC_TitleBarMinButton) break; - //fall through + Q_FALLTHROUGH(); case SC_TitleBarNormalButton: if (isMinimized && (tb->titleBarFlags & Qt::WindowMinimizeButtonHint)) offset += delta; @@ -3479,25 +3479,25 @@ QRect QWindowsXPStyle::subControlRect(ComplexControl cc, const QStyleOptionCompl offset += delta; else if (subControl == SC_TitleBarNormalButton) break; - //fall through + Q_FALLTHROUGH(); case SC_TitleBarMaxButton: if (!isMaximized && (tb->titleBarFlags & Qt::WindowMaximizeButtonHint)) offset += delta; else if (subControl == SC_TitleBarMaxButton) break; - //fall through + Q_FALLTHROUGH(); case SC_TitleBarShadeButton: if (!isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint)) offset += delta; else if (subControl == SC_TitleBarShadeButton) break; - //fall through + Q_FALLTHROUGH(); case SC_TitleBarUnshadeButton: if (isMinimized && (tb->titleBarFlags & Qt::WindowShadeButtonHint)) offset += delta; else if (subControl == SC_TitleBarUnshadeButton) break; - //fall through + Q_FALLTHROUGH(); case SC_TitleBarCloseButton: if (tb->titleBarFlags & Qt::WindowSystemMenuHint) offset += delta; @@ -3576,7 +3576,7 @@ QRect QWindowsXPStyle::subControlRect(ComplexControl cc, const QStyleOptionCompl if (numSubControls == 1) break; offset += buttonWidth; - //FALL THROUGH + Q_FALLTHROUGH(); case SC_MdiNormalButton: // No offset needed if // 1) There's only one sub control diff --git a/src/widgets/util/qflickgesture.cpp b/src/widgets/util/qflickgesture.cpp index 4f08664784..57db9ff7fc 100644 --- a/src/widgets/util/qflickgesture.cpp +++ b/src/widgets/util/qflickgesture.cpp @@ -551,11 +551,11 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state, case QEvent::TouchBegin: inputType = QScroller::InputPress; - // fall through + Q_FALLTHROUGH(); case QEvent::TouchEnd: if (!inputType) inputType = QScroller::InputRelease; - // fallthrough + Q_FALLTHROUGH(); case QEvent::TouchUpdate: if (!inputType) inputType = QScroller::InputMove; @@ -669,7 +669,7 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state, event->accept(); } } - // fall through + Q_FALLTHROUGH(); case QEvent::TouchBegin: q->setHotSpot(globalPos); result |= scrollerIsActive ? TriggerGesture : MayBeGesture; @@ -681,7 +681,7 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state, #endif if (PressDelayHandler::instance()->isDelaying()) result |= ConsumeEventHint; - // fall through + Q_FALLTHROUGH(); case QEvent::TouchUpdate: result |= scrollerIsActive ? TriggerGesture : Ignore; break; @@ -692,7 +692,7 @@ QGestureRecognizer::Result QFlickGestureRecognizer::recognize(QGesture *state, case QEvent::MouseButtonRelease: if (PressDelayHandler::instance()->released(event, scrollerWasDragging || scrollerWasScrolling, scrollerIsActive)) result |= ConsumeEventHint; - // fall through + Q_FALLTHROUGH(); case QEvent::TouchEnd: result |= scrollerIsActive ? FinishGesture : CancelGesture; break; diff --git a/src/widgets/widgets/qabstractbutton.cpp b/src/widgets/widgets/qabstractbutton.cpp index 1a5b8db33c..d04ee24861 100644 --- a/src/widgets/widgets/qabstractbutton.cpp +++ b/src/widgets/widgets/qabstractbutton.cpp @@ -1058,7 +1058,7 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e) break; case Qt::Key_Up: next = false; - // fall through + Q_FALLTHROUGH(); case Qt::Key_Left: case Qt::Key_Right: case Qt::Key_Down: { diff --git a/src/widgets/widgets/qabstractslider.cpp b/src/widgets/widgets/qabstractslider.cpp index 4221ff40ef..e85d82edb8 100644 --- a/src/widgets/widgets/qabstractslider.cpp +++ b/src/widgets/widgets/qabstractslider.cpp @@ -933,7 +933,7 @@ void QAbstractSlider::changeEvent(QEvent *ev) d->repeatActionTimer.stop(); setSliderDown(false); } - // fall through... + Q_FALLTHROUGH(); default: QWidget::changeEvent(ev); } diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index af178ce8f5..693d5f9e93 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -676,7 +676,7 @@ bool QComboBoxPrivateContainer::eventFilter(QObject *o, QEvent *e) case Qt::Key_Down: if (!(keyEvent->modifiers() & Qt::AltModifier)) break; - // fall through + Q_FALLTHROUGH(); case Qt::Key_F4: combo->hidePopup(); return true; @@ -3140,7 +3140,7 @@ void QComboBox::keyPressEvent(QKeyEvent *e) return; } else if (e->modifiers() & Qt::ControlModifier) break; // pass to line edit for auto completion - // fall through + Q_FALLTHROUGH(); case Qt::Key_PageDown: #ifdef QT_KEYPAD_NAVIGATION if (QApplication::keypadNavigationEnabled()) diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index cb99b58d97..2131025c8d 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -2979,7 +2979,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) key_consumed = true; break; } - //FALL THROUGH + Q_FALLTHROUGH(); case Qt::Key_Left: { if (d->currentAction && !d->scroll) { QAction *nextAction = 0; @@ -3026,6 +3026,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) if (!style()->styleHint(QStyle::SH_Menu_SpaceActivatesItem, 0, this)) break; // for motif, fall through + Q_FALLTHROUGH(); #ifdef QT_KEYPAD_NAVIGATION case Qt::Key_Select: #endif -- cgit v1.2.3