https://gcc.gnu.org/g:7abc86119e4ebb13d3fffc7e2b038e2629aa2fc1
commit r12-10275-g7abc86119e4ebb13d3fffc7e2b038e2629aa2fc1 Author: Jonathan Wakely <jwak...@redhat.com> Date: Mon Nov 7 15:00:34 2022 +0000 libstdc++: Fix -Wsystem-headers warnings in tests libstdc++-v3/ChangeLog: * testsuite/18_support/new_nothrow.cc: Add missing noexcept to operator delete replacements. * testsuite/20_util/any/cons/92156.cc: Disable -Winit-list-lifetime warnings from instantiating invalid specialization of manager function. * testsuite/20_util/any/modifiers/92156.cc: Likewise. * testsuite/20_util/default_delete/void_neg.cc: Prune additional diagnostics. * testsuite/20_util/headers/memory/synopsis.cc: Add missing noexcept. * testsuite/20_util/shared_ptr/cons/void_neg.cc: Prune additional diagnostic. * testsuite/20_util/unique_ptr/creation/for_overwrite.cc: Add missing noexcept to operator delete replacements. * testsuite/21_strings/basic_string/cons/char/103919.cc: Likewise. * testsuite/23_containers/map/modifiers/emplace/92300.cc: Likewise. * testsuite/23_containers/map/modifiers/insert/92300.cc: Likewise. * testsuite/24_iterators/headers/iterator/range_access_c++11.cc: Add missing noexcept to synopsis declarations. * testsuite/24_iterators/headers/iterator/range_access_c++14.cc: Likewise. * testsuite/24_iterators/headers/iterator/range_access_c++17.cc: Likewise. (cherry picked from commit bbcb84bba0a21ff367c95d3d0970926992b20cdd) Diff: --- libstdc++-v3/testsuite/18_support/new_nothrow.cc | 14 ++++++++++---- libstdc++-v3/testsuite/20_util/any/cons/92156.cc | 1 + libstdc++-v3/testsuite/20_util/any/modifiers/92156.cc | 1 + libstdc++-v3/testsuite/20_util/default_delete/void_neg.cc | 3 +++ libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc | 2 +- libstdc++-v3/testsuite/20_util/shared_ptr/cons/void_neg.cc | 2 ++ .../testsuite/20_util/unique_ptr/creation/for_overwrite.cc | 4 ++-- .../testsuite/21_strings/basic_string/cons/char/103919.cc | 4 ++-- .../testsuite/23_containers/map/modifiers/emplace/92300.cc | 4 ++-- .../testsuite/23_containers/map/modifiers/insert/92300.cc | 4 ++-- .../24_iterators/headers/iterator/range_access_c++11.cc | 4 ++-- .../24_iterators/headers/iterator/range_access_c++14.cc | 12 ++++++------ .../24_iterators/headers/iterator/range_access_c++17.cc | 12 ++++++------ 13 files changed, 40 insertions(+), 27 deletions(-) diff --git a/libstdc++-v3/testsuite/18_support/new_nothrow.cc b/libstdc++-v3/testsuite/18_support/new_nothrow.cc index b0ef4e966b8..a9e9da0ce81 100644 --- a/libstdc++-v3/testsuite/18_support/new_nothrow.cc +++ b/libstdc++-v3/testsuite/18_support/new_nothrow.cc @@ -63,7 +63,13 @@ void* operator new (size_t n) } } -void operator delete (void *p) +#if __cplusplus >= 201103L +#define NOEXCEPT noexcept +#else +#define NOEXCEPT +#endif + +void operator delete (void *p) NOEXCEPT { ++delete_called; if (p) @@ -76,18 +82,18 @@ void* operator new[] (size_t n) return operator new(n); } -void operator delete[] (void *p) +void operator delete[] (void *p) NOEXCEPT { ++delete_vec_called; operator delete(p); } #if __cplusplus >= 201402L -void operator delete (void *p, std::size_t) +void operator delete (void *p, std::size_t) noexcept { ::operator delete(p); } -void operator delete[] (void *p, std::size_t) +void operator delete[] (void *p, std::size_t) noexcept { ::operator delete[](p); } diff --git a/libstdc++-v3/testsuite/20_util/any/cons/92156.cc b/libstdc++-v3/testsuite/20_util/any/cons/92156.cc index 71e9dd94090..0e768df9a00 100644 --- a/libstdc++-v3/testsuite/20_util/any/cons/92156.cc +++ b/libstdc++-v3/testsuite/20_util/any/cons/92156.cc @@ -1,4 +1,5 @@ // { dg-do run { target c++17 } } +// { dg-options "-Wno-init-list-lifetime" } // Copyright (C) 2020-2022 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/20_util/any/modifiers/92156.cc b/libstdc++-v3/testsuite/20_util/any/modifiers/92156.cc index d8f9893667b..b98d0e8e92a 100644 --- a/libstdc++-v3/testsuite/20_util/any/modifiers/92156.cc +++ b/libstdc++-v3/testsuite/20_util/any/modifiers/92156.cc @@ -1,4 +1,5 @@ // { dg-do run { target c++17 } } +// { dg-options "-Wno-init-list-lifetime" } // Copyright (C) 2020-2022 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/20_util/default_delete/void_neg.cc b/libstdc++-v3/testsuite/20_util/default_delete/void_neg.cc index f6aefc0a7ff..04042c2d745 100644 --- a/libstdc++-v3/testsuite/20_util/default_delete/void_neg.cc +++ b/libstdc++-v3/testsuite/20_util/default_delete/void_neg.cc @@ -27,3 +27,6 @@ void test01() d(nullptr); // { dg-error "here" } // { dg-error "delete pointer to incomplete type" "" { target *-*-* } 0 } } + +// { dg-prune-output "invalid application of 'sizeof' to a void type" } +// { dg-prune-output "deleting 'void*' is undefined" } diff --git a/libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc b/libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc index 15437c72ee0..b14c4278cd3 100644 --- a/libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc +++ b/libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc @@ -32,7 +32,7 @@ namespace std template<class Ptr> struct pointer_traits; template<class T> struct pointer_traits<T*>; - void* align(size_t alignment, size_t size, void*& ptr, size_t& space); + void* align(size_t alignment, size_t size, void*& ptr, size_t& space) noexcept; struct allocator_arg_t; extern const allocator_arg_t allocator_arg; diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/void_neg.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/void_neg.cc index b6e4eb0a952..e42d9ca7677 100644 --- a/libstdc++-v3/testsuite/20_util/shared_ptr/cons/void_neg.cc +++ b/libstdc++-v3/testsuite/20_util/shared_ptr/cons/void_neg.cc @@ -30,3 +30,5 @@ void test01() using std::shared_ptr; using std::is_constructible; static_assert(!is_constructible<shared_ptr<void>, const void*>::value, ""); + +// { dg-prune-output "invalid application of 'sizeof' to a void type" } diff --git a/libstdc++-v3/testsuite/20_util/unique_ptr/creation/for_overwrite.cc b/libstdc++-v3/testsuite/20_util/unique_ptr/creation/for_overwrite.cc index f736c762a43..2326ad8ff11 100644 --- a/libstdc++-v3/testsuite/20_util/unique_ptr/creation/for_overwrite.cc +++ b/libstdc++-v3/testsuite/20_util/unique_ptr/creation/for_overwrite.cc @@ -40,8 +40,8 @@ void* operator new(std::size_t n) return p; } -void operator delete(void* p) { std::free(p); } -void operator delete(void* p, std::size_t) { std::free(p); } +void operator delete(void* p) noexcept { std::free(p); } +void operator delete(void* p, std::size_t) noexcept { std::free(p); } void test01() diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/103919.cc b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/103919.cc index 94400e319ff..c11036b49c5 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/103919.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/cons/char/103919.cc @@ -14,12 +14,12 @@ void* operator new(std::size_t n) return std::malloc(n); } -void operator delete(void* p) +void operator delete(void* p) noexcept { std::free(p); } -void operator delete(void* p, std::size_t) +void operator delete(void* p, std::size_t) noexcept { std::free(p); } diff --git a/libstdc++-v3/testsuite/23_containers/map/modifiers/emplace/92300.cc b/libstdc++-v3/testsuite/23_containers/map/modifiers/emplace/92300.cc index 937b4d9a103..ab48386bd8b 100644 --- a/libstdc++-v3/testsuite/23_containers/map/modifiers/emplace/92300.cc +++ b/libstdc++-v3/testsuite/23_containers/map/modifiers/emplace/92300.cc @@ -12,12 +12,12 @@ void* operator new(std::size_t n) return std::malloc(n); } -void operator delete(void* p) +void operator delete(void* p) noexcept { std::free(p); } -void operator delete(void* p, std::size_t) +void operator delete(void* p, std::size_t) noexcept { std::free(p); } diff --git a/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/92300.cc b/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/92300.cc index 80abdaf1f30..51c0138e1a3 100644 --- a/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/92300.cc +++ b/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/92300.cc @@ -12,12 +12,12 @@ void* operator new(std::size_t n) return std::malloc(n); } -void operator delete(void* p) +void operator delete(void* p) noexcept { std::free(p); } -void operator delete(void* p, std::size_t) +void operator delete(void* p, std::size_t) noexcept { std::free(p); } diff --git a/libstdc++-v3/testsuite/24_iterators/headers/iterator/range_access_c++11.cc b/libstdc++-v3/testsuite/24_iterators/headers/iterator/range_access_c++11.cc index 819bffa9c65..c6262a5a3be 100644 --- a/libstdc++-v3/testsuite/24_iterators/headers/iterator/range_access_c++11.cc +++ b/libstdc++-v3/testsuite/24_iterators/headers/iterator/range_access_c++11.cc @@ -28,6 +28,6 @@ namespace std template<class C> auto end(C& c) -> decltype(c.end()); template<class C> auto end(const C& c) -> decltype(c.end()); - template<class T, size_t N> T* begin(T (&array)[N]); - template<class T, size_t N> T* end(T (&array)[N]); + template<class T, size_t N> T* begin(T (&array)[N]) noexcept; + template<class T, size_t N> T* end(T (&array)[N]) noexcept; } diff --git a/libstdc++-v3/testsuite/24_iterators/headers/iterator/range_access_c++14.cc b/libstdc++-v3/testsuite/24_iterators/headers/iterator/range_access_c++14.cc index 425012f2d08..81e6e84819f 100644 --- a/libstdc++-v3/testsuite/24_iterators/headers/iterator/range_access_c++14.cc +++ b/libstdc++-v3/testsuite/24_iterators/headers/iterator/range_access_c++14.cc @@ -28,8 +28,8 @@ namespace std template<class C> auto end(C& c) -> decltype(c.end()); template<class C> auto end(const C& c) -> decltype(c.end()); - template<class T, size_t N> constexpr T* begin(T (&array)[N]); - template<class T, size_t N> constexpr T* end(T (&array)[N]); + template<class T, size_t N> constexpr T* begin(T (&array)[N]) noexcept; + template<class T, size_t N> constexpr T* end(T (&array)[N]) noexcept; template<class C> auto cbegin(const C& c) -> decltype(c.begin()); template<class C> auto cend(const C& c) -> decltype(c.end()); @@ -41,14 +41,14 @@ namespace std template<class C> auto rend(const C& c) -> decltype(c.rend()); template<class T, size_t N> - reverse_iterator<T*> rbegin(T (&array)[N]); + reverse_iterator<T*> rbegin(T (&array)[N]) noexcept; template<class T, size_t N> - reverse_iterator<T*> rend(T (&array)[N]); + reverse_iterator<T*> rend(T (&array)[N]) noexcept; template<class E> - reverse_iterator<const E*> rbegin(initializer_list<E>); + reverse_iterator<const E*> rbegin(initializer_list<E>) noexcept; template<class E> - reverse_iterator<const E*> rend(initializer_list<E>); + reverse_iterator<const E*> rend(initializer_list<E>) noexcept; template<class C> auto crbegin(const C& c) -> decltype(std::rbegin(c)); diff --git a/libstdc++-v3/testsuite/24_iterators/headers/iterator/range_access_c++17.cc b/libstdc++-v3/testsuite/24_iterators/headers/iterator/range_access_c++17.cc index da65c11f3a7..91295943682 100644 --- a/libstdc++-v3/testsuite/24_iterators/headers/iterator/range_access_c++17.cc +++ b/libstdc++-v3/testsuite/24_iterators/headers/iterator/range_access_c++17.cc @@ -27,8 +27,8 @@ namespace std template<class C> constexpr auto end(C& c) -> decltype(c.end()); template<class C> constexpr auto end(const C& c) -> decltype(c.end()); - template<class T, size_t N> constexpr T* begin(T (&array)[N]); - template<class T, size_t N> constexpr T* end(T (&array)[N]); + template<class T, size_t N> constexpr T* begin(T (&array)[N]) noexcept; + template<class T, size_t N> constexpr T* end(T (&array)[N]) noexcept; template<class C> constexpr auto cbegin(const C& c) -> decltype(c.begin()); template<class C> constexpr auto cend(const C& c) -> decltype(c.end()); @@ -40,14 +40,14 @@ namespace std template<class C> constexpr auto rend(const C& c) -> decltype(c.rend()); template<class T, size_t N> - constexpr reverse_iterator<T*> rbegin(T (&array)[N]); + constexpr reverse_iterator<T*> rbegin(T (&array)[N]) noexcept; template<class T, size_t N> - constexpr reverse_iterator<T*> rend(T (&array)[N]); + constexpr reverse_iterator<T*> rend(T (&array)[N]) noexcept; template<class E> - constexpr reverse_iterator<const E*> rbegin(initializer_list<E>); + constexpr reverse_iterator<const E*> rbegin(initializer_list<E>) noexcept; template<class E> - constexpr reverse_iterator<const E*> rend(initializer_list<E>); + constexpr reverse_iterator<const E*> rend(initializer_list<E>) noexcept; template<class C> constexpr auto crbegin(const C& c) -> decltype(std::rbegin(c));