diff --git a/src/corelib/global/qtypes.cpp b/src/corelib/global/qtypes.cpp index 5c3b963a922..1063f507c54 100644 --- a/src/corelib/global/qtypes.cpp +++ b/src/corelib/global/qtypes.cpp @@ -399,5 +399,17 @@ static_assert(sizeof(qint8) == 1, "Internal error, qint8 is misdefined"); static_assert(sizeof(qint16)== 2, "Internal error, qint16 is misdefined"); static_assert(sizeof(qint32) == 4, "Internal error, qint32 is misdefined"); static_assert(sizeof(qint64) == 8, "Internal error, qint64 is misdefined"); +#ifdef QT_SUPPORTS_INT128 +static_assert(sizeof(qint128) == 16, "Internal error, qint128 is misdefined"); +#endif + +#ifdef QT_SUPPORTS_INT128 +// check that numeric_limits works: +// This fails here for GCC 9, but succeeds on Clang and GCC >= 11 +// so just suppress the check for older GCC: +# if !defined(Q_CC_GNU_ONLY) || Q_CC_GNU >= 1100 +static_assert(std::numeric_limits::max() == quint128(-1)); +# endif +#endif QT_END_NAMESPACE diff --git a/tests/auto/corelib/global/qglobal/qglobal.c b/tests/auto/corelib/global/qglobal/qglobal.c index abe6ec4fde0..bf6d19cb81c 100644 --- a/tests/auto/corelib/global/qglobal/qglobal.c +++ b/tests/auto/corelib/global/qglobal/qglobal.c @@ -3,6 +3,7 @@ #include #include +#include #ifdef Q_COMPILER_THREAD_LOCAL # include @@ -44,6 +45,12 @@ void tst_GlobalTypes() qintptr qip; quintptr qup; Q_UNUSED(qs); Q_UNUSED(qp); Q_UNUSED(qip); Q_UNUSED(qup); + +#ifdef QT_SUPPORTS_INT128 + qint128 s128; + quint128 u128; + Q_UNUSED(s128); Q_UNUSED(u128); +#endif /* QT_SUPPORTS_INT128 */ } /* Qt version */ diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index 3d9759ff5bf..33be8fd0a27 100644 --- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp +++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp @@ -422,11 +422,17 @@ void tst_QGlobal::integerForSize() static_assert(sizeof(QIntegerForSize<2>::Signed) == 2); static_assert(sizeof(QIntegerForSize<4>::Signed) == 4); static_assert(sizeof(QIntegerForSize<8>::Signed) == 8); +#ifdef QT_SUPPORTS_INT128 + static_assert(sizeof(QIntegerForSize<16>::Signed) == 16); +#endif static_assert(sizeof(QIntegerForSize<1>::Unsigned) == 1); static_assert(sizeof(QIntegerForSize<2>::Unsigned) == 2); static_assert(sizeof(QIntegerForSize<4>::Unsigned) == 4); static_assert(sizeof(QIntegerForSize<8>::Unsigned) == 8); +#ifdef QT_SUPPORTS_INT128 + static_assert(sizeof(QIntegerForSize<16>::Unsigned) == 16); +#endif } typedef QPair stringpair;