aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely.gcc@gmail.com>2012-04-22 13:27:16 +0000
committerJonathan Wakely <redi@gcc.gnu.org>2012-04-22 14:27:16 +0100
commit7c688aded43731835cfd13566fe8240c346cc20d (patch)
tree4cc822a189910f33f4e66596db19082a4d0f4ddb /libstdc++-v3
parent49c45e289e98ae5abfcd6ba549b839cd70fe62af (diff)
downloadgcc-7c688aded43731835cfd13566fe8240c346cc20d.zip
gcc-7c688aded43731835cfd13566fe8240c346cc20d.tar.gz
gcc-7c688aded43731835cfd13566fe8240c346cc20d.tar.bz2
forward_list (forward_list::splice_after): Check allocators are equal.
* include/debug/forward_list (forward_list::splice_after): Check allocators are equal. * src/c++11/debug.cc: Fix spelling. * testsuite/23_containers/forward_list/debug/splice_after5_neg.cc: New. * testsuite/23_containers/forward_list/debug/splice_after6_neg.cc: Likewise. * testsuite/23_containers/forward_list/debug/splice_after7_neg.cc: Likewise. From-SVN: r186669
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog12
-rw-r--r--libstdc++-v3/include/debug/forward_list12
-rw-r--r--libstdc++-v3/src/c++11/debug.cc2
-rw-r--r--libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after5_neg.cc41
-rw-r--r--libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after6_neg.cc41
-rw-r--r--libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after7_neg.cc41
6 files changed, 148 insertions, 1 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index bebc23c..fc39c1e 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,15 @@
+2012-04-22 Jonathan Wakely <jwakely.gcc@gmail.com>
+
+ * include/debug/forward_list (forward_list::splice_after): Check
+ allocators are equal.
+ * src/c++11/debug.cc: Fix spelling.
+ * testsuite/23_containers/forward_list/debug/splice_after5_neg.cc:
+ New.
+ * testsuite/23_containers/forward_list/debug/splice_after6_neg.cc:
+ Likewise.
+ * testsuite/23_containers/forward_list/debug/splice_after7_neg.cc:
+ Likewise.
+
2012-04-20 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/53052
diff --git a/libstdc++-v3/include/debug/forward_list b/libstdc++-v3/include/debug/forward_list
index f4a7ee9..8ad4336 100644
--- a/libstdc++-v3/include/debug/forward_list
+++ b/libstdc++-v3/include/debug/forward_list
@@ -409,6 +409,10 @@ namespace __debug
_GLIBCXX_DEBUG_VERIFY(&__list != this,
_M_message(__gnu_debug::__msg_self_splice)
._M_sequence(*this, "this"));
+ _GLIBCXX_DEBUG_VERIFY(__list.get_allocator() == this->get_allocator(),
+ _M_message(__gnu_debug::__msg_splice_alloc)
+ ._M_sequence(*this)
+ ._M_sequence(__list, "__list"));
this->_M_transfer_from_if(__list, [&__list](_Base_const_iterator __it)
{
return __it != __list._M_base().cbefore_begin()
@@ -433,6 +437,10 @@ namespace __debug
_M_message(__gnu_debug::__msg_splice_other)
._M_iterator(__i, "__i")
._M_sequence(__list, "__list"));
+ _GLIBCXX_DEBUG_VERIFY(__list.get_allocator() == this->get_allocator(),
+ _M_message(__gnu_debug::__msg_splice_alloc)
+ ._M_sequence(*this)
+ ._M_sequence(__list, "__list"));
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 250. splicing invalidates iterators
@@ -469,6 +477,10 @@ namespace __debug
._M_sequence(__list, "list")
._M_iterator(__before, "before")
._M_iterator(__last, "last"));
+ _GLIBCXX_DEBUG_VERIFY(__list.get_allocator() == this->get_allocator(),
+ _M_message(__gnu_debug::__msg_splice_alloc)
+ ._M_sequence(*this)
+ ._M_sequence(__list, "__list"));
for (_Base_const_iterator __tmp = std::next(__before.base());
__tmp != __last.base(); ++__tmp)
diff --git a/libstdc++-v3/src/c++11/debug.cc b/libstdc++-v3/src/c++11/debug.cc
index 0c746c1..f0ab4bc 100644
--- a/libstdc++-v3/src/c++11/debug.cc
+++ b/libstdc++-v3/src/c++11/debug.cc
@@ -131,7 +131,7 @@ namespace __gnu_debug
"attempt to flip a singular bitset reference",
// std::list checks
"attempt to splice a list into itself",
- "attempt to splice lists with inequal allocators",
+ "attempt to splice lists with unequal allocators",
"attempt to splice elements referenced by a %1.state; iterator",
"attempt to splice an iterator from a different container",
"splice destination %1.name;"
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after5_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after5_neg.cc
new file mode 100644
index 0000000..6b7d0da
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after5_neg.cc
@@ -0,0 +1,41 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-debug-mode "" }
+// { dg-do run { xfail *-*-* } }
+
+// Copyright (C) 2012 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 Pred 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 <forward_list>
+#include <testsuite_allocator.h>
+
+void
+test01()
+{
+ typedef __gnu_test::uneq_allocator<int> alloc_type;
+
+ std::forward_list<int, alloc_type> fl1({1, 2, 3}, alloc_type(1));
+ std::forward_list<int, alloc_type> fl2({1, 2, 3}, alloc_type(2));
+
+ fl1.splice_after(fl1.before_begin(), fl2);
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after6_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after6_neg.cc
new file mode 100644
index 0000000..620bb5c
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after6_neg.cc
@@ -0,0 +1,41 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-debug-mode "" }
+// { dg-do run { xfail *-*-* } }
+
+// Copyright (C) 2012 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 Pred 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 <forward_list>
+#include <testsuite_allocator.h>
+
+void
+test01()
+{
+ typedef __gnu_test::uneq_allocator<int> alloc_type;
+
+ std::forward_list<int, alloc_type> fl1({1, 2, 3}, alloc_type(1));
+ std::forward_list<int, alloc_type> fl2({1, 2, 3}, alloc_type(2));
+
+ fl1.splice_after(fl1.before_begin(), fl2, fl2.begin());
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after7_neg.cc b/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after7_neg.cc
new file mode 100644
index 0000000..a2b5cfa
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/forward_list/debug/splice_after7_neg.cc
@@ -0,0 +1,41 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-require-debug-mode "" }
+// { dg-do run { xfail *-*-* } }
+
+// Copyright (C) 2012 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 Pred 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 <forward_list>
+#include <testsuite_allocator.h>
+
+void
+test01()
+{
+ typedef __gnu_test::uneq_allocator<int> alloc_type;
+
+ std::forward_list<int, alloc_type> fl1({1, 2, 3}, alloc_type(1));
+ std::forward_list<int, alloc_type> fl2({1, 2, 3}, alloc_type(2));
+
+ fl1.splice_after(fl1.before_begin(), fl2, fl2.begin(), fl2.end());
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}