From 831c1129547c973c59ccb957ed9fe0cf74102477 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Tue, 15 Dec 2015 00:32:21 +0000 Subject: [PATCH] Fix various GCC mis-configurations for newer versions. This patch goes through and enables C++11 and C++14 features for newer GCC's. The main changes are: 1. Turn on variable templates. (Uses __cpp_variable_templates) 2. Assert atomic is trivially copyable (Uses _GNUC_VER >= 501). 3. Turn on trailing return support for GCC. (Uses _GNUC_VER >= 404) 4. XFAIL void_t test for GCC 5.1 and 5.2. Fixed in GCC 6. llvm-svn: 255585 --- libcxx/include/__config | 4 +++- libcxx/include/atomic | 6 ++++++ .../atomics.types.generic/trivially_copyable.fail.cpp | 6 +++--- .../utilities/meta/meta.unary.prop.query/void_t.pass.cpp | 9 ++++----- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/libcxx/include/__config b/libcxx/include/__config index 211b5e9ff5a8..ec44f763910b 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -472,7 +472,9 @@ namespace std { #endif // GCC 5 will support variable templates +#if !defined(__cpp_variable_templates) || __cpp_variable_templates < 201304L #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES +#endif #define _NOEXCEPT throw() #define _NOEXCEPT_(x) @@ -494,7 +496,6 @@ namespace std { #else // __GXX_EXPERIMENTAL_CXX0X__ -#define _LIBCPP_HAS_NO_TRAILING_RETURN #define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS #if _GNUC_VER < 403 @@ -508,6 +509,7 @@ namespace std { #if _GNUC_VER < 404 #define _LIBCPP_HAS_NO_DECLTYPE #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS +#define _LIBCPP_HAS_NO_TRAILING_RETURN #define _LIBCPP_HAS_NO_UNICODE_CHARS #define _LIBCPP_HAS_NO_VARIADICS #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS diff --git a/libcxx/include/atomic b/libcxx/include/atomic index b5d5a27b0418..abec2a0b565a 100644 --- a/libcxx/include/atomic +++ b/libcxx/include/atomic @@ -552,6 +552,12 @@ typedef enum memory_order namespace __gcc_atomic { template struct __gcc_atomic_t { + +#if _GNUC_VER >= 501 + static_assert(is_trivially_copyable<_Tp>::value, + "std::atomic requires that 'Tp' be a trivially copyable type"); +#endif + _LIBCPP_INLINE_VISIBILITY #ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS __gcc_atomic_t() _NOEXCEPT = default; diff --git a/libcxx/test/std/atomics/atomics.types.generic/trivially_copyable.fail.cpp b/libcxx/test/std/atomics/atomics.types.generic/trivially_copyable.fail.cpp index f2bf4db0de48..d940980e32f0 100644 --- a/libcxx/test/std/atomics/atomics.types.generic/trivially_copyable.fail.cpp +++ b/libcxx/test/std/atomics/atomics.types.generic/trivially_copyable.fail.cpp @@ -57,12 +57,12 @@ struct NotTriviallyCopyable { NotTriviallyCopyable ( int i ) : i_(i) {} NotTriviallyCopyable ( const NotTriviallyCopyable &rhs) : i_(rhs.i_) {} int i_; - }; +}; -template +template void test ( T t ) { std::atomic t0(t); - } +} int main() { diff --git a/libcxx/test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp index 5deeeff110d4..ccec65fec399 100644 --- a/libcxx/test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp +++ b/libcxx/test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp @@ -11,11 +11,11 @@ // void_t -#include +// UNSUPPORTED: c++98, c++03, c++11, c++14 -#if _LIBCPP_STD_VER <= 14 -int main () {} -#else +// XFAIL: gcc-5.1 gcc-5.2 + +#include template void test1() @@ -66,4 +66,3 @@ int main() static_assert( std::is_same>::value, ""); } -#endif