Tests: suppress has_denorm deprecation

Deprecated in C++23:
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2614r2.pdf

Pick-to: 6.7 6.5
Task-number: QTBUG-128584
Change-Id: I43fb045dfa78b1f0ba5bd52886ca1bf89869d91d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
(cherry picked from commit e54ee29862bd97749d547330a739416768088986)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Mårten Nordheim 2024-09-03 08:52:34 +02:00 committed by Qt Cherry-pick Bot
parent bd9e40b14c
commit 7eea3acac9
7 changed files with 24 additions and 10 deletions

View File

@ -729,12 +729,16 @@ void tst_qfloat16::properties()
#if QT_CONFIG(signaling_nan)
QVERIFY(Bounds::has_signaling_NaN);
#endif
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED // has_denorm is deprecated in C++23
#if !defined(Q_CC_GHS)
QCOMPARE(Bounds::has_denorm, std::denorm_present);
#else
// For GHS compiler the "denorm_indeterminite" is the expected return value.
QCOMPARE(Bounds::has_denorm, std::denorm_indeterminate);
#endif // Q_CC_GHS
QT_WARNING_POP
QCOMPARE(Bounds::round_style, std::round_to_nearest);
QCOMPARE(Bounds::radix, 2);
// Untested: has_denorm_loss

View File

@ -334,7 +334,8 @@ void tst_QNumeric::classifyfp()
QCOMPARE(qFpClassify(-huge), FP_NORMAL);
QCOMPARE(qFpClassify(tiny), FP_NORMAL);
QCOMPARE(qFpClassify(-tiny), FP_NORMAL);
if (Bounds::has_denorm == std::denorm_present) {
QT_IGNORE_DEPRECATIONS(const bool has_denorm = Bounds::has_denorm == std::denorm_present;)
if (has_denorm) {
QCOMPARE(qFpClassify(tiny / two), FP_SUBNORMAL);
QCOMPARE(qFpClassify(tiny / -two), FP_SUBNORMAL);
}
@ -396,7 +397,8 @@ void tst_QNumeric::distance()
QFETCH(F, from);
QFETCH(F, stop);
QFETCH(Count, expectedDistance);
if constexpr (std::numeric_limits<F>::has_denorm != std::denorm_present) {
QT_IGNORE_DEPRECATIONS(constexpr bool has_denorm = std::numeric_limits<F>::has_denorm != std::denorm_present;)
if constexpr (has_denorm) {
if (qstrcmp(QTest::currentDataTag(), "denormal") == 0) {
QSKIP("Skipping 'denorm' as this type lacks denormals on this system");
}

View File

@ -407,7 +407,8 @@ void tst_QtJson::testNumbers_2()
// Validate the last actual value is min denorm
QVERIFY2(floatValues_1[1074] == 4.9406564584124654417656879286822e-324, QString("Min denorm value is incorrect: %1").arg(floatValues_1[1074]).toLatin1());
if constexpr (std::numeric_limits<double>::has_denorm == std::denorm_present) {
QT_IGNORE_DEPRECATIONS(constexpr bool has_denorm = std::numeric_limits<double>::has_denorm == std::denorm_present;)
if constexpr (has_denorm) {
// Validate that every value is half the value before it up to 1
for (int index = 1074; index > 0; index--) {
QVERIFY2(floatValues_1[index] != 0, QString("2**- %1 should not be 0").arg(index).toLatin1());
@ -2070,7 +2071,8 @@ void tst_QtJson::toJsonLargeNumericValues()
void tst_QtJson::toJsonDenormalValues()
{
if constexpr (std::numeric_limits<double>::has_denorm == std::denorm_present) {
QT_IGNORE_DEPRECATIONS(constexpr bool has_denorm = std::numeric_limits<double>::has_denorm == std::denorm_present;)
if constexpr (has_denorm) {
QJsonObject object;
QJsonArray array;
array.append(QJsonValue(5e-324)); // JS Number.MIN_VALUE
@ -2468,7 +2470,8 @@ void tst_QtJson::parseNumbers()
QCOMPARE(val.toDouble(), numbers[i].n);
}
}
if constexpr (std::numeric_limits<double>::has_denorm == std::denorm_present) {
QT_IGNORE_DEPRECATIONS(constexpr bool has_denorm = std::numeric_limits<double>::has_denorm == std::denorm_present;)
if constexpr (has_denorm) {
Numbers numbers [] = {
{ "1.1e-308", 1.1e-308 },
{ "-1.1e-308", -1.1e-308 }

View File

@ -1544,7 +1544,8 @@ void tst_QByteArray::number_double()
QFETCH(char, format);
QFETCH(int, precision);
if constexpr (std::numeric_limits<double>::has_denorm != std::denorm_present) {
QT_IGNORE_DEPRECATIONS(constexpr bool has_denorm = std::numeric_limits<double>::has_denorm != std::denorm_present;)
if constexpr (has_denorm) {
if (::qstrcmp(QTest::currentDataTag(), "Very small number, very high precision, format 'f', precision 350") == 0) {
QSKIP("Skipping 'denorm' as this type lacks denormals on this system");
}

View File

@ -1145,7 +1145,8 @@ void tst_QLocale::stringToFloat()
QLocale locale(locale_name);
QCOMPARE(locale.name(), locale_name);
if constexpr (std::numeric_limits<float>::has_denorm != std::denorm_present) {
QT_IGNORE_DEPRECATIONS(constexpr bool float_has_denorm = std::numeric_limits<float>::has_denorm != std::denorm_present;)
if constexpr (float_has_denorm) {
if (qstrcmp(QTest::currentDataTag(), "C float -min") == 0
|| qstrcmp(QTest::currentDataTag(), "C float min") == 0)
QSKIP("Skipping 'denorm' as this type lacks denormals on this system");
@ -1154,7 +1155,8 @@ void tst_QLocale::stringToFloat()
float f = locale.toFloat(num_str, &ok);
QCOMPARE(ok, good);
if constexpr (std::numeric_limits<double>::has_denorm != std::denorm_present) {
QT_IGNORE_DEPRECATIONS(constexpr bool double_has_denorm = std::numeric_limits<double>::has_denorm != std::denorm_present;)
if constexpr (double_has_denorm) {
if (qstrcmp(QTest::currentDataTag(), "C double min") == 0
|| qstrcmp(QTest::currentDataTag(), "C double -min") == 0
|| qstrcmp(QTest::currentDataTag(), "C tiny") == 0

View File

@ -6861,7 +6861,8 @@ void tst_QString::number_double()
QFETCH(double, value);
QFETCH(char, format);
QFETCH(int, precision);
if constexpr (std::numeric_limits<double>::has_denorm != std::denorm_present) {
QT_IGNORE_DEPRECATIONS(constexpr bool has_denorm = std::numeric_limits<double>::has_denorm != std::denorm_present;)
if constexpr (has_denorm) {
if (::qstrcmp(QTest::currentDataTag(), "Very small number, very high precision, format 'f', precision 350") == 0) {
QSKIP("Skipping 'denorm' as this type lacks denormals on this system");
}

View File

@ -375,7 +375,8 @@ void tst_QLine::testLength()
l.setLength(lengthToSet);
if constexpr (std::numeric_limits<double>::has_denorm != std::denorm_present) {
QT_IGNORE_DEPRECATIONS(constexpr bool has_denorm = std::numeric_limits<double>::has_denorm != std::denorm_present;)
if constexpr (has_denorm) {
if (qstrcmp(QTest::currentDataTag(), "[tiny,tiny]->|2| (-tiny/2,-tiny/2)") == 0
|| qstrcmp(QTest::currentDataTag(), "[4e-323,5e-324]|1892|") == 0) {
QSKIP("Skipping 'denorm' as this type lacks denormals on this system");