[multiple changes]

2010-05-20  Paolo Carlini  <paolo.carlini@oracle.com>

	PR libstdc++/41792
	* include/tr1_impl/array: Use std::__addressof.
	* include/std/functional (reference_wrapper): Likewise.
	* include/ext/throw_allocator.h: Likewise.
	* include/ext/pool_allocator.h: Likewise.
	* include/ext/bitmap_allocator.h: Likewise.
	* include/ext/new_allocator.h: Likewise.
	* include/ext/malloc_allocator.h: Likewise.
	* include/ext/array_allocator.h: Likewise.
	* include/ext/mt_allocator.h: Likewise.
	* include/ext/extptr_allocator.h: Likewise.
	* include/bits/stl_list.h: Likewise.
	* include/bits/hashtable_policy.h: Likewise.
	* include/bits/forward_list.h: Likewise.
	* include/bits/stl_uninitialized.h: Likewise.
	* include/bits/list.tcc: Likewise.
	* include/bits/stl_construct.h: Likewise.
	* include/bits/stl_tree.h: Likewise.
	* testsuite/20_util/reference_wrapper/41792.cc: New.
	* testsuite/23_containers/unordered_map/requirements/
	explicit_instantiation/4.cc: Likewise.
	* testsuite/23_containers/multimap/requirements/
	explicit_instantiation/4.cc: Likewise.
	* testsuite/23_containers/set/requirements/
	explicit_instantiation/4.cc: Likewise.
	* testsuite/23_containers/unordered_multimap/requirements/
	explicit_instantiation/4.cc: Likewise.
	* testsuite/23_containers/forward_list/requirements/
	explicit_instantiation/4.cc: Likewise.
	* testsuite/23_containers/unordered_set/requirements/
	explicit_instantiation/4.cc: Likewise.
	* testsuite/23_containers/vector/requirements/
	explicit_instantiation/4.cc: Likewise.
	* testsuite/23_containers/deque/requirements/
	explicit_instantiation/4.cc: Likewise.
	* testsuite/23_containers/multiset/requirements/
	explicit_instantiation/4.cc: Likewise.
	* testsuite/23_containers/list/requirements/
	explicit_instantiation/4.cc: Likewise.
	* testsuite/23_containers/unordered_multiset/requirements/
	explicit_instantiation/4.cc: Likewise.
	* testsuite/23_containers/map/requirements/
	explicit_instantiation/4.cc: Likewise.
	* testsuite/23_containers/array/requirements/
	explicit_instantiation/3.cc: Likewise.
	* testsuite/23_containers/forward_list/requirements/
	dr438/assign_neg.cc: Adjust dg-error line numbers.
	* testsuite/23_containers/forward_list/requirements/dr438/
	insert_neg.cc: Likewise.
	* testsuite/23_containers/forward_list/requirements/dr438/
	constructor_1_neg.cc: Likewise.
	* testsuite/23_containers/forward_list/requirements/dr438/
	constructor_2_neg.cc: Likewise.
	* testsuite/23_containers/list/requirements/dr438/
	assign_neg.cc: Likewise.
	* testsuite/23_containers/list/requirements/dr438/
	insert_neg.cc: Likewise.
	* testsuite/23_containers/list/requirements/dr438/
	constructor_1_neg.cc: Likewise.
	* testsuite/23_containers/list/requirements/dr438/
	constructor_2_neg.cc: Likewise.

2010-05-20  Peter Dimov  <pdimov@pdimov.com>
	    Paolo Carlini  <paolo.carlini@oracle.com>

	* include/bits/move.h (__addressof, addressof): Add.
	* testsuite/util/testsuite_api.h (struct OverloadedAddress): Add.
	* testsuite/20_util/addressof/requirements/
	explicit_instantiation.cc: New.
	* testsuite/20_util/addressof/1.cc: Likewise.

From-SVN: r159643
This commit is contained in:
Paolo Carlini 2010-05-20 22:35:49 +00:00
parent 9f946bc11c
commit 882b3d5c2e
44 changed files with 729 additions and 73 deletions

View File

@ -1,3 +1,76 @@
2010-05-20 Paolo Carlini <paolo.carlini@oracle.com>
PR libstdc++/41792
* include/tr1_impl/array: Use std::__addressof.
* include/std/functional (reference_wrapper): Likewise.
* include/ext/throw_allocator.h: Likewise.
* include/ext/pool_allocator.h: Likewise.
* include/ext/bitmap_allocator.h: Likewise.
* include/ext/new_allocator.h: Likewise.
* include/ext/malloc_allocator.h: Likewise.
* include/ext/array_allocator.h: Likewise.
* include/ext/mt_allocator.h: Likewise.
* include/ext/extptr_allocator.h: Likewise.
* include/bits/stl_list.h: Likewise.
* include/bits/hashtable_policy.h: Likewise.
* include/bits/forward_list.h: Likewise.
* include/bits/stl_uninitialized.h: Likewise.
* include/bits/list.tcc: Likewise.
* include/bits/stl_construct.h: Likewise.
* include/bits/stl_tree.h: Likewise.
* testsuite/20_util/reference_wrapper/41792.cc: New.
* testsuite/23_containers/unordered_map/requirements/
explicit_instantiation/4.cc: Likewise.
* testsuite/23_containers/multimap/requirements/
explicit_instantiation/4.cc: Likewise.
* testsuite/23_containers/set/requirements/
explicit_instantiation/4.cc: Likewise.
* testsuite/23_containers/unordered_multimap/requirements/
explicit_instantiation/4.cc: Likewise.
* testsuite/23_containers/forward_list/requirements/
explicit_instantiation/4.cc: Likewise.
* testsuite/23_containers/unordered_set/requirements/
explicit_instantiation/4.cc: Likewise.
* testsuite/23_containers/vector/requirements/
explicit_instantiation/4.cc: Likewise.
* testsuite/23_containers/deque/requirements/
explicit_instantiation/4.cc: Likewise.
* testsuite/23_containers/multiset/requirements/
explicit_instantiation/4.cc: Likewise.
* testsuite/23_containers/list/requirements/
explicit_instantiation/4.cc: Likewise.
* testsuite/23_containers/unordered_multiset/requirements/
explicit_instantiation/4.cc: Likewise.
* testsuite/23_containers/map/requirements/
explicit_instantiation/4.cc: Likewise.
* testsuite/23_containers/array/requirements/
explicit_instantiation/3.cc: Likewise.
* testsuite/23_containers/forward_list/requirements/
dr438/assign_neg.cc: Adjust dg-error line numbers.
* testsuite/23_containers/forward_list/requirements/dr438/
insert_neg.cc: Likewise.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_2_neg.cc: Likewise.
* testsuite/23_containers/list/requirements/dr438/
assign_neg.cc: Likewise.
* testsuite/23_containers/list/requirements/dr438/
insert_neg.cc: Likewise.
* testsuite/23_containers/list/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/list/requirements/dr438/
constructor_2_neg.cc: Likewise.
2010-05-20 Peter Dimov <pdimov@pdimov.com>
Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/move.h (__addressof, addressof): Add.
* testsuite/util/testsuite_api.h (struct OverloadedAddress): Add.
* testsuite/20_util/addressof/requirements/
explicit_instantiation.cc: New.
* testsuite/20_util/addressof/1.cc: Likewise.
2010-05-20 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/stl_pair.h (pair<>::pair(const pair&)): Defaulted

View File

@ -139,7 +139,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
pointer
operator->() const
{ return &static_cast<_Node*>(this->_M_node)->_M_value; }
{ return std::__addressof(static_cast<_Node*>
(this->_M_node)->_M_value); }
_Self&
operator++()
@ -210,7 +211,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
pointer
operator->() const
{ return &static_cast<_Node*>(this->_M_node)->_M_value; }
{ return std::__addressof(static_cast<_Node*>
(this->_M_node)->_M_value); }
_Self&
operator++()

View File

@ -145,7 +145,7 @@ namespace __detail
pointer
operator->() const
{ return &this->_M_cur->_M_v; }
{ return std::__addressof(this->_M_cur->_M_v); }
_Node_iterator&
operator++()
@ -190,7 +190,7 @@ namespace __detail
pointer
operator->() const
{ return &this->_M_cur->_M_v; }
{ return std::__addressof(this->_M_cur->_M_v); }
_Node_const_iterator&
operator++()
@ -288,7 +288,7 @@ namespace __detail
pointer
operator->() const
{ return &this->_M_cur_node->_M_v; }
{ return std::__addressof(this->_M_cur_node->_M_v); }
_Hashtable_iterator&
operator++()
@ -338,7 +338,7 @@ namespace __detail
pointer
operator->() const
{ return &this->_M_cur_node->_M_v; }
{ return std::__addressof(this->_M_cur_node->_M_v); }
_Hashtable_const_iterator&
operator++()

View File

@ -73,7 +73,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
#ifdef __GXX_EXPERIMENTAL_CXX0X__
_M_get_Node_allocator().destroy(__tmp);
#else
_M_get_Tp_allocator().destroy(&__tmp->_M_data);
_M_get_Tp_allocator().destroy(std::__addressof(__tmp->_M_data));
#endif
_M_put_node(__tmp);
}
@ -198,7 +198,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 526. Is it undefined if a function in the standard changes
// in parameters?
if (&*__first != &__value)
if (std::__addressof(*__first) != std::__addressof(__value))
_M_erase(__first);
else
__extra = __first;

View File

@ -1,6 +1,6 @@
// Move, forward and identity for C++0x + swap -*- C++ -*-
// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
// Copyright (C) 2007, 2008, 2009, 2010 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
@ -34,6 +34,19 @@
#include <cstddef>
#include <bits/concept_check.h>
_GLIBCXX_BEGIN_NAMESPACE(std)
// Used, in C++03 mode too, by allocators, etc.
template<typename _Tp>
inline _Tp*
__addressof(_Tp& __r)
{
return reinterpret_cast<_Tp*>
(&const_cast<char&>(reinterpret_cast<const volatile char&>(__r)));
}
_GLIBCXX_END_NAMESPACE
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <type_traits> // Brings in std::declval too.
@ -83,6 +96,18 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
/// declval, defined in <type_traits>.
/**
* @brief Returns the actual address of the object or function
* referenced by r, even in the presence of an overloaded
* operator&.
* @param __r Reference to an object or function.
* @return The actual address.
*/
template<typename _Tp>
inline _Tp*
addressof(_Tp& __r)
{ return std::__addressof(__r); }
_GLIBCXX_END_NAMESPACE
#define _GLIBCXX_MOVE(_Tp) std::move(_Tp)

View File

@ -1,6 +1,7 @@
// nonstandard construct and destroy functions -*- C++ -*-
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
// 2009, 2010
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@ -96,7 +97,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__destroy(_ForwardIterator __first, _ForwardIterator __last)
{
for (; __first != __last; ++__first)
std::_Destroy(&*__first);
std::_Destroy(std::__addressof(*__first));
}
};
@ -137,7 +138,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_Allocator& __alloc)
{
for (; __first != __last; ++__first)
__alloc.destroy(&*__first);
__alloc.destroy(std::__addressof(*__first));
}
template<typename _ForwardIterator, typename _Tp>

View File

@ -128,14 +128,14 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
_List_iterator(_List_node_base* __x)
: _M_node(__x) { }
// Must downcast from List_node_base to _List_node to get to _M_data.
// Must downcast from _List_node_base to _List_node to get to _M_data.
reference
operator*() const
{ return static_cast<_Node*>(_M_node)->_M_data; }
pointer
operator->() const
{ return &static_cast<_Node*>(_M_node)->_M_data; }
{ return std::__addressof(static_cast<_Node*>(_M_node)->_M_data); }
_Self&
operator++()
@ -215,7 +215,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
pointer
operator->() const
{ return &static_cast<_Node*>(_M_node)->_M_data; }
{ return std::__addressof(static_cast<_Node*>(_M_node)->_M_data); }
_Self&
operator++()
@ -461,7 +461,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
_Node* __p = this->_M_get_node();
__try
{
_M_get_Tp_allocator().construct(&__p->_M_data, __x);
_M_get_Tp_allocator().construct
(std::__addressof(__p->_M_data), __x);
}
__catch(...)
{
@ -1453,7 +1454,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
#ifdef __GXX_EXPERIMENTAL_CXX0X__
_M_get_Node_allocator().destroy(__n);
#else
_M_get_Tp_allocator().destroy(&__n->_M_data);
_M_get_Tp_allocator().destroy(std::__addressof(__n->_M_data));
#endif
_M_put_node(__n);
}

View File

@ -1,6 +1,7 @@
// RB tree implementation -*- C++ -*-
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
// 2009, 2010
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@ -176,7 +177,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
pointer
operator->() const
{ return &static_cast<_Link_type>(_M_node)->_M_value_field; }
{ return std::__addressof(static_cast<_Link_type>
(_M_node)->_M_value_field); }
_Self&
operator++()
@ -251,7 +253,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
pointer
operator->() const
{ return &static_cast<_Link_type>(_M_node)->_M_value_field; }
{ return std::__addressof(static_cast<_Link_type>
(_M_node)->_M_value_field); }
_Self&
operator++()
@ -368,7 +371,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
{
_Link_type __tmp = _M_get_node();
__try
{ get_allocator().construct(&__tmp->_M_value_field, __x); }
{ get_allocator().construct
(std::__addressof(__tmp->_M_value_field), __x); }
__catch(...)
{
_M_put_node(__tmp);
@ -380,7 +384,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
void
_M_destroy_node(_Link_type __p)
{
get_allocator().destroy(&__p->_M_value_field);
get_allocator().destroy(std::__addressof(__p->_M_value_field));
_M_put_node(__p);
}
#else

View File

@ -1,6 +1,7 @@
// Raw memory manipulators -*- C++ -*-
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
// 2009, 2010
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@ -71,7 +72,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__try
{
for (; __first != __last; ++__first, ++__cur)
std::_Construct(&*__cur, *__first);
std::_Construct(std::__addressof(*__cur), *__first);
return __cur;
}
__catch(...)
@ -129,7 +130,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__try
{
for (; __cur != __last; ++__cur)
std::_Construct(&*__cur, __x);
std::_Construct(std::__addressof(*__cur), __x);
}
__catch(...)
{
@ -185,11 +186,13 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
_ForwardIterator __cur = __first;
__try
{
std::_Construct(&*__first, _GLIBCXX_MOVE(__value));
std::_Construct(std::__addressof(*__first),
_GLIBCXX_MOVE(__value));
_ForwardIterator __prev = __cur;
++__cur;
for(; __cur != __last; ++__cur, ++__prev)
std::_Construct(&*__cur, _GLIBCXX_MOVE(*__prev));
std::_Construct(std::__addressof(*__cur),
_GLIBCXX_MOVE(*__prev));
__value = _GLIBCXX_MOVE(*__prev);
}
__catch(...)
@ -245,7 +248,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__try
{
for (; __n > 0; --__n, ++__cur)
std::_Construct(&*__cur, __x);
std::_Construct(std::__addressof(*__cur), __x);
}
__catch(...)
{
@ -301,7 +304,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__try
{
for (; __first != __last; ++__first, ++__cur)
__alloc.construct(&*__cur, *__first);
__alloc.construct(std::__addressof(*__cur), *__first);
return __cur;
}
__catch(...)
@ -337,7 +340,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__try
{
for (; __cur != __last; ++__cur)
__alloc.construct(&*__cur, __x);
__alloc.construct(std::__addressof(*__cur), __x);
}
__catch(...)
{
@ -362,7 +365,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__try
{
for (; __n > 0; --__n, ++__cur)
__alloc.construct(&*__cur, __x);
__alloc.construct(std::__addressof(*__cur), __x);
}
__catch(...)
{
@ -498,7 +501,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
__try
{
for (; __n > 0; --__n, ++__first, ++__cur)
::new(static_cast<void*>(&*__cur)) typename
::new(static_cast<void*>(std::__addressof(*__cur))) typename
iterator_traits<_ForwardIterator>::value_type(*__first);
return __cur;
}

View File

@ -1,6 +1,6 @@
// array allocator -*- C++ -*-
// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@ -55,10 +55,10 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
typedef _Tp value_type;
pointer
address(reference __x) const { return &__x; }
address(reference __x) const { return std::__addressof(__x); }
const_pointer
address(const_reference __x) const { return &__x; }
address(const_reference __x) const { return std::__addressof(__x); }
void
deallocate(pointer, size_type)

View File

@ -1,6 +1,6 @@
// Bitmap Allocator. -*- C++ -*-
// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009
// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@ -1039,11 +1039,11 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
pointer
address(reference __r) const
{ return &__r; }
{ return std::__addressof(__r); }
const_pointer
address(const_reference __r) const
{ return &__r; }
{ return std::__addressof(__r); }
size_type
max_size() const throw()

View File

@ -1,6 +1,6 @@
// <extptr_allocator.h> -*- C++ -*-
// Copyright (C) 2008, 2009 Free Software Foundation, Inc.
// Copyright (C) 2008, 2009, 2010 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
@ -82,10 +82,10 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
{ }
pointer address(reference __x) const
{ return &__x; }
{ return std::__addressof(__x); }
const_pointer address(const_reference __x) const
{ return &__x; }
{ return std::__addressof(__x); }
pointer allocate(size_type __n, void* __hint = 0)
{ return _M_real_alloc.allocate(__n,__hint); }

View File

@ -1,6 +1,6 @@
// Allocator that wraps "C" malloc -*- C++ -*-
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@ -74,10 +74,10 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
~malloc_allocator() throw() { }
pointer
address(reference __x) const { return &__x; }
address(reference __x) const { return std::__addressof(__x); }
const_pointer
address(const_reference __x) const { return &__x; }
address(const_reference __x) const { return std::__addressof(__x); }
// NB: __n is permitted to be 0. The C++ standard says nothing
// about what the return value is when __n == 0.

View File

@ -576,11 +576,11 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
pointer
address(reference __x) const
{ return &__x; }
{ return std::__addressof(__x); }
const_pointer
address(const_reference __x) const
{ return &__x; }
{ return std::__addressof(__x); }
size_type
max_size() const throw()

View File

@ -1,6 +1,6 @@
// Allocator that wraps operator new -*- C++ -*-
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2009
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2009, 2010
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@ -73,10 +73,10 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
~new_allocator() throw() { }
pointer
address(reference __x) const { return &__x; }
address(reference __x) const { return std::__addressof(__x); }
const_pointer
address(const_reference __x) const { return &__x; }
address(const_reference __x) const { return std::__addressof(__x); }
// NB: __n is permitted to be 0. The C++ standard says nothing
// about what the return value is when __n == 0.

View File

@ -1,6 +1,6 @@
// Allocators -*- C++ -*-
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@ -147,10 +147,10 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
~__pool_alloc() throw() { }
pointer
address(reference __x) const { return &__x; }
address(reference __x) const { return std::__addressof(__x); }
const_pointer
address(const_reference __x) const { return &__x; }
address(const_reference __x) const { return std::__addressof(__x); }
size_type
max_size() const throw()

View File

@ -619,6 +619,12 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
max_size() const throw()
{ return _M_allocator.max_size(); }
pointer
address(reference __x) const { return std::__addressof(__x); }
const_pointer
address(const_reference __x) const { return std::__addressof(__x); }
pointer
allocate(size_type __n, std::allocator<void>::const_pointer hint = 0)
{

View File

@ -390,7 +390,8 @@ namespace std
public:
typedef _Tp type;
reference_wrapper(_Tp& __indata): _M_data(&__indata)
reference_wrapper(_Tp& __indata)
: _M_data(std::__addressof(__indata))
{ }
reference_wrapper(_Tp&&) = delete;

View File

@ -83,19 +83,19 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
// Iterators.
iterator
begin()
{ return iterator(&_M_instance[0]); }
{ return iterator(std::__addressof(_M_instance[0])); }
const_iterator
begin() const
{ return const_iterator(&_M_instance[0]); }
{ return const_iterator(std::__addressof(_M_instance[0])); }
iterator
end()
{ return iterator(&_M_instance[_Nm]); }
{ return iterator(std::__addressof(_M_instance[_Nm])); }
const_iterator
end() const
{ return const_iterator(&_M_instance[_Nm]); }
{ return const_iterator(std::__addressof(_M_instance[_Nm])); }
reverse_iterator
rbegin()
@ -116,11 +116,11 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
#ifdef _GLIBCXX_INCLUDE_AS_CXX0X
const_iterator
cbegin() const
{ return const_iterator(&_M_instance[0]); }
{ return const_iterator(std::__addressof(_M_instance[0])); }
const_iterator
cend() const
{ return const_iterator(&_M_instance[_Nm]); }
{ return const_iterator(std::__addressof(_M_instance[_Nm])); }
const_reverse_iterator
crbegin() const
@ -182,13 +182,13 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
back() const
{ return _Nm ? *(end() - 1) : *end(); }
_Tp*
_Tp*
data()
{ return &_M_instance[0]; }
{ return std::__addressof(_M_instance[0]); }
const _Tp*
const _Tp*
data() const
{ return &_M_instance[0]; }
{ return std::__addressof(_M_instance[0]); }
};
// Array comparisons.

View File

@ -0,0 +1,51 @@
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com>
// Copyright (C) 2010 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 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <memory>
#include <testsuite_hooks.h>
#include <testsuite_api.h>
void f1(int) { }
void test01()
{
bool test __attribute__((unused)) = true;
using namespace __gnu_test;
OverloadedAddress* ao1 = new OverloadedAddress();
OverloadedAddress& o1 = *ao1;
VERIFY( std::addressof(o1) == ao1 );
const OverloadedAddress* ao2 = new OverloadedAddress();
const OverloadedAddress& o2 = *ao2;
VERIFY( std::addressof(o2) == ao2 );
VERIFY( std::addressof(f1) == &f1 );
}
int main()
{
test01();
return 0;
}

View File

@ -0,0 +1,31 @@
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com>
// Copyright (C) 2010 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 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// NB: This file is for testing utility with NO OTHER INCLUDES.
#include <memory>
namespace std
{
typedef short test_type;
template short* addressof(short&);
}

View File

@ -0,0 +1,34 @@
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com>
// Copyright (C) 2010 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 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <functional>
#include <testsuite_hooks.h>
#include <testsuite_api.h>
// libstdc++/41792
void test01()
{
using namespace __gnu_test;
OverloadedAddress* ao1 = new OverloadedAddress();
std::reference_wrapper<OverloadedAddress> rw1(*ao1);
}

View File

@ -0,0 +1,30 @@
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2010 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 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// This file tests explicit instantiation of library containers
#include <array>
#include <testsuite_hooks.h>
#include <testsuite_api.h>
// libstdc++/41792
template class std::array<__gnu_test::OverloadedAddress, 3>;

View File

@ -0,0 +1,30 @@
// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2010 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 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// This file tests explicit instantiation of library containers
#include <deque>
#include <testsuite_hooks.h>
#include <testsuite_api.h>
// { dg-do compile }
// libstdc++/41792
template class std::deque<__gnu_test::OverloadedAddress>;

View File

@ -1,6 +1,6 @@
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
// { dg-error "no matching" "" { target *-*-* } 1194 }
// { dg-error "no matching" "" { target *-*-* } 1196 }
// { dg-excess-errors "" }
// Copyright (C) 2009, 2010 Free Software Foundation

View File

@ -1,6 +1,6 @@
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
// { dg-error "no matching" "" { target *-*-* } 1194 }
// { dg-error "no matching" "" { target *-*-* } 1196 }
// { dg-excess-errors "" }
// Copyright (C) 2009, 2010 Free Software Foundation

View File

@ -1,6 +1,6 @@
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
// { dg-error "no matching" "" { target *-*-* } 1194 }
// { dg-error "no matching" "" { target *-*-* } 1196 }
// { dg-excess-errors "" }
// Copyright (C) 2009, 2010 Free Software Foundation

View File

@ -1,6 +1,6 @@
// { dg-do compile }
// { dg-options "-std=gnu++0x" }
// { dg-error "no matching" "" { target *-*-* } 1194 }
// { dg-error "no matching" "" { target *-*-* } 1196 }
// { dg-excess-errors "" }
// Copyright (C) 2009, 2010 Free Software Foundation

View File

@ -0,0 +1,32 @@
// { dg-options "-std=gnu++0x" }
// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2010 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 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// This file tests explicit instantiation of library containers
#include <forward_list>
#include <testsuite_hooks.h>
#include <testsuite_api.h>
// { dg-do compile }
// libstdc++/41792
template class std::forward_list<__gnu_test::OverloadedAddress>;

View File

@ -18,7 +18,7 @@
// <http://www.gnu.org/licenses/>.
// { dg-do compile }
// { dg-error "no matching" "" { target *-*-* } 1410 }
// { dg-error "no matching" "" { target *-*-* } 1411 }
// { dg-excess-errors "" }
#include <list>

View File

@ -1,6 +1,6 @@
// 2007-04-27 Paolo Carlini <pcarlini@suse.de>
// Copyright (C) 2007, 2008, 2009 Free Software Foundation
// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation
//
// 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
@ -18,7 +18,7 @@
// <http://www.gnu.org/licenses/>.
// { dg-do compile }
// { dg-error "no matching" "" { target *-*-* } 1379 }
// { dg-error "no matching" "" { target *-*-* } 1380 }
// { dg-excess-errors "" }
#include <list>

View File

@ -18,7 +18,7 @@
// <http://www.gnu.org/licenses/>.
// { dg-do compile }
// { dg-error "no matching" "" { target *-*-* } 1379 }
// { dg-error "no matching" "" { target *-*-* } 1380 }
// { dg-excess-errors "" }
#include <list>

View File

@ -18,7 +18,7 @@
// <http://www.gnu.org/licenses/>.
// { dg-do compile }
// { dg-error "no matching" "" { target *-*-* } 1379 }
// { dg-error "no matching" "" { target *-*-* } 1380 }
// { dg-excess-errors "" }
#include <list>

View File

@ -0,0 +1,29 @@
// Copyright (C) 2010 Free Software Foundation, Inc.
// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com>
//
// 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 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// This file tests explicit instantiation of library containers
#include <list>
#include <testsuite_hooks.h>
#include <testsuite_api.h>
// { dg-do compile }
// libstdc++/41792
template class std::list<__gnu_test::OverloadedAddress>;

View File

@ -0,0 +1,30 @@
// Copyright (C) 2010 Free Software Foundation, Inc.
// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com>
//
// 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 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// This file tests explicit instantiation of library containers
#include <map>
#include <testsuite_hooks.h>
#include <testsuite_api.h>
// { dg-do compile }
// libstdc++/41792
template class std::map<__gnu_test::OverloadedAddress,
__gnu_test::OverloadedAddress>;

View File

@ -0,0 +1,30 @@
// Copyright (C) 2010 Free Software Foundation, Inc.
// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com>
//
// 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 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// This file tests explicit instantiation of library containers
#include <map>
#include <testsuite_hooks.h>
#include <testsuite_api.h>
// { dg-do compile }
// libstdc++/41792
template class std::multimap<__gnu_test::OverloadedAddress,
__gnu_test::OverloadedAddress>;

View File

@ -0,0 +1,29 @@
// Copyright (C) 2010 Free Software Foundation, Inc.
// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com>
//
// 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 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// This file tests explicit instantiation of library containers
#include <set>
#include <testsuite_hooks.h>
#include <testsuite_api.h>
// { dg-do compile }
// libstdc++/41792
template class std::multiset<__gnu_test::OverloadedAddress>;

View File

@ -0,0 +1,29 @@
// Copyright (C) 2010 Free Software Foundation, Inc.
// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com>
//
// 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 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// This file tests explicit instantiation of library containers
#include <set>
#include <testsuite_hooks.h>
#include <testsuite_api.h>
// { dg-do compile }
// libstdc++/41792
template class std::set<__gnu_test::OverloadedAddress>;

View File

@ -0,0 +1,33 @@
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2010 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 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// This file tests explicit instantiation of library containers
#include <unordered_map>
#include <testsuite_hooks.h>
#include <testsuite_api.h>
typedef __gnu_test::OverloadedAddress inst_type;
typedef __gnu_test::OverloadedAddress_hash hash_type;
// libstdc++/41792
template class std::unordered_map<inst_type, inst_type, hash_type>;

View File

@ -0,0 +1,33 @@
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2010 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 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// This file tests explicit instantiation of library containers
#include <unordered_map>
#include <testsuite_hooks.h>
#include <testsuite_api.h>
typedef __gnu_test::OverloadedAddress inst_type;
typedef __gnu_test::OverloadedAddress_hash hash_type;
// libstdc++/41792
template class std::unordered_multimap<inst_type, inst_type, hash_type>;

View File

@ -0,0 +1,33 @@
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2010 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 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// This file tests explicit instantiation of library containers
#include <unordered_set>
#include <testsuite_hooks.h>
#include <testsuite_api.h>
typedef __gnu_test::OverloadedAddress inst_type;
typedef __gnu_test::OverloadedAddress_hash hash_type;
// libstdc++/41792
template class std::unordered_multiset<inst_type, hash_type>;

View File

@ -0,0 +1,33 @@
// { dg-options "-std=gnu++0x" }
// { dg-do compile }
// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2010 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 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// This file tests explicit instantiation of library containers
#include <unordered_set>
#include <testsuite_hooks.h>
#include <testsuite_api.h>
typedef __gnu_test::OverloadedAddress inst_type;
typedef __gnu_test::OverloadedAddress_hash hash_type;
// libstdc++/41792
template class std::unordered_set<inst_type, hash_type>;

View File

@ -0,0 +1,29 @@
// 2010-05-20 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2010 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 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 COPYING3. If not see
// <http://www.gnu.org/licenses/>.
// This file tests explicit instantiation of library containers
#include <vector>
#include <testsuite_hooks.h>
#include <testsuite_api.h>
// { dg-do compile }
// libstdc++/41792
template class std::vector<__gnu_test::OverloadedAddress>;

View File

@ -1,7 +1,7 @@
// -*- C++ -*-
// Exception testing utils for the C++ library testsuite.
//
// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
// Copyright (C) 2007, 2008, 2009, 2010 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
@ -150,6 +150,30 @@ namespace __gnu_test
operator()() const
{ return result_type(2); }
};
// For std::addressof, etc.
struct OverloadedAddressAux { };
struct OverloadedAddress
{
OverloadedAddressAux
operator&() const { return OverloadedAddressAux(); }
};
inline bool
operator<(const OverloadedAddress&, const OverloadedAddress&)
{ return false; }
inline bool
operator==(const OverloadedAddress&, const OverloadedAddress&)
{ return false; }
struct OverloadedAddress_hash
{
size_t
operator()(const OverloadedAddress&) const
{ return 1; }
};
}
#endif