Fix testsuite failures for __gnu_debug::string with old ABI
The __gnu_debug string (mostly) implements the C++11 API, but when it wraps the old COW string many of the member functions in the base class have the wrong parameter types or return types. This makes the __gnu_debug::string type adapt itself to the base class API. This actually makes the debug string slightly more conforming than the underlying string type when using the old ABI. * include/bits/basic_string.h [_GLIBCXX_USE_CXX11_ABI] (basic_string::__const_iterator): Change access to protected. [!_GLIBCXX_USE_CXX11_ABI] (basic_string::__const_iterator): Define as typedef for iterator. * include/debug/string (__const_iterator): Use typedef from base. (insert(const_iterator, _CharT)) (replace(const_iterator, const_iterator, const basic_string&)) (replace(const_iterator, const_iterator, const _CharT*, size_type)) (replace(const_iterator, const_iterator, const CharT*)) (replace(const_iterator, const_iterator, size_type, _CharT)) (replace(const_iterator, const_iterator, _InputIter, _InputIter)) (replace(const_iterator, const_iterator, initializer_list<_CharT>)): Change const_iterator parameters to __const_iterator. (insert(iterator, size_type, _CharT)): Add C++98 overload. (insert(const_iterator, _InputIterator, _InputIterator)): Change const_iterator parameter to __const_iterator. [!_GLIBCXX_USE_CXX11_ABI]: Add workaround for incorrect return type of base's member function. (insert(const_iterator, size_type, _CharT)) [!_GLIBCXX_USE_CXX11_ABI]: Likewise. (insert(const_iterator, initializer_list<_CharT>)) [!_GLIBCXX_USE_CXX11_ABI]: Likewise. * testsuite/21_strings/basic_string/init-list.cc: Remove effective target directive. From-SVN: r263808
This commit is contained in:
parent
832c74d935
commit
3eb1eda1c8
|
@ -1,5 +1,30 @@
|
||||||
2018-08-23 Jonathan Wakely <jwakely@redhat.com>
|
2018-08-23 Jonathan Wakely <jwakely@redhat.com>
|
||||||
|
|
||||||
|
* include/bits/basic_string.h [_GLIBCXX_USE_CXX11_ABI]
|
||||||
|
(basic_string::__const_iterator): Change access to protected.
|
||||||
|
[!_GLIBCXX_USE_CXX11_ABI] (basic_string::__const_iterator): Define
|
||||||
|
as typedef for iterator.
|
||||||
|
* include/debug/string (__const_iterator): Use typedef from base.
|
||||||
|
(insert(const_iterator, _CharT))
|
||||||
|
(replace(const_iterator, const_iterator, const basic_string&))
|
||||||
|
(replace(const_iterator, const_iterator, const _CharT*, size_type))
|
||||||
|
(replace(const_iterator, const_iterator, const CharT*))
|
||||||
|
(replace(const_iterator, const_iterator, size_type, _CharT))
|
||||||
|
(replace(const_iterator, const_iterator, _InputIter, _InputIter))
|
||||||
|
(replace(const_iterator, const_iterator, initializer_list<_CharT>)):
|
||||||
|
Change const_iterator parameters to __const_iterator.
|
||||||
|
(insert(iterator, size_type, _CharT)): Add C++98 overload.
|
||||||
|
(insert(const_iterator, _InputIterator, _InputIterator)): Change
|
||||||
|
const_iterator parameter to __const_iterator.
|
||||||
|
[!_GLIBCXX_USE_CXX11_ABI]: Add workaround for incorrect return type
|
||||||
|
of base's member function.
|
||||||
|
(insert(const_iterator, size_type, _CharT)) [!_GLIBCXX_USE_CXX11_ABI]:
|
||||||
|
Likewise.
|
||||||
|
(insert(const_iterator, initializer_list<_CharT>))
|
||||||
|
[!_GLIBCXX_USE_CXX11_ABI]: Likewise.
|
||||||
|
* testsuite/21_strings/basic_string/init-list.cc: Remove effective
|
||||||
|
target directive.
|
||||||
|
|
||||||
* testsuite/20_util/reference_wrapper/lwg2993.cc: Fix C++11 test to
|
* testsuite/20_util/reference_wrapper/lwg2993.cc: Fix C++11 test to
|
||||||
not use C++14 feature.
|
not use C++14 feature.
|
||||||
* testsuite/23_containers/list/68222_neg.cc: Likewise.
|
* testsuite/23_containers/list/68222_neg.cc: Likewise.
|
||||||
|
|
|
@ -100,7 +100,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
|
||||||
/// Value returned by various member functions when they fail.
|
/// Value returned by various member functions when they fail.
|
||||||
static const size_type npos = static_cast<size_type>(-1);
|
static const size_type npos = static_cast<size_type>(-1);
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
// type used for positions in insert, erase etc.
|
// type used for positions in insert, erase etc.
|
||||||
#if __cplusplus < 201103L
|
#if __cplusplus < 201103L
|
||||||
typedef iterator __const_iterator;
|
typedef iterator __const_iterator;
|
||||||
|
@ -108,6 +108,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
|
||||||
typedef const_iterator __const_iterator;
|
typedef const_iterator __const_iterator;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
#if __cplusplus > 201402L
|
#if __cplusplus > 201402L
|
||||||
// A helper type for avoiding boiler-plate.
|
// A helper type for avoiding boiler-plate.
|
||||||
typedef basic_string_view<_CharT, _Traits> __sv_type;
|
typedef basic_string_view<_CharT, _Traits> __sv_type;
|
||||||
|
@ -3119,6 +3120,10 @@ _GLIBCXX_END_NAMESPACE_CXX11
|
||||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// type used for positions in insert, erase etc.
|
||||||
|
typedef iterator __const_iterator;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// _Rep: string representation
|
// _Rep: string representation
|
||||||
// Invariants:
|
// Invariants:
|
||||||
|
|
|
@ -97,6 +97,10 @@ namespace __gnu_debug
|
||||||
template<typename _ItT, typename _SeqT, typename _CatT>
|
template<typename _ItT, typename _SeqT, typename _CatT>
|
||||||
friend class ::__gnu_debug::_Safe_iterator;
|
friend class ::__gnu_debug::_Safe_iterator;
|
||||||
|
|
||||||
|
// type used for positions in insert, erase etc.
|
||||||
|
typedef __gnu_debug::_Safe_iterator<
|
||||||
|
typename _Base::__const_iterator, basic_string> __const_iterator;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// types:
|
// types:
|
||||||
typedef _Traits traits_type;
|
typedef _Traits traits_type;
|
||||||
|
@ -589,7 +593,7 @@ namespace __gnu_debug
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator
|
iterator
|
||||||
insert(const_iterator __p, _CharT __c)
|
insert(__const_iterator __p, _CharT __c)
|
||||||
{
|
{
|
||||||
__glibcxx_check_insert(__p);
|
__glibcxx_check_insert(__p);
|
||||||
typename _Base::iterator __res = _Base::insert(__p.base(), __c);
|
typename _Base::iterator __res = _Base::insert(__p.base(), __c);
|
||||||
|
@ -597,29 +601,51 @@ namespace __gnu_debug
|
||||||
return iterator(__res, this);
|
return iterator(__res, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
iterator
|
iterator
|
||||||
insert(const_iterator __p, size_type __n, _CharT __c)
|
insert(const_iterator __p, size_type __n, _CharT __c)
|
||||||
{
|
{
|
||||||
__glibcxx_check_insert(__p);
|
__glibcxx_check_insert(__p);
|
||||||
|
#if _GLIBCXX_USE_CXX11_ABI
|
||||||
typename _Base::iterator __res = _Base::insert(__p.base(), __n, __c);
|
typename _Base::iterator __res = _Base::insert(__p.base(), __n, __c);
|
||||||
|
#else
|
||||||
|
const size_type __offset = __p.base() - _Base::cbegin();
|
||||||
|
_Base::insert(_Base::begin() + __offset, __n, __c);
|
||||||
|
typename _Base::iterator __res = _Base::begin() + __offset;
|
||||||
|
#endif
|
||||||
this->_M_invalidate_all();
|
this->_M_invalidate_all();
|
||||||
return iterator(__res, this);
|
return iterator(__res, this);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
void
|
||||||
|
insert(iterator __p, size_type __n, _CharT __c)
|
||||||
|
{
|
||||||
|
__glibcxx_check_insert(__p);
|
||||||
|
_Base::insert(__p.base(), __n, __c);
|
||||||
|
this->_M_invalidate_all();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template<typename _InputIterator>
|
template<typename _InputIterator>
|
||||||
iterator
|
iterator
|
||||||
insert(const_iterator __p,
|
insert(__const_iterator __p,
|
||||||
_InputIterator __first, _InputIterator __last)
|
_InputIterator __first, _InputIterator __last)
|
||||||
{
|
{
|
||||||
typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
|
typename __gnu_debug::_Distance_traits<_InputIterator>::__type __dist;
|
||||||
__glibcxx_check_insert_range(__p, __first, __last, __dist);
|
__glibcxx_check_insert_range(__p, __first, __last, __dist);
|
||||||
|
|
||||||
typename _Base::iterator __res;
|
typename _Base::iterator __res;
|
||||||
|
#if _GLIBCXX_USE_CXX11_ABI
|
||||||
if (__dist.second >= __dp_sign)
|
if (__dist.second >= __dp_sign)
|
||||||
__res = _Base::insert(__p.base(), __gnu_debug::__unsafe(__first),
|
__res = _Base::insert(__p.base(), __gnu_debug::__unsafe(__first),
|
||||||
__gnu_debug::__unsafe(__last));
|
__gnu_debug::__unsafe(__last));
|
||||||
else
|
else
|
||||||
__res = _Base::insert(__p.base(), __first, __last);
|
__res = _Base::insert(__p.base(), __first, __last);
|
||||||
|
#else
|
||||||
|
const size_type __offset = __p.base() - _Base::cbegin();
|
||||||
|
_Base::insert(__p.base(), __first, __last);
|
||||||
|
__res = _Base::begin() + __offset;
|
||||||
|
#endif
|
||||||
this->_M_invalidate_all();
|
this->_M_invalidate_all();
|
||||||
return iterator(__res, this);
|
return iterator(__res, this);
|
||||||
}
|
}
|
||||||
|
@ -629,7 +655,13 @@ namespace __gnu_debug
|
||||||
insert(const_iterator __p, std::initializer_list<_CharT> __l)
|
insert(const_iterator __p, std::initializer_list<_CharT> __l)
|
||||||
{
|
{
|
||||||
__glibcxx_check_insert(__p);
|
__glibcxx_check_insert(__p);
|
||||||
|
#if _GLIBCXX_USE_CXX11_ABI
|
||||||
const auto __res = _Base::insert(__p.base(), __l);
|
const auto __res = _Base::insert(__p.base(), __l);
|
||||||
|
#else
|
||||||
|
const size_type __offset = __p.base() - _Base::cbegin();
|
||||||
|
_Base::insert(_Base::begin() + __offset, __l);
|
||||||
|
auto __res = _Base::begin() + __offset;
|
||||||
|
#endif
|
||||||
this->_M_invalidate_all();
|
this->_M_invalidate_all();
|
||||||
return iterator(__res, this);
|
return iterator(__res, this);
|
||||||
}
|
}
|
||||||
|
@ -719,7 +751,8 @@ namespace __gnu_debug
|
||||||
}
|
}
|
||||||
|
|
||||||
basic_string&
|
basic_string&
|
||||||
replace(iterator __i1, iterator __i2, const basic_string& __str)
|
replace(__const_iterator __i1, __const_iterator __i2,
|
||||||
|
const basic_string& __str)
|
||||||
{
|
{
|
||||||
__glibcxx_check_erase_range(__i1, __i2);
|
__glibcxx_check_erase_range(__i1, __i2);
|
||||||
_Base::replace(__i1.base(), __i2.base(), __str);
|
_Base::replace(__i1.base(), __i2.base(), __str);
|
||||||
|
@ -728,7 +761,8 @@ namespace __gnu_debug
|
||||||
}
|
}
|
||||||
|
|
||||||
basic_string&
|
basic_string&
|
||||||
replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n)
|
replace(__const_iterator __i1, __const_iterator __i2,
|
||||||
|
const _CharT* __s, size_type __n)
|
||||||
{
|
{
|
||||||
__glibcxx_check_erase_range(__i1, __i2);
|
__glibcxx_check_erase_range(__i1, __i2);
|
||||||
__glibcxx_check_string_len(__s, __n);
|
__glibcxx_check_string_len(__s, __n);
|
||||||
|
@ -738,7 +772,8 @@ namespace __gnu_debug
|
||||||
}
|
}
|
||||||
|
|
||||||
basic_string&
|
basic_string&
|
||||||
replace(iterator __i1, iterator __i2, const _CharT* __s)
|
replace(__const_iterator __i1, __const_iterator __i2,
|
||||||
|
const _CharT* __s)
|
||||||
{
|
{
|
||||||
__glibcxx_check_erase_range(__i1, __i2);
|
__glibcxx_check_erase_range(__i1, __i2);
|
||||||
__glibcxx_check_string(__s);
|
__glibcxx_check_string(__s);
|
||||||
|
@ -748,7 +783,8 @@ namespace __gnu_debug
|
||||||
}
|
}
|
||||||
|
|
||||||
basic_string&
|
basic_string&
|
||||||
replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
|
replace(__const_iterator __i1, __const_iterator __i2,
|
||||||
|
size_type __n, _CharT __c)
|
||||||
{
|
{
|
||||||
__glibcxx_check_erase_range(__i1, __i2);
|
__glibcxx_check_erase_range(__i1, __i2);
|
||||||
_Base::replace(__i1.base(), __i2.base(), __n, __c);
|
_Base::replace(__i1.base(), __i2.base(), __n, __c);
|
||||||
|
@ -758,7 +794,7 @@ namespace __gnu_debug
|
||||||
|
|
||||||
template<typename _InputIterator>
|
template<typename _InputIterator>
|
||||||
basic_string&
|
basic_string&
|
||||||
replace(iterator __i1, iterator __i2,
|
replace(__const_iterator __i1, __const_iterator __i2,
|
||||||
_InputIterator __j1, _InputIterator __j2)
|
_InputIterator __j1, _InputIterator __j2)
|
||||||
{
|
{
|
||||||
__glibcxx_check_erase_range(__i1, __i2);
|
__glibcxx_check_erase_range(__i1, __i2);
|
||||||
|
@ -778,8 +814,9 @@ namespace __gnu_debug
|
||||||
}
|
}
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
basic_string& replace(iterator __i1, iterator __i2,
|
basic_string&
|
||||||
std::initializer_list<_CharT> __l)
|
replace(__const_iterator __i1, __const_iterator __i2,
|
||||||
|
std::initializer_list<_CharT> __l)
|
||||||
{
|
{
|
||||||
__glibcxx_check_erase_range(__i1, __i2);
|
__glibcxx_check_erase_range(__i1, __i2);
|
||||||
_Base::replace(__i1.base(), __i2.base(), __l);
|
_Base::replace(__i1.base(), __i2.base(), __l);
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
// { dg-do run { target c++11 } }
|
// { dg-do run { target c++11 } }
|
||||||
// { dg-require-effective-target cxx11-abi }
|
|
||||||
|
|
||||||
#include <testsuite_hooks.h>
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue