aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite
diff options
context:
space:
mode:
authorFrançois Dumont <francois.cppdevs@free.fr>2011-07-19 21:39:45 +0200
committerFrançois Dumont <fdumont@gcc.gnu.org>2011-07-19 19:39:45 +0000
commit77e0bf4e0799ef5080bb6b6f0e26a661417fe7fb (patch)
tree926f16c5943ea256d7196a0439c3b6482434002d /libstdc++-v3/testsuite
parent78767fd9cf5581827603c154235fd36ecf075e31 (diff)
downloadgcc-77e0bf4e0799ef5080bb6b6f0e26a661417fe7fb.zip
gcc-77e0bf4e0799ef5080bb6b6f0e26a661417fe7fb.tar.gz
gcc-77e0bf4e0799ef5080bb6b6f0e26a661417fe7fb.tar.bz2
safe_unordered_base.h, [...]: New, support for unordered sequence safe local iterators.
2011-07-19 François Dumont <francois.cppdevs@free.fr> * include/debug/safe_unordered_base.h, safe_unordered_sequence.h, safe_unordered_sequence.tcc, safe_local_iterator.h, safe_local_iterator.tcc: New, support for unordered sequence safe local iterators. * include/Makefile.am: Add previous files. * include/Makefile.in: Regenerate. * include/debug/unordered_map, unordered_set: Implement _Safe_unordered_sequence and expose _Safe_local_iterator. * include/debug/safe_iterator.h, safe_iterator.tcc: Refactor _Safe_iterator::_M_get_distance static method to expose it as __get_distance function and use it in _Safe_local_iterator type. * include/debug/formatter.h: Add __msg_local_iter_compare_bad _Debug_msg_id enum entry to notify invalid comparison between local iterators from different buckets. Add _Parameter constructor from _Safe_local_iterator. * include/debug/functions.h: Add __valid_range overload for _Safe_local_iterator. * src/debug.cc: Add _Safe_unordered_sequence_base and _Safe_local_iterator_base methods implementations. * config/abi/pre/gnu.ver: Add export of some _Safe_unordered_sequence_base and _Safe_local_iterator_base methods. * testsuite/util/debug/checks.h: Add use_invalid_iterator function to simulate use of a singular iterator. * testsuite/util/debug/unordered_checks.h: New, several functions to simulate classic invalid usage of unordered sequence local iterators. * testsuite/23_containers/unordered_map/debug/ use_erased_local_iterator_neg.cc, invalid_local_iterator_range_neg.cc, use_invalid_local_iterator_neg.cc, use_invalid_iterator_neg.cc, invalid_local_iterator_compare_neg.cc: New. * testsuite/23_containers/unordered_multimap/debug/ use_erased_local_iterator_neg.cc, invalid_local_iterator_range_neg.cc, use_invalid_local_iterator_neg.cc, use_invalid_iterator_neg.cc, invalid_local_iterator_compare_neg.cc: New. * testsuite/23_containers/unordered_set/debug/ use_erased_local_iterator_neg.cc, invalid_local_iterator_range_neg.cc, use_invalid_local_iterator_neg.cc, use_invalid_iterator_neg.cc, invalid_local_iterator_compare_neg.cc: New. * testsuite/23_containers/unordered_multiset/debug/ use_erased_local_iterator_neg.cc, invalid_local_iterator_range_neg.cc, use_invalid_local_iterator_neg.cc, use_invalid_iterator_neg.cc, invalid_local_iterator_compare_neg.cc: New. From-SVN: r176487
Diffstat (limited to 'libstdc++-v3/testsuite')
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_compare_neg.cc34
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_range_neg.cc34
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_erased_local_iterator_neg.cc34
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_invalid_iterator_neg.cc34
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_invalid_local_iterator_neg.cc34
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_compare_neg.cc35
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_range_neg.cc35
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_erased_local_iterator_neg.cc35
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_invalid_iterator_neg.cc35
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_invalid_local_iterator_neg.cc35
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_compare_neg.cc34
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_range_neg.cc34
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_erased_local_iterator_neg.cc34
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_invalid_iterator_neg.cc34
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_invalid_local_iterator_neg.cc34
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_compare_neg.cc34
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_range_neg.cc34
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_erased_local_iterator_neg.cc34
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_invalid_iterator_neg.cc34
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_invalid_local_iterator_neg.cc34
-rw-r--r--libstdc++-v3/testsuite/util/debug/checks.h44
-rw-r--r--libstdc++-v3/testsuite/util/debug/unordered_checks.h190
22 files changed, 907 insertions, 12 deletions
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_compare_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_compare_neg.cc
new file mode 100644
index 0000000..72611d3
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_compare_neg.cc
@@ -0,0 +1,34 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+//
+// { dg-require-debug-mode "" }
+// { dg-options "-std=gnu++0x" }
+// { dg-do run { xfail *-*-* } }
+
+#include <unordered_map>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+ __gnu_test::invalid_local_iterator_compare<std::unordered_map<int, int>>();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_range_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_range_neg.cc
new file mode 100644
index 0000000..1e45e62
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/invalid_local_iterator_range_neg.cc
@@ -0,0 +1,34 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+//
+// { dg-require-debug-mode "" }
+// { dg-options "-std=gnu++0x" }
+// { dg-do run { xfail *-*-* } }
+
+#include <unordered_map>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+ __gnu_test::invalid_local_iterator_range<std::unordered_map<int, int>>();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_erased_local_iterator_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_erased_local_iterator_neg.cc
new file mode 100644
index 0000000..ce70ef2
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_erased_local_iterator_neg.cc
@@ -0,0 +1,34 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+//
+// { dg-require-debug-mode "" }
+// { dg-options "-std=gnu++0x" }
+// { dg-do run { xfail *-*-* } }
+
+#include <unordered_map>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+ __gnu_test::use_erased_local_iterator<std::unordered_map<int, int>>();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_invalid_iterator_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_invalid_iterator_neg.cc
new file mode 100644
index 0000000..3d9f219
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_invalid_iterator_neg.cc
@@ -0,0 +1,34 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+//
+// { dg-require-debug-mode "" }
+// { dg-options "-std=gnu++0x" }
+// { dg-do run { xfail *-*-* } }
+
+#include <unordered_map>
+#include <debug/checks.h>
+
+void test01()
+{
+ __gnu_test::use_invalid_iterator<std::unordered_map<int, int>>();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_invalid_local_iterator_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_invalid_local_iterator_neg.cc
new file mode 100644
index 0000000..70cda47
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_map/debug/use_invalid_local_iterator_neg.cc
@@ -0,0 +1,34 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+//
+// { dg-require-debug-mode "" }
+// { dg-options "-std=gnu++0x" }
+// { dg-do run { xfail *-*-* } }
+
+#include <unordered_map>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+ __gnu_test::use_invalid_local_iterator<std::unordered_map<int, int>>();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_compare_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_compare_neg.cc
new file mode 100644
index 0000000..4ee44a4
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_compare_neg.cc
@@ -0,0 +1,35 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+//
+// { dg-require-debug-mode "" }
+// { dg-options "-std=gnu++0x" }
+// { dg-do run { xfail *-*-* } }
+
+#include <unordered_map>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+ typedef std::unordered_multimap<int, int> cont_type;
+ __gnu_test::invalid_local_iterator_compare<cont_type>();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_range_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_range_neg.cc
new file mode 100644
index 0000000..d70225e
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/invalid_local_iterator_range_neg.cc
@@ -0,0 +1,35 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+//
+// { dg-require-debug-mode "" }
+// { dg-options "-std=gnu++0x" }
+// { dg-do run { xfail *-*-* } }
+
+#include <unordered_map>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+ typedef std::unordered_multimap<int, int> cont_type;
+ __gnu_test::invalid_local_iterator_range<cont_type>();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_erased_local_iterator_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_erased_local_iterator_neg.cc
new file mode 100644
index 0000000..2d404e6
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_erased_local_iterator_neg.cc
@@ -0,0 +1,35 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+//
+// { dg-require-debug-mode "" }
+// { dg-options "-std=gnu++0x" }
+// { dg-do run { xfail *-*-* } }
+
+#include <unordered_map>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+ typedef std::unordered_multimap<int, int> cont_type;
+ __gnu_test::use_erased_local_iterator<cont_type>();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_invalid_iterator_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_invalid_iterator_neg.cc
new file mode 100644
index 0000000..6f7c250
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_invalid_iterator_neg.cc
@@ -0,0 +1,35 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+//
+// { dg-require-debug-mode "" }
+// { dg-options "-std=gnu++0x" }
+// { dg-do run { xfail *-*-* } }
+
+#include <unordered_map>
+#include <debug/checks.h>
+
+void test01()
+{
+ typedef std::unordered_multimap<int, int> cont_type;
+ __gnu_test::use_invalid_iterator<cont_type>();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_invalid_local_iterator_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_invalid_local_iterator_neg.cc
new file mode 100644
index 0000000..e47838f
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/debug/use_invalid_local_iterator_neg.cc
@@ -0,0 +1,35 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+//
+// { dg-require-debug-mode "" }
+// { dg-options "-std=gnu++0x" }
+// { dg-do run { xfail *-*-* } }
+
+#include <unordered_map>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+ typedef std::unordered_multimap<int, int> cont_type;
+ __gnu_test::use_invalid_local_iterator<cont_type>();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_compare_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_compare_neg.cc
new file mode 100644
index 0000000..03fa0b6
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_compare_neg.cc
@@ -0,0 +1,34 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+//
+// { dg-require-debug-mode "" }
+// { dg-options "-std=gnu++0x" }
+// { dg-do run { xfail *-*-* } }
+
+#include <unordered_set>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+ __gnu_test::invalid_local_iterator_compare<std::unordered_multiset<int>>();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_range_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_range_neg.cc
new file mode 100644
index 0000000..f2f2571
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/invalid_local_iterator_range_neg.cc
@@ -0,0 +1,34 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+//
+// { dg-require-debug-mode "" }
+// { dg-options "-std=gnu++0x" }
+// { dg-do run { xfail *-*-* } }
+
+#include <unordered_set>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+ __gnu_test::invalid_local_iterator_range<std::unordered_multiset<int>>();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_erased_local_iterator_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_erased_local_iterator_neg.cc
new file mode 100644
index 0000000..08b4e86
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_erased_local_iterator_neg.cc
@@ -0,0 +1,34 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+//
+// { dg-require-debug-mode "" }
+// { dg-options "-std=gnu++0x" }
+// { dg-do run { xfail *-*-* } }
+
+#include <unordered_set>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+ __gnu_test::use_erased_local_iterator<std::unordered_multiset<int>>();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_invalid_iterator_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_invalid_iterator_neg.cc
new file mode 100644
index 0000000..b4202f9
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_invalid_iterator_neg.cc
@@ -0,0 +1,34 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+//
+// { dg-require-debug-mode "" }
+// { dg-options "-std=gnu++0x" }
+// { dg-do run { xfail *-*-* } }
+
+#include <unordered_set>
+#include <debug/checks.h>
+
+void test01()
+{
+ __gnu_test::use_invalid_iterator<std::unordered_multiset<int>>();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_invalid_local_iterator_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_invalid_local_iterator_neg.cc
new file mode 100644
index 0000000..9e47220
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/debug/use_invalid_local_iterator_neg.cc
@@ -0,0 +1,34 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+//
+// { dg-require-debug-mode "" }
+// { dg-options "-std=gnu++0x" }
+// { dg-do run { xfail *-*-* } }
+
+#include <unordered_set>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+ __gnu_test::use_invalid_local_iterator<std::unordered_multiset<int>>();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_compare_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_compare_neg.cc
new file mode 100644
index 0000000..bef8e7b
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_compare_neg.cc
@@ -0,0 +1,34 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+//
+// { dg-require-debug-mode "" }
+// { dg-options "-std=gnu++0x" }
+// { dg-do run { xfail *-*-* } }
+
+#include <unordered_set>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+ __gnu_test::invalid_local_iterator_compare<std::unordered_set<int>>();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_range_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_range_neg.cc
new file mode 100644
index 0000000..e4cb8c1
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/invalid_local_iterator_range_neg.cc
@@ -0,0 +1,34 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+//
+// { dg-require-debug-mode "" }
+// { dg-options "-std=gnu++0x" }
+// { dg-do run { xfail *-*-* } }
+
+#include <unordered_set>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+ __gnu_test::invalid_local_iterator_range<std::unordered_set<int>>();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_erased_local_iterator_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_erased_local_iterator_neg.cc
new file mode 100644
index 0000000..1807005
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_erased_local_iterator_neg.cc
@@ -0,0 +1,34 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+//
+// { dg-require-debug-mode "" }
+// { dg-options "-std=gnu++0x" }
+// { dg-do run { xfail *-*-* } }
+
+#include <unordered_set>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+ __gnu_test::use_erased_local_iterator<std::unordered_set<int>>();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_invalid_iterator_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_invalid_iterator_neg.cc
new file mode 100644
index 0000000..c29889e
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_invalid_iterator_neg.cc
@@ -0,0 +1,34 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+//
+// { dg-require-debug-mode "" }
+// { dg-options "-std=gnu++0x" }
+// { dg-do run { xfail *-*-* } }
+
+#include <unordered_set>
+#include <debug/checks.h>
+
+void test01()
+{
+ __gnu_test::use_invalid_iterator<std::unordered_set<int>>();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_invalid_local_iterator_neg.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_invalid_local_iterator_neg.cc
new file mode 100644
index 0000000..28444ec
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_set/debug/use_invalid_local_iterator_neg.cc
@@ -0,0 +1,34 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+//
+// { dg-require-debug-mode "" }
+// { dg-options "-std=gnu++0x" }
+// { dg-do run { xfail *-*-* } }
+
+#include <unordered_set>
+#include <debug/unordered_checks.h>
+
+void test01()
+{
+ __gnu_test::use_invalid_local_iterator<std::unordered_set<int>>();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/util/debug/checks.h b/libstdc++-v3/testsuite/util/debug/checks.h
index b42ef1a..dbf6d40 100644
--- a/libstdc++-v3/testsuite/util/debug/checks.h
+++ b/libstdc++-v3/testsuite/util/debug/checks.h
@@ -1,4 +1,4 @@
-// Copyright (C) 2010 Free Software Foundation, Inc.
+// Copyright (C) 2010, 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
@@ -45,7 +45,7 @@ namespace __gnu_test
{
typedef _Tp value_type;
- operator value_type()
+ value_type build()
{
static value_type _S_;
++_S_;
@@ -60,7 +60,7 @@ namespace __gnu_test
typedef _Tp2 second_type;
typedef std::pair<_Tp1, _Tp2> pair_type;
- operator pair_type()
+ pair_type build()
{
static first_type _S_1;
static second_type _S_2;
@@ -86,7 +86,7 @@ namespace __gnu_test
vector_type v;
for (int i = 0; i != 5; ++i)
- v.push_back(gu);
+ v.push_back(gu.build());
VERIFY(v.size() == 5);
const val_type* first = &v.front() + 1;
@@ -116,7 +116,7 @@ namespace __gnu_test
vector_type v;
for (int i = 0; i != 5; ++i)
- v.push_back(gu);
+ v.push_back(gu.build());
VERIFY(v.size() == 5);
typename vector_type::iterator first = v.begin() + 1;
@@ -145,7 +145,7 @@ namespace __gnu_test
list_type l;
for (int i = 0; i != 5; ++i)
- l.push_back(gu);
+ l.push_back(gu.build());
VERIFY(l.size() == 5);
typename list_type::iterator first = l.begin(); ++first;
@@ -174,7 +174,7 @@ namespace __gnu_test
vector_type v;
for (int i = 0; i != 5; ++i)
- v.push_back(gu);
+ v.push_back(gu.build());
VERIFY(v.size() == 5);
val_type *first = &v.front() + 1;
@@ -201,7 +201,7 @@ namespace __gnu_test
vector_type v;
for (int i = 0; i != 5; ++i)
- v.push_back(gu);
+ v.push_back(gu.build());
VERIFY(v.size() == 5);
typename vector_type::iterator first = v.begin() + 1;
@@ -228,7 +228,7 @@ namespace __gnu_test
list_type l;
for (int i = 0; i != 5; ++i)
- l.push_back(gu);
+ l.push_back(gu.build());
VERIFY(l.size() == 5);
typename list_type::iterator first = l.begin(); ++first;
@@ -304,7 +304,7 @@ namespace __gnu_test
vector_type v;
for (int i = 0; i != 5; ++i)
- v.push_back(gu);
+ v.push_back(gu.build());
VERIFY(v.size() == 5);
const val_type* first = &v.front() + 1;
@@ -333,7 +333,7 @@ namespace __gnu_test
vector_type v;
for (int i = 0; i != 5; ++i)
- v.push_back(gu);
+ v.push_back(gu.build());
VERIFY(v.size() == 5);
typename vector_type::iterator first = v.begin() + 1;
@@ -362,7 +362,7 @@ namespace __gnu_test
list_type l;
for (int i = 0; i != 5; ++i)
- l.push_back(gu);
+ l.push_back(gu.build());
VERIFY(l.size() == 5);
typename list_type::iterator first = l.begin(); ++first;
@@ -375,5 +375,25 @@ namespace __gnu_test
cont_type c2;
InsertRangeHelper<cont_type>::Insert(c2, last, first); // Expected failure
}
+
+ template<typename _Tp>
+ void use_invalid_iterator()
+ {
+ bool test __attribute__((unused)) = true;
+
+ typedef _Tp cont_type;
+ typedef typename cont_type::value_type cont_val_type;
+ typedef typename CopyableValueType<cont_val_type>::value_type val_type;
+ generate_unique<val_type> gu;
+
+ cont_type c;
+ for (size_t i = 0; i != 5; ++i)
+ c.insert(gu.build());
+
+ typename cont_type::iterator it = c.begin();
+ cont_val_type val = *it;
+ c.clear();
+ VERIFY( *it == val );
+ }
}
diff --git a/libstdc++-v3/testsuite/util/debug/unordered_checks.h b/libstdc++-v3/testsuite/util/debug/unordered_checks.h
new file mode 100644
index 0000000..6684150
--- /dev/null
+++ b/libstdc++-v3/testsuite/util/debug/unordered_checks.h
@@ -0,0 +1,190 @@
+// 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
+// <http://www.gnu.org/licenses/>.
+//
+
+#include <testsuite_hooks.h>
+
+namespace __gnu_test
+{
+ template<typename _Tp>
+ struct CopyableValueType
+ {
+ typedef _Tp value_type;
+ };
+
+ template<typename _Tp1, typename _Tp2>
+ struct CopyableValueType<std::pair<const _Tp1, _Tp2> >
+ {
+ typedef std::pair<_Tp1, _Tp2> value_type;
+ };
+
+ template<typename _Tp>
+ struct generate_unique
+ {
+ typedef _Tp value_type;
+
+ value_type build()
+ {
+ static value_type _S_;
+ ++_S_;
+ return _S_;
+ }
+ };
+
+ template<typename _Tp1, typename _Tp2>
+ struct generate_unique<std::pair<_Tp1, _Tp2> >
+ {
+ typedef _Tp1 first_type;
+ typedef _Tp2 second_type;
+ typedef std::pair<_Tp1, _Tp2> pair_type;
+
+ pair_type build()
+ {
+ static first_type _S_1;
+ static second_type _S_2;
+ ++_S_1;
+ ++_S_2;
+ return pair_type(_S_1, _S_2);
+ }
+ };
+
+ template<typename _Tp>
+ struct KeyExtractor
+ {
+ static _Tp get_key(const _Tp& val)
+ { return val; }
+ };
+
+ template<typename _Tp1, typename _Tp2>
+ struct KeyExtractor<std::pair<const _Tp1, _Tp2>>
+ {
+ static _Tp1 get_key(const std::pair<const _Tp1, _Tp2>& val)
+ { return val.first; }
+ };
+
+ template<typename _Tp>
+ void use_erased_local_iterator()
+ {
+ bool test __attribute__((unused)) = true;
+
+ typedef _Tp cont_type;
+ typedef typename cont_type::value_type cont_val_type;
+ typedef typename CopyableValueType<cont_val_type>::value_type val_type;
+ generate_unique<val_type> gu;
+
+ cont_type c;
+ for (size_t i = 0; i != 5; ++i)
+ c.insert(gu.build());
+
+ typename cont_type::local_iterator it, end;
+ for (size_t i = 0; i != c.bucket_count(); ++i)
+ {
+ it = c.begin(i);
+ end = c.end(i);
+ if (it != end)
+ break;
+ }
+ typename cont_type::key_type key = KeyExtractor<cont_val_type>::get_key(*it);
+ c.erase(key);
+ VERIFY( it != end );
+ }
+
+ template<typename _Tp>
+ void use_invalid_local_iterator()
+ {
+ bool test __attribute__((unused)) = true;
+
+ typedef _Tp cont_type;
+ typedef typename cont_type::value_type cont_val_type;
+ typedef typename CopyableValueType<cont_val_type>::value_type val_type;
+ generate_unique<val_type> gu;
+
+ cont_type c;
+ for (size_t i = 0; i != 5; ++i)
+ c.insert(gu.build());
+
+ typename cont_type::local_iterator it;
+ for (size_t i = 0; i != c.bucket_count(); ++i)
+ {
+ it = c.begin(i);
+ if (it != c.end(i))
+ break;
+ }
+ cont_val_type val = *it;
+ c.clear();
+ VERIFY( *it == val );
+ }
+
+ template<typename _Tp>
+ void invalid_local_iterator_compare()
+ {
+ bool test __attribute__((unused)) = true;
+
+ typedef _Tp cont_type;
+ typedef typename cont_type::value_type cont_val_type;
+ typedef typename CopyableValueType<cont_val_type>::value_type val_type;
+ generate_unique<val_type> gu;
+
+ cont_type c;
+ for (size_t i = 0; i != 5; ++i)
+ c.insert(gu.build());
+
+ typename cont_type::local_iterator it1, it2;
+ size_t i;
+ for (i = 0; i != c.bucket_count(); ++i)
+ {
+ it1 = c.begin(i);
+ if (it1 != c.end(i))
+ break;
+ }
+ VERIFY( i != c.bucket_count() );
+ for (++i; i != c.bucket_count(); ++i)
+ {
+ it2 = c.begin(i);
+ if (it2 != c.end(i))
+ break;
+ }
+
+ VERIFY( it1 != it2 );
+ }
+
+ template<typename _Tp>
+ void invalid_local_iterator_range()
+ {
+ bool test __attribute__((unused)) = true;
+
+ typedef _Tp cont_type;
+ typedef typename cont_type::value_type cont_val_type;
+ typedef typename CopyableValueType<cont_val_type>::value_type val_type;
+ generate_unique<val_type> gu;
+
+ cont_type c;
+ for (size_t i = 0; i != 5; ++i)
+ c.insert(gu.build());
+
+ typename cont_type::local_iterator it, end;
+ for (size_t i = 0; i != c.bucket_count(); ++i)
+ {
+ it = c.begin(i);
+ end = c.end(i);
+ if (it != end)
+ break;
+ }
+ c.insert(end, it);
+ }
+}
+