From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- .../23_containers/list/modifiers/swap/1.cc | 35 +++++ .../23_containers/list/modifiers/swap/1.h | 58 ++++++++ .../23_containers/list/modifiers/swap/2.cc | 31 ++++ .../23_containers/list/modifiers/swap/2.h | 127 +++++++++++++++++ .../23_containers/list/modifiers/swap/3.cc | 31 ++++ .../23_containers/list/modifiers/swap/3.h | 156 +++++++++++++++++++++ 6 files changed, 438 insertions(+) create mode 100644 libstdc++-v3/testsuite/23_containers/list/modifiers/swap/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/modifiers/swap/1.h create mode 100644 libstdc++-v3/testsuite/23_containers/list/modifiers/swap/2.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/modifiers/swap/2.h create mode 100644 libstdc++-v3/testsuite/23_containers/list/modifiers/swap/3.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/modifiers/swap/3.h (limited to 'libstdc++-v3/testsuite/23_containers/list/modifiers/swap') diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/1.cc b/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/1.cc new file mode 100644 index 000000000..767640ea9 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/1.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2004, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// 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 +// . + +#include +#include "1.h" + +namespace std +{ + template<> + void + list >::swap(list >&) + { ++swap_calls; } +} + +// See c++/13658 for background info. +int main() +{ + swap11 >(); + swap12 >(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/1.h b/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/1.h new file mode 100644 index 000000000..64619b424 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/1.h @@ -0,0 +1,58 @@ +// Copyright (C) 2004, 2009 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// 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 +// . + +#include +#include + +struct T { int i; }; + +int swap_calls; + +// Should use list specialization for swap. +template +void +swap11() +{ + bool test __attribute__((unused)) = true; + typedef _Tp list_type; + + list_type A; + list_type B; + swap_calls = 0; + std::swap(A, B); + VERIFY(1 == swap_calls); +} + +// Should use list specialization for swap. +template +void +swap12() +{ + using namespace std; + bool test __attribute__((unused)) = true; + typedef _Tp list_type; + + list_type A; + list_type B; + swap_calls = 0; + swap(A, B); + VERIFY(1 == swap_calls); +} + +#if !__GXX_WEAK__ && _MT_ALLOCATOR_H +template class __gnu_cxx::__mt_alloc >; +#endif diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/2.cc b/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/2.cc new file mode 100644 index 000000000..d1faf025f --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/2.cc @@ -0,0 +1,31 @@ +// 2005-12-20 Paolo Carlini + +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// 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 +// . + +#include +#include "2.h" + +int main() +{ + typedef char value_type; + typedef __gnu_test::uneq_allocator allocator_type; + typedef std::list list_type; + + swap2(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/2.h b/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/2.h new file mode 100644 index 000000000..2cd68f60c --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/2.h @@ -0,0 +1,127 @@ +// 2005-12-20 Paolo Carlini + +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// 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 +// . + +// 23.2.2.3 list::swap + +#include +#include + +// uneq_allocator as a non-empty allocator. +template +void +swap2() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef _Tp list_type; + typedef typename list_type::allocator_type allocator_type; + typedef typename list_type::size_type size_type; + + const char title01[] = "Rivers of sand"; + const char title02[] = "Concret PH"; + const char title03[] = "Sonatas and Interludes for Prepared Piano"; + const char title04[] = "never as tired as when i'm waking up"; + + const size_t N1 = sizeof(title01); + const size_t N2 = sizeof(title02); + const size_t N3 = sizeof(title03); + const size_t N4 = sizeof(title04); + + size_type size01, size02; + + allocator_type alloc01(1); + + list_type lis01(alloc01); + size01 = lis01.size(); + list_type lis02(alloc01); + size02 = lis02.size(); + + lis01.swap(lis02); + VERIFY( lis01.size() == size02 ); + VERIFY( lis01.empty() ); + VERIFY( lis02.size() == size01 ); + VERIFY( lis02.empty() ); + + list_type lis03(alloc01); + size01 = lis03.size(); + list_type lis04(title02, title02 + N2, alloc01); + size02 = lis04.size(); + + lis03.swap(lis04); + VERIFY( lis03.size() == size02 ); + VERIFY( equal(lis03.begin(), lis03.end(), title02) ); + VERIFY( lis04.size() == size01 ); + VERIFY( lis04.empty() ); + + list_type lis05(title01, title01 + N1, alloc01); + size01 = lis05.size(); + list_type lis06(title02, title02 + N2, alloc01); + size02 = lis06.size(); + + lis05.swap(lis06); + VERIFY( lis05.size() == size02 ); + VERIFY( equal(lis05.begin(), lis05.end(), title02) ); + VERIFY( lis06.size() == size01 ); + VERIFY( equal(lis06.begin(), lis06.end(), title01) ); + + list_type lis07(title01, title01 + N1, alloc01); + size01 = lis07.size(); + list_type lis08(title03, title03 + N3, alloc01); + size02 = lis08.size(); + + lis07.swap(lis08); + VERIFY( lis07.size() == size02 ); + VERIFY( equal(lis07.begin(), lis07.end(), title03) ); + VERIFY( lis08.size() == size01 ); + VERIFY( equal(lis08.begin(), lis08.end(), title01) ); + + list_type lis09(title03, title03 + N3, alloc01); + size01 = lis09.size(); + list_type lis10(title04, title04 + N4, alloc01); + size02 = lis10.size(); + + lis09.swap(lis10); + VERIFY( lis09.size() == size02 ); + VERIFY( equal(lis09.begin(), lis09.end(), title04) ); + VERIFY( lis10.size() == size01 ); + VERIFY( equal(lis10.begin(), lis10.end(), title03) ); + + list_type lis11(title04, title04 + N4, alloc01); + size01 = lis11.size(); + list_type lis12(title01, title01 + N1, alloc01); + size02 = lis12.size(); + + lis11.swap(lis12); + VERIFY( lis11.size() == size02 ); + VERIFY( equal(lis11.begin(), lis11.end(), title01) ); + VERIFY( lis12.size() == size01 ); + VERIFY( equal(lis12.begin(), lis12.end(), title04) ); + + list_type lis13(title03, title03 + N3, alloc01); + size01 = lis13.size(); + list_type lis14(title03, title03 + N3, alloc01); + size02 = lis14.size(); + + lis13.swap(lis14); + VERIFY( lis13.size() == size02 ); + VERIFY( equal(lis13.begin(), lis13.end(), title03) ); + VERIFY( lis14.size() == size01 ); + VERIFY( equal(lis14.begin(), lis14.end(), title03) ); +} diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/3.cc b/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/3.cc new file mode 100644 index 000000000..676466d53 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/3.cc @@ -0,0 +1,31 @@ +// 2005-12-20 Paolo Carlini + +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// 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 +// . + +#include +#include "3.h" + +int main() +{ + typedef char value_type; + typedef __gnu_test::uneq_allocator allocator_type; + typedef std::list list_type; + + swap3(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/3.h b/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/3.h new file mode 100644 index 000000000..b4f2cd097 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/swap/3.h @@ -0,0 +1,156 @@ +// 2005-12-20 Paolo Carlini + +// Copyright (C) 2005, 2009 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// 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 +// . + +// 23.2.2.3 list::swap + +#include +#include + +// uneq_allocator, two different personalities. +template +void +swap3() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef _Tp list_type; + typedef typename list_type::allocator_type allocator_type; + typedef typename list_type::size_type size_type; + + const char title01[] = "Rivers of sand"; + const char title02[] = "Concret PH"; + const char title03[] = "Sonatas and Interludes for Prepared Piano"; + const char title04[] = "never as tired as when i'm waking up"; + + const size_t N1 = sizeof(title01); + const size_t N2 = sizeof(title02); + const size_t N3 = sizeof(title03); + const size_t N4 = sizeof(title04); + + size_type size01, size02; + + allocator_type alloc01(1), alloc02(2); + int personality01, personality02; + + list_type lis01(alloc01); + size01 = lis01.size(); + personality01 = lis01.get_allocator().get_personality(); + list_type lis02(alloc02); + size02 = lis02.size(); + personality02 = lis02.get_allocator().get_personality(); + + lis01.swap(lis02); + VERIFY( lis01.size() == size02 ); + VERIFY( lis01.empty() ); + VERIFY( lis02.size() == size01 ); + VERIFY( lis02.empty() ); + VERIFY( lis01.get_allocator().get_personality() == personality02 ); + VERIFY( lis02.get_allocator().get_personality() == personality01 ); + + list_type lis03(alloc02); + size01 = lis03.size(); + personality01 = lis03.get_allocator().get_personality(); + list_type lis04(title02, title02 + N2, alloc01); + size02 = lis04.size(); + personality02 = lis04.get_allocator().get_personality(); + + lis03.swap(lis04); + VERIFY( lis03.size() == size02 ); + VERIFY( equal(lis03.begin(), lis03.end(), title02) ); + VERIFY( lis04.size() == size01 ); + VERIFY( lis04.empty() ); + VERIFY( lis03.get_allocator().get_personality() == personality02 ); + VERIFY( lis04.get_allocator().get_personality() == personality01 ); + + list_type lis05(title01, title01 + N1, alloc01); + size01 = lis05.size(); + personality01 = lis05.get_allocator().get_personality(); + list_type lis06(title02, title02 + N2, alloc02); + size02 = lis06.size(); + personality02 = lis06.get_allocator().get_personality(); + + lis05.swap(lis06); + VERIFY( lis05.size() == size02 ); + VERIFY( equal(lis05.begin(), lis05.end(), title02) ); + VERIFY( lis06.size() == size01 ); + VERIFY( equal(lis06.begin(), lis06.end(), title01) ); + VERIFY( lis05.get_allocator().get_personality() == personality02 ); + VERIFY( lis06.get_allocator().get_personality() == personality01 ); + + list_type lis07(title01, title01 + N1, alloc02); + size01 = lis07.size(); + personality01 = lis07.get_allocator().get_personality(); + list_type lis08(title03, title03 + N3, alloc01); + size02 = lis08.size(); + personality02 = lis08.get_allocator().get_personality(); + + lis07.swap(lis08); + VERIFY( lis07.size() == size02 ); + VERIFY( equal(lis07.begin(), lis07.end(), title03) ); + VERIFY( lis08.size() == size01 ); + VERIFY( equal(lis08.begin(), lis08.end(), title01) ); + VERIFY( lis07.get_allocator().get_personality() == personality02 ); + VERIFY( lis08.get_allocator().get_personality() == personality01 ); + + list_type lis09(title03, title03 + N3, alloc01); + size01 = lis09.size(); + personality01 = lis09.get_allocator().get_personality(); + list_type lis10(title04, title04 + N4, alloc02); + size02 = lis10.size(); + personality02 = lis10.get_allocator().get_personality(); + + lis09.swap(lis10); + VERIFY( lis09.size() == size02 ); + VERIFY( equal(lis09.begin(), lis09.end(), title04) ); + VERIFY( lis10.size() == size01 ); + VERIFY( equal(lis10.begin(), lis10.end(), title03) ); + VERIFY( lis09.get_allocator().get_personality() == personality02 ); + VERIFY( lis10.get_allocator().get_personality() == personality01 ); + + list_type lis11(title04, title04 + N4, alloc02); + size01 = lis11.size(); + personality01 = lis11.get_allocator().get_personality(); + list_type lis12(title01, title01 + N1, alloc01); + size02 = lis12.size(); + personality02 = lis12.get_allocator().get_personality(); + + lis11.swap(lis12); + VERIFY( lis11.size() == size02 ); + VERIFY( equal(lis11.begin(), lis11.end(), title01) ); + VERIFY( lis12.size() == size01 ); + VERIFY( equal(lis12.begin(), lis12.end(), title04) ); + VERIFY( lis11.get_allocator().get_personality() == personality02 ); + VERIFY( lis12.get_allocator().get_personality() == personality01 ); + + list_type lis13(title03, title03 + N3, alloc01); + size01 = lis13.size(); + personality01 = lis13.get_allocator().get_personality(); + list_type lis14(title03, title03 + N3, alloc02); + size02 = lis14.size(); + personality02 = lis14.get_allocator().get_personality(); + + lis13.swap(lis14); + VERIFY( lis13.size() == size02 ); + VERIFY( equal(lis13.begin(), lis13.end(), title03) ); + VERIFY( lis14.size() == size01 ); + VERIFY( equal(lis14.begin(), lis14.end(), title03) ); + VERIFY( lis13.get_allocator().get_personality() == personality02 ); + VERIFY( lis14.get_allocator().get_personality() == personality01 ); +} -- cgit v1.2.3