summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/global/qcompilerdetection.h3
-rw-r--r--tests/auto/other/compiler/tst_compiler.cpp7
2 files changed, 6 insertions, 4 deletions
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index ad881ef4c9..01b3a298af 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -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
diff --git a/tests/auto/other/compiler/tst_compiler.cpp b/tests/auto/other/compiler/tst_compiler.cpp
index 540c155fd8..8cd25bf164 100644
--- a/tests/auto/other/compiler/tst_compiler.cpp
+++ b/tests/auto/other/compiler/tst_compiler.cpp
@@ -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
}