diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2019-10-21 15:19:18 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2019-10-29 10:37:02 +0100 |
commit | 226a60baf50c9c91a98c01c3dd9c0ced750f8d0e (patch) | |
tree | d9c57735a34f963eaafbe895f094d0009d262408 /tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp | |
parent | 8bcecd86fac60475a7236787b4b89460fa89d612 (diff) |
Replace Q_ALIGNOF usage in qtbase with C++11 alignof keyword
The macro is not documented, so not part of the public Qt API. It is
made obsolete by the alignof keyword in C++11.
Remove the usage of the macro across qtbase, in particular the
workarounds for compilers that didn't support alignof, and that will
not be supported in Qt 6.
The macro definition is left in place, no need to break existing
code.
Task-number: QTBUG-76414
Change-Id: I1cfedcd4dd748128696cdfb546d97aae4f98c3da
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp')
-rw-r--r-- | tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp index 25e2f21d03..12752e4d07 100644 --- a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp +++ b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp @@ -160,7 +160,7 @@ void tst_QArrayData::referenceCounting() void tst_QArrayData::sharedNullEmpty() { QArrayData *null = const_cast<QArrayData *>(QArrayData::shared_null); - QArrayData *empty = QArrayData::allocate(1, Q_ALIGNOF(QArrayData), 0); + QArrayData *empty = QArrayData::allocate(1, alignof(QArrayData), 0); QVERIFY(null->ref.isStatic()); QVERIFY(null->ref.isShared()); @@ -657,16 +657,16 @@ void tst_QArrayData::allocate_data() size_t objectSize; size_t alignment; } types[] = { - { "char", sizeof(char), Q_ALIGNOF(char) }, - { "short", sizeof(short), Q_ALIGNOF(short) }, - { "void *", sizeof(void *), Q_ALIGNOF(void *) } + { "char", sizeof(char), alignof(char) }, + { "short", sizeof(short), alignof(short) }, + { "void *", sizeof(void *), alignof(void *) } }; - QArrayData *shared_empty = QArrayData::allocate(0, Q_ALIGNOF(QArrayData), 0); + QArrayData *shared_empty = QArrayData::allocate(0, alignof(QArrayData), 0); QVERIFY(shared_empty); #if !defined(QT_NO_UNSHARABLE_CONTAINERS) - QArrayData *unsharable_empty = QArrayData::allocate(0, Q_ALIGNOF(QArrayData), 0, QArrayData::Unsharable); + QArrayData *unsharable_empty = QArrayData::allocate(0, alignof(QArrayData), 0, QArrayData::Unsharable); QVERIFY(unsharable_empty); #endif @@ -709,7 +709,7 @@ void tst_QArrayData::allocate() // Minimum alignment that can be requested is that of QArrayData. // Typically, this alignment is sizeof(void *) and ensured by malloc. - size_t minAlignment = qMax(alignment, Q_ALIGNOF(QArrayData)); + size_t minAlignment = qMax(alignment, alignof(QArrayData)); // Shared Empty QCOMPARE(QArrayData::allocate(objectSize, minAlignment, 0, @@ -749,11 +749,11 @@ void tst_QArrayData::reallocate() // Maximum alignment that can be requested is that of QArrayData, // otherwise, we can't use reallocate(). - Q_ASSERT(alignment <= Q_ALIGNOF(QArrayData)); + Q_ASSERT(alignment <= alignof(QArrayData)); // Minimum alignment that can be requested is that of QArrayData. // Typically, this alignment is sizeof(void *) and ensured by malloc. - size_t minAlignment = qMax(alignment, Q_ALIGNOF(QArrayData)); + size_t minAlignment = qMax(alignment, alignof(QArrayData)); int capacity = 10; Deallocator keeper(objectSize, minAlignment); @@ -808,7 +808,7 @@ void tst_QArrayData::alignment() // Minimum alignment that can be requested is that of QArrayData. // Typically, this alignment is sizeof(void *) and ensured by malloc. - size_t minAlignment = qMax(alignment, Q_ALIGNOF(QArrayData)); + size_t minAlignment = qMax(alignment, alignof(QArrayData)); Deallocator keeper(sizeof(Unaligned), minAlignment); keeper.headers.reserve(100); @@ -826,7 +826,7 @@ void tst_QArrayData::alignment() // allocated together QVERIFY(data->offset >= qptrdiff(sizeof(QArrayData))); QVERIFY(data->offset <= qptrdiff(sizeof(QArrayData) - + minAlignment - Q_ALIGNOF(QArrayData))); + + minAlignment - alignof(QArrayData))); // Data is aligned QCOMPARE(quintptr(quintptr(data->data()) % alignment), quintptr(0u)); @@ -886,7 +886,7 @@ void tst_QArrayData::typedData() { Deallocator keeper(sizeof(char), - Q_ALIGNOF(QTypedArrayData<char>::AlignmentDummy)); + alignof(QTypedArrayData<char>::AlignmentDummy)); QArrayData *array = QTypedArrayData<char>::allocate(10); keeper.headers.append(array); @@ -906,7 +906,7 @@ void tst_QArrayData::typedData() { Deallocator keeper(sizeof(short), - Q_ALIGNOF(QTypedArrayData<short>::AlignmentDummy)); + alignof(QTypedArrayData<short>::AlignmentDummy)); QArrayData *array = QTypedArrayData<short>::allocate(10); keeper.headers.append(array); @@ -926,7 +926,7 @@ void tst_QArrayData::typedData() { Deallocator keeper(sizeof(double), - Q_ALIGNOF(QTypedArrayData<double>::AlignmentDummy)); + alignof(QTypedArrayData<double>::AlignmentDummy)); QArrayData *array = QTypedArrayData<double>::allocate(10); keeper.headers.append(array); |