Commit f970a17d by Jonathan Wakely Committed by Jonathan Wakely

re PR libstdc++/64657 (Support iterators with overloaded operator-comma)

	PR libstdc++/64657
	* include/bits/basic_string (basic_string::_S_copy_chars): Cast
	expression to void.
	* include/bits/locale_facets_nonio.tcc (money_get::_M_extract,
	time_get::_M_extract_num, time_get::_M_extract_name,
	time_get::_M_extract_wday_or_month): Likewise.
	* include/bits/stl_algo.h (__includes, __replace_copy_if,
	__is_sorted_until, __is_permutation, transform): Likewise.
	* include/bits/stl_algobase.h (swap_ranges, __copy_move::__copy_m,
	__equal::equal, __lexicographical_compare_impl, equal): Likewise.
	* include/bits/stl_numeric.h (inner_product): Likewise.
	* include/bits/stl_uninitialized.h (__uninitialized_copy_a): Likewise.
	* testsuite/util/testsuite_iterators.h (output_iterator_wrapper,
	input_iterator_wrapper): Declare unusable comma operator.
	* testsuite/21_strings/basic_string/cons/char/64657.cc: New.
	* testsuite/21_strings/basic_string/modifiers/assign/char/64657.cc:
	New.

From-SVN: r222579
parent 0aa359c1
2015-04-29 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/64657
* include/bits/basic_string (basic_string::_S_copy_chars): Cast
expression to void.
* include/bits/locale_facets_nonio.tcc (money_get::_M_extract,
time_get::_M_extract_num, time_get::_M_extract_name,
time_get::_M_extract_wday_or_month): Likewise.
* include/bits/stl_algo.h (__includes, __replace_copy_if,
__is_sorted_until, __is_permutation, transform): Likewise.
* include/bits/stl_algobase.h (swap_ranges, __copy_move::__copy_m,
__equal::equal, __lexicographical_compare_impl, equal): Likewise.
* include/bits/stl_numeric.h (inner_product): Likewise.
* include/bits/stl_uninitialized.h (__uninitialized_copy_a): Likewise.
* testsuite/util/testsuite_iterators.h (output_iterator_wrapper,
input_iterator_wrapper): Declare unusable comma operator.
* testsuite/21_strings/basic_string/cons/char/64657.cc: New.
* testsuite/21_strings/basic_string/modifiers/assign/char/64657.cc:
New.
2015-04-28 Doug Evans <dje@google.com> 2015-04-28 Doug Evans <dje@google.com>
* testsuite/libstdc++-xmethods/list.cc (_GLIBCXX_USE_CXX11_ABI): * testsuite/libstdc++-xmethods/list.cc (_GLIBCXX_USE_CXX11_ABI):
......
...@@ -324,7 +324,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 ...@@ -324,7 +324,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
_S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2) _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
_GLIBCXX_NOEXCEPT _GLIBCXX_NOEXCEPT
{ {
for (; __k1 != __k2; ++__k1, ++__p) for (; __k1 != __k2; ++__k1, (void)++__p)
traits_type::assign(*__p, *__k1); // These types are off. traits_type::assign(*__p, *__k1); // These types are off.
} }
...@@ -2779,7 +2779,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 ...@@ -2779,7 +2779,7 @@ _GLIBCXX_END_NAMESPACE_CXX11
_S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2) _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
_GLIBCXX_NOEXCEPT _GLIBCXX_NOEXCEPT
{ {
for (; __k1 != __k2; ++__k1, ++__p) for (; __k1 != __k2; ++__k1, (void)++__p)
traits_type::assign(*__p, *__k1); // These types are off. traits_type::assign(*__p, *__k1); // These types are off.
} }
......
...@@ -202,7 +202,7 @@ _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 ...@@ -202,7 +202,7 @@ _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11
size_type __j = 0; size_type __j = 0;
for (; __beg != __end && __j < __len for (; __beg != __end && __j < __len
&& *__beg == __lc->_M_curr_symbol[__j]; && *__beg == __lc->_M_curr_symbol[__j];
++__beg, ++__j); ++__beg, (void)++__j);
if (__j != __len if (__j != __len
&& (__j || __io.flags() & ios_base::showbase)) && (__j || __io.flags() & ios_base::showbase))
__testvalid = false; __testvalid = false;
...@@ -298,7 +298,7 @@ _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11 ...@@ -298,7 +298,7 @@ _GLIBCXX_BEGIN_NAMESPACE_LDBL_OR_CXX11
: __lc->_M_positive_sign; : __lc->_M_positive_sign;
size_type __i = 1; size_type __i = 1;
for (; __beg != __end && __i < __sign_size for (; __beg != __end && __i < __sign_size
&& *__beg == __sign[__i]; ++__beg, ++__i); && *__beg == __sign[__i]; ++__beg, (void)++__i);
if (__i != __sign_size) if (__i != __sign_size)
__testvalid = false; __testvalid = false;
...@@ -858,7 +858,7 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 ...@@ -858,7 +858,7 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
++__min; ++__min;
size_t __i = 0; size_t __i = 0;
int __value = 0; int __value = 0;
for (; __beg != __end && __i < __len; ++__beg, ++__i) for (; __beg != __end && __i < __len; ++__beg, (void)++__i)
{ {
const char __c = __ctype.narrow(*__beg, '*'); const char __c = __ctype.narrow(*__beg, '*');
if (__c >= '0' && __c <= '9') if (__c >= '0' && __c <= '9')
...@@ -923,7 +923,8 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 ...@@ -923,7 +923,8 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
for (size_t __i2 = 1; __i2 < __nmatches; ++__i2) for (size_t __i2 = 1; __i2 < __nmatches; ++__i2)
__minlen = std::min(__minlen, __minlen = std::min(__minlen,
__traits_type::length(__names[__matches[__i2]])); __traits_type::length(__names[__matches[__i2]]));
++__beg, ++__pos; ++__beg;
++__pos;
if (__pos < __minlen && __beg != __end) if (__pos < __minlen && __beg != __end)
for (size_t __i3 = 0; __i3 < __nmatches;) for (size_t __i3 = 0; __i3 < __nmatches;)
{ {
...@@ -940,11 +941,12 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 ...@@ -940,11 +941,12 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
if (__nmatches == 1) if (__nmatches == 1)
{ {
// Make sure found name is completely extracted. // Make sure found name is completely extracted.
++__beg, ++__pos; ++__beg;
++__pos;
__name = __names[__matches[0]]; __name = __names[__matches[0]];
const size_t __len = __traits_type::length(__name); const size_t __len = __traits_type::length(__name);
while (__pos < __len && __beg != __end && __name[__pos] == *__beg) while (__pos < __len && __beg != __end && __name[__pos] == *__beg)
++__beg, ++__pos; ++__beg, (void)++__pos;
if (__len == __pos) if (__len == __pos)
__member = __matches[0]; __member = __matches[0];
...@@ -987,7 +989,8 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 ...@@ -987,7 +989,8 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
if (__nmatches) if (__nmatches)
{ {
++__beg, ++__pos; ++__beg;
++__pos;
__matches_lengths __matches_lengths
= static_cast<size_t*>(__builtin_alloca(sizeof(size_t) = static_cast<size_t*>(__builtin_alloca(sizeof(size_t)
...@@ -997,7 +1000,7 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11 ...@@ -997,7 +1000,7 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
= __traits_type::length(__names[__matches[__i]]); = __traits_type::length(__names[__matches[__i]]);
} }
for (; __beg != __end; ++__beg, ++__pos) for (; __beg != __end; ++__beg, (void)++__pos)
{ {
size_t __nskipped = 0; size_t __nskipped = 0;
const char_type __c = *__beg; const char_type __c = *__beg;
......
...@@ -2805,7 +2805,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -2805,7 +2805,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
else if (__comp(__first1, __first2)) else if (__comp(__first1, __first2))
++__first1; ++__first1;
else else
++__first1, ++__first2; {
++__first1;
++__first2;
}
return __first2 == __last2; return __first2 == __last2;
} }
...@@ -3108,7 +3111,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -3108,7 +3111,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_OutputIterator __result, _OutputIterator __result,
_Predicate __pred, const _Tp& __new_value) _Predicate __pred, const _Tp& __new_value)
{ {
for (; __first != __last; ++__first, ++__result) for (; __first != __last; ++__first, (void)++__result)
if (__pred(__first)) if (__pred(__first))
*__result = __new_value; *__result = __new_value;
else else
...@@ -3232,7 +3235,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -3232,7 +3235,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return __last; return __last;
_ForwardIterator __next = __first; _ForwardIterator __next = __first;
for (++__next; __next != __last; __first = __next, ++__next) for (++__next; __next != __last; __first = __next, (void)++__next)
if (__comp(__next, __first)) if (__comp(__next, __first))
return __next; return __next;
return __next; return __next;
...@@ -3491,7 +3494,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -3491,7 +3494,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ {
// Efficiently compare identical prefixes: O(N) if sequences // Efficiently compare identical prefixes: O(N) if sequences
// have the same elements in the same order. // have the same elements in the same order.
for (; __first1 != __last1; ++__first1, ++__first2) for (; __first1 != __last1; ++__first1, (void)++__first2)
if (!__pred(__first1, __first2)) if (!__pred(__first1, __first2))
break; break;
...@@ -3607,7 +3610,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -3607,7 +3610,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Efficiently compare identical prefixes: O(N) if sequences // Efficiently compare identical prefixes: O(N) if sequences
// have the same elements in the same order. // have the same elements in the same order.
for (; __first1 != __last1 && __first2 != __last2; for (; __first1 != __last1 && __first2 != __last2;
++__first1, ++__first2) ++__first1, (void)++__first2)
if (!__pred(__first1, __first2)) if (!__pred(__first1, __first2))
break; break;
...@@ -4171,7 +4174,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO ...@@ -4171,7 +4174,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
__typeof__(__unary_op(*__first))>) __typeof__(__unary_op(*__first))>)
__glibcxx_requires_valid_range(__first, __last); __glibcxx_requires_valid_range(__first, __last);
for (; __first != __last; ++__first, ++__result) for (; __first != __last; ++__first, (void)++__result)
*__result = __unary_op(*__first); *__result = __unary_op(*__first);
return __result; return __result;
} }
...@@ -4210,7 +4213,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO ...@@ -4210,7 +4213,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
__typeof__(__binary_op(*__first1,*__first2))>) __typeof__(__binary_op(*__first1,*__first2))>)
__glibcxx_requires_valid_range(__first1, __last1); __glibcxx_requires_valid_range(__first1, __last1);
for (; __first1 != __last1; ++__first1, ++__first2, ++__result) for (; __first1 != __last1; ++__first1, (void)++__first2, ++__result)
*__result = __binary_op(*__first1, *__first2); *__result = __binary_op(*__first1, *__first2);
return __result; return __result;
} }
......
...@@ -173,7 +173,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -173,7 +173,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_ForwardIterator2>) _ForwardIterator2>)
__glibcxx_requires_valid_range(__first1, __last1); __glibcxx_requires_valid_range(__first1, __last1);
for (; __first1 != __last1; ++__first1, ++__first2) for (; __first1 != __last1; ++__first1, (void)++__first2)
std::iter_swap(__first1, __first2); std::iter_swap(__first1, __first2);
return __first2; return __first2;
} }
...@@ -306,7 +306,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -306,7 +306,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static _OI static _OI
__copy_m(_II __first, _II __last, _OI __result) __copy_m(_II __first, _II __last, _OI __result)
{ {
for (; __first != __last; ++__result, ++__first) for (; __first != __last; ++__result, (void)++__first)
*__result = *__first; *__result = *__first;
return __result; return __result;
} }
...@@ -320,7 +320,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -320,7 +320,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static _OI static _OI
__copy_m(_II __first, _II __last, _OI __result) __copy_m(_II __first, _II __last, _OI __result)
{ {
for (; __first != __last; ++__result, ++__first) for (; __first != __last; ++__result, (void)++__first)
*__result = std::move(*__first); *__result = std::move(*__first);
return __result; return __result;
} }
...@@ -808,7 +808,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -808,7 +808,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static bool static bool
equal(_II1 __first1, _II1 __last1, _II2 __first2) equal(_II1 __first1, _II1 __last1, _II2 __first2)
{ {
for (; __first1 != __last1; ++__first1, ++__first2) for (; __first1 != __last1; ++__first1, (void)++__first2)
if (!(*__first1 == *__first2)) if (!(*__first1 == *__first2))
return false; return false;
return true; return true;
...@@ -889,7 +889,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -889,7 +889,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__last1 = __rai_type::__newlast1(__first1, __last1, __first2, __last2); __last1 = __rai_type::__newlast1(__first1, __last1, __first2, __last2);
for (; __first1 != __last1 && __rai_type::__cnd2(__first2, __last2); for (; __first1 != __last1 && __rai_type::__cnd2(__first2, __last2);
++__first1, ++__first2) ++__first1, (void)++__first2)
{ {
if (__comp(__first1, __first2)) if (__comp(__first1, __first2))
return true; return true;
...@@ -1088,7 +1088,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO ...@@ -1088,7 +1088,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
__glibcxx_function_requires(_InputIteratorConcept<_IIter2>) __glibcxx_function_requires(_InputIteratorConcept<_IIter2>)
__glibcxx_requires_valid_range(__first1, __last1); __glibcxx_requires_valid_range(__first1, __last1);
for (; __first1 != __last1; ++__first1, ++__first2) for (; __first1 != __last1; ++__first1, (void)++__first2)
if (!bool(__binary_pred(*__first1, *__first2))) if (!bool(__binary_pred(*__first1, *__first2)))
return false; return false;
return true; return true;
...@@ -1137,7 +1137,8 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO ...@@ -1137,7 +1137,8 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
return _GLIBCXX_STD_A::equal(__first1, __last1, __first2); return _GLIBCXX_STD_A::equal(__first1, __last1, __first2);
} }
for (; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2) for (; __first1 != __last1 && __first2 != __last2;
++__first1, (void)++__first2)
if (!(*__first1 == *__first2)) if (!(*__first1 == *__first2))
return false; return false;
return __first1 == __last1 && __first2 == __last2; return __first1 == __last1 && __first2 == __last2;
...@@ -1184,7 +1185,8 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO ...@@ -1184,7 +1185,8 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
__binary_pred); __binary_pred);
} }
for (; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2) for (; __first1 != __last1 && __first2 != __last2;
++__first1, (void)++__first2)
if (!bool(__binary_pred(*__first1, *__first2))) if (!bool(__binary_pred(*__first1, *__first2)))
return false; return false;
return __first1 == __last1 && __first2 == __last2; return __first1 == __last1 && __first2 == __last2;
......
...@@ -179,7 +179,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO ...@@ -179,7 +179,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
__glibcxx_requires_valid_range(__first1, __last1); __glibcxx_requires_valid_range(__first1, __last1);
for (; __first1 != __last1; ++__first1, ++__first2) for (; __first1 != __last1; ++__first1, (void)++__first2)
__init = __init + (*__first1 * *__first2); __init = __init + (*__first1 * *__first2);
return __init; return __init;
} }
...@@ -213,7 +213,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO ...@@ -213,7 +213,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
__glibcxx_requires_valid_range(__first1, __last1); __glibcxx_requires_valid_range(__first1, __last1);
for (; __first1 != __last1; ++__first1, ++__first2) for (; __first1 != __last1; ++__first1, (void)++__first2)
__init = __binary_op1(__init, __binary_op2(*__first1, *__first2)); __init = __binary_op1(__init, __binary_op2(*__first1, *__first2));
return __init; return __init;
} }
......
...@@ -263,7 +263,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -263,7 +263,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__try __try
{ {
typedef __gnu_cxx::__alloc_traits<_Allocator> __traits; typedef __gnu_cxx::__alloc_traits<_Allocator> __traits;
for (; __first != __last; ++__first, ++__cur) for (; __first != __last; ++__first, (void)++__cur)
__traits::construct(__alloc, std::__addressof(*__cur), *__first); __traits::construct(__alloc, std::__addressof(*__cur), *__first);
return __cur; return __cur;
} }
......
// Copyright (C) 2015 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 compile }
#include <string>
#include <testsuite_iterators.h>
void
test01()
{
using namespace __gnu_test;
char* p = 0;
test_container<char, forward_iterator_wrapper> c(p, p);
std::string s(c.begin(), c.end());
}
// Copyright (C) 2015 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 compile }
#include <string>
#include <testsuite_iterators.h>
void
test01()
{
using namespace __gnu_test;
char* p = 0;
test_container<char, forward_iterator_wrapper> c(p, p);
std::string s;
s.assign(c.begin(), c.end());
}
...@@ -170,6 +170,14 @@ namespace __gnu_test ...@@ -170,6 +170,14 @@ namespace __gnu_test
return tmp; return tmp;
} }
#if __cplusplus >= 201103L
template<typename U>
void operator,(const U&) const = delete;
#else
private:
template<typename U>
void operator,(const U&) const;
#endif
}; };
/** /**
...@@ -251,6 +259,15 @@ namespace __gnu_test ...@@ -251,6 +259,15 @@ namespace __gnu_test
{ {
++*this; ++*this;
} }
#if __cplusplus >= 201103L
template<typename U>
void operator,(const U&) const = delete;
#else
private:
template<typename U>
void operator,(const U&) const;
#endif
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment