From 3e1d03b1eaf6a5e842bed4ae4f9bb8cca05e5b31 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Thu, 11 Jun 2020 11:35:19 +0200 Subject: Port Q_STATIC_ASSERT(_X) to static_assert There is no reason for keep using our macro now that we have C++17. The macro itself is left in for the moment being, as well as its detection logic, because it's needed for C code (not everything supports C11 yet). A few more cleanups will arrive in the next few patches. Note that this is a mere search/replace; some places were using double braces to work around the presence of commas in a macro, no attempt has been done to fix those. tst_qglobal had just some minor changes to keep testing the macro. Change-Id: I1c1c397d9f3e63db3338842bf350c9069ea57639 Reviewed-by: Lars Knoll --- src/corelib/global/qflags.h | 4 ++-- src/corelib/global/qglobal.cpp | 28 +++++++++++------------ src/corelib/global/qhooks.cpp | 2 +- src/corelib/global/qnumeric.cpp | 4 ++-- src/corelib/global/qnumeric_p.h | 8 +++---- src/corelib/global/qrandom.cpp | 6 ++--- src/corelib/global/qrandom.h | 2 +- src/corelib/io/qfiledevice.cpp | 8 +++---- src/corelib/io/qfileinfo.cpp | 8 +++---- src/corelib/io/qfsfileengine.cpp | 2 +- src/corelib/io/qstandardpaths_win.cpp | 4 ++-- src/corelib/kernel/qdeadlinetimer.cpp | 4 ++-- src/corelib/kernel/qelapsedtimer_mac.cpp | 2 +- src/corelib/kernel/qelapsedtimer_unix.cpp | 2 +- src/corelib/kernel/qelapsedtimer_win.cpp | 2 +- src/corelib/kernel/qmetaobject.h | 4 ++-- src/corelib/kernel/qmetaobjectbuilder.cpp | 2 +- src/corelib/kernel/qmetatype.cpp | 8 +++---- src/corelib/kernel/qmetatype.h | 14 ++++++------ src/corelib/kernel/qmetatype_p.h | 2 +- src/corelib/kernel/qobject.h | 30 ++++++++++++------------- src/corelib/kernel/qobject_p.h | 12 +++++----- src/corelib/kernel/qobjectdefs_impl.h | 4 ++-- src/corelib/kernel/qpointer.h | 2 +- src/corelib/kernel/qtimer.h | 4 ++-- src/corelib/kernel/qvariant.cpp | 2 +- src/corelib/kernel/qvariant_p.h | 22 +++++++++--------- src/corelib/mimetypes/qmimeprovider.cpp | 6 ++--- src/corelib/plugin/qplugin.h | 4 ++-- src/corelib/serialization/qbinaryjson.cpp | 2 +- src/corelib/serialization/qcborcommon.cpp | 30 ++++++++++++------------- src/corelib/serialization/qcborstreamreader.cpp | 26 ++++++++++----------- src/corelib/serialization/qcborstreamwriter.cpp | 2 +- src/corelib/serialization/qcborvalue.h | 2 +- src/corelib/serialization/qcborvalue_p.h | 6 ++--- src/corelib/serialization/qjsonvalue.h | 4 ++-- src/corelib/text/qbytearraymatcher.h | 2 +- src/corelib/text/qchar.cpp | 8 +++---- src/corelib/text/qchar.h | 2 +- src/corelib/text/qlocale.cpp | 8 +++---- src/corelib/text/qlocale_p.h | 26 ++++++++++----------- src/corelib/text/qlocale_tools.cpp | 2 +- src/corelib/text/qstring.cpp | 2 +- src/corelib/text/qstringiterator_p.h | 2 +- src/corelib/text/qstringliteral.h | 2 +- src/corelib/text/qunicodetables_p.h | 2 +- src/corelib/thread/qatomic.cpp | 26 ++++++++++----------- src/corelib/thread/qatomic_msvc.h | 4 ++-- src/corelib/thread/qbasicatomic.h | 4 ++-- src/corelib/thread/qthread.h | 2 +- src/corelib/thread/qthread_unix.cpp | 2 +- src/corelib/thread/qwaitcondition_unix.cpp | 2 +- src/corelib/time/qtimezoneprivate.cpp | 2 +- src/corelib/tools/qarraydata.h | 14 ++++++------ src/corelib/tools/qtaggedpointer.h | 2 +- src/corelib/tools/qvarlengtharray.h | 2 +- src/corelib/tools/qversionnumber.h | 4 ++-- 57 files changed, 197 insertions(+), 197 deletions(-) (limited to 'src/corelib') 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 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::value), "QFlags is only usable on enumeration types."); + static_assert((std::is_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::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::radix == 2, "Qt assumes binary integers"); -Q_STATIC_ASSERT_X((std::numeric_limits::max() + std::numeric_limits::lowest()) == -1, +static_assert((std::numeric_limits::max() + std::numeric_limits::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::max() + std::numeric_limits::l // On GHC the compiler reports std::numeric_limits::is_iec559 as false. // This is all right according to our needs. #if !defined(Q_CC_GHS) -Q_STATIC_ASSERT_X(std::numeric_limits::is_iec559, +static_assert(std::numeric_limits::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::has_infinity && +static_assert(std::numeric_limits::has_infinity && std::numeric_limits::has_quiet_NaN && std::numeric_limits::has_signaling_NaN, "Qt assumes IEEE 754 floating point"); @@ -167,13 +167,13 @@ Q_STATIC_ASSERT_X(std::numeric_limits::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::radix == 2, +static_assert(std::numeric_limits::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::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::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::has_infinity, + static_assert(std::numeric_limits::has_infinity, "platform has no definition for infinity for type double"); return std::numeric_limits::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::has_signaling_NaN, + static_assert(std::numeric_limits::has_signaling_NaN, "platform has no definition for signaling NaN for type double"); return std::numeric_limits::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::has_quiet_NaN, + static_assert(std::numeric_limits::has_quiet_NaN, "platform has no definition for quiet NaN for type double"); return std::numeric_limits::quiet_NaN(); } @@ -204,7 +204,7 @@ namespace { */ template static inline bool convertDoubleTo(double v, T *value, bool allow_precision_upgrade = true) { - Q_STATIC_ASSERT(std::numeric_limits::is_integer); + static_assert(std::numeric_limits::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 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(begin), reinterpret_cast(end)); @@ -377,14 +377,14 @@ struct QRandomGenerator::SystemAndGlobalGenerators constexpr SystemAndGlobalGenerators g = {}; Q_UNUSED(g); - Q_STATIC_ASSERT(std::is_literal_type::value); + static_assert(std::is_literal_type::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(buffer); } #endif - Q_STATIC_ASSERT_X(std::is_trivially_destructible::value, + static_assert(std::is_trivially_destructible::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 SignalType; - Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro::Value, + static_assert(QtPrivate::HasQ_OBJECT_Macro::Value, "No Q_OBJECT in the class with the signal"); return fromSignalImpl(&SignalType::Object::staticMetaObject, reinterpret_cast(&signal)); @@ -241,7 +241,7 @@ public: inline bool isValid() const { return name() != nullptr; } template static QMetaEnum fromType() { - Q_STATIC_ASSERT_X(QtPrivate::IsQEnumHelper::Value, + static_assert(QtPrivate::IsQEnumHelper::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 static decltype(std::declval().operator>>(std::declval()), Yes()) load(int); template static decltype(operator>>(std::declval(), std::declval()), Yes()) load(int); @@ -1310,9 +1310,9 @@ public: }; // Quick sanity checks -Q_STATIC_ASSERT(HasStreamOperator::Value); -Q_STATIC_ASSERT(!HasStreamOperator::Value); -Q_STATIC_ASSERT(HasStreamOperator::Value); +static_assert(HasStreamOperator::Value); +static_assert(!HasStreamOperator::Value); +static_assert(HasStreamOperator::Value); template::IsAccepted && HasStreamOperator::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 static bool registerComparators() { - Q_STATIC_ASSERT_X((!QMetaTypeId2::IsBuiltIn), + static_assert((!QMetaTypeId2::IsBuiltIn), "QMetaType::registerComparators: The type must be a custom type."); const int typeId = qMetaTypeId(); @@ -590,7 +590,7 @@ public: template static bool registerEqualsComparator() { - Q_STATIC_ASSERT_X((!QMetaTypeId2::IsBuiltIn), + static_assert((!QMetaTypeId2::IsBuiltIn), "QMetaType::registerEqualsComparator: The type must be a custom type."); const int typeId = qMetaTypeId(); static const QtPrivate::BuiltInEqualsComparatorFunction f; @@ -609,7 +609,7 @@ public: template static bool registerDebugStreamOperator() { - Q_STATIC_ASSERT_X((!QMetaTypeId2::IsBuiltIn), + static_assert((!QMetaTypeId2::IsBuiltIn), "QMetaType::registerDebugStreamOperator: The type must be a custom type."); const int typeId = qMetaTypeId(); @@ -643,7 +643,7 @@ public: template static bool registerConverter(To(From::*function)() const) { - Q_STATIC_ASSERT_X((!QMetaTypeId2::IsBuiltIn || !QMetaTypeId2::IsBuiltIn), + static_assert((!QMetaTypeId2::IsBuiltIn || !QMetaTypeId2::IsBuiltIn), "QMetaType::registerConverter: At least one of the types must be a custom type."); const int fromTypeId = qMetaTypeId(); @@ -656,7 +656,7 @@ public: template static bool registerConverter(To(From::*function)(bool*) const) { - Q_STATIC_ASSERT_X((!QMetaTypeId2::IsBuiltIn || !QMetaTypeId2::IsBuiltIn), + static_assert((!QMetaTypeId2::IsBuiltIn || !QMetaTypeId2::IsBuiltIn), "QMetaType::registerConverter: At least one of the types must be a custom type."); const int fromTypeId = qMetaTypeId(); @@ -669,7 +669,7 @@ public: template static bool registerConverter(UnaryFunction function) { - Q_STATIC_ASSERT_X((!QMetaTypeId2::IsBuiltIn || !QMetaTypeId2::IsBuiltIn), + static_assert((!QMetaTypeId2::IsBuiltIn || !QMetaTypeId2::IsBuiltIn), "QMetaType::registerConverter: At least one of the types must be a custom type."); const int fromTypeId = qMetaTypeId(); @@ -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(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 SignalType; typedef QtPrivate::FunctionPointer SlotType; - Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro::Value, + static_assert(QtPrivate::HasQ_OBJECT_Macro::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::value), + static_assert((QtPrivate::CheckCompatibleArguments::value), "Signal and slot arguments are not compatible."); - Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible::value), + static_assert((QtPrivate::AreArgumentsCompatible::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 SignalType; typedef QtPrivate::FunctionPointer SlotType; - Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro::Value, + static_assert(QtPrivate::HasQ_OBJECT_Macro::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::value), + static_assert((QtPrivate::CheckCompatibleArguments::value), "Signal and slot arguments are not compatible."); - Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible::value), + static_assert((QtPrivate::AreArgumentsCompatible::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 SignalType; const int FunctorArgumentCount = QtPrivate::ComputeFunctorArgumentCount::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::Value>::Value SlotReturnType; - Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible::value), + static_assert((QtPrivate::AreArgumentsCompatible::value), "Return type of the slot is not compatible with the return type of the signal."); - Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro::Value, + static_assert(QtPrivate::HasQ_OBJECT_Macro::Value, "No Q_OBJECT in the class with the signal"); const int *types = nullptr; @@ -344,11 +344,11 @@ public: typedef QtPrivate::FunctionPointer SignalType; typedef QtPrivate::FunctionPointer SlotType; - Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro::Value, + static_assert(QtPrivate::HasQ_OBJECT_Macro::Value, "No Q_OBJECT in the class with the signal"); //compilation error if the arguments does not match. - Q_STATIC_ASSERT_X((QtPrivate::CheckCompatibleArguments::value), + static_assert((QtPrivate::CheckCompatibleArguments::value), "Signal and slot arguments are not compatible."); return disconnectImpl(sender, reinterpret_cast(&signal), receiver, reinterpret_cast(&slot), @@ -461,7 +461,7 @@ template inline T qobject_cast(QObject *object) { typedef typename std::remove_cv::type>::type ObjType; - Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro::Value, + static_assert(QtPrivate::HasQ_OBJECT_Macro::Value, "qobject_cast requires the type to have a Q_OBJECT macro"); return static_cast(ObjType::staticMetaObject.cast(object)); } @@ -470,7 +470,7 @@ template inline T qobject_cast(const QObject *object) { typedef typename std::remove_cv::type>::type ObjType; - Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro::Value, + static_assert(QtPrivate::HasQ_OBJECT_Macro::Value, "qobject_cast requires the type to have a Q_OBJECT macro"); return static_cast(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 SignalType; typedef QtPrivate::FunctionPointer SlotType; - Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro::Value, + static_assert(QtPrivate::HasQ_OBJECT_Macro::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::value), + static_assert((QtPrivate::CheckCompatibleArguments::value), "Signal and slot arguments are not compatible."); - Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible::value), + static_assert((QtPrivate::AreArgumentsCompatible::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 SignalType; typedef QtPrivate::FunctionPointer SlotType; - Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro::Value, + static_assert(QtPrivate::HasQ_OBJECT_Macro::Value, "No Q_OBJECT in the class with the signal"); //compilation error if the arguments does not match. - Q_STATIC_ASSERT_X((QtPrivate::CheckCompatibleArguments::value), + static_assert((QtPrivate::CheckCompatibleArguments::value), "Signal and slot arguments are not compatible."); return QObject::disconnectImpl(sender, reinterpret_cast(&signal), receiverPrivate->q_ptr, reinterpret_cast(&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::Arguments, FunctionPointer::Arguments>::value) + static_assert(CheckCompatibleArguments::Arguments, FunctionPointer::Arguments>::value) */ template struct AreArgumentsCompatible { static int test(const typename RemoveRef::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>; - 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 struct AreArgumentsCompatible { 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 QPointer { - Q_STATIC_ASSERT_X(!std::is_pointer::value, "QPointer's template type must not be a pointer type"); + static_assert(!std::is_pointer::value, "QPointer's template type must not be a pointer type"); using QObjectType = typename std::conditional::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 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 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::isRelocatable) || std::is_enum::value); typedef std::integral_constant CanUseInternalSpace_t; }; -Q_STATIC_ASSERT(QVariantIntegrator::CanUseInternalSpace); -Q_STATIC_ASSERT(QVariantIntegrator::CanUseInternalSpace); -Q_STATIC_ASSERT(QVariantIntegrator::CanUseInternalSpace); +static_assert(QVariantIntegrator::CanUseInternalSpace); +static_assert(QVariantIntegrator::CanUseInternalSpace); +static_assert(QVariantIntegrator::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 static decltype(static_cast(nullptr)->isNull(), Yes()) test(int); template static No test(...); @@ -276,19 +276,19 @@ class QVariantIsNull }; // TODO This part should go to autotests during HasIsNullMethod generalization. - Q_STATIC_ASSERT(!HasIsNullMethod::Value); + static_assert(!HasIsNullMethod::Value); struct SelfTest1 { bool isNull() const; }; - Q_STATIC_ASSERT(HasIsNullMethod::Value); + static_assert(HasIsNullMethod::Value); struct SelfTest2 {}; - Q_STATIC_ASSERT(!HasIsNullMethod::Value); + static_assert(!HasIsNullMethod::Value); struct SelfTest3 : public SelfTest1 {}; - Q_STATIC_ASSERT(HasIsNullMethod::Value); + static_assert(HasIsNullMethod::Value); struct SelfTestFinal1 final { bool isNull() const; }; - Q_STATIC_ASSERT(HasIsNullMethod::Value); + static_assert(HasIsNullMethod::Value); struct SelfTestFinal2 final {}; - Q_STATIC_ASSERT(!HasIsNullMethod::Value); + static_assert(!HasIsNullMethod::Value); struct SelfTestFinal3 final : public SelfTest1 {}; - Q_STATIC_ASSERT(HasIsNullMethod::Value); + static_assert(HasIsNullMethod::Value); template::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(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(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::value); -Q_STATIC_ASSERT(std::is_standard_layout::value); +static_assert(std::is_trivial::value); +static_assert(std::is_standard_layout::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) == sizeof(void *)); - Q_STATIC_ASSERT(sizeof(QCborValue::Type) == sizeof(QJsonValue::Type)); + static_assert(sizeof(QExplicitlySharedDataPointer) == 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 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(a), reinterpret_cast(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::value)); + static_assert((std::is_same::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)); -Q_STATIC_ASSERT(sizeof(QAtomicInteger)); -Q_STATIC_ASSERT(sizeof(QAtomicInteger)); -Q_STATIC_ASSERT(sizeof(QAtomicInteger)); -Q_STATIC_ASSERT(sizeof(QAtomicInteger)); +static_assert(sizeof(QAtomicInteger)); +static_assert(sizeof(QAtomicInteger)); +static_assert(sizeof(QAtomicInteger)); +static_assert(sizeof(QAtomicInteger)); +static_assert(sizeof(QAtomicInteger)); #ifdef Q_COMPILER_UNICODE_STRINGS -Q_STATIC_ASSERT(sizeof(QAtomicInteger)); +static_assert(sizeof(QAtomicInteger)); #endif #ifdef Q_ATOMIC_INT16_IS_SUPPORTED -Q_STATIC_ASSERT(sizeof(QAtomicInteger)); -Q_STATIC_ASSERT(sizeof(QAtomicInteger)); +static_assert(sizeof(QAtomicInteger)); +static_assert(sizeof(QAtomicInteger)); # if WCHAR_MAX < 0x10000 -Q_STATIC_ASSERT(sizeof(QAtomicInteger)); +static_assert(sizeof(QAtomicInteger)); # endif # ifdef Q_COMPILER_UNICODE_STRINGS -Q_STATIC_ASSERT(sizeof(QAtomicInteger)); +static_assert(sizeof(QAtomicInteger)); # endif #endif #ifdef Q_ATOMIC_INT64_IS_SUPPORTED -Q_STATIC_ASSERT(sizeof(QAtomicInteger)); -Q_STATIC_ASSERT(sizeof(QAtomicInteger)); +static_assert(sizeof(QAtomicInteger)); +static_assert(sizeof(QAtomicInteger)); #endif #if WCHAR_MAX == INT_MAX -Q_STATIC_ASSERT(sizeof(QAtomicInteger)); +static_assert(sizeof(QAtomicInteger)); #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 struct QAtomicOpsBySize : QGenericAtomicOps private: typedef typename QAtomicWindowsType::Type Type; template static inline Type *atomic(T *t) - { Q_STATIC_ASSERT(sizeof(T) == sizeof(Type)); return reinterpret_cast(t); } + { static_assert(sizeof(T) == sizeof(Type)); return reinterpret_cast(t); } template 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 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 Ops; // static check that this is a valid integer - Q_STATIC_ASSERT_X(QTypeInfo::isIntegral, "template parameter is not an integral type"); - Q_STATIC_ASSERT_X(QAtomicOpsSupport::IsSupported, "template parameter is an integral of a size not supported on this platform"); + static_assert(QTypeInfo::isIntegral, "template parameter is not an integral type"); + static_assert(QAtomicOpsSupport::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 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 pair = QArrayData::reallocateUnaligned(data, dataPointer, sizeof(T), capacity, options); return qMakePair(static_cast(pair.first), static_cast(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 fromRawData(const T *data, size_t n, ArrayOptions options = DefaultRawFlags) { - Q_STATIC_ASSERT(sizeof(QTypedArrayData) == sizeof(QArrayData)); + static_assert(sizeof(QTypedArrayData) == sizeof(QArrayData)); QArrayDataPointerRef result = { static_cast(prepareRawData(options)), const_cast(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(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(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", "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; template Q_INLINE_TEMPLATE QVarLengthArray::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(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 -- cgit v1.2.3