diff options
Diffstat (limited to 'src')
95 files changed, 294 insertions, 294 deletions
diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h index 4f46de5eaa..3cb46e3a01 100644 --- a/src/corelib/global/qflags.h +++ b/src/corelib/global/qflags.h @@ -88,10 +88,10 @@ Q_DECL_CONSTEXPR inline QIncompatibleFlag::QIncompatibleFlag(int value) noexcept template<typename Enum> class QFlags { - Q_STATIC_ASSERT_X((sizeof(Enum) <= sizeof(int)), + static_assert((sizeof(Enum) <= sizeof(int)), "QFlags uses an int as storage, so an enum with underlying " "long long will overflow."); - Q_STATIC_ASSERT_X((std::is_enum<Enum>::value), "QFlags is only usable on enumeration types."); + static_assert((std::is_enum<Enum>::value), "QFlags is only usable on enumeration types."); #if QT_DEPRECATED_SINCE(5,15) struct Private; diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 4d990f5bb5..460a36e2bc 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -133,15 +133,15 @@ Q_CORE_EXPORT void *qMemSet(void *dest, int c, size_t n); // in. The idea here is to error or warn if otherwise implicit Qt // assumptions are not fulfilled on new hardware or compilers // (if this list becomes too long, consider factoring into a separate file) -Q_STATIC_ASSERT_X(UCHAR_MAX == 255, "Qt assumes that char is 8 bits"); -Q_STATIC_ASSERT_X(sizeof(int) == 4, "Qt assumes that int is 32 bits"); -Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined incorrectly"); -Q_STATIC_ASSERT_X(sizeof(float) == 4, "Qt assumes that float is 32 bits"); -Q_STATIC_ASSERT_X(sizeof(char16_t) == 2, "Qt assumes that char16_t is 16 bits"); -Q_STATIC_ASSERT_X(sizeof(char32_t) == 4, "Qt assumes that char32_t is 32 bits"); -Q_STATIC_ASSERT_X(std::numeric_limits<int>::radix == 2, +static_assert(UCHAR_MAX == 255, "Qt assumes that char is 8 bits"); +static_assert(sizeof(int) == 4, "Qt assumes that int is 32 bits"); +static_assert(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined incorrectly"); +static_assert(sizeof(float) == 4, "Qt assumes that float is 32 bits"); +static_assert(sizeof(char16_t) == 2, "Qt assumes that char16_t is 16 bits"); +static_assert(sizeof(char32_t) == 4, "Qt assumes that char32_t is 32 bits"); +static_assert(std::numeric_limits<int>::radix == 2, "Qt assumes binary integers"); -Q_STATIC_ASSERT_X((std::numeric_limits<int>::max() + std::numeric_limits<int>::lowest()) == -1, +static_assert((std::numeric_limits<int>::max() + std::numeric_limits<int>::lowest()) == -1, "Qt assumes two's complement integers"); // While we'd like to check for __STDC_IEC_559__, as per ISO/IEC 9899:2011 @@ -152,13 +152,13 @@ Q_STATIC_ASSERT_X((std::numeric_limits<int>::max() + std::numeric_limits<int>::l // On GHC the compiler reports std::numeric_limits<float>::is_iec559 as false. // This is all right according to our needs. #if !defined(Q_CC_GHS) -Q_STATIC_ASSERT_X(std::numeric_limits<float>::is_iec559, +static_assert(std::numeric_limits<float>::is_iec559, "Qt assumes IEEE 754 floating point"); #endif // Technically, presence of NaN and infinities are implied from the above check, // but double checking our environment doesn't hurt... -Q_STATIC_ASSERT_X(std::numeric_limits<float>::has_infinity && +static_assert(std::numeric_limits<float>::has_infinity && std::numeric_limits<float>::has_quiet_NaN && std::numeric_limits<float>::has_signaling_NaN, "Qt assumes IEEE 754 floating point"); @@ -167,13 +167,13 @@ Q_STATIC_ASSERT_X(std::numeric_limits<float>::has_infinity && // but that allows for a non-binary radix. We need to recheck that. // Note how __STDC_IEC_559__ would instead check for IEC 60559:1989, aka // ANSI/IEEE 754−1985, which specifically implies binary floating point numbers. -Q_STATIC_ASSERT_X(std::numeric_limits<float>::radix == 2, +static_assert(std::numeric_limits<float>::radix == 2, "Qt assumes binary IEEE 754 floating point"); // not required by the definition of size_t, but we depend on this -Q_STATIC_ASSERT_X(sizeof(size_t) == sizeof(void *), "size_t and a pointer don't have the same size"); -Q_STATIC_ASSERT(sizeof(size_t) == sizeof(qsizetype)); // implied by the definition -Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value)); +static_assert(sizeof(size_t) == sizeof(void *), "size_t and a pointer don't have the same size"); +static_assert(sizeof(size_t) == sizeof(qsizetype)); // implied by the definition +static_assert((std::is_same<qsizetype, qptrdiff>::value)); /*! \class QFlag diff --git a/src/corelib/global/qhooks.cpp b/src/corelib/global/qhooks.cpp index 79f9b7d6c2..22f01853b7 100644 --- a/src/corelib/global/qhooks.cpp +++ b/src/corelib/global/qhooks.cpp @@ -70,7 +70,7 @@ quintptr Q_CORE_EXPORT qtHookData[] = { 18 }; -Q_STATIC_ASSERT(QHooks::LastHookIndex == sizeof(qtHookData) / sizeof(qtHookData[0])); +static_assert(QHooks::LastHookIndex == sizeof(qtHookData) / sizeof(qtHookData[0])); QT_END_NAMESPACE diff --git a/src/corelib/global/qnumeric.cpp b/src/corelib/global/qnumeric.cpp index 9cb9c1283a..b754155b30 100644 --- a/src/corelib/global/qnumeric.cpp +++ b/src/corelib/global/qnumeric.cpp @@ -169,7 +169,7 @@ Q_CORE_EXPORT quint32 qFloatDistance(float a, float b) * IEE754 format. * Integers and floats have the same endian */ - Q_STATIC_ASSERT(sizeof(quint32) == sizeof(float)); + static_assert(sizeof(quint32) == sizeof(float)); Q_ASSERT(qIsFinite(a) && qIsFinite(b)); if (a == b) return 0; @@ -227,7 +227,7 @@ Q_CORE_EXPORT quint64 qFloatDistance(double a, double b) * IEE754 format double precision * Integers and floats have the same endian */ - Q_STATIC_ASSERT(sizeof(quint64) == sizeof(double)); + static_assert(sizeof(quint64) == sizeof(double)); Q_ASSERT(qIsFinite(a) && qIsFinite(b)); if (a == b) return 0; diff --git a/src/corelib/global/qnumeric_p.h b/src/corelib/global/qnumeric_p.h index 27490bce97..790a00bdb5 100644 --- a/src/corelib/global/qnumeric_p.h +++ b/src/corelib/global/qnumeric_p.h @@ -128,7 +128,7 @@ Q_DECL_CONST_FUNCTION static inline int fpclassify(float f) { return std::fpclas Q_DECL_CONSTEXPR Q_DECL_CONST_FUNCTION static inline double qt_inf() noexcept { - Q_STATIC_ASSERT_X(std::numeric_limits<double>::has_infinity, + static_assert(std::numeric_limits<double>::has_infinity, "platform has no definition for infinity for type double"); return std::numeric_limits<double>::infinity(); } @@ -136,7 +136,7 @@ Q_DECL_CONSTEXPR Q_DECL_CONST_FUNCTION static inline double qt_inf() noexcept #if QT_CONFIG(signaling_nan) Q_DECL_CONSTEXPR Q_DECL_CONST_FUNCTION static inline double qt_snan() noexcept { - Q_STATIC_ASSERT_X(std::numeric_limits<double>::has_signaling_NaN, + static_assert(std::numeric_limits<double>::has_signaling_NaN, "platform has no definition for signaling NaN for type double"); return std::numeric_limits<double>::signaling_NaN(); } @@ -145,7 +145,7 @@ Q_DECL_CONSTEXPR Q_DECL_CONST_FUNCTION static inline double qt_snan() noexcept // Quiet NaN Q_DECL_CONSTEXPR Q_DECL_CONST_FUNCTION static inline double qt_qnan() noexcept { - Q_STATIC_ASSERT_X(std::numeric_limits<double>::has_quiet_NaN, + static_assert(std::numeric_limits<double>::has_quiet_NaN, "platform has no definition for quiet NaN for type double"); return std::numeric_limits<double>::quiet_NaN(); } @@ -204,7 +204,7 @@ namespace { */ template <typename T> static inline bool convertDoubleTo(double v, T *value, bool allow_precision_upgrade = true) { - Q_STATIC_ASSERT(std::numeric_limits<T>::is_integer); + static_assert(std::numeric_limits<T>::is_integer); // The [conv.fpint] (7.10 Floating-integral conversions) section of the C++ // standard says only exact conversions are guaranteed. Converting diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp index e35fc21d98..c18ee6acbb 100644 --- a/src/corelib/global/qrandom.cpp +++ b/src/corelib/global/qrandom.cpp @@ -183,7 +183,7 @@ struct QRandomGenerator::SystemGenerator // other than quint32 (unsigned int) to fill their buffers. template <typename T> void generate(T *begin, T *end) { - Q_STATIC_ASSERT(sizeof(T) >= sizeof(quint32)); + static_assert(sizeof(T) >= sizeof(quint32)); if (sizeof(T) == sizeof(quint32)) { // Microsoft Visual Studio uses unsigned long, but that's still 32-bit generate(reinterpret_cast<quint32 *>(begin), reinterpret_cast<quint32 *>(end)); @@ -377,14 +377,14 @@ struct QRandomGenerator::SystemAndGlobalGenerators constexpr SystemAndGlobalGenerators g = {}; Q_UNUSED(g); - Q_STATIC_ASSERT(std::is_literal_type<SystemAndGlobalGenerators>::value); + static_assert(std::is_literal_type<SystemAndGlobalGenerators>::value); #endif } static SystemAndGlobalGenerators *self() { static SystemAndGlobalGenerators g; - Q_STATIC_ASSERT(sizeof(g) > sizeof(QRandomGenerator64)); + static_assert(sizeof(g) > sizeof(QRandomGenerator64)); return &g; } diff --git a/src/corelib/global/qrandom.h b/src/corelib/global/qrandom.h index e1494ab523..4e27ef1edc 100644 --- a/src/corelib/global/qrandom.h +++ b/src/corelib/global/qrandom.h @@ -201,7 +201,7 @@ private: const RandomEngine &engine() const { return reinterpret_cast<const RandomEngine &>(buffer); } #endif - Q_STATIC_ASSERT_X(std::is_trivially_destructible<RandomEngine>::value, + static_assert(std::is_trivially_destructible<RandomEngine>::value, "std::mersenne_twister not trivially destructible as expected"); Q_DECL_CONSTEXPR Storage(); }; diff --git a/src/corelib/io/qfiledevice.cpp b/src/corelib/io/qfiledevice.cpp index b0aba3193c..4b1809010b 100644 --- a/src/corelib/io/qfiledevice.cpp +++ b/src/corelib/io/qfiledevice.cpp @@ -756,10 +756,10 @@ bool QFileDevice::unmap(uchar *address) static inline QAbstractFileEngine::FileTime FileDeviceTimeToAbstractFileEngineTime(QFileDevice::FileTime time) { - Q_STATIC_ASSERT(int(QFileDevice::FileAccessTime) == int(QAbstractFileEngine::AccessTime)); - Q_STATIC_ASSERT(int(QFileDevice::FileBirthTime) == int(QAbstractFileEngine::BirthTime)); - Q_STATIC_ASSERT(int(QFileDevice::FileMetadataChangeTime) == int(QAbstractFileEngine::MetadataChangeTime)); - Q_STATIC_ASSERT(int(QFileDevice::FileModificationTime) == int(QAbstractFileEngine::ModificationTime)); + static_assert(int(QFileDevice::FileAccessTime) == int(QAbstractFileEngine::AccessTime)); + static_assert(int(QFileDevice::FileBirthTime) == int(QAbstractFileEngine::BirthTime)); + static_assert(int(QFileDevice::FileMetadataChangeTime) == int(QAbstractFileEngine::MetadataChangeTime)); + static_assert(int(QFileDevice::FileModificationTime) == int(QAbstractFileEngine::ModificationTime)); return QAbstractFileEngine::FileTime(time); } diff --git a/src/corelib/io/qfileinfo.cpp b/src/corelib/io/qfileinfo.cpp index f33f03262f..fb5aeac189 100644 --- a/src/corelib/io/qfileinfo.cpp +++ b/src/corelib/io/qfileinfo.cpp @@ -1492,10 +1492,10 @@ QDateTime QFileInfo::lastRead() const */ QDateTime QFileInfo::fileTime(QFile::FileTime time) const { - Q_STATIC_ASSERT(int(QFile::FileAccessTime) == int(QAbstractFileEngine::AccessTime)); - Q_STATIC_ASSERT(int(QFile::FileBirthTime) == int(QAbstractFileEngine::BirthTime)); - Q_STATIC_ASSERT(int(QFile::FileMetadataChangeTime) == int(QAbstractFileEngine::MetadataChangeTime)); - Q_STATIC_ASSERT(int(QFile::FileModificationTime) == int(QAbstractFileEngine::ModificationTime)); + static_assert(int(QFile::FileAccessTime) == int(QAbstractFileEngine::AccessTime)); + static_assert(int(QFile::FileBirthTime) == int(QAbstractFileEngine::BirthTime)); + static_assert(int(QFile::FileMetadataChangeTime) == int(QAbstractFileEngine::MetadataChangeTime)); + static_assert(int(QFile::FileModificationTime) == int(QAbstractFileEngine::ModificationTime)); Q_D(const QFileInfo); auto fetime = QAbstractFileEngine::FileTime(time); diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index 3042eac2f0..1a1a9076c7 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -85,7 +85,7 @@ typedef unsigned int UnsignedIOType; #else typedef ssize_t SignedIOType; typedef size_t UnsignedIOType; -Q_STATIC_ASSERT_X(sizeof(SignedIOType) == sizeof(UnsignedIOType), +static_assert(sizeof(SignedIOType) == sizeof(UnsignedIOType), "Unsupported: read/write return a type with different size as the len parameter"); #endif diff --git a/src/corelib/io/qstandardpaths_win.cpp b/src/corelib/io/qstandardpaths_win.cpp index cbe4ccd0b2..a120db32fc 100644 --- a/src/corelib/io/qstandardpaths_win.cpp +++ b/src/corelib/io/qstandardpaths_win.cpp @@ -147,7 +147,7 @@ static GUID writableSpecialFolderId(QStandardPaths::StandardLocation type) FOLDERID_RoamingAppData,// AppDataLocation ("Roaming" path) FOLDERID_LocalAppData, // AppConfigLocation ("Local" path) }; - Q_STATIC_ASSERT(sizeof(folderIds) / sizeof(folderIds[0]) == size_t(QStandardPaths::AppConfigLocation + 1)); + static_assert(sizeof(folderIds) / sizeof(folderIds[0]) == size_t(QStandardPaths::AppConfigLocation + 1)); // folders for low integrity processes static const GUID folderIds_li[] = { @@ -169,7 +169,7 @@ static GUID writableSpecialFolderId(QStandardPaths::StandardLocation type) FOLDERID_RoamingAppData, // AppDataLocation ("Roaming" path) FOLDERID_LocalAppDataLow,// AppConfigLocation ("Local" path) }; - Q_STATIC_ASSERT(sizeof(folderIds_li) == sizeof(folderIds)); + static_assert(sizeof(folderIds_li) == sizeof(folderIds)); static bool low_integrity_process = isProcessLowIntegrity(); if (size_t(type) < sizeof(folderIds) / sizeof(folderIds[0])) diff --git a/src/corelib/kernel/qdeadlinetimer.cpp b/src/corelib/kernel/qdeadlinetimer.cpp index 520153b2e5..0ca052764a 100644 --- a/src/corelib/kernel/qdeadlinetimer.cpp +++ b/src/corelib/kernel/qdeadlinetimer.cpp @@ -190,7 +190,7 @@ bool TimeReference::addSecsAndNSecs(qint64 addSecs, qint64 addNSecs) */ bool TimeReference::adjust(const qint64 t1, const unsigned t2, qint64 carrySeconds) { - Q_STATIC_ASSERT(QDeadlineTimerNanosecondsInT2); + static_assert(QDeadlineTimerNanosecondsInT2); nsecs += t2; if (nsecs >= ugiga) { nsecs -= ugiga; @@ -291,7 +291,7 @@ inline bool TimeReference::addSecsAndNSecs(qint64 addSecs, qint64 addNSecs) inline bool TimeReference::adjust(const qint64 t1, const unsigned t2, qint64 carrySeconds) { - Q_STATIC_ASSERT(!QDeadlineTimerNanosecondsInT2); + static_assert(!QDeadlineTimerNanosecondsInT2); Q_UNUSED(t2); Q_UNUSED(carrySeconds); diff --git a/src/corelib/kernel/qelapsedtimer_mac.cpp b/src/corelib/kernel/qelapsedtimer_mac.cpp index 5370cf7b3d..1d9f02dff0 100644 --- a/src/corelib/kernel/qelapsedtimer_mac.cpp +++ b/src/corelib/kernel/qelapsedtimer_mac.cpp @@ -156,7 +156,7 @@ bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) noexcept QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType) noexcept { - Q_STATIC_ASSERT(!QDeadlineTimerNanosecondsInT2); + static_assert(!QDeadlineTimerNanosecondsInT2); QDeadlineTimer result; result.type = timerType; result.t1 = absoluteToNSecs(mach_absolute_time()); diff --git a/src/corelib/kernel/qelapsedtimer_unix.cpp b/src/corelib/kernel/qelapsedtimer_unix.cpp index ccc2eeafa3..59f5f90155 100644 --- a/src/corelib/kernel/qelapsedtimer_unix.cpp +++ b/src/corelib/kernel/qelapsedtimer_unix.cpp @@ -252,7 +252,7 @@ bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) noexcept QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType) noexcept { - Q_STATIC_ASSERT(QDeadlineTimerNanosecondsInT2); + static_assert(QDeadlineTimerNanosecondsInT2); QDeadlineTimer result; qint64 cursec, curnsec; do_gettime(&cursec, &curnsec); diff --git a/src/corelib/kernel/qelapsedtimer_win.cpp b/src/corelib/kernel/qelapsedtimer_win.cpp index 8becb17461..deeeb05921 100644 --- a/src/corelib/kernel/qelapsedtimer_win.cpp +++ b/src/corelib/kernel/qelapsedtimer_win.cpp @@ -162,7 +162,7 @@ bool operator<(const QElapsedTimer &v1, const QElapsedTimer &v2) noexcept QDeadlineTimer QDeadlineTimer::current(Qt::TimerType timerType) noexcept { - Q_STATIC_ASSERT(!QDeadlineTimerNanosecondsInT2); + static_assert(!QDeadlineTimerNanosecondsInT2); QDeadlineTimer result; result.t1 = ticksToNanoseconds(getTickCount()); result.type = timerType; diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h index 474e4da0f1..20a5c67586 100644 --- a/src/corelib/kernel/qmetaobject.h +++ b/src/corelib/kernel/qmetaobject.h @@ -171,7 +171,7 @@ public: static inline QMetaMethod fromSignal(PointerToMemberFunction signal) { typedef QtPrivate::FunctionPointer<PointerToMemberFunction> SignalType; - Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value, + static_assert(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value, "No Q_OBJECT in the class with the signal"); return fromSignalImpl(&SignalType::Object::staticMetaObject, reinterpret_cast<void **>(&signal)); @@ -241,7 +241,7 @@ public: inline bool isValid() const { return name() != nullptr; } template<typename T> static QMetaEnum fromType() { - Q_STATIC_ASSERT_X(QtPrivate::IsQEnumHelper<T>::Value, + static_assert(QtPrivate::IsQEnumHelper<T>::Value, "QMetaEnum::fromType only works with enums declared as " "Q_ENUM, Q_ENUM_NS, Q_FLAG or Q_FLAG_NS"); const QMetaObject *metaObject = qt_getEnumMetaObject(T()); diff --git a/src/corelib/kernel/qmetaobjectbuilder.cpp b/src/corelib/kernel/qmetaobjectbuilder.cpp index 204ba8f51b..1902b5e360 100644 --- a/src/corelib/kernel/qmetaobjectbuilder.cpp +++ b/src/corelib/kernel/qmetaobjectbuilder.cpp @@ -1193,7 +1193,7 @@ static int buildMetaObject(QMetaObjectBuilderPrivate *d, char *buf, - int(d->methods.size()) // return "parameters" don't have names - int(d->constructors.size()); // "this" parameters don't have names if (buf) { - Q_STATIC_ASSERT_X(QMetaObjectPrivate::OutputRevision == 9, "QMetaObjectBuilder should generate the same version as moc"); + static_assert(QMetaObjectPrivate::OutputRevision == 9, "QMetaObjectBuilder should generate the same version as moc"); pmeta->revision = QMetaObjectPrivate::OutputRevision; pmeta->flags = d->flags; pmeta->className = 0; // Class name is always the first string. diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 10fc5701e5..61515f7ea5 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -1293,7 +1293,7 @@ class HasStreamOperator { struct Yes { char unused[1]; }; struct No { char unused[2]; }; - Q_STATIC_ASSERT(sizeof(Yes) != sizeof(No)); + static_assert(sizeof(Yes) != sizeof(No)); template<class C> static decltype(std::declval<QDataStream&>().operator>>(std::declval<C&>()), Yes()) load(int); template<class C> static decltype(operator>>(std::declval<QDataStream&>(), std::declval<C&>()), Yes()) load(int); @@ -1310,9 +1310,9 @@ public: }; // Quick sanity checks -Q_STATIC_ASSERT(HasStreamOperator<NS(QJsonDocument)>::Value); -Q_STATIC_ASSERT(!HasStreamOperator<void*>::Value); -Q_STATIC_ASSERT(HasStreamOperator<qint8>::Value); +static_assert(HasStreamOperator<NS(QJsonDocument)>::Value); +static_assert(!HasStreamOperator<void*>::Value); +static_assert(HasStreamOperator<qint8>::Value); template<typename T, bool IsAcceptedType = DefinedTypesFilter::Acceptor<T>::IsAccepted && HasStreamOperator<T>::Value> struct FilteredOperatorSwitch diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index f59acf2d54..196df677e9 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -580,7 +580,7 @@ public: template<typename T> static bool registerComparators() { - Q_STATIC_ASSERT_X((!QMetaTypeId2<T>::IsBuiltIn), + static_assert((!QMetaTypeId2<T>::IsBuiltIn), "QMetaType::registerComparators: The type must be a custom type."); const int typeId = qMetaTypeId<T>(); @@ -590,7 +590,7 @@ public: template<typename T> static bool registerEqualsComparator() { - Q_STATIC_ASSERT_X((!QMetaTypeId2<T>::IsBuiltIn), + static_assert((!QMetaTypeId2<T>::IsBuiltIn), "QMetaType::registerEqualsComparator: The type must be a custom type."); const int typeId = qMetaTypeId<T>(); static const QtPrivate::BuiltInEqualsComparatorFunction<T> f; @@ -609,7 +609,7 @@ public: template<typename T> static bool registerDebugStreamOperator() { - Q_STATIC_ASSERT_X((!QMetaTypeId2<T>::IsBuiltIn), + static_assert((!QMetaTypeId2<T>::IsBuiltIn), "QMetaType::registerDebugStreamOperator: The type must be a custom type."); const int typeId = qMetaTypeId<T>(); @@ -643,7 +643,7 @@ public: template<typename From, typename To> static bool registerConverter(To(From::*function)() const) { - Q_STATIC_ASSERT_X((!QMetaTypeId2<To>::IsBuiltIn || !QMetaTypeId2<From>::IsBuiltIn), + static_assert((!QMetaTypeId2<To>::IsBuiltIn || !QMetaTypeId2<From>::IsBuiltIn), "QMetaType::registerConverter: At least one of the types must be a custom type."); const int fromTypeId = qMetaTypeId<From>(); @@ -656,7 +656,7 @@ public: template<typename From, typename To> static bool registerConverter(To(From::*function)(bool*) const) { - Q_STATIC_ASSERT_X((!QMetaTypeId2<To>::IsBuiltIn || !QMetaTypeId2<From>::IsBuiltIn), + static_assert((!QMetaTypeId2<To>::IsBuiltIn || !QMetaTypeId2<From>::IsBuiltIn), "QMetaType::registerConverter: At least one of the types must be a custom type."); const int fromTypeId = qMetaTypeId<From>(); @@ -669,7 +669,7 @@ public: template<typename From, typename To, typename UnaryFunction> static bool registerConverter(UnaryFunction function) { - Q_STATIC_ASSERT_X((!QMetaTypeId2<To>::IsBuiltIn || !QMetaTypeId2<From>::IsBuiltIn), + static_assert((!QMetaTypeId2<To>::IsBuiltIn || !QMetaTypeId2<From>::IsBuiltIn), "QMetaType::registerConverter: At least one of the types must be a custom type."); const int fromTypeId = qMetaTypeId<From>(); @@ -1444,7 +1444,7 @@ namespace QtPrivate static yes_type checkType(QObject* ); #endif static no_type checkType(...); - Q_STATIC_ASSERT_X(sizeof(T), "Type argument of Q_DECLARE_METATYPE(T*) must be fully defined"); + static_assert(sizeof(T), "Type argument of Q_DECLARE_METATYPE(T*) must be fully defined"); enum { Value = sizeof(checkType(static_cast<T*>(nullptr))) == sizeof(yes_type) }; }; diff --git a/src/corelib/kernel/qmetatype_p.h b/src/corelib/kernel/qmetatype_p.h index 2f4d69488f..d8dba13770 100644 --- a/src/corelib/kernel/qmetatype_p.h +++ b/src/corelib/kernel/qmetatype_p.h @@ -94,7 +94,7 @@ public: \ IsUnknown = !(IsCore || IsWidget || IsGui) \ }; \ static inline int module() { return MODULE; } \ - Q_STATIC_ASSERT((IsUnknown && !(IsCore || IsWidget || IsGui)) \ + static_assert((IsUnknown && !(IsCore || IsWidget || IsGui)) \ || (IsCore && !(IsUnknown || IsWidget || IsGui)) \ || (IsWidget && !(IsUnknown || IsCore || IsGui)) \ || (IsGui && !(IsUnknown || IsCore || IsWidget))); \ diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 556d975786..ea635ce6f1 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -220,15 +220,15 @@ public: typedef QtPrivate::FunctionPointer<Func1> SignalType; typedef QtPrivate::FunctionPointer<Func2> SlotType; - Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value, + static_assert(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value, "No Q_OBJECT in the class with the signal"); //compilation error if the arguments does not match. - Q_STATIC_ASSERT_X(int(SignalType::ArgumentCount) >= int(SlotType::ArgumentCount), + static_assert(int(SignalType::ArgumentCount) >= int(SlotType::ArgumentCount), "The slot requires more arguments than the signal provides."); - Q_STATIC_ASSERT_X((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value), + static_assert((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value), "Signal and slot arguments are not compatible."); - Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible<typename SlotType::ReturnType, typename SignalType::ReturnType>::value), + static_assert((QtPrivate::AreArgumentsCompatible<typename SlotType::ReturnType, typename SignalType::ReturnType>::value), "Return type of the slot is not compatible with the return type of the signal."); const int *types = nullptr; @@ -260,15 +260,15 @@ public: typedef QtPrivate::FunctionPointer<Func1> SignalType; typedef QtPrivate::FunctionPointer<Func2> SlotType; - Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value, + static_assert(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value, "No Q_OBJECT in the class with the signal"); //compilation error if the arguments does not match. - Q_STATIC_ASSERT_X(int(SignalType::ArgumentCount) >= int(SlotType::ArgumentCount), + static_assert(int(SignalType::ArgumentCount) >= int(SlotType::ArgumentCount), "The slot requires more arguments than the signal provides."); - Q_STATIC_ASSERT_X((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value), + static_assert((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value), "Signal and slot arguments are not compatible."); - Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible<typename SlotType::ReturnType, typename SignalType::ReturnType>::value), + static_assert((QtPrivate::AreArgumentsCompatible<typename SlotType::ReturnType, typename SignalType::ReturnType>::value), "Return type of the slot is not compatible with the return type of the signal."); const int *types = nullptr; @@ -299,15 +299,15 @@ public: typedef QtPrivate::FunctionPointer<Func1> SignalType; const int FunctorArgumentCount = QtPrivate::ComputeFunctorArgumentCount<Func2 , typename SignalType::Arguments>::Value; - Q_STATIC_ASSERT_X((FunctorArgumentCount >= 0), + static_assert((FunctorArgumentCount >= 0), "Signal and slot arguments are not compatible."); const int SlotArgumentCount = (FunctorArgumentCount >= 0) ? FunctorArgumentCount : 0; typedef typename QtPrivate::FunctorReturnType<Func2, typename QtPrivate::List_Left<typename SignalType::Arguments, SlotArgumentCount>::Value>::Value SlotReturnType; - Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible<SlotReturnType, typename SignalType::ReturnType>::value), + static_assert((QtPrivate::AreArgumentsCompatible<SlotReturnType, typename SignalType::ReturnType>::value), "Return type of the slot is not compatible with the return type of the signal."); - Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value, + static_assert(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value, "No Q_OBJECT in the class with the signal"); const int *types = nullptr; @@ -344,11 +344,11 @@ public: typedef QtPrivate::FunctionPointer<Func1> SignalType; typedef QtPrivate::FunctionPointer<Func2> SlotType; - Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value, + static_assert(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value, "No Q_OBJECT in the class with the signal"); //compilation error if the arguments does not match. - Q_STATIC_ASSERT_X((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value), + static_assert((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value), "Signal and slot arguments are not compatible."); return disconnectImpl(sender, reinterpret_cast<void **>(&signal), receiver, reinterpret_cast<void **>(&slot), @@ -461,7 +461,7 @@ template <class T> inline T qobject_cast(QObject *object) { typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type ObjType; - Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<ObjType>::Value, + static_assert(QtPrivate::HasQ_OBJECT_Macro<ObjType>::Value, "qobject_cast requires the type to have a Q_OBJECT macro"); return static_cast<T>(ObjType::staticMetaObject.cast(object)); } @@ -470,7 +470,7 @@ template <class T> inline T qobject_cast(const QObject *object) { typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type ObjType; - Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<ObjType>::Value, + static_assert(QtPrivate::HasQ_OBJECT_Macro<ObjType>::Value, "qobject_cast requires the type to have a Q_OBJECT macro"); return static_cast<T>(ObjType::staticMetaObject.cast(object)); } diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 97b492360c..ae6e4d3452 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -457,15 +457,15 @@ inline QMetaObject::Connection QObjectPrivate::connect(const typename QtPrivate: { typedef QtPrivate::FunctionPointer<Func1> SignalType; typedef QtPrivate::FunctionPointer<Func2> SlotType; - Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value, + static_assert(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value, "No Q_OBJECT in the class with the signal"); //compilation error if the arguments does not match. - Q_STATIC_ASSERT_X(int(SignalType::ArgumentCount) >= int(SlotType::ArgumentCount), + static_assert(int(SignalType::ArgumentCount) >= int(SlotType::ArgumentCount), "The slot requires more arguments than the signal provides."); - Q_STATIC_ASSERT_X((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value), + static_assert((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value), "Signal and slot arguments are not compatible."); - Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible<typename SlotType::ReturnType, typename SignalType::ReturnType>::value), + static_assert((QtPrivate::AreArgumentsCompatible<typename SlotType::ReturnType, typename SignalType::ReturnType>::value), "Return type of the slot is not compatible with the return type of the signal."); const int *types = nullptr; @@ -485,10 +485,10 @@ bool QObjectPrivate::disconnect(const typename QtPrivate::FunctionPointer< Func1 { typedef QtPrivate::FunctionPointer<Func1> SignalType; typedef QtPrivate::FunctionPointer<Func2> SlotType; - Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value, + static_assert(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value, "No Q_OBJECT in the class with the signal"); //compilation error if the arguments does not match. - Q_STATIC_ASSERT_X((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value), + static_assert((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value), "Signal and slot arguments are not compatible."); return QObject::disconnectImpl(sender, reinterpret_cast<void **>(&signal), receiverPrivate->q_ptr, reinterpret_cast<void **>(&slot), diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h index 71d6e236d7..f3f7f3df72 100644 --- a/src/corelib/kernel/qobjectdefs_impl.h +++ b/src/corelib/kernel/qobjectdefs_impl.h @@ -287,7 +287,7 @@ namespace QtPrivate { /* Logic that check if the arguments of the slot matches the argument of the signal. To be used like this: - Q_STATIC_ASSERT(CheckCompatibleArguments<FunctionPointer<Signal>::Arguments, FunctionPointer<Slot>::Arguments>::value) + static_assert(CheckCompatibleArguments<FunctionPointer<Signal>::Arguments, FunctionPointer<Slot>::Arguments>::value) */ template<typename A1, typename A2> struct AreArgumentsCompatible { static int test(const typename RemoveRef<A2>::Type&); @@ -296,7 +296,7 @@ namespace QtPrivate { enum { value = sizeof(test(dummy())) == sizeof(int) }; #ifdef QT_NO_NARROWING_CONVERSIONS_IN_CONNECT using AreArgumentsConvertibleWithoutNarrowing = AreArgumentsConvertibleWithoutNarrowingBase<std::decay_t<A1>, std::decay_t<A2>>; - Q_STATIC_ASSERT_X(AreArgumentsConvertibleWithoutNarrowing::value, "Signal and slot arguments are not compatible (narrowing)"); + static_assert(AreArgumentsConvertibleWithoutNarrowing::value, "Signal and slot arguments are not compatible (narrowing)"); #endif }; template<typename A1, typename A2> struct AreArgumentsCompatible<A1, A2&> { enum { value = false }; }; diff --git a/src/corelib/kernel/qpointer.h b/src/corelib/kernel/qpointer.h index 769ace5a71..ebc06a0fb1 100644 --- a/src/corelib/kernel/qpointer.h +++ b/src/corelib/kernel/qpointer.h @@ -52,7 +52,7 @@ class QVariant; template <class T> class QPointer { - Q_STATIC_ASSERT_X(!std::is_pointer<T>::value, "QPointer's template type must not be a pointer type"); + static_assert(!std::is_pointer<T>::value, "QPointer's template type must not be a pointer type"); using QObjectType = typename std::conditional<std::is_const<T>::value, const QObject, QObject>::type; diff --git a/src/corelib/kernel/qtimer.h b/src/corelib/kernel/qtimer.h index 6bbfd741d9..c55fd8d6c3 100644 --- a/src/corelib/kernel/qtimer.h +++ b/src/corelib/kernel/qtimer.h @@ -116,7 +116,7 @@ public: typedef QtPrivate::FunctionPointer<Func1> SlotType; //compilation error if the slot has arguments. - Q_STATIC_ASSERT_X(int(SlotType::ArgumentCount) == 0, + static_assert(int(SlotType::ArgumentCount) == 0, "The slot must not have any arguments."); singleShotImpl(interval, timerType, receiver, @@ -152,7 +152,7 @@ public: { //compilation error if the slot has arguments. typedef QtPrivate::FunctionPointer<Func1> SlotType; - Q_STATIC_ASSERT_X(int(SlotType::ArgumentCount) <= 0, "The slot must not have any arguments."); + static_assert(int(SlotType::ArgumentCount) <= 0, "The slot must not have any arguments."); singleShotImpl(interval, timerType, context, new QtPrivate::QFunctorSlotObject<Func1, 0, diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 5b397f5198..61a80eeae8 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -1519,7 +1519,7 @@ const QVariant::Handler qt_custom_variant_handler = { static HandlersManager handlerManager; -Q_STATIC_ASSERT_X(!QModulesPrivate::Core, "Initialization assumes that ModulesNames::Core is 0"); +static_assert(!QModulesPrivate::Core, "Initialization assumes that ModulesNames::Core is 0"); const QVariant::Handler *HandlersManager::Handlers[QModulesPrivate::ModulesCount] = { &qt_kernel_variant_handler, &qt_dummy_variant_handler, &qt_dummy_variant_handler, &qt_custom_variant_handler }; diff --git a/src/corelib/kernel/qvariant_p.h b/src/corelib/kernel/qvariant_p.h index aa89d42092..8739cb5173 100644 --- a/src/corelib/kernel/qvariant_p.h +++ b/src/corelib/kernel/qvariant_p.h @@ -68,9 +68,9 @@ struct QVariantIntegrator && ((QTypeInfoQuery<T>::isRelocatable) || std::is_enum<T>::value); typedef std::integral_constant<bool, CanUseInternalSpace> CanUseInternalSpace_t; }; -Q_STATIC_ASSERT(QVariantIntegrator<double>::CanUseInternalSpace); -Q_STATIC_ASSERT(QVariantIntegrator<long int>::CanUseInternalSpace); -Q_STATIC_ASSERT(QVariantIntegrator<qulonglong>::CanUseInternalSpace); +static_assert(QVariantIntegrator<double>::CanUseInternalSpace); +static_assert(QVariantIntegrator<long int>::CanUseInternalSpace); +static_assert(QVariantIntegrator<qulonglong>::CanUseInternalSpace); #ifdef Q_CC_SUN // Sun CC picks the wrong overload, so introduce awful hack @@ -267,7 +267,7 @@ class QVariantIsNull class HasIsNullMethod { struct Yes { char unused[1]; }; struct No { char unused[2]; }; - Q_STATIC_ASSERT(sizeof(Yes) != sizeof(No)); + static_assert(sizeof(Yes) != sizeof(No)); template<class C> static decltype(static_cast<const C*>(nullptr)->isNull(), Yes()) test(int); template<class C> static No test(...); @@ -276,19 +276,19 @@ class QVariantIsNull }; // TODO This part should go to autotests during HasIsNullMethod generalization. - Q_STATIC_ASSERT(!HasIsNullMethod<bool>::Value); + static_assert(!HasIsNullMethod<bool>::Value); struct SelfTest1 { bool isNull() const; }; - Q_STATIC_ASSERT(HasIsNullMethod<SelfTest1>::Value); + static_assert(HasIsNullMethod<SelfTest1>::Value); struct SelfTest2 {}; - Q_STATIC_ASSERT(!HasIsNullMethod<SelfTest2>::Value); + static_assert(!HasIsNullMethod<SelfTest2>::Value); struct SelfTest3 : public SelfTest1 {}; - Q_STATIC_ASSERT(HasIsNullMethod<SelfTest3>::Value); + static_assert(HasIsNullMethod<SelfTest3>::Value); struct SelfTestFinal1 final { bool isNull() const; }; - Q_STATIC_ASSERT(HasIsNullMethod<SelfTestFinal1>::Value); + static_assert(HasIsNullMethod<SelfTestFinal1>::Value); struct SelfTestFinal2 final {}; - Q_STATIC_ASSERT(!HasIsNullMethod<SelfTestFinal2>::Value); + static_assert(!HasIsNullMethod<SelfTestFinal2>::Value); struct SelfTestFinal3 final : public SelfTest1 {}; - Q_STATIC_ASSERT(HasIsNullMethod<SelfTestFinal3>::Value); + static_assert(HasIsNullMethod<SelfTestFinal3>::Value); template<typename T, bool HasIsNull = HasIsNullMethod<T>::Value> struct CallFilteredIsNull diff --git a/src/corelib/mimetypes/qmimeprovider.cpp b/src/corelib/mimetypes/qmimeprovider.cpp index c18d72fd2c..cbf2562581 100644 --- a/src/corelib/mimetypes/qmimeprovider.cpp +++ b/src/corelib/mimetypes/qmimeprovider.cpp @@ -630,10 +630,10 @@ static QString internalMimeFileName() QMimeXMLProvider::QMimeXMLProvider(QMimeDatabasePrivate *db, InternalDatabaseEnum) : QMimeProviderBase(db, internalMimeFileName()) { - Q_STATIC_ASSERT_X(sizeof(mimetype_database), "Bundled MIME database is empty"); - Q_STATIC_ASSERT_X(sizeof(mimetype_database) <= MimeTypeDatabaseOriginalSize, + static_assert(sizeof(mimetype_database), "Bundled MIME database is empty"); + static_assert(sizeof(mimetype_database) <= MimeTypeDatabaseOriginalSize, "Compressed MIME database is larger than the original size"); - Q_STATIC_ASSERT_X(MimeTypeDatabaseOriginalSize <= 16*1024*1024, + static_assert(MimeTypeDatabaseOriginalSize <= 16*1024*1024, "Bundled MIME database is too big"); const char *data = reinterpret_cast<const char *>(mimetype_database); qsizetype size = MimeTypeDatabaseOriginalSize; diff --git a/src/corelib/plugin/qplugin.h b/src/corelib/plugin/qplugin.h index c176155c28..d53182f1a9 100644 --- a/src/corelib/plugin/qplugin.h +++ b/src/corelib/plugin/qplugin.h @@ -207,10 +207,10 @@ void Q_CORE_EXPORT qRegisterStaticPluginFunction(QStaticPlugin staticPlugin); #define Q_EXPORT_PLUGIN(PLUGIN) \ Q_EXPORT_PLUGIN2(PLUGIN, PLUGIN) # define Q_EXPORT_PLUGIN2(PLUGIN, PLUGINCLASS) \ - Q_STATIC_ASSERT_X(false, "Old plugin system used") + static_assert(false, "Old plugin system used") # define Q_EXPORT_STATIC_PLUGIN2(PLUGIN, PLUGINCLASS) \ - Q_STATIC_ASSERT_X(false, "Old plugin system used") + static_assert(false, "Old plugin system used") QT_END_NAMESPACE diff --git a/src/corelib/serialization/qbinaryjson.cpp b/src/corelib/serialization/qbinaryjson.cpp index 3d359f0998..4149705df5 100644 --- a/src/corelib/serialization/qbinaryjson.cpp +++ b/src/corelib/serialization/qbinaryjson.cpp @@ -60,7 +60,7 @@ static Q_CONSTEXPR Base emptyObject = { void MutableData::compact() { - Q_STATIC_ASSERT(sizeof(Value) == sizeof(offset)); + static_assert(sizeof(Value) == sizeof(offset)); Base *base = header->root(); int reserve = 0; diff --git a/src/corelib/serialization/qcborcommon.cpp b/src/corelib/serialization/qcborcommon.cpp index 5fc47fa399..b29e1f1bf6 100644 --- a/src/corelib/serialization/qcborcommon.cpp +++ b/src/corelib/serialization/qcborcommon.cpp @@ -271,50 +271,50 @@ QString QCborError::toString() const { switch (c) { case NoError: - Q_STATIC_ASSERT(int(NoError) == int(CborNoError)); + static_assert(int(NoError) == int(CborNoError)); return QString(); case UnknownError: - Q_STATIC_ASSERT(int(UnknownError) == int(CborUnknownError)); + static_assert(int(UnknownError) == int(CborUnknownError)); return QStringLiteral("Unknown error"); case AdvancePastEnd: - Q_STATIC_ASSERT(int(AdvancePastEnd) == int(CborErrorAdvancePastEOF)); + static_assert(int(AdvancePastEnd) == int(CborErrorAdvancePastEOF)); return QStringLiteral("Read past end of buffer (more bytes needed)"); case InputOutputError: - Q_STATIC_ASSERT(int(InputOutputError) == int(CborErrorIO)); + static_assert(int(InputOutputError) == int(CborErrorIO)); return QStringLiteral("Input/Output error"); case GarbageAtEnd: - Q_STATIC_ASSERT(int(GarbageAtEnd) == int(CborErrorGarbageAtEnd)); + static_assert(int(GarbageAtEnd) == int(CborErrorGarbageAtEnd)); return QStringLiteral("Data found after the end of the stream"); case EndOfFile: - Q_STATIC_ASSERT(int(EndOfFile) == int(CborErrorUnexpectedEOF)); + static_assert(int(EndOfFile) == int(CborErrorUnexpectedEOF)); return QStringLiteral("Unexpected end of input data (more bytes needed)"); case UnexpectedBreak: - Q_STATIC_ASSERT(int(UnexpectedBreak) == int(CborErrorUnexpectedBreak)); + static_assert(int(UnexpectedBreak) == int(CborErrorUnexpectedBreak)); return QStringLiteral("Invalid CBOR stream: unexpected 'break' byte"); case UnknownType: - Q_STATIC_ASSERT(int(UnknownType) == int(CborErrorUnknownType)); + static_assert(int(UnknownType) == int(CborErrorUnknownType)); return QStringLiteral("Invalid CBOR stream: unknown type"); case IllegalType: - Q_STATIC_ASSERT(int(IllegalType) == int(CborErrorIllegalType)); + static_assert(int(IllegalType) == int(CborErrorIllegalType)); return QStringLiteral("Invalid CBOR stream: illegal type found"); case IllegalNumber: - Q_STATIC_ASSERT(int(IllegalNumber) == int(CborErrorIllegalNumber)); + static_assert(int(IllegalNumber) == int(CborErrorIllegalNumber)); return QStringLiteral("Invalid CBOR stream: illegal number encoding (future extension)"); case IllegalSimpleType: - Q_STATIC_ASSERT(int(IllegalSimpleType) == int(CborErrorIllegalSimpleType)); + static_assert(int(IllegalSimpleType) == int(CborErrorIllegalSimpleType)); return QStringLiteral("Invalid CBOR stream: illegal simple type"); case InvalidUtf8String: - Q_STATIC_ASSERT(int(InvalidUtf8String) == int(CborErrorInvalidUtf8TextString)); + static_assert(int(InvalidUtf8String) == int(CborErrorInvalidUtf8TextString)); return QStringLiteral("Invalid CBOR stream: invalid UTF-8 text string"); case DataTooLarge: - Q_STATIC_ASSERT(int(DataTooLarge) == int(CborErrorDataTooLarge)); + static_assert(int(DataTooLarge) == int(CborErrorDataTooLarge)); return QStringLiteral("Internal limitation: data set too large"); case NestingTooDeep: - Q_STATIC_ASSERT(int(NestingTooDeep) == int(CborErrorNestingTooDeep)); + static_assert(int(NestingTooDeep) == int(CborErrorNestingTooDeep)); return QStringLiteral("Internal limitation: data nesting too deep"); case UnsupportedType: - Q_STATIC_ASSERT(int(UnsupportedType) == int(CborErrorUnsupportedType)); + static_assert(int(UnsupportedType) == int(CborErrorUnsupportedType)); return QStringLiteral("Internal limitation: unsupported type"); } diff --git a/src/corelib/serialization/qcborstreamreader.cpp b/src/corelib/serialization/qcborstreamreader.cpp index 5eb2086447..308fbe9ae9 100644 --- a/src/corelib/serialization/qcborstreamreader.cpp +++ b/src/corelib/serialization/qcborstreamreader.cpp @@ -80,17 +80,17 @@ static CborError Q_DECL_UNUSED cbor_value_get_half_float_as_float(const CborValu } // confirm our constants match TinyCBOR's -Q_STATIC_ASSERT(int(QCborStreamReader::UnsignedInteger) == CborIntegerType); -Q_STATIC_ASSERT(int(QCborStreamReader::ByteString) == CborByteStringType); -Q_STATIC_ASSERT(int(QCborStreamReader::TextString) == CborTextStringType); -Q_STATIC_ASSERT(int(QCborStreamReader::Array) == CborArrayType); -Q_STATIC_ASSERT(int(QCborStreamReader::Map) == CborMapType); -Q_STATIC_ASSERT(int(QCborStreamReader::Tag) == CborTagType); -Q_STATIC_ASSERT(int(QCborStreamReader::SimpleType) == CborSimpleType); -Q_STATIC_ASSERT(int(QCborStreamReader::HalfFloat) == CborHalfFloatType); -Q_STATIC_ASSERT(int(QCborStreamReader::Float) == CborFloatType); -Q_STATIC_ASSERT(int(QCborStreamReader::Double) == CborDoubleType); -Q_STATIC_ASSERT(int(QCborStreamReader::Invalid) == CborInvalidType); +static_assert(int(QCborStreamReader::UnsignedInteger) == CborIntegerType); +static_assert(int(QCborStreamReader::ByteString) == CborByteStringType); +static_assert(int(QCborStreamReader::TextString) == CborTextStringType); +static_assert(int(QCborStreamReader::Array) == CborArrayType); +static_assert(int(QCborStreamReader::Map) == CborMapType); +static_assert(int(QCborStreamReader::Tag) == CborTagType); +static_assert(int(QCborStreamReader::SimpleType) == CborSimpleType); +static_assert(int(QCborStreamReader::HalfFloat) == CborHalfFloatType); +static_assert(int(QCborStreamReader::Float) == CborFloatType); +static_assert(int(QCborStreamReader::Double) == CborDoubleType); +static_assert(int(QCborStreamReader::Invalid) == CborInvalidType); /*! \class QCborStreamReader @@ -708,8 +708,8 @@ static CborError qt_cbor_decoder_transfer_string(void *token, const void **userp { auto self = static_cast<QCborStreamReaderPrivate *>(token); Q_ASSERT(offset <= size_t(self->buffer.size())); - Q_STATIC_ASSERT(sizeof(size_t) >= sizeof(QByteArray::size_type)); - Q_STATIC_ASSERT(sizeof(size_t) == sizeof(qsizetype)); + static_assert(sizeof(size_t) >= sizeof(QByteArray::size_type)); + static_assert(sizeof(size_t) == sizeof(qsizetype)); // check that we will have enough data from the QIODevice before we advance // (otherwise, we'd lose the length information) diff --git a/src/corelib/serialization/qcborstreamwriter.cpp b/src/corelib/serialization/qcborstreamwriter.cpp index c73c17aed1..791f8775ff 100644 --- a/src/corelib/serialization/qcborstreamwriter.cpp +++ b/src/corelib/serialization/qcborstreamwriter.cpp @@ -243,7 +243,7 @@ public: void createContainer(CborError (*f)(CborEncoder *, CborEncoder *, size_t), quint64 len = IndefiniteLength) { - Q_STATIC_ASSERT(size_t(IndefiniteLength) == CborIndefiniteLength); + static_assert(size_t(IndefiniteLength) == CborIndefiniteLength); if (sizeof(len) != sizeof(size_t) && len != IndefiniteLength) { if (Q_UNLIKELY(len >= CborIndefiniteLength)) { // TinyCBOR can't do this in 32-bit mode diff --git a/src/corelib/serialization/qcborvalue.h b/src/corelib/serialization/qcborvalue.h index ebdd9c18bf..487173e421 100644 --- a/src/corelib/serialization/qcborvalue.h +++ b/src/corelib/serialization/qcborvalue.h @@ -320,7 +320,7 @@ private: double fp_helper() const { - Q_STATIC_ASSERT(sizeof(double) == sizeof(n)); + static_assert(sizeof(double) == sizeof(n)); double d; memcpy(&d, &n, sizeof(d)); return d; diff --git a/src/corelib/serialization/qcborvalue_p.h b/src/corelib/serialization/qcborvalue_p.h index 38383c7522..cad605bd1a 100644 --- a/src/corelib/serialization/qcborvalue_p.h +++ b/src/corelib/serialization/qcborvalue_p.h @@ -95,7 +95,7 @@ struct Element } }; Q_DECLARE_OPERATORS_FOR_FLAGS(Element::ValueFlags) -Q_STATIC_ASSERT(sizeof(Element) == 16); +static_assert(sizeof(Element) == 16); struct ByteData { @@ -115,8 +115,8 @@ struct ByteData QStringView asStringView() const{ return QStringView(utf16(), len / 2); } QString asQStringRaw() const { return QString::fromRawData(utf16(), len / 2); } }; -Q_STATIC_ASSERT(std::is_trivial<ByteData>::value); -Q_STATIC_ASSERT(std::is_standard_layout<ByteData>::value); +static_assert(std::is_trivial<ByteData>::value); +static_assert(std::is_standard_layout<ByteData>::value); } // namespace QtCbor Q_DECLARE_TYPEINFO(QtCbor::Element, Q_PRIMITIVE_TYPE); diff --git a/src/corelib/serialization/qjsonvalue.h b/src/corelib/serialization/qjsonvalue.h index 6acdace562..205ee31dd5 100644 --- a/src/corelib/serialization/qjsonvalue.h +++ b/src/corelib/serialization/qjsonvalue.h @@ -152,8 +152,8 @@ private: QCborValue::Type t; // Assert binary compatibility with pre-5.15 QJsonValue - Q_STATIC_ASSERT(sizeof(QExplicitlySharedDataPointer<QCborContainerPrivate>) == sizeof(void *)); - Q_STATIC_ASSERT(sizeof(QCborValue::Type) == sizeof(QJsonValue::Type)); + static_assert(sizeof(QExplicitlySharedDataPointer<QCborContainerPrivate>) == sizeof(void *)); + static_assert(sizeof(QCborValue::Type) == sizeof(QJsonValue::Type)); }; class Q_CORE_EXPORT QJsonValueRef diff --git a/src/corelib/text/qbytearraymatcher.h b/src/corelib/text/qbytearraymatcher.h index 7cc5037095..95de7416a0 100644 --- a/src/corelib/text/qbytearraymatcher.h +++ b/src/corelib/text/qbytearraymatcher.h @@ -138,7 +138,7 @@ template <uint N> class QStaticByteArrayMatcher : QStaticByteArrayMatcherBase { char m_pattern[N]; - Q_STATIC_ASSERT_X(N > 2, "QStaticByteArrayMatcher makes no sense for finding a single-char pattern"); + static_assert(N > 2, "QStaticByteArrayMatcher makes no sense for finding a single-char pattern"); public: explicit Q_DECL_RELAXED_CONSTEXPR QStaticByteArrayMatcher(const char (&patternToMatch)[N]) noexcept : QStaticByteArrayMatcherBase(patternToMatch, N - 1), m_pattern() diff --git a/src/corelib/text/qchar.cpp b/src/corelib/text/qchar.cpp index b7f78c3f5d..628d4ab370 100644 --- a/src/corelib/text/qchar.cpp +++ b/src/corelib/text/qchar.cpp @@ -2154,10 +2154,10 @@ static void canonicalOrderHelper(QString *str, QChar::UnicodeVersion version, in // sets lastStable to the position of the last stable code point static bool normalizationQuickCheckHelper(QString *str, QString::NormalizationForm mode, int from, int *lastStable) { - Q_STATIC_ASSERT(QString::NormalizationForm_D == 0); - Q_STATIC_ASSERT(QString::NormalizationForm_C == 1); - Q_STATIC_ASSERT(QString::NormalizationForm_KD == 2); - Q_STATIC_ASSERT(QString::NormalizationForm_KC == 3); + static_assert(QString::NormalizationForm_D == 0); + static_assert(QString::NormalizationForm_C == 1); + static_assert(QString::NormalizationForm_KD == 2); + static_assert(QString::NormalizationForm_KC == 3); enum { NFQC_YES = 0, NFQC_NO = 1, NFQC_MAYBE = 3 }; diff --git a/src/corelib/text/qchar.h b/src/corelib/text/qchar.h index 9fea104ec1..056101325e 100644 --- a/src/corelib/text/qchar.h +++ b/src/corelib/text/qchar.h @@ -106,7 +106,7 @@ public: Q_DECL_CONSTEXPR QChar(char16_t ch) noexcept : ucs(ch) {} // implicit #endif #if defined(Q_OS_WIN) - Q_STATIC_ASSERT(sizeof(wchar_t) == sizeof(char16_t)); + static_assert(sizeof(wchar_t) == sizeof(char16_t)); #endif #if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC) # if !defined(_WCHAR_T_DEFINED) || defined(_NATIVE_WCHAR_T_DEFINED) diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index 8217641aa3..6c6b371532 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -116,19 +116,19 @@ QLocale::Language QLocalePrivate::codeToLanguage(QStringView code) noexcept if (uc3 == 0) { // legacy codes if (uc1 == 'n' && uc2 == 'o') { // no -> nb - Q_STATIC_ASSERT(QLocale::Norwegian == QLocale::NorwegianBokmal); + static_assert(QLocale::Norwegian == QLocale::NorwegianBokmal); return QLocale::Norwegian; } if (uc1 == 't' && uc2 == 'l') { // tl -> fil - Q_STATIC_ASSERT(QLocale::Tagalog == QLocale::Filipino); + static_assert(QLocale::Tagalog == QLocale::Filipino); return QLocale::Tagalog; } if (uc1 == 's' && uc2 == 'h') { // sh -> sr[_Latn] - Q_STATIC_ASSERT(QLocale::SerboCroatian == QLocale::Serbian); + static_assert(QLocale::SerboCroatian == QLocale::Serbian); return QLocale::SerboCroatian; } if (uc1 == 'm' && uc2 == 'o') { // mo -> ro - Q_STATIC_ASSERT(QLocale::Moldavian == QLocale::Romanian); + static_assert(QLocale::Moldavian == QLocale::Romanian); return QLocale::Moldavian; } // Android uses the following deprecated codes diff --git a/src/corelib/text/qlocale_p.h b/src/corelib/text/qlocale_p.h index 751e254d53..b4064d747b 100644 --- a/src/corelib/text/qlocale_p.h +++ b/src/corelib/text/qlocale_p.h @@ -498,19 +498,19 @@ Q_DECL_CONSTEXPR inline bool ascii_isspace(uchar c) } #if defined(Q_COMPILER_CONSTEXPR) -Q_STATIC_ASSERT(ascii_isspace(' ')); -Q_STATIC_ASSERT(ascii_isspace('\t')); -Q_STATIC_ASSERT(ascii_isspace('\n')); -Q_STATIC_ASSERT(ascii_isspace('\v')); -Q_STATIC_ASSERT(ascii_isspace('\f')); -Q_STATIC_ASSERT(ascii_isspace('\r')); -Q_STATIC_ASSERT(!ascii_isspace('\0')); -Q_STATIC_ASSERT(!ascii_isspace('\a')); -Q_STATIC_ASSERT(!ascii_isspace('a')); -Q_STATIC_ASSERT(!ascii_isspace('\177')); -Q_STATIC_ASSERT(!ascii_isspace(uchar('\200'))); -Q_STATIC_ASSERT(!ascii_isspace(uchar('\xA0'))); -Q_STATIC_ASSERT(!ascii_isspace(uchar('\377'))); +static_assert(ascii_isspace(' ')); +static_assert(ascii_isspace('\t')); +static_assert(ascii_isspace('\n')); +static_assert(ascii_isspace('\v')); +static_assert(ascii_isspace('\f')); +static_assert(ascii_isspace('\r')); +static_assert(!ascii_isspace('\0')); +static_assert(!ascii_isspace('\a')); +static_assert(!ascii_isspace('a')); +static_assert(!ascii_isspace('\177')); +static_assert(!ascii_isspace(uchar('\200'))); +static_assert(!ascii_isspace(uchar('\xA0'))); +static_assert(!ascii_isspace(uchar('\377'))); #endif QT_END_NAMESPACE diff --git a/src/corelib/text/qlocale_tools.cpp b/src/corelib/text/qlocale_tools.cpp index 9adb6e4a23..a1838add72 100644 --- a/src/corelib/text/qlocale_tools.cpp +++ b/src/corelib/text/qlocale_tools.cpp @@ -433,7 +433,7 @@ QString qulltoa(qulonglong number, int base, const QStringView zero) // Length of MAX_ULLONG in base 2 is 64; and we may need a surrogate pair // per digit. We do not need a terminator. const unsigned maxlen = 128; - Q_STATIC_ASSERT(CHAR_BIT * sizeof(number) <= maxlen); + static_assert(CHAR_BIT * sizeof(number) <= maxlen); ushort buff[maxlen]; ushort *const end = buff + maxlen, *p = end; diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index 13a8377f4a..6e5415055c 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -909,7 +909,7 @@ static int ucstrncmp(const QChar *a, const QChar *b, size_t l) return 0; #else #if defined(__mips_dsp) - Q_STATIC_ASSERT(sizeof(uint) == sizeof(size_t)); + static_assert(sizeof(uint) == sizeof(size_t)); if (l >= 8) { return qt_ucstrncmp_mips_dsp_asm(reinterpret_cast<const char16_t*>(a), reinterpret_cast<const char16_t*>(b), diff --git a/src/corelib/text/qstringiterator_p.h b/src/corelib/text/qstringiterator_p.h index 2998d2a423..6f9e82389e 100644 --- a/src/corelib/text/qstringiterator_p.h +++ b/src/corelib/text/qstringiterator_p.h @@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE class QStringIterator { QString::const_iterator i, pos, e; - Q_STATIC_ASSERT((std::is_same<QString::const_iterator, const QChar *>::value)); + static_assert((std::is_same<QString::const_iterator, const QChar *>::value)); public: explicit QStringIterator(QStringView string, qsizetype idx = 0) : i(string.begin()), diff --git a/src/corelib/text/qstringliteral.h b/src/corelib/text/qstringliteral.h index 0968a9531a..a44787c7a4 100644 --- a/src/corelib/text/qstringliteral.h +++ b/src/corelib/text/qstringliteral.h @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE typedef char16_t qunicodechar; -Q_STATIC_ASSERT_X(sizeof(qunicodechar) == 2, +static_assert(sizeof(qunicodechar) == 2, "qunicodechar must typedef an integral type of size 2"); #define QT_UNICODE_LITERAL(str) u"" str diff --git a/src/corelib/text/qunicodetables_p.h b/src/corelib/text/qunicodetables_p.h index c8815e7919..e59aea25bd 100644 --- a/src/corelib/text/qunicodetables_p.h +++ b/src/corelib/text/qunicodetables_p.h @@ -101,7 +101,7 @@ struct Properties { Q_CORE_EXPORT const Properties * QT_FASTCALL properties(char32_t ucs4) noexcept; Q_CORE_EXPORT const Properties * QT_FASTCALL properties(char16_t ucs2) noexcept; -Q_STATIC_ASSERT(sizeof(Properties) == 20); +static_assert(sizeof(Properties) == 20); enum GraphemeBreakClass { GraphemeBreak_Any, diff --git a/src/corelib/thread/qatomic.cpp b/src/corelib/thread/qatomic.cpp index 5c3ad9412f..d302da72eb 100644 --- a/src/corelib/thread/qatomic.cpp +++ b/src/corelib/thread/qatomic.cpp @@ -1750,33 +1750,33 @@ QT_BEGIN_NAMESPACE // The following specializations must always be defined -Q_STATIC_ASSERT(sizeof(QAtomicInteger<unsigned>)); -Q_STATIC_ASSERT(sizeof(QAtomicInteger<long>)); -Q_STATIC_ASSERT(sizeof(QAtomicInteger<unsigned long>)); -Q_STATIC_ASSERT(sizeof(QAtomicInteger<quintptr>)); -Q_STATIC_ASSERT(sizeof(QAtomicInteger<qptrdiff>)); +static_assert(sizeof(QAtomicInteger<unsigned>)); +static_assert(sizeof(QAtomicInteger<long>)); +static_assert(sizeof(QAtomicInteger<unsigned long>)); +static_assert(sizeof(QAtomicInteger<quintptr>)); +static_assert(sizeof(QAtomicInteger<qptrdiff>)); #ifdef Q_COMPILER_UNICODE_STRINGS -Q_STATIC_ASSERT(sizeof(QAtomicInteger<char32_t>)); +static_assert(sizeof(QAtomicInteger<char32_t>)); #endif #ifdef Q_ATOMIC_INT16_IS_SUPPORTED -Q_STATIC_ASSERT(sizeof(QAtomicInteger<short>)); -Q_STATIC_ASSERT(sizeof(QAtomicInteger<unsigned short>)); +static_assert(sizeof(QAtomicInteger<short>)); +static_assert(sizeof(QAtomicInteger<unsigned short>)); # if WCHAR_MAX < 0x10000 -Q_STATIC_ASSERT(sizeof(QAtomicInteger<wchar_t>)); +static_assert(sizeof(QAtomicInteger<wchar_t>)); # endif # ifdef Q_COMPILER_UNICODE_STRINGS -Q_STATIC_ASSERT(sizeof(QAtomicInteger<char16_t>)); +static_assert(sizeof(QAtomicInteger<char16_t>)); # endif #endif #ifdef Q_ATOMIC_INT64_IS_SUPPORTED -Q_STATIC_ASSERT(sizeof(QAtomicInteger<qint64>)); -Q_STATIC_ASSERT(sizeof(QAtomicInteger<quint64>)); +static_assert(sizeof(QAtomicInteger<qint64>)); +static_assert(sizeof(QAtomicInteger<quint64>)); #endif #if WCHAR_MAX == INT_MAX -Q_STATIC_ASSERT(sizeof(QAtomicInteger<wchar_t>)); +static_assert(sizeof(QAtomicInteger<wchar_t>)); #endif QT_END_NAMESPACE diff --git a/src/corelib/thread/qatomic_msvc.h b/src/corelib/thread/qatomic_msvc.h index 67b5224cd7..54b12f5bb2 100644 --- a/src/corelib/thread/qatomic_msvc.h +++ b/src/corelib/thread/qatomic_msvc.h @@ -291,9 +291,9 @@ template <int N> struct QAtomicOpsBySize : QGenericAtomicOps<QAtomicOpsBySize<N> private: typedef typename QAtomicWindowsType<N>::Type Type; template <typename T> static inline Type *atomic(T *t) - { Q_STATIC_ASSERT(sizeof(T) == sizeof(Type)); return reinterpret_cast<Type *>(t); } + { static_assert(sizeof(T) == sizeof(Type)); return reinterpret_cast<Type *>(t); } template <typename T> static inline Type value(T t) - { Q_STATIC_ASSERT(sizeof(T) == sizeof(Type)); return Type(t); } + { static_assert(sizeof(T) == sizeof(Type)); return Type(t); } }; template <typename T> diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qbasicatomic.h index c9c95cf6ce..18da268270 100644 --- a/src/corelib/thread/qbasicatomic.h +++ b/src/corelib/thread/qbasicatomic.h @@ -93,8 +93,8 @@ public: typedef T Type; typedef QAtomicOps<T> Ops; // static check that this is a valid integer - Q_STATIC_ASSERT_X(QTypeInfo<T>::isIntegral, "template parameter is not an integral type"); - Q_STATIC_ASSERT_X(QAtomicOpsSupport<sizeof(T)>::IsSupported, "template parameter is an integral of a size not supported on this platform"); + static_assert(QTypeInfo<T>::isIntegral, "template parameter is not an integral type"); + static_assert(QAtomicOpsSupport<sizeof(T)>::IsSupported, "template parameter is an integral of a size not supported on this platform"); typename Ops::Type _q_value; diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h index 635dd94522..5a1e63ee0a 100644 --- a/src/corelib/thread/qthread.h +++ b/src/corelib/thread/qthread.h @@ -253,7 +253,7 @@ QThread *QThread::create(Function &&f) inline Qt::HANDLE QThread::currentThreadId() noexcept { Qt::HANDLE tid; // typedef to void* - Q_STATIC_ASSERT(sizeof(tid) == sizeof(void*)); + static_assert(sizeof(tid) == sizeof(void*)); // See https://akkadia.org/drepper/tls.pdf for x86 ABI #if defined(Q_PROCESSOR_X86_32) && defined(Q_OS_LINUX) // x86 32-bit always uses GS __asm__("movl %%gs:0, %0" : "=r" (tid) : : ); diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index 96c3f5c45c..35bfd35f1a 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -104,7 +104,7 @@ QT_BEGIN_NAMESPACE #if QT_CONFIG(thread) -Q_STATIC_ASSERT(sizeof(pthread_t) <= sizeof(Qt::HANDLE)); +static_assert(sizeof(pthread_t) <= sizeof(Qt::HANDLE)); enum { ThreadPriorityResetFlag = 0x80000000 }; diff --git a/src/corelib/thread/qwaitcondition_unix.cpp b/src/corelib/thread/qwaitcondition_unix.cpp index 88b058f410..a1c973562b 100644 --- a/src/corelib/thread/qwaitcondition_unix.cpp +++ b/src/corelib/thread/qwaitcondition_unix.cpp @@ -108,7 +108,7 @@ void qt_abstime_for_timeout(timespec *ts, QDeadlineTimer deadline) normalizedTimespec(*ts); #else // depends on QDeadlineTimer's internals!! - Q_STATIC_ASSERT(QDeadlineTimerNanosecondsInT2); + static_assert(QDeadlineTimerNanosecondsInT2); ts->tv_sec = deadline._q_data().first; ts->tv_nsec = deadline._q_data().second; #endif diff --git a/src/corelib/time/qtimezoneprivate.cpp b/src/corelib/time/qtimezoneprivate.cpp index facdf6661d..ebd08ea7db 100644 --- a/src/corelib/time/qtimezoneprivate.cpp +++ b/src/corelib/time/qtimezoneprivate.cpp @@ -259,7 +259,7 @@ QTimeZonePrivate::Data QTimeZonePrivate::dataForLocalTime(qint64 forLocalMSecs, brackets the correct time and at most one DST transition. */ const qint64 sixteenHoursInMSecs(16 * 3600 * 1000); - Q_STATIC_ASSERT(-sixteenHoursInMSecs / 1000 < QTimeZone::MinUtcOffsetSecs + static_assert(-sixteenHoursInMSecs / 1000 < QTimeZone::MinUtcOffsetSecs && sixteenHoursInMSecs / 1000 > QTimeZone::MaxUtcOffsetSecs); const qint64 recent = forLocalMSecs - sixteenHoursInMSecs; const qint64 imminent = forLocalMSecs + sixteenHoursInMSecs; diff --git a/src/corelib/tools/qarraydata.h b/src/corelib/tools/qarraydata.h index de52713348..2515c1ae5a 100644 --- a/src/corelib/tools/qarraydata.h +++ b/src/corelib/tools/qarraydata.h @@ -206,7 +206,7 @@ struct QTypedArrayData Q_REQUIRED_RESULT static QPair<QTypedArrayData *, T *> allocate(size_t capacity, ArrayOptions options = DefaultAllocationFlags) { - Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); + static_assert(sizeof(QTypedArrayData) == sizeof(QArrayData)); QArrayData *d; void *result = QArrayData::allocate(&d, sizeof(T), alignof(AlignmentDummy), capacity, options); #if (defined(Q_CC_GNU) && Q_CC_GNU >= 407) || QT_HAS_BUILTIN(__builtin_assume_aligned) @@ -219,7 +219,7 @@ struct QTypedArrayData reallocateUnaligned(QTypedArrayData *data, T *dataPointer, size_t capacity, ArrayOptions options = DefaultAllocationFlags) { - Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); + static_assert(sizeof(QTypedArrayData) == sizeof(QArrayData)); QPair<QArrayData *, void *> pair = QArrayData::reallocateUnaligned(data, dataPointer, sizeof(T), capacity, options); return qMakePair(static_cast<QTypedArrayData *>(pair.first), static_cast<T *>(pair.second)); @@ -227,14 +227,14 @@ struct QTypedArrayData static void deallocate(QArrayData *data) { - Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); + static_assert(sizeof(QTypedArrayData) == sizeof(QArrayData)); QArrayData::deallocate(data, sizeof(T), alignof(AlignmentDummy)); } static QArrayDataPointerRef<T> fromRawData(const T *data, size_t n, ArrayOptions options = DefaultRawFlags) { - Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); + static_assert(sizeof(QTypedArrayData) == sizeof(QArrayData)); QArrayDataPointerRef<T> result = { static_cast<QTypedArrayData *>(prepareRawData(options)), const_cast<T *>(data), uint(n) }; @@ -246,19 +246,19 @@ struct QTypedArrayData static QTypedArrayData *sharedNull() noexcept { - Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); + static_assert(sizeof(QTypedArrayData) == sizeof(QArrayData)); return static_cast<QTypedArrayData *>(QArrayData::sharedNull()); } static QTypedArrayData *sharedEmpty() { - Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); + static_assert(sizeof(QTypedArrayData) == sizeof(QArrayData)); return allocate(/* capacity */ 0); } static T *sharedNullData() { - Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); + static_assert(sizeof(QTypedArrayData) == sizeof(QArrayData)); return static_cast<T *>(QArrayData::sharedNullData()); } }; diff --git a/src/corelib/tools/qtaggedpointer.h b/src/corelib/tools/qtaggedpointer.h index 67209ffc08..819ebb2387 100644 --- a/src/corelib/tools/qtaggedpointer.h +++ b/src/corelib/tools/qtaggedpointer.h @@ -85,7 +85,7 @@ public: explicit QTaggedPointer(T *pointer, Tag tag = Tag()) noexcept : d(quintptr(pointer)) { - Q_STATIC_ASSERT(sizeof(Type*) == sizeof(QTaggedPointer)); + static_assert(sizeof(Type*) == sizeof(QTaggedPointer)); Q_ASSERT_X((quintptr(pointer) & tagMask()) == 0, "QTaggedPointer<T, Tag>", "Pointer is not aligned"); diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index cf5e2ee8c7..f90e455fe4 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -275,7 +275,7 @@ QVarLengthArray(InputIterator, InputIterator) -> QVarLengthArray<ValueType>; template <class T, qsizetype Prealloc> Q_INLINE_TEMPLATE QVarLengthArray<T, Prealloc>::QVarLengthArray(qsizetype asize) : s(asize) { - Q_STATIC_ASSERT_X(Prealloc > 0, "QVarLengthArray Prealloc must be greater than 0."); + static_assert(Prealloc > 0, "QVarLengthArray Prealloc must be greater than 0."); Q_ASSERT_X(s >= 0, "QVarLengthArray::QVarLengthArray()", "Size must be greater than or equal to 0."); if (s > Prealloc) { ptr = reinterpret_cast<T *>(malloc(s * sizeof(T))); diff --git a/src/corelib/tools/qversionnumber.h b/src/corelib/tools/qversionnumber.h index 184aeac692..d30dcd47a3 100644 --- a/src/corelib/tools/qversionnumber.h +++ b/src/corelib/tools/qversionnumber.h @@ -75,7 +75,7 @@ class QVersionNumber InlineSegmentStartIdx = !InlineSegmentMarker, // 0 for BE, 1 for LE InlineSegmentCount = sizeof(void*) - 1 }; - Q_STATIC_ASSERT(InlineSegmentCount >= 3); // at least major, minor, micro + static_assert(InlineSegmentCount >= 3); // at least major, minor, micro struct SegmentStorage { // Note: we alias the use of dummy and inline_segments in the use of the @@ -454,7 +454,7 @@ inline constexpr bool operator>=(QTypeRevision lhs, QTypeRevision rhs) return lhs == rhs || !(lhs < rhs); } -Q_STATIC_ASSERT(sizeof(QTypeRevision) == 2); +static_assert(sizeof(QTypeRevision) == 2); Q_DECLARE_TYPEINFO(QTypeRevision, Q_MOVABLE_TYPE); #ifndef QT_NO_DEBUG_STREAM diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp index 5757567a87..0334b1156d 100644 --- a/src/dbus/qdbusconnection.cpp +++ b/src/dbus/qdbusconnection.cpp @@ -78,7 +78,7 @@ Q_GLOBAL_STATIC(QDBusConnectionManager, _q_manager) QDBusConnectionPrivate *QDBusConnectionManager::busConnection(QDBusConnection::BusType type) { - Q_STATIC_ASSERT(int(QDBusConnection::SessionBus) + int(QDBusConnection::SystemBus) == 1); + static_assert(int(QDBusConnection::SessionBus) + int(QDBusConnection::SystemBus) == 1); Q_ASSERT(type == QDBusConnection::SessionBus || type == QDBusConnection::SystemBus); if (!qdbus_loadLibDBus()) diff --git a/src/dbus/qdbusmessage.cpp b/src/dbus/qdbusmessage.cpp index 10d2f07d4d..1625dcdfea 100644 --- a/src/dbus/qdbusmessage.cpp +++ b/src/dbus/qdbusmessage.cpp @@ -56,11 +56,11 @@ QT_BEGIN_NAMESPACE -Q_STATIC_ASSERT(QDBusMessage::InvalidMessage == DBUS_MESSAGE_TYPE_INVALID); -Q_STATIC_ASSERT(QDBusMessage::MethodCallMessage == DBUS_MESSAGE_TYPE_METHOD_CALL); -Q_STATIC_ASSERT(QDBusMessage::ReplyMessage == DBUS_MESSAGE_TYPE_METHOD_RETURN); -Q_STATIC_ASSERT(QDBusMessage::ErrorMessage == DBUS_MESSAGE_TYPE_ERROR); -Q_STATIC_ASSERT(QDBusMessage::SignalMessage == DBUS_MESSAGE_TYPE_SIGNAL); +static_assert(QDBusMessage::InvalidMessage == DBUS_MESSAGE_TYPE_INVALID); +static_assert(QDBusMessage::MethodCallMessage == DBUS_MESSAGE_TYPE_METHOD_CALL); +static_assert(QDBusMessage::ReplyMessage == DBUS_MESSAGE_TYPE_METHOD_RETURN); +static_assert(QDBusMessage::ErrorMessage == DBUS_MESSAGE_TYPE_ERROR); +static_assert(QDBusMessage::SignalMessage == DBUS_MESSAGE_TYPE_SIGNAL); static inline const char *data(const QByteArray &arr) { diff --git a/src/dbus/qdbusmetaobject.cpp b/src/dbus/qdbusmetaobject.cpp index 0846c3ed9b..dc52dacca5 100644 --- a/src/dbus/qdbusmetaobject.cpp +++ b/src/dbus/qdbusmetaobject.cpp @@ -416,7 +416,7 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj) - methods.count(); // ditto QDBusMetaObjectPrivate *header = reinterpret_cast<QDBusMetaObjectPrivate *>(idata.data()); - Q_STATIC_ASSERT_X(QMetaObjectPrivate::OutputRevision == 9, "QtDBus meta-object generator should generate the same version as moc"); + static_assert(QMetaObjectPrivate::OutputRevision == 9, "QtDBus meta-object generator should generate the same version as moc"); header->revision = QMetaObjectPrivate::OutputRevision; header->className = 0; header->classInfoCount = 0; diff --git a/src/dbus/qdbuspendingreply.h b/src/dbus/qdbuspendingreply.h index 1d7e60ad7f..9d25115a67 100644 --- a/src/dbus/qdbuspendingreply.h +++ b/src/dbus/qdbuspendingreply.h @@ -154,7 +154,7 @@ public: template<int Index> inline const typename Select<Index>::Type argumentAt() const { - Q_STATIC_ASSERT_X(Index >= 0 && Index < Count, "Index out of bounds"); + static_assert(Index >= 0 && Index < Count, "Index out of bounds"); typedef typename Select<Index>::Type ResultType; return qdbus_cast<ResultType>(argumentAt(Index), nullptr); } diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 27969cabb6..bcb4288631 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -5265,7 +5265,7 @@ static Q_CONSTEXPR QPixelFormat pixelformats[] = { /*INTERPRETATION*/ QPixelFormat::UnsignedByte, /*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian), }; -Q_STATIC_ASSERT(sizeof(pixelformats) / sizeof(*pixelformats) == QImage::NImageFormats); +static_assert(sizeof(pixelformats) / sizeof(*pixelformats) == QImage::NImageFormats); /*! Returns the QImage::Format as a QPixelFormat diff --git a/src/gui/image/qimagereaderwriterhelpers_p.h b/src/gui/image/qimagereaderwriterhelpers_p.h index 6fe418a8ab..ae1141b3ab 100644 --- a/src/gui/image/qimagereaderwriterhelpers_p.h +++ b/src/gui/image/qimagereaderwriterhelpers_p.h @@ -118,7 +118,7 @@ static const _qt_BuiltInFormatStruct _qt_BuiltInFormats[] = { {"xpm", "x-xpixmap"}, #endif }; -Q_STATIC_ASSERT(_qt_NumFormats == sizeof _qt_BuiltInFormats / sizeof *_qt_BuiltInFormats); +static_assert(_qt_NumFormats == sizeof _qt_BuiltInFormats / sizeof *_qt_BuiltInFormats); #ifndef QT_NO_IMAGEFORMATPLUGIN QSharedPointer<QFactoryLoader> pluginLoader(); diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index c54f10fd5e..92737db8d3 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -851,7 +851,7 @@ QKeySequence::QKeySequence(const QString &key, QKeySequence::SequenceFormat form assign(key, format); } -Q_STATIC_ASSERT_X(QKeySequencePrivate::MaxKeyCount == 4, "Change docs and ctor impl below"); +static_assert(QKeySequencePrivate::MaxKeyCount == 4, "Change docs and ctor impl below"); /*! Constructs a key sequence with up to 4 keys \a k1, \a k2, \a k3 and \a k4. @@ -915,7 +915,7 @@ void QKeySequence::setKey(int key, int index) d->key[index] = key; } -Q_STATIC_ASSERT_X(QKeySequencePrivate::MaxKeyCount == 4, "Change docs below"); +static_assert(QKeySequencePrivate::MaxKeyCount == 4, "Change docs below"); /*! Returns the number of keys in the key sequence. The maximum is 4. @@ -1609,7 +1609,7 @@ QString QKeySequence::listToString(const QList<QKeySequence> &list, SequenceForm */ QDataStream &operator<<(QDataStream &s, const QKeySequence &keysequence) { - Q_STATIC_ASSERT_X(QKeySequencePrivate::MaxKeyCount == 4, "Forgot to adapt QDataStream &operator<<(QDataStream &s, const QKeySequence &keysequence) to new QKeySequence::MaxKeyCount"); + static_assert(QKeySequencePrivate::MaxKeyCount == 4, "Forgot to adapt QDataStream &operator<<(QDataStream &s, const QKeySequence &keysequence) to new QKeySequence::MaxKeyCount"); const bool extended = s.version() >= 5 && keysequence.count() > 1; s << quint32(extended ? 4 : 1) << quint32(keysequence.d->key[0]); if (extended) { diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp index 92c43688cc..2c636dc553 100644 --- a/src/gui/kernel/qpalette.cpp +++ b/src/gui/kernel/qpalette.cpp @@ -61,7 +61,7 @@ static constexpr QPalette::ResolveMask bitPosition(QPalette::ColorGroup colorGro return colorRole + colorRoleOffset(colorGroup); } -Q_STATIC_ASSERT_X(bitPosition(QPalette::ColorGroup(QPalette::NColorGroups - 1), +static_assert(bitPosition(QPalette::ColorGroup(QPalette::NColorGroups - 1), QPalette::ColorRole(QPalette::NColorRoles - 1)) < sizeof(QPalette::ResolveMask) * CHAR_BIT, "The resolve mask type is not wide enough to fit the entire bit mask."); diff --git a/src/gui/kernel/qpixelformat.cpp b/src/gui/kernel/qpixelformat.cpp index 3100d13398..7a47dd472c 100644 --- a/src/gui/kernel/qpixelformat.cpp +++ b/src/gui/kernel/qpixelformat.cpp @@ -521,7 +521,7 @@ QT_BEGIN_NAMESPACE \internal */ -Q_STATIC_ASSERT(sizeof(QPixelFormat) == sizeof(quint64)); +static_assert(sizeof(QPixelFormat) == sizeof(quint64)); namespace QtPrivate { diff --git a/src/gui/kernel/qpixelformat.h b/src/gui/kernel/qpixelformat.h index a041a39fc1..a0bb300c12 100644 --- a/src/gui/kernel/qpixelformat.h +++ b/src/gui/kernel/qpixelformat.h @@ -92,8 +92,8 @@ class QPixelFormat TotalFieldWidthByOffsets = UnusedField + UnusedFieldWidth }; - Q_STATIC_ASSERT(uint(TotalFieldWidthByWidths) == uint(TotalFieldWidthByOffsets)); - Q_STATIC_ASSERT(uint(TotalFieldWidthByWidths) == 8 * sizeof(quint64)); + static_assert(uint(TotalFieldWidthByWidths) == uint(TotalFieldWidthByOffsets)); + static_assert(uint(TotalFieldWidthByWidths) == 8 * sizeof(quint64)); Q_DECL_CONSTEXPR inline uchar get(Field offset, FieldWidth width) const noexcept { return uchar((data >> uint(offset)) & ((Q_UINT64_C(1) << uint(width)) - Q_UINT64_C(1))); } @@ -228,7 +228,7 @@ private: friend Q_DECL_CONST_FUNCTION Q_DECL_CONSTEXPR inline bool operator!=(QPixelFormat fmt1, QPixelFormat fmt2) { return !(fmt1 == fmt2); } }; -Q_STATIC_ASSERT(sizeof(QPixelFormat) == sizeof(quint64)); +static_assert(sizeof(QPixelFormat) == sizeof(quint64)); Q_DECLARE_TYPEINFO(QPixelFormat, Q_PRIMITIVE_TYPE); diff --git a/src/gui/math3d/qvector2d.cpp b/src/gui/math3d/qvector2d.cpp index 5f651cf376..9cd4b5924a 100644 --- a/src/gui/math3d/qvector2d.cpp +++ b/src/gui/math3d/qvector2d.cpp @@ -49,8 +49,8 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_VECTOR2D -Q_STATIC_ASSERT_X(std::is_standard_layout<QVector2D>::value, "QVector2D is supposed to be standard layout"); -Q_STATIC_ASSERT_X(sizeof(QVector2D) == sizeof(float) * 2, "QVector2D is not supposed to have padding at the end"); +static_assert(std::is_standard_layout<QVector2D>::value, "QVector2D is supposed to be standard layout"); +static_assert(sizeof(QVector2D) == sizeof(float) * 2, "QVector2D is not supposed to have padding at the end"); // QVector2D used to be defined as class QVector2D { float x, y; };, // now instead it is defined as classs QVector2D { float v[2]; };. @@ -69,15 +69,15 @@ struct QVector2DNew float v[2]; }; -Q_STATIC_ASSERT_X(std::is_standard_layout<QVector2DOld>::value, "Binary compatibility break in QVector2D"); -Q_STATIC_ASSERT_X(std::is_standard_layout<QVector2DNew>::value, "Binary compatibility break in QVector2D"); +static_assert(std::is_standard_layout<QVector2DOld>::value, "Binary compatibility break in QVector2D"); +static_assert(std::is_standard_layout<QVector2DNew>::value, "Binary compatibility break in QVector2D"); -Q_STATIC_ASSERT_X(sizeof(QVector2DOld) == sizeof(QVector2DNew), "Binary compatibility break in QVector2D"); +static_assert(sizeof(QVector2DOld) == sizeof(QVector2DNew), "Binary compatibility break in QVector2D"); // requires a constexpr offsetof #if !defined(Q_CC_MSVC) || (_MSC_VER >= 1910) -Q_STATIC_ASSERT_X(offsetof(QVector2DOld, x) == offsetof(QVector2DNew, v) + sizeof(QVector2DNew::v[0]) * 0, "Binary compatibility break in QVector2D"); -Q_STATIC_ASSERT_X(offsetof(QVector2DOld, y) == offsetof(QVector2DNew, v) + sizeof(QVector2DNew::v[0]) * 1, "Binary compatibility break in QVector2D"); +static_assert(offsetof(QVector2DOld, x) == offsetof(QVector2DNew, v) + sizeof(QVector2DNew::v[0]) * 0, "Binary compatibility break in QVector2D"); +static_assert(offsetof(QVector2DOld, y) == offsetof(QVector2DNew, v) + sizeof(QVector2DNew::v[0]) * 1, "Binary compatibility break in QVector2D"); #endif } // anonymous namespace diff --git a/src/gui/math3d/qvector3d.cpp b/src/gui/math3d/qvector3d.cpp index 08c3de99d2..afe1e4789a 100644 --- a/src/gui/math3d/qvector3d.cpp +++ b/src/gui/math3d/qvector3d.cpp @@ -51,8 +51,8 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_VECTOR3D -Q_STATIC_ASSERT_X(std::is_standard_layout<QVector3D>::value, "QVector3D is supposed to be standard layout"); -Q_STATIC_ASSERT_X(sizeof(QVector3D) == sizeof(float) * 3, "QVector3D is not supposed to have padding at the end"); +static_assert(std::is_standard_layout<QVector3D>::value, "QVector3D is supposed to be standard layout"); +static_assert(sizeof(QVector3D) == sizeof(float) * 3, "QVector3D is not supposed to have padding at the end"); // QVector3D used to be defined as class QVector3D { float x, y, z; };, // now instead it is defined as classs QVector3D { float v[3]; };. @@ -71,16 +71,16 @@ struct QVector3DNew float v[3]; }; -Q_STATIC_ASSERT_X(std::is_standard_layout<QVector3DOld>::value, "Binary compatibility break in QVector3D"); -Q_STATIC_ASSERT_X(std::is_standard_layout<QVector3DNew>::value, "Binary compatibility break in QVector3D"); +static_assert(std::is_standard_layout<QVector3DOld>::value, "Binary compatibility break in QVector3D"); +static_assert(std::is_standard_layout<QVector3DNew>::value, "Binary compatibility break in QVector3D"); -Q_STATIC_ASSERT_X(sizeof(QVector3DOld) == sizeof(QVector3DNew), "Binary compatibility break in QVector3D"); +static_assert(sizeof(QVector3DOld) == sizeof(QVector3DNew), "Binary compatibility break in QVector3D"); // requires a constexpr offsetof #if !defined(Q_CC_MSVC) || (_MSC_VER >= 1910) -Q_STATIC_ASSERT_X(offsetof(QVector3DOld, x) == offsetof(QVector3DNew, v) + sizeof(QVector3DNew::v[0]) * 0, "Binary compatibility break in QVector3D"); -Q_STATIC_ASSERT_X(offsetof(QVector3DOld, y) == offsetof(QVector3DNew, v) + sizeof(QVector3DNew::v[0]) * 1, "Binary compatibility break in QVector3D"); -Q_STATIC_ASSERT_X(offsetof(QVector3DOld, z) == offsetof(QVector3DNew, v) + sizeof(QVector3DNew::v[0]) * 2, "Binary compatibility break in QVector3D"); +static_assert(offsetof(QVector3DOld, x) == offsetof(QVector3DNew, v) + sizeof(QVector3DNew::v[0]) * 0, "Binary compatibility break in QVector3D"); +static_assert(offsetof(QVector3DOld, y) == offsetof(QVector3DNew, v) + sizeof(QVector3DNew::v[0]) * 1, "Binary compatibility break in QVector3D"); +static_assert(offsetof(QVector3DOld, z) == offsetof(QVector3DNew, v) + sizeof(QVector3DNew::v[0]) * 2, "Binary compatibility break in QVector3D"); #endif diff --git a/src/gui/math3d/qvector4d.cpp b/src/gui/math3d/qvector4d.cpp index 070ea7454e..43cfb0c61c 100644 --- a/src/gui/math3d/qvector4d.cpp +++ b/src/gui/math3d/qvector4d.cpp @@ -49,8 +49,8 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_VECTOR4D -Q_STATIC_ASSERT_X(std::is_standard_layout<QVector4D>::value, "QVector4D is supposed to be standard layout"); -Q_STATIC_ASSERT_X(sizeof(QVector4D) == sizeof(float) * 4, "QVector4D is not supposed to have padding at the end"); +static_assert(std::is_standard_layout<QVector4D>::value, "QVector4D is supposed to be standard layout"); +static_assert(sizeof(QVector4D) == sizeof(float) * 4, "QVector4D is not supposed to have padding at the end"); // QVector4D used to be defined as class QVector4D { float x, y, z, w; };, // now instead it is defined as classs QVector4D { float v[4]; };. @@ -69,17 +69,17 @@ struct QVector4DNew float v[4]; }; -Q_STATIC_ASSERT_X(std::is_standard_layout<QVector4DOld>::value, "Binary compatibility break in QVector4D"); -Q_STATIC_ASSERT_X(std::is_standard_layout<QVector4DNew>::value, "Binary compatibility break in QVector4D"); +static_assert(std::is_standard_layout<QVector4DOld>::value, "Binary compatibility break in QVector4D"); +static_assert(std::is_standard_layout<QVector4DNew>::value, "Binary compatibility break in QVector4D"); -Q_STATIC_ASSERT_X(sizeof(QVector4DOld) == sizeof(QVector4DNew), "Binary compatibility break in QVector4D"); +static_assert(sizeof(QVector4DOld) == sizeof(QVector4DNew), "Binary compatibility break in QVector4D"); // requires a constexpr offsetof #if !defined(Q_CC_MSVC) || (_MSC_VER >= 1910) -Q_STATIC_ASSERT_X(offsetof(QVector4DOld, x) == offsetof(QVector4DNew, v) + sizeof(QVector4DNew::v[0]) * 0, "Binary compatibility break in QVector4D"); -Q_STATIC_ASSERT_X(offsetof(QVector4DOld, y) == offsetof(QVector4DNew, v) + sizeof(QVector4DNew::v[0]) * 1, "Binary compatibility break in QVector4D"); -Q_STATIC_ASSERT_X(offsetof(QVector4DOld, z) == offsetof(QVector4DNew, v) + sizeof(QVector4DNew::v[0]) * 2, "Binary compatibility break in QVector4D"); -Q_STATIC_ASSERT_X(offsetof(QVector4DOld, w) == offsetof(QVector4DNew, v) + sizeof(QVector4DNew::v[0]) * 3, "Binary compatibility break in QVector4D"); +static_assert(offsetof(QVector4DOld, x) == offsetof(QVector4DNew, v) + sizeof(QVector4DNew::v[0]) * 0, "Binary compatibility break in QVector4D"); +static_assert(offsetof(QVector4DOld, y) == offsetof(QVector4DNew, v) + sizeof(QVector4DNew::v[0]) * 1, "Binary compatibility break in QVector4D"); +static_assert(offsetof(QVector4DOld, z) == offsetof(QVector4DNew, v) + sizeof(QVector4DNew::v[0]) * 2, "Binary compatibility break in QVector4D"); +static_assert(offsetof(QVector4DOld, w) == offsetof(QVector4DNew, v) + sizeof(QVector4DNew::v[0]) * 3, "Binary compatibility break in QVector4D"); #endif diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 3b76635b7a..10aa78ba22 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -487,7 +487,7 @@ static const QRgba64 *QT_FASTCALL fetchUntransformedRGBA64PM(QRgba64 *, const Op template<TextureBlendType blendType> inline void fetchTransformed_pixelBounds(int max, int l1, int l2, int &v) { - Q_STATIC_ASSERT(blendType == BlendTransformed || blendType == BlendTransformedTiled); + static_assert(blendType == BlendTransformed || blendType == BlendTransformedTiled); if (blendType == BlendTransformedTiled) { if (v < 0 || v >= max) { v %= max; @@ -519,7 +519,7 @@ template<TextureBlendType blendType, QPixelLayout::BPP bpp, typename T> static void QT_FASTCALL fetchTransformed_fetcher(T *buffer, const QSpanData *data, int y, int x, int length) { - Q_STATIC_ASSERT(blendType == BlendTransformed || blendType == BlendTransformedTiled); + static_assert(blendType == BlendTransformed || blendType == BlendTransformedTiled); const QTextureData &image = data->texture; const qreal cx = x + qreal(0.5); @@ -683,7 +683,7 @@ template<TextureBlendType blendType, QPixelLayout::BPP bpp> static const uint *QT_FASTCALL fetchTransformed(uint *buffer, const Operator *, const QSpanData *data, int y, int x, int length) { - Q_STATIC_ASSERT(blendType == BlendTransformed || blendType == BlendTransformedTiled); + static_assert(blendType == BlendTransformed || blendType == BlendTransformedTiled); const QPixelLayout *layout = &qPixelLayouts[data->texture.format]; fetchTransformed_fetcher<blendType, bpp, uint>(buffer, data, y, x, length); layout->convertToARGB32PM(buffer, length, data->texture.colorTable); diff --git a/src/gui/painting/qpagesize.cpp b/src/gui/painting/qpagesize.cpp index 944e35c69c..324881ec6b 100644 --- a/src/gui/painting/qpagesize.cpp +++ b/src/gui/painting/qpagesize.cpp @@ -385,7 +385,7 @@ static const StandardPageSize qt_pageSizes[] = { }; static const int pageSizesCount = int(sizeof(qt_pageSizes) / sizeof(qt_pageSizes[0])); -Q_STATIC_ASSERT(pageSizesCount == QPageSize::LastPageSize + 1); +static_assert(pageSizesCount == QPageSize::LastPageSize + 1); // Return key name for PageSize static QString qt_keyForPageSizeId(QPageSize::PageSizeId id) diff --git a/src/gui/painting/qpixellayout.cpp b/src/gui/painting/qpixellayout.cpp index d0fb8f0bb4..42d14bb3b3 100644 --- a/src/gui/painting/qpixellayout.cpp +++ b/src/gui/painting/qpixellayout.cpp @@ -512,7 +512,7 @@ static void QT_FASTCALL rbSwap(uchar *dst, const uchar *src, int count) Q_CONSTEXPR uchar bWidth = blueWidth<Format>(); Q_CONSTEXPR uchar bShift = blueShift<Format>(); #ifdef Q_COMPILER_CONSTEXPR - Q_STATIC_ASSERT(rWidth == bWidth); + static_assert(rWidth == bWidth); #endif Q_CONSTEXPR uint redBlueMask = (1 << rWidth) - 1; Q_CONSTEXPR uint alphaGreenMask = (((1 << aWidth) - 1) << aShift) @@ -1426,7 +1426,7 @@ QPixelLayout qPixelLayouts[QImage::NImageFormats] = { pixelLayoutRGB<QImage::Format_BGR888>(), }; -Q_STATIC_ASSERT(sizeof(qPixelLayouts) / sizeof(*qPixelLayouts) == QImage::NImageFormats); +static_assert(sizeof(qPixelLayouts) / sizeof(*qPixelLayouts) == QImage::NImageFormats); static void QT_FASTCALL convertFromRgb64(uint *dest, const QRgba64 *src, int length) { diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index b5a9c5bb45..2ec2263321 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -390,7 +390,7 @@ static const int scriptForWritingSystem[] = { QChar::Script_Nko // Nko }; -Q_STATIC_ASSERT(sizeof(scriptForWritingSystem) / sizeof(scriptForWritingSystem[0]) == QFontDatabase::WritingSystemsCount); +static_assert(sizeof(scriptForWritingSystem) / sizeof(scriptForWritingSystem[0]) == QFontDatabase::WritingSystemsCount); Q_GUI_EXPORT int qt_script_for_writing_system(QFontDatabase::WritingSystem writingSystem) { @@ -1328,7 +1328,7 @@ QList<QFontDatabase::WritingSystem> QFontDatabase::writingSystems() const QT_PREPEND_NAMESPACE(load)(); quint64 writingSystemsFound = 0; - Q_STATIC_ASSERT(WritingSystemsCount < 64); + static_assert(WritingSystemsCount < 64); for (int i = 0; i < d->count; ++i) { QtFontFamily *family = d->families[i]; diff --git a/src/gui/text/qharfbuzzng.cpp b/src/gui/text/qharfbuzzng.cpp index a93f648bc9..ae24b57cbf 100644 --- a/src/gui/text/qharfbuzzng.cpp +++ b/src/gui/text/qharfbuzzng.cpp @@ -239,7 +239,7 @@ static const hb_script_t _qtscript_to_hbscript[] = { hb_script_t(HB_TAG('K', 'h', 'i', 't')), // Script_KhitanSmallScript hb_script_t(HB_TAG('Y', 'e', 'z', 'i')), // Script_Yezidi }; -Q_STATIC_ASSERT(QChar::ScriptCount == sizeof(_qtscript_to_hbscript) / sizeof(_qtscript_to_hbscript[0])); +static_assert(QChar::ScriptCount == sizeof(_qtscript_to_hbscript) / sizeof(_qtscript_to_hbscript[0])); hb_script_t hb_qt_script_to_script(QChar::Script script) { diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index ab4dc59594..dab69a8b89 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -189,7 +189,7 @@ struct QGlyphAttributes { uchar justification : 4; uchar reserved : 2; }; -Q_STATIC_ASSERT(sizeof(QGlyphAttributes) == 1); +static_assert(sizeof(QGlyphAttributes) == 1); Q_DECLARE_TYPEINFO(QGlyphAttributes, Q_PRIMITIVE_TYPE); struct QGlyphLayout diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp index bec636757e..6fed48e9b6 100644 --- a/src/gui/text/qtexthtmlparser.cpp +++ b/src/gui/text/qtexthtmlparser.cpp @@ -319,7 +319,7 @@ static const struct QTextHtmlEntity { const char name[9]; char16_t code; } entit { "zwj", 0x200d }, { "zwnj", 0x200c } }; -Q_STATIC_ASSERT(MAX_ENTITY == sizeof entities / sizeof *entities); +static_assert(MAX_ENTITY == sizeof entities / sizeof *entities); #if defined(Q_CC_MSVC) && _MSC_VER < 1600 bool operator<(const QTextHtmlEntity &entity1, const QTextHtmlEntity &entity2) diff --git a/src/gui/text/qtextmarkdownimporter.cpp b/src/gui/text/qtextmarkdownimporter.cpp index b5532696f4..caf7c097a3 100644 --- a/src/gui/text/qtextmarkdownimporter.cpp +++ b/src/gui/text/qtextmarkdownimporter.cpp @@ -60,21 +60,21 @@ static const QChar Space = QLatin1Char(' '); // TODO maybe eliminate the margins after all views recognize BlockQuoteLevel, CSS can format it, etc. static const int BlockQuoteIndent = 40; // pixels, same as in QTextHtmlParserNode::initializeProperties -Q_STATIC_ASSERT(int(QTextMarkdownImporter::FeatureCollapseWhitespace) == MD_FLAG_COLLAPSEWHITESPACE); -Q_STATIC_ASSERT(int(QTextMarkdownImporter::FeaturePermissiveATXHeaders) == MD_FLAG_PERMISSIVEATXHEADERS); -Q_STATIC_ASSERT(int(QTextMarkdownImporter::FeaturePermissiveURLAutoLinks) == MD_FLAG_PERMISSIVEURLAUTOLINKS); -Q_STATIC_ASSERT(int(QTextMarkdownImporter::FeaturePermissiveMailAutoLinks) == MD_FLAG_PERMISSIVEEMAILAUTOLINKS); -Q_STATIC_ASSERT(int(QTextMarkdownImporter::FeatureNoIndentedCodeBlocks) == MD_FLAG_NOINDENTEDCODEBLOCKS); -Q_STATIC_ASSERT(int(QTextMarkdownImporter::FeatureNoHTMLBlocks) == MD_FLAG_NOHTMLBLOCKS); -Q_STATIC_ASSERT(int(QTextMarkdownImporter::FeatureNoHTMLSpans) == MD_FLAG_NOHTMLSPANS); -Q_STATIC_ASSERT(int(QTextMarkdownImporter::FeatureTables) == MD_FLAG_TABLES); -Q_STATIC_ASSERT(int(QTextMarkdownImporter::FeatureStrikeThrough) == MD_FLAG_STRIKETHROUGH); -Q_STATIC_ASSERT(int(QTextMarkdownImporter::FeaturePermissiveWWWAutoLinks) == MD_FLAG_PERMISSIVEWWWAUTOLINKS); -Q_STATIC_ASSERT(int(QTextMarkdownImporter::FeaturePermissiveAutoLinks) == MD_FLAG_PERMISSIVEAUTOLINKS); -Q_STATIC_ASSERT(int(QTextMarkdownImporter::FeatureTasklists) == MD_FLAG_TASKLISTS); -Q_STATIC_ASSERT(int(QTextMarkdownImporter::FeatureNoHTML) == MD_FLAG_NOHTML); -Q_STATIC_ASSERT(int(QTextMarkdownImporter::DialectCommonMark) == MD_DIALECT_COMMONMARK); -Q_STATIC_ASSERT(int(QTextMarkdownImporter::DialectGitHub) == MD_DIALECT_GITHUB); +static_assert(int(QTextMarkdownImporter::FeatureCollapseWhitespace) == MD_FLAG_COLLAPSEWHITESPACE); +static_assert(int(QTextMarkdownImporter::FeaturePermissiveATXHeaders) == MD_FLAG_PERMISSIVEATXHEADERS); +static_assert(int(QTextMarkdownImporter::FeaturePermissiveURLAutoLinks) == MD_FLAG_PERMISSIVEURLAUTOLINKS); +static_assert(int(QTextMarkdownImporter::FeaturePermissiveMailAutoLinks) == MD_FLAG_PERMISSIVEEMAILAUTOLINKS); +static_assert(int(QTextMarkdownImporter::FeatureNoIndentedCodeBlocks) == MD_FLAG_NOINDENTEDCODEBLOCKS); +static_assert(int(QTextMarkdownImporter::FeatureNoHTMLBlocks) == MD_FLAG_NOHTMLBLOCKS); +static_assert(int(QTextMarkdownImporter::FeatureNoHTMLSpans) == MD_FLAG_NOHTMLSPANS); +static_assert(int(QTextMarkdownImporter::FeatureTables) == MD_FLAG_TABLES); +static_assert(int(QTextMarkdownImporter::FeatureStrikeThrough) == MD_FLAG_STRIKETHROUGH); +static_assert(int(QTextMarkdownImporter::FeaturePermissiveWWWAutoLinks) == MD_FLAG_PERMISSIVEWWWAUTOLINKS); +static_assert(int(QTextMarkdownImporter::FeaturePermissiveAutoLinks) == MD_FLAG_PERMISSIVEAUTOLINKS); +static_assert(int(QTextMarkdownImporter::FeatureTasklists) == MD_FLAG_TASKLISTS); +static_assert(int(QTextMarkdownImporter::FeatureNoHTML) == MD_FLAG_NOHTML); +static_assert(int(QTextMarkdownImporter::DialectCommonMark) == MD_DIALECT_COMMONMARK); +static_assert(int(QTextMarkdownImporter::DialectGitHub) == MD_DIALECT_GITHUB); // -------------------------------------------------------- // MD4C callback function wrappers diff --git a/src/gui/text/unix/qfontconfigdatabase.cpp b/src/gui/text/unix/qfontconfigdatabase.cpp index c6b0485ec5..624fd1f9a5 100644 --- a/src/gui/text/unix/qfontconfigdatabase.cpp +++ b/src/gui/text/unix/qfontconfigdatabase.cpp @@ -279,7 +279,7 @@ static const char specialLanguages[][6] = { "", // KhitanSmallScript "" // Yezidi }; -Q_STATIC_ASSERT(sizeof specialLanguages / sizeof *specialLanguages == QChar::ScriptCount); +static_assert(sizeof specialLanguages / sizeof *specialLanguages == QChar::ScriptCount); // this could become a list of all languages used for each writing // system, instead of using the single most common language. @@ -319,7 +319,7 @@ static const char languageForWritingSystem[][6] = { "non", // Runic "man" // N'Ko }; -Q_STATIC_ASSERT(sizeof languageForWritingSystem / sizeof *languageForWritingSystem == QFontDatabase::WritingSystemsCount); +static_assert(sizeof languageForWritingSystem / sizeof *languageForWritingSystem == QFontDatabase::WritingSystemsCount); #if FC_VERSION >= 20297 // Newer FontConfig let's us sort out fonts that report certain scripts support, @@ -361,7 +361,7 @@ static const char capabilityForWritingSystem[][5] = { "", // Runic "nko " // N'Ko }; -Q_STATIC_ASSERT(sizeof(capabilityForWritingSystem) / sizeof(*capabilityForWritingSystem) == QFontDatabase::WritingSystemsCount); +static_assert(sizeof(capabilityForWritingSystem) / sizeof(*capabilityForWritingSystem) == QFontDatabase::WritingSystemsCount); #endif static const char *getFcFamilyForStyleHint(const QFont::StyleHint style) diff --git a/src/gui/util/qgridlayoutengine_p.h b/src/gui/util/qgridlayoutengine_p.h index 33bd4ad917..19ed07d30d 100644 --- a/src/gui/util/qgridlayoutengine_p.h +++ b/src/gui/util/qgridlayoutengine_p.h @@ -105,8 +105,8 @@ template <typename T> class QHVContainer { T m_data[2]; - Q_STATIC_ASSERT(Qt::Horizontal == 0x1); - Q_STATIC_ASSERT(Qt::Vertical == 0x2); + static_assert(Qt::Horizontal == 0x1); + static_assert(Qt::Vertical == 0x2); static constexpr int map(Qt::Orientation o) noexcept { return int(o) - 1; diff --git a/src/network/kernel/qhostinfo.h b/src/network/kernel/qhostinfo.h index 047ab3bbd9..ca2eaae2bd 100644 --- a/src/network/kernel/qhostinfo.h +++ b/src/network/kernel/qhostinfo.h @@ -106,12 +106,12 @@ public: typedef QtPrivate::FunctionPointer<Func> SlotType; typedef QtPrivate::FunctionPointer<void (*)(QHostInfo)> SignalType; - Q_STATIC_ASSERT_X(int(SignalType::ArgumentCount) >= int(SlotType::ArgumentCount), + static_assert(int(SignalType::ArgumentCount) >= int(SlotType::ArgumentCount), "The slot requires more arguments than the signal provides."); - Q_STATIC_ASSERT_X((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, + static_assert((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value), "Signal and slot arguments are not compatible."); - Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible<typename SlotType::ReturnType, + static_assert((QtPrivate::AreArgumentsCompatible<typename SlotType::ReturnType, typename SignalType::ReturnType>::value), "Return type of the slot is not compatible " "with the return type of the signal."); @@ -137,7 +137,7 @@ public: { typedef QtPrivate::FunctionPointer<Func1> SlotType; - Q_STATIC_ASSERT_X(int(SlotType::ArgumentCount) <= 1, + static_assert(int(SlotType::ArgumentCount) <= 1, "The slot must not require more than one argument"); auto slotObj = new QtPrivate::QFunctorSlotObject<Func1, 1, diff --git a/src/network/kernel/qnetworkinterface_linux.cpp b/src/network/kernel/qnetworkinterface_linux.cpp index 25aba5836e..a21ccf40c4 100644 --- a/src/network/kernel/qnetworkinterface_linux.cpp +++ b/src/network/kernel/qnetworkinterface_linux.cpp @@ -151,8 +151,8 @@ template <typename Lambda> struct ProcessNetlinkRequest static int expectedTypeForRequest(int rtype) { - Q_STATIC_ASSERT(RTM_NEWADDR == RTM_GETADDR - 2); - Q_STATIC_ASSERT(RTM_NEWLINK == RTM_GETLINK - 2); + static_assert(RTM_NEWADDR == RTM_GETADDR - 2); + static_assert(RTM_NEWLINK == RTM_GETLINK - 2); Q_ASSERT(rtype == RTM_GETADDR || rtype == RTM_GETLINK); return rtype - 2; } diff --git a/src/network/kernel/qnetworkinterface_unix.cpp b/src/network/kernel/qnetworkinterface_unix.cpp index a6b0886bc6..977a0dcde9 100644 --- a/src/network/kernel/qnetworkinterface_unix.cpp +++ b/src/network/kernel/qnetworkinterface_unix.cpp @@ -487,7 +487,7 @@ static QList<QNetworkInterfacePrivate *> createInterfaces(ifaddrs *rawList) memset(&mediareq, 0, sizeof(mediareq)); // ensure both structs start with the name field, of size IFNAMESIZ - Q_STATIC_ASSERT(sizeof(mediareq.ifm_name) == sizeof(req.ifr_name)); + static_assert(sizeof(mediareq.ifm_name) == sizeof(req.ifr_name)); Q_ASSERT(&mediareq.ifm_name == &req.ifr_name); // on NetBSD we use AF_LINK and sockaddr_dl diff --git a/src/network/kernel/qtldurl.cpp b/src/network/kernel/qtldurl.cpp index 1723acfc5b..2823a3157d 100644 --- a/src/network/kernel/qtldurl.cpp +++ b/src/network/kernel/qtldurl.cpp @@ -84,7 +84,7 @@ static bool containsTLDEntry(QStringView entry, TLDMatchType match) Q_ASSERT(tldGroupOffset <= tldIndices[index + 1]); // The last extra entry in tldIndices // should be equal to the total of all chunks' lengths. - Q_STATIC_ASSERT(tldIndices[tldCount] == tldChunks[tldChunkCount - 1]); + static_assert(tldIndices[tldCount] == tldChunks[tldChunkCount - 1]); // Find which chunk contains the tldGroupOffset while (tldGroupOffset >= tldChunks[chunk]) { diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index e5b9fbbdb2..a39b345d30 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -1044,7 +1044,7 @@ qint64 QNativeSocketEnginePrivate::nativeReceiveDatagram(char *data, qint64 maxS if (cmsgptr->cmsg_len == CMSG_LEN(sizeof(int)) && ((cmsgptr->cmsg_level == IPPROTO_IPV6 && cmsgptr->cmsg_type == IPV6_HOPLIMIT) || (cmsgptr->cmsg_level == IPPROTO_IP && cmsgptr->cmsg_type == IP_TTL))) { - Q_STATIC_ASSERT(sizeof(header->hopLimit) == sizeof(int)); + static_assert(sizeof(header->hopLimit) == sizeof(int)); memcpy(&header->hopLimit, CMSG_DATA(cmsgptr), sizeof(header->hopLimit)); } diff --git a/src/network/ssl/qsslsocket_schannel.cpp b/src/network/ssl/qsslsocket_schannel.cpp index c355abad73..c87d599aff 100644 --- a/src/network/ssl/qsslsocket_schannel.cpp +++ b/src/network/ssl/qsslsocket_schannel.cpp @@ -1617,7 +1617,7 @@ QList<QSslCipher> QSslSocketBackendPrivate::defaultCiphers() const QSsl::SslProtocol protocols[] = { QSsl::TlsV1_0, QSsl::TlsV1_1, QSsl::TlsV1_2, QSsl::TlsV1_3 }; const int size = ARRAYSIZE(protocols); - Q_STATIC_ASSERT(size == ARRAYSIZE(protocolStrings)); + static_assert(size == ARRAYSIZE(protocolStrings)); ciphers.reserve(size); for (int i = 0; i < size; ++i) { QSslCipher cipher; diff --git a/src/plugins/generic/tuiotouch/qoscmessage.cpp b/src/plugins/generic/tuiotouch/qoscmessage.cpp index 3c30caa923..dba0decf51 100644 --- a/src/plugins/generic/tuiotouch/qoscmessage.cpp +++ b/src/plugins/generic/tuiotouch/qoscmessage.cpp @@ -104,7 +104,7 @@ QOscMessage::QOscMessage(const QByteArray &data) if (parsedBytes > (quint32)data.size() || data.size() - parsedBytes < sizeof(quint32)) return; - Q_STATIC_ASSERT(sizeof(float) == sizeof(quint32)); + static_assert(sizeof(float) == sizeof(quint32)); union { quint32 u; float f; diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index 02e397ca9f..bca23cb33e 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -540,7 +540,7 @@ static const Qt::KeyboardModifiers ModsTbl[] = { Qt::NoModifier, // Fall-back to raw Key_* }; static const size_t NumMods = sizeof ModsTbl / sizeof *ModsTbl; -Q_STATIC_ASSERT((NumMods == KeyboardLayoutItem::NumQtKeys)); +static_assert((NumMods == KeyboardLayoutItem::NumQtKeys)); #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug d, const KeyboardLayoutItem &k) diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index 1f4c851742..c55a9c668c 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -840,7 +840,7 @@ class FakePointer { public: - Q_STATIC_ASSERT_X(sizeof(T) <= sizeof(void *), "FakePointers can only go that far."); + static_assert(sizeof(T) <= sizeof(void *), "FakePointers can only go that far."); static FakePointer *create(T thing) { diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 01d4a06c61..b28eeb7cb5 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -3238,7 +3238,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai static const CFStringRef keys[] = { kCTFontAttributeName, kCTForegroundColorAttributeName }; static const int numValues = sizeof(keys) / sizeof(keys[0]); const CFTypeRef values[] = { (CFTypeRef)checkmarkFont, (CFTypeRef)checkmarkColor }; - Q_STATIC_ASSERT((sizeof(values) / sizeof(values[0])) == numValues); + static_assert((sizeof(values) / sizeof(values[0])) == numValues); QCFType<CFDictionaryRef> attributes = CFDictionaryCreate(kCFAllocatorDefault, (const void **)keys, (const void **)values, numValues, NULL, NULL); // U+2713: CHECK MARK diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h index 0498681670..e5f2a8bbbf 100644 --- a/src/testlib/qtestcase.h +++ b/src/testlib/qtestcase.h @@ -124,7 +124,7 @@ do {\ * in their code. */ # define QVERIFY_EXCEPTION_THROWN(expression, exceptiontype) \ - Q_STATIC_ASSERT_X(false, "Support of exceptions is disabled") + static_assert(false, "Support of exceptions is disabled") #endif // !QT_NO_EXCEPTIONS @@ -342,7 +342,7 @@ namespace QTest inline void addColumn(const char *name, T * = nullptr) { using QIsSameTConstChar = std::is_same<T, const char*>; - Q_STATIC_ASSERT_X(!QIsSameTConstChar::value, "const char* is not allowed as a test data format."); + static_assert(!QIsSameTConstChar::value, "const char* is not allowed as a test data format."); addColumnInternal(qMetaTypeId<T>(), name); } Q_TESTLIB_EXPORT QTestData &newRow(const char *dataTag); diff --git a/src/widgets/dialogs/qerrormessage.cpp b/src/widgets/dialogs/qerrormessage.cpp index 790d09414b..ba57faa898 100644 --- a/src/widgets/dialogs/qerrormessage.cpp +++ b/src/widgets/dialogs/qerrormessage.cpp @@ -163,11 +163,11 @@ static bool metFatal = false; static QString msgType2i18nString(QtMsgType t) { - Q_STATIC_ASSERT(QtDebugMsg == 0); - Q_STATIC_ASSERT(QtWarningMsg == 1); - Q_STATIC_ASSERT(QtCriticalMsg == 2); - Q_STATIC_ASSERT(QtFatalMsg == 3); - Q_STATIC_ASSERT(QtInfoMsg == 4); + static_assert(QtDebugMsg == 0); + static_assert(QtWarningMsg == 1); + static_assert(QtCriticalMsg == 2); + static_assert(QtFatalMsg == 3); + static_assert(QtInfoMsg == 4); // adjust the array below if any of the above fire... diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index ff2f202bb4..97d61a9a15 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -163,7 +163,7 @@ static const char *changed_signal(int which) case 5: return SIGNAL(currentRowChanged(int)); case 6: return SIGNAL(valueChanged(int)); }; - Q_STATIC_ASSERT(7 == NFallbackDefaultProperties); + static_assert(7 == NFallbackDefaultProperties); Q_UNREACHABLE(); return nullptr; } diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index c7303dde66..b7396f2b6b 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -10869,7 +10869,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) return; Q_D(QWidget); - Q_STATIC_ASSERT_X(sizeof(d->high_attributes)*8 >= (Qt::WA_AttributeCount - sizeof(uint)*8), + static_assert(sizeof(d->high_attributes)*8 >= (Qt::WA_AttributeCount - sizeof(uint)*8), "QWidget::setAttribute(WidgetAttribute, bool): " "QWidgetPrivate::high_attributes[] too small to contain all attributes in WidgetAttribute"); #ifdef Q_OS_WIN diff --git a/src/widgets/widgets/qkeysequenceedit.cpp b/src/widgets/widgets/qkeysequenceedit.cpp index b63b0b4d72..a38250c195 100644 --- a/src/widgets/widgets/qkeysequenceedit.cpp +++ b/src/widgets/widgets/qkeysequenceedit.cpp @@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE -Q_STATIC_ASSERT(QKeySequencePrivate::MaxKeyCount == 4); // assumed by the code around here +static_assert(QKeySequencePrivate::MaxKeyCount == 4); // assumed by the code around here void QKeySequenceEditPrivate::init() { |