diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 39d1acdb1da..cbd68c15071 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,21 @@ +2004-05-17 Benjamin Kosnik + + * 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 + + 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 * 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 7482d6caa65..8a4123af694 100644 --- a/libstdc++-v3/include/debug/safe_iterator.h +++ b/libstdc++-v3/include/debug/safe_iterator.h @@ -35,6 +35,7 @@ #include #include #include +#include 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 - _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 00000000000..1e1c302856e --- /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 +#include + +// { dg-options "-D_GLIBCXX_DEBUG" } +// { dg-do compile } + +// libstdc++/14340 +int main() +{ + typedef std::deque container; + __gnu_test::conversion::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 00000000000..3d2b369ea88 --- /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 +#include + +// { dg-options "-D_GLIBCXX_DEBUG" } +// { dg-do compile } + +// libstdc++/14340 +int main() +{ + typedef std::list container; + __gnu_test::conversion::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 00000000000..8f01440f244 --- /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 +#include + +// { dg-options "-D_GLIBCXX_DEBUG" } +// { 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/multimap/14340.cc b/libstdc++-v3/testsuite/23_containers/multimap/14340.cc new file mode 100644 index 00000000000..f119796b039 --- /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 +#include + +// { dg-options "-D_GLIBCXX_DEBUG" } +// { dg-do compile } + +// libstdc++/14340 +int main() +{ + typedef std::multimap container; + __gnu_test::conversion::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 00000000000..354c5153edf --- /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 +#include + +// { dg-options "-D_GLIBCXX_DEBUG" } +// { dg-do compile } + +// libstdc++/14340 +int main() +{ + typedef std::multiset container; + __gnu_test::conversion::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 00000000000..b24fb4c73e8 --- /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 +#include + +// { dg-options "-D_GLIBCXX_DEBUG" } +// { dg-do compile } + +// libstdc++/14340 +int main() +{ + typedef std::set container; + __gnu_test::conversion::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 00000000000..c81408633f5 --- /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 +#include + +// { dg-options "-D_GLIBCXX_DEBUG" } +// { dg-do compile } + +// libstdc++/14340 +int main() +{ + typedef std::vector container; + __gnu_test::conversion::iterator_to_const_iterator(); + return 0; +} diff --git a/libstdc++-v3/testsuite/testsuite_hooks.h b/libstdc++-v3/testsuite/testsuite_hooks.h index fad69adadd7..daa44232ae4 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 + 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