From f07c22376848e9923aa8455d2c0a059d9d0e01d5 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 18 May 2018 16:02:14 -0400 Subject: [PATCH] Some libstdc++ fixes for -Wdeprecated-copy. * include/bits/stl_deque.h (_Deque_iterator): Constrain constructor for conversion to const_iterator. Add defaulted copy ops. * libsupc++/new (bad_alloc): Add defaulted copy ops. * libsupc++/exception.h (exception): Add defaulted copy ops. * include/std/system_error (system_error): Add defaulted copy ops. * include/std/stdexcept (domain_error, invalid_argument) (length_error, out_of_range, range_error, overflow_error) (underflow_error): Add defaulted copy ops. * include/bits/stl_iterator.h (reverse_iterator): Add defaulted copy assignment. * include/bits/allocator.h (allocator): Add defaulted copy assignment. * include/ext/throw_allocator.h (condition_base): Add defaulted default and copy ctor and copy assignment. From-SVN: r260380 --- gcc/testsuite/g++.dg/cpp0x/Wattributes1.C | 2 +- libstdc++-v3/ChangeLog | 16 ++++++++++++++++ libstdc++-v3/include/bits/allocator.h | 4 ++++ libstdc++-v3/include/bits/stl_deque.h | 14 ++++++++++++++ libstdc++-v3/include/bits/stl_iterator.h | 4 ++++ libstdc++-v3/include/ext/throw_allocator.h | 5 +++++ libstdc++-v3/include/std/stdexcept | 14 ++++++++++++++ libstdc++-v3/include/std/system_error | 5 +++++ libstdc++-v3/libsupc++/exception.h | 4 ++++ libstdc++-v3/libsupc++/new | 5 +++++ 10 files changed, 72 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/g++.dg/cpp0x/Wattributes1.C b/gcc/testsuite/g++.dg/cpp0x/Wattributes1.C index b0a1e864eff..b1c48d42349 100644 --- a/gcc/testsuite/g++.dg/cpp0x/Wattributes1.C +++ b/gcc/testsuite/g++.dg/cpp0x/Wattributes1.C @@ -5,4 +5,4 @@ #include __attribute__((visibility("hidden")))void*operator new(std::size_t); // { dg-warning "visibility attribute ignored" } -// { dg-message "previous declaration" "" { target *-*-* } 120 } +// { dg-message "previous declaration" "" { target *-*-* } 125 } diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 2ccf585dddc..c4e10f11b5f 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,19 @@ +2018-05-18 Jason Merrill + + * include/bits/stl_deque.h (_Deque_iterator): Constrain constructor + for conversion to const_iterator. Add defaulted copy ops. + * libsupc++/new (bad_alloc): Add defaulted copy ops. + * libsupc++/exception.h (exception): Add defaulted copy ops. + * include/std/system_error (system_error): Add defaulted copy ops. + * include/std/stdexcept (domain_error, invalid_argument) + (length_error, out_of_range, range_error, overflow_error) + (underflow_error): Add defaulted copy ops. + * include/bits/stl_iterator.h (reverse_iterator): Add defaulted + copy assignment. + * include/bits/allocator.h (allocator): Add defaulted copy assignment. + * include/ext/throw_allocator.h (condition_base): Add defaulted + default and copy ctor and copy assignment. + 2018-05-18 Jonathan Wakely PR libstdc++/85098 diff --git a/libstdc++-v3/include/bits/allocator.h b/libstdc++-v3/include/bits/allocator.h index 0a4eb55f611..2da499f1498 100644 --- a/libstdc++-v3/include/bits/allocator.h +++ b/libstdc++-v3/include/bits/allocator.h @@ -132,6 +132,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION allocator(const allocator& __a) throw() : __allocator_base<_Tp>(__a) { } +#if __cplusplus >= 201103L + // Avoid implicit deprecation. + allocator& operator=(const allocator&) = default; +#endif template allocator(const allocator<_Tp1>&) throw() { } diff --git a/libstdc++-v3/include/bits/stl_deque.h b/libstdc++-v3/include/bits/stl_deque.h index 0d4390b2929..58a01c894c0 100644 --- a/libstdc++-v3/include/bits/stl_deque.h +++ b/libstdc++-v3/include/bits/stl_deque.h @@ -149,9 +149,23 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _Deque_iterator() _GLIBCXX_NOEXCEPT : _M_cur(), _M_first(), _M_last(), _M_node() { } +#if __cplusplus < 201103L + // Conversion from iterator to const_iterator. _Deque_iterator(const iterator& __x) _GLIBCXX_NOEXCEPT : _M_cur(__x._M_cur), _M_first(__x._M_first), _M_last(__x._M_last), _M_node(__x._M_node) { } +#else + // Conversion from iterator to const_iterator. + template, + is_same<_Iter, iterator>>> + _Deque_iterator(const _Iter& __x) noexcept + : _M_cur(__x._M_cur), _M_first(__x._M_first), + _M_last(__x._M_last), _M_node(__x._M_node) { } + + _Deque_iterator(const _Deque_iterator&) = default; + _Deque_iterator& operator=(const _Deque_iterator&) = default; +#endif iterator _M_const_cast() const _GLIBCXX_NOEXCEPT diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h index 750b0c0f307..0d5f20bc2c6 100644 --- a/libstdc++-v3/include/bits/stl_iterator.h +++ b/libstdc++-v3/include/bits/stl_iterator.h @@ -138,6 +138,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION reverse_iterator(const reverse_iterator& __x) : current(__x.current) { } +#if __cplusplus >= 201103L + reverse_iterator& operator=(const reverse_iterator&) = default; +#endif + /** * A %reverse_iterator across other types can be copied if the * underlying %iterator can be converted to the type of @c current. diff --git a/libstdc++-v3/include/ext/throw_allocator.h b/libstdc++-v3/include/ext/throw_allocator.h index 5d9caa2bcae..7fd2ca149a0 100644 --- a/libstdc++-v3/include/ext/throw_allocator.h +++ b/libstdc++-v3/include/ext/throw_allocator.h @@ -402,6 +402,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION */ struct condition_base { +#if __cplusplus >= 201103L + condition_base() = default; + condition_base(const condition_base&) = default; + condition_base& operator=(const condition_base&) = default; +#endif virtual ~condition_base() { }; }; diff --git a/libstdc++-v3/include/std/stdexcept b/libstdc++-v3/include/std/stdexcept index ddc056f752f..5267e5692bf 100644 --- a/libstdc++-v3/include/std/stdexcept +++ b/libstdc++-v3/include/std/stdexcept @@ -150,6 +150,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION explicit domain_error(const string& __arg) _GLIBCXX_TXN_SAFE; #if __cplusplus >= 201103L explicit domain_error(const char*) _GLIBCXX_TXN_SAFE; + domain_error(const domain_error&) = default; + domain_error& operator=(const domain_error&) = default; #endif virtual ~domain_error() _GLIBCXX_USE_NOEXCEPT; }; @@ -161,6 +163,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION explicit invalid_argument(const string& __arg) _GLIBCXX_TXN_SAFE; #if __cplusplus >= 201103L explicit invalid_argument(const char*) _GLIBCXX_TXN_SAFE; + invalid_argument(const invalid_argument&) = default; + invalid_argument& operator=(const invalid_argument&) = default; #endif virtual ~invalid_argument() _GLIBCXX_USE_NOEXCEPT; }; @@ -173,6 +177,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION explicit length_error(const string& __arg) _GLIBCXX_TXN_SAFE; #if __cplusplus >= 201103L explicit length_error(const char*) _GLIBCXX_TXN_SAFE; + length_error(const length_error&) = default; + length_error& operator=(const length_error&) = default; #endif virtual ~length_error() _GLIBCXX_USE_NOEXCEPT; }; @@ -185,6 +191,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION explicit out_of_range(const string& __arg) _GLIBCXX_TXN_SAFE; #if __cplusplus >= 201103L explicit out_of_range(const char*) _GLIBCXX_TXN_SAFE; + out_of_range(const out_of_range&) = default; + out_of_range& operator=(const out_of_range&) = default; #endif virtual ~out_of_range() _GLIBCXX_USE_NOEXCEPT; }; @@ -233,6 +241,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION explicit range_error(const string& __arg) _GLIBCXX_TXN_SAFE; #if __cplusplus >= 201103L explicit range_error(const char*) _GLIBCXX_TXN_SAFE; + range_error(const range_error&) = default; + range_error& operator=(const range_error&) = default; #endif virtual ~range_error() _GLIBCXX_USE_NOEXCEPT; }; @@ -244,6 +254,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION explicit overflow_error(const string& __arg) _GLIBCXX_TXN_SAFE; #if __cplusplus >= 201103L explicit overflow_error(const char*) _GLIBCXX_TXN_SAFE; + overflow_error(const overflow_error&) = default; + overflow_error& operator=(const overflow_error&) = default; #endif virtual ~overflow_error() _GLIBCXX_USE_NOEXCEPT; }; @@ -255,6 +267,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION explicit underflow_error(const string& __arg) _GLIBCXX_TXN_SAFE; #if __cplusplus >= 201103L explicit underflow_error(const char*) _GLIBCXX_TXN_SAFE; + underflow_error(const underflow_error&) = default; + underflow_error& operator=(const underflow_error&) = default; #endif virtual ~underflow_error() _GLIBCXX_USE_NOEXCEPT; }; diff --git a/libstdc++-v3/include/std/system_error b/libstdc++-v3/include/std/system_error index 4918ef363d8..150ec025975 100644 --- a/libstdc++-v3/include/std/system_error +++ b/libstdc++-v3/include/std/system_error @@ -364,6 +364,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : runtime_error(__what + ": " + error_code(__v, __ecat).message()), _M_code(__v, __ecat) { } +#if __cplusplus >= 201103L + system_error (const system_error &) = default; + system_error &operator= (const system_error &) = default; +#endif + virtual ~system_error() noexcept; const error_code& diff --git a/libstdc++-v3/libsupc++/exception.h b/libstdc++-v3/libsupc++/exception.h index 3f1111d3e4b..1adfe7cbef6 100644 --- a/libstdc++-v3/libsupc++/exception.h +++ b/libstdc++-v3/libsupc++/exception.h @@ -62,6 +62,10 @@ namespace std public: exception() _GLIBCXX_USE_NOEXCEPT { } virtual ~exception() _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_USE_NOEXCEPT; +#if __cplusplus >= 201103L + exception(const exception&) = default; + exception& operator=(const exception&) = default; +#endif /** Returns a C-style character string describing the general cause * of the current error. */ diff --git a/libstdc++-v3/libsupc++/new b/libstdc++-v3/libsupc++/new index 99c769c48d6..73483c8a92c 100644 --- a/libstdc++-v3/libsupc++/new +++ b/libstdc++-v3/libsupc++/new @@ -56,6 +56,11 @@ namespace std public: bad_alloc() throw() { } +#if __cplusplus >= 201103L + bad_alloc(const bad_alloc&) = default; + bad_alloc& operator=(const bad_alloc&) = default; +#endif + // This declaration is not useless: // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 virtual ~bad_alloc() throw(); -- 2.30.2