From 50875e80e1ed5ba34bf4342571530b7ad516af1b Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Tue, 19 Nov 2013 22:03:30 +0000 Subject: [PATCH] noexcept.cc: Change to compile-only test. * testsuite/23_containers/forward_list/allocator/noexcept.cc: Change to compile-only test. Adjust swap overload to handle rebound allocators. * testsuite/23_containers/map/allocator/noexcept.cc: Likewise. * testsuite/23_containers/multimap/allocator/noexcept.cc: Likewise. * testsuite/23_containers/multiset/allocator/noexcept.cc: Likewise. * testsuite/23_containers/set/allocator/noexcept.cc: Likewise. * testsuite/23_containers/unordered_map/allocator/noexcept.cc: Likewise. * testsuite/23_containers/unordered_multimap/allocator/noexcept.cc: Likewise. * testsuite/23_containers/unordered_multiset/allocator/noexcept.cc: Likewise. * testsuite/23_containers/unordered_set/allocator/noexcept.cc: Likewise. * testsuite/23_containers/vector/allocator/noexcept.cc: Likewise. * testsuite/23_containers/vector/allocator/swap.cc: Add elements before swapping. From-SVN: r205056 --- libstdc++-v3/ChangeLog | 21 ++++++++++++++++ .../forward_list/allocator/noexcept.cc | 24 ++++++------------- .../23_containers/map/allocator/noexcept.cc | 23 +++++------------- .../multimap/allocator/noexcept.cc | 23 +++++------------- .../multiset/allocator/noexcept.cc | 22 +++++------------ .../23_containers/set/allocator/noexcept.cc | 23 +++++------------- .../unordered_map/allocator/noexcept.cc | 24 ++++++------------- .../unordered_multimap/allocator/noexcept.cc | 24 ++++++------------- .../unordered_multiset/allocator/noexcept.cc | 24 ++++++------------- .../unordered_set/allocator/noexcept.cc | 24 ++++++------------- .../vector/allocator/noexcept.cc | 22 +++++------------ .../23_containers/vector/allocator/swap.cc | 2 ++ 12 files changed, 88 insertions(+), 168 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 946b67f8cfc2..27629f9c59d2 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,24 @@ +2013-11-19 Jonathan Wakely + + * testsuite/23_containers/forward_list/allocator/noexcept.cc: Change + to compile-only test. Adjust swap overload to handle rebound + allocators. + * testsuite/23_containers/map/allocator/noexcept.cc: Likewise. + * testsuite/23_containers/multimap/allocator/noexcept.cc: Likewise. + * testsuite/23_containers/multiset/allocator/noexcept.cc: Likewise. + * testsuite/23_containers/set/allocator/noexcept.cc: Likewise. + * testsuite/23_containers/unordered_map/allocator/noexcept.cc: + Likewise. + * testsuite/23_containers/unordered_multimap/allocator/noexcept.cc: + Likewise. + * testsuite/23_containers/unordered_multiset/allocator/noexcept.cc: + Likewise. + * testsuite/23_containers/unordered_set/allocator/noexcept.cc: + Likewise. + * testsuite/23_containers/vector/allocator/noexcept.cc: Likewise. + * testsuite/23_containers/vector/allocator/swap.cc: Add elements + before swapping. + 2013-11-19 Paolo Carlini * include/experimental/string_view (_S_max_size): Remove. diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/allocator/noexcept.cc b/libstdc++-v3/testsuite/23_containers/forward_list/allocator/noexcept.cc index 0ee16705a91a..635fb77bec54 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/allocator/noexcept.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/allocator/noexcept.cc @@ -15,23 +15,21 @@ // with this library; see the file COPYING3. If not see // . +// { dg-do compile } // { dg-options "-std=gnu++0x" } #include -#include #include struct T { int i; }; namespace __gnu_test { - inline void - swap(propagating_allocator& l, propagating_allocator& r) - noexcept(false) - { - typedef uneq_allocator base_alloc; - swap(static_cast(l), static_cast(r)); - } + template + inline void + swap(propagating_allocator& l, propagating_allocator& r) + noexcept(false) + { } } using __gnu_test::propagating_allocator; @@ -64,13 +62,5 @@ void test03() test_type v1(alloc_type(1)); test_type v2(alloc_type(2)); static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); - // static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); -} - -int main() -{ - test01(); - test02(); - test03(); - return 0; + static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); } diff --git a/libstdc++-v3/testsuite/23_containers/map/allocator/noexcept.cc b/libstdc++-v3/testsuite/23_containers/map/allocator/noexcept.cc index 832a28ab63a7..4bd3f5755aa9 100644 --- a/libstdc++-v3/testsuite/23_containers/map/allocator/noexcept.cc +++ b/libstdc++-v3/testsuite/23_containers/map/allocator/noexcept.cc @@ -15,10 +15,10 @@ // with this library; see the file COPYING3. If not see // . +// { dg-do compile } // { dg-options "-std=gnu++11" } #include -#include #include struct T { int i; }; @@ -31,14 +31,11 @@ struct U { }; namespace __gnu_test { - inline void - swap(propagating_allocator, true>& l, - propagating_allocator, true>& r) - noexcept(false) - { - typedef uneq_allocator> base_alloc; - swap(static_cast(l), static_cast(r)); - } + template + inline void + swap(propagating_allocator& l, propagating_allocator& r) + noexcept(false) + { } } using __gnu_test::propagating_allocator; @@ -73,11 +70,3 @@ void test03() static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); } - -int main() -{ - test01(); - test02(); - test03(); - return 0; -} diff --git a/libstdc++-v3/testsuite/23_containers/multimap/allocator/noexcept.cc b/libstdc++-v3/testsuite/23_containers/multimap/allocator/noexcept.cc index aee4dc90029f..9913acb86329 100644 --- a/libstdc++-v3/testsuite/23_containers/multimap/allocator/noexcept.cc +++ b/libstdc++-v3/testsuite/23_containers/multimap/allocator/noexcept.cc @@ -15,10 +15,10 @@ // with this library; see the file COPYING3. If not see // . +// { dg-do compile } // { dg-options "-std=gnu++11" } #include -#include #include struct T { int i; }; @@ -31,14 +31,11 @@ struct U { }; namespace __gnu_test { - inline void - swap(propagating_allocator, true>& l, - propagating_allocator, true>& r) - noexcept(false) - { - typedef uneq_allocator> base_alloc; - swap(static_cast(l), static_cast(r)); - } + template + inline void + swap(propagating_allocator& l, propagating_allocator& r) + noexcept(false) + { } } using __gnu_test::propagating_allocator; @@ -73,11 +70,3 @@ void test03() static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); } - -int main() -{ - test01(); - test02(); - test03(); - return 0; -} diff --git a/libstdc++-v3/testsuite/23_containers/multiset/allocator/noexcept.cc b/libstdc++-v3/testsuite/23_containers/multiset/allocator/noexcept.cc index 89b0053d4c2a..d429313d5871 100644 --- a/libstdc++-v3/testsuite/23_containers/multiset/allocator/noexcept.cc +++ b/libstdc++-v3/testsuite/23_containers/multiset/allocator/noexcept.cc @@ -15,6 +15,7 @@ // with this library; see the file COPYING3. If not see // . +// { dg-do compile } // { dg-options "-std=gnu++11" } #include @@ -29,14 +30,11 @@ using Cmp = std::less; namespace __gnu_test { - inline void - swap(propagating_allocator& l, - propagating_allocator& r) - noexcept(false) - { - typedef uneq_allocator base_alloc; - swap(static_cast(l), static_cast(r)); - } + template + inline void + swap(propagating_allocator& l, propagating_allocator& r) + noexcept(false) + { } } using __gnu_test::propagating_allocator; @@ -71,11 +69,3 @@ void test03() static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); } - -int main() -{ - test01(); - test02(); - test03(); - return 0; -} diff --git a/libstdc++-v3/testsuite/23_containers/set/allocator/noexcept.cc b/libstdc++-v3/testsuite/23_containers/set/allocator/noexcept.cc index 07adbc08013e..f8389d6a42f7 100644 --- a/libstdc++-v3/testsuite/23_containers/set/allocator/noexcept.cc +++ b/libstdc++-v3/testsuite/23_containers/set/allocator/noexcept.cc @@ -15,10 +15,10 @@ // with this library; see the file COPYING3. If not see // . +// { dg-do compile } // { dg-options "-std=gnu++11" } #include -#include #include struct T { int i; }; @@ -29,14 +29,11 @@ using Cmp = std::less; namespace __gnu_test { - inline void - swap(propagating_allocator& l, - propagating_allocator& r) - noexcept(false) - { - typedef uneq_allocator base_alloc; - swap(static_cast(l), static_cast(r)); - } + template + inline void + swap(propagating_allocator& l, propagating_allocator& r) + noexcept(false) + { } } using __gnu_test::propagating_allocator; @@ -71,11 +68,3 @@ void test03() static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); } - -int main() -{ - test01(); - test02(); - test03(); - return 0; -} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/noexcept.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/noexcept.cc index 47eb61d77fce..64c46f2e12bb 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/noexcept.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/allocator/noexcept.cc @@ -15,10 +15,10 @@ // with this library; see the file COPYING3. If not see // . +// { dg-do compile } // { dg-options "-std=c++11" } #include -#include #include struct T { int i; }; @@ -37,13 +37,11 @@ struct equal_to namespace __gnu_test { - inline void - swap(propagating_allocator& l, propagating_allocator& r) - noexcept(false) - { - typedef uneq_allocator base_alloc; - swap(static_cast(l), static_cast(r)); - } + template + inline void + swap(propagating_allocator& l, propagating_allocator& r) + noexcept(false) + { } } using __gnu_test::propagating_allocator; @@ -76,13 +74,5 @@ void test03() test_type v1(alloc_type(1)); test_type v2(alloc_type(2)); static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); - // static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); -} - -int main() -{ - test01(); - test02(); - test03(); - return 0; + static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); } diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/noexcept.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/noexcept.cc index de16cbd25e8c..fe6fc6e0c728 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/noexcept.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/allocator/noexcept.cc @@ -15,10 +15,10 @@ // with this library; see the file COPYING3. If not see // . +// { dg-do compile } // { dg-options "-std=c++11" } #include -#include #include struct T { int i; }; @@ -37,13 +37,11 @@ struct equal_to namespace __gnu_test { - inline void - swap(propagating_allocator& l, propagating_allocator& r) - noexcept(false) - { - typedef uneq_allocator base_alloc; - swap(static_cast(l), static_cast(r)); - } + template + inline void + swap(propagating_allocator& l, propagating_allocator& r) + noexcept(false) + { } } using __gnu_test::propagating_allocator; @@ -76,13 +74,5 @@ void test03() test_type v1(alloc_type(1)); test_type v2(alloc_type(2)); static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); - // static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); -} - -int main() -{ - test01(); - test02(); - test03(); - return 0; + static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); } diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/noexcept.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/noexcept.cc index 5d69e0768ced..2c7e853891fe 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/noexcept.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/allocator/noexcept.cc @@ -15,10 +15,10 @@ // with this library; see the file COPYING3. If not see // . +// { dg-do compile } // { dg-options "-std=c++11" } #include -#include #include struct T { int i; }; @@ -37,13 +37,11 @@ struct equal_to namespace __gnu_test { - inline void - swap(propagating_allocator& l, propagating_allocator& r) - noexcept(false) - { - typedef uneq_allocator base_alloc; - swap(static_cast(l), static_cast(r)); - } + template + inline void + swap(propagating_allocator& l, propagating_allocator& r) + noexcept(false) + { } } using __gnu_test::propagating_allocator; @@ -76,13 +74,5 @@ void test03() test_type v1(alloc_type(1)); test_type v2(alloc_type(2)); static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); - // static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); -} - -int main() -{ - test01(); - test02(); - test03(); - return 0; + static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); } diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/noexcept.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/noexcept.cc index 0f73126ccd95..5ada755fcbf0 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/noexcept.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/allocator/noexcept.cc @@ -15,10 +15,10 @@ // with this library; see the file COPYING3. If not see // . +// { dg-do compile } // { dg-options "-std=c++11" } #include -#include #include struct T { int i; }; @@ -37,13 +37,11 @@ struct equal_to namespace __gnu_test { - inline void - swap(propagating_allocator& l, propagating_allocator& r) - noexcept(false) - { - typedef uneq_allocator base_alloc; - swap(static_cast(l), static_cast(r)); - } + template + inline void + swap(propagating_allocator& l, propagating_allocator& r) + noexcept(false) + { } } using __gnu_test::propagating_allocator; @@ -76,13 +74,5 @@ void test03() test_type v1(alloc_type(1)); test_type v2(alloc_type(2)); static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); - // static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); -} - -int main() -{ - test01(); - test02(); - test03(); - return 0; + static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); } diff --git a/libstdc++-v3/testsuite/23_containers/vector/allocator/noexcept.cc b/libstdc++-v3/testsuite/23_containers/vector/allocator/noexcept.cc index a805a4f0a2d6..31231436b037 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/allocator/noexcept.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/allocator/noexcept.cc @@ -15,23 +15,21 @@ // with this library; see the file COPYING3. If not see // . +// { dg-do compile } // { dg-options "-std=gnu++0x" } #include -#include #include struct T { int i; }; namespace __gnu_test { - inline void - swap(propagating_allocator& l, propagating_allocator& r) - noexcept(false) - { - typedef uneq_allocator base_alloc; - swap(static_cast(l), static_cast(r)); - } + template + inline void + swap(propagating_allocator& l, propagating_allocator& r) + noexcept(false) + { } } using __gnu_test::propagating_allocator; @@ -66,11 +64,3 @@ void test03() static_assert( noexcept( v1 = std::move(v2) ), "Move assign cannot throw" ); static_assert( !noexcept( v1.swap(v2) ), "Swap can throw" ); } - -int main() -{ - test01(); - test02(); - test03(); - return 0; -} diff --git a/libstdc++-v3/testsuite/23_containers/vector/allocator/swap.cc b/libstdc++-v3/testsuite/23_containers/vector/allocator/swap.cc index ce44cf80f881..ba44267737f3 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/allocator/swap.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/allocator/swap.cc @@ -64,7 +64,9 @@ void test02() typedef propagating_allocator alloc_type; typedef std::vector test_type; test_type v1(alloc_type(1)); + v1.push_back(T()); test_type v2(alloc_type(2)); + v2.push_back(T()); std::swap(v1, v2); VERIFY(2 == v1.get_allocator().get_personality()); VERIFY(1 == v2.get_allocator().get_personality()); -- 2.43.5