re PR libstdc++/58338 (Add noexcept to functions with a narrow contract)
2013-09-17 Marc Glisse <marc.glisse@inria.fr> PR libstdc++/58338 * include/bits/stl_vector.h (vector::vector(), vector::vector(const allocator_type&)): Merge. (_Vector_impl::_Vector_impl(_Tp_alloc_type const&), _Vector_impl::_Vector_impl(_Tp_alloc_type&&), _Vector_impl::_M_swap_data, _Vector_base::_Vector_base(const allocator_type&), _Vector_base::_Vector_base(allocator_type&&), _Vector_base::_Vector_base(_Vector_base&&), _Vector_base::~_Vector_base, vector::vector(const allocator_type&), vector::operator[], vector::operator[] const, vector::front, vector::front const, vector::back, vector::back const, vector::pop_back, vector::_M_erase_at_end): Mark as noexcept. * include/debug/vector (vector::vector(const _Allocator&), vector::operator[], vector::operator[] const, vector::front, vector::front const, vector::back, vector::back const, vector::pop_back, _M_requires_reallocation, _M_update_guaranteed_capacity, _M_invalidate_after_nth): Mark as noexcept. * include/profile/vector (vector::vector(const _Allocator&), vector::operator[], vector::operator[] const, vector::front, vector::front const, vector::back, vector::back const): Mark as noexcept. (vector::vector(vector&&, const _Allocator&)): Remove wrong noexcept. * testsuite/23_containers/vector/requirements/dr438/assign_neg.cc: Adjust line number. * testsuite/23_containers/vector/requirements/dr438/ constructor_1_neg.cc: Likewise. * testsuite/23_containers/vector/requirements/dr438/ constructor_2_neg.cc: Likewise. * testsuite/23_containers/vector/requirements/dr438/insert_neg.cc: Likewise. From-SVN: r202650
This commit is contained in:
parent
9a0ac98faf
commit
757b16440b
8 changed files with 73 additions and 45 deletions
|
@ -1,3 +1,37 @@
|
|||
2013-09-17 Marc Glisse <marc.glisse@inria.fr>
|
||||
|
||||
PR libstdc++/58338
|
||||
* include/bits/stl_vector.h (vector::vector(),
|
||||
vector::vector(const allocator_type&)): Merge.
|
||||
(_Vector_impl::_Vector_impl(_Tp_alloc_type const&),
|
||||
_Vector_impl::_Vector_impl(_Tp_alloc_type&&),
|
||||
_Vector_impl::_M_swap_data,
|
||||
_Vector_base::_Vector_base(const allocator_type&),
|
||||
_Vector_base::_Vector_base(allocator_type&&),
|
||||
_Vector_base::_Vector_base(_Vector_base&&), _Vector_base::~_Vector_base,
|
||||
vector::vector(const allocator_type&), vector::operator[],
|
||||
vector::operator[] const, vector::front, vector::front const,
|
||||
vector::back, vector::back const, vector::pop_back,
|
||||
vector::_M_erase_at_end): Mark as noexcept.
|
||||
* include/debug/vector (vector::vector(const _Allocator&),
|
||||
vector::operator[], vector::operator[] const, vector::front,
|
||||
vector::front const, vector::back, vector::back const, vector::pop_back,
|
||||
_M_requires_reallocation, _M_update_guaranteed_capacity,
|
||||
_M_invalidate_after_nth): Mark as noexcept.
|
||||
* include/profile/vector (vector::vector(const _Allocator&),
|
||||
vector::operator[], vector::operator[] const, vector::front,
|
||||
vector::front const, vector::back, vector::back const): Mark as
|
||||
noexcept.
|
||||
(vector::vector(vector&&, const _Allocator&)): Remove wrong noexcept.
|
||||
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc:
|
||||
Adjust line number.
|
||||
* testsuite/23_containers/vector/requirements/dr438/
|
||||
constructor_1_neg.cc: Likewise.
|
||||
* testsuite/23_containers/vector/requirements/dr438/
|
||||
constructor_2_neg.cc: Likewise.
|
||||
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc:
|
||||
Likewise.
|
||||
|
||||
2013-09-14 Tim Shen <timshen91@gmail.com>
|
||||
|
||||
* include/bits/regex.h (regex_match<>, regex_search<>):
|
||||
|
|
|
@ -87,18 +87,18 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||
: _Tp_alloc_type(), _M_start(0), _M_finish(0), _M_end_of_storage(0)
|
||||
{ }
|
||||
|
||||
_Vector_impl(_Tp_alloc_type const& __a)
|
||||
_Vector_impl(_Tp_alloc_type const& __a) _GLIBCXX_NOEXCEPT
|
||||
: _Tp_alloc_type(__a), _M_start(0), _M_finish(0), _M_end_of_storage(0)
|
||||
{ }
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
_Vector_impl(_Tp_alloc_type&& __a)
|
||||
_Vector_impl(_Tp_alloc_type&& __a) noexcept
|
||||
: _Tp_alloc_type(std::move(__a)),
|
||||
_M_start(0), _M_finish(0), _M_end_of_storage(0)
|
||||
{ }
|
||||
#endif
|
||||
|
||||
void _M_swap_data(_Vector_impl& __x)
|
||||
void _M_swap_data(_Vector_impl& __x) _GLIBCXX_NOEXCEPT
|
||||
{
|
||||
std::swap(_M_start, __x._M_start);
|
||||
std::swap(_M_finish, __x._M_finish);
|
||||
|
@ -124,7 +124,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||
_Vector_base()
|
||||
: _M_impl() { }
|
||||
|
||||
_Vector_base(const allocator_type& __a)
|
||||
_Vector_base(const allocator_type& __a) _GLIBCXX_NOEXCEPT
|
||||
: _M_impl(__a) { }
|
||||
|
||||
_Vector_base(size_t __n)
|
||||
|
@ -136,10 +136,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||
{ _M_create_storage(__n); }
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
_Vector_base(_Tp_alloc_type&& __a)
|
||||
_Vector_base(_Tp_alloc_type&& __a) noexcept
|
||||
: _M_impl(std::move(__a)) { }
|
||||
|
||||
_Vector_base(_Vector_base&& __x)
|
||||
_Vector_base(_Vector_base&& __x) noexcept
|
||||
: _M_impl(std::move(__x._M_get_Tp_allocator()))
|
||||
{ this->_M_impl._M_swap_data(__x._M_impl); }
|
||||
|
||||
|
@ -156,7 +156,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||
}
|
||||
#endif
|
||||
|
||||
~_Vector_base()
|
||||
~_Vector_base() _GLIBCXX_NOEXCEPT
|
||||
{ _M_deallocate(this->_M_impl._M_start, this->_M_impl._M_end_of_storage
|
||||
- this->_M_impl._M_start); }
|
||||
|
||||
|
@ -242,18 +242,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||
public:
|
||||
// [23.2.4.1] construct/copy/destroy
|
||||
// (assign() and get_allocator() are also listed in this section)
|
||||
/**
|
||||
* @brief Default constructor creates no elements.
|
||||
*/
|
||||
vector()
|
||||
: _Base() { }
|
||||
|
||||
/**
|
||||
* @brief Creates a %vector with no elements.
|
||||
* @param __a An allocator object.
|
||||
*/
|
||||
explicit
|
||||
vector(const allocator_type& __a)
|
||||
vector(const allocator_type& __a = allocator_type()) _GLIBCXX_NOEXCEPT
|
||||
: _Base(__a) { }
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
|
@ -767,7 +761,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||
* see at().)
|
||||
*/
|
||||
reference
|
||||
operator[](size_type __n)
|
||||
operator[](size_type __n) _GLIBCXX_NOEXCEPT
|
||||
{ return *(this->_M_impl._M_start + __n); }
|
||||
|
||||
/**
|
||||
|
@ -782,7 +776,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||
* see at().)
|
||||
*/
|
||||
const_reference
|
||||
operator[](size_type __n) const
|
||||
operator[](size_type __n) const _GLIBCXX_NOEXCEPT
|
||||
{ return *(this->_M_impl._M_start + __n); }
|
||||
|
||||
protected:
|
||||
|
@ -836,7 +830,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||
* element of the %vector.
|
||||
*/
|
||||
reference
|
||||
front()
|
||||
front() _GLIBCXX_NOEXCEPT
|
||||
{ return *begin(); }
|
||||
|
||||
/**
|
||||
|
@ -844,7 +838,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||
* element of the %vector.
|
||||
*/
|
||||
const_reference
|
||||
front() const
|
||||
front() const _GLIBCXX_NOEXCEPT
|
||||
{ return *begin(); }
|
||||
|
||||
/**
|
||||
|
@ -852,7 +846,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||
* element of the %vector.
|
||||
*/
|
||||
reference
|
||||
back()
|
||||
back() _GLIBCXX_NOEXCEPT
|
||||
{ return *(end() - 1); }
|
||||
|
||||
/**
|
||||
|
@ -860,7 +854,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||
* last element of the %vector.
|
||||
*/
|
||||
const_reference
|
||||
back() const
|
||||
back() const _GLIBCXX_NOEXCEPT
|
||||
{ return *(end() - 1); }
|
||||
|
||||
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
||||
|
@ -934,7 +928,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||
* called.
|
||||
*/
|
||||
void
|
||||
pop_back()
|
||||
pop_back() _GLIBCXX_NOEXCEPT
|
||||
{
|
||||
--this->_M_impl._M_finish;
|
||||
_Alloc_traits::destroy(this->_M_impl, this->_M_impl._M_finish);
|
||||
|
@ -1415,7 +1409,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||
// Called by erase(q1,q2), clear(), resize(), _M_fill_assign,
|
||||
// _M_assign_aux.
|
||||
void
|
||||
_M_erase_at_end(pointer __pos)
|
||||
_M_erase_at_end(pointer __pos) _GLIBCXX_NOEXCEPT
|
||||
{
|
||||
std::_Destroy(__pos, this->_M_impl._M_finish, _M_get_Tp_allocator());
|
||||
this->_M_impl._M_finish = __pos;
|
||||
|
|
|
@ -76,7 +76,7 @@ namespace __debug
|
|||
|
||||
// 23.2.4.1 construct/copy/destroy:
|
||||
explicit
|
||||
vector(const _Allocator& __a = _Allocator())
|
||||
vector(const _Allocator& __a = _Allocator()) _GLIBCXX_NOEXCEPT
|
||||
: _Base(__a), _M_guaranteed_capacity(0) { }
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
|
@ -341,14 +341,14 @@ namespace __debug
|
|||
|
||||
// element access:
|
||||
reference
|
||||
operator[](size_type __n)
|
||||
operator[](size_type __n) _GLIBCXX_NOEXCEPT
|
||||
{
|
||||
__glibcxx_check_subscript(__n);
|
||||
return _M_base()[__n];
|
||||
}
|
||||
|
||||
const_reference
|
||||
operator[](size_type __n) const
|
||||
operator[](size_type __n) const _GLIBCXX_NOEXCEPT
|
||||
{
|
||||
__glibcxx_check_subscript(__n);
|
||||
return _M_base()[__n];
|
||||
|
@ -357,28 +357,28 @@ namespace __debug
|
|||
using _Base::at;
|
||||
|
||||
reference
|
||||
front()
|
||||
front() _GLIBCXX_NOEXCEPT
|
||||
{
|
||||
__glibcxx_check_nonempty();
|
||||
return _Base::front();
|
||||
}
|
||||
|
||||
const_reference
|
||||
front() const
|
||||
front() const _GLIBCXX_NOEXCEPT
|
||||
{
|
||||
__glibcxx_check_nonempty();
|
||||
return _Base::front();
|
||||
}
|
||||
|
||||
reference
|
||||
back()
|
||||
back() _GLIBCXX_NOEXCEPT
|
||||
{
|
||||
__glibcxx_check_nonempty();
|
||||
return _Base::back();
|
||||
}
|
||||
|
||||
const_reference
|
||||
back() const
|
||||
back() const _GLIBCXX_NOEXCEPT
|
||||
{
|
||||
__glibcxx_check_nonempty();
|
||||
return _Base::back();
|
||||
|
@ -419,7 +419,7 @@ namespace __debug
|
|||
#endif
|
||||
|
||||
void
|
||||
pop_back()
|
||||
pop_back() _GLIBCXX_NOEXCEPT
|
||||
{
|
||||
__glibcxx_check_nonempty();
|
||||
this->_M_invalidate_if(_Equal(--_Base::end()));
|
||||
|
@ -630,18 +630,18 @@ namespace __debug
|
|||
size_type _M_guaranteed_capacity;
|
||||
|
||||
bool
|
||||
_M_requires_reallocation(size_type __elements)
|
||||
_M_requires_reallocation(size_type __elements) _GLIBCXX_NOEXCEPT
|
||||
{ return __elements > this->capacity(); }
|
||||
|
||||
void
|
||||
_M_update_guaranteed_capacity()
|
||||
_M_update_guaranteed_capacity() _GLIBCXX_NOEXCEPT
|
||||
{
|
||||
if (this->size() > _M_guaranteed_capacity)
|
||||
_M_guaranteed_capacity = this->size();
|
||||
}
|
||||
|
||||
void
|
||||
_M_invalidate_after_nth(difference_type __n)
|
||||
_M_invalidate_after_nth(difference_type __n) _GLIBCXX_NOEXCEPT
|
||||
{
|
||||
typedef __gnu_debug::_After_nth_from<_Base_const_iterator> _After_nth;
|
||||
this->_M_invalidate_if(_After_nth(__n, _Base::begin()));
|
||||
|
|
|
@ -78,7 +78,7 @@ namespace __profile
|
|||
|
||||
// 23.2.4.1 construct/copy/destroy:
|
||||
explicit
|
||||
vector(const _Allocator& __a = _Allocator())
|
||||
vector(const _Allocator& __a = _Allocator()) _GLIBCXX_NOEXCEPT
|
||||
: _Base(__a)
|
||||
{
|
||||
__profcxx_vector_construct(this, this->capacity());
|
||||
|
@ -156,7 +156,7 @@ namespace __profile
|
|||
__profcxx_vector_construct2(this);
|
||||
}
|
||||
|
||||
vector(vector&& __x, const _Allocator& __a) noexcept
|
||||
vector(vector&& __x, const _Allocator& __a)
|
||||
: _Base(std::move(__x), __a)
|
||||
{
|
||||
__profcxx_vector_construct(this, this->capacity());
|
||||
|
@ -292,13 +292,13 @@ namespace __profile
|
|||
|
||||
// element access:
|
||||
reference
|
||||
operator[](size_type __n)
|
||||
operator[](size_type __n) _GLIBCXX_NOEXCEPT
|
||||
{
|
||||
__profcxx_vector_invalid_operator(this);
|
||||
return _M_base()[__n];
|
||||
}
|
||||
const_reference
|
||||
operator[](size_type __n) const
|
||||
operator[](size_type __n) const _GLIBCXX_NOEXCEPT
|
||||
{
|
||||
__profcxx_vector_invalid_operator(this);
|
||||
return _M_base()[__n];
|
||||
|
@ -307,25 +307,25 @@ namespace __profile
|
|||
using _Base::at;
|
||||
|
||||
reference
|
||||
front()
|
||||
front() _GLIBCXX_NOEXCEPT
|
||||
{
|
||||
return _Base::front();
|
||||
}
|
||||
|
||||
const_reference
|
||||
front() const
|
||||
front() const _GLIBCXX_NOEXCEPT
|
||||
{
|
||||
return _Base::front();
|
||||
}
|
||||
|
||||
reference
|
||||
back()
|
||||
back() _GLIBCXX_NOEXCEPT
|
||||
{
|
||||
return _Base::back();
|
||||
}
|
||||
|
||||
const_reference
|
||||
back() const
|
||||
back() const _GLIBCXX_NOEXCEPT
|
||||
{
|
||||
return _Base::back();
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do compile }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1308 }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1302 }
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do compile }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1234 }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1228 }
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do compile }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1234 }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1228 }
|
||||
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
// <http://www.gnu.org/licenses/>.
|
||||
|
||||
// { dg-do compile }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1349 }
|
||||
// { dg-error "no matching" "" { target *-*-* } 1343 }
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue