aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kosnik <bkoz@gcc.gnu.org>2004-05-18 03:27:57 +0000
committerBenjamin Kosnik <bkoz@gcc.gnu.org>2004-05-18 03:27:57 +0000
commit261e5b9e6a0a97700d3e0b6bbf0c9cff2d185386 (patch)
tree4a0820b77b1ca2936bfaad93db204a507ced96e5
parent85b87c94afe309afc7be3fa3e5ad6e303affe2ea (diff)
downloadgcc-261e5b9e6a0a97700d3e0b6bbf0c9cff2d185386.zip
gcc-261e5b9e6a0a97700d3e0b6bbf0c9cff2d185386.tar.gz
gcc-261e5b9e6a0a97700d3e0b6bbf0c9cff2d185386.tar.bz2
[multiple changes]
2004-05-17 Benjamin Kosnik <bkoz@redhat.com> * testsuite/testsuite_hooks.h (__gnu_test::conversion): New class. * testsuite/23_containers/deque/14340.cc: New. * testsuite/23_containers/list/14340.cc: New. * testsuite/23_containers/map/14340.cc: New. * testsuite/23_containers/multimap/14340.cc: New. * testsuite/23_containers/multiset/14340.cc: New. * testsuite/23_containers/set/14340.cc: New. * testsuite/23_containers/vector/14340.cc: New. 2004-05-17 Douglas Gregor <gregod@cs.rpi.edu> PR libstdc++/14340 * include/debug/safe_iterator.h (_Safe_iterator converting constructor): Only allow declaration to instantiate when the incoming _Safe_iterator has exactly the right iterator type. From-SVN: r81970
-rw-r--r--libstdc++-v3/ChangeLog18
-rw-r--r--libstdc++-v3/include/debug/safe_iterator.h10
-rw-r--r--libstdc++-v3/testsuite/23_containers/deque/14340.cc42
-rw-r--r--libstdc++-v3/testsuite/23_containers/list/14340.cc42
-rw-r--r--libstdc++-v3/testsuite/23_containers/map/14340.cc42
-rw-r--r--libstdc++-v3/testsuite/23_containers/multimap/14340.cc42
-rw-r--r--libstdc++-v3/testsuite/23_containers/multiset/14340.cc42
-rw-r--r--libstdc++-v3/testsuite/23_containers/set/14340.cc42
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/14340.cc42
-rw-r--r--libstdc++-v3/testsuite/testsuite_hooks.h20
10 files changed, 340 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 39d1acd..cbd68c1 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,21 @@
+2004-05-17 Benjamin Kosnik <bkoz@redhat.com>
+
+ * testsuite/testsuite_hooks.h (__gnu_test::conversion): New class.
+ * testsuite/23_containers/deque/14340.cc: New.
+ * testsuite/23_containers/list/14340.cc: New.
+ * testsuite/23_containers/map/14340.cc: New.
+ * testsuite/23_containers/multimap/14340.cc: New.
+ * testsuite/23_containers/multiset/14340.cc: New.
+ * testsuite/23_containers/set/14340.cc: New.
+ * testsuite/23_containers/vector/14340.cc: New.
+
+2004-05-17 Douglas Gregor <gregod@cs.rpi.edu>
+
+ PR libstdc++/14340
+ * include/debug/safe_iterator.h (_Safe_iterator converting
+ constructor): Only allow declaration to instantiate when the
+ incoming _Safe_iterator has exactly the right iterator type.
+
2004-05-17 Jonathan Wakely <redi@gcc.gnu.org>
* include/bits/boost_concept_check.h: Fix old attribute syntax.
diff --git a/libstdc++-v3/include/debug/safe_iterator.h b/libstdc++-v3/include/debug/safe_iterator.h
index 7482d6c..8a4123a 100644
--- a/libstdc++-v3/include/debug/safe_iterator.h
+++ b/libstdc++-v3/include/debug/safe_iterator.h
@@ -35,6 +35,7 @@
#include <debug/debug.h>
#include <debug/formatter.h>
#include <debug/safe_base.h>
+#include <bits/cpp_type_traits.h>
namespace __gnu_debug
{
@@ -88,6 +89,7 @@ namespace __gnu_debug
typedef iterator_traits<_Iterator> _Traits;
public:
+ typedef _Iterator _Base_iterator;
typedef typename _Traits::iterator_category iterator_category;
typedef typename _Traits::value_type value_type;
typedef typename _Traits::difference_type difference_type;
@@ -132,7 +134,13 @@ namespace __gnu_debug
* @pre @p x is not singular
*/
template<typename _MutableIterator>
- _Safe_iterator(const _Safe_iterator<_MutableIterator, _Sequence>& __x)
+ _Safe_iterator(
+ const _Safe_iterator<_MutableIterator,
+ typename std::__enable_if<
+ _Sequence,
+ (std::__are_same<_MutableIterator,
+ typename _Sequence::iterator::_Base_iterator>::_M_type)
+ >::_M_type>& __x)
: _Safe_iterator_base(__x, _M_constant()), _M_current(__x.base())
{
_GLIBCXX_DEBUG_VERIFY(!__x._M_singular(),
diff --git a/libstdc++-v3/testsuite/23_containers/deque/14340.cc b/libstdc++-v3/testsuite/23_containers/deque/14340.cc
new file mode 100644
index 0000000..1e1c302
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/deque/14340.cc
@@ -0,0 +1,42 @@
+// -*- C++ -*-
+
+// Copyright (C) 2004 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <testsuite_hooks.h>
+#include <deque>
+
+// { dg-options "-D_GLIBCXX_DEBUG" }
+// { dg-do compile }
+
+// libstdc++/14340
+int main()
+{
+ typedef std::deque<int> container;
+ __gnu_test::conversion<container>::iterator_to_const_iterator();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/list/14340.cc b/libstdc++-v3/testsuite/23_containers/list/14340.cc
new file mode 100644
index 0000000..3d2b369
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/list/14340.cc
@@ -0,0 +1,42 @@
+// -*- C++ -*-
+
+// Copyright (C) 2004 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <testsuite_hooks.h>
+#include <list>
+
+// { dg-options "-D_GLIBCXX_DEBUG" }
+// { dg-do compile }
+
+// libstdc++/14340
+int main()
+{
+ typedef std::list<int> container;
+ __gnu_test::conversion<container>::iterator_to_const_iterator();
+ return 0;
+}
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 0000000..8f01440
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/map/14340.cc
@@ -0,0 +1,42 @@
+// -*- C++ -*-
+
+// Copyright (C) 2004 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <testsuite_hooks.h>
+#include <map>
+
+// { dg-options "-D_GLIBCXX_DEBUG" }
+// { dg-do compile }
+
+// libstdc++/14340
+int main()
+{
+ typedef std::map<int, int> container;
+ __gnu_test::conversion<container>::iterator_to_const_iterator();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/multimap/14340.cc b/libstdc++-v3/testsuite/23_containers/multimap/14340.cc
new file mode 100644
index 0000000..f119796b
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/multimap/14340.cc
@@ -0,0 +1,42 @@
+// -*- C++ -*-
+
+// Copyright (C) 2004 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <testsuite_hooks.h>
+#include <map>
+
+// { dg-options "-D_GLIBCXX_DEBUG" }
+// { dg-do compile }
+
+// libstdc++/14340
+int main()
+{
+ typedef std::multimap<int, int> container;
+ __gnu_test::conversion<container>::iterator_to_const_iterator();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/multiset/14340.cc b/libstdc++-v3/testsuite/23_containers/multiset/14340.cc
new file mode 100644
index 0000000..354c515
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/multiset/14340.cc
@@ -0,0 +1,42 @@
+// -*- C++ -*-
+
+// Copyright (C) 2004 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <testsuite_hooks.h>
+#include <set>
+
+// { dg-options "-D_GLIBCXX_DEBUG" }
+// { dg-do compile }
+
+// libstdc++/14340
+int main()
+{
+ typedef std::multiset<int, int> container;
+ __gnu_test::conversion<container>::iterator_to_const_iterator();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/set/14340.cc b/libstdc++-v3/testsuite/23_containers/set/14340.cc
new file mode 100644
index 0000000..b24fb4c
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/set/14340.cc
@@ -0,0 +1,42 @@
+// -*- C++ -*-
+
+// Copyright (C) 2004 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <testsuite_hooks.h>
+#include <set>
+
+// { dg-options "-D_GLIBCXX_DEBUG" }
+// { dg-do compile }
+
+// libstdc++/14340
+int main()
+{
+ typedef std::set<int, int> container;
+ __gnu_test::conversion<container>::iterator_to_const_iterator();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/vector/14340.cc b/libstdc++-v3/testsuite/23_containers/vector/14340.cc
new file mode 100644
index 0000000..c8140863
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/14340.cc
@@ -0,0 +1,42 @@
+// -*- C++ -*-
+
+// Copyright (C) 2004 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <testsuite_hooks.h>
+#include <vector>
+
+// { dg-options "-D_GLIBCXX_DEBUG" }
+// { dg-do compile }
+
+// libstdc++/14340
+int main()
+{
+ typedef std::vector<int> container;
+ __gnu_test::conversion<container>::iterator_to_const_iterator();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/testsuite_hooks.h b/libstdc++-v3/testsuite/testsuite_hooks.h
index fad69ad..daa4423 100644
--- a/libstdc++-v3/testsuite/testsuite_hooks.h
+++ b/libstdc++-v3/testsuite/testsuite_hooks.h
@@ -1,7 +1,7 @@
// -*- C++ -*-
// Utility subroutines for the C++ library testsuite.
//
-// Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+// Copyright (C) 2000, 2001, 2002, 2003, 2004 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
@@ -340,6 +340,24 @@ namespace __gnu_test
inline bool
operator==(const copy_tracker& lhs, const copy_tracker& rhs)
{ return lhs.id() == rhs.id(); }
+
+ // Class for checking required type conversions, implicit and
+ // explicit for given library data structures.
+ template<typename _Container>
+ struct conversion
+ {
+ typedef typename _Container::const_iterator const_iterator;
+
+ // Implicit conversion iterator to const_iterator.
+ static const_iterator
+ iterator_to_const_iterator()
+ {
+ _Container v;
+ const_iterator it = v.begin();
+ const_iterator end = v.end();
+ return it == end ? v.end() : it;
+ }
+ };
} // namespace __gnu_test
namespace std