From 8a486dac25c84840907cfe842ca4227eabb46094 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Wed, 28 Nov 2018 18:16:02 +0000 Subject: Move internal usages of `alignof`/`__alignof` to use `_LIBCPP_ALIGNOF`. Summary: Starting in Clang 8.0 and GCC 8.0, `alignof` and `__alignof` return different values in same cases. Specifically `alignof` and `_Alignof` return the minimum alignment for a type, where as `__alignof` returns the preferred alignment. libc++ currently uses `__alignof` but means to use `alignof`. See llvm.org/PR39713 This patch introduces the macro `_LIBCPP_ALIGNOF` so we can control which spelling gets used. This patch does not introduce any ABI guard to provide the old behavior with newer compilers. However, if we decide that is needed, this patch makes it trivial to implement. I think we should commit this change immediately, and decide what we want to do about the ABI afterwards. Reviewers: ldionne, EricWF Reviewed By: EricWF Subscribers: christof, libcxx-commits Differential Revision: https://reviews.llvm.org/D54814 llvm-svn: 347787 --- libcxx/test/support/test_macros.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'libcxx/test/support') diff --git a/libcxx/test/support/test_macros.h b/libcxx/test/support/test_macros.h index 88cc4d5cacc..cee8a38d9f0 100644 --- a/libcxx/test/support/test_macros.h +++ b/libcxx/test/support/test_macros.h @@ -115,7 +115,11 @@ # define TEST_THROW_SPEC(...) throw(__VA_ARGS__) # endif #else -#define TEST_ALIGNOF(...) __alignof(__VA_ARGS__) +#if defined(TEST_COMPILER_CLANG) +# define TEST_ALIGNOF(...) _Alignof(__VA_ARGS__) +#else +# define TEST_ALIGNOF(...) __alignof(__VA_ARGS__) +#endif #define TEST_ALIGNAS(...) __attribute__((__aligned__(__VA_ARGS__))) #define TEST_CONSTEXPR #define TEST_CONSTEXPR_CXX14 -- cgit v1.2.3