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. --- libstdc++-v3/testsuite/23_containers/list/14340.cc | 34 +++++ libstdc++-v3/testsuite/23_containers/list/18604.cc | 42 ++++++ .../testsuite/23_containers/list/23781_neg.cc | 29 ++++ .../testsuite/23_containers/list/capacity/1.cc | 26 ++++ .../testsuite/23_containers/list/capacity/1.h | 61 ++++++++ .../testsuite/23_containers/list/capacity/29134.cc | 44 ++++++ .../23_containers/list/capacity/resize_size.cc | 43 ++++++ .../23_containers/list/check_construct_destroy.cc | 29 ++++ .../23_containers/list/check_construct_destroy.h | 79 +++++++++++ .../testsuite/23_containers/list/cons/1.cc | 25 ++++ libstdc++-v3/testsuite/23_containers/list/cons/1.h | 63 +++++++++ .../testsuite/23_containers/list/cons/2.cc | 26 ++++ libstdc++-v3/testsuite/23_containers/list/cons/2.h | 77 ++++++++++ .../testsuite/23_containers/list/cons/3.cc | 25 ++++ libstdc++-v3/testsuite/23_containers/list/cons/3.h | 48 +++++++ .../testsuite/23_containers/list/cons/4.cc | 26 ++++ libstdc++-v3/testsuite/23_containers/list/cons/4.h | 61 ++++++++ .../testsuite/23_containers/list/cons/5.cc | 26 ++++ libstdc++-v3/testsuite/23_containers/list/cons/5.h | 51 +++++++ .../testsuite/23_containers/list/cons/6.cc | 26 ++++ libstdc++-v3/testsuite/23_containers/list/cons/6.h | 64 +++++++++ .../testsuite/23_containers/list/cons/7.cc | 26 ++++ libstdc++-v3/testsuite/23_containers/list/cons/7.h | 65 +++++++++ .../testsuite/23_containers/list/cons/8.cc | 26 ++++ libstdc++-v3/testsuite/23_containers/list/cons/8.h | 51 +++++++ .../testsuite/23_containers/list/cons/9.cc | 25 ++++ libstdc++-v3/testsuite/23_containers/list/cons/9.h | 59 ++++++++ .../23_containers/list/cons/clear_allocator.cc | 27 ++++ .../23_containers/list/cons/clear_allocator.h | 78 +++++++++++ .../testsuite/23_containers/list/cons/cons_size.cc | 40 ++++++ .../testsuite/23_containers/list/cons/moveable.cc | 27 ++++ .../testsuite/23_containers/list/cons/moveable.h | 41 ++++++ .../23_containers/list/debug/assign1_neg.cc | 33 +++++ .../23_containers/list/debug/assign2_neg.cc | 33 +++++ .../23_containers/list/debug/assign3_neg.cc | 33 +++++ .../23_containers/list/debug/assign4_neg.cc | 32 +++++ .../23_containers/list/debug/construct1_neg.cc | 33 +++++ .../23_containers/list/debug/construct2_neg.cc | 33 +++++ .../23_containers/list/debug/construct3_neg.cc | 33 +++++ .../23_containers/list/debug/construct4_neg.cc | 32 +++++ .../23_containers/list/debug/insert1_neg.cc | 33 +++++ .../23_containers/list/debug/insert2_neg.cc | 33 +++++ .../23_containers/list/debug/insert3_neg.cc | 33 +++++ .../23_containers/list/debug/insert4_neg.cc | 32 +++++ .../23_containers/list/debug/invalidation/1.cc | 59 ++++++++ .../23_containers/list/debug/invalidation/2.cc | 55 ++++++++ .../23_containers/list/debug/invalidation/3.cc | 77 ++++++++++ .../23_containers/list/debug/invalidation/4.cc | 55 ++++++++ .../testsuite/23_containers/list/init-list.cc | 31 ++++ .../testsuite/23_containers/list/init-list.h | 65 +++++++++ .../testsuite/23_containers/list/modifiers/1.cc | 25 ++++ .../testsuite/23_containers/list/modifiers/1.h | 116 +++++++++++++++ .../23_containers/list/modifiers/1_c++0x.cc | 27 ++++ .../testsuite/23_containers/list/modifiers/2.cc | 25 ++++ .../testsuite/23_containers/list/modifiers/2.h | 89 ++++++++++++ .../testsuite/23_containers/list/modifiers/3.cc | 25 ++++ .../testsuite/23_containers/list/modifiers/3.h | 121 ++++++++++++++++ .../23_containers/list/modifiers/insert/25288.cc | 31 ++++ .../23_containers/list/modifiers/insert/25288.h | 90 ++++++++++++ .../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 +++++++++++++++++++++ .../testsuite/23_containers/list/operations/1.cc | 26 ++++ .../testsuite/23_containers/list/operations/1.h | 68 +++++++++ .../testsuite/23_containers/list/operations/2.cc | 25 ++++ .../testsuite/23_containers/list/operations/2.h | 54 +++++++ .../23_containers/list/operations/2_c++0x.cc | 27 ++++ .../testsuite/23_containers/list/operations/3.cc | 25 ++++ .../testsuite/23_containers/list/operations/3.h | 68 +++++++++ .../23_containers/list/operations/35969.cc | 79 +++++++++++ .../23_containers/list/operations/3_c++0x.cc | 27 ++++ .../testsuite/23_containers/list/operations/4.cc | 26 ++++ .../testsuite/23_containers/list/operations/4.h | 92 ++++++++++++ .../23_containers/list/operations/42352.cc | 66 +++++++++ .../testsuite/23_containers/list/operations/5.cc | 31 ++++ .../testsuite/23_containers/list/operations/5.h | 134 ++++++++++++++++++ .../testsuite/23_containers/list/pthread1.cc | 131 +++++++++++++++++ .../testsuite/23_containers/list/pthread5.cc | 125 +++++++++++++++++ .../testsuite/23_containers/list/range_access.cc | 31 ++++ .../23_containers/list/requirements/citerators.cc | 30 ++++ .../list/requirements/dr438/assign_neg.cc | 36 +++++ .../list/requirements/dr438/constructor.cc | 28 ++++ .../list/requirements/dr438/constructor_1_neg.cc | 30 ++++ .../list/requirements/dr438/constructor_2_neg.cc | 31 ++++ .../list/requirements/dr438/insert_neg.cc | 36 +++++ .../list/requirements/exception/basic.cc | 40 ++++++ .../exception/generation_prohibited.cc | 34 +++++ .../exception/propagation_consistent.cc | 34 +++++ .../list/requirements/explicit_instantiation/1.cc | 25 ++++ .../requirements/explicit_instantiation/1_c++0x.cc | 25 ++++ .../list/requirements/explicit_instantiation/2.cc | 30 ++++ .../list/requirements/explicit_instantiation/3.cc | 26 ++++ .../list/requirements/explicit_instantiation/4.cc | 29 ++++ .../list/requirements/partial_specialization/1.cc | 33 +++++ .../23_containers/list/requirements/typedefs.cc | 25 ++++ 98 files changed, 4619 insertions(+) create mode 100644 libstdc++-v3/testsuite/23_containers/list/14340.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/18604.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/23781_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/capacity/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/capacity/1.h create mode 100644 libstdc++-v3/testsuite/23_containers/list/capacity/29134.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/capacity/resize_size.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/check_construct_destroy.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/check_construct_destroy.h create mode 100644 libstdc++-v3/testsuite/23_containers/list/cons/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/cons/1.h create mode 100644 libstdc++-v3/testsuite/23_containers/list/cons/2.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/cons/2.h create mode 100644 libstdc++-v3/testsuite/23_containers/list/cons/3.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/cons/3.h create mode 100644 libstdc++-v3/testsuite/23_containers/list/cons/4.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/cons/4.h create mode 100644 libstdc++-v3/testsuite/23_containers/list/cons/5.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/cons/5.h create mode 100644 libstdc++-v3/testsuite/23_containers/list/cons/6.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/cons/6.h create mode 100644 libstdc++-v3/testsuite/23_containers/list/cons/7.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/cons/7.h create mode 100644 libstdc++-v3/testsuite/23_containers/list/cons/8.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/cons/8.h create mode 100644 libstdc++-v3/testsuite/23_containers/list/cons/9.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/cons/9.h create mode 100644 libstdc++-v3/testsuite/23_containers/list/cons/clear_allocator.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/cons/clear_allocator.h create mode 100644 libstdc++-v3/testsuite/23_containers/list/cons/cons_size.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/cons/moveable.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/cons/moveable.h create mode 100644 libstdc++-v3/testsuite/23_containers/list/debug/assign1_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/debug/assign2_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/debug/assign3_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/debug/assign4_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/debug/construct1_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/debug/construct2_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/debug/construct3_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/debug/construct4_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/debug/insert1_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/debug/insert2_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/debug/insert3_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/debug/insert4_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/debug/invalidation/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/debug/invalidation/2.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/debug/invalidation/3.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/debug/invalidation/4.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/init-list.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/init-list.h create mode 100644 libstdc++-v3/testsuite/23_containers/list/modifiers/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/modifiers/1.h create mode 100644 libstdc++-v3/testsuite/23_containers/list/modifiers/1_c++0x.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/modifiers/2.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/modifiers/2.h create mode 100644 libstdc++-v3/testsuite/23_containers/list/modifiers/3.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/modifiers/3.h create mode 100644 libstdc++-v3/testsuite/23_containers/list/modifiers/insert/25288.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/modifiers/insert/25288.h 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 create mode 100644 libstdc++-v3/testsuite/23_containers/list/operations/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/operations/1.h create mode 100644 libstdc++-v3/testsuite/23_containers/list/operations/2.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/operations/2.h create mode 100644 libstdc++-v3/testsuite/23_containers/list/operations/2_c++0x.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/operations/3.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/operations/3.h create mode 100644 libstdc++-v3/testsuite/23_containers/list/operations/35969.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/operations/3_c++0x.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/operations/4.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/operations/4.h create mode 100644 libstdc++-v3/testsuite/23_containers/list/operations/42352.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/operations/5.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/operations/5.h create mode 100644 libstdc++-v3/testsuite/23_containers/list/pthread1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/pthread5.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/range_access.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/requirements/citerators.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/requirements/exception/basic.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/requirements/exception/generation_prohibited.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/requirements/exception/propagation_consistent.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/1_c++0x.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/3.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/4.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/requirements/partial_specialization/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/requirements/typedefs.cc (limited to 'libstdc++-v3/testsuite/23_containers/list') diff --git a/libstdc++-v3/testsuite/23_containers/list/14340.cc b/libstdc++-v3/testsuite/23_containers/list/14340.cc new file mode 100644 index 000000000..5606ff042 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/14340.cc @@ -0,0 +1,34 @@ +// -*- C++ -*- + +// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 +// 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 + +// NB: This issue affected only debug-mode. + +// { dg-do compile } + +// libstdc++/14340 +int main() +{ + typedef std::list list_type; + __gnu_test::conversion::iterator_to_const_iterator(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/18604.cc b/libstdc++-v3/testsuite/23_containers/list/18604.cc new file mode 100644 index 000000000..398d0f6cd --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/18604.cc @@ -0,0 +1,42 @@ +// 2005-05-09 Paolo Carlini + +// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 +// 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 +// . + +// NB: This issue affected only debug-mode. + +// { dg-do compile } + +// libstdc++/18604 +struct less; +struct allocator; +struct pair; +struct binary_function; +struct iterator; +struct iterator_traits; +struct bidirectional_iterator_tag; +struct forward_iterator_tag; +struct input_iterator_tag; +struct random_access_iterator_tag; +struct ios_base; +struct basic_string; +struct basic_istream; +struct basic_ostream; +struct char_traits; + +#include diff --git a/libstdc++-v3/testsuite/23_containers/list/23781_neg.cc b/libstdc++-v3/testsuite/23_containers/list/23781_neg.cc new file mode 100644 index 000000000..7b291df79 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/23781_neg.cc @@ -0,0 +1,29 @@ +// 2005-09-10 Paolo Carlini +// +// Copyright (C) 2005, 2009, 2010 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 +// . +// + +// { dg-do compile } + +// libstdc++/23781 +#include +#include + +typedef std::list list_type; +list_type::iterator it = NULL; // { dg-error "conversion" } +list_type::const_iterator cit = NULL; // { dg-error "conversion" } diff --git a/libstdc++-v3/testsuite/23_containers/list/capacity/1.cc b/libstdc++-v3/testsuite/23_containers/list/capacity/1.cc new file mode 100644 index 000000000..3b0e8dc72 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/capacity/1.cc @@ -0,0 +1,26 @@ +// Copyright (C) 2001, 2004, 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 "1.h" +#include + +int +main() +{ + capacity01 >(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/capacity/1.h b/libstdc++-v3/testsuite/23_containers/list/capacity/1.h new file mode 100644 index 000000000..408e0786c --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/capacity/1.h @@ -0,0 +1,61 @@ +// Copyright (C) 2001, 2004, 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.2 list capacity [lib.list.capacity] + +#include + +// This test verifies the following. +// +// 23.2.2 bool empty() const +// 23.2.2 size_type size() const +// 23.2.2 iterator begin() +// 23.2.2 iterator end() +// 23.2.2.3 void push_back(const T&) +// 23.2.2 size_type max_size() const +// 23.2.2.2 void resize(size_type s, T c = T()) +// +template +void +capacity01() +{ + bool test __attribute__((unused)) = true; + typedef _Tp list_type; + typedef typename list_type::iterator iterator_type; + + list_type list0101; + VERIFY(list0101.empty()); + VERIFY(list0101.size() == 0); + + list0101.push_back(1); + VERIFY(!list0101.empty()); + VERIFY(list0101.size() == 1); + + list0101.resize(3, 2); + VERIFY(!list0101.empty()); + VERIFY(list0101.size() == 3); + + iterator_type i = list0101.begin(); + VERIFY(*i == 1); ++i; + VERIFY(*i == 2); ++i; + VERIFY(*i == 2); ++i; + VERIFY(i == list0101.end()); + + list0101.resize(0); + VERIFY(list0101.empty()); + VERIFY(list0101.size() == 0); +} diff --git a/libstdc++-v3/testsuite/23_containers/list/capacity/29134.cc b/libstdc++-v3/testsuite/23_containers/list/capacity/29134.cc new file mode 100644 index 000000000..d8c88b526 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/capacity/29134.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2006, 2007, 2008, 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.2 list capacity [lib.list.capacity] + +#include +#include + +// libstdc++/29134 +void test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::list list_type; + list_type l; + +#if ! defined _GLIBCXX_DEBUG && ! defined _GLIBCXX_PROFILE + using std::_List_node; +#else + using std::_GLIBCXX_STD_C::_List_node; +#endif + + VERIFY( l.max_size() == std::allocator<_List_node >().max_size() ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/capacity/resize_size.cc b/libstdc++-v3/testsuite/23_containers/list/capacity/resize_size.cc new file mode 100644 index 000000000..06424c0a8 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/capacity/resize_size.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-06-18 Paolo Carlini + +// Copyright (C) 2010 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 +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::list<__gnu_test::NonCopyConstructible> l; + VERIFY( std::distance(l.begin(), l.end()) == 0 ); + + l.resize(1000); + VERIFY( std::distance(l.begin(), l.end()) == 1000 ); + for(auto it = l.begin(); it != l.end(); ++it) + VERIFY( *it == -1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/check_construct_destroy.cc b/libstdc++-v3/testsuite/23_containers/list/check_construct_destroy.cc new file mode 100644 index 000000000..31dacb592 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/check_construct_destroy.cc @@ -0,0 +1,29 @@ +// 2004-07-26 Matt Austern +// +// Copyright (C) 2003, 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 "check_construct_destroy.h" +#include + +int main() +{ + typedef __gnu_test::tracker_allocator allocator_type; + construct_destroy >(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/check_construct_destroy.h b/libstdc++-v3/testsuite/23_containers/list/check_construct_destroy.h new file mode 100644 index 000000000..14da42dc8 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/check_construct_destroy.h @@ -0,0 +1,79 @@ +// 2004-07-26 Matt Austern +// +// Copyright (C) 2003, 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 + +template +bool +construct_destroy() +{ + typedef _Tp list_type; + typedef typename list_type::iterator iterator_type; + + using namespace __gnu_test; + const int arr10[10] = { 2, 4, 1, 7, 3, 8, 10, 5, 9, 6 }; + bool ok = true; + + tracker_allocator_counter::reset(); + { + list_type c; + ok = check_construct_destroy("empty container", 0, 0) && ok; + } + ok = check_construct_destroy("empty container", 0, 0) && ok; + + + tracker_allocator_counter::reset(); + { + list_type c(arr10, arr10 + 10); + ok = check_construct_destroy("Construct from range", 10, 0) && ok; + } + ok = check_construct_destroy("Construct from range", 10, 10) && ok; + + { + list_type c(arr10, arr10 + 10); + tracker_allocator_counter::reset(); + c.insert(c.begin(), arr10[0]); + ok = check_construct_destroy("Insert element", 1, 0) && ok; + } + ok = check_construct_destroy("Insert element", 1, 11) && ok; + + { + list_type c(arr10, arr10 + 10); + tracker_allocator_counter::reset(); + iterator_type i5 = c.begin(); + std::advance(i5, 5); + c.insert(i5, arr10, arr10+3); + ok = check_construct_destroy("Insert short range", 3, 0) && ok; + } + ok = check_construct_destroy("Insert short range", 3, 13) && ok; + + { + list_type c(arr10, arr10 + 10); + tracker_allocator_counter::reset(); + iterator_type i7 = c.begin(); + std::advance(i7, 5); + c.insert(i7, arr10, arr10+10); + ok = check_construct_destroy("Insert long range", 10, 0) && ok; + } + ok = check_construct_destroy("Insert long range", 10, 20) && ok; + + return ok ? 0 : 1; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/1.cc b/libstdc++-v3/testsuite/23_containers/list/cons/1.cc new file mode 100644 index 000000000..da469ebb1 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/1.cc @@ -0,0 +1,25 @@ +// Copyright (C) 2001, 2004, 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 "1.h" +#include + +int main() +{ + cons01 > >(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/1.h b/libstdc++-v3/testsuite/23_containers/list/cons/1.h new file mode 100644 index 000000000..2aa48be91 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/1.h @@ -0,0 +1,63 @@ +// Copyright (C) 2001, 2004, 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.1 list constructors, copy, and assignment + +#include + +// A nontrivial type. +template + struct A { }; + +// Another nontrivial type +struct B { }; + +// Default constructor, basic properties +// +// This test verifies the following. +// 23.2.2.1 explicit list(const a& = Allocator()) +// 23.1 (7) iterator behaviour of empty containers +// 23.2.2 iterator begin() +// 23.2.2 iterator end() +// 23.2.2 size_type size() const +// 23.2.2 existence of required typedefs +// +template +void +cons01() +{ + bool test __attribute__((unused)) = true; + typedef _Tp list_type; + + list_type list0101; + VERIFY(list0101.begin() == list0101.end()); + VERIFY(list0101.size() == 0); + + // check type definitions -- will fail compile if missing + typedef typename list_type::reference reference; + typedef typename list_type::const_reference const_reference; + typedef typename list_type::iterator iterator; + typedef typename list_type::const_iterator const_iterator; + typedef typename list_type::size_type size_type; + typedef typename list_type::difference_type difference_type; + typedef typename list_type::value_type value_type; + typedef typename list_type::allocator_type allocator_type; + typedef typename list_type::pointer pointer; + typedef typename list_type::const_pointer const_pointer; + typedef typename list_type::reverse_iterator reverse_iterator; + typedef typename list_type::const_reverse_iterator const_reverse_iterator; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/2.cc b/libstdc++-v3/testsuite/23_containers/list/cons/2.cc new file mode 100644 index 000000000..86c59f383 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/2.cc @@ -0,0 +1,26 @@ +// Copyright (C) 2001, 2004, 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 "2.h" +#include + +int main() +{ + cons021 >(); + cons022 > >(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/2.h b/libstdc++-v3/testsuite/23_containers/list/cons/2.h new file mode 100644 index 000000000..eb32896e7 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/2.h @@ -0,0 +1,77 @@ +// Copyright (C) 2001, 2004, 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.1 list constructors, copy, and assignment + +#include + +// A nontrivial type. +template + struct A { }; + +// Another nontrivial type +struct B { }; + +// Fill constructor +// +// This test verifies the following. +// 23.2.2.1 explicit list(size_type n, const T& v = T(), const a& = Allocator()) +// 23.2.2 const_iterator begin() const +// 23.2.2 const_iterator end() const +// 23.2.2 size_type size() const +// +template +void +cons021() +{ + bool test __attribute__((unused)) = true; + const std::size_t LIST_SIZE = 5; + const int INIT_VALUE = 7; + std::size_t count; + + typedef _Tp list_type; + typedef typename list_type::const_iterator const_iterator; + const_iterator i; + + // default value + list_type list0202(LIST_SIZE); + for (i = list0202.begin(), count = 0; + i != list0202.end(); + ++i, ++count) + VERIFY(*i == 0); + VERIFY(count == LIST_SIZE); + VERIFY(list0202.size() == LIST_SIZE); + + // explicit value + list_type list0203(LIST_SIZE, INIT_VALUE); + for (i = list0203.begin(), count = 0; + i != list0203.end(); + ++i, ++count) + VERIFY(*i == INIT_VALUE); + VERIFY(count == LIST_SIZE); + VERIFY(list0203.size() == LIST_SIZE); +} + +template +void +cons022() +{ + // nontrivial value_type + typedef _Tp list_type; + const std::size_t LIST_SIZE = 5; + list_type list0201(LIST_SIZE); +} diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/3.cc b/libstdc++-v3/testsuite/23_containers/list/cons/3.cc new file mode 100644 index 000000000..f373cc05d --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/3.cc @@ -0,0 +1,25 @@ +// Copyright (C) 2001, 2004, 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 "3.h" +#include + +int main() +{ + cons03 >(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/3.h b/libstdc++-v3/testsuite/23_containers/list/cons/3.h new file mode 100644 index 000000000..983c24ca8 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/3.h @@ -0,0 +1,48 @@ +// Copyright (C) 2001, 2004, 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.1 list constructors, copy, and assignment + +#include + +// A nontrivial type convertible from an int +struct C +{ + C(int i) : i_(i) { } + bool operator==(const C& rhs) { return i_ == rhs.i_; } + int i_; +}; + +// Fill constructor disguised as a range constructor +template +void +cons03() +{ + bool test __attribute__((unused)) = true; + typedef _Tp list_type; + typedef typename list_type::iterator iterator; + + const std::size_t LIST_SIZE = 5; + const int INIT_VALUE = 7; + std::size_t count = 0; + list_type list0204(LIST_SIZE, INIT_VALUE); + iterator i = list0204.begin(); + for (; i != list0204.end(); ++i, ++count) + VERIFY(*i == INIT_VALUE); + VERIFY(count == LIST_SIZE); + VERIFY(list0204.size() == LIST_SIZE); +} diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/4.cc b/libstdc++-v3/testsuite/23_containers/list/cons/4.cc new file mode 100644 index 000000000..d6b58be04 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/4.cc @@ -0,0 +1,26 @@ +// Copyright (C) 2001, 2004, 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 "4.h" +#include + +int main() +{ + cons04 >(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/4.h b/libstdc++-v3/testsuite/23_containers/list/cons/4.h new file mode 100644 index 000000000..bf2e51c13 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/4.h @@ -0,0 +1,61 @@ +// Copyright (C) 2001, 2004, 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.1 list constructors, copy, and assignment + +#include + +// Range constructor +// +// This test verifies the following. +// 23.2.2.1 template list(InputIterator f, InputIterator l, +// const Allocator& a = Allocator()) +// 23.2.2 const_iterator begin() const +// 23.2.2 const_iterator end() const +// 23.2.2 size_type size() const +// +template +void +cons04() +{ + bool test __attribute__((unused)) = true; + const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; + const std::size_t N = sizeof(A) / sizeof(int); + std::size_t count; + + typedef _Tp list_type; + typedef typename list_type::const_iterator const_iterator; + const_iterator i; + + // construct from a dissimilar range + list_type list0301(A, A + N); + for (i = list0301.begin(), count = 0; + i != list0301.end(); + ++i, ++count) + VERIFY(*i == A[count]); + VERIFY(count == N); + VERIFY(list0301.size() == N); + + // construct from a similar range + list_type list0302(list0301.begin(), list0301.end()); + for (i = list0302.begin(), count = 0; + i != list0302.end(); + ++i, ++count) + VERIFY(*i == A[count]); + VERIFY(count == N); + VERIFY(list0302.size() == N); +} diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/5.cc b/libstdc++-v3/testsuite/23_containers/list/cons/5.cc new file mode 100644 index 000000000..de86dccd6 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/5.cc @@ -0,0 +1,26 @@ +// Copyright (C) 2001, 2004, 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 "5.h" +#include + +int main() +{ + cons05 >(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/5.h b/libstdc++-v3/testsuite/23_containers/list/cons/5.h new file mode 100644 index 000000000..5c273a322 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/5.h @@ -0,0 +1,51 @@ +// Copyright (C) 2001, 2004, 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.1 list constructors, copy, and assignment + +#include + +// Copy constructor +// +// This test verifies the following. +// 23.2.2.1 list(const list& x) +// 23.2.2 reverse_iterator rbegin() +// 23.2.2 reverse_iterator rend() +// 23.2.2 size_type size() const +// +template +void +cons05() +{ + bool test __attribute__((unused)) = true; + const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; + const std::size_t N = sizeof(A) / sizeof(int); + int count; + + typedef _Tp list_type; + typedef typename list_type::reverse_iterator reverse_iterator; + reverse_iterator i; + list_type list0401(A, A + N); + + list_type list0402(list0401); + for (i = list0401.rbegin(), count = N - 1; + i != list0401.rend(); + ++i, --count) + VERIFY(*i == A[count]); + VERIFY(count == -1); + VERIFY(list0401.size() == N); +} diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/6.cc b/libstdc++-v3/testsuite/23_containers/list/cons/6.cc new file mode 100644 index 000000000..c1a2baedc --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/6.cc @@ -0,0 +1,26 @@ +// Copyright (C) 2001, 2004, 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 "6.h" +#include + +int main() +{ + cons06 >(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/6.h b/libstdc++-v3/testsuite/23_containers/list/cons/6.h new file mode 100644 index 000000000..b247e5563 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/6.h @@ -0,0 +1,64 @@ +// Copyright (C) 2001, 2004, 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.1 list constructors, copy, and assignment + +#include + +// Range assign +// +// This test verifies the following. +// 23.2.2.1 void assign(InputIterator f, InputIterator l) +// 23.2.2 const_iterator begin() const +// 23.2.2 const_iterator end() const +// 23.2.2 size_type size() const +// +template +void +cons06() +{ + bool test __attribute__((unused)) = true; + const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17}; + const int B[] = {101, 102, 103, 104, 105}; + const std::size_t N = sizeof(A) / sizeof(int); + const std::size_t M = sizeof(B) / sizeof(int); + std::size_t count; + + typedef _Tp list_type; + typedef typename list_type::const_iterator const_iterator; + const_iterator i; + + list_type list0501; + + // make it bigger + list0501.assign(A, A + N); + for (i = list0501.begin(), count = 0; + i != list0501.end(); + ++i, ++count) + VERIFY(*i == A[count]); + VERIFY(count == N); + VERIFY(list0501.size() == N); + + // make it smaller + list0501.assign(B, B + M); + for (i = list0501.begin(), count = 0; + i != list0501.end(); + ++i, ++count) + VERIFY(*i == B[count]); + VERIFY(count == M); + VERIFY(list0501.size() == M); +} diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/7.cc b/libstdc++-v3/testsuite/23_containers/list/cons/7.cc new file mode 100644 index 000000000..0f3de3c67 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/7.cc @@ -0,0 +1,26 @@ +// Copyright (C) 2001, 2004, 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 "7.h" +#include + +int main() +{ + cons07 >(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/7.h b/libstdc++-v3/testsuite/23_containers/list/cons/7.h new file mode 100644 index 000000000..1ebd7a5cf --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/7.h @@ -0,0 +1,65 @@ +// Copyright (C) 2001, 2004, 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.1 list constructors, copy, and assignment + +#include + +// Fill assign +// +// This test verifies the following. +// 23.2.2.1 void assign(size_type n, const T& v) +// 23.2.2 const_iterator begin() const +// 23.2.2 const_iterator end() const +// 23.2.2 size_type size() const +// +template +void +cons07() +{ + bool test __attribute__((unused)) = true; + const std::size_t BIG_LIST_SIZE = 11; + const int BIG_INIT_VALUE = 7; + const std::size_t SMALL_LIST_SIZE = 5; + const int SMALL_INIT_VALUE = 17; + std::size_t count; + + typedef _Tp list_type; + typedef typename list_type::const_iterator const_iterator; + const_iterator i; + + list_type list0601; + VERIFY(list0601.size() == 0); + + // make it bigger + list0601.assign(BIG_LIST_SIZE, BIG_INIT_VALUE); + for (i = list0601.begin(), count = 0; + i != list0601.end(); + ++i, ++count) + VERIFY(*i == BIG_INIT_VALUE); + VERIFY(count == BIG_LIST_SIZE); + VERIFY(list0601.size() == BIG_LIST_SIZE); + + // make it shrink + list0601.assign(SMALL_LIST_SIZE, SMALL_INIT_VALUE); + for (i = list0601.begin(), count = 0; + i != list0601.end(); + ++i, ++count) + VERIFY(*i == SMALL_INIT_VALUE); + VERIFY(count == SMALL_LIST_SIZE); + VERIFY(list0601.size() == SMALL_LIST_SIZE); +} diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/8.cc b/libstdc++-v3/testsuite/23_containers/list/cons/8.cc new file mode 100644 index 000000000..16d888b44 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/8.cc @@ -0,0 +1,26 @@ +// Copyright (C) 2001, 2004, 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 "8.h" +#include + +int main() +{ + cons08 >(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/8.h b/libstdc++-v3/testsuite/23_containers/list/cons/8.h new file mode 100644 index 000000000..4aed16b81 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/8.h @@ -0,0 +1,51 @@ +// Copyright (C) 2001, 2004, 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.1 list constructors, copy, and assignment + +#include + +// A nontrivial type convertible from an int +struct C +{ + C(int i) : i_(i) { } + bool operator==(const C& rhs) { return i_ == rhs.i_; } + int i_; +}; + +// Fill Assignment disguised as a Range Assignment +template +void +cons08() +{ + typedef _Tp list_type; + typedef typename list_type::iterator iterator; + bool test __attribute__((unused)) = true; + const std::size_t LIST_SIZE = 5; + const int INIT_VALUE = 7; + std::size_t count = 0; + + list_type list0604; + VERIFY(list0604.size() == 0); + + list0604.assign(LIST_SIZE, INIT_VALUE); + iterator i = list0604.begin(); + for (; i != list0604.end(); ++i, ++count) + VERIFY(*i == INIT_VALUE); + VERIFY(count == LIST_SIZE); + VERIFY(list0604.size() == LIST_SIZE); +} diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/9.cc b/libstdc++-v3/testsuite/23_containers/list/cons/9.cc new file mode 100644 index 000000000..908454453 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/9.cc @@ -0,0 +1,25 @@ +// Copyright (C) 2001, 2004, 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 "9.h" +#include + +int main() +{ + cons09 >(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/9.h b/libstdc++-v3/testsuite/23_containers/list/cons/9.h new file mode 100644 index 000000000..90c3fd054 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/9.h @@ -0,0 +1,59 @@ +// Copyright (C) 2001, 2004, 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.1 list constructors, copy, and assignment + +#include + +// Assignment operator +// +// This test verifies the following. +// 23.2.2 operator=(const list& x) +// 23.2.2 iterator begin() +// 23.2.2 iterator end() +// 23.2.2 size_type size() const +// 23.2.2 bool operator==(const list& x, const list& y) +// +template +void +cons09() +{ + bool test __attribute__((unused)) = true; + typedef _Tp list_type; + typedef typename list_type::iterator iterator; + + const int A[] = {701, 702, 703, 704, 705}; + const std::size_t N = sizeof(A) / sizeof(int); + std::size_t count; + + iterator i; + + list_type list0701(A, A + N); + VERIFY(list0701.size() == N); + + list_type list0702; + VERIFY(list0702.size() == 0); + + list0702 = list0701; + VERIFY(list0702.size() == N); + for (i = list0702.begin(), count = 0; + i != list0702.end(); + ++i, ++count) + VERIFY(*i == A[count]); + VERIFY(count == N); + VERIFY(list0702 == list0701); +} diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/clear_allocator.cc b/libstdc++-v3/testsuite/23_containers/list/cons/clear_allocator.cc new file mode 100644 index 000000000..cb186d321 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/clear_allocator.cc @@ -0,0 +1,27 @@ +// Copyright (C) 2004, 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 "clear_allocator.h" +#include + +int main() +{ + typedef std::list > list_type; + Check_Container(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/clear_allocator.h b/libstdc++-v3/testsuite/23_containers/list/cons/clear_allocator.h new file mode 100644 index 000000000..3a53751c9 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/clear_allocator.h @@ -0,0 +1,78 @@ +// Copyright (C) 2004, 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 + +using namespace std; +using __gnu_cxx::new_allocator; + +template + class clear_alloc : public new_allocator + { + public: + + template + struct rebind + { typedef clear_alloc other; }; + + virtual void clear() throw() + { } + + clear_alloc() throw() + { } + + clear_alloc(clear_alloc const&) throw() : new_allocator() + { } + + template + clear_alloc(clear_alloc const&) throw() + { } + + virtual ~clear_alloc() throw() + { this->clear(); } + + T* allocate(typename new_allocator::size_type n, const void *hint = 0) + { + this->clear(); + return new_allocator::allocate(n, hint); + } + + void deallocate(T *ptr, typename new_allocator::size_type n) + { + this->clear(); + new_allocator::deallocate(ptr, n); + } + }; + +template + void Check_Container() + { + Container* pic = new Container; + int x = 230; + + while (x--) + { + pic->push_back(x); + } + + pic->get_allocator(); + + // The following has led to infinite recursions or cores. + pic->clear(); + + delete pic; + } diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/cons_size.cc b/libstdc++-v3/testsuite/23_containers/list/cons/cons_size.cc new file mode 100644 index 000000000..f59f520f9 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/cons_size.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-06-18 Paolo Carlini + +// Copyright (C) 2010 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 +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::list<__gnu_test::NonCopyConstructible> l(1000); + VERIFY( std::distance(l.begin(), l.end()) == 1000 ); + for(auto it = l.begin(); it != l.end(); ++it) + VERIFY( *it == -1 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/moveable.cc b/libstdc++-v3/testsuite/23_containers/list/cons/moveable.cc new file mode 100644 index 000000000..fbe06634e --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/moveable.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 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 "moveable.h" +#include + +int main() +{ + test_moveable >(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/cons/moveable.h b/libstdc++-v3/testsuite/23_containers/list/cons/moveable.h new file mode 100644 index 000000000..1f11d6221 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/cons/moveable.h @@ -0,0 +1,41 @@ +// Copyright (C) 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 +// . + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on list (via swap). If the implementation changed +// this test may begin to fail. + +#include +#include + +template + void + test_moveable() + { + bool test __attribute__((unused)) = true; + + typedef _Tp list_type; + + list_type a,b; + a.push_back(1); + b = std::move(a); + VERIFY( b.size() == 1 && *b.begin() == 1 && a.size() == 0 ); + + list_type c(std::move(b)); + VERIFY( c.size() == 1 && *c.begin() == 1 ); + VERIFY( b.size() == 0 ); + } diff --git a/libstdc++-v3/testsuite/23_containers/list/debug/assign1_neg.cc b/libstdc++-v3/testsuite/23_containers/list/debug/assign1_neg.cc new file mode 100644 index 000000000..e7b0e5cfe --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/debug/assign1_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010 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 +// . +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_assign1 >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/debug/assign2_neg.cc b/libstdc++-v3/testsuite/23_containers/list/debug/assign2_neg.cc new file mode 100644 index 000000000..1bd6c2f90 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/debug/assign2_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010 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 +// . +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_assign2 >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/debug/assign3_neg.cc b/libstdc++-v3/testsuite/23_containers/list/debug/assign3_neg.cc new file mode 100644 index 000000000..7a40d3189 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/debug/assign3_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010 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 +// . +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_assign3 >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/debug/assign4_neg.cc b/libstdc++-v3/testsuite/23_containers/list/debug/assign4_neg.cc new file mode 100644 index 000000000..bde7b923e --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/debug/assign4_neg.cc @@ -0,0 +1,32 @@ +// Copyright (C) 2010 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 +// . +// +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_assign1<__gnu_debug::list >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/debug/construct1_neg.cc b/libstdc++-v3/testsuite/23_containers/list/debug/construct1_neg.cc new file mode 100644 index 000000000..cbd045571 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/debug/construct1_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010 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 +// . +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_construct1 >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/debug/construct2_neg.cc b/libstdc++-v3/testsuite/23_containers/list/debug/construct2_neg.cc new file mode 100644 index 000000000..40fdf43b8 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/debug/construct2_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010 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 +// . +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_construct2 >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/debug/construct3_neg.cc b/libstdc++-v3/testsuite/23_containers/list/debug/construct3_neg.cc new file mode 100644 index 000000000..5000f5a07 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/debug/construct3_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010 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 +// . +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_construct3 >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/debug/construct4_neg.cc b/libstdc++-v3/testsuite/23_containers/list/debug/construct4_neg.cc new file mode 100644 index 000000000..29843ea43 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/debug/construct4_neg.cc @@ -0,0 +1,32 @@ +// Copyright (C) 2010 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 +// . +// +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_construct1<__gnu_debug::list >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/debug/insert1_neg.cc b/libstdc++-v3/testsuite/23_containers/list/debug/insert1_neg.cc new file mode 100644 index 000000000..aa35b46cf --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/debug/insert1_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010 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 +// . +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_insert1 >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/debug/insert2_neg.cc b/libstdc++-v3/testsuite/23_containers/list/debug/insert2_neg.cc new file mode 100644 index 000000000..dc84fdd58 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/debug/insert2_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010 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 +// . +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_insert2 >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/debug/insert3_neg.cc b/libstdc++-v3/testsuite/23_containers/list/debug/insert3_neg.cc new file mode 100644 index 000000000..aa4910838 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/debug/insert3_neg.cc @@ -0,0 +1,33 @@ +// Copyright (C) 2010 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 +// . +// +// { dg-require-debug-mode "" } +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_insert3 >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/debug/insert4_neg.cc b/libstdc++-v3/testsuite/23_containers/list/debug/insert4_neg.cc new file mode 100644 index 000000000..ade280688 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/debug/insert4_neg.cc @@ -0,0 +1,32 @@ +// Copyright (C) 2010 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 +// . +// +// { dg-do run { xfail *-*-* } } + +#include +#include + +void test01() +{ + __gnu_test::check_insert1<__gnu_debug::list >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/debug/invalidation/1.cc b/libstdc++-v3/testsuite/23_containers/list/debug/invalidation/1.cc new file mode 100644 index 000000000..7198e2402 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/debug/invalidation/1.cc @@ -0,0 +1,59 @@ +// List iterator invalidation tests + +// Copyright (C) 2003, 2004, 2005, 2006, 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 +#include + +// Assignment +void test01() +{ + using std::advance; + + bool test __attribute__((unused)) = true; + + typedef __gnu_debug::list list_type; + list_type v1; + list_type v2; + + v1.push_front(17); + + list_type::iterator start = v1.begin(); + list_type::iterator finish = v1.end(); + VERIFY(start._M_dereferenceable()); + VERIFY(!finish._M_dereferenceable() && !finish._M_singular()); + + v1 = v2; + VERIFY(start._M_singular()); + VERIFY(!finish._M_dereferenceable() && !finish._M_singular()); + + finish = v1.end(); + v1.assign(v2.begin(), v2.end()); + VERIFY(!finish._M_dereferenceable() && !finish._M_singular()); + + finish = v1.end(); + v1.assign(17, 42); + VERIFY(!finish._M_dereferenceable() && !finish._M_singular()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/debug/invalidation/2.cc b/libstdc++-v3/testsuite/23_containers/list/debug/invalidation/2.cc new file mode 100644 index 000000000..5872936bb --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/debug/invalidation/2.cc @@ -0,0 +1,55 @@ +// List iterator invalidation tests + +// Copyright (C) 2003, 2004, 2005, 2006, 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 +#include + +// Resize +void test02() +{ + using std::advance; + + bool test __attribute__((unused)) = true; + + typedef __gnu_debug::list list_type; + + list_type v(10, 17); + + list_type::iterator before = v.begin(); + advance(before, 6); + list_type::iterator at = before; + advance(at, 1); + list_type::iterator after = at; + advance(after, 1); + list_type::iterator finish = v.end(); + + // Shrink + v.resize(7); + VERIFY(before._M_dereferenceable()); + VERIFY(at._M_singular()); + VERIFY(after._M_singular()); + VERIFY(!finish._M_singular() && !finish._M_dereferenceable()); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/debug/invalidation/3.cc b/libstdc++-v3/testsuite/23_containers/list/debug/invalidation/3.cc new file mode 100644 index 000000000..0d4844793 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/debug/invalidation/3.cc @@ -0,0 +1,77 @@ +// List iterator invalidation tests + +// Copyright (C) 2003, 2004, 2005, 2006, 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 +#include + +// Erase +void test03() +{ + using std::advance; + + bool test __attribute__((unused)) = true; + typedef __gnu_debug::list list_type; + + list_type v(20, 42); + + // Single element erase (middle) + list_type::iterator before = v.begin(); + list_type::iterator at = before; + advance(at, 3); + list_type::iterator after = at; + at = v.erase(at); + VERIFY(before._M_dereferenceable()); + VERIFY(at._M_dereferenceable()); + VERIFY(after._M_singular()); + + // Single element erase (end) + before = v.begin(); + at = before; + after = at; + ++after; + at = v.erase(at); + VERIFY(before._M_singular()); + VERIFY(at._M_dereferenceable()); + VERIFY(after._M_dereferenceable()); + + // Multiple element erase + before = v.begin(); + at = before; + advance(at, 3); + after = at; + advance(after, 3); + v.erase(at, after); + VERIFY(before._M_dereferenceable()); + VERIFY(at._M_singular()); + + // clear() + before = v.begin(); + list_type::iterator finish = v.end(); + VERIFY(before._M_dereferenceable()); + v.clear(); + VERIFY(before._M_singular()); + VERIFY(!finish._M_singular() && !finish._M_dereferenceable()); +} + +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/debug/invalidation/4.cc b/libstdc++-v3/testsuite/23_containers/list/debug/invalidation/4.cc new file mode 100644 index 000000000..a5c9219a2 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/debug/invalidation/4.cc @@ -0,0 +1,55 @@ +// List iterator invalidation tests + +// Copyright (C) 2003, 2004, 2005, 2006, 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 +#include + +// Splice +void test04() +{ + using std::advance; + + bool test __attribute__((unused)) = true; + + typedef __gnu_debug::list list_type; + + list_type l1(10, 17); + list_type l2(10, 42); + + list_type::iterator start2 = l2.begin(); + list_type::iterator end2 = start2; + advance(end2, 5); + list_type::iterator after2 = end2; + advance(after2, 2); + + l1.splice(l1.begin(), l2, start2, end2); + VERIFY(start2._M_dereferenceable()); + VERIFY(end2._M_dereferenceable()); + VERIFY(after2._M_dereferenceable()); + VERIFY(start2._M_attached_to(&l1)); + VERIFY(end2._M_attached_to(&l2)); + VERIFY(after2._M_attached_to(&l2)); +} + +int main() +{ + test04(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/init-list.cc b/libstdc++-v3/testsuite/23_containers/list/init-list.cc new file mode 100644 index 000000000..db6bc3b69 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/init-list.cc @@ -0,0 +1,31 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008, 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 "init-list.h" +#include + +int main() +{ + typedef int value_type; + typedef __gnu_test::tracker_allocator allocator_type; + typedef std::list list_type; + init_list(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/init-list.h b/libstdc++-v3/testsuite/23_containers/list/init-list.h new file mode 100644 index 000000000..a391ffdad --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/init-list.h @@ -0,0 +1,65 @@ +// Copyright (C) 2008, 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 + +template +bool +init_list() +{ + using namespace __gnu_test; + typedef _Tp list_type; + typedef typename list_type::iterator iterator; + + const int arr10[10] = { 2, 4, 1, 7, 3, 8, 10, 5, 9, 6 }; + bool ok = true; + + tracker_allocator_counter::reset(); + { + list_type c({ 2, 4, 1 }); + ok = check_construct_destroy("Construct from init-list", 3, 0) && ok; + iterator i = c.begin(); + ok &= (*i++ == 2); + ok &= (*i++ == 4); + } + ok = check_construct_destroy("Construct from init-list", 3, 3) && ok; + + { + list_type c(arr10, arr10 + 10); + tracker_allocator_counter::reset(); + iterator i = c.begin(); + ++i; ++i; ++i; ++i; ++i; ++i; ++i; + c.insert(i, { 234, 42, 1 }); + ok = check_construct_destroy("Insert init-list", 3, 0) && ok; + ok &= (*--i == 1); + ok &= (*--i == 42); + } + ok = check_construct_destroy("Insert init-list", 3, 13) && ok; + + { + list_type c; + tracker_allocator_counter::reset(); + c = { 13, 0, 42 }; + ok = check_construct_destroy("Assign init-list", 3, 0) && ok; + iterator i = c.begin(); + ok &= (*i++ == 13); + } + ok = check_construct_destroy("Assign init-list", 3, 3) && ok; + + return ok ? 0 : 1; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/1.cc b/libstdc++-v3/testsuite/23_containers/list/modifiers/1.cc new file mode 100644 index 000000000..4d56b154a --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/1.cc @@ -0,0 +1,25 @@ +// Copyright (C) 2001, 2003, 2004, 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 "1.h" +#include + +int main() +{ + modifiers1 >(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/1.h b/libstdc++-v3/testsuite/23_containers/list/modifiers/1.h new file mode 100644 index 000000000..2abc063e1 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/1.h @@ -0,0 +1,116 @@ +// Copyright (C) 2001, 2003, 2004, 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 modifiers [lib.list.modifiers] + +#include + +// range and fill insert/erase + clear +// missing: o fill insert disguised as a range insert in all its variants +// o exception effects +template +void +modifiers1() +{ + bool test __attribute__((unused)) = true; + typedef _Tp list_type; + typedef typename list_type::iterator iterator; + typedef typename list_type::value_type value_type; + + using __gnu_test::copy_constructor; + using __gnu_test::destructor; + + list_type list0301; + value_type::reset(); + + // fill insert at beginning of list / empty list + list0301.insert(list0301.begin(), 3, value_type(11)); // should be [11 11 11] + VERIFY(list0301.size() == 3); + VERIFY(copy_constructor::count() == 3); + + // save iterators to verify post-insert validity + iterator b = list0301.begin(); + iterator m = list0301.end(); --m; + iterator e = list0301.end(); + + // fill insert at end of list + value_type::reset(); + list0301.insert(list0301.end(), 3, value_type(13)); // should be [11 11 11 13 13 13] + VERIFY(list0301.size() == 6); + VERIFY(copy_constructor::count() == 3); + VERIFY(b == list0301.begin() && b->id() == 11); + VERIFY(e == list0301.end()); + VERIFY(m->id() == 11); + + // fill insert in the middle of list + ++m; + value_type::reset(); + list0301.insert(m, 3, value_type(12)); // should be [11 11 11 12 12 12 13 13 13] + VERIFY(list0301.size() == 9); + VERIFY(copy_constructor::count() == 3); + VERIFY(b == list0301.begin() && b->id() == 11); + VERIFY(e == list0301.end()); + VERIFY(m->id() == 13); + + // single erase + value_type::reset(); + m = list0301.erase(m); // should be [11 11 11 12 12 12 13 13] + VERIFY(list0301.size() == 8); + VERIFY(destructor::count() == 1); + VERIFY(b == list0301.begin() && b->id() == 11); + VERIFY(e == list0301.end()); + VERIFY(m->id() == 13); + + // range erase + value_type::reset(); + m = list0301.erase(list0301.begin(), m); // should be [13 13] + VERIFY(list0301.size() == 2); + VERIFY(destructor::count() == 6); + VERIFY(m->id() == 13); + + // range fill at beginning + const int A[] = {321, 322, 333}; + const int N = sizeof(A) / sizeof(int); + value_type::reset(); + b = list0301.begin(); + list0301.insert(b, A, A + N); // should be [321 322 333 13 13] + VERIFY(list0301.size() == 5); + VERIFY(copy_constructor::count() == 3); + VERIFY(m->id() == 13); + + // range fill at end + value_type::reset(); + list0301.insert(e, A, A + N); // should be [321 322 333 13 13 321 322 333] + VERIFY(list0301.size() == 8); + VERIFY(copy_constructor::count() == 3); + VERIFY(e == list0301.end()); + VERIFY(m->id() == 13); + + // range fill in middle + value_type::reset(); + list0301.insert(m, A, A + N); + VERIFY(list0301.size() == 11); + VERIFY(copy_constructor::count() == 3); + VERIFY(e == list0301.end()); + VERIFY(m->id() == 13); + + value_type::reset(); + list0301.clear(); + VERIFY(list0301.size() == 0); + VERIFY(destructor::count() == 11); + VERIFY(e == list0301.end()); +} diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/1_c++0x.cc b/libstdc++-v3/testsuite/23_containers/list/modifiers/1_c++0x.cc new file mode 100644 index 000000000..dea0d4c44 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/1_c++0x.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 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 "1.h" +#include + +int main() +{ + modifiers1 >(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/2.cc b/libstdc++-v3/testsuite/23_containers/list/modifiers/2.cc new file mode 100644 index 000000000..1879ed2e5 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/2.cc @@ -0,0 +1,25 @@ +// Copyright (C) 2001, 2003, 2004, 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 "2.h" +#include + +int main() +{ + modifiers2 >(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/2.h b/libstdc++-v3/testsuite/23_containers/list/modifiers/2.h new file mode 100644 index 000000000..b25467bdb --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/2.h @@ -0,0 +1,89 @@ +// Copyright (C) 2001, 2003, 2004, 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 modifiers [lib.list.modifiers] + +#include + +// general single insert/erase + swap +template +void +modifiers2() +{ + bool test __attribute__((unused)) = true; + typedef _Tp list_type; + typedef typename list_type::value_type value_type; + typedef typename list_type::iterator iterator; + typedef typename list_type::const_iterator const_iterator; + + using __gnu_test::copy_constructor; + using __gnu_test::destructor; + + list_type list0201; + value_type::reset(); + + list0201.insert(list0201.begin(), value_type(1)); // list should be [1] + VERIFY(list0201.size() == 1); + VERIFY(copy_constructor::count() == 1); + + list0201.insert(list0201.end(), value_type(2)); // list should be [1 2] + VERIFY(list0201.size() == 2); + VERIFY(copy_constructor::count() == 2); + + iterator i = list0201.begin(); + const_iterator j = i; + VERIFY(i->id() == 1); ++i; + VERIFY(i->id() == 2); + + list0201.insert(i, value_type(3)); // list should be [1 3 2] + VERIFY(list0201.size() == 3); + VERIFY(copy_constructor::count() == 3); + + const_iterator k = i; + VERIFY(i->id() == 2); --i; + VERIFY(i->id() == 3); --i; + VERIFY(i->id() == 1); + VERIFY(j->id() == 1); + + ++i; // will point to '3' + value_type::reset(); + list0201.erase(i); // should be [1 2] + VERIFY(list0201.size() == 2); + VERIFY(destructor::count() == 1); + VERIFY(k->id() == 2); + VERIFY(j->id() == 1); + + list_type list0202; + value_type::reset(); + VERIFY(list0202.size() == 0); + VERIFY(copy_constructor::count() == 0); + VERIFY(destructor::count() == 0); + + // member swap + list0202.swap(list0201); + VERIFY(list0201.size() == 0); + VERIFY(list0202.size() == 2); + VERIFY(copy_constructor::count() == 0); + VERIFY(destructor::count() == 0); + + // specialized swap + swap(list0201, list0202); + VERIFY(list0201.size() == 2); + VERIFY(list0202.size() == 0); + VERIFY(copy_constructor::count() == 0); + VERIFY(destructor::count() == 0); +} diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/3.cc b/libstdc++-v3/testsuite/23_containers/list/modifiers/3.cc new file mode 100644 index 000000000..990cf227c --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/3.cc @@ -0,0 +1,25 @@ +// Copyright (C) 2001, 2003, 2004, 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 "3.h" +#include + +int main() +{ + modifiers3 >(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/3.h b/libstdc++-v3/testsuite/23_containers/list/modifiers/3.h new file mode 100644 index 000000000..c4017db49 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/3.h @@ -0,0 +1,121 @@ +// Copyright (C) 2001, 2003, 2004, 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 modifiers [lib.list.modifiers] + +#include + +// This test verifies the following. +// +// 23.2.2.3 void push_front(const T& x) +// 23.2.2.3 void push_back(const T& x) +// 23.2.2.3 (1) iterator and reference non-invalidation +// 23.2.2.3 (1) exception effects +// 23.2.2.3 (2) complexity requirements +// +// 23.2.2.3 void pop_front() +// 23.2.2.3 void pop_back() +// 23.2.2.3 (3) iterator and reference non-invalidation +// 23.2.2.3 (5) complexity requirements +// +// 23.2.2 const_iterator begin() const +// 23.2.2 iterator end() +// 23.2.2 const_reverse_iterator rbegin() const +// 23.2.2 _reference front() +// 23.2.2 const_reference front() const +// 23.2.2 reference back() +// 23.2.2 const_reference back() const +// +template +void +modifiers3() +{ + bool test __attribute__((unused)) = true; + typedef _Tp list_type; + typedef typename list_type::iterator iterator; + typedef typename list_type::value_type value_type; + typedef typename list_type::const_iterator const_iterator; + typedef typename list_type::const_reverse_iterator const_reverse_iterator; + + using __gnu_test::copy_constructor; + using __gnu_test::destructor; + + list_type list0101; + const_iterator i; + const_reverse_iterator j; + iterator k; + value_type::reset(); + + list0101.push_back(value_type(1)); // list should be [1] + VERIFY(list0101.size() == 1); + VERIFY(copy_constructor::count() == 1); + + k = list0101.end(); + --k; + VERIFY(k->id() == 1); + VERIFY(k->id() == list0101.front().id()); + VERIFY(k->id() == list0101.back().id()); + + list0101.push_front(value_type(2)); // list should be [2 1] + VERIFY(list0101.size() == 2); + VERIFY(copy_constructor::count() == 2); + VERIFY(k->id() == 1); + + list0101.push_back(value_type(3)); // list should be [2 1 3] + VERIFY(list0101.size() == 3); + VERIFY(copy_constructor::count() == 3); + VERIFY(k->id() == 1); + + try + { + list0101.push_back(value_type(4, true)); + VERIFY(false); + } + catch (...) + { + VERIFY(list0101.size() == 3); + VERIFY(copy_constructor::count() == 4); + } + + i = list0101.begin(); + VERIFY(i->id() == 2); + VERIFY(i->id() == list0101.front().id()); + + j = list0101.rbegin(); + VERIFY(j->id() == 3); + VERIFY(j->id() == list0101.back().id()); + + ++i; + VERIFY(i->id() == 1); + + ++j; + VERIFY(j->id() == 1); + + value_type::reset(); + + list0101.pop_back(); // list should be [2 1] + VERIFY(list0101.size() == 2); + VERIFY(destructor::count() == 1); + VERIFY(i->id() == 1); + VERIFY(k->id() == 1); + + list0101.pop_front(); // list should be [1] + VERIFY(list0101.size() == 1); + VERIFY(destructor::count() == 2); + VERIFY(i->id() == 1); + VERIFY(k->id() == 1); +} diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/insert/25288.cc b/libstdc++-v3/testsuite/23_containers/list/modifiers/insert/25288.cc new file mode 100644 index 000000000..6fbcf6c17 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/insert/25288.cc @@ -0,0 +1,31 @@ +// { dg-require-time "" } + +// Copyright (C) 2005, 2006, 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 "25288.h" +#include + +int main() +{ + typedef int value_type; + typedef __gnu_cxx::throw_allocator_random allocator_type; + typedef std::list list_type; + + insert1(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/insert/25288.h b/libstdc++-v3/testsuite/23_containers/list/modifiers/insert/25288.h new file mode 100644 index 000000000..772128d95 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/insert/25288.h @@ -0,0 +1,90 @@ +// Copyright (C) 2005, 2006, 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 modifiers [lib.list.modifiers] + +#include +#include + +// libstdc++/25288 +template +void insert1() +{ + bool test __attribute__((unused)) = true; + + typedef _Tp list_type; + typedef typename _Tp::value_type value_type; + typedef typename _Tp::allocator_type allocator_type; + typedef typename _Tp::size_type size_type; + + for (int j = 0; j < 10; ++j) + for (int i = 0; i < 10; ++i) + { + allocator_type alloc1; + typename allocator_type::never_adjustor adjust1; + list_type list1(alloc1); + + for (int k = 0; k < j; ++k) + list1.push_back(value_type(-(k + 1))); + + try + { + typename allocator_type::always_adjustor adjust2; + list1.insert(list1.begin(), 10, 99); + VERIFY( false ); + } + catch (__gnu_cxx::forced_error&) + { + VERIFY( true ); + } + catch (...) + { + __throw_exception_again; + } + + VERIFY( list1.size() == size_type(j) ); + VERIFY( list1.size() == 0 || list1.back() == -j ); + VERIFY( list1.size() == 0 || list1.front() == -1 ); + + allocator_type alloc2; + list_type list2(alloc2); + + const int data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; + + for (int k = 0; k < j; ++k) + list2.push_back(-(k + 1)); + + try + { + typename allocator_type::always_adjustor adjust3; + list2.insert(list2.begin(), data, data + 10); + VERIFY( false ); + } + catch (__gnu_cxx::forced_error&) + { + VERIFY( true ); + } + catch (...) + { + VERIFY( false ); + } + + VERIFY( list2.size() == size_type(j) ); + VERIFY( list2.size() == 0 || list2.back() == -j ); + VERIFY( list2.size() == 0 || list2.front() == -1 ); + } +} 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 ); +} diff --git a/libstdc++-v3/testsuite/23_containers/list/operations/1.cc b/libstdc++-v3/testsuite/23_containers/list/operations/1.cc new file mode 100644 index 000000000..48c7d908c --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/operations/1.cc @@ -0,0 +1,26 @@ +// Copyright (C) 2001, 2004, 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 "1.h" +#include + +int main() +{ + operations01 >(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/23_containers/list/operations/1.h b/libstdc++-v3/testsuite/23_containers/list/operations/1.h new file mode 100644 index 000000000..601c5e772 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/operations/1.h @@ -0,0 +1,68 @@ +// Copyright (C) 2001, 2004, 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.4 list operations [lib.list.ops] + +#include + +// splice(p, x) + remove + reverse +template +void +operations01() +{ + bool test __attribute__((unused)) = true; + typedef _Tp list_type; + typedef typename list_type::iterator iterator; + + const int K = 417; + const int A[] = {1, 2, 3, 4, 5}; + const int B[] = {K, K, K, K, K}; + const std::size_t N = sizeof(A) / sizeof(int); + const std::size_t M = sizeof(B) / sizeof(int); + + list_type list0101(A, A + N); + list_type list0102(B, B + M); + iterator p = list0101.begin(); + + VERIFY(list0101.size() == N); + VERIFY(list0102.size() == M); + + ++p; + list0101.splice(p, list0102); // [1 K K K K K 2 3 4 5] + VERIFY(list0101.size() == N + M); + VERIFY(list0102.size() == 0); + + // remove range from middle + list0101.remove(K); + VERIFY(list0101.size() == N); + + // remove first element + list0101.remove(1); + VERIFY(list0101.size() == N - 1); + + // remove last element + list0101.remove(5); + VERIFY(list0101.size() == N - 2); + + // reverse + list0101.reverse(); + p = list0101.begin(); + VERIFY(*p == 4); ++p; + VERIFY(*p == 3); ++p; + VERIFY(*p == 2); ++p; + VERIFY(p == list0101.end()); +} diff --git a/libstdc++-v3/testsuite/23_containers/list/operations/2.cc b/libstdc++-v3/testsuite/23_containers/list/operations/2.cc new file mode 100644 index 000000000..7cd576220 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/operations/2.cc @@ -0,0 +1,25 @@ +// Copyright (C) 2001, 2004, 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 "2.h" +#include + +int main() +{ + operations02 >(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/operations/2.h b/libstdc++-v3/testsuite/23_containers/list/operations/2.h new file mode 100644 index 000000000..6db3333bd --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/operations/2.h @@ -0,0 +1,54 @@ +// Copyright (C) 2001, 2004, 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.4 list operations [lib.list.ops] + +#include + +// splice(p, x, i) + remove_if + operator== +template +void +operations02() +{ + bool test __attribute__((unused)) = true; + typedef _Tp list_type; + typedef typename list_type::iterator iterator; + + const int A[] = {1, 2, 3, 4, 5}; + const int B[] = {2, 1, 3, 4, 5}; + const int C[] = {1, 3, 4, 5, 2}; + const int N = sizeof(A) / sizeof(int); + list_type list0201(A, A + N); + list_type list0202(A, A + N); + list_type list0203(B, B + N); + list_type list0204(C, C + N); + iterator i = list0201.begin(); + + // result should be unchanged + list0201.splice(list0201.begin(), list0201, i); + VERIFY(list0201 == list0202); + + // result should be [2 1 3 4 5] + ++i; + list0201.splice(list0201.begin(), list0201, i); + VERIFY(list0201 != list0202); + VERIFY(list0201 == list0203); + + // result should be [1 3 4 5 2] + list0201.splice(list0201.end(), list0201, i); + VERIFY(list0201 == list0204); +} diff --git a/libstdc++-v3/testsuite/23_containers/list/operations/2_c++0x.cc b/libstdc++-v3/testsuite/23_containers/list/operations/2_c++0x.cc new file mode 100644 index 000000000..6d744a015 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/operations/2_c++0x.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 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 "2.h" +#include + +int main() +{ + operations02 >(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/operations/3.cc b/libstdc++-v3/testsuite/23_containers/list/operations/3.cc new file mode 100644 index 000000000..1ed46b21d --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/operations/3.cc @@ -0,0 +1,25 @@ +// Copyright (C) 2001, 2004, 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 "3.h" +#include + +int main(void) +{ + operations03 >(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/operations/3.h b/libstdc++-v3/testsuite/23_containers/list/operations/3.h new file mode 100644 index 000000000..9181e7ea9 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/operations/3.h @@ -0,0 +1,68 @@ +// Copyright (C) 2001, 2004, 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.4 list operations [lib.list.ops] + +#include + +// splice(p, x, f, l) + sort + merge + unique +template +void +operations03() +{ + bool test __attribute__((unused)) = true; + typedef _Tp list_type; + typedef typename list_type::iterator iterator; + + const int A[] = {103, 203, 603, 303, 403, 503}; + const int B[] = {417, 417, 417, 417, 417}; + const int E[] = {103, 417, 417, 203, 603, 303, 403, 503}; + const int F[] = {103, 203, 303, 403, 417, 417, 503, 603}; + const int C[] = {103, 203, 303, 403, 417, 417, 417, 417, 417, 503, 603}; + const int D[] = {103, 203, 303, 403, 417, 503, 603}; + const int N = sizeof(A) / sizeof(int); + const int M = sizeof(B) / sizeof(int); + const int P = sizeof(C) / sizeof(int); + const int Q = sizeof(D) / sizeof(int); + const int R = sizeof(E) / sizeof(int); + + list_type list0301(A, A + N); + list_type list0302(B, B + M); + list_type list0303(C, C + P); + list_type list0304(D, D + Q); + list_type list0305(E, E + R); + list_type list0306(F, F + R); + iterator p = list0301.begin(); + iterator q = list0302.begin(); + + ++p; ++q; ++q; + list0301.splice(p, list0302, list0302.begin(), q); + VERIFY(list0301 == list0305); + VERIFY(list0301.size() == N + 2); + VERIFY(list0302.size() == M - 2); + + list0301.sort(); + VERIFY(list0301 == list0306); + + list0301.merge(list0302); + VERIFY(list0301.size() == N + M); + VERIFY(list0302.size() == 0); + VERIFY(list0301 == list0303); + + list0301.unique(); + VERIFY(list0301 == list0304); +} diff --git a/libstdc++-v3/testsuite/23_containers/list/operations/35969.cc b/libstdc++-v3/testsuite/23_containers/list/operations/35969.cc new file mode 100644 index 000000000..2442f9601 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/operations/35969.cc @@ -0,0 +1,79 @@ +// Copyright (C) 2008, 2009, 2010 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.4 list operations [lib.list.ops] + +// NB: This issue affected only debug-mode. + +#include +#include + +// libstdc++/35969 +void test01() +{ + { + std::list list1; + std::list list2; + + for(int i = 0; i < 10; ++i) + { + list1.push_back(i); + list2.push_back(10 - i); + } + + list1.sort(); + list2.sort(); + + std::list::iterator node_of_interest = list2.begin(); + + list1.splice(list1.begin(), list2, node_of_interest); + list2.splice(list2.begin(), list1, node_of_interest); + + list1.merge(list2); + + list2.splice(list2.begin(), list1, node_of_interest); + } + + { + std::list list1; + std::list list2; + + for(int i = 0; i < 10; ++i) + { + list1.push_back(i); + list2.push_back(10 - i); + } + + list1.sort(); + list2.sort(); + + std::list::iterator node_of_interest = list2.begin(); + + list1.splice(list1.begin(), list2, node_of_interest); + list2.splice(list2.begin(), list1, node_of_interest); + + list1.merge(list2, std::less()); + + list2.splice(list2.begin(), list1, node_of_interest); + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/operations/3_c++0x.cc b/libstdc++-v3/testsuite/23_containers/list/operations/3_c++0x.cc new file mode 100644 index 000000000..37a480606 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/operations/3_c++0x.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 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 "3.h" +#include + +int main() +{ + operations03 >(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/operations/4.cc b/libstdc++-v3/testsuite/23_containers/list/operations/4.cc new file mode 100644 index 000000000..4e14f1ae6 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/operations/4.cc @@ -0,0 +1,26 @@ +// Copyright (C) 2001, 2004, 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 "4.h" +#include + +int main() +{ + operations04 >(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/23_containers/list/operations/4.h b/libstdc++-v3/testsuite/23_containers/list/operations/4.h new file mode 100644 index 000000000..650282747 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/operations/4.h @@ -0,0 +1,92 @@ +// Copyright (C) 2001, 2004, 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.4 list operations [lib.list.ops] + +#include + +// A comparison predicate to order by rightmost digit. Tracks call +// counts for performance checks. +struct CompLastLt +{ + bool operator()(const int x, const int y) + { ++itsCount; return x % 10 < y % 10; } + static int count() { return itsCount; } + static void reset() { itsCount = 0; } + static int itsCount; +}; + +int CompLastLt::itsCount; + +struct CompLastEq +{ + bool operator()(const int x, const int y) + { ++itsCount; return x % 10 == y % 10; } + static int count() { return itsCount; } + static void reset() { itsCount = 0; } + static int itsCount; +}; + +int CompLastEq::itsCount; + +// sort(pred) + merge(pred) + unique(pred) +// also checks performance requirements +template +void +operations04() +{ + bool test __attribute__((unused)) = true; + typedef _Tp list_type; + + const int A[] = {1, 2, 3, 4, 5, 6}; + const int B[] = {12, 15, 13, 14, 11}; + const int C[] = {11, 12, 13, 14, 15}; + const int D[] = {1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6}; + const int N = sizeof(A) / sizeof(int); + const int M = sizeof(B) / sizeof(int); + const int Q = sizeof(D) / sizeof(int); + + list_type list0401(A, A + N); + list_type list0402(B, B + M); + list_type list0403(C, C + M); + list_type list0404(D, D + Q); + list_type list0405(A, A + N); + + // sort B + CompLastLt lt; + + CompLastLt::reset(); + list0402.sort(lt); + VERIFY(list0402 == list0403); + + CompLastLt::reset(); + list0401.merge(list0402, lt); + VERIFY(list0401 == list0404); +#ifndef _GLIBCXX_DEBUG + VERIFY(lt.count() <= (N + M - 1)); +#endif + + CompLastEq eq; + + CompLastEq::reset(); + list0401.unique(eq); + VERIFY(list0401 == list0405); +#ifndef _GLIBCXX_DEBUG + VERIFY(eq.count() == (N + M - 1)); +#endif +} + diff --git a/libstdc++-v3/testsuite/23_containers/list/operations/42352.cc b/libstdc++-v3/testsuite/23_containers/list/operations/42352.cc new file mode 100644 index 000000000..7e6c9c4f1 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/operations/42352.cc @@ -0,0 +1,66 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 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 + +// PR libstdc++/42352 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::list l{3, 2, 4, 1, 5, 9, 0, 8, 6, 7}; + + l.sort(); + + for (auto it = l.begin(); it != l.end(); ++it) + { + static int nn = 0; + VERIFY( *it == nn++ ); + } +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + std::list l{3, 2, 4, 1, 5, 9, 0, 8, 6, 7}; + + struct compare + { + bool + operator()(int const& one, int const& two) const + { return one > two; } + }; + + l.sort(compare()); + + for (auto it = l.begin(); it != l.end(); ++it) + { + static int nn = 9; + VERIFY( *it == nn-- ); + } +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/operations/5.cc b/libstdc++-v3/testsuite/23_containers/list/operations/5.cc new file mode 100644 index 000000000..bcfbb81b7 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/operations/5.cc @@ -0,0 +1,31 @@ +// 2006-01-19 Paolo Carlini + +// Copyright (C) 2006, 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 "5.h" +#include + +int main() +{ + typedef int value_type; + typedef __gnu_test::uneq_allocator allocator_type; + typedef std::list list_type; + + operations05(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/operations/5.h b/libstdc++-v3/testsuite/23_containers/list/operations/5.h new file mode 100644 index 000000000..0820e8a69 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/operations/5.h @@ -0,0 +1,134 @@ +// 2006-01-19 Paolo Carlini + +// Copyright (C) 2006, 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.4 list operations [lib.list.ops] + +#include +#include +#include + +// Check the splice (and merge) bits of N1599. +template +void +operations05() +{ + bool test __attribute__((unused)) = true; + + typedef _Tp list_type; + typedef typename list_type::allocator_type allocator_type; + + const int data1[] = {1, 2, 3, 4, 5}; + const int data2[] = {6, 7, 8, 9, 10}; + const size_t N1 = sizeof(data1) / sizeof(int); + const size_t N2 = sizeof(data2) / sizeof(int); + + allocator_type alloc01(1), alloc02(2); + + list_type l01(data1, data1 + N1, alloc01); + const list_type l01_ref = l01; + + list_type l02(data2, data2 + N2, alloc02); + const list_type l02_ref = l02; + + bool catched = false; + + try + { + l01.splice(l01.begin(), l02); + } + catch(std::runtime_error&) + { + catched = true; + } + catch(...) + { + VERIFY( false ); + } + VERIFY( catched ); + VERIFY( l01 == l01_ref ); + VERIFY( l02 == l02_ref ); + + catched = false; + try + { + l01.splice(l01.begin(), l02, l02.begin()); + } + catch(std::runtime_error&) + { + catched = true; + } + catch(...) + { + VERIFY( false ); + } + VERIFY( catched ); + VERIFY( l01 == l01_ref ); + VERIFY( l02 == l02_ref ); + + catched = false; + try + { + l01.splice(l01.begin(), l02, l02.begin(), l02.end()); + } + catch(std::runtime_error&) + { + catched = true; + } + catch(...) + { + VERIFY( false ); + } + VERIFY( catched ); + VERIFY( l01 == l01_ref ); + VERIFY( l02 == l02_ref ); + + catched = false; + try + { + l01.merge(l02); + } + catch(std::runtime_error&) + { + catched = true; + } + catch(...) + { + VERIFY( false ); + } + VERIFY( catched ); + VERIFY( l01 == l01_ref ); + VERIFY( l02 == l02_ref ); + + catched = false; + try + { + l01.merge(l02, std::less()); + } + catch(std::runtime_error&) + { + catched = true; + } + catch(...) + { + VERIFY( false ); + } + VERIFY( catched ); + VERIFY( l01 == l01_ref ); + VERIFY( l02 == l02_ref ); +} diff --git a/libstdc++-v3/testsuite/23_containers/list/pthread1.cc b/libstdc++-v3/testsuite/23_containers/list/pthread1.cc new file mode 100644 index 000000000..00dc817b1 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/pthread1.cc @@ -0,0 +1,131 @@ +// 2002-01-23 Loren J. Rittle +// +// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010 +// 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 +// . + +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } } +// { dg-options "-pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } } +// { dg-options "-pthreads" { target *-*-solaris* } } + +// This multi-threading C++/STL/POSIX code adheres to rules outlined here: +// http://www.sgi.com/tech/stl/thread_safety.html +// +// It is believed to exercise the allocation code in a manner that +// should reveal memory leaks (and, under rare cases, race conditions, +// if the STL threading support is fubar'd). + +#include +#include +#include + +const int thread_cycles = 10; +const int thread_pairs = 10; +const unsigned max_size = 100; +const int iters = 10000; + +class task_queue +{ + typedef std::list list_type; + +public: + task_queue () + { + pthread_mutex_init (&fooLock, 0); + pthread_cond_init (&fooCond1, 0); + pthread_cond_init (&fooCond2, 0); + } + ~task_queue () + { + pthread_mutex_destroy (&fooLock); + pthread_cond_destroy (&fooCond1); + pthread_cond_destroy (&fooCond2); + } + + list_type foo; + pthread_mutex_t fooLock; + pthread_cond_t fooCond1; + pthread_cond_t fooCond2; +}; + +void* +produce(void* t) +{ + task_queue& tq = *(static_cast (t)); + int num = 0; + while (num < iters) + { + pthread_mutex_lock (&tq.fooLock); + while (tq.foo.size () >= max_size) + pthread_cond_wait (&tq.fooCond1, &tq.fooLock); + tq.foo.push_back (num++); + pthread_cond_signal (&tq.fooCond2); + pthread_mutex_unlock (&tq.fooLock); + } + return 0; +} + +void* +consume(void* t) +{ + task_queue& tq = *(static_cast (t)); + int num = 0; + while (num < iters) + { + pthread_mutex_lock (&tq.fooLock); + while (tq.foo.size () == 0) + pthread_cond_wait (&tq.fooCond2, &tq.fooLock); + if (tq.foo.front () != num++) + abort (); + tq.foo.pop_front (); + pthread_cond_signal (&tq.fooCond1); + pthread_mutex_unlock (&tq.fooLock); + } + return 0; +} + +int +main() +{ + pthread_t prod[thread_pairs]; + pthread_t cons[thread_pairs]; + + task_queue* tq[thread_pairs]; + +#if defined(__sun) && defined(__svr4__) && _XOPEN_VERSION >= 500 + pthread_setconcurrency (thread_pairs * 2); +#endif + + for (int j = 0; j < thread_cycles; j++) + { + for (int i = 0; i < thread_pairs; i++) + { + tq[i] = new task_queue; + pthread_create (&prod[i], 0, produce, static_cast (tq[i])); + pthread_create (&cons[i], 0, consume, static_cast (tq[i])); + } + + for (int i = 0; i < thread_pairs; i++) + { + pthread_join (prod[i], 0); + pthread_join (cons[i], 0); + delete tq[i]; + } + } + + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/pthread5.cc b/libstdc++-v3/testsuite/23_containers/list/pthread5.cc new file mode 100644 index 000000000..4f4643721 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/pthread5.cc @@ -0,0 +1,125 @@ +// 2002-01-23 Loren J. Rittle +// Adpated from libstdc++/5464 submitted by jjessel@amadeus.net +// Jean-Francois JESSEL (Amadeus SAS Development) +// +// Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010 +// 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 +// . + +// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* *-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* } } +// { dg-options "-pthread" { target *-*-freebsd* *-*-netbsd* *-*-linux* alpha*-*-osf* mips-sgi-irix6* } } +// { dg-options "-pthreads" { target *-*-solaris* } } + +#include +#include +#include +#include +#include + +#ifdef _GLIBCXX_HAVE_UNISTD_H +#include // To test for _POSIX_THREAD_PRIORITY_SCHEDULING +#endif + +#define NTHREADS 8 +#define LOOPS 20 + +struct tt_t +{ + char buf[100]; + int i; +}; + +void* +thread_function (void* arg) +{ + typedef std::vector vector_type; + typedef std::list list_type; + + int myid __attribute__((unused)) = *(int*) arg; + for (int i = 0; i < LOOPS; i++) + { + vector_type myvect1; + + for (int j = 0; j < 2000; j++) + { + vector_type myvect2; + tt_t v; + v.i = j; + myvect1.push_back (v); + myvect2.push_back (v); + list_type mylist; + std::string string_array[4]; + string_array[0] = "toto"; + string_array[1] = "titi"; + string_array[2] = "tata"; + string_array[3] = "tutu"; + for (int k = 0; k < 4; k++) + { + if (mylist.size ()) + { + list_type::iterator aIt; + for (aIt = mylist.begin (); aIt != mylist.end (); ++aIt) + { + if ((*aIt) == &(string_array[k])) + abort (); + } + } + mylist.push_back (&(string_array[k])); + } + } + } + + return arg; +} + +int +main () +{ + int worker; + pthread_t threads[NTHREADS]; + int ids[NTHREADS]; + void* status; + +#if defined(__sun) && defined(__svr4__) && _XOPEN_VERSION >= 500 + pthread_setconcurrency (NTHREADS); +#endif + + pthread_attr_t tattr; + int ret __attribute__((unused)) = pthread_attr_init (&tattr); +#ifdef _POSIX_THREAD_PRIORITY_SCHEDULING + ret = pthread_attr_setscope(&tattr, PTHREAD_SCOPE_SYSTEM); +#endif + + for (worker = 0; worker < NTHREADS; worker++) + { + ids[worker] = worker; + if (pthread_create(&threads[worker], &tattr, + thread_function, &ids[worker])) + abort (); + } + + for (worker = 0; worker < NTHREADS; worker++) + { + if (pthread_join(threads[worker], static_cast(&status))) + abort (); + + if (*((int *)status) != worker) + abort (); + } + + return (0); +} diff --git a/libstdc++-v3/testsuite/23_containers/list/range_access.cc b/libstdc++-v3/testsuite/23_containers/list/range_access.cc new file mode 100644 index 000000000..768bd638a --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/range_access.cc @@ -0,0 +1,31 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2010 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 +// . + +// 24.6.5, range access [iterator.range] + +#include + +void +test01() +{ + std::list l{1, 2, 3}; + std::begin(l); + std::end(l); +} diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/citerators.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/citerators.cc new file mode 100644 index 000000000..ac5bdec98 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/citerators.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-10-15 Paolo Carlini + +// Copyright (C) 2007, 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 + +int main() +{ + typedef std::list test_type; + __gnu_test::citerator test; + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc new file mode 100644 index 000000000..96a14e4da --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc @@ -0,0 +1,36 @@ +// 2007-04-27 Paolo Carlini + +// Copyright (C) 2007, 2008, 2009, 2010, 2011 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 +// . + +// { dg-do compile } +// { dg-error "no matching" "" { target *-*-* } 1491 } +// { dg-excess-errors "" } + +#include + +struct A +{ + explicit A(int) { } +}; + +void f() +{ + typedef std::list list_type; + list_type l; + l.assign(10, 1); +} diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor.cc new file mode 100644 index 000000000..5c0bf6f72 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor.cc @@ -0,0 +1,28 @@ +// 2007-04-27 Paolo Carlini + +// Copyright (C) 2007, 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 +// . + +// { dg-do compile } + +#include + +void f() +{ + typedef std::list list_type; + list_type l(10, 1); +} diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc new file mode 100644 index 000000000..cc10877fa --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc @@ -0,0 +1,30 @@ +// 2007-04-27 Paolo Carlini + +// Copyright (C) 2007, 2008, 2009, 2010, 2011 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 +// . + +// { dg-do compile } +// { dg-error "no matching" "" { target *-*-* } 1447 } +// { dg-excess-errors "" } + +#include + +void f() +{ + typedef std::list > list_type; + list_type l(10, 1); +} diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc new file mode 100644 index 000000000..acc64e4af --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc @@ -0,0 +1,31 @@ +// 2007-04-27 Paolo Carlini + +// Copyright (C) 2007, 2008, 2009, 2010, 2011 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 +// . + +// { dg-do compile } +// { dg-error "no matching" "" { target *-*-* } 1447 } +// { dg-excess-errors "" } + +#include +#include + +void f() +{ + typedef std::list > > list_type; + list_type l('a', 'b'); +} diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc new file mode 100644 index 000000000..8df0ac528 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc @@ -0,0 +1,36 @@ +// 2007-04-27 Paolo Carlini + +// Copyright (C) 2007, 2008, 2009, 2010, 2011 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 +// . + +// { dg-do compile } +// { dg-error "no matching" "" { target *-*-* } 1447 } +// { dg-excess-errors "" } + +#include + +struct A +{ + explicit A(int) { } +}; + +void f() +{ + typedef std::list list_type; + list_type l; + l.insert(l.begin(), 10, 1); +} diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/exception/basic.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/exception/basic.cc new file mode 100644 index 000000000..33232f965 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/exception/basic.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-11-30 Benjamin Kosnik + +// Copyright (C) 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 + +void +value() +{ + typedef __gnu_cxx::throw_value_limit value_type; + typedef __gnu_cxx::throw_allocator_limit allocator_type; + typedef std::list test_type; + __gnu_test::basic_safety test; +} + +// Container requirement testing, exceptional behavior +int main() +{ + value(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/exception/generation_prohibited.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/exception/generation_prohibited.cc new file mode 100644 index 000000000..f3d16028e --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/exception/generation_prohibited.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-09-09 Benjamin Kosnik + +// Copyright (C) 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 + +// Container requirement testing, exceptional behavior +int main() +{ + typedef __gnu_cxx::throw_value_random value_type; + typedef __gnu_cxx::throw_allocator_random allocator_type; + typedef std::list test_type; + __gnu_test::generation_prohibited test; + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/exception/propagation_consistent.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/exception/propagation_consistent.cc new file mode 100644 index 000000000..02d8d0b25 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/exception/propagation_consistent.cc @@ -0,0 +1,34 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-cstdint "" } + +// 2009-09-09 Benjamin Kosnik + +// Copyright (C) 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 + +// Container requirement testing, exceptional behavior +int main() +{ + typedef __gnu_cxx::throw_value_limit value_type; + typedef __gnu_cxx::throw_allocator_limit allocator_type; + typedef std::list test_type; + __gnu_test::propagation_consistent test; + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..787fe3801 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/1.cc @@ -0,0 +1,25 @@ +// Copyright (C) 2004, 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 +// . + + +// This file tests explicit instantiation of library containers + +#include + +// { dg-do compile } + +template class std::list; diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/1_c++0x.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/1_c++0x.cc new file mode 100644 index 000000000..78e026a7f --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/1_c++0x.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 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 +// . + +// This file tests explicit instantiation of library containers + +#include + +template class std::list; diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..50ae78560 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/2.cc @@ -0,0 +1,30 @@ +// Copyright (C) 2004, 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 +// . + + +// This file tests explicit instantiation of library containers + +#include +#include + +// { dg-do compile } + +// N.B. In C++0x mode we cannot instantiate with T == NonDefaultConstructible +// because of 23.3.4.1.4 +#ifndef __GXX_EXPERIMENTAL_CXX0X__ +template class std::list<__gnu_test::NonDefaultConstructible>; +#endif diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/3.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/3.cc new file mode 100644 index 000000000..ddc34e4be --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/3.cc @@ -0,0 +1,26 @@ +// 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 +// . + + +// This file tests explicit instantiation of library containers + +#include + +// { dg-do compile } + +// libstdc++/21770 +template class std::list >; diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/4.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/4.cc new file mode 100644 index 000000000..7ad82a365 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/explicit_instantiation/4.cc @@ -0,0 +1,29 @@ +// Copyright (C) 2010 Free Software Foundation, Inc. + +// 2010-05-20 Paolo Carlini +// +// 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 +// . + +// This file tests explicit instantiation of library containers + +#include +#include +#include + +// { dg-do compile } + +// libstdc++/41792 +template class std::list<__gnu_test::OverloadedAddress>; diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/partial_specialization/1.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/partial_specialization/1.cc new file mode 100644 index 000000000..69d25cf70 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/partial_specialization/1.cc @@ -0,0 +1,33 @@ +// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 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 +// . + + +// This file tests user specialization of library containers + +#include +#include + +// { dg-do compile } + +struct user_type {}; + +namespace std +{ + template + class list { }; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/typedefs.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/typedefs.cc new file mode 100644 index 000000000..444ebb540 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/typedefs.cc @@ -0,0 +1,25 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 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 + +// Check container for required typedefs. +__gnu_test::types > t; -- cgit v1.2.3