Add some tests for q(u)int128
Check that QIntegerForSize<16> and std::numeric_limits<quint128> work and that q(u)int128 are available in C mode, too. Pick-to: 6.6 Change-Id: I44af8282399c78f6e74a8268af53bad64407ca34 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
39d3af0c29
commit
32f66f7008
@ -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(qint16)== 2, "Internal error, qint16 is misdefined");
|
||||||
static_assert(sizeof(qint32) == 4, "Internal error, qint32 is misdefined");
|
static_assert(sizeof(qint32) == 4, "Internal error, qint32 is misdefined");
|
||||||
static_assert(sizeof(qint64) == 8, "Internal error, qint64 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<quint128>::max() == qint128(-1));
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <QtCore/qglobal.h>
|
#include <QtCore/qglobal.h>
|
||||||
#include <QtCore/qtversion.h>
|
#include <QtCore/qtversion.h>
|
||||||
#include <QtCore/qyieldcpu.h>
|
#include <QtCore/qyieldcpu.h>
|
||||||
|
#include <QtCore/qtypes.h>
|
||||||
|
|
||||||
#ifdef Q_COMPILER_THREAD_LOCAL
|
#ifdef Q_COMPILER_THREAD_LOCAL
|
||||||
# include <threads.h>
|
# include <threads.h>
|
||||||
@ -50,6 +51,12 @@ void tst_GlobalTypes()
|
|||||||
qintptr qip;
|
qintptr qip;
|
||||||
quintptr qup;
|
quintptr qup;
|
||||||
Q_UNUSED(qs); Q_UNUSED(qp); Q_UNUSED(qip); Q_UNUSED(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 */
|
/* Qt version */
|
||||||
|
@ -424,11 +424,17 @@ void tst_QGlobal::integerForSize()
|
|||||||
static_assert(sizeof(QIntegerForSize<2>::Signed) == 2);
|
static_assert(sizeof(QIntegerForSize<2>::Signed) == 2);
|
||||||
static_assert(sizeof(QIntegerForSize<4>::Signed) == 4);
|
static_assert(sizeof(QIntegerForSize<4>::Signed) == 4);
|
||||||
static_assert(sizeof(QIntegerForSize<8>::Signed) == 8);
|
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<1>::Unsigned) == 1);
|
||||||
static_assert(sizeof(QIntegerForSize<2>::Unsigned) == 2);
|
static_assert(sizeof(QIntegerForSize<2>::Unsigned) == 2);
|
||||||
static_assert(sizeof(QIntegerForSize<4>::Unsigned) == 4);
|
static_assert(sizeof(QIntegerForSize<4>::Unsigned) == 4);
|
||||||
static_assert(sizeof(QIntegerForSize<8>::Unsigned) == 8);
|
static_assert(sizeof(QIntegerForSize<8>::Unsigned) == 8);
|
||||||
|
#ifdef QT_SUPPORTS_INT128
|
||||||
|
static_assert(sizeof(QIntegerForSize<16>::Unsigned) == 16);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef QPair<const char *, const char *> stringpair;
|
typedef QPair<const char *, const char *> stringpair;
|
||||||
|
Loading…
Reference in New Issue
Block a user