mirror of git://gcc.gnu.org/git/gcc.git
macros.h (__glibcxx_check_can_increment_range): New.
2018-06-12 François Dumont <fdumont@gcc.gnu.org> * include/debug/macros.h (__glibcxx_check_can_increment_range): New. (__glibcxx_check_can_decrement_range): New. * include/debug/debug.h (__glibcxx_requires_can_increment_range): New. (__glibcxx_requires_can_decrement_range): New. * include/bits/stl_algobase.h (std::copy(_II, _II, _OI)): Use __glibcxx_requires_can_increment_range. (std::move(_II, _II, _OI)): Likewise. (std::copy_backward(_BI, _BI, _BI2)): Use __glibcxx_requires_can_decrement_range. (std::move_backward(_BI, _BI, _BI2)): Likewise. * testsuite/25_algorithms/copy_backward/debug/1_neg.cc: New. * testsuite/25_algorithms/copy_backward/debug/2_neg.cc: New. * testsuite/25_algorithms/copy_backward/debug/3_neg.cc: New. * testsuite/25_algorithms/equal/debug/1_neg.cc: New. * testsuite/25_algorithms/equal/debug/2_neg.cc: New. * testsuite/25_algorithms/equal/debug/3_neg.cc: New. From-SVN: r261525
This commit is contained in:
parent
dd9db6f897
commit
84a9d3b6c1
|
|
@ -1,3 +1,22 @@
|
||||||
|
2018-06-12 François Dumont <fdumont@gcc.gnu.org>
|
||||||
|
|
||||||
|
* include/debug/macros.h (__glibcxx_check_can_increment_range): New.
|
||||||
|
(__glibcxx_check_can_decrement_range): New.
|
||||||
|
* include/debug/debug.h (__glibcxx_requires_can_increment_range): New.
|
||||||
|
(__glibcxx_requires_can_decrement_range): New.
|
||||||
|
* include/bits/stl_algobase.h (std::copy(_II, _II, _OI)): Use
|
||||||
|
__glibcxx_requires_can_increment_range.
|
||||||
|
(std::move(_II, _II, _OI)): Likewise.
|
||||||
|
(std::copy_backward(_BI, _BI, _BI2)): Use
|
||||||
|
__glibcxx_requires_can_decrement_range.
|
||||||
|
(std::move_backward(_BI, _BI, _BI2)): Likewise.
|
||||||
|
* testsuite/25_algorithms/copy_backward/debug/1_neg.cc: New.
|
||||||
|
* testsuite/25_algorithms/copy_backward/debug/2_neg.cc: New.
|
||||||
|
* testsuite/25_algorithms/copy_backward/debug/3_neg.cc: New.
|
||||||
|
* testsuite/25_algorithms/equal/debug/1_neg.cc: New.
|
||||||
|
* testsuite/25_algorithms/equal/debug/2_neg.cc: New.
|
||||||
|
* testsuite/25_algorithms/equal/debug/3_neg.cc: New.
|
||||||
|
|
||||||
2018-06-12 Jonathan Wakely <jwakely@redhat.com>
|
2018-06-12 Jonathan Wakely <jwakely@redhat.com>
|
||||||
|
|
||||||
P0935R0 Eradicating unnecessarily explicit default constructors
|
P0935R0 Eradicating unnecessarily explicit default constructors
|
||||||
|
|
|
||||||
|
|
@ -449,11 +449,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
__glibcxx_function_requires(_InputIteratorConcept<_II>)
|
__glibcxx_function_requires(_InputIteratorConcept<_II>)
|
||||||
__glibcxx_function_requires(_OutputIteratorConcept<_OI,
|
__glibcxx_function_requires(_OutputIteratorConcept<_OI,
|
||||||
typename iterator_traits<_II>::value_type>)
|
typename iterator_traits<_II>::value_type>)
|
||||||
__glibcxx_requires_valid_range(__first, __last);
|
__glibcxx_requires_can_increment_range(__first, __last, __result);
|
||||||
|
|
||||||
return (std::__copy_move_a2<__is_move_iterator<_II>::__value>
|
return std::__copy_move_a2<__is_move_iterator<_II>::__value>
|
||||||
(std::__miter_base(__first), std::__miter_base(__last),
|
(std::__miter_base(__first), std::__miter_base(__last), __result);
|
||||||
__result));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
|
|
@ -482,7 +481,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
__glibcxx_function_requires(_InputIteratorConcept<_II>)
|
__glibcxx_function_requires(_InputIteratorConcept<_II>)
|
||||||
__glibcxx_function_requires(_OutputIteratorConcept<_OI,
|
__glibcxx_function_requires(_OutputIteratorConcept<_OI,
|
||||||
typename iterator_traits<_II>::value_type>)
|
typename iterator_traits<_II>::value_type>)
|
||||||
__glibcxx_requires_valid_range(__first, __last);
|
__glibcxx_requires_can_increment_range(__first, __last, __result);
|
||||||
|
|
||||||
return std::__copy_move_a2<true>(std::__miter_base(__first),
|
return std::__copy_move_a2<true>(std::__miter_base(__first),
|
||||||
std::__miter_base(__last), __result);
|
std::__miter_base(__last), __result);
|
||||||
|
|
@ -627,11 +626,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
__glibcxx_function_requires(_ConvertibleConcept<
|
__glibcxx_function_requires(_ConvertibleConcept<
|
||||||
typename iterator_traits<_BI1>::value_type,
|
typename iterator_traits<_BI1>::value_type,
|
||||||
typename iterator_traits<_BI2>::value_type>)
|
typename iterator_traits<_BI2>::value_type>)
|
||||||
__glibcxx_requires_valid_range(__first, __last);
|
__glibcxx_requires_can_decrement_range(__first, __last, __result);
|
||||||
|
|
||||||
return (std::__copy_move_backward_a2<__is_move_iterator<_BI1>::__value>
|
return std::__copy_move_backward_a2<__is_move_iterator<_BI1>::__value>
|
||||||
(std::__miter_base(__first), std::__miter_base(__last),
|
(std::__miter_base(__first), std::__miter_base(__last), __result);
|
||||||
__result));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
|
|
@ -663,7 +661,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
||||||
__glibcxx_function_requires(_ConvertibleConcept<
|
__glibcxx_function_requires(_ConvertibleConcept<
|
||||||
typename iterator_traits<_BI1>::value_type,
|
typename iterator_traits<_BI1>::value_type,
|
||||||
typename iterator_traits<_BI2>::value_type>)
|
typename iterator_traits<_BI2>::value_type>)
|
||||||
__glibcxx_requires_valid_range(__first, __last);
|
__glibcxx_requires_can_decrement_range(__first, __last, __result);
|
||||||
|
|
||||||
return std::__copy_move_backward_a2<true>(std::__miter_base(__first),
|
return std::__copy_move_backward_a2<true>(std::__miter_base(__first),
|
||||||
std::__miter_base(__last),
|
std::__miter_base(__last),
|
||||||
|
|
|
||||||
|
|
@ -38,12 +38,15 @@
|
||||||
* the user error and where the error is reported.
|
* the user error and where the error is reported.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
#define _GLIBCXX_DEBUG_VERIFY_COND_AT(_Cond,_ErrMsg,_File,_Line,_Func) \
|
||||||
|
if (! (_Cond)) \
|
||||||
|
__gnu_debug::_Error_formatter::_S_at(_File, _Line, _Func) \
|
||||||
|
._ErrMsg._M_error()
|
||||||
|
|
||||||
#define _GLIBCXX_DEBUG_VERIFY_AT_F(_Cond,_ErrMsg,_File,_Line,_Func) \
|
#define _GLIBCXX_DEBUG_VERIFY_AT_F(_Cond,_ErrMsg,_File,_Line,_Func) \
|
||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
if (! (_Cond)) \
|
_GLIBCXX_DEBUG_VERIFY_COND_AT(_Cond,_ErrMsg,_File,_Line,_Func); \
|
||||||
__gnu_debug::_Error_formatter::_S_at(_File, _Line, _Func) \
|
|
||||||
._ErrMsg._M_error(); \
|
|
||||||
} while (false)
|
} while (false)
|
||||||
|
|
||||||
#define _GLIBCXX_DEBUG_VERIFY_AT(_Cond,_ErrMsg,_File,_Line) \
|
#define _GLIBCXX_DEBUG_VERIFY_AT(_Cond,_ErrMsg,_File,_Line) \
|
||||||
|
|
@ -84,6 +87,42 @@ _GLIBCXX_DEBUG_VERIFY(_First != _Last, \
|
||||||
._M_iterator(_First, #_First) \
|
._M_iterator(_First, #_First) \
|
||||||
._M_iterator(_Last, #_Last))
|
._M_iterator(_Last, #_Last))
|
||||||
|
|
||||||
|
#define __glibcxx_check_can_increment_range(_First1,_Last1,_First2) \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
|
typename __gnu_debug::_Distance_traits<__decltype(_First1)>::__type __dist;\
|
||||||
|
_GLIBCXX_DEBUG_VERIFY_COND_AT( \
|
||||||
|
__gnu_debug::__valid_range(_First1, _Last1, __dist),\
|
||||||
|
_M_message(__gnu_debug::__msg_valid_range) \
|
||||||
|
._M_iterator(_First1, #_First1) \
|
||||||
|
._M_iterator(_Last1, #_Last1), \
|
||||||
|
__FILE__,__LINE__,__PRETTY_FUNCTION__); \
|
||||||
|
_GLIBCXX_DEBUG_VERIFY_COND_AT( \
|
||||||
|
__gnu_debug::__can_advance(_First2, __dist.first),\
|
||||||
|
_M_message(__gnu_debug::__msg_iter_subscript_oob)\
|
||||||
|
._M_iterator(_First2, #_First2) \
|
||||||
|
._M_integer(__dist.first), \
|
||||||
|
__FILE__,__LINE__,__PRETTY_FUNCTION__); \
|
||||||
|
} while(false)
|
||||||
|
|
||||||
|
#define __glibcxx_check_can_decrement_range(_First1,_Last1,_First2) \
|
||||||
|
do \
|
||||||
|
{ \
|
||||||
|
typename __gnu_debug::_Distance_traits<__decltype(_First1)>::__type __dist;\
|
||||||
|
_GLIBCXX_DEBUG_VERIFY_COND_AT( \
|
||||||
|
__gnu_debug::__valid_range(_First1, _Last1, __dist),\
|
||||||
|
_M_message(__gnu_debug::__msg_valid_range) \
|
||||||
|
._M_iterator(_First1, #_First1) \
|
||||||
|
._M_iterator(_Last1, #_Last1), \
|
||||||
|
__FILE__,__LINE__,__PRETTY_FUNCTION__); \
|
||||||
|
_GLIBCXX_DEBUG_VERIFY_COND_AT( \
|
||||||
|
__gnu_debug::__can_advance(_First2, -__dist.first),\
|
||||||
|
_M_message(__gnu_debug::__msg_iter_subscript_oob)\
|
||||||
|
._M_iterator(_First2, #_First2) \
|
||||||
|
._M_integer(-__dist.first), \
|
||||||
|
__FILE__,__LINE__,__PRETTY_FUNCTION__); \
|
||||||
|
} while(false)
|
||||||
|
|
||||||
/** Verify that we can insert into *this with the iterator _Position.
|
/** Verify that we can insert into *this with the iterator _Position.
|
||||||
* Insertion into a container at a specific position requires that
|
* Insertion into a container at a specific position requires that
|
||||||
* the iterator be nonsingular, either dereferenceable or past-the-end,
|
* the iterator be nonsingular, either dereferenceable or past-the-end,
|
||||||
|
|
@ -145,7 +184,7 @@ _GLIBCXX_DEBUG_VERIFY(__gnu_debug::__foreign_iterator(_Position,_First,_Last),\
|
||||||
* _Safe_sequence and the _Position iterator is a _Safe_iterator.
|
* _Safe_sequence and the _Position iterator is a _Safe_iterator.
|
||||||
*/
|
*/
|
||||||
#define __glibcxx_check_insert_range_after(_Position,_First,_Last,_Dist)\
|
#define __glibcxx_check_insert_range_after(_Position,_First,_Last,_Dist)\
|
||||||
__glibcxx_check_valid_range2(_First,_Last,_Dist); \
|
__glibcxx_check_valid_range2(_First,_Last,_Dist); \
|
||||||
__glibcxx_check_insert_after(_Position); \
|
__glibcxx_check_insert_after(_Position); \
|
||||||
_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__foreign_iterator(_Position,_First,_Last),\
|
_GLIBCXX_DEBUG_VERIFY(__gnu_debug::__foreign_iterator(_Position,_First,_Last),\
|
||||||
_M_message(__gnu_debug::__msg_insert_range_from_self)\
|
_M_message(__gnu_debug::__msg_insert_range_from_self)\
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
// Copyright (C) 2018 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/>.
|
||||||
|
|
||||||
|
// { dg-do run { xfail *-*-* } }
|
||||||
|
// { dg-require-debug-mode "" }
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
void
|
||||||
|
test01()
|
||||||
|
{
|
||||||
|
std::vector<int> vect;
|
||||||
|
vect.push_back(1);
|
||||||
|
std::copy_backward(vect.end(), vect.begin(), vect.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
test01();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
// Copyright (C) 2018 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/>.
|
||||||
|
|
||||||
|
// { dg-do run { xfail *-*-* } }
|
||||||
|
// { dg-require-debug-mode "" }
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
void
|
||||||
|
test01()
|
||||||
|
{
|
||||||
|
std::vector<int> vect;
|
||||||
|
vect.push_back(1);
|
||||||
|
std::copy_backward(vect.begin(), vect.end(), vect.begin());
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
test01();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
// Copyright (C) 2018 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/>.
|
||||||
|
|
||||||
|
// { dg-do run { xfail *-*-* } }
|
||||||
|
// { dg-require-debug-mode "" }
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <list>
|
||||||
|
|
||||||
|
void
|
||||||
|
test01()
|
||||||
|
{
|
||||||
|
std::list<int> l1, l2;
|
||||||
|
l1.push_back(1);
|
||||||
|
l1.push_back(2);
|
||||||
|
l1.push_back(3);
|
||||||
|
|
||||||
|
l2.push_back(1);
|
||||||
|
std::copy_backward(++l1.begin(), l1.end(), l2.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
test01();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
// Copyright (C) 2018 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/>.
|
||||||
|
|
||||||
|
// { dg-do run { xfail *-*-* } }
|
||||||
|
// { dg-require-debug-mode "" }
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
void
|
||||||
|
test01()
|
||||||
|
{
|
||||||
|
std::vector<int> vect;
|
||||||
|
vect.push_back(1);
|
||||||
|
std::equal(vect.end(), vect.begin(), vect.begin());
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
test01();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
// Copyright (C) 2018 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/>.
|
||||||
|
|
||||||
|
// { dg-do run { xfail *-*-* } }
|
||||||
|
// { dg-require-debug-mode "" }
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
void
|
||||||
|
test01()
|
||||||
|
{
|
||||||
|
std::vector<int> v1, v2;
|
||||||
|
v1.push_back(1);
|
||||||
|
std::equal(v1.begin(), v1.end(), v2.begin());
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
test01();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
// Copyright (C) 2018 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/>.
|
||||||
|
|
||||||
|
// { dg-do run { xfail *-*-* } }
|
||||||
|
// { dg-require-debug-mode "" }
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <list>
|
||||||
|
|
||||||
|
void
|
||||||
|
test01()
|
||||||
|
{
|
||||||
|
std::list<int> l1, l2;
|
||||||
|
l1.push_back(1);
|
||||||
|
l1.push_back(2);
|
||||||
|
l1.push_back(3);
|
||||||
|
|
||||||
|
l2.push_back(1);
|
||||||
|
l2.push_back(2);
|
||||||
|
|
||||||
|
std::equal(++l1.begin(), l1.end(), ++l2.begin());
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
test01();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue