diff options
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/codecs/qiconvcodec.cpp | 2 | ||||
-rw-r--r-- | src/corelib/codecs/qjiscodec.cpp | 2 | ||||
-rw-r--r-- | src/corelib/global/qcompilerdetection.h | 12 | ||||
-rw-r--r-- | src/corelib/global/qglobal.cpp | 14 | ||||
-rw-r--r-- | src/corelib/io/qsettings.cpp | 2 | ||||
-rw-r--r-- | src/corelib/io/qsettings_win.cpp | 2 | ||||
-rw-r--r-- | src/corelib/json/qjson.cpp | 4 | ||||
-rw-r--r-- | src/corelib/kernel/qmimedata.cpp | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qsystemerror.cpp | 3 | ||||
-rw-r--r-- | src/corelib/kernel/qtimerinfo_unix.cpp | 3 | ||||
-rw-r--r-- | src/corelib/kernel/qvariant.cpp | 6 | ||||
-rw-r--r-- | src/corelib/tools/qdatetime.cpp | 2 | ||||
-rw-r--r-- | src/corelib/tools/qdatetimeparser.cpp | 11 | ||||
-rw-r--r-- | src/corelib/tools/qregexp.cpp | 6 | ||||
-rw-r--r-- | src/corelib/tools/qunicodetools.cpp | 4 | ||||
-rw-r--r-- | src/corelib/xml/qxmlstream.cpp | 24 | ||||
-rw-r--r-- | src/corelib/xml/qxmlstream_p.h | 14 |
17 files changed, 70 insertions, 43 deletions
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 @@ -2950,6 +2950,20 @@ QString QSysInfo::machineHostName() */ /*! + \macro void Q_FALLTHROUGH() + \relates <QtGlobal> + \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 <QtGlobal> 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<QJsonValue>(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<QJsonValue>(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); |