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.
This commit is contained in:
Jonathan Wakely 2020-10-29 22:47:21 +00:00
parent 11dc4c4e13
commit 13feb0234b
74 changed files with 393 additions and 243 deletions

View File

@ -38,7 +38,7 @@ int init()
void clean_terminate() { _Exit(0); }
int
main (int argc, char **argv)
main ()
{
std::set_terminate(clean_terminate);
init();

View File

@ -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;

View File

@ -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()

View File

@ -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()

View File

@ -67,7 +67,7 @@ void test01()
f1(3.14159f);
VERIFY( false );
}
catch (bad_function_call)
catch (const bad_function_call&)
{
thrown = true;
}

View File

@ -31,7 +31,4 @@ struct C {
C operator()(int, int);
};
int main() {
C c = C();
}
C c = C();

View File

@ -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&&) { }

View File

@ -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);

View File

@ -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;
}

View File

@ -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) { }
};

View File

@ -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);

View File

@ -87,7 +87,7 @@ int main()
fail_after = i;
f();
break;
} catch (std::bad_alloc) {
} catch (const std::bad_alloc&) {
}
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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" }

View File

@ -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" }

View File

@ -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" }

View File

@ -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>&

View File

@ -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);

View File

@ -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; }
}

View File

@ -27,6 +27,7 @@ struct A
{
A() = default;
A(const A&) { if (fail) throw fail; }
A& operator=(const A&) = default;
};
void test01()

View File

@ -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>&

View File

@ -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)));
}

View File

@ -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)));
}

View File

@ -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)));
}

View File

@ -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)));
}

View File

@ -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>

View File

@ -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)));
}

View File

@ -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>;

View File

@ -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; }
}

View File

@ -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; }
}

View File

@ -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; }
}

View File

@ -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; }
}

View File

@ -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; }
}

View File

@ -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"; }
};

View File

@ -29,7 +29,8 @@ void test01()
const std::vector<bool>::const_iterator cfu = v.begin();
if (cfu[0])
;
{
}
}
int main()

View File

@ -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; }
}

View File

@ -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);

View File

@ -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));

View File

@ -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

View File

@ -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());

View File

@ -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());

View File

@ -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 {

View File

@ -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()

View File

@ -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()

View File

@ -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 {

View File

@ -44,7 +44,6 @@ void test02()
void test03()
{
int x{};
observer_ptr<int> a;
observer_ptr<const int> b{a};
VERIFY(a == b);

View File

@ -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&) {

View File

@ -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 );

View File

@ -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;

View File

@ -90,7 +90,7 @@ int main()
fail_after = i;
f();
break;
} catch (std::bad_alloc) {
} catch (const std::bad_alloc&) {
}
}
}

View File

@ -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);

View File

@ -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> );

View File

@ -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" }

View File

@ -67,7 +67,7 @@ void test01()
f1(3.14159f);
VERIFY( false );
}
catch (bad_function_call)
catch (const bad_function_call&)
{
thrown = true;
}

View File

@ -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

View File

@ -86,6 +86,9 @@ namespace __gnu_test
NonDefaultConstructible(const NonDefaultConstructible&) { }
#if __cplusplus >= 201103L
NonDefaultConstructible&
operator=(const NonDefaultConstructible&) = default;
// For std::iota.
NonDefaultConstructible&
operator++()

View File

@ -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,

View File

@ -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);
}

View File

@ -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)