From e1d0da65261077bfd720887d6e6216497abb4c5f Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 13 Apr 2016 12:36:28 -0700 Subject: Fix Clang -Wexpansion-to-defined warning by deprecating QT_SUPPORTS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The C and C++ standards say it's undefined whether the preprocessor supports macros that expand to defined() will operate as an ifdef. Clang 3.9 started complaining about that fact. One solution was to change QT_SUPPORTS to check for zero or one, which means we need to change the #defines QT_NO_xxx to #define QT_NO_xxx 1. The C standard says we don't need to #define to 0, as an unknown token is interpreted as zero. However, that might produce a warning (GCC with -Wundef), so changing the macro this way is not recommended. Instead, we deprecate the macro and replace the uses with #ifdef/ndef. Change-Id: Id75834dab9ed466e94c7ffff1444874d5680b96a Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: Thiago Macieira --- tests/auto/corelib/tools/qarraydata/simplevector.h | 2 +- .../corelib/tools/qarraydata/tst_qarraydata.cpp | 30 +++++++++++----------- tests/auto/corelib/tools/qhash/tst_qhash.cpp | 2 +- .../corelib/tools/qlinkedlist/tst_qlinkedlist.cpp | 4 +-- tests/auto/corelib/tools/qlist/tst_qlist.cpp | 6 ++--- tests/auto/corelib/tools/qmap/tst_qmap.cpp | 4 +-- tests/auto/corelib/tools/qvector/tst_qvector.cpp | 22 ++++++++-------- 7 files changed, 35 insertions(+), 35 deletions(-) (limited to 'tests/auto') diff --git a/tests/auto/corelib/tools/qarraydata/simplevector.h b/tests/auto/corelib/tools/qarraydata/simplevector.h index 091d871e82..9c7e1ae228 100644 --- a/tests/auto/corelib/tools/qarraydata/simplevector.h +++ b/tests/auto/corelib/tools/qarraydata/simplevector.h @@ -93,7 +93,7 @@ public: bool isStatic() const { return d->ref.isStatic(); } bool isShared() const { return d->ref.isShared(); } bool isSharedWith(const SimpleVector &other) const { return d == other.d; } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) bool isSharable() const { return d->ref.isSharable(); } void setSharable(bool sharable) { d.setSharable(sharable); } #endif diff --git a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp index 31e44bc3ae..31ade26067 100644 --- a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp +++ b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp @@ -44,7 +44,7 @@ struct SharedNullVerifier { Q_ASSERT(QArrayData::shared_null[0].ref.isStatic()); Q_ASSERT(QArrayData::shared_null[0].ref.isShared()); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) Q_ASSERT(QArrayData::shared_null[0].ref.isSharable()); #endif } @@ -101,7 +101,7 @@ void tst_QArrayData::referenceCounting() QCOMPARE(array.ref.atomic.load(), 1); QVERIFY(!array.ref.isStatic()); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QVERIFY(array.ref.isSharable()); #endif @@ -123,7 +123,7 @@ void tst_QArrayData::referenceCounting() // Now would be a good time to free/release allocated data } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) { // Reference counting initialized to 0 (non-sharable) QArrayData array = { { Q_BASIC_ATOMIC_INITIALIZER(0) }, 0, 0, 0, 0 }; @@ -151,7 +151,7 @@ void tst_QArrayData::referenceCounting() QCOMPARE(array.ref.atomic.load(), -1); QVERIFY(array.ref.isStatic()); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QVERIFY(array.ref.isSharable()); #endif @@ -178,7 +178,7 @@ void tst_QArrayData::sharedNullEmpty() QCOMPARE(null->ref.atomic.load(), -1); QCOMPARE(empty->ref.atomic.load(), -1); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QVERIFY(null->ref.isSharable()); QVERIFY(empty->ref.isSharable()); #endif @@ -309,7 +309,7 @@ void tst_QArrayData::simpleVector() QVERIFY(!v7.isShared()); QVERIFY(!v8.isShared()); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QVERIFY(v1.isSharable()); QVERIFY(v2.isSharable()); QVERIFY(v3.isSharable()); @@ -502,7 +502,7 @@ void tst_QArrayData::simpleVector() for (int i = 0; i < 120; ++i) QCOMPARE(v1[i], v8[i % 10]); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) { v7.setSharable(true); QVERIFY(v7.isSharable()); @@ -672,7 +672,7 @@ void tst_QArrayData::allocate_data() QArrayData *shared_empty = QArrayData::allocate(0, Q_ALIGNOF(QArrayData), 0); QVERIFY(shared_empty); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QArrayData *unsharable_empty = QArrayData::allocate(0, Q_ALIGNOF(QArrayData), 0, QArrayData::Unsharable); QVERIFY(unsharable_empty); #endif @@ -686,7 +686,7 @@ void tst_QArrayData::allocate_data() } options[] = { { "Default", QArrayData::Default, false, true, shared_empty }, { "Reserved", QArrayData::CapacityReserved, true, true, shared_empty }, -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) { "Reserved | Unsharable", QArrayData::CapacityReserved | QArrayData::Unsharable, true, false, unsharable_empty }, @@ -736,7 +736,7 @@ void tst_QArrayData::allocate() else QCOMPARE(data->alloc, uint(capacity)); QCOMPARE(data->capacityReserved, uint(isCapacityReserved)); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QFETCH(bool, isSharable); QCOMPARE(data->ref.isSharable(), isSharable); #endif @@ -1316,7 +1316,7 @@ static inline bool arrayIsFilledWith(const QArrayDataPointer &array, void tst_QArrayData::setSharable_data() { -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QTest::addColumn >("array"); QTest::addColumn("size"); QTest::addColumn("capacity"); @@ -1362,7 +1362,7 @@ void tst_QArrayData::setSharable_data() void tst_QArrayData::setSharable() { -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QFETCH(QArrayDataPointer, array); QFETCH(size_t, size); QFETCH(size_t, capacity); @@ -1492,7 +1492,7 @@ void fromRawData_impl() QVERIFY((const T *)raw.constBegin() != array); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) { // Immutable, unsharable SimpleVector raw = SimpleVector::fromRawData(array, @@ -1578,7 +1578,7 @@ void tst_QArrayData::literals() QVERIFY(v.isStatic()); #endif -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QVERIFY(v.isSharable()); #endif QCOMPARE((void*)(const char*)(v.constBegin() + v.size()), (void*)(const char*)v.constEnd()); @@ -1629,7 +1629,7 @@ void tst_QArrayData::variadicLiterals() QVERIFY(v.isStatic()); -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QVERIFY(v.isSharable()); #endif QCOMPARE((const int *)(v.constBegin() + v.size()), (const int *)v.constEnd()); diff --git a/tests/auto/corelib/tools/qhash/tst_qhash.cpp b/tests/auto/corelib/tools/qhash/tst_qhash.cpp index 6a5c6b5670..d485040a14 100644 --- a/tests/auto/corelib/tools/qhash/tst_qhash.cpp +++ b/tests/auto/corelib/tools/qhash/tst_qhash.cpp @@ -1191,7 +1191,7 @@ void tst_QHash::noNeedlessRehashes() void tst_QHash::const_shared_null() { QHash hash2; -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QHash hash1; hash1.setSharable(false); QVERIFY(hash1.isDetached()); diff --git a/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp b/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp index d3ace40164..848fdae445 100644 --- a/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp +++ b/tests/auto/corelib/tools/qlinkedlist/tst_qlinkedlist.cpp @@ -1027,7 +1027,7 @@ template void tst_QLinkedList::constSharedNull() const { QLinkedList list2; -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QLinkedList list1; list1.setSharable(false); QVERIFY(list1.isDetached()); @@ -1059,7 +1059,7 @@ void tst_QLinkedList::constSharedNullComplex() const void tst_QLinkedList::setSharableInt() const { -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QLinkedList orglist; orglist << 0 << 1 << 2 << 3 << 4 << 5; int size = 6; diff --git a/tests/auto/corelib/tools/qlist/tst_qlist.cpp b/tests/auto/corelib/tools/qlist/tst_qlist.cpp index 1bb31afa9c..87f0012002 100644 --- a/tests/auto/corelib/tools/qlist/tst_qlist.cpp +++ b/tests/auto/corelib/tools/qlist/tst_qlist.cpp @@ -1892,7 +1892,7 @@ template void tst_QList::constSharedNull() const { QList list2; -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QList list1; list1.setSharable(false); QVERIFY(list1.isDetached()); @@ -1926,7 +1926,7 @@ void tst_QList::constSharedNullComplex() const template void generateSetSharableData() { -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QTest::addColumn >("list"); QTest::addColumn("size"); @@ -1938,7 +1938,7 @@ void generateSetSharableData() template void runSetSharableTest() { -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QFETCH(QList, list); QFETCH(int, size); diff --git a/tests/auto/corelib/tools/qmap/tst_qmap.cpp b/tests/auto/corelib/tools/qmap/tst_qmap.cpp index bb6535b635..1fb9dc6d7d 100644 --- a/tests/auto/corelib/tools/qmap/tst_qmap.cpp +++ b/tests/auto/corelib/tools/qmap/tst_qmap.cpp @@ -1012,7 +1012,7 @@ void tst_QMap::qmultimap_specific() void tst_QMap::const_shared_null() { QMap map2; -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QMap map1; map1.setSharable(false); QVERIFY(map1.isDetached()); @@ -1109,7 +1109,7 @@ const T &const_(const T &t) void tst_QMap::setSharable() { -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) QMap map; map.insert(1, "um"); diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp index 87822bca6f..edcf4c72b6 100644 --- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp +++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp @@ -431,7 +431,7 @@ void tst_QVector::copyConstructor() const QVector v2(v1); QCOMPARE(v1, v2); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section { QVector v1; @@ -595,7 +595,7 @@ void tst_QVector::append() const QVERIFY(v.size() == 3); QCOMPARE(v.at(v.size() - 1), SimpleValue::at(0)); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section { QVector v(2); @@ -930,7 +930,7 @@ void tst_QVector::eraseEmpty() const v.erase(v.begin(), v.end()); QCOMPARE(v.size(), 0); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section { QVector v; @@ -969,7 +969,7 @@ void tst_QVector::eraseEmptyReserved() const v.erase(v.begin(), v.end()); QCOMPARE(v.size(), 0); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section { QVector v; @@ -1085,7 +1085,7 @@ void tst_QVector::erase(bool shared) const if (shared) QCOMPARE(SimpleValue::vector(12), *svc.copy); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section { QVector v = SimpleValue::vector(10); @@ -1172,7 +1172,7 @@ template void tst_QVector::eraseReserved() const v.erase(v.begin() + 1, v.end() - 1); QCOMPARE(v.size(), 2); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section { QVector v(10); @@ -1907,7 +1907,7 @@ void tst_QVector::resizePOD_data() const QTest::newRow("nonEmpty") << nonEmpty << 10; QTest::newRow("nonEmptyReserved") << nonEmptyReserved << 10; -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section QVector nullNotShared; QVector emptyNotShared(0, 5); @@ -1982,7 +1982,7 @@ void tst_QVector::resizeComplexMovable_data() const QTest::newRow("nonEmpty") << nonEmpty << 10; QTest::newRow("nonEmptyReserved") << nonEmptyReserved << 10; -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section QVector nullNotShared; QVector emptyNotShared(0, 'Q'); @@ -2061,7 +2061,7 @@ void tst_QVector::resizeComplex_data() const QTest::newRow("nonEmpty") << nonEmpty << 10; QTest::newRow("nonEmptyReserved") << nonEmptyReserved << 10; -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section QVector nullNotShared; QVector emptyNotShared(0, '0'); @@ -2500,7 +2500,7 @@ void tst_QVector::initializeListCustom() void tst_QVector::const_shared_null() { QVector v2; -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section QVector v1; v1.setSharable(false); @@ -2511,7 +2511,7 @@ void tst_QVector::const_shared_null() QVERIFY(!v2.isDetached()); } -#if QT_SUPPORTS(UNSHARABLE_CONTAINERS) +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) // ### Qt6 remove this section template void tst_QVector::setSharable_data() const -- cgit v1.2.3