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/map/14340.cc | 34 ++++ libstdc++-v3/testsuite/23_containers/map/18604.cc | 42 +++++ .../testsuite/23_containers/map/23781_neg.cc | 28 ++++ .../testsuite/23_containers/map/capacity/29134.cc | 38 +++++ .../testsuite/23_containers/map/cons/moveable.cc | 43 +++++ .../23_containers/map/debug/construct1_neg.cc | 33 ++++ .../23_containers/map/debug/construct2_neg.cc | 33 ++++ .../23_containers/map/debug/construct3_neg.cc | 33 ++++ .../23_containers/map/debug/construct4_neg.cc | 32 ++++ .../23_containers/map/debug/insert1_neg.cc | 33 ++++ .../23_containers/map/debug/insert2_neg.cc | 33 ++++ .../23_containers/map/debug/insert3_neg.cc | 33 ++++ .../23_containers/map/debug/insert4_neg.cc | 32 ++++ .../23_containers/map/debug/invalidation/1.cc | 51 ++++++ .../23_containers/map/debug/invalidation/2.cc | 70 +++++++++ libstdc++-v3/testsuite/23_containers/map/dr130.cc | 77 +++++++++ .../23_containers/map/element_access/1.cc | 78 +++++++++ .../23_containers/map/element_access/2.cc | 57 +++++++ .../23_containers/map/element_access/46148.cc | 37 +++++ .../testsuite/23_containers/map/init-list.cc | 54 +++++++ .../23_containers/map/modifiers/erase/47628.cc | 46 ++++++ .../23_containers/map/modifiers/erase/51142.cc | 38 +++++ .../23_containers/map/modifiers/insert/1.cc | 67 ++++++++ .../23_containers/map/modifiers/insert/16813.cc | 41 +++++ .../23_containers/map/modifiers/insert/2.cc | 74 +++++++++ .../23_containers/map/modifiers/insert/3.cc | 77 +++++++++ .../23_containers/map/modifiers/insert/4.cc | 70 +++++++++ .../23_containers/map/modifiers/insert/5.cc | 73 +++++++++ .../23_containers/map/modifiers/swap/1.cc | 65 ++++++++ .../23_containers/map/modifiers/swap/2.cc | 146 +++++++++++++++++ .../23_containers/map/modifiers/swap/3.cc | 175 +++++++++++++++++++++ .../testsuite/23_containers/map/operations/1.cc | 127 +++++++++++++++ .../23_containers/map/operations/31440.cc | 52 ++++++ .../testsuite/23_containers/map/operators/1.cc | 49 ++++++ .../testsuite/23_containers/map/operators/1_neg.cc | 45 ++++++ .../testsuite/23_containers/map/pthread6.cc | 87 ++++++++++ .../testsuite/23_containers/map/range_access.cc | 31 ++++ .../23_containers/map/requirements/citerators.cc | 30 ++++ .../map/requirements/exception/basic.cc | 43 +++++ .../exception/generation_prohibited.cc | 36 +++++ .../exception/propagation_consistent.cc | 36 +++++ .../map/requirements/explicit_instantiation/1.cc | 25 +++ .../requirements/explicit_instantiation/1_c++0x.cc | 25 +++ .../map/requirements/explicit_instantiation/2.cc | 29 ++++ .../map/requirements/explicit_instantiation/3.cc | 26 +++ .../map/requirements/explicit_instantiation/4.cc | 30 ++++ .../map/requirements/partial_specialization/1.cc | 33 ++++ .../23_containers/map/requirements/typedefs.cc | 25 +++ 48 files changed, 2472 insertions(+) create mode 100644 libstdc++-v3/testsuite/23_containers/map/14340.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/18604.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/23781_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/capacity/29134.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/cons/moveable.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/debug/construct1_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/debug/construct2_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/debug/construct3_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/debug/construct4_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/debug/insert1_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/debug/insert2_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/debug/insert3_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/debug/insert4_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/debug/invalidation/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/debug/invalidation/2.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/dr130.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/element_access/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/element_access/2.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/element_access/46148.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/init-list.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/modifiers/erase/47628.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/modifiers/erase/51142.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/modifiers/insert/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/modifiers/insert/16813.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/modifiers/insert/2.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/modifiers/insert/3.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/modifiers/insert/4.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/modifiers/insert/5.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/modifiers/swap/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/modifiers/swap/2.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/modifiers/swap/3.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/operations/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/operations/31440.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/operators/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/operators/1_neg.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/pthread6.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/range_access.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/requirements/citerators.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/requirements/exception/basic.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/requirements/exception/generation_prohibited.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/requirements/exception/propagation_consistent.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/1_c++0x.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/2.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/3.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/4.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/requirements/partial_specialization/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/map/requirements/typedefs.cc (limited to 'libstdc++-v3/testsuite/23_containers/map') diff --git a/libstdc++-v3/testsuite/23_containers/map/14340.cc b/libstdc++-v3/testsuite/23_containers/map/14340.cc new file mode 100644 index 000000000..1ee9fc1c9 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/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::map container; + __gnu_test::conversion::iterator_to_const_iterator(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/map/18604.cc b/libstdc++-v3/testsuite/23_containers/map/18604.cc new file mode 100644 index 000000000..ba1b06485 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/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/map/23781_neg.cc b/libstdc++-v3/testsuite/23_containers/map/23781_neg.cc new file mode 100644 index 000000000..e282c7546 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/23781_neg.cc @@ -0,0 +1,28 @@ +// 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 + +std::map::iterator it = NULL; // { dg-error "conversion" } +std::map::const_iterator cit = NULL; // { dg-error "conversion" } diff --git a/libstdc++-v3/testsuite/23_containers/map/capacity/29134.cc b/libstdc++-v3/testsuite/23_containers/map/capacity/29134.cc new file mode 100644 index 000000000..303160801 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/capacity/29134.cc @@ -0,0 +1,38 @@ +// 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.3.1 map capacity + +#include +#include + +// libstdc++/29134 +void test01() +{ + bool test __attribute__((unused)) = true; + + std::map m; + + VERIFY( (m.max_size() == std::allocator > >().max_size()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/map/cons/moveable.cc b/libstdc++-v3/testsuite/23_containers/map/cons/moveable.cc new file mode 100644 index 000000000..47dbd40a2 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/cons/moveable.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2005, 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 +// . + + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on map (via swap). If the implementation changed +// this test may begin to fail. + +#include +#include +#include + +int main() +{ + bool test __attribute__((unused)) = true; + + std::map a,b; + a[2]=0; + b[1]=0; + b = std::move(a); + VERIFY(b.find(2) != b.end() && a.find(1) == a.end()); + + std::map c(std::move(b)); + VERIFY( c.find(2) != c.end()); + VERIFY( b.find(2) == b.end()); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/map/debug/construct1_neg.cc b/libstdc++-v3/testsuite/23_containers/map/debug/construct1_neg.cc new file mode 100644 index 000000000..72adcf42e --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/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/map/debug/construct2_neg.cc b/libstdc++-v3/testsuite/23_containers/map/debug/construct2_neg.cc new file mode 100644 index 000000000..a9cb0e300 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/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/map/debug/construct3_neg.cc b/libstdc++-v3/testsuite/23_containers/map/debug/construct3_neg.cc new file mode 100644 index 000000000..7f88827db --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/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/map/debug/construct4_neg.cc b/libstdc++-v3/testsuite/23_containers/map/debug/construct4_neg.cc new file mode 100644 index 000000000..ce2eccc38 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/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::map >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/map/debug/insert1_neg.cc b/libstdc++-v3/testsuite/23_containers/map/debug/insert1_neg.cc new file mode 100644 index 000000000..7b868a7af --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/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/map/debug/insert2_neg.cc b/libstdc++-v3/testsuite/23_containers/map/debug/insert2_neg.cc new file mode 100644 index 000000000..93c6c7ef5 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/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/map/debug/insert3_neg.cc b/libstdc++-v3/testsuite/23_containers/map/debug/insert3_neg.cc new file mode 100644 index 000000000..2802a0de5 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/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/map/debug/insert4_neg.cc b/libstdc++-v3/testsuite/23_containers/map/debug/insert4_neg.cc new file mode 100644 index 000000000..a68d60108 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/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::map >(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/map/debug/invalidation/1.cc b/libstdc++-v3/testsuite/23_containers/map/debug/invalidation/1.cc new file mode 100644 index 000000000..a42112527 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/debug/invalidation/1.cc @@ -0,0 +1,51 @@ +// Map 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 + +using __gnu_debug::map; +using std::advance; + +bool test = true; + +// Assignment +void test01() +{ + map v1; + map v2; + + v1[17] = 42; + + map::iterator start = v1.begin(); + map::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()); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/map/debug/invalidation/2.cc b/libstdc++-v3/testsuite/23_containers/map/debug/invalidation/2.cc new file mode 100644 index 000000000..85351da9f --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/debug/invalidation/2.cc @@ -0,0 +1,70 @@ +// Map 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 + +using __gnu_debug::map; +using std::advance; + +bool test = true; + +// Erase +void test02() +{ + map v; + for (int i = 0; i < 20; ++i) + v[i] = 20-i; + + // Single element erase (middle) + map::iterator before = v.begin(); + map::iterator at = before; + advance(at, 3); + map::iterator after = at; + ++after; + v.erase(at); + VERIFY(before._M_dereferenceable()); + VERIFY(at._M_singular()); + VERIFY(after._M_dereferenceable()); + + // Multiple element erase + before = v.begin(); + at = before; + advance(at, 3); + after = at; + advance(after, 4); + v.erase(at, after); + VERIFY(before._M_dereferenceable()); + VERIFY(at._M_singular()); + + // clear() + before = v.begin(); + map::iterator finish = v.end(); + VERIFY(before._M_dereferenceable()); + v.clear(); + VERIFY(before._M_singular()); + VERIFY(!finish._M_singular() && !finish._M_dereferenceable()); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/map/dr130.cc b/libstdc++-v3/testsuite/23_containers/map/dr130.cc new file mode 100644 index 000000000..9186a621e --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/dr130.cc @@ -0,0 +1,77 @@ +// { dg-options "-std=gnu++0x" } +// 2008-07-22 Edward Smith-Rowland <3dw4rd@verizon.net> +// +// Copyright (C) 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 + +// DR 130. Associative erase should return an iterator. +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + map m0; + typedef map::iterator iterator; + typedef map::const_iterator const_iterator; + typedef map::value_type value_type; + typedef pair insert_return_type; + + m0.insert(value_type(1, 1)); + insert_return_type irt1 = m0.insert(value_type(2, 2)); + insert_return_type irt2 = m0.insert(value_type(3, 3)); + + iterator pos1 = m0.erase(irt1.first); + VERIFY( pos1 == irt2.first ); + + iterator pos2 = m0.erase(irt2.first); + VERIFY( pos2 == m0.end() ); +} + +void +test02() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + map m0; + typedef map::iterator iterator; + typedef map::const_iterator const_iterator; + typedef map::value_type value_type; + typedef pair insert_return_type; + + insert_return_type irt0 = m0.insert(value_type(1, 1)); + m0.insert(value_type(2, 2)); + insert_return_type irt2 = m0.insert(value_type(3, 3)); + insert_return_type irt3 = m0.insert(value_type(4, 4)); + + iterator pos1 = m0.erase(irt0.first, irt2.first); + VERIFY( pos1 == irt2.first ); + + iterator pos2 = m0.erase(irt2.first, ++irt3.first); + VERIFY( pos2 == m0.end() ); +} + +int +main() +{ + test01(); + test02(); +} diff --git a/libstdc++-v3/testsuite/23_containers/map/element_access/1.cc b/libstdc++-v3/testsuite/23_containers/map/element_access/1.cc new file mode 100644 index 000000000..ed30c1317 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/element_access/1.cc @@ -0,0 +1,78 @@ +// 2005-08-29 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 +#include + +// libstdc++/23578 +void test01() +{ + bool test __attribute__((unused)) = true; + typedef std::map map_type; + + { + map_type m; + m[0] = 1.5; + + double& rd = m.at(0); + VERIFY( rd == 1.5 ); + try + { + m.at(1); + } + catch(std::out_of_range& obj) + { + // Expected. + } + catch(...) + { + // Failed. + throw; + } + } + + { + map_type m; + m[1] = 2.5; + const map_type cm(m); + + const double& crd = cm.at(1); + VERIFY( crd == 2.5 ); + try + { + cm.at(0); + } + catch(std::out_of_range& obj) + { + // Expected. + } + catch(...) + { + // Failed. + throw; + } + } +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/map/element_access/2.cc b/libstdc++-v3/testsuite/23_containers/map/element_access/2.cc new file mode 100644 index 000000000..8f42066d0 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/element_access/2.cc @@ -0,0 +1,57 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-11-10 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 +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::map Map; + + Map m; + VERIFY( m.empty() ); + + m[rvalstruct(1)] = rvalstruct(17); + VERIFY( m.size() == 1 ); + VERIFY( (m.begin()->first).val == 1 ); + VERIFY( (m.begin()->second).val == 17 ); + VERIFY( m[rvalstruct(1)].val == 17 ); + + m[rvalstruct(2)] = rvalstruct(9); + VERIFY( m.size() == 2 ); + VERIFY( m[rvalstruct(2)].val == 9 ); + + m[rvalstruct(1)] = rvalstruct(5); + VERIFY( m.size() == 2 ); + VERIFY( m[rvalstruct(1)].val == 5 ); + VERIFY( m[rvalstruct(2)].val == 9 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/map/element_access/46148.cc b/libstdc++-v3/testsuite/23_containers/map/element_access/46148.cc new file mode 100644 index 000000000..d63f08b85 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/element_access/46148.cc @@ -0,0 +1,37 @@ +// { 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 +// . + +#include + +class moveable +{ +public: + moveable(moveable&&) { } + moveable() { } + + operator int() + { return 0; } +}; + +// libstdc++/46148 +int main() +{ + std::map the_map; + return the_map[true]; +} diff --git a/libstdc++-v3/testsuite/23_containers/map/init-list.cc b/libstdc++-v3/testsuite/23_containers/map/init-list.cc new file mode 100644 index 000000000..b70753a3f --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/init-list.cc @@ -0,0 +1,54 @@ +// 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 +// . +// + +// { dg-options "-std=gnu++0x" } + +#include +#include + +using namespace std; + +int test01() +{ + bool test __attribute__((unused)) = true; + + map m({ { 1, 1.0 }, { 2, 2.0 }, { 42, 237.0 } }); + VERIFY(m.size() == 3); + VERIFY(m[1] == 1.0); + VERIFY(m[2] == 2.0); + VERIFY(m[42] == 237.0); + + m = { {5, 55.0}, { 6, 66.0 } }; + VERIFY(m.size() == 2); + VERIFY(m[5] == 55.0); + VERIFY(m[6] == 66.0); + + m.insert({ { 7, 77.0 }, { 8, 88.0 } }); + VERIFY(m.size() == 4); + VERIFY(m[5] == 55.0); + VERIFY(m[6] == 66.0); + VERIFY(m[7] == 77.0); + VERIFY(m[8] == 88.0); + return test; +} + +int main() +{ + __gnu_test::set_memory_limits(); + test01(); +} diff --git a/libstdc++-v3/testsuite/23_containers/map/modifiers/erase/47628.cc b/libstdc++-v3/testsuite/23_containers/map/modifiers/erase/47628.cc new file mode 100644 index 000000000..6c61b9430 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/modifiers/erase/47628.cc @@ -0,0 +1,46 @@ +// Copyright (C) 2011 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 } + +#include + +struct Key +{ + Key() { } + + Key(const Key&) { } + + template + Key(const T&) + { } + + bool operator<(const Key&) const; +}; + +#ifndef __GXX_EXPERIMENTAL_CXX0X__ +// libstdc++/47628 +void f() +{ + typedef std::map Map; + Map m; + m.insert(Map::value_type()); + Map::iterator i = m.begin(); + m.erase(i); +} +#endif diff --git a/libstdc++-v3/testsuite/23_containers/map/modifiers/erase/51142.cc b/libstdc++-v3/testsuite/23_containers/map/modifiers/erase/51142.cc new file mode 100644 index 000000000..f50b7b7e9 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/modifiers/erase/51142.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2011 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 } +// { dg-options "-std=gnu++0x" } + +#include + +struct X +{ + template + X(T&) {} +}; + +bool operator<(const X&, const X&) { return false; } + +// LWG 2059. +void erasor(std::map& s, X x) +{ + std::map::iterator it = s.find(x); + if (it != s.end()) + s.erase(it); +} diff --git a/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/1.cc b/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/1.cc new file mode 100644 index 000000000..037e00a68 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/1.cc @@ -0,0 +1,67 @@ +// 2001-08-23 pme & Sylvain.Pion@sophia.inria.fr + +// 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.3.1.2, table 69 -- map::insert(p,t) + +#include +#include + +// { dg-do run } + +// libstdc++/3349 and +// http://gcc.gnu.org/ml/gcc-patches/2001-08/msg01375.html +void test01() +{ + bool test __attribute__((unused)) = true; + typedef std::map Map; + Map M; + Map::iterator hint; + + hint = M.insert(Map::value_type(7, 0)).first; + + M.insert(hint, Map::value_type(8, 1)); + M.insert(M.begin(), Map::value_type(9, 2)); + +#if 0 + // The tree's __rb_verify() member must be exposed in map<> before this + // will even compile. It's good test to see that "missing" entries are + // in fact present in the {map,tree}, but in the wrong place. + if (0) + { + Map::iterator i = M.begin(); + while (i != M.end()) { + std::cerr << '(' << i->first << ',' << i->second << ")\n"; + ++i; + } + std::cerr << "tree internal verify: " + << std::boolalpha << M.__rb_verify() << "\n"; + } +#endif + + VERIFY ( M.find(7) != M.end() ); + VERIFY ( M.find(8) != M.end() ); + VERIFY ( M.find(9) != M.end() ); +} + +int main() +{ + test01(); + return 0; +} + diff --git a/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/16813.cc b/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/16813.cc new file mode 100644 index 000000000..eab015380 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/16813.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2004, 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 + +// libstdc++/16813 +void test01() +{ + using __gnu_debug::map; + bool test __attribute__((unused)) = true; + + map m1, m2; + + m1[3] = 3.0f; + m1[11] = -67.0f; + + m2.insert(m1.begin(), m1.end()); + + VERIFY( m1 == m2 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/2.cc b/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/2.cc new file mode 100644 index 000000000..5de89de54 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/2.cc @@ -0,0 +1,74 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-11-10 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 +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::map Map; + typedef std::pair Pair; + + Map m; + VERIFY( m.empty()); + + std::pair p = m.insert(Pair(1, rvalstruct(3))); + VERIFY( p.second ); + VERIFY( m.size() == 1 ); + VERIFY( std::distance(m.begin(), m.end()) == 1 ); + VERIFY( p.first == m.begin() ); + VERIFY( p.first->first == 1 ); + VERIFY( (p.first->second).val == 3 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::map Map; + typedef std::pair Pair; + + Map m; + VERIFY( m.empty() ); + + std::pair p1 = m.insert(Pair(2, rvalstruct(3))); + std::pair p2 = m.insert(Pair(2, rvalstruct(7))); + + VERIFY( p1.second ); + VERIFY( !p2.second ); + VERIFY( m.size() == 1 ); + VERIFY( p1.first == p2.first ); + VERIFY( p1.first->first == 2 ); + VERIFY( (p2.first->second).val == 3 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/3.cc b/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/3.cc new file mode 100644 index 000000000..e5827bfb3 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/3.cc @@ -0,0 +1,77 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-11-10 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 +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::map Map; + typedef std::pair Pair; + + Map m; + VERIFY( m.empty()); + + std::pair p = m.insert(Pair(rvalstruct(1), + rvalstruct(3))); + VERIFY( p.second ); + VERIFY( m.size() == 1 ); + VERIFY( std::distance(m.begin(), m.end()) == 1 ); + VERIFY( p.first == m.begin() ); + VERIFY( (p.first->first).val == 1 ); + VERIFY( (p.first->second).val == 3 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::map Map; + typedef std::pair Pair; + + Map m; + VERIFY( m.empty() ); + + std::pair p1 = m.insert(Pair(rvalstruct(2), + rvalstruct(3))); + std::pair p2 = m.insert(Pair(rvalstruct(2), + rvalstruct(7))); + + VERIFY( p1.second ); + VERIFY( !p2.second ); + VERIFY( m.size() == 1 ); + VERIFY( p1.first == p2.first ); + VERIFY( (p1.first->first).val == 2 ); + VERIFY( (p2.first->second).val == 3 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/4.cc b/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/4.cc new file mode 100644 index 000000000..28eba6472 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/4.cc @@ -0,0 +1,70 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-11-10 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 +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::map Map; + typedef std::pair Pair; + + Map m; + VERIFY( m.empty()); + + Map::iterator p = m.insert(m.begin(), Pair(1, rvalstruct(3))); + VERIFY( m.size() == 1 ); + VERIFY( std::distance(m.begin(), m.end()) == 1 ); + VERIFY( p == m.begin() ); + VERIFY( p->first == 1 ); + VERIFY( (p->second).val == 3 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::map Map; + typedef std::pair Pair; + + Map m; + VERIFY( m.empty() ); + + Map::iterator p1 = m.insert(m.begin(), Pair(2, rvalstruct(3))); + Map::iterator p2 = m.insert(p1, Pair(2, rvalstruct(7))); + VERIFY( m.size() == 1 ); + VERIFY( p1 == p2 ); + VERIFY( p1->first == 2 ); + VERIFY( (p2->second).val == 3 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/5.cc b/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/5.cc new file mode 100644 index 000000000..3dc153b85 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/5.cc @@ -0,0 +1,73 @@ +// { dg-options "-std=gnu++0x" } + +// 2010-11-10 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 +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::map Map; + typedef std::pair Pair; + + Map m; + VERIFY( m.empty()); + + Map::iterator p = m.insert(m.begin(), Pair(rvalstruct(1), + rvalstruct(3))); + VERIFY( m.size() == 1 ); + VERIFY( std::distance(m.begin(), m.end()) == 1 ); + VERIFY( p == m.begin() ); + VERIFY( (p->first).val == 1 ); + VERIFY( (p->second).val == 3 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + using __gnu_test::rvalstruct; + + typedef std::map Map; + typedef std::pair Pair; + + Map m; + VERIFY( m.empty() ); + + Map::iterator p1 = m.insert(m.begin(), Pair(rvalstruct(2), + rvalstruct(3))); + Map::iterator p2 = m.insert(p1, Pair(rvalstruct(2), + rvalstruct(7))); + VERIFY( m.size() == 1 ); + VERIFY( p1 == p2 ); + VERIFY( (p1->first).val == 2 ); + VERIFY( (p2->second).val == 3 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/map/modifiers/swap/1.cc b/libstdc++-v3/testsuite/23_containers/map/modifiers/swap/1.cc new file mode 100644 index 000000000..b5fe2e374 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/modifiers/swap/1.cc @@ -0,0 +1,65 @@ +// Copyright (C) 2004, 2005, 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; }; + +// T must be LessThanComparable to pass concept-checks +bool operator<(T l, T r) { return l.i < r.i; } + +int swap_calls; + +namespace std +{ + template<> + void + map::swap(map&) + { ++swap_calls; } +} + +// Should use map specialization for swap. +void test01() +{ + bool test __attribute__((unused)) = true; + std::map A; + std::map B; + swap_calls = 0; + std::swap(A, B); + VERIFY(1 == swap_calls); +} + +// Should use map specialization for swap. +void test02() +{ + bool test __attribute__((unused)) = true; + using namespace std; + map A; + map B; + swap_calls = 0; + swap(A, B); + VERIFY(1 == swap_calls); +} + +// See c++/13658 for background info. +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/map/modifiers/swap/2.cc b/libstdc++-v3/testsuite/23_containers/map/modifiers/swap/2.cc new file mode 100644 index 000000000..741276b83 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/modifiers/swap/2.cc @@ -0,0 +1,146 @@ +// 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.3.1 map::swap + +#include +#include +#include + +// uneq_allocator as a non-empty allocator. +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef pair my_pair; + typedef __gnu_test::uneq_allocator my_alloc; + typedef map, my_alloc> my_map; + + 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); + + map map01_ref; + for (size_t i = 0; i < N1; ++i) + map01_ref.insert(my_pair(title01[i], i)); + map map02_ref; + for (size_t i = 0; i < N2; ++i) + map02_ref.insert(my_pair(title02[i], i)); + map map03_ref; + for (size_t i = 0; i < N3; ++i) + map03_ref.insert(my_pair(title03[i], i)); + map map04_ref; + for (size_t i = 0; i < N4; ++i) + map04_ref.insert(my_pair(title04[i], i)); + + my_map::size_type size01, size02; + + my_alloc alloc01(1); + + my_map map01(less(), alloc01); + size01 = map01.size(); + my_map map02(less(), alloc01); + size02 = map02.size(); + + map01.swap(map02); + VERIFY( map01.size() == size02 ); + VERIFY( map01.empty() ); + VERIFY( map02.size() == size01 ); + VERIFY( map02.empty() ); + + my_map map03(less(), alloc01); + size01 = map03.size(); + my_map map04(map02_ref.begin(), map02_ref.end(), less(), alloc01); + size02 = map04.size(); + + map03.swap(map04); + VERIFY( map03.size() == size02 ); + VERIFY( equal(map03.begin(), map03.end(), map02_ref.begin()) ); + VERIFY( map04.size() == size01 ); + VERIFY( map04.empty() ); + + my_map map05(map01_ref.begin(), map01_ref.end(), less(), alloc01); + size01 = map05.size(); + my_map map06(map02_ref.begin(), map02_ref.end(), less(), alloc01); + size02 = map06.size(); + + map05.swap(map06); + VERIFY( map05.size() == size02 ); + VERIFY( equal(map05.begin(), map05.end(), map02_ref.begin()) ); + VERIFY( map06.size() == size01 ); + VERIFY( equal(map06.begin(), map06.end(), map01_ref.begin()) ); + + my_map map07(map01_ref.begin(), map01_ref.end(), less(), alloc01); + size01 = map07.size(); + my_map map08(map03_ref.begin(), map03_ref.end(), less(), alloc01); + size02 = map08.size(); + + map07.swap(map08); + VERIFY( map07.size() == size02 ); + VERIFY( equal(map07.begin(), map07.end(), map03_ref.begin()) ); + VERIFY( map08.size() == size01 ); + VERIFY( equal(map08.begin(), map08.end(), map01_ref.begin()) ); + + my_map map09(map03_ref.begin(), map03_ref.end(), less(), alloc01); + size01 = map09.size(); + my_map map10(map04_ref.begin(), map04_ref.end(), less(), alloc01); + size02 = map10.size(); + + map09.swap(map10); + VERIFY( map09.size() == size02 ); + VERIFY( equal(map09.begin(), map09.end(), map04_ref.begin()) ); + VERIFY( map10.size() == size01 ); + VERIFY( equal(map10.begin(), map10.end(), map03_ref.begin()) ); + + my_map map11(map04_ref.begin(), map04_ref.end(), less(), alloc01); + size01 = map11.size(); + my_map map12(map01_ref.begin(), map01_ref.end(), less(), alloc01); + size02 = map12.size(); + + map11.swap(map12); + VERIFY( map11.size() == size02 ); + VERIFY( equal(map11.begin(), map11.end(), map01_ref.begin()) ); + VERIFY( map12.size() == size01 ); + VERIFY( equal(map12.begin(), map12.end(), map04_ref.begin()) ); + + my_map map13(map03_ref.begin(), map03_ref.end(), less(), alloc01); + size01 = map13.size(); + my_map map14(map03_ref.begin(), map03_ref.end(), less(), alloc01); + size02 = map14.size(); + + map13.swap(map14); + VERIFY( map13.size() == size02 ); + VERIFY( equal(map13.begin(), map13.end(), map03_ref.begin()) ); + VERIFY( map14.size() == size01 ); + VERIFY( equal(map14.begin(), map14.end(), map03_ref.begin()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/map/modifiers/swap/3.cc b/libstdc++-v3/testsuite/23_containers/map/modifiers/swap/3.cc new file mode 100644 index 000000000..68980e463 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/modifiers/swap/3.cc @@ -0,0 +1,175 @@ +// 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.3.1 map::swap + +#include +#include +#include + +// uneq_allocator, two different personalities. +void +test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + typedef pair my_pair; + typedef __gnu_test::uneq_allocator my_alloc; + typedef map, my_alloc> my_map; + + 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); + + map map01_ref; + for (size_t i = 0; i < N1; ++i) + map01_ref.insert(my_pair(title01[i], i)); + map map02_ref; + for (size_t i = 0; i < N2; ++i) + map02_ref.insert(my_pair(title02[i], i)); + map map03_ref; + for (size_t i = 0; i < N3; ++i) + map03_ref.insert(my_pair(title03[i], i)); + map map04_ref; + for (size_t i = 0; i < N4; ++i) + map04_ref.insert(my_pair(title04[i], i)); + + my_map::size_type size01, size02; + + my_alloc alloc01(1), alloc02(2); + int personality01, personality02; + + my_map map01(less(), alloc01); + size01 = map01.size(); + personality01 = map01.get_allocator().get_personality(); + my_map map02(less(), alloc02); + size02 = map02.size(); + personality02 = map02.get_allocator().get_personality(); + + map01.swap(map02); + VERIFY( map01.size() == size02 ); + VERIFY( map01.empty() ); + VERIFY( map02.size() == size01 ); + VERIFY( map02.empty() ); + VERIFY( map01.get_allocator().get_personality() == personality02 ); + VERIFY( map02.get_allocator().get_personality() == personality01 ); + + my_map map03(less(), alloc02); + size01 = map03.size(); + personality01 = map03.get_allocator().get_personality(); + my_map map04(map02_ref.begin(), map02_ref.end(), less(), alloc01); + size02 = map04.size(); + personality02 = map04.get_allocator().get_personality(); + + map03.swap(map04); + VERIFY( map03.size() == size02 ); + VERIFY( equal(map03.begin(), map03.end(), map02_ref.begin()) ); + VERIFY( map04.size() == size01 ); + VERIFY( map04.empty() ); + VERIFY( map03.get_allocator().get_personality() == personality02 ); + VERIFY( map04.get_allocator().get_personality() == personality01 ); + + my_map map05(map01_ref.begin(), map01_ref.end(), less(), alloc01); + size01 = map05.size(); + personality01 = map05.get_allocator().get_personality(); + my_map map06(map02_ref.begin(), map02_ref.end(), less(), alloc02); + size02 = map06.size(); + personality02 = map06.get_allocator().get_personality(); + + map05.swap(map06); + VERIFY( map05.size() == size02 ); + VERIFY( equal(map05.begin(), map05.end(), map02_ref.begin()) ); + VERIFY( map06.size() == size01 ); + VERIFY( equal(map06.begin(), map06.end(), map01_ref.begin()) ); + VERIFY( map05.get_allocator().get_personality() == personality02 ); + VERIFY( map06.get_allocator().get_personality() == personality01 ); + + my_map map07(map01_ref.begin(), map01_ref.end(), less(), alloc02); + size01 = map07.size(); + personality01 = map07.get_allocator().get_personality(); + my_map map08(map03_ref.begin(), map03_ref.end(), less(), alloc01); + size02 = map08.size(); + personality02 = map08.get_allocator().get_personality(); + + map07.swap(map08); + VERIFY( map07.size() == size02 ); + VERIFY( equal(map07.begin(), map07.end(), map03_ref.begin()) ); + VERIFY( map08.size() == size01 ); + VERIFY( equal(map08.begin(), map08.end(), map01_ref.begin()) ); + VERIFY( map07.get_allocator().get_personality() == personality02 ); + VERIFY( map08.get_allocator().get_personality() == personality01 ); + + my_map map09(map03_ref.begin(), map03_ref.end(), less(), alloc01); + size01 = map09.size(); + personality01 = map09.get_allocator().get_personality(); + my_map map10(map04_ref.begin(), map04_ref.end(), less(), alloc02); + size02 = map10.size(); + personality02 = map10.get_allocator().get_personality(); + + map09.swap(map10); + VERIFY( map09.size() == size02 ); + VERIFY( equal(map09.begin(), map09.end(), map04_ref.begin()) ); + VERIFY( map10.size() == size01 ); + VERIFY( equal(map10.begin(), map10.end(), map03_ref.begin()) ); + VERIFY( map09.get_allocator().get_personality() == personality02 ); + VERIFY( map10.get_allocator().get_personality() == personality01 ); + + my_map map11(map04_ref.begin(), map04_ref.end(), less(), alloc02); + size01 = map11.size(); + personality01 = map11.get_allocator().get_personality(); + my_map map12(map01_ref.begin(), map01_ref.end(), less(), alloc01); + size02 = map12.size(); + personality02 = map12.get_allocator().get_personality(); + + map11.swap(map12); + VERIFY( map11.size() == size02 ); + VERIFY( equal(map11.begin(), map11.end(), map01_ref.begin()) ); + VERIFY( map12.size() == size01 ); + VERIFY( equal(map12.begin(), map12.end(), map04_ref.begin()) ); + VERIFY( map11.get_allocator().get_personality() == personality02 ); + VERIFY( map12.get_allocator().get_personality() == personality01 ); + + my_map map13(map03_ref.begin(), map03_ref.end(), less(), alloc01); + size01 = map13.size(); + personality01 = map13.get_allocator().get_personality(); + my_map map14(map03_ref.begin(), map03_ref.end(), less(), alloc02); + size02 = map14.size(); + personality02 = map14.get_allocator().get_personality(); + + map13.swap(map14); + VERIFY( map13.size() == size02 ); + VERIFY( equal(map13.begin(), map13.end(), map03_ref.begin()) ); + VERIFY( map14.size() == size01 ); + VERIFY( equal(map14.begin(), map14.end(), map03_ref.begin()) ); + VERIFY( map13.get_allocator().get_personality() == personality02 ); + VERIFY( map14.get_allocator().get_personality() == personality01 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/map/operations/1.cc b/libstdc++-v3/testsuite/23_containers/map/operations/1.cc new file mode 100644 index 000000000..5ff32f6b0 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/operations/1.cc @@ -0,0 +1,127 @@ +// 2006-11-25 Paolo Carlini + +// Copyright (C) 2006, 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 + +// A few tests for equal_range, in the occasion of libstdc++/29385. +void test01() +{ + bool test __attribute__((unused)) = true; + using namespace std; + + map m0; + typedef map::iterator iterator; + typedef pair insert_return_type; + pair pp0; + typedef map::value_type value_type; + + pp0 = m0.equal_range(1); + VERIFY( m0.count(1) == 0 ); + VERIFY( pp0.first == m0.end() ); + VERIFY( pp0.second == m0.end() ); + + insert_return_type irt0 = m0.insert(value_type(1, 1)); + insert_return_type irt1 = m0.insert(value_type(2, 2)); + insert_return_type irt2 = m0.insert(value_type(3, 3)); + + pp0 = m0.equal_range(2); + VERIFY( m0.count(2) == 1 ); + VERIFY( *pp0.first == value_type(2, 2) ); + VERIFY( *pp0.second == value_type(3, 3) ); + VERIFY( pp0.first == irt1.first ); + VERIFY( --pp0.first == irt0.first ); + VERIFY( pp0.second == irt2.first ); + + m0.insert(value_type(3, 4)); + insert_return_type irt3 = m0.insert(value_type(3, 5)); + insert_return_type irt4 = m0.insert(value_type(4, 6)); + + pp0 = m0.equal_range(3); + VERIFY( m0.count(3) == 1 ); + VERIFY( *pp0.first == value_type(3, 3) ); + VERIFY( *pp0.second == value_type(4, 6) ); + VERIFY( pp0.first == irt2.first ); + VERIFY( --pp0.first == irt1.first ); + VERIFY( pp0.second == irt4.first ); + + insert_return_type irt5 = m0.insert(value_type(0, 7)); + m0.insert(value_type(1, 8)); + m0.insert(value_type(1, 9)); + m0.insert(value_type(1, 10)); + + pp0 = m0.equal_range(1); + VERIFY( m0.count(1) == 1 ); + VERIFY( *pp0.first == value_type(1, 1) ); + VERIFY( *pp0.second == value_type(2, 2) ); + VERIFY( pp0.first == irt0.first ); + VERIFY( --pp0.first == irt5.first ); + VERIFY( pp0.second == irt1.first ); + + insert_return_type irt6 = m0.insert(value_type(5, 11)); + m0.insert(value_type(5, 12)); + m0.insert(value_type(5, 13)); + + pp0 = m0.equal_range(5); + VERIFY( m0.count(5) == 1 ); + VERIFY( *pp0.first == value_type(5, 11) ); + VERIFY( pp0.first == irt6.first ); + VERIFY( --pp0.first == irt4.first ); + VERIFY( pp0.second == m0.end() ); + + m0.insert(value_type(4, 14)); + m0.insert(value_type(4, 15)); + m0.insert(value_type(4, 16)); + + pp0 = m0.equal_range(4); + VERIFY( m0.count(4) == 1 ); + VERIFY( *pp0.first == value_type(4, 6) ); + VERIFY( *pp0.second == value_type(5, 11) ); + VERIFY( pp0.first == irt4.first ); + VERIFY( --pp0.first == irt3.first ); + VERIFY( pp0.second == irt6.first ); + + m0.insert(value_type(0, 17)); + insert_return_type irt7 = m0.insert(value_type(0, 18)); + m0.insert(value_type(1, 19)); + + pp0 = m0.equal_range(0); + VERIFY( m0.count(0) == 1 ); + VERIFY( *pp0.first == value_type(0, 7) ); + VERIFY( *pp0.second == value_type(1, 1) ); + VERIFY( pp0.first == irt5.first ); + VERIFY( pp0.first == m0.begin() ); + VERIFY( pp0.second == irt0.first ); + + pp0 = m0.equal_range(1); + VERIFY( m0.count(1) == 1 ); + VERIFY( *pp0.first == value_type(1, 1) ); + VERIFY( *pp0.second == value_type(2, 2) ); + VERIFY( pp0.first == irt0.first ); + VERIFY( --pp0.first == irt7.first); + VERIFY( pp0.second == irt1.first ); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/map/operations/31440.cc b/libstdc++-v3/testsuite/23_containers/map/operations/31440.cc new file mode 100644 index 000000000..a28a8d62f --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/operations/31440.cc @@ -0,0 +1,52 @@ +// { dg-do compile } + +// 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 + +// libstdc++/31440 +struct DagNode +{ }; + +class MemoTable +{ +public: + void memoRewrite(); + +private: + struct dagNodeLt; + class MemoMap; + + MemoMap* memoMap; +}; + +struct MemoTable::dagNodeLt +{ + bool operator()(const DagNode*, const DagNode*); +}; + +class MemoTable::MemoMap +: public std::map +{ }; + +void +MemoTable::memoRewrite() +{ + memoMap->find(0); +} diff --git a/libstdc++-v3/testsuite/23_containers/map/operators/1.cc b/libstdc++-v3/testsuite/23_containers/map/operators/1.cc new file mode 100644 index 000000000..d58f17b6f --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/operators/1.cc @@ -0,0 +1,49 @@ +// 2000-09-07 bgarcia@laurelnetworks.com + +// Copyright (C) 2000, 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.3.4 template class multiset + +#include +#include +#include + +// libstdc++/737 +// http://gcc.gnu.org/ml/libstdc++/2000-11/msg00093.html +void test02() +{ + typedef std::map MapInt; + + MapInt m; + + for (unsigned i = 0; i < 10; ++i) + m.insert(MapInt::value_type(i,i)); + + for (MapInt::const_iterator i = m.begin(); i != m.end(); ++i) + std::cerr << i->second << ' '; + + for (MapInt::const_iterator i = m.begin(); m.end() != i; ++i) + std::cerr << i->second << ' '; +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/map/operators/1_neg.cc b/libstdc++-v3/testsuite/23_containers/map/operators/1_neg.cc new file mode 100644 index 000000000..c5fd9cd0d --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/operators/1_neg.cc @@ -0,0 +1,45 @@ +// { dg-do compile } + +// Copyright (C) 2000, 2001, 2002, 2003, 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 +// . + +// 23.3.4 template class multiset negative tests +// 2000-09-07 bgarcia@laurelnetworks.com + +#include +#include + +// libstdc++/86: map & set iterator comparisons are not type-safe +void test01() +{ + bool test __attribute__((unused)) = true; + std::map mapByIndex; + std::map mapByName; + + mapByIndex.insert(std::pair(0, 1)); + mapByIndex.insert(std::pair(6, 5)); + + std::map::iterator itr(mapByIndex.begin()); + + // NB: notice, it's not mapByIndex!! + test &= itr != mapByName.end(); // { dg-error "no" } + test &= itr == mapByName.end(); // { dg-error "no" } +} + +// { dg-excess-errors "" } diff --git a/libstdc++-v3/testsuite/23_containers/map/pthread6.cc b/libstdc++-v3/testsuite/23_containers/map/pthread6.cc new file mode 100644 index 000000000..38c20ed64 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/pthread6.cc @@ -0,0 +1,87 @@ +// 2002-01-23 Loren J. Rittle +// Adpated from libstdc++/5444 submitted by markus.breuer@materna.de +// +// 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 + +const int max_thread_count = 8; +const int loops = 100000; + +const char* my_default = "Hallo Welt!"; + +const std::size_t upper_limit = 2500; +const std::size_t lower_limit = 1000; + +typedef char charT; + +typedef std::string String; + +typedef String MyType; + +void* +thread_main (void*) +{ + typedef std::map Map; + typedef Map::value_type Value_Pair; + Map myMap; + + for (int loop = 0; loop < loops; loop++) + { + String& str = myMap[loop]; + str.append (my_default); + myMap.insert (Value_Pair (loop, str)); + + if (myMap.size () > upper_limit) + { + while (myMap.size () > lower_limit) + { + Map::iterator it = myMap.begin (); + myMap.erase (it); + } + } + } + + return 0; +} + +int +main (void) +{ + pthread_t tid[max_thread_count]; + +#if defined(__sun) && defined(__svr4__) && _XOPEN_VERSION >= 500 + pthread_setconcurrency (max_thread_count); +#endif + + for (int i = 0; i < max_thread_count; i++) + pthread_create (&tid[i], 0, thread_main, 0); + + for (int i = 0; i < max_thread_count; i++) + pthread_join (tid[i], 0); + + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/map/range_access.cc b/libstdc++-v3/testsuite/23_containers/map/range_access.cc new file mode 100644 index 000000000..1e4e3c187 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/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::map m{{1, 1.0}, {2, 2.0}, {3, 3.0}}; + std::begin(m); + std::end(m); +} diff --git a/libstdc++-v3/testsuite/23_containers/map/requirements/citerators.cc b/libstdc++-v3/testsuite/23_containers/map/requirements/citerators.cc new file mode 100644 index 000000000..17db1e7da --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/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::map test_type; + __gnu_test::citerator test; + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/map/requirements/exception/basic.cc b/libstdc++-v3/testsuite/23_containers/map/requirements/exception/basic.cc new file mode 100644 index 000000000..cb5e2daed --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/requirements/exception/basic.cc @@ -0,0 +1,43 @@ +// { 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 key_type; + typedef std::pair value_type; + typedef __gnu_cxx::throw_allocator_limit allocator_type; + typedef std::less compare_type; + typedef std::map 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/map/requirements/exception/generation_prohibited.cc b/libstdc++-v3/testsuite/23_containers/map/requirements/exception/generation_prohibited.cc new file mode 100644 index 000000000..7d67cd7fc --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/requirements/exception/generation_prohibited.cc @@ -0,0 +1,36 @@ +// { 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 key_type; + typedef std::pair value_type; + typedef __gnu_cxx::throw_allocator_random allocator_type; + typedef std::less compare_type; + typedef std::map test_type; + __gnu_test::generation_prohibited test; + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/map/requirements/exception/propagation_consistent.cc b/libstdc++-v3/testsuite/23_containers/map/requirements/exception/propagation_consistent.cc new file mode 100644 index 000000000..eee010bd0 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/requirements/exception/propagation_consistent.cc @@ -0,0 +1,36 @@ +// { 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 key_type; + typedef std::pair value_type; + typedef __gnu_cxx::throw_allocator_limit allocator_type; + typedef std::less compare_type; + typedef std::map test_type; + __gnu_test::propagation_consistent test; + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/1.cc new file mode 100644 index 000000000..792a8b4bc --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/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::map; diff --git a/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/1_c++0x.cc b/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/1_c++0x.cc new file mode 100644 index 000000000..3b35d54b0 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/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::map; diff --git a/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/2.cc new file mode 100644 index 000000000..0a620e6ff --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/2.cc @@ -0,0 +1,29 @@ +// 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 +#include + +// { dg-do compile } + +// N.B. We cannot instantiate with T == NonDefaultConstructible +// because of 23.3.1.2. +template class std::map<__gnu_test::NonDefaultConstructible, double>; diff --git a/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/3.cc b/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/3.cc new file mode 100644 index 000000000..d0ece3db1 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/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::map, std::allocator >; diff --git a/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/4.cc b/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/4.cc new file mode 100644 index 000000000..2a3700add --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/requirements/explicit_instantiation/4.cc @@ -0,0 +1,30 @@ +// 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::map<__gnu_test::OverloadedAddress, + __gnu_test::OverloadedAddress>; diff --git a/libstdc++-v3/testsuite/23_containers/map/requirements/partial_specialization/1.cc b/libstdc++-v3/testsuite/23_containers/map/requirements/partial_specialization/1.cc new file mode 100644 index 000000000..8ede16a59 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/requirements/partial_specialization/1.cc @@ -0,0 +1,33 @@ +// Copyright (C) 1999, 2000, 2001, 2002, 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 +// . + + +// This file tests user specialization of library containers + +#include +#include + +// { dg-do compile } + +struct user_type {}; + +namespace std +{ + template + class map {}; +} diff --git a/libstdc++-v3/testsuite/23_containers/map/requirements/typedefs.cc b/libstdc++-v3/testsuite/23_containers/map/requirements/typedefs.cc new file mode 100644 index 000000000..1325cc607 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/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