From eefcf8206eaed1ef26d996f97377017664c38d91 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Tue, 24 Nov 2015 22:10:51 +0000 Subject: [PATCH] Remove undefined behavior from tests; specifically, ensure that the value type of the allocators match the value type of the containers git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@254030 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../map/map.access/index_rv_key.pass.cpp | 2 +- .../map/map.cons/default_noexcept.pass.cpp | 5 ++-- .../map/map.cons/dtor_noexcept.pass.cpp | 5 ++-- .../map.cons/move_assign_noexcept.pass.cpp | 5 ++-- .../map/map.cons/move_noexcept.pass.cpp | 5 ++-- .../map/map.special/swap_noexcept.pass.cpp | 15 ++++++------ .../multimap.cons/default_noexcept.pass.cpp | 5 ++-- .../multimap.cons/dtor_noexcept.pass.cpp | 5 ++-- .../move_assign_noexcept.pass.cpp | 5 ++-- .../multimap.cons/move_noexcept.pass.cpp | 5 ++-- .../multimap.special/swap_noexcept.pass.cpp | 15 ++++++------ .../forwardlist.cons/move.pass.cpp | 6 ++--- .../forwardlist.cons/move_alloc.pass.cpp | 6 ++--- .../swap_noexcept.pass.cpp | 24 +++++++++---------- 14 files changed, 59 insertions(+), 49 deletions(-) diff --git a/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp b/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp index 7e0fd41d..6511dcc8 100644 --- a/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp +++ b/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp @@ -38,7 +38,7 @@ int main() assert(m.size() == 2); } { - typedef std::pair V; + typedef std::pair V; std::map, min_allocator> m; assert(m.size() == 0); assert(m[1] == 0.0); diff --git a/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp b/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp index 1f11fc95..dedc89bd 100644 --- a/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp +++ b/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp @@ -33,16 +33,17 @@ struct some_comp int main() { #if __has_feature(cxx_noexcept) + typedef std::pair V; { typedef std::map C; static_assert(std::is_nothrow_default_constructible::value, ""); } { - typedef std::map, test_allocator> C; + typedef std::map, test_allocator> C; static_assert(std::is_nothrow_default_constructible::value, ""); } { - typedef std::map, other_allocator> C; + typedef std::map, other_allocator> C; static_assert(!std::is_nothrow_default_constructible::value, ""); } { diff --git a/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp b/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp index eed26d3a..9baa19b5 100644 --- a/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp @@ -31,16 +31,17 @@ struct some_comp int main() { #if __has_feature(cxx_noexcept) + typedef std::pair V; { typedef std::map C; static_assert(std::is_nothrow_destructible::value, ""); } { - typedef std::map, test_allocator> C; + typedef std::map, test_allocator> C; static_assert(std::is_nothrow_destructible::value, ""); } { - typedef std::map, other_allocator> C; + typedef std::map, other_allocator> C; static_assert(std::is_nothrow_destructible::value, ""); } { diff --git a/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp b/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp index f80b1d32..3b28118b 100644 --- a/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp @@ -33,16 +33,17 @@ struct some_comp int main() { #if __has_feature(cxx_noexcept) + typedef std::pair V; { typedef std::map C; static_assert(std::is_nothrow_move_assignable::value, ""); } { - typedef std::map, test_allocator> C; + typedef std::map, test_allocator> C; static_assert(!std::is_nothrow_move_assignable::value, ""); } { - typedef std::map, other_allocator> C; + typedef std::map, other_allocator> C; static_assert(std::is_nothrow_move_assignable::value, ""); } { diff --git a/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp b/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp index 9347b832..0f1fd396 100644 --- a/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp +++ b/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp @@ -31,16 +31,17 @@ struct some_comp int main() { #if __has_feature(cxx_noexcept) + typedef std::pair V; { typedef std::map C; static_assert(std::is_nothrow_move_constructible::value, ""); } { - typedef std::map, test_allocator> C; + typedef std::map, test_allocator> C; static_assert(std::is_nothrow_move_constructible::value, ""); } { - typedef std::map, other_allocator> C; + typedef std::map, other_allocator> C; static_assert(std::is_nothrow_move_constructible::value, ""); } { diff --git a/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp b/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp index 4598e994..f25dff2c 100644 --- a/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp +++ b/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp @@ -94,18 +94,19 @@ struct some_alloc3 int main() { #if __has_feature(cxx_noexcept) + typedef std::pair V; { typedef std::map C; C c1, c2; static_assert(noexcept(swap(c1, c2)), ""); } { - typedef std::map, test_allocator> C; + typedef std::map, test_allocator> C; C c1, c2; static_assert(noexcept(swap(c1, c2)), ""); } { - typedef std::map, other_allocator> C; + typedef std::map, other_allocator> C; C c1, c2; static_assert(noexcept(swap(c1, c2)), ""); } @@ -117,28 +118,28 @@ int main() #if TEST_STD_VER >= 14 { // POCS allocator, throwable swap for comp - typedef std::map, some_alloc > C; + typedef std::map, some_alloc > C; C c1, c2; static_assert(!noexcept(swap(c1, c2)), ""); } { // always equal allocator, throwable swap for comp - typedef std::map, some_alloc2> C; + typedef std::map, some_alloc2> C; C c1, c2; static_assert(!noexcept(swap(c1, c2)), ""); } { // POCS allocator, nothrow swap for comp - typedef std::map, some_alloc > C; + typedef std::map, some_alloc > C; C c1, c2; static_assert( noexcept(swap(c1, c2)), ""); } { // always equal allocator, nothrow swap for comp - typedef std::map, some_alloc2> C; + typedef std::map, some_alloc2> C; C c1, c2; static_assert( noexcept(swap(c1, c2)), ""); } { // NOT always equal allocator, nothrow swap for comp - typedef std::map, some_alloc3> C; + typedef std::map, some_alloc3> C; C c1, c2; static_assert( noexcept(swap(c1, c2)), ""); } diff --git a/test/std/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp index d1db40b1..5f05a0dc 100644 --- a/test/std/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp @@ -33,16 +33,17 @@ struct some_comp int main() { #if __has_feature(cxx_noexcept) + typedef std::pair V; { typedef std::multimap C; static_assert(std::is_nothrow_default_constructible::value, ""); } { - typedef std::multimap, test_allocator> C; + typedef std::multimap, test_allocator> C; static_assert(std::is_nothrow_default_constructible::value, ""); } { - typedef std::multimap, other_allocator> C; + typedef std::multimap, other_allocator> C; static_assert(!std::is_nothrow_default_constructible::value, ""); } { diff --git a/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp index cb55e3fb..dd170124 100644 --- a/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp @@ -31,16 +31,17 @@ struct some_comp int main() { #if __has_feature(cxx_noexcept) + typedef std::pair V; { typedef std::multimap C; static_assert(std::is_nothrow_destructible::value, ""); } { - typedef std::multimap, test_allocator> C; + typedef std::multimap, test_allocator> C; static_assert(std::is_nothrow_destructible::value, ""); } { - typedef std::multimap, other_allocator> C; + typedef std::multimap, other_allocator> C; static_assert(std::is_nothrow_destructible::value, ""); } { diff --git a/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp index 8ad9e8b8..635a8dca 100644 --- a/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp @@ -33,16 +33,17 @@ struct some_comp int main() { #if __has_feature(cxx_noexcept) + typedef std::pair V; { typedef std::multimap C; static_assert(std::is_nothrow_move_assignable::value, ""); } { - typedef std::multimap, test_allocator> C; + typedef std::multimap, test_allocator> C; static_assert(!std::is_nothrow_move_assignable::value, ""); } { - typedef std::multimap, other_allocator> C; + typedef std::multimap, other_allocator> C; static_assert(std::is_nothrow_move_assignable::value, ""); } { diff --git a/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp index 66ea8737..0f31f04f 100644 --- a/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp @@ -31,16 +31,17 @@ struct some_comp int main() { #if __has_feature(cxx_noexcept) + typedef std::pair V; { typedef std::multimap C; static_assert(std::is_nothrow_move_constructible::value, ""); } { - typedef std::multimap, test_allocator> C; + typedef std::multimap, test_allocator> C; static_assert(std::is_nothrow_move_constructible::value, ""); } { - typedef std::multimap, other_allocator> C; + typedef std::multimap, other_allocator> C; static_assert(std::is_nothrow_move_constructible::value, ""); } { diff --git a/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp b/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp index 1013c628..e70ee1fa 100644 --- a/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp @@ -94,18 +94,19 @@ struct some_alloc3 int main() { #if __has_feature(cxx_noexcept) + typedef std::pair V; { typedef std::multimap C; C c1, c2; static_assert(noexcept(swap(c1, c2)), ""); } { - typedef std::multimap, test_allocator> C; + typedef std::multimap, test_allocator> C; C c1, c2; static_assert(noexcept(swap(c1, c2)), ""); } { - typedef std::multimap, other_allocator> C; + typedef std::multimap, other_allocator> C; C c1, c2; static_assert(noexcept(swap(c1, c2)), ""); } @@ -117,28 +118,28 @@ int main() #if TEST_STD_VER >= 14 { // POCS allocator, throwable swap for comp - typedef std::multimap, some_alloc > C; + typedef std::multimap, some_alloc > C; C c1, c2; static_assert(!noexcept(swap(c1, c2)), ""); } { // always equal allocator, throwable swap for comp - typedef std::multimap, some_alloc2> C; + typedef std::multimap, some_alloc2> C; C c1, c2; static_assert(!noexcept(swap(c1, c2)), ""); } { // POCS allocator, nothrow swap for comp - typedef std::multimap, some_alloc > C; + typedef std::multimap, some_alloc > C; C c1, c2; static_assert( noexcept(swap(c1, c2)), ""); } { // always equal allocator, nothrow swap for comp - typedef std::multimap, some_alloc2> C; + typedef std::multimap, some_alloc2> C; C c1, c2; static_assert( noexcept(swap(c1, c2)), ""); } { // NOT always equal allocator, nothrow swap for comp - typedef std::map, some_alloc3> C; + typedef std::map, some_alloc3> C; C c1, c2; static_assert( noexcept(swap(c1, c2)), ""); } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp index 8341f7ba..88ecb754 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp @@ -24,7 +24,7 @@ int main() #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef MoveOnly T; - typedef test_allocator A; + typedef test_allocator A; typedef std::forward_list C; T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; typedef std::move_iterator I; @@ -39,7 +39,7 @@ int main() } { typedef MoveOnly T; - typedef other_allocator A; + typedef other_allocator A; typedef std::forward_list C; T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; typedef std::move_iterator I; @@ -55,7 +55,7 @@ int main() #if __cplusplus >= 201103L { typedef MoveOnly T; - typedef min_allocator A; + typedef min_allocator A; typedef std::forward_list C; T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; typedef std::move_iterator I; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp index 6bb575ef..3f0e45af 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp @@ -24,7 +24,7 @@ int main() #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef MoveOnly T; - typedef test_allocator A; + typedef test_allocator A; typedef std::forward_list C; T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; typedef std::move_iterator I; @@ -39,7 +39,7 @@ int main() } { typedef MoveOnly T; - typedef test_allocator A; + typedef test_allocator A; typedef std::forward_list C; T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; typedef std::move_iterator I; @@ -55,7 +55,7 @@ int main() #if __cplusplus >= 201103L { typedef MoveOnly T; - typedef min_allocator A; + typedef min_allocator A; typedef std::forward_list C; T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; typedef std::move_iterator I; diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp index 37c81190..7c912e01 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp @@ -116,7 +116,7 @@ struct some_alloc3 int main() { #if __has_feature(cxx_noexcept) - typedef std::pair MapType; + typedef std::pair V; { typedef std::unordered_multimap C; C c1, c2; @@ -124,13 +124,13 @@ int main() } { typedef std::unordered_multimap, - std::equal_to, test_allocator> C; + std::equal_to, test_allocator> C; C c1, c2; static_assert(noexcept(swap(c1, c2)), ""); } { typedef std::unordered_multimap, - std::equal_to, other_allocator> C; + std::equal_to, other_allocator> C; C c1, c2; static_assert(noexcept(swap(c1, c2)), ""); } @@ -148,47 +148,47 @@ int main() #if TEST_STD_VER >= 14 { // POCS allocator, throwable swap for hash, throwable swap for comp - typedef std::unordered_multimap, some_comp , some_alloc > C; + typedef std::unordered_multimap, some_comp , some_alloc > C; C c1, c2; static_assert(!noexcept(swap(c1, c2)), ""); } { // always equal allocator, throwable swap for hash, throwable swap for comp - typedef std::unordered_multimap, some_comp , some_alloc2> C; + typedef std::unordered_multimap, some_comp , some_alloc2> C; C c1, c2; static_assert(!noexcept(swap(c1, c2)), ""); } { // POCS allocator, throwable swap for hash, nothrow swap for comp - typedef std::unordered_multimap, some_comp2, some_alloc > C; + typedef std::unordered_multimap, some_comp2, some_alloc > C; C c1, c2; static_assert(!noexcept(swap(c1, c2)), ""); } { // always equal allocator, throwable swap for hash, nothrow swap for comp - typedef std::unordered_multimap, some_comp2, some_alloc2> C; + typedef std::unordered_multimap, some_comp2, some_alloc2> C; C c1, c2; static_assert(!noexcept(swap(c1, c2)), ""); } { // POCS allocator, nothrow swap for hash, throwable swap for comp - typedef std::unordered_multimap, some_comp , some_alloc > C; + typedef std::unordered_multimap, some_comp , some_alloc > C; C c1, c2; static_assert(!noexcept(swap(c1, c2)), ""); } { // always equal allocator, nothrow swap for hash, throwable swap for comp - typedef std::unordered_multimap, some_comp , some_alloc2> C; + typedef std::unordered_multimap, some_comp , some_alloc2> C; C c1, c2; static_assert(!noexcept(swap(c1, c2)), ""); } { // POCS allocator, nothrow swap for hash, nothrow swap for comp - typedef std::unordered_multimap, some_comp2, some_alloc > C; + typedef std::unordered_multimap, some_comp2, some_alloc > C; C c1, c2; static_assert( noexcept(swap(c1, c2)), ""); } { // always equal allocator, nothrow swap for hash, nothrow swap for comp - typedef std::unordered_multimap, some_comp2, some_alloc2> C; + typedef std::unordered_multimap, some_comp2, some_alloc2> C; C c1, c2; static_assert( noexcept(swap(c1, c2)), ""); } { // NOT always equal allocator, nothrow swap for hash, nothrow swap for comp - typedef std::unordered_multimap, some_comp2, some_alloc3> C; + typedef std::unordered_multimap, some_comp2, some_alloc3> C; C c1, c2; static_assert( noexcept(swap(c1, c2)), ""); }