tst_QGlobal: add a build of this test in strict mode
This is in preparation of adding some static assertions here that we need to have evaluated in both "normal" and "strict" mode, namely <type_traits> and <limits> support for qint128. But this change is more general, so making it a separate change. Turns out we already have (non-static) assertions here about <limits> support for qint128. These force us to define precisely when GCC/libstdc++ has gained <limits> support for __int128_t: the timestamp of the __GLIBCXX__ macro is the Daily Bump immediately preceding the gcc commit that fixed <limits> (gcc/8eb9a45e87bdb81cb44948c651edee846c622a0f). Let's hope no-one is running the prerelease version of GCC 10.3 from that particular day, otherwise these might become XPASSes. But just not testing is also wrong; we want to be informed about True Positives and Negatives here. Task-number: QTBUG-119901 Pick-to: 6.7 6.5 Change-Id: I6f9be047f846fff74133c466c5bed40d0039d60f Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit e7c54248987d474cff9f49cad502822eb9dcb114) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>bb10
parent
ae7ca75995
commit
caf57f0ca3
|
|
@ -19,5 +19,17 @@ qt_internal_add_test(tst_qglobal
|
|||
tst_qglobal.cpp # undef QT_NO_FOREACH
|
||||
)
|
||||
|
||||
# check stuff (esp. qtypes.h) works in -ansi mode
|
||||
qt_internal_add_test(tst_qglobal_strict
|
||||
SOURCES
|
||||
qglobal.c
|
||||
tst_qglobal.cpp
|
||||
DEFINES
|
||||
tst_QGlobal=tst_QGlobal_strict
|
||||
NO_PCH_SOURCES
|
||||
tst_qglobal.cpp # undef QT_NO_FOREACH
|
||||
)
|
||||
_qt_internal_apply_strict_cpp(tst_qglobal_strict)
|
||||
|
||||
## Scopes:
|
||||
#####################################################################
|
||||
|
|
|
|||
|
|
@ -544,13 +544,25 @@ void tst_QGlobal::integerForSize()
|
|||
void tst_QGlobal::int128Literals()
|
||||
{
|
||||
#ifdef QT_SUPPORTS_INT128
|
||||
# if defined(__GLIBCXX__) && defined(__STRICT_ANSI__) && \
|
||||
(_GLIBCXX_RELEASE < 10 || \
|
||||
_GLIBCXX_RELEASE == 10 && __GLIBCXX__ < 20201112L /*gcc commit 8eb9a45e87bdb81cb44948c651edee846c622a0f*/)
|
||||
// -ansi/-std=c++NN instead of gnu++NN
|
||||
// breaks <type_traits> on libstdc++ <= 10.2; fixed in 10.3+
|
||||
# define QTBUG_119901_MAYBE_FAIL QEXPECT_FAIL("", "QTBUG-119901", Continue)
|
||||
# else
|
||||
# define QTBUG_119901_MAYBE_FAIL do {} while (false)
|
||||
# endif
|
||||
#define COMPARE_EQ(lhs, rhs, Expected128) do { \
|
||||
constexpr auto lhs_ = lhs; \
|
||||
static_assert(std::is_same_v<std::remove_cv_t<decltype(lhs_)>, Expected128>); \
|
||||
QCOMPARE_EQ(lhs_, rhs); \
|
||||
} while (0)
|
||||
QTBUG_119901_MAYBE_FAIL;
|
||||
COMPARE_EQ(Q_INT128_MIN, std::numeric_limits<qint128>::min(), qint128);
|
||||
QTBUG_119901_MAYBE_FAIL;
|
||||
COMPARE_EQ(Q_INT128_MAX, std::numeric_limits<qint128>::max(), qint128);
|
||||
QTBUG_119901_MAYBE_FAIL;
|
||||
COMPARE_EQ(Q_UINT128_MAX, std::numeric_limits<quint128>::max(), quint128);
|
||||
QCOMPARE_EQ(tst_qint128_min(), Q_INT128_MIN);
|
||||
QCOMPARE_EQ(tst_qint128_max(), Q_INT128_MAX);
|
||||
|
|
@ -603,6 +615,7 @@ void tst_QGlobal::int128Literals()
|
|||
// the literal, but called on the result of the literal.
|
||||
constexpr auto i = Q_INT128_C(-170141183460469231731687303715884105727); // 128-bit MIN + 1
|
||||
static_assert(std::is_same_v<decltype(i), const qint128>);
|
||||
QTBUG_119901_MAYBE_FAIL;
|
||||
QCOMPARE_EQ(i, std::numeric_limits<qint128>::min() + 1);
|
||||
}
|
||||
{
|
||||
|
|
@ -610,7 +623,9 @@ void tst_QGlobal::int128Literals()
|
|||
constexpr auto u = Q_UINT128_C(340282366920938463463374607431768211455); // UMAX
|
||||
static_assert(std::is_same_v<decltype(i), const qint128>);
|
||||
static_assert(std::is_same_v<decltype(u), const quint128>);
|
||||
QTBUG_119901_MAYBE_FAIL;
|
||||
QCOMPARE_EQ(i, std::numeric_limits<qint128>::max());
|
||||
QTBUG_119901_MAYBE_FAIL;
|
||||
QCOMPARE_EQ(u, std::numeric_limits<quint128>::max());
|
||||
QCOMPARE_EQ(u, Q_UINT128_C(-1));
|
||||
}
|
||||
|
|
@ -630,7 +645,9 @@ void tst_QGlobal::int128Literals()
|
|||
constexpr auto u = Q_UINT128_C(0b1111'1111'1111'1111'1111'1111'1111'1111'1111'1111'1111'1111'1111'1111'1111'1111'1111'1111'1111'1111'1111'1111'1111'1111'1111'1111'1111'1111'1111'1111'1111'1111);
|
||||
static_assert(std::is_same_v<decltype(i), const qint128>);
|
||||
static_assert(std::is_same_v<decltype(u), const quint128>);
|
||||
QTBUG_119901_MAYBE_FAIL;
|
||||
QCOMPARE_EQ(i, std::numeric_limits<qint128>::max());
|
||||
QTBUG_119901_MAYBE_FAIL;
|
||||
QCOMPARE_EQ(u, std::numeric_limits<quint128>::max());
|
||||
QCOMPARE_EQ(u, Q_UINT128_C(-0b1));
|
||||
}
|
||||
|
|
@ -654,7 +671,9 @@ void tst_QGlobal::int128Literals()
|
|||
constexpr auto u = Q_UINT128_C(0377'7777'7777'7777'7777'7777'7777'7777'7777'7777'7777);
|
||||
static_assert(std::is_same_v<decltype(i), const qint128>);
|
||||
static_assert(std::is_same_v<decltype(u), const quint128>);
|
||||
QTBUG_119901_MAYBE_FAIL;
|
||||
QCOMPARE_EQ(i, std::numeric_limits<qint128>::max());
|
||||
QTBUG_119901_MAYBE_FAIL;
|
||||
QCOMPARE_EQ(u, std::numeric_limits<quint128>::max());
|
||||
QCOMPARE_EQ(u, Q_UINT128_C(-01));
|
||||
}
|
||||
|
|
@ -678,12 +697,15 @@ void tst_QGlobal::int128Literals()
|
|||
constexpr auto u = Q_UINT128_C(0xFFFF'FFFF'FFFF'FFFF'FFFF'FFFF'FFFF'FFFF);
|
||||
static_assert(std::is_same_v<decltype(i), const qint128>);
|
||||
static_assert(std::is_same_v<decltype(u), const quint128>);
|
||||
QTBUG_119901_MAYBE_FAIL;
|
||||
QCOMPARE_EQ(i, std::numeric_limits<qint128>::max());
|
||||
QTBUG_119901_MAYBE_FAIL;
|
||||
QCOMPARE_EQ(u, std::numeric_limits<quint128>::max());
|
||||
QCOMPARE_EQ(Q_UINT128_C(-1), u);
|
||||
}
|
||||
#undef CHECK
|
||||
}
|
||||
#undef QTBUG_119901_MAYBE_FAIL
|
||||
#undef COMPARE_EQ
|
||||
#else
|
||||
QSKIP("This test requires 128-bit integer support enabled in the compiler.");
|
||||
|
|
|
|||
Loading…
Reference in New Issue