diff --git a/tests/auto/corelib/global/qglobal/CMakeLists.txt b/tests/auto/corelib/global/qglobal/CMakeLists.txt index 5a0877663b..527e218aba 100644 --- a/tests/auto/corelib/global/qglobal/CMakeLists.txt +++ b/tests/auto/corelib/global/qglobal/CMakeLists.txt @@ -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: ##################################################################### diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index 954eab6a43..e67f991fae 100644 --- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp +++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp @@ -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 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, Expected128>); \ QCOMPARE_EQ(lhs_, rhs); \ } while (0) + QTBUG_119901_MAYBE_FAIL; COMPARE_EQ(Q_INT128_MIN, std::numeric_limits::min(), qint128); + QTBUG_119901_MAYBE_FAIL; COMPARE_EQ(Q_INT128_MAX, std::numeric_limits::max(), qint128); + QTBUG_119901_MAYBE_FAIL; COMPARE_EQ(Q_UINT128_MAX, std::numeric_limits::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); + QTBUG_119901_MAYBE_FAIL; QCOMPARE_EQ(i, std::numeric_limits::min() + 1); } { @@ -610,7 +623,9 @@ void tst_QGlobal::int128Literals() constexpr auto u = Q_UINT128_C(340282366920938463463374607431768211455); // UMAX static_assert(std::is_same_v); static_assert(std::is_same_v); + QTBUG_119901_MAYBE_FAIL; QCOMPARE_EQ(i, std::numeric_limits::max()); + QTBUG_119901_MAYBE_FAIL; QCOMPARE_EQ(u, std::numeric_limits::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); static_assert(std::is_same_v); + QTBUG_119901_MAYBE_FAIL; QCOMPARE_EQ(i, std::numeric_limits::max()); + QTBUG_119901_MAYBE_FAIL; QCOMPARE_EQ(u, std::numeric_limits::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); static_assert(std::is_same_v); + QTBUG_119901_MAYBE_FAIL; QCOMPARE_EQ(i, std::numeric_limits::max()); + QTBUG_119901_MAYBE_FAIL; QCOMPARE_EQ(u, std::numeric_limits::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); static_assert(std::is_same_v); + QTBUG_119901_MAYBE_FAIL; QCOMPARE_EQ(i, std::numeric_limits::max()); + QTBUG_119901_MAYBE_FAIL; QCOMPARE_EQ(u, std::numeric_limits::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.");