From fe9390e7a12d76b1498f684e4150735ef7986f3e Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Fri, 9 Oct 2015 21:04:28 +0000 Subject: [PATCH] Pull in r242623 from upstream libc++ trunk (by Eric Fiselier): Enable and fix warnings during the build. Although CMake adds warning flags, they are ignored in the libc++ headers because the headers '#pragma system header' themselves. This patch disables the system header pragma when building libc++ and fixes the warnings that arose. The warnings fixed were: 1. - anonymous structs are a GNU extension 2. - anonymous structs are a GNU extension. 3. <__hash_table> - Embedded preprocessor directives have undefined behavior. 4. - Definition is missing noexcept from declaration. 5. <__std_stream> - Unused variable. This should fix building world (in particular libatf-c++) with -std=c++11. Reported by: Oliver Hartmann --- contrib/libc++/include/__hash_table | 12 ++++++++---- contrib/libc++/include/__std_stream | 1 - contrib/libc++/include/functional | 20 ++++++++++---------- contrib/libc++/include/memory | 6 +++--- contrib/libc++/include/string | 7 ++++++- 5 files changed, 27 insertions(+), 19 deletions(-) diff --git a/contrib/libc++/include/__hash_table b/contrib/libc++/include/__hash_table index f3a20309df71..ec20e10fcb57 100644 --- a/contrib/libc++/include/__hash_table +++ b/contrib/libc++/include/__hash_table @@ -984,15 +984,17 @@ public: __equal_range_multi(const _Key& __k) const; void swap(__hash_table& __u) +#if _LIBCPP_STD_VER <= 11 _NOEXCEPT_( __is_nothrow_swappable::value && __is_nothrow_swappable::value -#if _LIBCPP_STD_VER <= 11 && (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value || __is_nothrow_swappable<__pointer_allocator>::value) && (!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable<__node_allocator>::value) -#endif ); +#else + _NOEXCEPT_(__is_nothrow_swappable::value && __is_nothrow_swappable::value); +#endif _LIBCPP_INLINE_VISIBILITY size_type max_bucket_count() const _NOEXCEPT @@ -2351,15 +2353,17 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_multi( template void __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u) +#if _LIBCPP_STD_VER <= 11 _NOEXCEPT_( __is_nothrow_swappable::value && __is_nothrow_swappable::value -#if _LIBCPP_STD_VER <= 11 && (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value || __is_nothrow_swappable<__pointer_allocator>::value) && (!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable<__node_allocator>::value) -#endif ) +#else + _NOEXCEPT_(__is_nothrow_swappable::value && __is_nothrow_swappable::value) +#endif { { __node_pointer_pointer __npp = __bucket_list_.release(); diff --git a/contrib/libc++/include/__std_stream b/contrib/libc++/include/__std_stream index 5403adabc343..f867cd23bdd5 100644 --- a/contrib/libc++/include/__std_stream +++ b/contrib/libc++/include/__std_stream @@ -276,7 +276,6 @@ __stdoutbuf<_CharT>::overflow(int_type __c) codecvt_base::result __r; char_type* pbase = &__1buf; char_type* pptr = pbase + 1; - char_type* epptr = pptr; do { const char_type* __e; diff --git a/contrib/libc++/include/functional b/contrib/libc++/include/functional index 5ee941763020..9bed783153ef 100644 --- a/contrib/libc++/include/functional +++ b/contrib/libc++/include/functional @@ -2402,14 +2402,14 @@ struct _LIBCPP_TYPE_VIS_ONLY hash size_t __b; size_t __c; size_t __d; - }; + } __s; } __u; - __u.__a = 0; - __u.__b = 0; - __u.__c = 0; - __u.__d = 0; + __u.__s.__a = 0; + __u.__s.__b = 0; + __u.__s.__c = 0; + __u.__s.__d = 0; __u.__t = __v; - return __u.__a ^ __u.__b ^ __u.__c ^ __u.__d; + return __u.__s.__a ^ __u.__s.__b ^ __u.__s.__c ^ __u.__s.__d; #elif defined(__x86_64__) // Zero out padding bits union @@ -2419,12 +2419,12 @@ struct _LIBCPP_TYPE_VIS_ONLY hash { size_t __a; size_t __b; - }; + } __s; } __u; - __u.__a = 0; - __u.__b = 0; + __u.__s.__a = 0; + __u.__s.__b = 0; __u.__t = __v; - return __u.__a ^ __u.__b; + return __u.__s.__a ^ __u.__s.__b; #else return __scalar_hash::operator()(__v); #endif diff --git a/contrib/libc++/include/memory b/contrib/libc++/include/memory index 22311aaace92..df35a07143ce 100644 --- a/contrib/libc++/include/memory +++ b/contrib/libc++/include/memory @@ -3420,7 +3420,7 @@ struct __scalar_hash<_Tp, 2> { size_t __a; size_t __b; - }; + } __s; } __u; __u.__t = __v; return __murmur2_or_cityhash()(&__u, sizeof(__u)); @@ -3442,7 +3442,7 @@ struct __scalar_hash<_Tp, 3> size_t __a; size_t __b; size_t __c; - }; + } __s; } __u; __u.__t = __v; return __murmur2_or_cityhash()(&__u, sizeof(__u)); @@ -3465,7 +3465,7 @@ struct __scalar_hash<_Tp, 4> size_t __b; size_t __c; size_t __d; - }; + } __s; } __u; __u.__t = __v; return __murmur2_or_cityhash()(&__u, sizeof(__u)); diff --git a/contrib/libc++/include/string b/contrib/libc++/include/string index 6be21955b146..5777ee2a547b 100644 --- a/contrib/libc++/include/string +++ b/contrib/libc++/include/string @@ -1936,7 +1936,12 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string() template inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __a) - : __r_(__a) +#if _LIBCPP_STD_VER <= 14 + _NOEXCEPT_(is_nothrow_copy_constructible::value) +#else + _NOEXCEPT +#endif +: __r_(__a) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this);