re PR libstdc++/58338 (Add noexcept to functions with a narrow contract)
authorMarc Glisse <marc.glisse@inria.fr>
Tue, 17 Sep 2013 12:23:54 +0000 (14:23 +0200)
committerMarc Glisse <glisse@gcc.gnu.org>
Tue, 17 Sep 2013 12:23:54 +0000 (12:23 +0000)
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

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/stl_vector.h
libstdc++-v3/include/debug/vector
libstdc++-v3/include/profile/vector
libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc
libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc
libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc
libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc

index 96891056ac7e397400cb8efaf5f52a8b4741abaf..31fa21f0580ce7e0fb532c71b812c2a4df2124cf 100644 (file)
@@ -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<>):
index 726693918a3fadc94e5fecf021eb53d48c220417..03850b5e28f9f7920148c8206d2bc4229854c48e 100644 (file)
@@ -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;
index 7b28177c2a0a9028f367af4c48046a8120d432db..e5b80649b9a7741734c4c17f9b8c963b47bf16b4 100644 (file)
@@ -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()));
index 3ef04ff0a7c5f5c4ede5c4c4ecbe6666c6520177..8f79df7f07c454fc0b5ec9538cfaa9f356d87681 100644 (file)
@@ -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();
       }
index f7353ab325caead9506de1b47b0e7f9d6cb84a3a..388e57182cc46e6ae19d40699370b6fad724a265 100644 (file)
@@ -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>
 
index f404a7009da36bbd2b00a59b0fc95b19dd565b98..68cfab064f8e9e89d9f21b861ce10273a2cc6a73 100644 (file)
@@ -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>
 
index 070295676a543e44cadd9ee8baaf00c8094ab5df..35c03286a26247bf696df24aaece447e91861e5e 100644 (file)
@@ -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>
index 95af05795ce858a78dd6d56e6ce35015c9e533cf..6ab70388b83322dfc2d621dec50c66c8bf04503a 100644 (file)
@@ -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>