[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
This commit is contained in:
Benjamin Kosnik 2004-05-18 03:27:57 +00:00
parent 85b87c94af
commit 261e5b9e6a
10 changed files with 340 additions and 2 deletions

View File

@ -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.

View File

@ -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(),

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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