diff --git a/src/corelib/global/qtypeinfo.h b/src/corelib/global/qtypeinfo.h index 9b2119da1df..473854f230c 100644 --- a/src/corelib/global/qtypeinfo.h +++ b/src/corelib/global/qtypeinfo.h @@ -23,7 +23,13 @@ class QDebug; namespace QtPrivate { template -inline constexpr bool qIsRelocatable = std::is_trivially_copyable_v && std::is_trivially_destructible_v; +inline constexpr bool qIsRelocatable = (std::is_trivially_copyable_v && std::is_trivially_destructible_v) +#if defined(__has_builtin) +#if __has_builtin(__is_trivially_relocatable) + || __is_trivially_relocatable(T) +#endif +#endif + ; // Denotes types that are trivially default constructible, and for which // value-initialization can be achieved by filling their storage with 0 bits. diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index 1a19048bbe7..524212e9333 100644 --- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp +++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp @@ -930,6 +930,20 @@ struct Trivial1 static_assert(!QTypeInfo::isComplex); static_assert(QTypeInfo::isRelocatable); +#if defined(__has_builtin) +#if __has_builtin(__is_trivially_relocatable) && __has_attribute(trivial_abi) +struct [[clang::trivial_abi]] TrivialAbi1 +{ + ~TrivialAbi1(); + TrivialAbi1(TrivialAbi1 &&); +}; +static_assert(__has_builtin(__is_trivially_relocatable)); +static_assert(__is_trivially_relocatable(TrivialAbi1)); +static_assert(QTypeInfo::isComplex); +static_assert(QTypeInfo::isRelocatable); +#endif +#endif + QT_END_NAMESPACE QTEST_APPLESS_MAIN(tst_QGlobal)