Force the use of the C++11 alignof keyword instead of an extension
If the compiler supports C++11 alignof, let's use it. No point in perpetuating the use of __alignof__ or __alignof. There's a fallback implementation in qglobal.h that works even without compiler extensions. We can't drop it just yet (alignas is not a required C++11 feature), but at this point I doubt that fallback is used anywhere anymore. The tst_compiler test was wrong to use alignof(variable). That's not permitted by the standard nor would it work with our fallback implementation. MSVC 2015 enforces this, but ICC, GCC and Clang don't. Change-Id: Ifea6e497f11a461db432ffff1448abfa86672c63 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>bb10
parent
9e9888f69a
commit
0f559a2d99
|
|
@ -1053,7 +1053,8 @@
|
|||
# define Q_DECL_NOTHROW Q_DECL_NOEXCEPT
|
||||
#endif
|
||||
|
||||
#if defined(Q_COMPILER_ALIGNOF) && !defined(Q_ALIGNOF)
|
||||
#if defined(Q_COMPILER_ALIGNOF)
|
||||
# undef Q_ALIGNOF
|
||||
# define Q_ALIGNOF(x) alignof(x)
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -636,9 +636,10 @@ void tst_Compiler::cxx11_alignas()
|
|||
#ifndef Q_COMPILER_ALIGNAS
|
||||
QSKIP("Compiler does not support C++11 feature");
|
||||
#else
|
||||
alignas(double) char c;
|
||||
Q_UNUSED(c);
|
||||
QCOMPARE(Q_ALIGNOF(c), Q_ALIGNOF(double));
|
||||
struct S {
|
||||
alignas(double) char c;
|
||||
};
|
||||
QCOMPARE(Q_ALIGNOF(S), Q_ALIGNOF(double));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue