From: Jonathan Wakely Date: Tue, 5 Feb 2019 14:44:56 +0000 (+0000) Subject: PR libstdc++/89090 avoid C++17 features in C++11/C++14 code X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2781287255a16b6f2db18c68d02c3f40004332a7;p=gcc.git PR libstdc++/89090 avoid C++17 features in C++11/C++14 code Although GCC and Clang both allow these features pre-C++17 in system headers, Clang does issue warnings with -Wsystem-headers. It can also complicate bisection and/or testcase reduction if # line markers are stripped, because the code won't be known to come from system headers. PR libstdc++/89090 * include/bits/stl_uninitialized.h (__relocate_a_1): Make unused parameter unnamed. Add message to static assertion. * include/bits/vector.tcc (vector::reserve, vector::_M_realloc_insert) (vector::_M_default_append): Use _GLIBCXX17_CONSTEXPR for if constexpr in C++11 code. From-SVN: r268536 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index a3c0002d8bd..ff847f86d6a 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,12 @@ +2019-02-05 Jonathan Wakely + + PR libstdc++/89090 + * include/bits/stl_uninitialized.h (__relocate_a_1): Make unused + parameter unnamed. Add message to static assertion. + * include/bits/vector.tcc (vector::reserve, vector::_M_realloc_insert) + (vector::_M_default_append): Use _GLIBCXX17_CONSTEXPR for if constexpr + in C++11 code. + 2019-02-05 Marc Glisse PR libstdc++/87106 diff --git a/libstdc++-v3/include/bits/stl_uninitialized.h b/libstdc++-v3/include/bits/stl_uninitialized.h index 03ed16b8c1a..0d42b253df1 100644 --- a/libstdc++-v3/include/bits/stl_uninitialized.h +++ b/libstdc++-v3/include/bits/stl_uninitialized.h @@ -904,7 +904,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template inline __enable_if_t::value, _Tp*> __relocate_a_1(_Tp* __first, _Tp* __last, - _Tp* __result, allocator<_Up>& __alloc) noexcept + _Tp* __result, allocator<_Up>&) noexcept { ptrdiff_t __count = __last - __first; if (__count > 0) @@ -925,7 +925,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _ValueType; typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType2; - static_assert(std::is_same<_ValueType, _ValueType2>::value); + static_assert(std::is_same<_ValueType, _ValueType2>::value, + "relocation is only possible for values of the same type"); _ForwardIterator __cur = __result; for (; __first != __last; ++__first, (void)++__cur) std::__relocate_object_a(std::__addressof(*__cur), diff --git a/libstdc++-v3/include/bits/vector.tcc b/libstdc++-v3/include/bits/vector.tcc index 4cf0e809fe9..54c09774b15 100644 --- a/libstdc++-v3/include/bits/vector.tcc +++ b/libstdc++-v3/include/bits/vector.tcc @@ -73,7 +73,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER const size_type __old_size = size(); pointer __tmp; #if __cplusplus >= 201103L - if constexpr (_S_use_relocate()) + if _GLIBCXX17_CONSTEXPR (_S_use_relocate()) { __tmp = this->_M_allocate(__n); std::__relocate_a(this->_M_impl._M_start, @@ -457,7 +457,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER __new_finish = pointer(); #if __cplusplus >= 201103L - if constexpr (_S_use_relocate()) + if _GLIBCXX17_CONSTEXPR (_S_use_relocate()) { __new_finish = std::__relocate_a @@ -498,7 +498,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER __throw_exception_again; } #if __cplusplus >= 201103L - if constexpr (!_S_use_relocate()) + if _GLIBCXX17_CONSTEXPR (!_S_use_relocate()) #endif std::_Destroy(__old_start, __old_finish, _M_get_Tp_allocator()); _GLIBCXX_ASAN_ANNOTATE_REINIT; @@ -638,8 +638,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER const size_type __len = _M_check_len(__n, "vector::_M_default_append"); pointer __new_start(this->_M_allocate(__len)); -#if __cplusplus >= 201103L - if constexpr (_S_use_relocate()) + if _GLIBCXX17_CONSTEXPR (_S_use_relocate()) { __try { @@ -656,7 +655,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER __new_start, _M_get_Tp_allocator()); } else -#endif { pointer __destroy_from = pointer(); __try