Skip to content

Commit

Permalink
Tests: disable various compiler warnings
Browse files Browse the repository at this point in the history
The build on Android with clang results in a bunch of irrelevant
warnings. Disable them for the offending lines of test code.

Pick-to: 6.8
Change-Id: Ica5d867e3a2b1215dc526cc5f945a39ac908ac23
Reviewed-by: Thiago Macieira <[email protected]>
  • Loading branch information
vohi committed Jul 11, 2024
1 parent 2339cb3 commit 8d523a0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/auto/corelib/serialization/json/tst_qtjson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,13 +503,17 @@ void tst_QtJson::testNumberComparisons()
QJsonValue llMinPlus1(Q_INT64_C(-9223372036854775806));
QCOMPARE(llMin == llMinPlus1, Q_INT64_C(-9223372036854775807) == Q_INT64_C(-9223372036854775806)); // false

QT_WARNING_PUSH
// Android clang complains about implicit conversion from 'long long' to 'double'
QT_WARNING_DISABLE_CLANG("-Wimplicit-const-int-float-conversion")
// The different storage formats should be able to compare as their C++ versions (all true)
QCOMPARE(llMin == llMinDbl, Q_INT64_C(-9223372036854775807) == -9223372036854775807.0);
QCOMPARE(llMinDbl == llMin, -9223372036854775807.0 == Q_INT64_C(-9223372036854775807));
QCOMPARE(llMinPlus1 == llMinPlus1Dbl, Q_INT64_C(-9223372036854775806) == -9223372036854775806.0);
QCOMPARE(llMinPlus1Dbl == llMinPlus1, -9223372036854775806.0 == Q_INT64_C(-9223372036854775806));
QCOMPARE(llMinPlus1 == llMinDbl, Q_INT64_C(-9223372036854775806) == -9223372036854775807.0);
QCOMPARE(llMinPlus1Dbl == llMin, -9223372036854775806.0 == Q_INT64_C(-9223372036854775807));
QT_WARNING_POP
}

void tst_QtJson::testObjectSimple()
Expand Down
8 changes: 8 additions & 0 deletions tests/auto/corelib/text/qstring/tst_qstring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1652,12 +1652,16 @@ void tst_QString::asprintfS()
// Check utf8 conversion for %s
QCOMPARE(QString::asprintf("%s", "\303\266\303\244\303\274\303\226\303\204\303\234\303\270\303\246\303\245\303\230\303\206\303\205"), QString::fromLatin1("\366\344\374\326\304\334\370\346\345\330\306\305"));

QT_WARNING_PUSH
// Android clang emits warning: '%n' specifier not supported on this platform
QT_WARNING_DISABLE_CLANG("-Wformat")
int n1;
QCOMPARE(QString::asprintf("%s%n%s", "hello", &n1, "goodbye"), u"hellogoodbye");
QCOMPARE(n1, 5);
qlonglong n2;
QCOMPARE(QString::asprintf("%s%s%lln%s", "foo", "bar", &n2, "whiz"), u"foobarwhiz");
QCOMPARE((int)n2, 6);
QT_WARNING_POP

{ // %ls

Expand All @@ -1681,7 +1685,11 @@ void tst_QString::asprintfS()
QLatin1String("\366\344\374\326\304\334\370\346\345\330\306\305"));

int n;
QT_WARNING_PUSH
// Android clang emits warning: '%n' specifier not supported on this platform
QT_WARNING_DISABLE_CLANG("-Wformat")
QCOMPARE(QString::asprintf("%ls%n%s", qUtf16Printable(u"hello"_s), &n, "goodbye"), "hellogoodbye"_L1);
QT_WARNING_POP
QCOMPARE(n, 5);
}
}
Expand Down
8 changes: 8 additions & 0 deletions tests/auto/corelib/tools/qbitarray/tst_qbitarray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,13 +409,17 @@ void tst_QBitArray::operator_andeq()
result &= detached(input1);
COMPARE_BITARRAY_EQ(result, res);

QT_WARNING_PUSH
// Android clang emits warning: explicitly assigning value of variable of type 'QBitArray' to itself
QT_WARNING_DISABLE_CLANG("-Wself-assign-overloaded")
// operation is idempotent
result &= result;
COMPARE_BITARRAY_EQ(result, res);
result &= std::move(result);
COMPARE_BITARRAY_EQ(result, res);
result &= detached(result);
COMPARE_BITARRAY_EQ(result, res);
QT_WARNING_POP
}

void tst_QBitArray::operator_and()
Expand Down Expand Up @@ -515,13 +519,17 @@ void tst_QBitArray::operator_oreq()
result |= detached(input1);
COMPARE_BITARRAY_EQ(result, res);

QT_WARNING_PUSH
// Android clang emits warning: explicitly assigning value of variable of type 'QBitArray' to itself
QT_WARNING_DISABLE_CLANG("-Wself-assign-overloaded")
// operation is idempotent
result |= result;
COMPARE_BITARRAY_EQ(result, res);
result |= QBitArray(result);
COMPARE_BITARRAY_EQ(result, res);
result |= detached(result);
COMPARE_BITARRAY_EQ(result, res);
QT_WARNING_POP
}

void tst_QBitArray::operator_or()
Expand Down

0 comments on commit 8d523a0

Please sign in to comment.