re PR libstdc++/23781 (Implicit conversion from NULL to list<T>::iterator)

2005-09-11  Paolo Carlini  <pcarlini@suse.de>

	PR libstdc++/23781
	* include/bits/stl_list.h (_List_iterator<>::
	_List_iterator(_List_node_base*), _List_const_iterator<>::
	_List_const_iterator(const _List_node_base*)): Make explicit.
	(list<>::begin(), list<>::end(), list<>::pop_back()): Adjust
	consistently.
	* include/bits/list.tcc (list<>::insert, list<>::erase): Adjust
	consistently.
	* include/bits/stl_tree.h (_Rb_tree_iterator<>::
	_Rb_tree_iterator(_Link_type), _Rb_tree_const_iterator<>::
	_Rb_tree_const_iterator(_Link_type)): Make explicit.
	(_Rb_tree<>::begin(), _Rb_tree<>::end()): Adjust consistently.
	* include/ext/slist (_Slist_iterator<>::_Slist_iterator(_Node*)):
	Make explicit.
	(slist<>::erase(iterator), slist<>::erase(iterator, iterator)):
	Adjust consistently.
	* include/tr1/hashtable (hashtable_iterator<>::
	hashtable_iterator(hash_node<>**)): Make explicit.
	* testsuite/23_containers/list/23781.cc: New.
	* testsuite/23_containers/map/23781.cc: Likewise.
	* testsuite/23_containers/multimap/23781.cc: Likewise.
	* testsuite/23_containers/multiset/23781.cc: Likewise.
	* testsuite/23_containers/set/23781.cc: Likewise.
	* testsuite/ext/slist/23781.cc: Likewise.
	* testsuite/tr1/6_containers/unordered/23781.cc: Likewise.
	* testsuite/23_containers/map/operators/1_neg.cc: Adjust dg-error
	line numbers.
	* testsuite/23_containers/set/operators/1_neg.cc: Likewise.

	* include/tr1/array (array<>::begin(), array<>::end()): Adjust
	stylistically for consistency with the other containers.

From-SVN: r104139
This commit is contained in:
Paolo Carlini 2005-09-11 09:48:41 +00:00 committed by Paolo Carlini
parent 2347f5c931
commit e182017e46
16 changed files with 352 additions and 40 deletions

View file

@ -1,3 +1,37 @@
2005-09-11 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/23781
* include/bits/stl_list.h (_List_iterator<>::
_List_iterator(_List_node_base*), _List_const_iterator<>::
_List_const_iterator(const _List_node_base*)): Make explicit.
(list<>::begin(), list<>::end(), list<>::pop_back()): Adjust
consistently.
* include/bits/list.tcc (list<>::insert, list<>::erase): Adjust
consistently.
* include/bits/stl_tree.h (_Rb_tree_iterator<>::
_Rb_tree_iterator(_Link_type), _Rb_tree_const_iterator<>::
_Rb_tree_const_iterator(_Link_type)): Make explicit.
(_Rb_tree<>::begin(), _Rb_tree<>::end()): Adjust consistently.
* include/ext/slist (_Slist_iterator<>::_Slist_iterator(_Node*)):
Make explicit.
(slist<>::erase(iterator), slist<>::erase(iterator, iterator)):
Adjust consistently.
* include/tr1/hashtable (hashtable_iterator<>::
hashtable_iterator(hash_node<>**)): Make explicit.
* testsuite/23_containers/list/23781.cc: New.
* testsuite/23_containers/map/23781.cc: Likewise.
* testsuite/23_containers/multimap/23781.cc: Likewise.
* testsuite/23_containers/multiset/23781.cc: Likewise.
* testsuite/23_containers/set/23781.cc: Likewise.
* testsuite/ext/slist/23781.cc: Likewise.
* testsuite/tr1/6_containers/unordered/23781.cc: Likewise.
* testsuite/23_containers/map/operators/1_neg.cc: Adjust dg-error
line numbers.
* testsuite/23_containers/set/operators/1_neg.cc: Likewise.
* include/tr1/array (array<>::begin(), array<>::end()): Adjust
stylistically for consistency with the other containers.
2005-09-10 Joseph S. Myers <joseph@codesourcery.com>
* testsuite/26_numerics/cmath/c99_classification_macros_c.cc:

View file

@ -86,7 +86,7 @@ namespace _GLIBCXX_STD
{
_Node* __tmp = _M_create_node(__x);
__tmp->hook(__position._M_node);
return __tmp;
return iterator(__tmp);
}
template<typename _Tp, typename _Alloc>
@ -94,7 +94,7 @@ namespace _GLIBCXX_STD
list<_Tp, _Alloc>::
erase(iterator __position)
{
iterator __ret = __position._M_node->_M_next;
iterator __ret = iterator(__position._M_node->_M_next);
_M_erase(__position);
return __ret;
}

View file

@ -122,6 +122,7 @@ namespace _GLIBCXX_STD
_List_iterator()
: _M_node() { }
explicit
_List_iterator(_List_node_base* __x)
: _M_node(__x) { }
@ -199,6 +200,7 @@ namespace _GLIBCXX_STD
_List_const_iterator()
: _M_node() { }
explicit
_List_const_iterator(const _List_node_base* __x)
: _M_node(__x) { }
@ -574,7 +576,7 @@ namespace _GLIBCXX_STD
*/
iterator
begin()
{ return this->_M_impl._M_node._M_next; }
{ return iterator(this->_M_impl._M_node._M_next); }
/**
* Returns a read-only (constant) iterator that points to the
@ -583,7 +585,7 @@ namespace _GLIBCXX_STD
*/
const_iterator
begin() const
{ return this->_M_impl._M_node._M_next; }
{ return const_iterator(this->_M_impl._M_node._M_next); }
/**
* Returns a read/write iterator that points one past the last
@ -591,7 +593,8 @@ namespace _GLIBCXX_STD
* order.
*/
iterator
end() { return &this->_M_impl._M_node; }
end()
{ return iterator(&this->_M_impl._M_node); }
/**
* Returns a read-only (constant) iterator that points one past
@ -600,7 +603,7 @@ namespace _GLIBCXX_STD
*/
const_iterator
end() const
{ return &this->_M_impl._M_node; }
{ return const_iterator(&this->_M_impl._M_node); }
/**
* Returns a read/write reverse iterator that points to the last
@ -769,7 +772,7 @@ namespace _GLIBCXX_STD
*/
void
pop_back()
{ this->_M_erase(this->_M_impl._M_node._M_prev); }
{ this->_M_erase(iterator(this->_M_impl._M_node._M_prev)); }
/**
* @brief Inserts given value into %list before specified iterator.

View file

@ -164,6 +164,7 @@ namespace std
_Rb_tree_iterator()
: _M_node() { }
explicit
_Rb_tree_iterator(_Link_type __x)
: _M_node(__x) { }
@ -235,6 +236,7 @@ namespace std
_Rb_tree_const_iterator()
: _M_node() { }
explicit
_Rb_tree_const_iterator(_Link_type __x)
: _M_node(__x) { }
@ -579,22 +581,28 @@ namespace std
iterator
begin()
{ return static_cast<_Link_type>(this->_M_impl._M_header._M_left); }
{
return iterator(static_cast<_Link_type>
(this->_M_impl._M_header._M_left));
}
const_iterator
begin() const
{
return static_cast<_Const_Link_type>
(this->_M_impl._M_header._M_left);
{
return const_iterator(static_cast<_Const_Link_type>
(this->_M_impl._M_header._M_left));
}
iterator
end()
{ return static_cast<_Link_type>(&this->_M_impl._M_header); }
{ return iterator(static_cast<_Link_type>(&this->_M_impl._M_header)); }
const_iterator
end() const
{ return static_cast<_Const_Link_type>(&this->_M_impl._M_header); }
{
return const_iterator(static_cast<_Const_Link_type>
(&this->_M_impl._M_header));
}
reverse_iterator
rbegin()
@ -641,12 +649,12 @@ namespace std
insert_equal(iterator __position, const value_type& __x);
template<typename _InputIterator>
void
insert_unique(_InputIterator __first, _InputIterator __last);
void
insert_unique(_InputIterator __first, _InputIterator __last);
template<typename _InputIterator>
void
insert_equal(_InputIterator __first, _InputIterator __last);
void
insert_equal(_InputIterator __first, _InputIterator __last);
void
erase(iterator __position);

View file

@ -190,6 +190,7 @@ namespace __gnu_cxx
typedef _Ref reference;
typedef _Slist_node<_Tp> _Node;
explicit
_Slist_iterator(_Node* __x)
: _Slist_iterator_base(__x) {}
@ -601,20 +602,26 @@ namespace __gnu_cxx
iterator
erase_after(iterator __before_first, iterator __last)
{ return iterator((_Node*) this->_M_erase_after(__before_first._M_node,
__last._M_node)); }
{
return iterator((_Node*) this->_M_erase_after(__before_first._M_node,
__last._M_node));
}
iterator
erase(iterator __pos)
{ return (_Node*) this->_M_erase_after(__slist_previous(&this->_M_head,
__pos._M_node)); }
{
return iterator((_Node*) this->_M_erase_after
(__slist_previous(&this->_M_head, __pos._M_node)));
}
iterator
erase(iterator __first, iterator __last)
{ return (_Node*) this->_M_erase_after(__slist_previous(&this->_M_head,
__first._M_node),
__last._M_node); }
{
return iterator((_Node*) this->_M_erase_after
(__slist_previous(&this->_M_head, __first._M_node),
__last._M_node));
}
void
resize(size_type new_size, const _Tp& __x);

View file

@ -75,21 +75,21 @@ namespace tr1
swap(array&);
// Iterators.
iterator
iterator
begin()
{ return &_M_instance[0]; }
{ return iterator(&_M_instance[0]); }
const_iterator
const_iterator
begin() const
{ return &_M_instance[0]; }
{ return const_iterator(&_M_instance[0]); }
iterator
iterator
end()
{ return &_M_instance[_Nm]; }
{ return iterator(&_M_instance[_Nm]); }
const_iterator
const_iterator
end() const
{ return &_M_instance[_Nm]; }
{ return const_iterator(&_M_instance[_Nm]); }
reverse_iterator
rbegin()

View file

@ -261,7 +261,8 @@ namespace Internal
hashtable_iterator(hash_node<Value, cache>* p,
hash_node<Value, cache>** b)
: hashtable_iterator_base<Value, cache>(p, b) { }
explicit
hashtable_iterator(hash_node<Value, cache>** b)
: hashtable_iterator_base<Value, cache>(*b, b) { }

View file

@ -0,0 +1,36 @@
// 2005-09-10 Paolo Carlini <pcarlini@suse.de>
//
// Copyright (C) 2005 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// 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.
// { dg-do compile }
// libstdc++/23781
#include <list>
std::list<int>::iterator it = NULL; // { dg-error "conversion" }
std::list<int>::const_iterator cit = NULL; // { dg-error "conversion" }

View file

@ -0,0 +1,36 @@
// 2005-09-10 Paolo Carlini <pcarlini@suse.de>
//
// Copyright (C) 2005 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// 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.
// { dg-do compile }
// libstdc++/23781
#include <map>
std::map<int, int>::iterator it = NULL; // { dg-error "conversion" }
std::map<int, int>::const_iterator cit = NULL; // { dg-error "conversion" }

View file

@ -1,6 +1,6 @@
// { dg-do compile }
// Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
// Copyright (C) 2000, 2001, 2002, 2004, 2005 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
@ -41,5 +41,5 @@ void test01()
test &= itr == mapByName.end(); // { dg-error "no" }
}
// { dg-error "candidates are" "" { target *-*-* } 209 }
// { dg-error "candidates are" "" { target *-*-* } 213 }
// { dg-error "candidates are" "" { target *-*-* } 210 }
// { dg-error "candidates are" "" { target *-*-* } 214 }

View file

@ -0,0 +1,36 @@
// 2005-09-10 Paolo Carlini <pcarlini@suse.de>
//
// Copyright (C) 2005 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// 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.
// { dg-do compile }
// libstdc++/23781
#include <map>
std::multimap<int, int>::iterator it = NULL; // { dg-error "conversion" }
std::multimap<int, int>::const_iterator cit = NULL; // { dg-error "conversion" }

View file

@ -0,0 +1,36 @@
// 2005-09-10 Paolo Carlini <pcarlini@suse.de>
//
// Copyright (C) 2005 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// 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.
// { dg-do compile }
// libstdc++/23781
#include <set>
std::multiset<int>::iterator it = NULL; // { dg-error "conversion" }
std::multiset<int>::const_iterator cit = NULL; // { dg-error "conversion" }

View file

@ -0,0 +1,36 @@
// 2005-09-10 Paolo Carlini <pcarlini@suse.de>
//
// Copyright (C) 2005 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// 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.
// { dg-do compile }
// libstdc++/23781
#include <set>
std::set<int>::iterator it = NULL; // { dg-error "conversion" }
std::set<int>::const_iterator cit = NULL; // { dg-error "conversion" }

View file

@ -1,6 +1,6 @@
// { dg-do compile }
// Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
// Copyright (C) 2000, 2001, 2002, 2004, 2005 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
@ -39,5 +39,5 @@ void test01()
test &= itr == setByName.end(); // { dg-error "no" }
}
// { dg-error "candidates are" "" { target *-*-* } 283 }
// { dg-error "candidates are" "" { target *-*-* } 287 }
// { dg-error "candidates are" "" { target *-*-* } 285 }
// { dg-error "candidates are" "" { target *-*-* } 289 }

View file

@ -0,0 +1,36 @@
// 2005-09-10 Paolo Carlini <pcarlini@suse.de>
//
// Copyright (C) 2005 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// 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.
// { dg-do compile }
// libstdc++/23781
#include <ext/slist>
__gnu_cxx::slist<int>::iterator it = NULL; // { dg-error "conversion" }
__gnu_cxx::slist<int>::const_iterator cit = NULL; // { dg-error "conversion" }

View file

@ -0,0 +1,43 @@
// 2005-09-10 Paolo Carlini <pcarlini@suse.de>
//
// Copyright (C) 2005 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// 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.
// { dg-do compile }
// libstdc++/23781
#include <tr1/unordered_map>
#include <tr1/unordered_set>
std::tr1::unordered_map<int, int>::iterator it1 = NULL; // { dg-error "conversion" }
std::tr1::unordered_map<int, int>::const_iterator cit1 = NULL; // { dg-error "conversion" }
std::tr1::unordered_multimap<int, int>::iterator it2 = NULL; // { dg-error "conversion" }
std::tr1::unordered_multimap<int, int>::const_iterator cit2 = NULL; // { dg-error "conversion" }
std::tr1::unordered_multiset<int>::iterator it3 = NULL; // { dg-error "conversion" }
std::tr1::unordered_multiset<int>::const_iterator cit3 = NULL; // { dg-error "conversion" }
std::tr1::unordered_set<int>::iterator it4 = NULL; // { dg-error "conversion" }
std::tr1::unordered_set<int>::const_iterator cit4 = NULL; // { dg-error "conversion" }