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/global | |
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/global')
-rw-r--r-- | tests/auto/corelib/global/qglobal/tst_qglobal.cpp | 101 |
1 files changed, 0 insertions, 101 deletions
diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index b33dec8a61..047130d5ea 100644 --- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp +++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp @@ -49,7 +49,6 @@ private slots: void qConstructorFunction(); void qCoreAppStartupFunction(); void qCoreAppStartupFunctionRestart(); - void qAlignOf(); void integerForSize(); void qprintable(); void qprintable_data(); @@ -434,106 +433,6 @@ template <class T> struct AlignmentInStruct { T dummy; }; typedef int (*fun) (); typedef int (Empty::*memFun) (); -#define TEST_AlignOf(type, alignment) \ - do { \ - TEST_AlignOf_impl(type, alignment); \ - \ - TEST_AlignOf_impl(type &, alignment); \ - TEST_AlignOf_RValueRef(type &&, alignment); \ - \ - TEST_AlignOf_impl(type [5], alignment); \ - TEST_AlignOf_impl(type (&) [5], alignment); \ - \ - TEST_AlignOf_impl(AlignmentInStruct<type>, alignment); \ - \ - /* Some internal sanity validation, just for fun */ \ - TEST_AlignOf_impl(AlignmentInStruct<type [5]>, alignment); \ - TEST_AlignOf_impl(AlignmentInStruct<type &>, Q_ALIGNOF(void *)); \ - TEST_AlignOf_impl(AlignmentInStruct<type (&) [5]>, \ - Q_ALIGNOF(void *)); \ - TEST_AlignOf_RValueRef(AlignmentInStruct<type &&>, \ - Q_ALIGNOF(void *)); \ - } while (false) \ - /**/ - -#define TEST_AlignOf_RValueRef(type, alignment) \ - TEST_AlignOf_impl(type, alignment) - -#define TEST_AlignOf_impl(type, alignment) \ - do { \ - QCOMPARE(Q_ALIGNOF(type), size_t(alignment)); \ - /* Compare to native operator for compilers that support it, - otherwise... erm... check consistency! :-) */ \ - QCOMPARE(alignof(type), Q_ALIGNOF(type)); \ - } while (false) - /**/ - -void tst_QGlobal::qAlignOf() -{ - // Built-in types, except 64-bit integers and double - TEST_AlignOf(char, 1); - TEST_AlignOf(signed char, 1); - TEST_AlignOf(unsigned char, 1); - TEST_AlignOf(qint8, 1); - TEST_AlignOf(quint8, 1); - TEST_AlignOf(qint16, 2); - TEST_AlignOf(quint16, 2); - TEST_AlignOf(qint32, 4); - TEST_AlignOf(quint32, 4); - TEST_AlignOf(void *, sizeof(void *)); - - // Depends on platform and compiler, disabling test for now - // TEST_AlignOf(long double, 16); - - // Empty struct - TEST_AlignOf(Empty, 1); - - // Function pointers - TEST_AlignOf(fun, Q_ALIGNOF(void *)); - TEST_AlignOf(memFun, Q_ALIGNOF(void *)); - - - // 64-bit integers and double - TEST_AlignOf_impl(qint64, 8); - TEST_AlignOf_impl(quint64, 8); - TEST_AlignOf_impl(double, 8); - - TEST_AlignOf_impl(qint64 &, 8); - TEST_AlignOf_impl(quint64 &, 8); - TEST_AlignOf_impl(double &, 8); - - TEST_AlignOf_RValueRef(qint64 &&, 8); - TEST_AlignOf_RValueRef(quint64 &&, 8); - TEST_AlignOf_RValueRef(double &&, 8); - - // 32-bit x86 ABI idiosyncrasies -#if defined(Q_PROCESSOR_X86_32) && !defined(Q_OS_WIN) - TEST_AlignOf_impl(AlignmentInStruct<qint64>, 4); -#else - TEST_AlignOf_impl(AlignmentInStruct<qint64>, 8); -#endif - - TEST_AlignOf_impl(AlignmentInStruct<quint64>, Q_ALIGNOF(AlignmentInStruct<qint64>)); - TEST_AlignOf_impl(AlignmentInStruct<double>, Q_ALIGNOF(AlignmentInStruct<qint64>)); - - // 32-bit x86 ABI, Clang disagrees with gcc -#if !defined(Q_PROCESSOR_X86_32) || !defined(Q_CC_CLANG) || defined(Q_OS_ANDROID) - TEST_AlignOf_impl(qint64 [5], Q_ALIGNOF(qint64)); -#else - TEST_AlignOf_impl(qint64 [5], Q_ALIGNOF(AlignmentInStruct<qint64>)); -#endif - - TEST_AlignOf_impl(qint64 (&) [5], Q_ALIGNOF(qint64 [5])); - TEST_AlignOf_impl(quint64 [5], Q_ALIGNOF(quint64 [5])); - TEST_AlignOf_impl(quint64 (&) [5], Q_ALIGNOF(quint64 [5])); - TEST_AlignOf_impl(double [5], Q_ALIGNOF(double [5])); - TEST_AlignOf_impl(double (&) [5], Q_ALIGNOF(double [5])); -} - -#undef TEST_AlignOf -#undef TEST_AlignOf_RValueRef -#undef TEST_AlignOf_impl - void tst_QGlobal::integerForSize() { // compile-only test: |