diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2020-10-29 22:47:21 +0000 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2020-10-29 22:47:21 +0000 |
commit | 13feb0234b136fbdc1dbfba3a9663fb4e1043f75 (patch) | |
tree | d05a39206b08d2b19889146875b6cb6aac63abc0 /libstdc++-v3/testsuite | |
parent | 11dc4c4e137a9b48d585d7b1b146fb8404e3e1fe (diff) | |
download | gcc-13feb0234b136fbdc1dbfba3a9663fb4e1043f75.tar.gz |
libstdc++: Avoid warnings in tests
This fixes some warnings emitted when testing with warning flags added.
Some of these are only necessary when testing with -Wsystem-headers, but
either way it cleans up the tests to be less noisy under non-default
flags.
libstdc++-v3/ChangeLog:
* testsuite/18_support/96817.cc: Avoid -Wunused warnings.
* testsuite/20_util/any/assign/2.cc: Likewise.
* testsuite/20_util/any/cons/2.cc: Likewise.
* testsuite/20_util/align/1.cc: Avoid -Wsign-compare warning.
* testsuite/20_util/function/65760.cc: Avoid -Wunused warning.
* testsuite/20_util/function/1.cc: Avoid -Wcatch-value warning.
* testsuite/20_util/function/cons/move_target.cc: Avoid -Wunused
warning.
* testsuite/20_util/headers/memory/synopsis.cc: Add exception
specification.
* testsuite/20_util/monotonic_buffer_resource/allocate.cc: Avoid
-Wsign-compare warning.
* testsuite/20_util/tuple/cons/deduction.cc: Avoid -Wunused
warning.
* testsuite/20_util/specialized_algorithms/uninitialized_copy/808590-cxx11.cc:
Avoid -Wdeprecated-copy warning.
* testsuite/21_strings/basic_string/56166.cc: Avoid
-Wcatch-value warning.
* testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc:
Avoid -Wcatch-value warnings.
* testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stof.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoi.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stol.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoll.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoul.cc:
Likewise.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoull.cc:
Likewise.
* testsuite/21_strings/basic_string_view/operations/compare/char/nonnull.cc:
Prune additional diagnostics.
* testsuite/21_strings/basic_string_view/operations/find/char/nonnull.cc:
Likewise.
* testsuite/21_strings/basic_string_view/operations/rfind/char/nonnull.cc:
Likewise.
* testsuite/21_strings/headers/string/synopsis.cc: Add exception
specifications.
* testsuite/22_locale/locale/cons/12352.cc: Define sized
delete operators to avoid warnings.
* testsuite/23_containers/deque/modifiers/swap/1.cc: Add
exception specification.
* testsuite/23_containers/forward_list/cons/11.cc: Avoid
-Wdeprecated-copy warning.
* testsuite/23_containers/headers/bitset/synopsis.cc: Add
exception specification.
* testsuite/23_containers/headers/deque/synopsis.cc: Likewise.
* testsuite/23_containers/headers/forward_list/synopsis.cc:
Likewise.
* testsuite/23_containers/headers/list/synopsis.cc: Likewise.
* testsuite/23_containers/headers/map/synopsis.cc: Likewise.
* testsuite/23_containers/headers/queue/synopsis.cc: Likewise.
* testsuite/23_containers/headers/set/synopsis.cc: Likewise.
* testsuite/23_containers/headers/vector/synopsis.cc: Likewise.
* testsuite/23_containers/list/modifiers/swap/1.cc: Likewise.
* testsuite/23_containers/map/modifiers/swap/1.cc: Likewise.
* testsuite/23_containers/multimap/modifiers/swap/1.cc:
Likewise.
* testsuite/23_containers/multiset/modifiers/swap/1.cc:
Likewise.
* testsuite/23_containers/set/modifiers/swap/1.cc: Likewise.
* testsuite/23_containers/unordered_set/56267-2.cc: Avoid
-Wdeprecated-copy warning.
* testsuite/23_containers/vector/bool/23632.cc: Avoid
-Wempty-body warning.
* testsuite/23_containers/vector/modifiers/swap/1.cc: Add
exception specification.
* testsuite/25_algorithms/heap/moveable2.cc: Fix misplaced
parentheses around arguments.
* testsuite/25_algorithms/sample/1.cc: Use return value.
* testsuite/25_algorithms/search/searcher.cc: Avoid -Wunused
warnings.
* testsuite/27_io/basic_ostream/exceptions/char/9561.cc:
Likewise.
* testsuite/27_io/basic_ostream/exceptions/wchar_t/9561.cc:
Likewise.
* testsuite/27_io/filesystem/operations/remove_all.cc: Avoid
-Wsign-compare warning.
* testsuite/experimental/any/assign/2.cc: Avoid -Wunused warnings.
* testsuite/experimental/any/cons/2.cc: Likewise.
* testsuite/experimental/filesystem/operations/remove_all.cc:
Avoid -Wign-compare warning.
* testsuite/experimental/memory/observer_ptr/cons/cons.cc:
Likewise.
* testsuite/experimental/memory_resource/null_memory_resource.cc:
Likewise.
* testsuite/experimental/source_location/1.cc: Avoid -Waddress
warning.
* testsuite/ext/pod_char_traits.cc: Avoid -Wunused warning.
* testsuite/ext/vstring/modifiers/clear/56166.cc: Avoid
-Wcatch-value.
* testsuite/std/concepts/concepts.lang/concept.swappable/swap.cc:
Avoid -Wunused warning.
* testsuite/std/concepts/concepts.lang/concept.swappable/swappable.cc:
Likewise.
* testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc:
Prune additional warnings.
* testsuite/tr1/3_function_objects/function/1.cc: Avoid
-Wcatch-value warning.
* testsuite/util/replacement_memory_operators.h: Define sized
delete to avoid warnings.
* testsuite/util/testsuite_api.h (_NonDefaultConstructible): Add
user-declared assignment operator to stop -Wdeprecated-copy
warnings.
* testsuite/util/testsuite_containers.h: Avoid -Wunused warning.
* testsuite/util/testsuite_iterators.h: Avoid -Wsign-compare
warnings.
* testsuite/util/testsuite_new_operators.h: Define sized deleted.
Diffstat (limited to 'libstdc++-v3/testsuite')
74 files changed, 393 insertions, 243 deletions
diff --git a/libstdc++-v3/testsuite/18_support/96817.cc b/libstdc++-v3/testsuite/18_support/96817.cc index 19399c473ef..f0332967831 100644 --- a/libstdc++-v3/testsuite/18_support/96817.cc +++ b/libstdc++-v3/testsuite/18_support/96817.cc @@ -38,7 +38,7 @@ int init() void clean_terminate() { _Exit(0); } int -main (int argc, char **argv) +main () { std::set_terminate(clean_terminate); init(); diff --git a/libstdc++-v3/testsuite/20_util/align/1.cc b/libstdc++-v3/testsuite/20_util/align/1.cc index 2fc1b6d1d9c..a08b0312fb9 100644 --- a/libstdc++-v3/testsuite/20_util/align/1.cc +++ b/libstdc++-v3/testsuite/20_util/align/1.cc @@ -30,6 +30,8 @@ void test01() { + using std::size_t; + size_t space = 100; void* ptr = new char[space]; char* const orig_ptr = static_cast<char*>(ptr); @@ -44,7 +46,7 @@ test01() uintptr_t p = reinterpret_cast<uintptr_t>(ptr); VERIFY( p % alignment == 0 ); char* const x = static_cast<char*>(ptr); - VERIFY( x - old_ptr == old_space - space ); + VERIFY( size_t(x - old_ptr) == old_space - space ); VERIFY( (void*)x < (void*)(orig_ptr + orig_space) ); VERIFY( (void*)(x + size) < (void*)(orig_ptr + orig_space) ); ptr = x + size; diff --git a/libstdc++-v3/testsuite/20_util/any/assign/2.cc b/libstdc++-v3/testsuite/20_util/any/assign/2.cc index bd1aab454f6..64b0dbb2b63 100644 --- a/libstdc++-v3/testsuite/20_util/any/assign/2.cc +++ b/libstdc++-v3/testsuite/20_util/any/assign/2.cc @@ -31,14 +31,14 @@ struct X { X() = default; X(const X&) { copied = true; } - X(X&& x) { moved = true; } + X(X&&) { moved = true; } }; struct X2 { X2() = default; X2(const X2&) { copied = true; } - X2(X2&& x) noexcept { moved = true; } + X2(X2&&) noexcept { moved = true; } }; void test01() diff --git a/libstdc++-v3/testsuite/20_util/any/cons/2.cc b/libstdc++-v3/testsuite/20_util/any/cons/2.cc index 36f6ec86088..1ce150cdca7 100644 --- a/libstdc++-v3/testsuite/20_util/any/cons/2.cc +++ b/libstdc++-v3/testsuite/20_util/any/cons/2.cc @@ -31,14 +31,14 @@ struct X { X() = default; X(const X&) { copied = true; } - X(X&& x) { moved = true; } + X(X&&) { moved = true; } }; struct X2 { X2() = default; X2(const X2&) { copied = true; } - X2(X2&& x) noexcept { moved = true; } + X2(X2&&) noexcept { moved = true; } }; void test01() diff --git a/libstdc++-v3/testsuite/20_util/function/1.cc b/libstdc++-v3/testsuite/20_util/function/1.cc index bb2f737b4bb..efcd160e7d3 100644 --- a/libstdc++-v3/testsuite/20_util/function/1.cc +++ b/libstdc++-v3/testsuite/20_util/function/1.cc @@ -67,7 +67,7 @@ void test01() f1(3.14159f); VERIFY( false ); } - catch (bad_function_call) + catch (const bad_function_call&) { thrown = true; } diff --git a/libstdc++-v3/testsuite/20_util/function/65760.cc b/libstdc++-v3/testsuite/20_util/function/65760.cc index 6dd320cbca4..afd323e239b 100644 --- a/libstdc++-v3/testsuite/20_util/function/65760.cc +++ b/libstdc++-v3/testsuite/20_util/function/65760.cc @@ -31,7 +31,4 @@ struct C { C operator()(int, int); }; -int main() { - C c = C(); -} - +C c = C(); diff --git a/libstdc++-v3/testsuite/20_util/function/cons/move_target.cc b/libstdc++-v3/testsuite/20_util/function/cons/move_target.cc index e0880c3304c..5b6ae319354 100644 --- a/libstdc++-v3/testsuite/20_util/function/cons/move_target.cc +++ b/libstdc++-v3/testsuite/20_util/function/cons/move_target.cc @@ -25,7 +25,7 @@ struct moveable ~moveable() = default; // target object must be CopyConstructible, // but should not be copied during this test - moveable(const moveable& c) { throw "copied"; } + moveable(const moveable&) { throw "copied"; } moveable& operator=(const moveable&) = delete; moveable(moveable&&) { } diff --git a/libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc b/libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc index 187de621257..96786e1810a 100644 --- a/libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc +++ b/libstdc++-v3/testsuite/20_util/headers/memory/synopsis.cc @@ -20,6 +20,10 @@ #include <memory> +#if __cplusplus >= 201103L +# define NOTHROW noexcept +#endif + namespace std { // lib.default.allocator, the default allocator: template <class T> class allocator; @@ -40,7 +44,7 @@ namespace std { // lib.temporary.buffer, temporary buffers: template <class T> - pair<T*,ptrdiff_t> get_temporary_buffer(ptrdiff_t n); + pair<T*,ptrdiff_t> get_temporary_buffer(ptrdiff_t n) NOTHROW; template <class T> void return_temporary_buffer(T* p); diff --git a/libstdc++-v3/testsuite/20_util/monotonic_buffer_resource/allocate.cc b/libstdc++-v3/testsuite/20_util/monotonic_buffer_resource/allocate.cc index 637bdf1b30e..2f7facd0655 100644 --- a/libstdc++-v3/testsuite/20_util/monotonic_buffer_resource/allocate.cc +++ b/libstdc++-v3/testsuite/20_util/monotonic_buffer_resource/allocate.cc @@ -150,7 +150,7 @@ test04() { std::size_t size = 1 << i; void* ptr = mr.allocate(size, 1); - VERIFY( ((char*)ptr - (char*)prev_ptr) == prev_size ); + VERIFY( std::size_t((char*)ptr - (char*)prev_ptr) == prev_size ); prev_ptr = ptr; prev_size = size; } diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/808590-cxx11.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/808590-cxx11.cc index 40f4b8caed2..513803201f8 100644 --- a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/808590-cxx11.cc +++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/808590-cxx11.cc @@ -31,6 +31,8 @@ struct c c(void* o = 0) : m(o) {} c(const c &r) : m(r.m) {} + c& operator=(const c &) = default; + template<class T> explicit c(T &o) : m((void*)0xdeadbeef) { } }; diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/deduction.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/deduction.cc index 2b5b9f15d3b..120a3154545 100644 --- a/libstdc++-v3/testsuite/20_util/tuple/cons/deduction.cc +++ b/libstdc++-v3/testsuite/20_util/tuple/cons/deduction.cc @@ -124,10 +124,8 @@ test04() std::pair<int, unsigned> p; std::tuple x = p; check_type<std::tuple<int, unsigned>>(x); - int y = 42; std::tuple x2{p}; check_type<std::tuple<int, unsigned>>(x2); - const int z = 666; std::pair<const int, unsigned> p2; std::tuple x3{p2}; check_type<std::tuple<const int, unsigned>>(x3); diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/56166.cc b/libstdc++-v3/testsuite/21_strings/basic_string/56166.cc index 6ee51c8f1c8..0feb747e880 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/56166.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/56166.cc @@ -87,7 +87,7 @@ int main() fail_after = i; f(); break; - } catch (std::bad_alloc) { + } catch (const std::bad_alloc&) { } } } diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc index 3265ccbff87..58b40ed176e 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stod.cc @@ -38,9 +38,9 @@ test01() try { string one; - stod(one); + stod(one); } - catch(std::invalid_argument) + catch(const std::invalid_argument&) { test = true; } @@ -53,9 +53,9 @@ test01() try { string one("a"); - stod(one); + stod(one); } - catch(std::invalid_argument) + catch(const std::invalid_argument&) { test = true; } @@ -69,7 +69,7 @@ test01() try { string one("2.0a"); - d1 = stod(one, &idx1); + d1 = stod(one, &idx1); } catch(...) { @@ -86,7 +86,7 @@ test01() one.append(2 * numeric_limits<double>::max_exponent10, '9'); d1 = stod(one); } - catch(std::out_of_range) + catch(const std::out_of_range&) { test = true; } @@ -120,7 +120,7 @@ test01() string one(to_string(ld1)); d1 = stod(one); } - catch(std::out_of_range) + catch(const std::out_of_range&) { test = true; } diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc index 4cb9b13e331..1a203721e56 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stof.cc @@ -36,9 +36,9 @@ test01() try { string one; - stof(one); + stof(one); } - catch(std::invalid_argument) + catch(const std::invalid_argument&) { test = true; } @@ -51,9 +51,9 @@ test01() try { string one("a"); - stof(one); + stof(one); } - catch(std::invalid_argument) + catch(const std::invalid_argument&) { test = true; } @@ -67,7 +67,7 @@ test01() try { string one("2.0a"); - f1 = stof(one, &idx1); + f1 = stof(one, &idx1); } catch(...) { @@ -84,7 +84,7 @@ test01() one.append(2 * numeric_limits<float>::max_exponent10, '9'); f1 = stof(one); } - catch(std::out_of_range) + catch(const std::out_of_range&) { test = true; } @@ -118,7 +118,7 @@ test01() string one(to_string(ld1)); f1 = stof(one); } - catch(std::out_of_range) + catch(const std::out_of_range&) { test = true; } diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc index 656c6f713d7..21d1d296b77 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoi.cc @@ -36,9 +36,9 @@ test01() try { string one; - stoi(one); + stoi(one); } - catch(std::invalid_argument) + catch(const std::invalid_argument&) { test = true; } @@ -51,9 +51,9 @@ test01() try { string one("a"); - stoi(one); + stoi(one); } - catch(std::invalid_argument) + catch(const std::invalid_argument&) { test = true; } @@ -66,7 +66,7 @@ test01() try { string one("a"); - i1 = stoi(one, 0, 16); + i1 = stoi(one, 0, 16); } catch(...) { @@ -79,7 +79,7 @@ test01() try { string one("78"); - i1 = stoi(one, &idx1, 8); + i1 = stoi(one, &idx1, 8); } catch(...) { @@ -92,7 +92,7 @@ test01() try { string one("10112"); - i1 = stoi(one, &idx1, 2); + i1 = stoi(one, &idx1, 2); } catch(...) { @@ -105,7 +105,7 @@ test01() try { string one("0XE"); - i1 = stoi(one, &idx1, 0); + i1 = stoi(one, &idx1, 0); } catch(...) { @@ -121,7 +121,7 @@ test01() string one(1000, '9'); i1 = stoi(one); } - catch(std::out_of_range) + catch(const std::out_of_range&) { test = true; } @@ -166,7 +166,7 @@ test01() string one(to_string(ll0)); i1 = stoi(one); } - catch(std::out_of_range) + catch(const std::out_of_range&) { test = true; } @@ -184,7 +184,7 @@ test01() string one(to_string(ll1)); i1 = stoi(one); } - catch(std::out_of_range) + catch(const std::out_of_range&) { test = true; } diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc index 48b17ba2393..9a4ed257168 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stol.cc @@ -36,9 +36,9 @@ test01() try { string one; - stol(one); + stol(one); } - catch(std::invalid_argument) + catch(const std::invalid_argument&) { test = true; } @@ -51,9 +51,9 @@ test01() try { string one("a"); - stol(one); + stol(one); } - catch(std::invalid_argument) + catch(const std::invalid_argument&) { test = true; } @@ -66,7 +66,7 @@ test01() try { string one("a"); - l1 = stol(one, 0, 16); + l1 = stol(one, 0, 16); } catch(...) { @@ -79,7 +79,7 @@ test01() try { string one("78"); - l1 = stol(one, &idx1, 8); + l1 = stol(one, &idx1, 8); } catch(...) { @@ -92,7 +92,7 @@ test01() try { string one("10112"); - l1 = stol(one, &idx1, 2); + l1 = stol(one, &idx1, 2); } catch(...) { @@ -105,7 +105,7 @@ test01() try { string one("0XE"); - l1 = stol(one, &idx1, 0); + l1 = stol(one, &idx1, 0); } catch(...) { @@ -121,7 +121,7 @@ test01() string one(1000, '9'); l1 = stol(one); } - catch(std::out_of_range) + catch(const std::out_of_range&) { test = true; } diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc index f9fd524ec3b..f120ccca128 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stold.cc @@ -37,9 +37,9 @@ test01() try { string one; - stold(one); + stold(one); } - catch(std::invalid_argument) + catch(const std::invalid_argument&) { test = true; } @@ -52,9 +52,9 @@ test01() try { string one("a"); - stold(one); + stold(one); } - catch(std::invalid_argument) + catch(const std::invalid_argument&) { test = true; } @@ -68,7 +68,7 @@ test01() try { string one("2.0a"); - ld1 = stold(one, &idx1); + ld1 = stold(one, &idx1); } catch(...) { @@ -85,7 +85,7 @@ test01() one.append(2 * numeric_limits<long double>::max_exponent10, '9'); ld1 = stold(one); } - catch(std::out_of_range) + catch(const std::out_of_range&) { test = true; } diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc index 921db800461..24761bb1479 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoll.cc @@ -36,9 +36,9 @@ test01() try { string one; - stoll(one); + stoll(one); } - catch(std::invalid_argument) + catch(const std::invalid_argument&) { test = true; } @@ -51,9 +51,9 @@ test01() try { string one("a"); - stoll(one); + stoll(one); } - catch(std::invalid_argument) + catch(const std::invalid_argument&) { test = true; } @@ -66,7 +66,7 @@ test01() try { string one("a"); - ll1 = stoll(one, 0, 16); + ll1 = stoll(one, 0, 16); } catch(...) { @@ -79,7 +79,7 @@ test01() try { string one("78"); - ll1 = stoll(one, &idx1, 8); + ll1 = stoll(one, &idx1, 8); } catch(...) { @@ -92,7 +92,7 @@ test01() try { string one("10112"); - ll1 = stoll(one, &idx1, 2); + ll1 = stoll(one, &idx1, 2); } catch(...) { @@ -105,7 +105,7 @@ test01() try { string one("0XE"); - ll1 = stoll(one, &idx1, 0); + ll1 = stoll(one, &idx1, 0); } catch(...) { @@ -121,7 +121,7 @@ test01() string one(1000, '9'); ll1 = stoll(one); } - catch(std::out_of_range) + catch(const std::out_of_range&) { test = true; } diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc index 703daa7b75f..489a569c6ab 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoul.cc @@ -36,9 +36,9 @@ test01() try { string one; - stoul(one); + stoul(one); } - catch(std::invalid_argument) + catch(const std::invalid_argument&) { test = true; } @@ -51,9 +51,9 @@ test01() try { string one("a"); - stoul(one); + stoul(one); } - catch(std::invalid_argument) + catch(const std::invalid_argument&) { test = true; } @@ -66,7 +66,7 @@ test01() try { string one("a"); - ul1 = stoul(one, 0, 16); + ul1 = stoul(one, 0, 16); } catch(...) { @@ -79,7 +79,7 @@ test01() try { string one("78"); - ul1 = stoul(one, &idx1, 8); + ul1 = stoul(one, &idx1, 8); } catch(...) { @@ -92,7 +92,7 @@ test01() try { string one("10112"); - ul1 = stoul(one, &idx1, 2); + ul1 = stoul(one, &idx1, 2); } catch(...) { @@ -105,7 +105,7 @@ test01() try { string one("0XE"); - ul1 = stoul(one, &idx1, 0); + ul1 = stoul(one, &idx1, 0); } catch(...) { @@ -121,7 +121,7 @@ test01() string one(1000, '9'); ul1 = stoul(one); } - catch(std::out_of_range) + catch(const std::out_of_range&) { test = true; } diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc index ab2ae036115..a0330e24b93 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/char/stoull.cc @@ -36,9 +36,9 @@ test01() try { string one; - stoull(one); + stoull(one); } - catch(std::invalid_argument) + catch(const std::invalid_argument&) { test = true; } @@ -46,14 +46,14 @@ test01() { } VERIFY( test ); - + test = false; try { string one("a"); - stoull(one); + stoull(one); } - catch(std::invalid_argument) + catch(const std::invalid_argument&) { test = true; } @@ -66,7 +66,7 @@ test01() try { string one("a"); - ull1 = stoull(one, 0, 16); + ull1 = stoull(one, 0, 16); } catch(...) { @@ -79,7 +79,7 @@ test01() try { string one("78"); - ull1 = stoull(one, &idx1, 8); + ull1 = stoull(one, &idx1, 8); } catch(...) { @@ -92,7 +92,7 @@ test01() try { string one("10112"); - ull1 = stoull(one, &idx1, 2); + ull1 = stoull(one, &idx1, 2); } catch(...) { @@ -105,7 +105,7 @@ test01() try { string one("0XE"); - ull1 = stoull(one, &idx1, 0); + ull1 = stoull(one, &idx1, 0); } catch(...) { @@ -121,7 +121,7 @@ test01() string one(1000, '9'); ull1 = stoull(one); } - catch(std::out_of_range) + catch(const std::out_of_range&) { test = true; } diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc index f691abd08cc..cfe2de2e603 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stod.cc @@ -39,9 +39,9 @@ test01() try { wstring one; - stod(one); + stod(one); } - catch(std::invalid_argument) + catch(const std::invalid_argument&) { test = true; } @@ -54,9 +54,9 @@ test01() try { wstring one(L"a"); - stod(one); + stod(one); } - catch(std::invalid_argument) + catch(const std::invalid_argument&) { test = true; } @@ -70,7 +70,7 @@ test01() try { wstring one(L"2.0a"); - d1 = stod(one, &idx1); + d1 = stod(one, &idx1); } catch(...) { @@ -87,7 +87,7 @@ test01() one.append(2 * numeric_limits<double>::max_exponent10, L'9'); d1 = stod(one); } - catch(std::out_of_range) + catch(const std::out_of_range&) { test = true; } @@ -121,7 +121,7 @@ test01() wstring one(to_wstring(ld1)); d1 = stod(one); } - catch(std::out_of_range) + catch(const std::out_of_range&) { test = true; } diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stof.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stof.cc index 0aeec211aad..3d02ec4f88c 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stof.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stof.cc @@ -37,9 +37,9 @@ test01() try { wstring one; - stof(one); + stof(one); } - catch(std::invalid_argument) + catch(const std::invalid_argument&) { test = true; } @@ -52,9 +52,9 @@ test01() try { wstring one(L"a"); - stof(one); + stof(one); } - catch(std::invalid_argument) + catch(const std::invalid_argument&) { test = true; } @@ -68,7 +68,7 @@ test01() try { wstring one(L"2.0a"); - f1 = stof(one, &idx1); + f1 = stof(one, &idx1); } catch(...) { @@ -85,7 +85,7 @@ test01() one.append(2 * numeric_limits<float>::max_exponent10, L'9'); f1 = stof(one); } - catch(std::out_of_range) + catch(const std::out_of_range&) { test = true; } @@ -119,7 +119,7 @@ test01() wstring one(to_wstring(ld1)); f1 = stof(one); } - catch(std::out_of_range) + catch(const std::out_of_range&) { test = true; } diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoi.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoi.cc index 0e25023c4ee..f6187a9019d 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoi.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoi.cc @@ -37,9 +37,9 @@ test01() try { wstring one; - stoi(one); + stoi(one); } - catch(std::invalid_argument) + catch(const std::invalid_argument&) { test = true; } @@ -52,9 +52,9 @@ test01() try { wstring one(L"a"); - stoi(one); + stoi(one); } - catch(std::invalid_argument) + catch(const std::invalid_argument&) { test = true; } @@ -67,7 +67,7 @@ test01() try { wstring one(L"a"); - i1 = stoi(one, 0, 16); + i1 = stoi(one, 0, 16); } catch(...) { @@ -80,7 +80,7 @@ test01() try { wstring one(L"78"); - i1 = stoi(one, &idx1, 8); + i1 = stoi(one, &idx1, 8); } catch(...) { @@ -93,7 +93,7 @@ test01() try { wstring one(L"10112"); - i1 = stoi(one, &idx1, 2); + i1 = stoi(one, &idx1, 2); } catch(...) { @@ -106,7 +106,7 @@ test01() try { wstring one(L"0XE"); - i1 = stoi(one, &idx1, 0); + i1 = stoi(one, &idx1, 0); } catch(...) { @@ -122,7 +122,7 @@ test01() wstring one(1000, L'9'); i1 = stoi(one); } - catch(std::out_of_range) + catch(const std::out_of_range&) { test = true; } @@ -167,7 +167,7 @@ test01() wstring one(to_wstring(ll0)); i1 = stoi(one); } - catch(std::out_of_range) + catch(const std::out_of_range&) { test = true; } @@ -185,7 +185,7 @@ test01() wstring one(to_wstring(ll1)); i1 = stoi(one); } - catch(std::out_of_range) + catch(const std::out_of_range&) { test = true; } diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stol.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stol.cc index 968d1355a68..9c78d9839fa 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stol.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stol.cc @@ -37,9 +37,9 @@ test01() try { wstring one; - stol(one); + stol(one); } - catch(std::invalid_argument) + catch(const std::invalid_argument&) { test = true; } @@ -52,9 +52,9 @@ test01() try { wstring one(L"a"); - stol(one); + stol(one); } - catch(std::invalid_argument) + catch(const std::invalid_argument&) { test = true; } @@ -67,7 +67,7 @@ test01() try { wstring one(L"a"); - l1 = stol(one, 0, 16); + l1 = stol(one, 0, 16); } catch(...) { @@ -80,7 +80,7 @@ test01() try { wstring one(L"78"); - l1 = stol(one, &idx1, 8); + l1 = stol(one, &idx1, 8); } catch(...) { @@ -93,7 +93,7 @@ test01() try { wstring one(L"10112"); - l1 = stol(one, &idx1, 2); + l1 = stol(one, &idx1, 2); } catch(...) { @@ -106,7 +106,7 @@ test01() try { wstring one(L"0XE"); - l1 = stol(one, &idx1, 0); + l1 = stol(one, &idx1, 0); } catch(...) { @@ -122,7 +122,7 @@ test01() wstring one(1000, L'9'); l1 = stol(one); } - catch(std::out_of_range) + catch(const std::out_of_range&) { test = true; } diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc index 9642dc9c27c..a637a549f14 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stold.cc @@ -39,9 +39,9 @@ test01() try { wstring one; - stold(one); + stold(one); } - catch(std::invalid_argument) + catch(const std::invalid_argument&) { test = true; } @@ -54,9 +54,9 @@ test01() try { wstring one(L"a"); - stold(one); + stold(one); } - catch(std::invalid_argument) + catch(const std::invalid_argument&) { test = true; } @@ -70,7 +70,7 @@ test01() try { wstring one(L"2.0a"); - ld1 = stold(one, &idx1); + ld1 = stold(one, &idx1); } catch(...) { @@ -87,7 +87,7 @@ test01() one.append(2 * numeric_limits<long double>::max_exponent10, L'9'); ld1 = stold(one); } - catch(std::out_of_range) + catch(const std::out_of_range&) { test = true; } diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoll.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoll.cc index f4c237dead8..326fa5fbd5d 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoll.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoll.cc @@ -37,9 +37,9 @@ test01() try { wstring one; - stoll(one); + stoll(one); } - catch(std::invalid_argument) + catch(const std::invalid_argument&) { test = true; } @@ -52,9 +52,9 @@ test01() try { wstring one(L"a"); - stoll(one); + stoll(one); } - catch(std::invalid_argument) + catch(const std::invalid_argument&) { test = true; } @@ -67,7 +67,7 @@ test01() try { wstring one(L"a"); - ll1 = stoll(one, 0, 16); + ll1 = stoll(one, 0, 16); } catch(...) { @@ -80,7 +80,7 @@ test01() try { wstring one(L"78"); - ll1 = stoll(one, &idx1, 8); + ll1 = stoll(one, &idx1, 8); } catch(...) { @@ -93,7 +93,7 @@ test01() try { wstring one(L"10112"); - ll1 = stoll(one, &idx1, 2); + ll1 = stoll(one, &idx1, 2); } catch(...) { @@ -106,7 +106,7 @@ test01() try { wstring one(L"0XE"); - ll1 = stoll(one, &idx1, 0); + ll1 = stoll(one, &idx1, 0); } catch(...) { @@ -122,7 +122,7 @@ test01() wstring one(1000, L'9'); ll1 = stoll(one); } - catch(std::out_of_range) + catch(const std::out_of_range&) { test = true; } diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoul.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoul.cc index 4cdc6569110..3020a570c52 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoul.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoul.cc @@ -37,9 +37,9 @@ test01() try { wstring one; - stoul(one); + stoul(one); } - catch(std::invalid_argument) + catch(const std::invalid_argument&) { test = true; } @@ -52,9 +52,9 @@ test01() try { wstring one(L"a"); - stoul(one); + stoul(one); } - catch(std::invalid_argument) + catch(const std::invalid_argument&) { test = true; } @@ -67,7 +67,7 @@ test01() try { wstring one(L"a"); - ul1 = stoul(one, 0, 16); + ul1 = stoul(one, 0, 16); } catch(...) { @@ -80,7 +80,7 @@ test01() try { wstring one(L"78"); - ul1 = stoul(one, &idx1, 8); + ul1 = stoul(one, &idx1, 8); } catch(...) { @@ -93,7 +93,7 @@ test01() try { wstring one(L"10112"); - ul1 = stoul(one, &idx1, 2); + ul1 = stoul(one, &idx1, 2); } catch(...) { @@ -106,7 +106,7 @@ test01() try { wstring one(L"0XE"); - ul1 = stoul(one, &idx1, 0); + ul1 = stoul(one, &idx1, 0); } catch(...) { @@ -122,7 +122,7 @@ test01() wstring one(1000, L'9'); ul1 = stoul(one); } - catch(std::out_of_range) + catch(const std::out_of_range&) { test = true; } diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoull.cc b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoull.cc index de16e4ee476..db0175ef050 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoull.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string/numeric_conversions/wchar_t/stoull.cc @@ -37,9 +37,9 @@ test01() try { wstring one; - stoull(one); + stoull(one); } - catch(std::invalid_argument) + catch(const std::invalid_argument&) { test = true; } @@ -47,14 +47,14 @@ test01() { } VERIFY( test ); - + test = false; try { wstring one(L"a"); - stoull(one); + stoull(one); } - catch(std::invalid_argument) + catch(const std::invalid_argument&) { test = true; } @@ -67,7 +67,7 @@ test01() try { wstring one(L"a"); - ull1 = stoull(one, 0, 16); + ull1 = stoull(one, 0, 16); } catch(...) { @@ -80,7 +80,7 @@ test01() try { wstring one(L"78"); - ull1 = stoull(one, &idx1, 8); + ull1 = stoull(one, &idx1, 8); } catch(...) { @@ -93,7 +93,7 @@ test01() try { wstring one(L"10112"); - ull1 = stoull(one, &idx1, 2); + ull1 = stoull(one, &idx1, 2); } catch(...) { @@ -106,7 +106,7 @@ test01() try { wstring one(L"0XE"); - ull1 = stoull(one, &idx1, 0); + ull1 = stoull(one, &idx1, 0); } catch(...) { @@ -122,7 +122,7 @@ test01() wstring one(1000, L'9'); ull1 = stoull(one); } - catch(std::out_of_range) + catch(const std::out_of_range&) { test = true; } diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/compare/char/nonnull.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/compare/char/nonnull.cc index 7060ffb0109..b77de279576 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/compare/char/nonnull.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/compare/char/nonnull.cc @@ -27,3 +27,6 @@ test01() return s.compare((const char*)nullptr); // { dg-warning "\\\[-Wnonnull" } return s.compare(0, 2, (const char*)nullptr); // { dg-warning "\\\[-Wnonnull" } } + +// Ignore additional diagnostic given with -Wsystem-headers: +// { dg-prune-output "argument 1 null where non-null expected" } diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/char/nonnull.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/char/nonnull.cc index 97c7629d388..1025396fba2 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/char/nonnull.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/find/char/nonnull.cc @@ -31,3 +31,6 @@ test01() return s.find_first_not_of((const char*)nullptr); // { dg-warning "\\\[-Wnonnull" } return s.find_first_not_of((const char*)nullptr, 1); // { dg-warning "\\\[-Wnonnull" } } + +// Ignore additional diagnostic given with -Wsystem-headers: +// { dg-prune-output "argument . null where non-null expected" } diff --git a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/rfind/char/nonnull.cc b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/rfind/char/nonnull.cc index 91525a54d1a..fd7a4bcad33 100644 --- a/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/rfind/char/nonnull.cc +++ b/libstdc++-v3/testsuite/21_strings/basic_string_view/operations/rfind/char/nonnull.cc @@ -27,3 +27,6 @@ test01() return s.rfind((const char*)nullptr); // { dg-warning "\\\[-Wnonnull" } return s.rfind((const char*)nullptr, 1); // { dg-warning "\\\[-Wnonnull" } } + +// Ignore additional diagnostic given with -Wsystem-headers: +// { dg-prune-output "argument . null where non-null expected" } diff --git a/libstdc++-v3/testsuite/21_strings/headers/string/synopsis.cc b/libstdc++-v3/testsuite/21_strings/headers/string/synopsis.cc index dea3dd10290..d48394f514d 100644 --- a/libstdc++-v3/testsuite/21_strings/headers/string/synopsis.cc +++ b/libstdc++-v3/testsuite/21_strings/headers/string/synopsis.cc @@ -20,6 +20,12 @@ #include <string> +#if __cplusplus >= 201103L +# define NOTHROW noexcept +#else +# define NOTHROW +#endif + namespace std { // lib.char.traits, character traits: template<class charT> @@ -54,7 +60,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 template<class charT, class traits, class Allocator> bool operator==(const basic_string<charT,traits,Allocator>& lhs, - const basic_string<charT,traits,Allocator>& rhs); + const basic_string<charT,traits,Allocator>& rhs) NOTHROW; template<class charT, class traits, class Allocator> bool operator==(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs); @@ -63,7 +69,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 const charT* rhs); template<class charT, class traits, class Allocator> bool operator!=(const basic_string<charT,traits,Allocator>& lhs, - const basic_string<charT,traits,Allocator>& rhs); + const basic_string<charT,traits,Allocator>& rhs) NOTHROW; template<class charT, class traits, class Allocator> bool operator!=(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs); @@ -73,7 +79,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 template<class charT, class traits, class Allocator> bool operator< (const basic_string<charT,traits,Allocator>& lhs, - const basic_string<charT,traits,Allocator>& rhs); + const basic_string<charT,traits,Allocator>& rhs) NOTHROW; template<class charT, class traits, class Allocator> bool operator< (const basic_string<charT,traits,Allocator>& lhs, const charT* rhs); @@ -82,7 +88,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 const basic_string<charT,traits,Allocator>& rhs); template<class charT, class traits, class Allocator> bool operator> (const basic_string<charT,traits,Allocator>& lhs, - const basic_string<charT,traits,Allocator>& rhs); + const basic_string<charT,traits,Allocator>& rhs) NOTHROW; template<class charT, class traits, class Allocator> bool operator> (const basic_string<charT,traits,Allocator>& lhs, const charT* rhs); @@ -92,7 +98,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 template<class charT, class traits, class Allocator> bool operator<=(const basic_string<charT,traits,Allocator>& lhs, - const basic_string<charT,traits,Allocator>& rhs); + const basic_string<charT,traits,Allocator>& rhs) NOTHROW; template<class charT, class traits, class Allocator> bool operator<=(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs); @@ -101,7 +107,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 const basic_string<charT,traits,Allocator>& rhs); template<class charT, class traits, class Allocator> bool operator>=(const basic_string<charT,traits,Allocator>& lhs, - const basic_string<charT,traits,Allocator>& rhs); + const basic_string<charT,traits,Allocator>& rhs) NOTHROW; template<class charT, class traits, class Allocator> bool operator>=(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs); @@ -112,7 +118,11 @@ _GLIBCXX_END_NAMESPACE_CXX11 // lib.string.special: template<class charT, class traits, class Allocator> void swap(basic_string<charT,traits,Allocator>& lhs, - basic_string<charT,traits,Allocator>& rhs); + basic_string<charT,traits,Allocator>& rhs) +#if __cplusplus >= 201103L + noexcept(noexcept(lhs.swap(rhs))) +#endif + ; template<class charT, class traits, class Allocator> basic_istream<charT,traits>& diff --git a/libstdc++-v3/testsuite/22_locale/locale/cons/12352.cc b/libstdc++-v3/testsuite/22_locale/locale/cons/12352.cc index 9d07c5af063..5fc41116649 100644 --- a/libstdc++-v3/testsuite/22_locale/locale/cons/12352.cc +++ b/libstdc++-v3/testsuite/22_locale/locale/cons/12352.cc @@ -71,6 +71,18 @@ void operator delete[](void* p) throw() deallocate(p); } +#if __cpp_sized_deallocation +void operator delete(void* p, std::size_t) throw() +{ + deallocate(p); +} + +void operator delete[](void* p, std::size_t) throw() +{ + deallocate(p); +} +#endif + void* operator new(std::size_t n, const std::nothrow_t&) throw() { return allocate(n); diff --git a/libstdc++-v3/testsuite/23_containers/deque/modifiers/swap/1.cc b/libstdc++-v3/testsuite/23_containers/deque/modifiers/swap/1.cc index fc347991385..fb4a62c2918 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/modifiers/swap/1.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/modifiers/swap/1.cc @@ -5,28 +5,34 @@ // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. - + // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - + // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. #include <deque> #include <testsuite_hooks.h> - + +#if __cplusplus >= 201103L +# define NOTHROW noexcept +#else +# define NOTHROW +#endif + struct T { int i; }; int swap_calls; namespace std { - template<> - void - deque<T, allocator<T> >::swap(deque<T, allocator<T> >&) + template<> + void + deque<T, allocator<T> >::swap(deque<T, allocator<T> >&) NOTHROW { ++swap_calls; } } diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/cons/11.cc b/libstdc++-v3/testsuite/23_containers/forward_list/cons/11.cc index cb820fe7486..19415411282 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/cons/11.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/cons/11.cc @@ -27,6 +27,7 @@ struct A { A() = default; A(const A&) { if (fail) throw fail; } + A& operator=(const A&) = default; }; void test01() diff --git a/libstdc++-v3/testsuite/23_containers/headers/bitset/synopsis.cc b/libstdc++-v3/testsuite/23_containers/headers/bitset/synopsis.cc index 3e9a7049631..d67a037fb7d 100644 --- a/libstdc++-v3/testsuite/23_containers/headers/bitset/synopsis.cc +++ b/libstdc++-v3/testsuite/23_containers/headers/bitset/synopsis.cc @@ -21,18 +21,24 @@ #include <bitset> +#if __cplusplus >= 201103L +# define NOTHROW noexcept +#else +# define NOTHROW +#endif + namespace std { template <size_t N> class bitset; // 23.3.5.3 bitset operations: template <size_t N> - bitset<N> operator&(const bitset<N>&, const bitset<N>&); + bitset<N> operator&(const bitset<N>&, const bitset<N>&) NOTHROW; template <size_t N> - bitset<N> operator|(const bitset<N>&, const bitset<N>&); + bitset<N> operator|(const bitset<N>&, const bitset<N>&) NOTHROW; template <size_t N> - bitset<N> operator^(const bitset<N>&, const bitset<N>&); + bitset<N> operator^(const bitset<N>&, const bitset<N>&) NOTHROW; template <class charT, class traits, size_t N> basic_istream<charT, traits>& diff --git a/libstdc++-v3/testsuite/23_containers/headers/deque/synopsis.cc b/libstdc++-v3/testsuite/23_containers/headers/deque/synopsis.cc index f043d54bd05..be409856452 100644 --- a/libstdc++-v3/testsuite/23_containers/headers/deque/synopsis.cc +++ b/libstdc++-v3/testsuite/23_containers/headers/deque/synopsis.cc @@ -21,6 +21,12 @@ #include <deque> +#if __cplusplus >= 201103L +# define NOTHROW(X) noexcept(X) +#else +# define NOTHROW(X) +#endif + namespace std { template <class T, class Allocator> class deque; @@ -43,5 +49,6 @@ namespace std { bool operator<= (const deque<T,Allocator>& x, const deque<T,Allocator>& y); template <class T, class Allocator> - void swap(deque<T,Allocator>& x, deque<T,Allocator>& y); + void swap(deque<T,Allocator>& x, deque<T,Allocator>& y) + NOTHROW(noexcept(x.swap(y))); } diff --git a/libstdc++-v3/testsuite/23_containers/headers/forward_list/synopsis.cc b/libstdc++-v3/testsuite/23_containers/headers/forward_list/synopsis.cc index 3c2c143df16..5664306cefc 100644 --- a/libstdc++-v3/testsuite/23_containers/headers/forward_list/synopsis.cc +++ b/libstdc++-v3/testsuite/23_containers/headers/forward_list/synopsis.cc @@ -49,5 +49,6 @@ namespace std { const forward_list<T,Allocator>&); template <class T, class Allocator> - void swap(forward_list<T,Allocator>& x, forward_list<T,Allocator>& y); + void swap(forward_list<T,Allocator>& x, forward_list<T,Allocator>& y) + noexcept(noexcept(x.swap(y))); } diff --git a/libstdc++-v3/testsuite/23_containers/headers/list/synopsis.cc b/libstdc++-v3/testsuite/23_containers/headers/list/synopsis.cc index c42f23635dc..6cfd9ff437e 100644 --- a/libstdc++-v3/testsuite/23_containers/headers/list/synopsis.cc +++ b/libstdc++-v3/testsuite/23_containers/headers/list/synopsis.cc @@ -21,6 +21,12 @@ #include <list> +#if __cplusplus >= 201103L +# define NOTHROW(X) noexcept(X) +#else +# define NOTHROW(X) +#endif + namespace std { _GLIBCXX_BEGIN_NAMESPACE_CXX11 template <class T, class Allocator> class list; @@ -45,5 +51,6 @@ _GLIBCXX_END_NAMESPACE_CXX11 bool operator<=(const list<T,Allocator>& x, const list<T,Allocator>&); template <class T, class Allocator> - void swap(list<T,Allocator>& x, list<T,Allocator>& y); + void swap(list<T,Allocator>& x, list<T,Allocator>& y) + NOTHROW(noexcept(x.swap(y))); } diff --git a/libstdc++-v3/testsuite/23_containers/headers/map/synopsis.cc b/libstdc++-v3/testsuite/23_containers/headers/map/synopsis.cc index d57b41fa1de..f70cd069006 100644 --- a/libstdc++-v3/testsuite/23_containers/headers/map/synopsis.cc +++ b/libstdc++-v3/testsuite/23_containers/headers/map/synopsis.cc @@ -21,6 +21,12 @@ #include <map> +#if __cplusplus >= 201103L +# define NOTHROW(X) noexcept(X) +#else +# define NOTHROW(X) +#endif + namespace std { template <class Key, class T, class Compare, class Allocator> class map; @@ -44,7 +50,8 @@ namespace std { const map<Key,T,Compare,Allocator>& y); template <class Key, class T, class Compare, class Allocator> void swap(map<Key,T,Compare,Allocator>& x, - map<Key,T,Compare,Allocator>& y); + map<Key,T,Compare,Allocator>& y) + NOTHROW(noexcept(x.swap(y))); template <class Key, class T, class Compare, class Allocator> class multimap; @@ -68,5 +75,6 @@ namespace std { const multimap<Key,T,Compare,Allocator>& y); template <class Key, class T, class Compare, class Allocator> void swap(multimap<Key,T,Compare,Allocator>& x, - multimap<Key,T,Compare,Allocator>& y); + multimap<Key,T,Compare,Allocator>& y) + NOTHROW(noexcept(x.swap(y))); } diff --git a/libstdc++-v3/testsuite/23_containers/headers/queue/synopsis.cc b/libstdc++-v3/testsuite/23_containers/headers/queue/synopsis.cc index 94038eeda44..4426a494152 100644 --- a/libstdc++-v3/testsuite/23_containers/headers/queue/synopsis.cc +++ b/libstdc++-v3/testsuite/23_containers/headers/queue/synopsis.cc @@ -20,6 +20,12 @@ #include <queue> +#if __cplusplus >= 201103L +# define NOTHROW noexcept +#else +# define NOTHROW +#endif + namespace std { template <class T, class Container> class queue; template <class T, class Container> diff --git a/libstdc++-v3/testsuite/23_containers/headers/set/synopsis.cc b/libstdc++-v3/testsuite/23_containers/headers/set/synopsis.cc index 4172b3ba761..5ecbabec790 100644 --- a/libstdc++-v3/testsuite/23_containers/headers/set/synopsis.cc +++ b/libstdc++-v3/testsuite/23_containers/headers/set/synopsis.cc @@ -21,6 +21,12 @@ #include <set> +#if __cplusplus >= 201103L +# define NOTHROW(X) noexcept(X) +#else +# define NOTHROW(X) +#endif + namespace std { template <class Key, class Compare, class Allocator> class set; @@ -51,7 +57,8 @@ namespace std { template <class Key, class Compare, class Allocator> void swap(set<Key,Compare,Allocator>& x, - set<Key,Compare,Allocator>& y); + set<Key,Compare,Allocator>& y) + NOTHROW(noexcept(x.swap(y))); template <class Key, class Compare, class Allocator> class multiset; @@ -82,5 +89,6 @@ namespace std { template <class Key, class Compare, class Allocator> void swap(multiset<Key,Compare,Allocator>& x, - multiset<Key,Compare,Allocator>& y); + multiset<Key,Compare,Allocator>& y) + NOTHROW(noexcept(x.swap(y))); } diff --git a/libstdc++-v3/testsuite/23_containers/headers/vector/synopsis.cc b/libstdc++-v3/testsuite/23_containers/headers/vector/synopsis.cc index 54f449e56cb..a728f54b732 100644 --- a/libstdc++-v3/testsuite/23_containers/headers/vector/synopsis.cc +++ b/libstdc++-v3/testsuite/23_containers/headers/vector/synopsis.cc @@ -21,6 +21,12 @@ #include <vector> +#if __cplusplus >= 201103L +# define NOTHROW(X) noexcept(X) +#else +# define NOTHROW(X) +#endif + namespace std { template <class T, class Allocator> class vector; @@ -49,7 +55,8 @@ namespace std { const vector<T,Allocator>& y); template <class T, class Allocator> - void swap(vector<T,Allocator>& x, vector<T,Allocator>& y); + void swap(vector<T,Allocator>& x, vector<T,Allocator>& y) + NOTHROW(noexcept(x.swap(y))); template <class Allocator> class vector<bool,Allocator>; diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/1.cc b/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/1.cc index a95400e237d..24fa534fd0d 100644 --- a/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/1.cc +++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/1.cc @@ -5,12 +5,12 @@ // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. - + // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - + // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. @@ -18,11 +18,17 @@ #include <list> #include "1.h" +#if __cplusplus >= 201103L +# define NOTHROW noexcept +#else +# define NOTHROW +#endif + namespace std { - template<> - void - list<T, allocator<T> >::swap(list<T, allocator<T> >&) + template<> + void + list<T, allocator<T> >::swap(list<T, allocator<T> >&) NOTHROW { ++swap_calls; } } diff --git a/libstdc++-v3/testsuite/23_containers/map/modifiers/swap/1.cc b/libstdc++-v3/testsuite/23_containers/map/modifiers/swap/1.cc index 95ec943fb83..98e4344ceb3 100644 --- a/libstdc++-v3/testsuite/23_containers/map/modifiers/swap/1.cc +++ b/libstdc++-v3/testsuite/23_containers/map/modifiers/swap/1.cc @@ -5,19 +5,25 @@ // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. - + // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - + // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. #include <map> #include <testsuite_hooks.h> - + +#if __cplusplus >= 201103L +# define NOTHROW noexcept +#else +# define NOTHROW +#endif + struct T { int i; }; // T must be LessThanComparable to pass concept-checks @@ -27,9 +33,9 @@ int swap_calls; namespace std { - template<> - void - map<T, int>::swap(map<T, int>&) + template<> + void + map<T, int>::swap(map<T, int>&) NOTHROW { ++swap_calls; } } diff --git a/libstdc++-v3/testsuite/23_containers/multimap/modifiers/swap/1.cc b/libstdc++-v3/testsuite/23_containers/multimap/modifiers/swap/1.cc index c737040e42d..bdfd152fe94 100644 --- a/libstdc++-v3/testsuite/23_containers/multimap/modifiers/swap/1.cc +++ b/libstdc++-v3/testsuite/23_containers/multimap/modifiers/swap/1.cc @@ -5,19 +5,25 @@ // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. - + // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - + // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. #include <map> #include <testsuite_hooks.h> - + +#if __cplusplus >= 201103L +# define NOTHROW noexcept +#else +# define NOTHROW +#endif + struct T { int i; }; // T must be LessThanComparable to pass concept-checks @@ -27,9 +33,9 @@ int swap_calls; namespace std { - template<> - void - multimap<T, int>::swap(multimap<T, int>&) + template<> + void + multimap<T, int>::swap(multimap<T, int>&) NOTHROW { ++swap_calls; } } diff --git a/libstdc++-v3/testsuite/23_containers/multiset/modifiers/swap/1.cc b/libstdc++-v3/testsuite/23_containers/multiset/modifiers/swap/1.cc index f2342904048..f56894deb21 100644 --- a/libstdc++-v3/testsuite/23_containers/multiset/modifiers/swap/1.cc +++ b/libstdc++-v3/testsuite/23_containers/multiset/modifiers/swap/1.cc @@ -5,19 +5,25 @@ // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. - + // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - + // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. #include <set> #include <testsuite_hooks.h> - + +#if __cplusplus >= 201103L +# define NOTHROW noexcept +#else +# define NOTHROW +#endif + struct T { int i; }; // T must be LessThanComparable to pass concept-checks @@ -27,9 +33,9 @@ int swap_calls; namespace std { - template<> - void - multiset<T>::swap(multiset<T>&) + template<> + void + multiset<T>::swap(multiset<T>&) NOTHROW { ++swap_calls; } } diff --git a/libstdc++-v3/testsuite/23_containers/set/modifiers/swap/1.cc b/libstdc++-v3/testsuite/23_containers/set/modifiers/swap/1.cc index fce2f80dcb0..be884613532 100644 --- a/libstdc++-v3/testsuite/23_containers/set/modifiers/swap/1.cc +++ b/libstdc++-v3/testsuite/23_containers/set/modifiers/swap/1.cc @@ -5,19 +5,25 @@ // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. - + // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - + // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. #include <set> #include <testsuite_hooks.h> - + +#if __cplusplus >= 201103L +# define NOTHROW noexcept +#else +# define NOTHROW +#endif + struct T { int i; }; // T must be LessThanComparable to pass concept-checks @@ -27,9 +33,9 @@ int swap_calls; namespace std { - template<> - void - set<T>::swap(set<T>&) + template<> + void + set<T>::swap(set<T>&) NOTHROW { ++swap_calls; } } diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/56267-2.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/56267-2.cc index c0d41c07669..1347866f810 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/56267-2.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/56267-2.cc @@ -25,6 +25,8 @@ struct audrey2hash : std::hash<int> audrey2hash(int) { } + audrey2hash(const audrey2hash&) = default; + audrey2hash& operator=(const audrey2hash&) { throw "Don't assign the plants"; } }; diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/23632.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/23632.cc index 26423ee5d13..339876f8710 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/bool/23632.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/23632.cc @@ -29,7 +29,8 @@ void test01() const std::vector<bool>::const_iterator cfu = v.begin(); if (cfu[0]) - ; + { + } } int main() diff --git a/libstdc++-v3/testsuite/23_containers/vector/modifiers/swap/1.cc b/libstdc++-v3/testsuite/23_containers/vector/modifiers/swap/1.cc index e15b47755e0..bbfa62084a1 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/modifiers/swap/1.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/modifiers/swap/1.cc @@ -5,28 +5,34 @@ // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. - + // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. - + // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. #include <vector> #include <testsuite_hooks.h> - + +#if __cplusplus >= 201103L +# define NOTHROW noexcept +#else +# define NOTHROW +#endif + struct T { int i; }; int swap_calls; namespace std { - template<> - void - vector<T, allocator<T> >::swap(vector<T, allocator<T> >&) + template<> + void + vector<T, allocator<T> >::swap(vector<T, allocator<T> >&) NOTHROW { ++swap_calls; } } diff --git a/libstdc++-v3/testsuite/25_algorithms/heap/moveable2.cc b/libstdc++-v3/testsuite/25_algorithms/heap/moveable2.cc index c1116591614..0ec8359d912 100644 --- a/libstdc++-v3/testsuite/25_algorithms/heap/moveable2.cc +++ b/libstdc++-v3/testsuite/25_algorithms/heap/moveable2.cc @@ -44,13 +44,13 @@ bool are_ordered(const rvalstruct& lhs, const rvalstruct& rhs) bool are_ordered_int(const int& lhs, const int& rhs) { return lhs < rhs; } -void +void check_make(int* array, int length) { rvalstruct makeheap[9]; int makeheap_ref[9]; std::copy(array, array + length, makeheap); - std::copy(array, array + length, makeheap_ref); + std::copy(array, array + length, makeheap_ref); container makecon(makeheap, makeheap + length); container_ref makecon_ref(makeheap_ref, makeheap_ref + length); std::make_heap(makecon.begin(), makecon.end(), are_ordered); @@ -75,7 +75,7 @@ check_pop(int* array, int length) std::pop_heap(popcon_ref.begin(), popcon_ref.end(), are_ordered_int); for (int z = 0; z < length; ++z) VERIFY( popheap[z] == popheap_ref[z] ); - VERIFY( (std::__is_heap(popheap, popheap + length - 1), are_ordered) ); + VERIFY( std::__is_heap(popheap, popheap + length - 1, are_ordered) ); for (int z = 0; z < length; ++z) VERIFY( popheap[z].val <= popheap[length-1].val && popheap[z].valid ); } @@ -104,7 +104,7 @@ check_push(int* array, int pushval, int length) rvalstruct pushheap[10]; int pushheap_ref[10]; std::copy(array, array + length, pushheap); - std::copy(array, array + length, pushheap_ref); + std::copy(array, array + length, pushheap_ref); pushheap[length] = pushval; pushheap_ref[length] = pushval; container pushcon(pushheap, pushheap + length + 1); diff --git a/libstdc++-v3/testsuite/25_algorithms/sample/1.cc b/libstdc++-v3/testsuite/25_algorithms/sample/1.cc index 5fc888f7b82..ea92c4a0ed5 100644 --- a/libstdc++-v3/testsuite/25_algorithms/sample/1.cc +++ b/libstdc++-v3/testsuite/25_algorithms/sample/1.cc @@ -94,6 +94,7 @@ test04() // forward iterator for population and output iterator for result auto res = sample(pop.begin(), pop.end(), samp.begin(), sample_size, rng); + VERIFY( res.ptr == (out + sample_size) ); // verify no duplicates std::sort(std::begin(out), std::end(out)); diff --git a/libstdc++-v3/testsuite/25_algorithms/search/searcher.cc b/libstdc++-v3/testsuite/25_algorithms/search/searcher.cc index 64b7fb122b3..0c371bcaa6e 100644 --- a/libstdc++-v3/testsuite/25_algorithms/search/searcher.cc +++ b/libstdc++-v3/testsuite/25_algorithms/search/searcher.cc @@ -29,7 +29,7 @@ struct nocopy struct P { int* first; }; - P operator()(int* f, int* l) const { return {f}; } + P operator()(int* f, int*) const { return {f}; } }; void diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/exceptions/char/9561.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/exceptions/char/9561.cc index 4334598e412..81fd490e8b2 100644 --- a/libstdc++-v3/testsuite/27_io/basic_ostream/exceptions/char/9561.cc +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/exceptions/char/9561.cc @@ -46,7 +46,7 @@ void test01() { strm << std::endl; } - catch(foobar) + catch(const foobar&) { // strm should throw foobar and not do anything else VERIFY(strm.bad()); diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/exceptions/wchar_t/9561.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/exceptions/wchar_t/9561.cc index 99cd6ee4b46..0fdb05bdbeb 100644 --- a/libstdc++-v3/testsuite/27_io/basic_ostream/exceptions/wchar_t/9561.cc +++ b/libstdc++-v3/testsuite/27_io/basic_ostream/exceptions/wchar_t/9561.cc @@ -44,7 +44,7 @@ void test01() { strm << std::endl; } - catch(foobar) + catch(const foobar&) { // strm should throw foobar and not do anything else VERIFY(strm.bad()); diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc index 7e018b51af2..90685b5db7e 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/remove_all.cc @@ -156,7 +156,7 @@ test04() // remove write permission on the directory: fs::permissions(dir, fs::perms::owner_read|fs::perms::owner_exec); n = fs::remove_all(dir, ec); - VERIFY( n == -1 ); + VERIFY( n == std::uintmax_t(-1) ); VERIFY( ec == std::errc::permission_denied ); // not ENOTEMPTY try { diff --git a/libstdc++-v3/testsuite/experimental/any/assign/2.cc b/libstdc++-v3/testsuite/experimental/any/assign/2.cc index e38455bdaa8..c2d7fec955c 100644 --- a/libstdc++-v3/testsuite/experimental/any/assign/2.cc +++ b/libstdc++-v3/testsuite/experimental/any/assign/2.cc @@ -31,14 +31,14 @@ struct X { X() = default; X(const X&) { copied = true; } - X(X&& x) { moved = true; } + X(X&&) { moved = true; } }; struct X2 { X2() = default; X2(const X2&) { copied = true; } - X2(X2&& x) noexcept { moved = true; } + X2(X2&&) noexcept { moved = true; } }; void test01() diff --git a/libstdc++-v3/testsuite/experimental/any/cons/2.cc b/libstdc++-v3/testsuite/experimental/any/cons/2.cc index d6af4475462..d6241ae5d84 100644 --- a/libstdc++-v3/testsuite/experimental/any/cons/2.cc +++ b/libstdc++-v3/testsuite/experimental/any/cons/2.cc @@ -30,14 +30,14 @@ struct X { X() = default; X(const X&) { copied = true; } - X(X&& x) { moved = true; } + X(X&&) { moved = true; } }; struct X2 { X2() = default; X2(const X2&) { copied = true; } - X2(X2&& x) noexcept { moved = true; } + X2(X2&&) noexcept { moved = true; } }; void test01() diff --git a/libstdc++-v3/testsuite/experimental/filesystem/operations/remove_all.cc b/libstdc++-v3/testsuite/experimental/filesystem/operations/remove_all.cc index 0e2aedae96d..c346a95eff4 100644 --- a/libstdc++-v3/testsuite/experimental/filesystem/operations/remove_all.cc +++ b/libstdc++-v3/testsuite/experimental/filesystem/operations/remove_all.cc @@ -124,7 +124,7 @@ test04() // remove write permission on the directory: fs::permissions(dir, fs::perms::owner_read|fs::perms::owner_exec); n = fs::remove_all(dir, ec); - VERIFY( n == -1 ); + VERIFY( n == std::uintmax_t(-1) ); VERIFY( ec == std::errc::permission_denied ); // not ENOTEMPTY try { diff --git a/libstdc++-v3/testsuite/experimental/memory/observer_ptr/cons/cons.cc b/libstdc++-v3/testsuite/experimental/memory/observer_ptr/cons/cons.cc index 4b29da22469..3d6bb41e3ba 100644 --- a/libstdc++-v3/testsuite/experimental/memory/observer_ptr/cons/cons.cc +++ b/libstdc++-v3/testsuite/experimental/memory/observer_ptr/cons/cons.cc @@ -44,7 +44,6 @@ void test02() void test03() { - int x{}; observer_ptr<int> a; observer_ptr<const int> b{a}; VERIFY(a == b); diff --git a/libstdc++-v3/testsuite/experimental/memory_resource/null_memory_resource.cc b/libstdc++-v3/testsuite/experimental/memory_resource/null_memory_resource.cc index 01d4a949e98..284b42829ca 100644 --- a/libstdc++-v3/testsuite/experimental/memory_resource/null_memory_resource.cc +++ b/libstdc++-v3/testsuite/experimental/memory_resource/null_memory_resource.cc @@ -31,7 +31,7 @@ test06() memory_resource* r = null_memory_resource(); bool caught = false; - void* p = nullptr; + void* p __attribute__((unused)) = nullptr; try { p = r->allocate(1); } catch (const std::bad_alloc&) { diff --git a/libstdc++-v3/testsuite/experimental/source_location/1.cc b/libstdc++-v3/testsuite/experimental/source_location/1.cc index 9f5a00df99b..5ca5b3addc1 100644 --- a/libstdc++-v3/testsuite/experimental/source_location/1.cc +++ b/libstdc++-v3/testsuite/experimental/source_location/1.cc @@ -17,6 +17,7 @@ // { dg-do run { target c++14 } } // { dg-require-cstdint "" } +// { dg-options "-Wno-address" } #include <experimental/source_location> #include <experimental/string_view> @@ -29,7 +30,7 @@ void test01() { constexpr source_location loc = source_location::current(); - static_assert( loc.line() == 31 ); + static_assert( loc.line() == 32 ); // static_assert( loc.column() == 35 ); VERIFY( loc.file_name() == __FILE__ ); VERIFY( loc.function_name() == string_view(__FUNCTION__) ); @@ -51,13 +52,13 @@ struct S { void test02() { S s0; - VERIFY( s0.loc.line() == 53 ); + VERIFY( s0.loc.line() == 54 ); // static_assert( s0.loc.column() == 7 ); VERIFY( s0.loc.file_name() == __FILE__ ); VERIFY( s0.loc.function_name() == string_view(__FUNCTION__) ); S s1(1); - VERIFY( s1.loc.line() == 47 ); + VERIFY( s1.loc.line() == 48 ); VERIFY( s1.loc.file_name() == __FILE__ ); VERIFY( s1.loc.function_name() == s1.func ); } @@ -75,21 +76,21 @@ source_location g(string_view& func) { void test03() { auto loc = f(); // f's first argument corresponds to this line of code - VERIFY( loc.line() == 77 ); + VERIFY( loc.line() == 78 ); // static_assert( loc.column() == 16 ); VERIFY( loc.file_name() == __FILE__ ); VERIFY( loc.function_name() == string_view(__FUNCTION__) ); source_location c = source_location::current(); loc = f(c); // f's first argument gets the same values as c, above - VERIFY( loc.line() == 83 ); + VERIFY( loc.line() == 84 ); // static_assert( loc.column() == 23 ); VERIFY( loc.file_name() == __FILE__ ); VERIFY( loc.function_name() == string_view(__FUNCTION__) ); string_view func; loc = g(func); - VERIFY( loc.line() == 70 ); + VERIFY( loc.line() == 71 ); // static_assert( loc.column() == 23 ); VERIFY( loc.file_name() == __FILE__ ); VERIFY( loc.function_name() == func ); diff --git a/libstdc++-v3/testsuite/ext/pod_char_traits.cc b/libstdc++-v3/testsuite/ext/pod_char_traits.cc index 5a12d3a623c..4124d2193f2 100644 --- a/libstdc++-v3/testsuite/ext/pod_char_traits.cc +++ b/libstdc++-v3/testsuite/ext/pod_char_traits.cc @@ -22,6 +22,7 @@ // Benjamin Kosnik <bkoz@redhat.com> #include <ext/pod_char_traits.h> +#include <testsuite_hooks.h> int main() { @@ -40,10 +41,12 @@ int main() char_type c1 = { uc1 }; char_type c2 = { uc2 }; test = !(c1 == c2); + VERIFY( test ); // 2 char_traits test = traits_type::eq(c1, c2); - + VERIFY( ! test ); + // 3 basic_string<char_type> typedef std::basic_string<char_type> string_type; string_type str; diff --git a/libstdc++-v3/testsuite/ext/vstring/modifiers/clear/56166.cc b/libstdc++-v3/testsuite/ext/vstring/modifiers/clear/56166.cc index ce2987f8722..84dd79eef5e 100644 --- a/libstdc++-v3/testsuite/ext/vstring/modifiers/clear/56166.cc +++ b/libstdc++-v3/testsuite/ext/vstring/modifiers/clear/56166.cc @@ -90,7 +90,7 @@ int main() fail_after = i; f(); break; - } catch (std::bad_alloc) { + } catch (const std::bad_alloc&) { } } } diff --git a/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.swappable/swap.cc b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.swappable/swap.cc index 314d4a9a326..a922cf94cbd 100644 --- a/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.swappable/swap.cc +++ b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.swappable/swap.cc @@ -30,7 +30,7 @@ namespace nu constexpr void swap(U& l, U& r) { l.i = r.i = 99; } } -constexpr bool check_struct_with_adl_swap(int i) +constexpr bool check_struct_with_adl_swap(int) { nu::S s1, s2; std::ranges::swap(s1, s2); @@ -39,7 +39,7 @@ constexpr bool check_struct_with_adl_swap(int i) static_assert(check_struct_with_adl_swap(1)); -constexpr bool check_array_with_adl_swap(int i) +constexpr bool check_array_with_adl_swap(int) { nu::S s1[2], s2[2]; std::ranges::swap(s1, s2); diff --git a/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.swappable/swappable.cc b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.swappable/swappable.cc index 37a72e0b653..a62423f1600 100644 --- a/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.swappable/swappable.cc +++ b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.swappable/swappable.cc @@ -23,11 +23,11 @@ namespace nu { struct S { bool swapped = false; }; - constexpr void swap(S& l, S& r) { } + constexpr void swap(S&, S&) { } struct T { int i; }; union U { char c; int i; }; - constexpr void swap(U& l, U& r) { } + constexpr void swap(U&, U&) { } } static_assert( std::swappable<nu::S> ); diff --git a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc index 509fc30decf..c1c503022c1 100644 --- a/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc +++ b/libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc @@ -37,3 +37,7 @@ void test01() std::tr1::shared_ptr<X> p9(ap()); // { dg-error "here" } // { dg-error "incomplete" "" { target *-*-* } 593 } } + +// Ignore additional diagnostic given with -Wsystem-headers: +// { dg-prune-output "has incomplete type" } +// { dg-prune-output "possible problem detected" } diff --git a/libstdc++-v3/testsuite/tr1/3_function_objects/function/1.cc b/libstdc++-v3/testsuite/tr1/3_function_objects/function/1.cc index e43255c8c9c..0037974cf44 100644 --- a/libstdc++-v3/testsuite/tr1/3_function_objects/function/1.cc +++ b/libstdc++-v3/testsuite/tr1/3_function_objects/function/1.cc @@ -67,7 +67,7 @@ void test01() f1(3.14159f); VERIFY( false ); } - catch (bad_function_call) + catch (const bad_function_call&) { thrown = true; } diff --git a/libstdc++-v3/testsuite/util/replacement_memory_operators.h b/libstdc++-v3/testsuite/util/replacement_memory_operators.h index a90ffd47524..34c6e1b1a8b 100644 --- a/libstdc++-v3/testsuite/util/replacement_memory_operators.h +++ b/libstdc++-v3/testsuite/util/replacement_memory_operators.h @@ -116,3 +116,7 @@ void operator delete(void* p) throw() std::printf("%lu allocations to be released \n", (unsigned long)count); } } + +#if __cpp_sized_deallocation +void operator delete(void* p, std::size_t) throw() { ::operator delete(p); } +#endif diff --git a/libstdc++-v3/testsuite/util/testsuite_api.h b/libstdc++-v3/testsuite/util/testsuite_api.h index d4edd2593b5..e22e04e6237 100644 --- a/libstdc++-v3/testsuite/util/testsuite_api.h +++ b/libstdc++-v3/testsuite/util/testsuite_api.h @@ -86,6 +86,9 @@ namespace __gnu_test NonDefaultConstructible(const NonDefaultConstructible&) { } #if __cplusplus >= 201103L + NonDefaultConstructible& + operator=(const NonDefaultConstructible&) = default; + // For std::iota. NonDefaultConstructible& operator++() diff --git a/libstdc++-v3/testsuite/util/testsuite_containers.h b/libstdc++-v3/testsuite/util/testsuite_containers.h index 33259ae3601..0a030b3a29c 100644 --- a/libstdc++-v3/testsuite/util/testsuite_containers.h +++ b/libstdc++-v3/testsuite/util/testsuite_containers.h @@ -168,7 +168,7 @@ namespace __gnu_test template<typename _Tp> struct reverse_members<_Tp, false> { - reverse_members(_Tp& container) { } + reverse_members(_Tp&) { } }; template<typename _Iterator, diff --git a/libstdc++-v3/testsuite/util/testsuite_iterators.h b/libstdc++-v3/testsuite/util/testsuite_iterators.h index 2eaafa16bee..a67f3aa6185 100644 --- a/libstdc++-v3/testsuite/util/testsuite_iterators.h +++ b/libstdc++-v3/testsuite/util/testsuite_iterators.h @@ -599,7 +599,7 @@ namespace __gnu_test ItType<T> it(int pos) { - ITERATOR_VERIFY(pos >= 0 && pos <= size()); + ITERATOR_VERIFY(pos >= 0 && (unsigned)pos <= size()); return ItType<T>(bounds.first + pos, &bounds); } diff --git a/libstdc++-v3/testsuite/util/testsuite_new_operators.h b/libstdc++-v3/testsuite/util/testsuite_new_operators.h index e3b6e926f5a..46612bd9e5d 100644 --- a/libstdc++-v3/testsuite/util/testsuite_new_operators.h +++ b/libstdc++-v3/testsuite/util/testsuite_new_operators.h @@ -65,6 +65,11 @@ void operator delete(void* p) throw() std::free(p); } +#if __cpp_sized_deallocation +void operator delete(void* p, std::size_t) throw() +{ ::operator delete(p); } +#endif + void operator delete(void* p, const std::nothrow_t&) throw() { if (p) |