diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-06-11 11:35:19 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-06-19 19:38:23 +0200 |
commit | 3e1d03b1eaf6a5e842bed4ae4f9bb8cca05e5b31 (patch) | |
tree | 74dd3478dce3bc96121238300fc0bbc6ef97fc3e /tests/auto/corelib/kernel | |
parent | 5b686e208ffc68f9f660d36c468280d50a40e3ad (diff) |
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 <lars.knoll@qt.io>
Diffstat (limited to 'tests/auto/corelib/kernel')
4 files changed, 25 insertions, 25 deletions
diff --git a/tests/auto/corelib/kernel/qmetaenum/tst_qmetaenum.cpp b/tests/auto/corelib/kernel/qmetaenum/tst_qmetaenum.cpp index 6ed0a6caa9..6452800bf0 100644 --- a/tests/auto/corelib/kernel/qmetaenum/tst_qmetaenum.cpp +++ b/tests/auto/corelib/kernel/qmetaenum/tst_qmetaenum.cpp @@ -109,13 +109,13 @@ void tst_QMetaEnum::defaultConstructed() QCOMPARE(e.name(), QByteArray()); } -Q_STATIC_ASSERT(QtPrivate::IsQEnumHelper<tst_QMetaEnum::SuperEnum>::Value); -Q_STATIC_ASSERT(QtPrivate::IsQEnumHelper<Qt::WindowFlags>::Value); -Q_STATIC_ASSERT(QtPrivate::IsQEnumHelper<Qt::Orientation>::Value); -Q_STATIC_ASSERT(!QtPrivate::IsQEnumHelper<int>::Value); -Q_STATIC_ASSERT(!QtPrivate::IsQEnumHelper<QObject>::Value); -Q_STATIC_ASSERT(!QtPrivate::IsQEnumHelper<QObject*>::Value); -Q_STATIC_ASSERT(!QtPrivate::IsQEnumHelper<void>::Value); +static_assert(QtPrivate::IsQEnumHelper<tst_QMetaEnum::SuperEnum>::Value); +static_assert(QtPrivate::IsQEnumHelper<Qt::WindowFlags>::Value); +static_assert(QtPrivate::IsQEnumHelper<Qt::Orientation>::Value); +static_assert(!QtPrivate::IsQEnumHelper<int>::Value); +static_assert(!QtPrivate::IsQEnumHelper<QObject>::Value); +static_assert(!QtPrivate::IsQEnumHelper<QObject*>::Value); +static_assert(!QtPrivate::IsQEnumHelper<void>::Value); QTEST_MAIN(tst_QMetaEnum) #include "tst_qmetaenum.moc" diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index 2688d90b43..651efa53cf 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -677,21 +677,21 @@ void tst_QMetaType::type_fromSubString() namespace { template <typename T> struct static_assert_trigger { - Q_STATIC_ASSERT(( QMetaTypeId2<T>::IsBuiltIn )); + static_assert(( QMetaTypeId2<T>::IsBuiltIn )); enum { value = true }; }; } #define CHECK_BUILTIN(MetaTypeName, MetaTypeId, RealType) static_assert_trigger< RealType >::value && -Q_STATIC_ASSERT(( FOR_EACH_CORE_METATYPE(CHECK_BUILTIN) true )); +static_assert(( FOR_EACH_CORE_METATYPE(CHECK_BUILTIN) true )); #undef CHECK_BUILTIN -Q_STATIC_ASSERT(( QMetaTypeId2<QList<QVariant> >::IsBuiltIn)); -Q_STATIC_ASSERT(( QMetaTypeId2<QMap<QString,QVariant> >::IsBuiltIn)); -Q_STATIC_ASSERT(( QMetaTypeId2<QObject*>::IsBuiltIn)); -Q_STATIC_ASSERT((!QMetaTypeId2<tst_QMetaType*>::IsBuiltIn)); // QObject subclass -Q_STATIC_ASSERT((!QMetaTypeId2<QList<int> >::IsBuiltIn)); -Q_STATIC_ASSERT((!QMetaTypeId2<QMap<int,int> >::IsBuiltIn)); -Q_STATIC_ASSERT((!QMetaTypeId2<QMetaType::Type>::IsBuiltIn)); +static_assert(( QMetaTypeId2<QList<QVariant> >::IsBuiltIn)); +static_assert(( QMetaTypeId2<QMap<QString,QVariant> >::IsBuiltIn)); +static_assert(( QMetaTypeId2<QObject*>::IsBuiltIn)); +static_assert((!QMetaTypeId2<tst_QMetaType*>::IsBuiltIn)); // QObject subclass +static_assert((!QMetaTypeId2<QList<int> >::IsBuiltIn)); +static_assert((!QMetaTypeId2<QMap<int,int> >::IsBuiltIn)); +static_assert((!QMetaTypeId2<QMetaType::Type>::IsBuiltIn)); void tst_QMetaType::create_data() { @@ -2090,7 +2090,7 @@ void tst_QMetaType::constRefs() QCOMPARE(::qMetaTypeId<const CustomMovable &>(), ::qMetaTypeId<CustomMovable>()); QCOMPARE(::qMetaTypeId<const QList<CustomMovable> &>(), ::qMetaTypeId<QList<CustomMovable> >()); #if defined(Q_COMPILER_CONSTEXPR) - Q_STATIC_ASSERT(::qMetaTypeId<const int &>() == ::qMetaTypeId<int>()); + static_assert(::qMetaTypeId<const int &>() == ::qMetaTypeId<int>()); #endif } diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index b2dc3c7297..7c806ed78d 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -6973,13 +6973,13 @@ void tst_QObject::checkArgumentsForNarrowing() static constexpr bool IsUnscopedEnumSigned = std::is_signed_v<std::underlying_type_t<UnscopedEnum>>; -#define NARROWS_IF(x, y, test) Q_STATIC_ASSERT((QtPrivate::AreArgumentsConvertibleWithoutNarrowingBase<x, y>::value) != (test)) -#define FITS_IF(x, y, test) Q_STATIC_ASSERT((QtPrivate::AreArgumentsConvertibleWithoutNarrowingBase<x, y>::value) == (test)) +#define NARROWS_IF(x, y, test) static_assert((QtPrivate::AreArgumentsConvertibleWithoutNarrowingBase<x, y>::value) != (test)) +#define FITS_IF(x, y, test) static_assert((QtPrivate::AreArgumentsConvertibleWithoutNarrowingBase<x, y>::value) == (test)) #define NARROWS(x, y) NARROWS_IF(x, y, true) #define FITS(x, y) FITS_IF(x, y, true) - Q_STATIC_ASSERT(sizeof(UnscopedEnum) <= sizeof(int)); - Q_STATIC_ASSERT(sizeof(SignedUnscopedEnum) <= sizeof(int)); + static_assert(sizeof(UnscopedEnum) <= sizeof(int)); + static_assert(sizeof(SignedUnscopedEnum) <= sizeof(int)); // floating point to integral @@ -7230,7 +7230,7 @@ void tst_QObject::checkArgumentsForNarrowing() NARROWS_IF(UnscopedEnum, long long, sizeof(UnscopedEnum) > sizeof(long long) || (sizeof(UnscopedEnum) == sizeof(long long) && !IsUnscopedEnumSigned)); NARROWS_IF(UnscopedEnum, unsigned long long, IsUnscopedEnumSigned); - Q_STATIC_ASSERT(std::is_signed<typename std::underlying_type<SignedUnscopedEnum>::type>::value); + static_assert(std::is_signed<typename std::underlying_type<SignedUnscopedEnum>::type>::value); NARROWS_IF(SignedUnscopedEnum, signed char, (sizeof(SignedUnscopedEnum) > sizeof(char))); NARROWS_IF(SignedUnscopedEnum, short, (sizeof(SignedUnscopedEnum) > sizeof(short))); @@ -7469,8 +7469,8 @@ void tst_QObject::disconnectDisconnects() } // Test for QtPrivate::HasQ_OBJECT_Macro -Q_STATIC_ASSERT(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value); -Q_STATIC_ASSERT(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value); +static_assert(QtPrivate::HasQ_OBJECT_Macro<tst_QObject>::Value); +static_assert(!QtPrivate::HasQ_OBJECT_Macro<SiblingDeleter>::Value); QTEST_MAIN(tst_QObject) #include "tst_qobject.moc" diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index 0b760f75a8..fdd39cb0a4 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -3563,7 +3563,7 @@ struct BigConvertible { }; Q_DECLARE_METATYPE(BigConvertible); -Q_STATIC_ASSERT(sizeof(BigConvertible) > sizeof(QVariant)); +static_assert(sizeof(BigConvertible) > sizeof(QVariant)); void tst_QVariant::userConversion() { |