Commit Graph

11900 Commits

Author SHA1 Message Date
GCC Administrator
a995c40d03 Daily bump. 2020-09-08 00:16:32 +00:00
Jonathan Wakely
ec5096f48b libstdc++: Simplify chrono::duration::_S_gcd
We can simplify this constexpr function further because we know that
period::num >= 1 and period::den >= 1 so only the remainder can ever be
zero.

libstdc++-v3/ChangeLog:

	* include/std/chrono (duration::_S_gcd): Use invariant that
	neither value is zero initially.
2020-09-07 20:09:17 +01:00
Jonathan Wakely
00ffe73007 libstdc++: Simplify constraints for semiregular-box [LWG 3477]
libstdc++-v3/ChangeLog:

	* include/std/ranges (__box): Simplify constraints as per LWG 3477.
2020-09-07 20:09:17 +01:00
GCC Administrator
6e82b6cfcf Daily bump. 2020-09-04 00:16:32 +00:00
Jonathan Wakely
032a4b42cc libstdc++: Add workaround for weird std::tuple error [PR 96592]
This "fix" makes no sense, but it avoids an error from G++ about
std::is_constructible being incomplete. The real problem is elsewhere,
but this "fixes" the regression for now.

libstdc++-v3/ChangeLog:

	PR libstdc++/96592
	* include/std/tuple (_TupleConstraints<true, T...>): Use
	alternative is_constructible instead of std::is_constructible.
	* testsuite/20_util/tuple/cons/96592.cc: New test.
2020-09-03 16:26:16 +01:00
Jonathan Wakely
3c21913415 libstdc++: Optimise GCD algorithms
The current std::gcd and std::chrono::duration::_S_gcd algorithms are
both recursive. This is potentially expensive to evaluate in constant
expressions, because each level of recursion makes a new copy of the
function to evaluate. The maximum number of steps is bounded
(proportional to the number of decimal digits in the smaller value) and
so unlikely to exceed the limit for constexpr nesting, but the memory
usage is still suboptimal. By using an iterative algorithm we avoid
that compile-time cost. Because looping in constexpr functions is not
allowed until C++14, we need to keep the recursive implementation in
duration::_S_gcd for C++11 mode.

For std::gcd we can also optimise runtime performance by using the
binary GCD algorithm.

libstdc++-v3/ChangeLog:

	* include/std/chrono (duration::_S_gcd): Use iterative algorithm
	for C++14 and later.
	* include/std/numeric (__detail::__gcd): Replace recursive
	Euclidean algorithm with iterative version of binary GCD algorithm.
	* testsuite/26_numerics/gcd/1.cc: Test additional inputs.
	* testsuite/26_numerics/gcd/gcd_neg.cc: Adjust dg-error lines.
	* testsuite/26_numerics/lcm/lcm_neg.cc: Likewise.
	* testsuite/experimental/numeric/gcd.cc: Test additional inputs.
	* testsuite/26_numerics/gcd/2.cc: New test.
2020-09-03 12:46:13 +01:00
GCC Administrator
6a8f4e47c9 Daily bump. 2020-09-03 00:16:26 +00:00
Jonathan Wakely
c71644776f libstdc++: Fix test to use correct function
This was copied from a test for std::lcm but I forgot to change one of
the calls to use the experimental version of the function.

libstdc++-v3/ChangeLog:

	PR libstdc++/92978
	* testsuite/experimental/numeric/92978.cc: Use experimental::lcm
	not std::lcm.
2020-09-02 17:22:47 +01:00
Jonathan Wakely
2f983fa690 libstdc++: Fix three-way comparison for std::array [PR 96851]
The spaceship operator for std::array uses memcmp when the
__is_byte<value_type> trait is true, but memcmp isn't usable in
constexpr contexts. Also, memcmp should only be used for unsigned byte
types, because it gives the wrong answer for signed chars with negative
values.

We can simply check std::is_constant_evaluated() so that we don't use
memcmp during constant evaluation.

To fix the problem of using memcmp for inappropriate types, this patch
adds new __is_memcmp_ordered and __is_memcmp_ordered_with traits. These
say whether using memcmp will give the right answer for ordering
operations such as lexicographical_compare and three-way comparisons.
The new traits can be used in several places, and can also be used to
implement my suggestion in PR 93059 comment 37 to use memcmp for
unsigned integers larger than one byte on big endian targets.

libstdc++-v3/ChangeLog:

	PR libstdc++/96851
	* include/bits/cpp_type_traits.h (__is_memcmp_ordered):
	New trait that says if memcmp can be used for ordering.
	(__is_memcmp_ordered_with): Likewise, for two types.
	* include/bits/deque.tcc (__lex_cmp_dit): Use new traits
	instead of __is_byte and __numeric_traits.
	(__lexicographical_compare_aux1): Likewise.
	* include/bits/ranges_algo.h (__lexicographical_compare_fn):
	Likewise.
	* include/bits/stl_algobase.h (__lexicographical_compare_aux1)
	(__is_byte_iter): Likewise.
	* include/std/array (operator<=>): Likewise. Only use memcmp
	when std::is_constant_evaluated() is false.
	* testsuite/23_containers/array/comparison_operators/96851.cc:
	New test.
	* testsuite/23_containers/array/tuple_interface/get_neg.cc:
	Adjust dg-error line numbers.
2020-09-02 15:32:11 +01:00
Jonathan Wakely
6bdbf0f37b libstdc++: Break header cycle between <new> and <exception>
The <new> and <exception> headers each include each other, which makes
building them as header-units "exciting". The <new> header only needs
the definition of std::exception (in order to derive from it) which is
already in its own header, so just include that.

libstdc++-v3/ChangeLog:

	* include/bits/stl_iterator.h: Include <bits/exception_defines.h>
	for definitions of __try, __catch and __throw_exception_again.
	(counted_iterator::operator++(int)): Use __throw_exception_again
	instead of throw.
	* libsupc++/new: Include <bits/exception.h> not <exception>.
	* libsupc++/new_opvnt.cc: Include <bits/exception_defines.h>.
	* testsuite/18_support/destroying_delete.cc: Include
	<type_traits> for std::is_same_v definition.
	* testsuite/20_util/variant/index_type.cc: Qualify size_t.
2020-09-02 13:56:32 +01:00
GCC Administrator
e1a4a8a03f Daily bump. 2020-09-02 00:16:25 +00:00
Jonathan Wakely
10f51543bb libstdc++: Add compile-time checks to__glibcxx_assert [PR 71960]
This change evaluates __glibcxx_assert checks unconditionally when a
function is being constant evaluated (when std::is_constant_evaluated()
is true). If the check fails, compilation will fail with an error.

If the function isn't being constant evaluated, the normal runtime check
will be done if enabled by _GLIBCXX_ASSERTIONS or _GLIBCXX_DEBUG, the
same as before.

Tangentially, the __glibcxx_assert and _GLIBCXX_PARALLEL_ASSERT macros
are changed to expand to 'do { } while (false)' when assertions are
disabled, instead of expanding to nothing. This avoids -Wempty-body
warnings when a disabled assertion is used in an 'if' or 'else'
statement e.g.

  if constexpr (/* precondition is testable */)
    __glibcxx_assert(precondition);

a.C:9:27: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body]
    9 |     __glibcxx_assert(precondition);
      |                                  ^

libstdc++-v3/ChangeLog:

	PR libstdc++/71960
	* include/bits/c++config (__glibcxx_assert_impl): Remove
	do-while so that uses of the macro need to add it.
	(__glibcxx_assert): Rename macro for runtime assertions
	to __glibcxx_assert_2.
	(__glibcxx_assert_1): Define macro for constexpr assertions.
	(__glibcxx_assert): Define macro for constexpr and runtime
	assertions.
	* include/bits/range_access.h (ranges::advance): Remove
	redundant precondition checks during constant evaluation.
	* include/parallel/base.h (_GLIBCXX_PARALLEL_ASSERT): Always
	use do-while in macro expansion.
	* include/std/ranges (iota_view::iota_view(W, B)): Remove
	redundant braces.
2020-09-01 20:52:26 +01:00
Jonathan Wakely
b1850c617b libstdc++: Constrain chrono::duration conversions [LWG 2094]
The chrono::duration constructor that converts from another duration
type is meant to be constrained so that it doesn't participate in
overload resolution if the ratio of the periods cannot be represented as
a std::ratio.

Because our std::ratio_divide is not SFINAE-friendly the evaluation of
__is_harmonic results in an error outside the immediate context when an
overflow occurs. I intend to make ratio_divide (and ratio_multiply)
SFINAE-friendly in a future patch, but for now this patch just
introduces a new SFINAE-friendly alias template for the division.

The standard doesn't require it, but it also seems right to constrain
the constructor with std::is_convertible_v<_Rep2, rep>.

libstdc++-v3/ChangeLog:

	* include/std/chrono (duration::_S_gcd(intmax_t, intmax_t)):
	New helper function for finding GCD of two positive intmax_t
	values.
	(duration::__divide): New helper alias for dividing one period
	by another.
	(duration::__is_harmonic): Use __divide not ratio_divide.
	(duration(const duration<R2, P2>&)): Require the duration rep
	types to be convertible.
	* testsuite/20_util/duration/cons/dr2094.cc: New test.
	* testsuite/20_util/duration/requirements/reduced_period.cc:
	Fix definition of unused member functions in test type.
	* testsuite/20_util/duration/requirements/typedefs_neg2.cc:
	Adjust expected errors.
2020-09-01 18:18:26 +01:00
GCC Administrator
daba4a713e Daily bump. 2020-08-30 00:16:20 +00:00
Jonathan Wakely
0789600c59 libstdc++: Fix deleted overload of __absu(bool)
libstdc++-v3/ChangeLog:

	* include/std/numeric (__detail::__absu(bool)): Make deleted
	function a function template, so it will be chosen for calls
	with an explicit template argument list.
	* testsuite/26_numerics/gcd/gcd_neg.cc: Add dg-prune-output.
	* testsuite/26_numerics/lcm/lcm_neg.cc: Likewise.
2020-08-29 18:24:08 +01:00
GCC Administrator
8f7ea26ae3 Daily bump. 2020-08-29 00:16:21 +00:00
Jonathan Wakely
f2f48b68a6 libstdc++: Fix common_type specializations for duration
My recent change to implement P0548 ("common_type and duration") was not
correct. The result of common_type_t<duration<R,P>, duration<R,P>>
should be duration<common_type_t<R>, P::type>, not duration<R, P::type>.
The common_type specialization for two different duration types was
correct, but the specializations for a single duration type (which only
exist to optimize compilation time) were wrong.

This fixes the partial specializations of common_type for a single
duration type, and also the return types of duration::operator+ and
duration::operator- which are supposed to use common_type_t<duration>.

libstdc++-v3/ChangeLog:

	* include/std/chrono (common_type): Fix partial specializations
	for a single duration type to use the common_type of the rep.
	(duration::operator+, duration::operator-): Fix return types
	to also use the common_type of the rep.
	* testsuite/20_util/duration/requirements/reduced_period.cc:
	Check duration using a rep that has common_type specialized.
2020-08-28 23:41:13 +01:00
Jonathan Wakely
82db1a42e9 libstdc++: Fix std::gcd and std::lcm for unsigned integers [PR 92978]
This fixes a bug with mixed signed and unsigned types, where converting
a negative value to the unsigned result type alters the value. The
solution is to obtain the absolute values of the arguments immediately
and to perform the actual GCD or LCM algorithm on two arguments of the
same type.

In order to operate on the most negative number without overflow when
taking its absolute, use an unsigned type for the result of the abs
operation. For example, -INT_MIN will overflow, but -(unsigned)INT_MIN
is (unsigned)INT_MAX+1U which is the correct value.

libstdc++-v3/ChangeLog:

	PR libstdc++/92978
	* include/std/numeric (__abs_integral): Replace with ...
	(__detail::__absu): New function template that returns an
	unsigned type, guaranteeing it can represent the most
	negative signed value.
	(__detail::__gcd, __detail::__lcm): Require arguments to
	be unsigned and therefore already non-negative.
	(gcd, lcm): Convert arguments to absolute value as unsigned
	type before calling __detail::__gcd or __detail::__lcm.
	* include/experimental/numeric (gcd, lcm): Likewise.
	* testsuite/26_numerics/gcd/gcd_neg.cc: Adjust expected
	errors.
	* testsuite/26_numerics/lcm/lcm_neg.cc: Likewise.
	* testsuite/26_numerics/gcd/92978.cc: New test.
	* testsuite/26_numerics/lcm/92978.cc: New test.
	* testsuite/experimental/numeric/92978.cc: New test.
2020-08-28 23:03:28 +01:00
GCC Administrator
8b394f011a Daily bump. 2020-08-28 00:16:24 +00:00
Jonathan Wakely
82030d5101 libstdc++: Make std::chrono::duration use reduced ratio for period
This implements the changes from P0548 "common_type and duration". That
was a change for C++17, but as it corrects some issues introduced by DRs
I'm also treating it as a DR and changing it for all modes from C++11
up.

The main change is that duration<R,P>::period no longer denotes P, but
rather P::type, the reduced ratio. The unary operator+ and operator-
members of duration should now return a duration using that reduced
ratio.

The requirement that common_type<T>::type is the same type as
common_type<T, T>::type (rather than simply T) was already implemented
for PR 89102.

The standard says that duration::operator+() and duration::operator-()
should return common_type_t<duration>, but that seems unnecessarily
expensive to compute. This change just uses duration<rep, period> which
is the same type, so we don't need to instantiate common_type.

As an optimization, this also adds partial specializations of
common_type for two durations of the same type, a single duration, two
time_points of the same type, and a single time_point. These
specializations avoid instantiating other specializations of common_type
and one or both of __duration_common_type or __timepoint_common_type for
the cases where the answer is trivial to obtain.

libstdc++-v3/ChangeLog:

	* include/std/chrono (__duration_common_type): Ensure the
	reduced ratio is used. Remove unused partial specialization
	using __failure_type.
	(common_type): Pass reduced ratios to __duration_common_type.
	Add partial specializations for simple cases involving a single
	duration or time_point type.
	(duration::period): Use reduced ratio.
	(duration::operator+(), duration::operator-()): Return duration
	type using the reduced ratio.
	* testsuite/20_util/duration/requirements/typedefs_neg2.cc:
	Adjust expected errors.
	* testsuite/20_util/duration/requirements/reduced_period.cc: New test.
2020-08-27 22:36:03 +01:00
Patrick Palka
71e9716137 libstdc++: Fix arithmetic bug in chrono::year_month::operator+
This fixes the months-based addition for year_month when the
year_month's month component is 0.

libstdc++-v3/ChangeLog:

	* include/std/chrono (year_month::operator+): Properly handle a
	month value of 0 by casting the month value to int before
	subtracting 1 from it so that the difference is sign-extended in
	the subsequent addition.
	* testsuite/std/time/year_month/1.cc: Test adding months to a
	year_month whose month component is below or above the
	normalized range of [1,12].
2020-08-27 14:11:24 -04:00
Patrick Palka
7b743c67f0 libstdc++: Fix operator overload ambiguity with calendar types
We currently don't enforce a constraint on some of the calendar types'
addition/subtraction operator overloads that take a 'months' arguments:

  Constraints: If the argument supplied by the caller for the months
  parameter is convertible to years, its implicit conversion sequence to
  years is worse than its implicit conversion sequence to months.

This constraint is relevant when adding/subtracting a duration to/from,
say, a year_month where the given duration is convertible to both
'months' and to 'years' (as in the new testcases below).  The correct
behavior here in light of this constraint is to perform the operation
through the (more efficient) 'years'-based overload, but we currently
emit an ambiguous overload error.

This patch templatizes the 'months'-based addition/subtraction operator
overloads so that in the event of an implicit-conversion tie, we select
the non-template 'years'-based overload.  This is the same approach
that the date library takes for enforcing this constraint.

libstdc++-v3/ChangeLog:

	* include/std/chrono
	(__detail::__months_years_conversion_disambiguator): Define.
	(year_month::operator+=): Templatize the 'months'-based overload
	so that the 'years'-based overload is selected in case of
	equally-ranked implicit conversion sequences to both 'months'
	and 'years' from the supplied argument.
	(year_month::operator-=): Likewise.
	(year_month::operator+): Likewise.
	(year_month::operator-): Likewise.
	(year_month_day::operator+=): Likewise.
	(year_month_day::operator-=): Likewise.
	(year_month_day::operator+): Likewise.
	(year_month_day::operator-): Likewise.
	(year_month_day_last::operator+=): Likewise.
	(year_month_day_last::operator-=): Likewise.
	(year_month_day_last::operator+): Likewise
	(year_month_day_last::operator-): Likewise.
	(year_month_day_weekday::operator+=): Likewise
	(year_month_day_weekday::operator-=): Likewise.
	(year_month_day_weekday::operator+): Likewise.
	(year_month_day_weekday::operator-): Likewise.
	(year_month_day_weekday_last::operator+=): Likewise
	(year_month_day_weekday_last::operator-=): Likewise.
	(year_month_day_weekday_last::operator+): Likewise.
	(year_month_day_weekday_last::operator-): Likewise.
	(testsuite/std/time/year_month/2.cc): New test.
	(testsuite/std/time/year_month_day/2.cc): New test.
	(testsuite/std/time/year_month_day_last/2.cc): New test.
	(testsuite/std/time/year_month_weekday/2.cc): New test.
	(testsuite/std/time/year_month_weekday_last/2.cc): New test.
2020-08-27 14:09:52 -04:00
Patrick Palka
3ae0cd94ab libstdc++: Implement remaining piece of LWG 3448
Almost all of the proposed resolution for LWG 3448 is already
implemented; the only part left is to adjust the return type of
transform_view::sentinel::operator-.

libstdc++-v3/ChangeLog:

	PR libstdc++/95322
	* include/std/ranges (transform_view::sentinel::__distance_from):
	Give this a deduced return type.
	(transform_view::sentinel::operator-): Adjust the return type so
	that it's based on the constness of the iterator rather than
	that of the sentinel.
	* testsuite/std/ranges/adaptors/95322.cc: Refer to LWG 3488.
2020-08-26 21:53:04 -04:00
Patrick Palka
4be16d1c1c libstdc++: elements_view's sentinel and iterator not comparable [LWG 3406]
This implements the proposed resolution for LWG 3406, and adds a
testcase for the example from P1994R1.

libstdc++-v3/ChangeLog:

	* include/std/ranges (elements_view::begin): Adjust constraints.
	(elements_view::end): Likewise.
	(elements_view::_Sentinel::operator==): Templatize to take both
	_Iterator<true> and _Iterator<false>.
	(elements_view::_Sentinel::operator-): Likewise.
	* testsuite/std/ranges/adaptors/elements.cc: Add testcase for
	the example from P1994R1.
	* testsuite/std/ranges/adaptors/lwg3406.cc: New test.
2020-08-26 21:52:58 -04:00
Patrick Palka
97ab5daa6c libstdc++: Implement P1994R1 changes to ranges::elements_view
The example from the paper doesn't compile without the proposed
resolution for LWG 3406, so we'll add a testcase for this once the
proposed resolution is implemented.

libstdc++-v3/ChangeLog:

	* include/std/ranges (elements_view::end): Replace these two
	overloads with four new overloads.
	(elements_view::_Iterator::operator==): Remove.
	(elements_view::_Iterator::operator-): Likewise.
	(elements_view::_Sentinel): Define.
2020-08-26 21:49:51 -04:00
GCC Administrator
57ea089421 Daily bump. 2020-08-27 00:16:27 +00:00
Jonathan Wakely
af06acfc8d libstdc++: Whitespace changes in <tuple>
libstdc++-v3/ChangeLog:

	* include/std/tuple (_Tuple_impl): Whitespaces changes for
	consistent indentation. Also use __enable_if_t alias template.
2020-08-26 19:32:30 +01:00
Jonathan Wakely
5494edae83 libstdc++: Use correct argument type for __use_alloc [PR 96803]
The _Tuple_impl constructor for allocator-extended construction from a
different tuple type uses the _Tuple_impl's own _Head type in the
__use_alloc test. That is incorrect, because the argument tuple could
have a different type. Using the wrong type might select the
leading-allocator convention when it should use the trailing-allocator
convention, or vice versa.

libstdc++-v3/ChangeLog:

	PR libstdc++/96803
	* include/std/tuple
	(_Tuple_impl(allocator_arg_t, Alloc, const _Tuple_impl<U...>&)):
	Replace parameter pack with a type parameter and a pack and pass
	the first type to __use_alloc.
	* testsuite/20_util/tuple/cons/96803.cc: New test.
2020-08-26 19:32:30 +01:00
Patrick Palka
0c5df67ffc libstdc++: Fix typo in chrono::year_month_weekday::operator==
libstdc++-v3/ChangeLog:

	* include/std/chrono (year_month_weekday::operator==): Compare
	weekday_indexed instead of weekday.
	* testsuite/std/time/year_month_weekday/1.cc: Augment testcase.
2020-08-26 12:58:37 -04:00
Jonathan Wakely
9f9c0549dd libstdc++: Fix regression in hash containers
A recent change altered the layout of EBO-helper base classes, resulting
in an ambiguity when the hash function and equality predicate are the
same type.

This modifies the type of one of the base classes, so that we don't get
two base classes of the same type.

libstdc++-v3/ChangeLog:

	* include/bits/hashtable_policy.h (_Hash_code_base): Change
	index of _Hashtable_ebo_helper base class.
	* testsuite/23_containers/unordered_map/dup_types.cc: New test.
2020-08-26 17:44:23 +01:00
Jonathan Wakely
3eefb302d2 libstdc++: Enable assertions in constexpr string_view members [PR 71960]
Since GCC 6.1 there is no reason we can't just use __glibcxx_assert in
constexpr functions in string_view. As long as the condition is true,
there will be no call to std::__replacement_assert that would make the
function ineligible for constant evaluation.

	PR libstdc++/71960
	* include/experimental/string_view (basic_string_view):
	Enable debug assertions.
	* include/std/string_view (basic_string_view):
	Likewise.
2020-08-26 14:48:49 +01:00
Patrick Palka
e9a2b5b8a3 libstdc++: Add missing extra space to ChangeLog author lines 2020-08-26 09:35:07 -04:00
Patrick Palka
121dc0c378 libstdc++: Add missing coauthors to ChangeLog entry
The corresponding commit had the Co-authored-by: lines in the middle of
the commit message instead of at the end, so the ChangeLog script didn't
consider them.
2020-08-26 09:29:39 -04:00
François Dumont
4797a61cc5 libstdc++: Rename _Hashtable _H1, _H2 and _Hash template parameters
Limit our _Hashtable implementation to ranged hash. _H1 is now rename
to _Hash matching the _Hash functor used for unordered containers. _H2
is now renamed to _RangeHash. Former _Hash simply becomes _Unused. Remove
_ExtractKey storage.

libstdc++-v3/ChangeLog:

	* include/bits/hashtable_policy.h (_Hashtable<>): Rename _H1 into _Hash
	_H2 into _RangeHash and _Hash into _Unused.
	(_Hastable_base<>): Likewise.
	(_Map_base<>): Likewise.
	(_Insert_base<>): Likewise.
	(_Insert<>): Likewise.
	(_Rehash_base<>): Likewise.
	(_Local_iterator_base<>): Likewise.
	(_Hash_code_base<>): Likewise.
	(_Hash_code_base<_Key, _Value, _ExtractKey, _H1, _H2, _Hash, false>):
	Remove.
	(_Hash_code_base<_Key, _Value, _ExtractKey, _H1, _H2, _Hash, true>):
	Remove.
	(_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHas, _Unused,
	bool>): Remove _Hashtable_ebo_helper<2, _RangeHash> base type..
	(_Hash_code_base<>::_M_bucket_index(const _Key&, __hash_code, size_t)):
	Replace by...
	(_Hash_code_base<>::_M_bucket_index(__hash_code, size_t)): ...this.
	(_Local_iterator<>): Remove _H1 and _H2 template parameters.
	(_Local_const_iterator<>): Likewise.
	(_Equality<>): Likewise.
	(_Map_base<>::operator[](const key_type&): Adapt.
	(_Map_base<>::operator[](key_type&&): Adapt.
	(_Identity::operator()): Add noexcept.
	(_Select1st::operator()): Likewise.
	(_Hash_code_base<>): Remove _Hashtable_ebo_helper<0, _ExtractKey> base
	type.
	(_Hash_code_base::_M_extract): Remove.
	* include/bits/hashtable.h (_Hashtable<>): Remove _H1 and _H2 template
	parameters. Remove _ExtractKey from constructors.
	(_Hashtable<>::_M_insert_unique_node(const key_type&, size_t,
	__hash_code, __node_type*, size_t)): Replace by...
	(_Hashtable<>::_M_insert_unique_node(size_t, __hash_code,
	 __node_type*, size_t)): ...this.
	(_Hashtable<>::_M_insert_muti_node(__node_type*, const key_type&,
	__hash_code, __node_type*)): Replace by...
	(_Hashtable<>::_M_insert_multi_node(__node_type*, __hash_code,
	__node_type*)): ...this.
	(_Hashtable<>::__key_extract): Remove.
	* include/bits/node_handle.h: Adapt.
2020-08-26 07:58:46 +02:00
GCC Administrator
db0f6efe7a Daily bump. 2020-08-26 00:16:32 +00:00
Jonathan Wakely
24f2764521 libstdc++: Remove tests for self-move debug assertions
I recently removed the debug mode checks for self-move assignment, which
means these tests now fail when _GLIBCXX_DEBUG is added to the options
or when the check-debug target is used. Remove all the tests.

libstdc++-v3/ChangeLog:

	* testsuite/21_strings/debug/iterator_self_move_assign_neg.cc: Removed.
	* testsuite/21_strings/debug/self_move_assign_neg.cc: Removed.
	* testsuite/23_containers/deque/debug/iterator_self_move_assign_neg.cc: Removed.
	* testsuite/23_containers/deque/debug/self_move_assign_neg.cc: Removed.
	* testsuite/23_containers/forward_list/debug/iterator_self_move_assign_neg.cc: Removed.
	* testsuite/23_containers/forward_list/debug/self_move_assign_neg.cc: Removed.
	* testsuite/23_containers/list/debug/iterator_self_move_assign_neg.cc: Removed.
	* testsuite/23_containers/list/debug/self_move_assign_neg.cc: Removed.
	* testsuite/23_containers/map/debug/iterator_self_move_assign_neg.cc: Removed.
	* testsuite/23_containers/map/debug/self_move_assign_neg.cc: Removed.
	* testsuite/23_containers/multimap/debug/iterator_self_move_assign_neg.cc: Removed.
	* testsuite/23_containers/multimap/debug/self_move_assign_neg.cc: Removed.
	* testsuite/23_containers/multiset/debug/iterator_self_move_assign_neg.cc: Removed.
	* testsuite/23_containers/multiset/debug/self_move_assign_neg.cc: Removed.
	* testsuite/23_containers/set/debug/iterator_self_move_assign_neg.cc: Removed.
	* testsuite/23_containers/set/debug/self_move_assign_neg.cc: Removed.
	* testsuite/23_containers/unordered_map/debug/iterator_self_move_assign_neg.cc: Removed.
	* testsuite/23_containers/unordered_map/debug/self_move_assign_neg.cc: Removed.
	* testsuite/23_containers/unordered_multimap/debug/iterator_self_move_assign_neg.cc:
	Removed.
	* testsuite/23_containers/unordered_multimap/debug/self_move_assign_neg.cc: Removed.
	* testsuite/23_containers/unordered_multiset/debug/iterator_self_move_assign_neg.cc:
	Removed.
	* testsuite/23_containers/unordered_multiset/debug/self_move_assign_neg.cc: Removed.
	* testsuite/23_containers/unordered_set/debug/iterator_self_move_assign_neg.cc: Removed.
	* testsuite/23_containers/unordered_set/debug/self_move_assign_neg.cc: Removed.
	* testsuite/23_containers/vector/debug/iterator_self_move_assign_neg.cc: Removed.
	* testsuite/23_containers/vector/debug/self_move_assign_neg.cc: Removed.
2020-08-25 16:36:01 +01:00
Patrick Palka
1007170df8 libstdc++: Fix debug-mode build failure in <chrono>
libstdc++-v3/ChangeLog:

	* include/std/chrono (year_month_weekday::ok): Fix assert.
2020-08-25 11:23:36 -04:00
Jonathan Wakely
71ed3c0c9a libstdc++: Adjust static assertions in futures and promises [LWG 3466]
Add a static_assertions to check the result type is destructible, as in
the proposed resolution for LWG 3466 (which supersedes 3458).

libstdc++-v3/ChangeLog:

	* include/std/future (future, shared_future. promise): Add
	is_destructible assertion (LWG 3466). Adjust string-literal for
	!is_array and !is_function assertions.
	* testsuite/30_threads/future/requirements/lwg3458.cc: Check
	types with no accessible destructor. Adjust expected errors.
	* testsuite/30_threads/promise/requirements/lwg3466.cc:
	Likewise.
	* testsuite/30_threads/shared_future/requirements/lwg3458.cc:
	Likewise.
2020-08-25 15:52:57 +01:00
Patrick Palka
03d5044b31 libstdc++: Add more C++20 additions to <chrono>
This patch adds the C++20 calendar types and their methods as defined in
[time.cal] (modulo the parsing/printing support).  This patch also
implements [time.hms] and [time.12], and a few more bits of
[time.clock].  The remaining C++20 additions to <chrono> from P0355 and
P1466 depend on [time.zone] and <format>, so they will come later, as
will more optimized versions of some of the algorithms added here.

The non-member operator overloads for the calendar types are defined as
namespace-scope functions in the standard, but here we instead define
these operator overloads as hidden friends.  This simplifies the
implementation somewhat and lets us reap the benefits of hidden friends
for these overloads.

The bulk of this work is based on a patch from Ed Smith-Rowland, which can
be found at the Git branch users/redi/heads/calendar.

Co-authored-by: Ed Smith-Rowland <3dw4rd@verizon.net>
Co-authored-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/std/chrono (time_point::operator++)
	(time_point::operator--): Define.
	(utc_clock, tai_clock, gps_clock): Forward declare.
	(utc_time, utc_seconds, tai_time, tai_seconds, gps_time)
	(gps_seconds): Define.
	(is_clock<utc_clock>, is_clock<tai_clock>, is_clock<gps_clock>)
	(is_clock_v<utc_clock>, is_clock_v<tai_clock>)
	(is_clock_v<gps_clock>): Define these specializations.
	(leap_second_info): Define.
	(day, month, year, weekday, weekday_indexed)
	(weekday_last, month_day, month_day_last, month_weekday)
	(month_weekday_last, year_month, year_month_day)
	(year_month_day_last, year_month_weekday, year_month_weekday_last):
	Declare and later define.
	(last_spec, last, __detail::__days_per_month)
	(__detail::__days_per_month, __detail::__last_day): Define.
	(January, February, March, April, May, June, July, August)
	(September, October, November, December, Sunday, Monday, Tuesday)
	(Wednesday, Thursday, Friday, Saturday): Define.
	(weekday::operator[]): Define out-of-line.
	(year_month_day::_S_from_days, year_month_day::M_days_since_epoch):
	Likewise.
	(year_month_day::year_month_day, year_month_day::ok): Likewise.
	(__detail::__pow10, hh_mm_ss): Define.
	(literals::chrono_literals::operator""d)
	(literals::chrono_literals::operator""y): Define.
	(is_am, is_pm, make12, make24): Define.
	* testsuite/20_util/time_point/4.cc: New test.
	* testsuite/std/time/day/1.cc: New test.
	* testsuite/std/time/hh_mm_ss/1.cc: New test.
	* testsuite/std/time/is_am/1.cc: New test.
	* testsuite/std/time/is_pm/1.cc: New test.
	* testsuite/std/time/make12/1.cc: New test.
	* testsuite/std/time/make24/1.cc: New test.
	* testsuite/std/time/month/1.cc: New test.
	* testsuite/std/time/month_day/1.cc: New test.
	* testsuite/std/time/month_day_last/1.cc: New test.
	* testsuite/std/time/month_weekday/1.cc: New test.
	* testsuite/std/time/month_weekday_last/1.cc: New test.
	* testsuite/std/time/weekday/1.cc: New test.
	* testsuite/std/time/weekday_indexed/1.cc: New test.
	* testsuite/std/time/weekday_last/1.cc: New test.
	* testsuite/std/time/year/1.cc: New test.
	* testsuite/std/time/year_month/1.cc: New test.
	* testsuite/std/time/year_month_day/1.cc: New test.
	* testsuite/std/time/year_month_day_last/1.cc: New test.
	* testsuite/std/time/year_month_weekday/1.cc: New test.
	* testsuite/std/time/year_month_weekday_last/1.cc: New test.
2020-08-25 10:23:59 -04:00
GCC Administrator
b2b24d30bb Daily bump. 2020-08-25 00:16:24 +00:00
Jonathan Wakely
ef275d1f20 libstdc++: Add deduction guide for std::ranges::join_view [LWG 3474]
This implements the proposed resolution for LWG 3474.

libstdc++-v3/ChangeLog:

	* include/std/ranges (join_view): Add deduction guide (LWG 3474).
	* testsuite/std/ranges/adaptors/join_lwg3474.cc: New test.
2020-08-24 16:18:32 +01:00
Jonathan Wakely
186aa63045 libstdc++: Fix std::indirectly_readable ambiguity [LWG 3446]
This implements the proposed resolution of LWG 3446. I'm also adding
another new constrained specialization which isn't proposed by 3446, to
resolve the ambiguity when a type has both value_type and element_type
but denoting different types.

libstdc++-v3/ChangeLog:

	* include/bits/iterator_concepts.h (indirectly_readable): Add
	partial specializations to resolve ambiguities (LWG 3446).
	* testsuite/24_iterators/associated_types/readable.traits.cc:
	Check types with both value_type and element_type.
2020-08-24 16:18:31 +01:00
Jonathan Wakely
a0e6f05d26 libstdc++: Fix iota_view::size() to avoid overflow
This avoids the overflow that occurs when negating the most negative
value of an integral type.

Also prevent returning signed int when the values have lower rank and
promote to int.

libstdc++-v3/ChangeLog:

	* include/std/ranges (ranges::iota_view::size()): Perform all
	calculations in the right unsigned types.
	* testsuite/std/ranges/iota/size.cc: New test.
2020-08-24 16:17:04 +01:00
Jonathan Wakely
074436cf8c libstdc++: Make variant_npos conversions explicit [PR 96766]
libstdc++-v3/ChangeLog:

	PR libstdc++/96766
	* include/std/variant (_Variant_storage): Replace implicit
	conversions from size_t to __index_type with explicit casts.
2020-08-24 16:10:07 +01:00
Jonathan Wakely
ac4e9090fc libstdc++: Fix 30_threads/packaged_task/cons/alloc.cc regression
libstdc++-v3/ChangeLog:

	* testsuite/30_threads/packaged_task/cons/alloc.cc: Run for
	C++11 and skip for C++17 or later.
2020-08-24 16:07:12 +01:00
Corentin Gay
1e42d2f4cf Fix libstdc++ testsuite to handle VxWorks gthreads implementation
When implementing the support for gthreads in VxWorks, we stumbled on
a problem in the testsuite. In the libstdc++ testsuite, we
indiscriminately add the `-pthread` switch to the tests that require
linking against the pthread library. In certain cases, such as
VxWorks, the gthread interface relies on the system native threads
lilbrary and the `-pthread` switch does not exist.

This patch adds a condition for the use of the `-pthread` switch. It
adds it only if the target supports it. The patch also adds
`dg-require-gthreads` in tests that were lacking it.


for libstdc++-v3/ChangeLog

	* testsuite/20_util/shared_ptr/atomic/3.cc: Do not require POSIX
	threads and add -pthread only on targets supporting them.
	* testsuite/20_util/shared_ptr/thread/default_weaktoshared.cc:
	Likewise.
	* testsuite/20_util/shared_ptr/thread/mutex_weaktoshared.cc:
	Likewise.
	* testsuite/30_threads/async/42819.cc: Likewise.
	* testsuite/30_threads/async/49668.cc: Likewise.
	* testsuite/30_threads/async/54297.cc: Likewise.
	* testsuite/30_threads/async/any.cc: Likewise.
	* testsuite/30_threads/async/async.cc: Likewise.
	* testsuite/30_threads/async/except.cc: Likewise.
	* testsuite/30_threads/async/launch.cc: Likewise.
	* testsuite/30_threads/async/lwg2021.cc: Likewise.
	* testsuite/30_threads/async/sync.cc: Likewise. : Likewise.
	* testsuite/30_threads/call_once/39909.cc: Likewise.
	* testsuite/30_threads/call_once/49668.cc: Likewise.
	* testsuite/30_threads/call_once/60497.cc: Likewise.
	* testsuite/30_threads/call_once/call_once1.cc: Likewise.
	* testsuite/30_threads/call_once/dr2442.cc: Likewise.
	* testsuite/30_threads/condition_variable/54185.cc: Likewise.
	* testsuite/30_threads/condition_variable/cons/1.cc: Likewise.
	* testsuite/30_threads/condition_variable/members/1.cc: Likewise.
	* testsuite/30_threads/condition_variable/members/2.cc: Likewise.
	* testsuite/30_threads/condition_variable/members/3.cc: Likewise.
	* testsuite/30_threads/condition_variable/members/53841.cc: Likewise.
	* testsuite/30_threads/condition_variable/members/68519.cc: Likewise.
	* testsuite/30_threads/condition_variable/native_handle/typesizes.cc:
	Likewise.
	* testsuite/30_threads/condition_variable_any/50862.cc: Likewise.
	* testsuite/30_threads/condition_variable_any/53830.cc: Likewise.
	* testsuite/30_threads/condition_variable_any/cond.cc: Likewise.
	* testsuite/30_threads/condition_variable_any/cons/1.cc: Likewise.
	* testsuite/30_threads/condition_variable_any/members/1.cc: Likewise.
	* testsuite/30_threads/condition_variable_any/members/2.cc: Likewise.
	* testsuite/30_threads/future/cons/move.cc: Likewise.
	* testsuite/30_threads/future/members/45133.cc: Likewise.
	* testsuite/30_threads/future/members/get.cc: Likewise.
	* testsuite/30_threads/future/members/get2.cc: Likewise.
	* testsuite/30_threads/future/members/share.cc: Likewise.
	* testsuite/30_threads/future/members/valid.cc: Likewise.
	* testsuite/30_threads/future/members/wait.cc: Likewise.
	* testsuite/30_threads/future/members/wait_for.cc: Likewise.
	* testsuite/30_threads/future/members/wait_until.cc: Likewise.
	* testsuite/30_threads/lock/1.cc: Likewise.
	* testsuite/30_threads/lock/2.cc: Likewise.
	* testsuite/30_threads/lock/3.cc: Likewise.
	* testsuite/30_threads/lock/4.cc: Likewise.
	* testsuite/30_threads/mutex/cons/1.cc: Likewise.
	* testsuite/30_threads/mutex/dest/destructor_locked.cc: Likewise.
	* testsuite/30_threads/mutex/lock/1.cc: Likewise.
	* testsuite/30_threads/mutex/native_handle/1.cc: Likewise.
	* testsuite/30_threads/mutex/native_handle/typesizes.cc: Likewise.
	* testsuite/30_threads/mutex/try_lock/1.cc: Likewise.
	* testsuite/30_threads/mutex/try_lock/2.cc: Likewise.
	* testsuite/30_threads/mutex/unlock/1.cc: Likewise.
	* testsuite/30_threads/mutex/unlock/2.cc: Likewise.
	* testsuite/30_threads/packaged_task/49668.cc: Likewise.
	* testsuite/30_threads/packaged_task/60564.cc: Likewise.
	* testsuite/30_threads/packaged_task/cons/1.cc: Likewise.
	* testsuite/30_threads/packaged_task/cons/2.cc: Likewise.
	* testsuite/30_threads/packaged_task/cons/3.cc: Likewise.
	* testsuite/30_threads/packaged_task/cons/56492.cc: Likewise.
	* testsuite/30_threads/packaged_task/cons/alloc.cc: Likewise.
	* testsuite/30_threads/packaged_task/cons/move.cc: Likewise.
	* testsuite/30_threads/packaged_task/cons/move_assign.cc: Likewise.
	* testsuite/30_threads/packaged_task/members/at_thread_exit.cc:
	Likewise.
	* testsuite/30_threads/packaged_task/members/get_future.cc: Likewise.
	* testsuite/30_threads/packaged_task/members/get_future2.cc: Likewise.
	* testsuite/30_threads/packaged_task/members/invoke.cc: Likewise.
	* testsuite/30_threads/packaged_task/members/invoke2.cc: Likewise.
	* testsuite/30_threads/packaged_task/members/invoke3.cc: Likewise.
	* testsuite/30_threads/packaged_task/members/invoke4.cc: Likewise.
	* testsuite/30_threads/packaged_task/members/invoke5.cc: Likewise.
	* testsuite/30_threads/packaged_task/members/reset.cc: Likewise.
	* testsuite/30_threads/packaged_task/members/reset2.cc: Likewise.
	* testsuite/30_threads/packaged_task/members/swap.cc: Likewise.
	* testsuite/30_threads/packaged_task/members/valid.cc: Likewise.
	* testsuite/30_threads/promise/60966.cc: Likewise.
	* testsuite/30_threads/promise/cons/1.cc: Likewise.
	* testsuite/30_threads/promise/cons/alloc.cc: Likewise.
	* testsuite/30_threads/promise/cons/move.cc: Likewise.
	* testsuite/30_threads/promise/cons/move_assign.cc: Likewise.
	* testsuite/30_threads/promise/members/at_thread_exit.cc: Likewise.
	* testsuite/30_threads/promise/members/at_thread_exit2.cc: Likewise.
	* testsuite/30_threads/promise/members/get_future.cc: Likewise.
	* testsuite/30_threads/promise/members/get_future2.cc: Likewise.
	* testsuite/30_threads/promise/members/set_exception.cc: Likewise.
	* testsuite/30_threads/promise/members/set_exception2.cc: Likewise.
	* testsuite/30_threads/promise/members/set_value.cc: Likewise.
	* testsuite/30_threads/promise/members/set_value2.cc: Likewise.
	* testsuite/30_threads/promise/members/set_value3.cc: Likewise.
	* testsuite/30_threads/promise/members/swap.cc: Likewise.
	* testsuite/30_threads/recursive_mutex/cons/1.cc: Likewise.
	* testsuite/30_threads/recursive_mutex/dest/destructor_locked.cc:
	Likewise.
	* testsuite/30_threads/recursive_mutex/lock/1.cc: Likewise.
	* testsuite/30_threads/recursive_mutex/native_handle/1.cc: Likewise.
	* testsuite/30_threads/recursive_mutex/native_handle/typesizes.cc:
	Likewise.
	* testsuite/30_threads/recursive_mutex/try_lock/1.cc: Likewise.
	* testsuite/30_threads/recursive_mutex/try_lock/2.cc: Likewise.
	* testsuite/30_threads/recursive_mutex/unlock/1.cc: Likewise.
	* testsuite/30_threads/recursive_mutex/unlock/2.cc: Likewise.
	* testsuite/30_threads/recursive_timed_mutex/cons/1.cc: Likewise.
	* testsuite/30_threads/recursive_timed_mutex/dest/destructor_locked.cc:
	Likewise.
	* testsuite/30_threads/recursive_timed_mutex/lock/1.cc: Likewise.
	* testsuite/30_threads/recursive_timed_mutex/lock/2.cc: Likewise.
	* testsuite/30_threads/recursive_timed_mutex/native_handle/1.cc:
	Likewise.
	* testsuite/30_threads/recursive_timed_mutex/native_handle/typesizes.cc:
	Likewise.
	* testsuite/30_threads/recursive_timed_mutex/try_lock/1.cc: Likewise.
	* testsuite/30_threads/recursive_timed_mutex/try_lock/2.cc: Likewise.
	* testsuite/30_threads/recursive_timed_mutex/try_lock_for/1.cc:
	Likewise.
	* testsuite/30_threads/recursive_timed_mutex/try_lock_for/2.cc:
	Likewise.
	* testsuite/30_threads/recursive_timed_mutex/try_lock_for/3.cc:
	Likewise.
	* testsuite/30_threads/recursive_timed_mutex/try_lock_until/1.cc:
	Likewise.
	* testsuite/30_threads/recursive_timed_mutex/try_lock_until/2.cc:
	Likewise.
	* testsuite/30_threads/recursive_timed_mutex/unlock/1.cc: Likewise.
	* testsuite/30_threads/recursive_timed_mutex/unlock/2.cc: Likewise.
	* testsuite/30_threads/shared_future/cons/move.cc: Likewise.
	* testsuite/30_threads/shared_future/members/45133.cc: Likewise.
	* testsuite/30_threads/shared_future/members/get.cc: Likewise.
	* testsuite/30_threads/shared_future/members/get2.cc: Likewise.
	* testsuite/30_threads/shared_future/members/valid.cc: Likewise.
	* testsuite/30_threads/shared_future/members/wait.cc: Likewise.
	* testsuite/30_threads/shared_future/members/wait_for.cc: Likewise.
	* testsuite/30_threads/shared_future/members/wait_until.cc: Likewise.
	* testsuite/30_threads/shared_lock/cons/1.cc: Likewise.
	* testsuite/30_threads/shared_lock/cons/2.cc: Likewise.
	* testsuite/30_threads/shared_lock/cons/3.cc: Likewise.
	* testsuite/30_threads/shared_lock/cons/4.cc: Likewise.
	* testsuite/30_threads/shared_lock/cons/5.cc: Likewise.
	* testsuite/30_threads/shared_lock/cons/6.cc: Likewise.
	* testsuite/30_threads/shared_lock/locking/1.cc: Likewise.
	* testsuite/30_threads/shared_lock/locking/2.cc: Likewise.
	* testsuite/30_threads/shared_lock/locking/3.cc: Likewise.
	* testsuite/30_threads/shared_lock/locking/4.cc: Likewise.
	* testsuite/30_threads/shared_lock/modifiers/1.cc: Likewise.
	* testsuite/30_threads/shared_mutex/cons/1.cc: Likewise.
	* testsuite/30_threads/shared_mutex/try_lock/1.cc: Likewise.
	* testsuite/30_threads/shared_mutex/try_lock/2.cc: Likewise.
	* testsuite/30_threads/shared_mutex/unlock/1.cc: Likewise.
	* testsuite/30_threads/shared_timed_mutex/cons/1.cc: Likewise.
	* testsuite/30_threads/shared_timed_mutex/try_lock/1.cc: Likewise.
	* testsuite/30_threads/shared_timed_mutex/try_lock/2.cc: Likewise.
	* testsuite/30_threads/shared_timed_mutex/try_lock/3.cc: Likewise.
	* testsuite/30_threads/shared_timed_mutex/unlock/1.cc: Likewise.
	* testsuite/30_threads/this_thread/1.cc: Likewise.
	* testsuite/30_threads/this_thread/sleep_for-mt.cc: Likewise.
	* testsuite/30_threads/this_thread/sleep_until-mt.cc: Likewise.
	* testsuite/30_threads/thread/cons/1.cc: Likewise.
	* testsuite/30_threads/thread/cons/2.cc: Likewise.
	* testsuite/30_threads/thread/cons/3.cc: Likewise.
	* testsuite/30_threads/thread/cons/4.cc: Likewise.
	* testsuite/30_threads/thread/cons/49668.cc: Likewise.
	* testsuite/30_threads/thread/cons/5.cc: Likewise.
	* testsuite/30_threads/thread/cons/6.cc: Likewise.
	* testsuite/30_threads/thread/cons/7.cc: Likewise.
	* testsuite/30_threads/thread/cons/8.cc: Likewise.
	* testsuite/30_threads/thread/cons/9.cc: Likewise.
	* testsuite/30_threads/thread/cons/moveable.cc: Likewise.
	* testsuite/30_threads/thread/cons/terminate.cc: Likewise.
	* testsuite/30_threads/thread/members/1.cc: Likewise.
	* testsuite/30_threads/thread/members/2.cc: Likewise.
	* testsuite/30_threads/thread/members/3.cc: Likewise.
	* testsuite/30_threads/thread/members/4.cc: Likewise.
	* testsuite/30_threads/thread/members/5.cc: Likewise.
	* testsuite/30_threads/thread/members/hardware_concurrency.cc:
	Likewise.
	* testsuite/30_threads/thread/native_handle/typesizes.cc: Likewise.
	* testsuite/30_threads/thread/swap/1.cc: Likewise.
	* testsuite/30_threads/timed_mutex/cons/1.cc: Likewise.
	* testsuite/30_threads/timed_mutex/dest/destructor_locked.cc:
	Likewise.
	* testsuite/30_threads/timed_mutex/lock/1.cc: Likewise.
	* testsuite/30_threads/timed_mutex/native_handle/1.cc: Likewise.
	* testsuite/30_threads/timed_mutex/native_handle/typesizes.cc:
	Likewise.
	* testsuite/30_threads/timed_mutex/try_lock/1.cc: Likewise.
	* testsuite/30_threads/timed_mutex/try_lock/2.cc: Likewise.
	* testsuite/30_threads/timed_mutex/try_lock_for/1.cc: Likewise.
	* testsuite/30_threads/timed_mutex/try_lock_for/2.cc: Likewise.
	* testsuite/30_threads/timed_mutex/try_lock_for/3.cc: Likewise.
	* testsuite/30_threads/timed_mutex/try_lock_until/1.cc: Likewise.
	* testsuite/30_threads/timed_mutex/try_lock_until/2.cc: Likewise.
	* testsuite/30_threads/timed_mutex/try_lock_until/57641.cc: Likewise.
	* testsuite/30_threads/timed_mutex/unlock/1.cc: Likewise.
	* testsuite/30_threads/timed_mutex/unlock/2.cc: Likewise.
	* testsuite/30_threads/try_lock/1.cc: Likewise.
	* testsuite/30_threads/try_lock/2.cc: Likewise.
	* testsuite/30_threads/try_lock/3.cc: Likewise.
	* testsuite/30_threads/try_lock/4.cc: Likewise.
	* testsuite/30_threads/unique_lock/cons/1.cc: Likewise.
	* testsuite/30_threads/unique_lock/cons/2.cc: Likewise.
	* testsuite/30_threads/unique_lock/cons/3.cc: Likewise.
	* testsuite/30_threads/unique_lock/cons/4.cc: Likewise.
	* testsuite/30_threads/unique_lock/cons/5.cc: Likewise.
	* testsuite/30_threads/unique_lock/cons/6.cc: Likewise.
	* testsuite/30_threads/unique_lock/locking/1.cc: Likewise.
	* testsuite/30_threads/unique_lock/locking/2.cc: Likewise.
	* testsuite/30_threads/unique_lock/locking/3.cc: Likewise.
	* testsuite/30_threads/unique_lock/locking/4.cc: Likewise.
	* testsuite/30_threads/unique_lock/modifiers/1.cc: Likewise.
2020-08-23 23:18:48 -03:00
GCC Administrator
3eeede6de7 Daily bump. 2020-08-22 00:16:24 +00:00
Jonathan Wakely
9b5d4f6e66 libstdc++: Do not check "cold" name on darwin [PR 96736]
libstdc++-v3/ChangeLog:

	PR libstdc++/96736
	* testsuite/17_intro/headers/c++1998/all_attributes.cc: Do not
	test "cold" on darwin.
	* testsuite/17_intro/headers/c++2011/all_attributes.cc:
	Likewise.
	* testsuite/17_intro/headers/c++2014/all_attributes.cc:
	Likewise.
	* testsuite/17_intro/headers/c++2017/all_attributes.cc:
	Likewise.
	* testsuite/17_intro/headers/c++2020/all_attributes.cc:
	Likewise.
2020-08-21 18:24:40 +01:00
Jonathan Wakely
988fb2f597 libstdc++: Skip PSTL tests when installed TBB is too old [PR 96718]
These tests do not actually require TBB, because they only inspect the
feature test macros present in the headers. However, if TBB is installed
then its headers will be included, and the version will be checked. If
the version is too old, compilation fails due to a #error directive.

This change disables the tests if TBB is not present, so that we skip
them instead of failing.

libstdc++-v3/ChangeLog:

	PR libstdc++/96718
	* testsuite/25_algorithms/pstl/feature_test-2.cc: Require
	tbb-backend effective target.
	* testsuite/25_algorithms/pstl/feature_test-3.cc: Likewise.
	* testsuite/25_algorithms/pstl/feature_test-5.cc: Likewise.
	* testsuite/25_algorithms/pstl/feature_test.cc: Likewise.
2020-08-21 12:01:05 +01:00
GCC Administrator
5b9a3d2a05 Daily bump. 2020-08-21 00:16:23 +00:00
Jonathan Wakely
1531d8df6e libstdc++: Fix typo in ChangeLog 2020-08-20 21:56:43 +01:00
Jonathan Wakely
5e9ad288eb libstdc++: Make incrementable<__int128> satisfied in strict mode
This adds specializations of std::incrementable_traits so that 128-bit
integers are always considered incrementable (and therefore usable with
std::ranges::iota_view) even when they don't satisfy std::integral.

libstdc++-v3/ChangeLog:

	* include/bits/iterator_concepts.h [__STRICT_ANSI__]
	(incrementable_traits<__int128>): Define specialization.
	(incrementable_traits<unsigned __int128>): Likewise.
	* testsuite/std/ranges/iota/96042.cc: Test iota_view with
	__int128.
2020-08-20 19:42:02 +01:00
GCC Administrator
04e23a4051 Daily bump. 2020-08-20 00:16:34 +00:00
Jonathan Wakely
e6e01618e8 libstdc++: Make make-unsigned-like-t<__int128> work [PR 96042]
As well as ensuring that numeric_limits<__int128> is defined, we need to
ensure that make-unsigned-like-t and to-unsigned-like work correctly for
128-bit integers in strict mode. This ensures that a subrange created
from an iota_view's iterator and sentinel can represent its size.

Co-authored-by: Patrick Palka  <ppalka@redhat.com>

libstdc++-v3/ChangeLog:

2020-08-19  Jonathan Wakely  <jwakely@redhat.com>
	    Patrick Palka  <ppalka@redhat.com>

	PR libstdc++/96042
	* include/bits/range_access.h (__detail::__to_unsigned_like):
	Do not use make_unsigned_t<T> in the return type, as it can
	result in an error before the integral<T> constraint is checked.
	[__STRICT_ANSI__]: Add overloads for 128-bit integer types.
	(__detail::__make_unsigned_like_t): Define as the return type
	of __to_unsigned_like.
	* testsuite/std/ranges/subrange/96042.cc: New test.
2020-08-19 20:36:10 +01:00
Jonathan Wakely
5abc821556 libstdc++: Remove deprecated comparison operators for RB trees
These functions were deprecated in GCC 9.1.0 because they are never used
by the library. This patch removes them for GCC 11.

libstdc++-v3/ChangeLog:

	* include/bits/stl_tree.h (operator!=, operator>, operator<=)
	(operator>=): Remove deprecated functions.
2020-08-19 17:04:49 +01:00
Jonathan Wakely
386fd16c55 libstdc++: Make __int128 meet integer-class requirements [PR 96042]
Because __int128 can be used as the difference type for iota_view, we
need to ensure that it meets the requirements of an integer-class type.
The requirements in [iterator.concept.winc] p10 include numeric_limits
being specialized and giving meaningful answers. Currently we only
specialize numeric_limits for non-standard integer types in non-strict
modes.  However, nothing prevents us from defining an explicit
specialization for any implementation-defined type, so it doesn't matter
whether std::is_integral<__int128> is true or not.

This patch ensures that the numeric_limits specializations for signed
and unsigned __int128 are defined whenever __int128 is available. It
also makes the __numeric_traits and __int_limits helpers work for
__int128, via a new __gnu_cxx::__is_integer_nonstrict trait.

libstdc++-v3/ChangeLog:

	PR libstdc++/96042
	* include/ext/numeric_traits.h (__is_integer_nonstrict): New
	trait which is true for 128-bit integers even in strict modes.
	(__numeric_traits_integer, __numeric_traits): Use
	__is_integer_nonstrict instead of __is_integer.
	* include/std/limits [__STRICT_ANSI__ && __SIZEOF_INT128__]
	(numeric_limits<__int128>, (numeric_limits<unsigned __int128>):
	Define.
	* testsuite/std/ranges/iota/96042.cc: New test.
2020-08-19 16:49:07 +01:00
Jonathan Wakely
1e235788bb libstdc++: Mention new macros in comments
libstdc++-v3/ChangeLog:

	* include/bits/c++config (_GLIBCXX_DEPRECATED_SUGGEST)
	(_GLIBCXX11_DEPRECATED, _GLIBCXX11_DEPRECATED_SUGGEST)
	(_GLIBCXX17_DEPRECATED_SUGGEST, _GLIBCXX20_DEPRECATED_SUGGEST):
	Add new macros to comment.
2020-08-19 14:51:32 +01:00
Patrick Palka
e6c76f0d33 libstdc++: integer-class types as per [iterator.concept.winc]
This implements signed and unsigned integer-class types, whose width is
one bit larger than the widest supported signed and unsigned integral
type respectively.  In our case this is either __int128 and unsigned
__int128, or long long and unsigned long long.

Internally, the two integer-class types are represented as a largest
supported unsigned integral type plus one extra bit.  The signed
integer-class type is represented in two's complement form with the
extra bit acting as the sign bit.

libstdc++-v3/ChangeLog:

	* include/Makefile.am (bits_headers): Add new header
	<bits/max_size_type.h>.
	* include/Makefile.in: Regenerate.
	* include/bits/iterator_concepts.h
	(ranges::__detail::__max_diff_type): Remove definition, replace
	with forward declaration of class __max_diff_type.
	(__detail::__max_size_type): Remove definition, replace with
	forward declaration of class __max_size_type.
	(__detail::__is_unsigned_int128, __is_signed_int128)
	(__is_int128): New concepts.
	(__detail::__is_integer_like): Accept __int128 and unsigned
	__int128.
	(__detail::__is_signed_integer_like): Accept __int128.
	* include/bits/max_size_type.h: New header.
	* include/bits/range_access.h: Include <bits/max_size_type.h>.
	(__detail::__to_unsigned_like): Two new overloads.
	* testsuite/std/ranges/iota/difference_type.cc: New test.
	* testsuite/std/ranges/iota/max_size_type.cc: New test.
2020-08-19 09:12:55 -04:00
Jonathan Wakely
eef9bf4ca8 libstdc++: Add deprecated attributes to old iostream members
Back in 2017 I removed these prehistoric members (which were deprecated
since C++98) for C++17 mode. But I didn't add deprecated attributes to
most of them, so users didn't get any warning they would be going away.
Apparently some poor souls do actually use some of these names, and so
now that GCC 11 defaults to -std=gnu++17 some code has stopped
compiling.

This adds deprecated attributes to them, so that C++98/03/11/14 code
will get a warning if it uses them. I'll also backport this to the
release branches so that users can find out about the deprecation before
they start using C++17.

In order to give deprecated warnings even in C++98 mode this patch makes
_GLIBCXX_DEPRECATED work even for C++98, adds _GLIBCXX11_DEPRECATED for
the old meaning of _GLIBCXX_DEPRECATED, and adds new macros such as
_GLIBCXX_DEPRECATED_SUGGEST for suggesting alternatives to deprecated
features.

libstdc++-v3/ChangeLog:

	* include/bits/c++config (_GLIBCXX_DEPRECATED): Define for all
	standard modes.
	(_GLIBCXX_DEPRECATED_SUGGEST): New macro for "use 'foo' instead"
	message in deprecated warnings.
	(_GLIBCXX11_DEPRECATED, _GLIBCXX11_DEPRECATED_SUGGEST): New
	macros for marking features derpecated in C++11.
	(_GLIBCXX17_DEPRECATED_SUGGEST, _GLIBCXX20_DEPRECATED_SUGGEST):
	New macros.
	* include/backward/auto_ptr.h (auto_ptr_ref, auto_ptr<void>):
	Use _GLIBCXX11_DEPRECATED instead of _GLIBCXX_DEPRECATED.
	(auto_ptr): Use _GLIBCXX11_DEPRECATED_SUGGEST.
	* include/backward/binders.h (binder1st, binder2nd): Likewise.
	* include/bits/ios_base.h (io_state, open_mode, seek_dir)
	(streampos, streamoff): Use _GLIBCXX_DEPRECATED_SUGGEST.
	* include/std/streambuf (stossc): Replace C++11 attribute
	with _GLIBCXX_DEPRECATED_SUGGEST.
	* include/std/type_traits (__is_nullptr_t): Use
	_GLIBCXX_DEPRECATED_SUGGEST instead of _GLIBCXX_DEPRECATED.
	* testsuite/27_io/types/1.cc: Check for deprecated warnings.
	Also check for io_state, open_mode and seek_dir typedefs.
2020-08-19 12:13:23 +01:00
Antony Polukhin
69f571ffc5 libstdc++: assert that type traits are not misused with incomplete types [PR 71579]
libstdc++-v3/ChangeLog:

2020-08-19  Antony Polukhin  <antoshkka@gmail.com>

	PR libstdc++/71579
	* include/std/type_traits (invoke_result, is_nothrow_invocable_r)
	Add static_asserts to make sure that the argument of the type
	trait is not misused with incomplete types.
	(is_swappable_with, is_nothrow_swappable_with): Add static_asserts
	to make sure that the first and second arguments of the type trait
	are not misused with incomplete types.
	* testsuite/20_util/invoke_result/incomplete_neg.cc: New test.
	* testsuite/20_util/is_nothrow_invocable/incomplete_neg.cc: New test.
	* testsuite/20_util/is_nothrow_swappable/incomplete_neg.cc: New test.
	* testsuite/20_util/is_nothrow_swappable_with/incomplete_neg.cc: New
	test.
	* testsuite/20_util/is_swappable_with/incomplete_neg.cc: New test.
2020-08-19 12:12:40 +01:00
GCC Administrator
5c265693bf Daily bump. 2020-08-19 00:16:23 +00:00
David Edelsohn
9599c9853a aix: Support libsupc++ as a FAT library
Build libstdc++++ static library libsupc++.a as a FAT 32/64 bit library.

libstdc++-v3/ChangeLog:

2020-08-18  David Edelsohn  <dje.gcc@gmail.com>
	    Clement Chigot  <clement.chigot@atos.net>

	* config/os/aix/t-aix: Add complementary mode object files to
	libsupc++.a
2020-08-18 16:55:10 -04:00
Jonathan Wakely
6c1a58b7fb libstdc++: Add "cold" to tests for reserved attribute names
libstdc++-v3/ChangeLog:

	* testsuite/17_intro/headers/c++1998/all_attributes.cc: Check
	"cold" isn't used in the library. Also check <cxxabi.h>.
	* testsuite/17_intro/headers/c++2011/all_attributes.cc:
	Likewise.
	* testsuite/17_intro/headers/c++2014/all_attributes.cc:
	Likewise.
	* testsuite/17_intro/headers/c++2017/all_attributes.cc:
	Likewise.
	* testsuite/17_intro/headers/c++2020/all_attributes.cc:
	Likewise.
2020-08-18 15:37:33 +01:00
Jonathan Wakely
bb1b7f087b libstdc++: Remove redundant copying of std::async arguments [PR 69724]
As was previously done for std::thread, this removes an unnecessary copy
of an rvalue of type thread::_Invoker. Instead of creating the rvalue
and then moving that into the shared state, the member of the shared
state is initialized directly from the forwarded callable and bound
arguments.

This also slightly simplifies std::thread creation to remove the
_S_make_state helper function.

libstdc++-v3/ChangeLog:

	PR libstdc++/69724
	* include/std/future (__future_base::_S_make_deferred_state)
	(__future_base::_S_make_async_state): Remove.
	(__future_base::_Deferred_state): Change constructor to accept a
	parameter pack of arguments and forward them to the call
	wrapper.
	(__future_base::_Async_state_impl): Likewise. Replace lambda
	expression with a named member function.
	(async): Construct state object directly from the arguments,
	instead of using thread::__make_invoker, _S_make_deferred_state
	and _S_make_async_state. Move shared state into the returned
	future.
	* include/std/thread (thread::_Call_wrapper): New alias
	template for use by constructor and std::async.
	(thread::thread(Callable&&, Args&&...)): Create state object
	directly instead of using _S_make_state.
	(thread::__make_invoker, thread::__decayed_tuple)
	(thread::_S_make_state): Remove.
	* testsuite/30_threads/async/69724.cc: New test.
2020-08-18 14:28:38 +01:00
GCC Administrator
deee2322a2 Daily bump. 2020-08-18 00:16:26 +00:00
Jonathan Wakely
91e6226f88 libstdc++: Remove inheritance from elements in std::tuple
This fixes a number of std::tuple bugs by no longer making use of the
empty base-class optimization. By using the C++20 [[no_unique_address]]
attribute we can always store the element as a data member, while still
compressing the layout of tuples containing empty types.

Since we no longer use inheritance we could also apply the compression
optimization for final types and for tuples of tuples, but doing so
would be an ABI break.

Using [[no_unique_address]] more liberally for the unstable std::__8
configuration is left for a later date. There may be reasons not to
apply the attribute unconditionally, e.g. see the discussion about
guaranteed elision in PR 94062.

libstdc++-v3/ChangeLog:

	PR libstdc++/55713
	PR libstdc++/71096
	PR libstdc++/93147
	* include/std/tuple [__has_cpp_attribute(no_unique_address)]
	(_Head_base<Idx, Head, true>): New definition of the partial
	specialization, using [[no_unique_address]] instead of
	inheritance.
	* testsuite/libstdc++-prettyprinters/48362.cc: Adjust expected
	output.
	* testsuite/20_util/tuple/comparison_operators/93147.cc: New test.
	* testsuite/20_util/tuple/creation_functions/55713.cc: New test.
	* testsuite/20_util/tuple/element_access/71096.cc: New test.
2020-08-17 15:27:51 +01:00
GCC Administrator
661ee09b8b Daily bump. 2020-08-15 00:16:22 +00:00
Lewis Hyatt
129a1319c0 diagnostics: Add new option -fdiagnostics-plain-output
Adds the new option -fdiagnostics-plain-output, which is an alias for
several others:

    -fno-diagnostics-show-caret
    -fno-diagnostics-show-line-numbers
    -fdiagnostics-color=never
    -fdiagnostics-urls=never

The idea is that in the future, if the default behavior of diagnostics is
changed to add some fancy feature or other, then the
-fdiagnostics-plain-output option will also be changed accordingly so that
the old behavior is preserved in the presence of this option. This allows
us to use -fdiagnostics-plain-output in in the testsuite, such that the
testsuite (specifically the setting of TEST_ALWAYS_FLAGS in prune.exp)
does not need to be touched whenever diagnostics get a new look. This also
removes the need to add workarounds to compat.exp for every new option
that may be needed in a newer version of the compiler, but is not
supported in older versions.

gcc/ChangeLog:

	* common.opt: Add new option -fdiagnostics-plain-output.
	* doc/invoke.texi: Document it.
	* opts-common.c (decode_cmdline_options_to_array): Implement it.
	(decode_cmdline_option): Add missing const qualifier to argv.

libstdc++-v3/ChangeLog:

	* testsuite/lib/libstdc++.exp: Use the new option
	-fdiagnostics-plain-output.

gcc/testsuite/ChangeLog:

	* lib/prune.exp: Change TEST_ALWAYS_FLAGS to use -fdiagnostics-plain-output.
	* lib/c-compat.exp: Adapt to the prune.exp change.
2020-08-14 09:29:19 -04:00
GCC Administrator
b3cb56060b Daily bump. 2020-08-14 00:16:24 +00:00
Jonathan Wakely
55484a0f81 libstdc++: Deprecate the --enable-cheaders=c_std configuration
These headers do not offer any tangible benefit compared to the default
c_global version. They are not actively maintained meaning that they
have bugs which have already been fixed for the c_global headers.

This change adds a warning if they are used, and requires a new
--enable-cheaders-obsolete option to allow their use. Unless we receive
reports from users who rely on the c_std headers they should be removed
at some point in future.

libstdc++-v3/ChangeLog:

	* acinclude.m4 (GLIBCXX_ENABLE_CHEADERS): Warn if the c_std
	option is used and fail unless --enable-cheaders-obsolete is
	also used.
	* configure: Regenerate.
2020-08-13 16:33:28 +01:00
GCC Administrator
afdd220a0c Daily bump. 2020-08-13 00:16:23 +00:00
Jonathan Wakely
86f8741485 libstdc++: ChangeLog corrections
I got the name of the __stat64 type wrong in r11-2628 and missed the
bugzilla PR number in r11-2632.
2020-08-12 20:42:04 +01:00
Jonathan Wakely
c2fb0a1a2e libstdc++: Make self-move well-defined for containers [PR 85828]
The C++ LWG recently confirmed that self-move assignment should not have
undefined behaviour for standard containers (see the proposed resolution
of LWG 2839). The result should be a valid but unspecified value, just
like other times when a container is moved from.

Our std::list, std::__cxx11::basic_string and unordered containers all
have bugs which result in undefined behaviour.

For std::list the problem is that we clear the previous contents using
_M_clear() instead of clear(). This means the _M_next, _M_prev and
_M_size members are not zeroed, and so after we "update" them (with
their existing values), we are left with dangling pointers and a
non-zero size, but no elements.

For the unordered containers the problem is similar. _Hashtable first
deallocates the existing contents, then takes ownership of the pointers
from the RHS object (which has just had its contents deallocated so the
pointers are dangling).

For std::basic_string it's a little more subtle. When the string is
local (i.e. fits in the SSO buffer) we use char_traits::copy to copy the
contents from this->data() to __rhs.data(). When &__rhs == this that
copy violates the precondition that the ranges don't overlap. We only
need to check for self-move for this case where it's local, because the
only other case that can be true for self-move is that it's non-local
but the allocators compare equal. In that case the data pointer is
neither deallocated nor leaked, so the result is well-defined.

This patch also makes a small optimization for std::deque move
assignment, to use the efficient move when is_always_equal is false, but
the allocators compare equal at runtime.

Finally, we need to remove all the Debug Mode checks which abort the
program when a self-move is detected, because it's not undefined to do
that.

Before PR 85828 can be closed we should also look into fixing
std::shuffle so it doesn't do any redundant self-swaps.

libstdc++-v3/ChangeLog:

	PR libstdc++/85828
	* include/bits/basic_string.h (operator=(basic_string&&)): Check
	for self-move before copying with char_traits::copy.
	* include/bits/hashtable.h (operator=(_Hashtable&&)): Check for
	self-move.
	* include/bits/stl_deque.h (_M_move_assign1(deque&&, false_type)):
	Check for equal allocators.
	* include/bits/stl_list.h (_M_move_assign(list&&, true_type)):
	Call clear() instead of _M_clear().
	* include/debug/formatter.h (__msg_self_move_assign): Change
	comment.
	* include/debug/macros.h (__glibcxx_check_self_move_assign):
	(_GLIBCXX_DEBUG_VERIFY): Remove.
	* include/debug/safe_container.h (operator=(_Safe_container&&)):
	Remove assertion check for safe move and make it well-defined.
	* include/debug/safe_iterator.h (operator=(_Safe_iterator&&)):
	Remove assertion check for self-move.
	* include/debug/safe_local_iterator.h
	(operator=(_Safe_local_iterator&&)): Likewise.
	* testsuite/21_strings/basic_string/cons/char/self_move.cc: New test.
	* testsuite/23_containers/deque/cons/self_move.cc: New test.
	* testsuite/23_containers/forward_list/cons/self_move.cc: New test.
	* testsuite/23_containers/list/cons/self_move.cc: New test.
	* testsuite/23_containers/set/cons/self_move.cc: New test.
	* testsuite/23_containers/unordered_set/cons/self_move.cc: New test.
	* testsuite/23_containers/vector/cons/self_move.cc: New test.
2020-08-12 20:36:00 +01:00
GCC Administrator
a64938091b Daily bump. 2020-08-12 00:16:27 +00:00
François Dumont
8b7af071b0 libstdc++: Implement DR 526 on [forward_]list remove_if/unique [PR 91620]
Respect DR 526 in implementation of std::[forward_]list remove/remove_if/unique.
[forward_]list::remove was already implementing it but the implementation has
been modified to generalize the following pattern. All nodes to remove are
collected in an intermediate [forward_]list which purpose is just to be
detroyed once out of scope.

libstdc++-v3/ChangeLog:

	PR libstdc++/91620
	* include/bits/forward_list.tcc (forward_list<>::remove): Collect nodes
	to destroy in an intermediate forward_list.
	(forward_list<>::remove_if, forward_list<>::unique): Likewise.
	* include/bits/list.tcc (list<>::remove, list<>::unique): Likewise.
	(list<>::remove_if): Likewise.
	* include/debug/forward_list (forward_list<>::_M_erase_after): Remove.
	(forward_list<>::erase_after): Adapt.
	(forward_list<>::remove, forward_list<>::remove_if): Collect nodes to
	destroy in an intermediate forward_list.
	(forward_list<>::unique): Likewise.
	* include/debug/list (list<>::remove, list<>::unique): Likewise.
	(list<>::remove_if): Likewise.
	* testsuite/23_containers/forward_list/operations/91620.cc: New test.
	* testsuite/23_containers/list/operations/91620.cc: New test.
2020-08-11 21:30:05 +02:00
Jonathan Wakely
fe8d7fec4d libstdc++: Fix failing tests for AIX
These two tests fail on AIX because <sys/thread.h> defines struct thread
in the global namespace (despite it not being a reserved name). That
means the using-declaration that adds it to the global namespace causes
a redeclaration error.

libstdc++-v3/ChangeLog:

	* testsuite/30_threads/thread/cons/84535.cc: Use a custom
	namespace.
	* testsuite/30_threads/thread/cons/lwg2097.cc: Likewise.
2020-08-11 16:16:22 +01:00
Jonathan Wakely
18095be170 libstdc++: Make Networking TS work without gthreads [PR 89760]
Make the experimental Networking TS code work without std::mutex and
std::condition_variable.

libstdc++-v3/ChangeLog:

	PR libstdc++/89760
	* include/experimental/executor [!_GLIBCXX_HAS_GTHREADS]:
	(execution_context::mutex_type): Define dummy mutex type.
	(system_context): Use execution_context::mutex_type.
	(system_context) [!_GLIBCXX_HAS_GTHREADS]: Define dummy
	thread and condition variable types.
	[!_GLIBCXX_HAS_GTHREADS] (system_context::_M_run()): Do not
	define.
	(system_context::_M_post) [!_GLIBCXX_HAS_GTHREADS]: Throw
	an exception when threads aren't available.
	(strand::running_in_this_thread()): Defer to _M_state.
	(strand::_State::running_in_this_thread()): New function.
	(use_future_t): Do not depend on _GLIBCXX_USE_C99_STDINT_TR1.
	* include/experimental/io_context (io_context): Use the
	execution_context::mutex_type alias. Replace stack of thread
	IDs with counter.
	* testsuite/experimental/net/execution_context/use_service.cc:
	Enable test for non-pthread targets.
2020-08-11 16:16:22 +01:00
Jonathan Wakely
2a6918e4fa libstdc++: Make net::system_context tag type constructor explicit
libstdc++-v3/ChangeLog:

	* include/experimental/executor (system_context::a__tag): Make
	default constructor explicit.
2020-08-11 16:16:21 +01:00
Jonathan Wakely
61759518ad libstdc++: Fix net::system_context stop condition
libstdc++-v3/ChangeLog:

	* include/experimental/executor (system_context::_M_run()):
	Fix predicate.
	* testsuite/experimental/net/system_context/1.cc: New test.
2020-08-11 16:16:21 +01:00
Jonathan Wakely
35e5294c4b libstdc++: Fix <stop_token> to compile without gthreads
libstdc++-v3/ChangeLog:

	* include/std/stop_token: Check _GLIBCXX_HAS_GTHREADS using
	#ifdef instead of #if.
	(stop_token::_S_yield()): Check _GLIBCXX_HAS_GTHREADS before
	using __gthread_yield.
2020-08-11 16:16:21 +01:00
Jonathan Wakely
5bbb1f3000 libstdc++: Make std::this_thread functions work without gthreads
The only function in namespace std::this_thread that actually depends on
thread support being present is this_thread::get_id(). The other
functions (yield, sleep_for and sleep_until) can be defined for targets
without gthreads.

A small change is needed in std::this_thread::sleep_for which currently
uses the __gthread_time_t typedef. Since it just calls nanosleep
directly, it should use timespec directly instead of the typedef.

Even std::this_thread::get_id() could be made to work, the only
difficulty is that it returns a value of type std:🧵:id and
std::thread is only defined when gthreads support exists.

libstdc++-v3/ChangeLog:

	* include/std/thread [!_GLIBCXX_HAS_GTHREADS] (this_thread::yield)
	(this_thread::sleep_until): Define.
	[!_GLIBCXX_HAS_GTHREADS] (this_thread::sleep_for): Define. Replace
	use of __gthread_time_t typedef with timespec.
	* src/c++11/thread.cc [!_GLIBCXX_HAS_GTHREADS] (__sleep_for):
	Likewise.
	* testsuite/30_threads/this_thread/2.cc: Moved to...
	* testsuite/30_threads/this_thread/yield.cc: ...here.
	* testsuite/30_threads/this_thread/3.cc: Moved to...
	* testsuite/30_threads/this_thread/sleep_for-mt.cc: ...here.
	* testsuite/30_threads/this_thread/4.cc: Moved to...
	* testsuite/30_threads/this_thread/sleep_until-mt.cc: ...here.
	* testsuite/30_threads/this_thread/58038.cc: Add
	dg-require-sleep.
	* testsuite/30_threads/this_thread/60421.cc: Likewise.
	* testsuite/30_threads/this_thread/sleep_for.cc: New test.
	* testsuite/30_threads/this_thread/sleep_until.cc: New test.
2020-08-11 16:16:21 +01:00
GCC Administrator
84005b8abf Daily bump. 2020-08-11 00:16:45 +00:00
Jonathan Wakely
5b065f0563 libstdc++: Fix build for targets without lstat [PR 94681]
libstdc++-v3/ChangeLog:

	PR libstdc++/94681
	* src/c++17/fs_ops.cc (read_symlink): Use posix::lstat instead
	of calling ::lstat directly.
	* src/filesystem/ops.cc (read_symlink): Likewise.
2020-08-10 19:12:12 +01:00
Jonathan Wakely
ed11f7e84b libstdc++: Fix compatibility support in unique_ptr pretty printer
The support for the old std::unique_ptr implementation was failing,
because it tried to work on a typedef instead of the underlying type.
The test supposed to verify the support worked wasn't using a typedef,
so didn't notice the problem.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (UniquePointerPrinter.__init__):
	Use gdb.Type.strip_typedefs().
	* testsuite/libstdc++-prettyprinters/compat.cc: Use a typedef in
	the emulated old type.
2020-08-10 18:47:06 +01:00
Jonathan Wakely
90f7636bf8 libstdc++: Make C++17 ignore --disable-libstdcxx-filesystem-ts [PR 94681]
The configure switch should only affect the optional Filesystem TS, not
the std::filesystem features of C++17.

libstdc++-v3/ChangeLog:

	PR libstdc++/94681
	* acinclude.m4 (GLIBCXX_CHECK_FILESYSTEM_DEPS): Do not depend on
	$enable_libstdcxx_filesystem_ts.
	* configure: Regenerate.
2020-08-10 13:21:59 +01:00
Jonathan Wakely
2203a80a72 libstdc++: Implement LWG 561 for std::inserter
libstdc++-v3/ChangeLog:

	* include/bits/stl_iterator.h (inserter): Do not deduce
	iterator type (LWG 561).
	* testsuite/24_iterators/insert_iterator/dr561.cc: New test.
2020-08-10 12:09:59 +01:00
Jonathan Wakely
8bd92d8097 libstdc++: Check __cpp_exceptions in basic_string::reserve()
If exceptions are disabled then reallocating could abort, so ignore
shrink-to-fit requests.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.tcc [_GLIBCXX_USE_CXX11_ABI=0]
	(basic_string::reserve()): Do nothing if exceptions are not
	enabled.
2020-08-10 12:02:18 +01:00
Jonathan Wakely
9939be5758 libstdc++: Use _wstat64 for Windows [PR 95749]
In order to handle large files on Windows we need to use stat API with
64-bit st_sioze member.

libstdc++-v3/ChangeLog:

	PR libstdc++/95749
	* src/filesystem/ops-common.h [_GLIBCXX_FILESYSTEM_IS_WINDOWS]
	(stat_type): Change to __wstat64.
	(stat): Use _wstat64.
2020-08-10 11:10:26 +01:00
GCC Administrator
a72e938d71 Daily bump. 2020-08-08 00:16:34 +00:00
Jonathan Wakely
de1e3b8795 libstdc++: Fix ambiguous comparisons in __gnu_debug::bitset [PR 96303]
With -pedantic the debug mode bitset has an ambiguous equality
comparison operator, because it tries to compare the non-debug base to
the debug object. The base object can be converted to another debug
bitset, making the same operator== a candidate again.

The fix is to do the comparison on both base objects, so the operator
for the derived type isn't a candidate.

For the inequality operator the same change should be done, but that
operator can be removed entirely for C++20 because it can be synthesized
by the compiler.

I don't think either equality or inequality operators are really needed,
because the public _GLIBCXX_STD_C::bitset base class cam always be
compared using its own comparison operators. I'm not changing that here
though.

libstdc++-v3/ChangeLog:

	PR libstdc++/96303
	* include/debug/bitset (bitset::operator==): Call _M_base() on
	right operand.
	(bitset::operator!=): Likewise, but don't define it at all when
	default comparisons are supported by the compiler.
	* testsuite/23_containers/bitset/operations/96303.cc: New test.
2020-08-07 20:29:11 +01:00
Jonathan Wakely
6c3ae88d1e libstdc++: Replace some VERIFY tests with static_assert
libstdc++-v3/ChangeLog:

	* testsuite/18_support/comparisons/algorithms/partial_order.cc:
	Replace VERIFY with static_assert where the compiler now
	allows it.
	* testsuite/18_support/comparisons/algorithms/weak_order.cc:
	Likewise.
2020-08-07 17:45:42 +01:00
Jonathan Wakely
9e4ebad20a libstdc++: Fix linker script patterns for 32-bit targets
When making the patterns less greedy I forgot to use [jmy] for unsigned
integer parameters.

libstdc++-v3/ChangeLog:

	* config/abi/pre/gnu.ver: Fix wildcards for wstring symbols.
2020-08-07 16:38:51 +01:00
GCC Administrator
74d91e8bb7 Daily bump. 2020-08-07 00:16:33 +00:00
Andrew Luo
140cf935cd libstdc++: Implement P0966 std::string::reserve should not shrink
Remove ability for reserve(n) to reduce a string's capacity. Add a new
reserve() overload that makes a shrink-to-fit request, and make
shrink_to_fit() use that.

libstdc++-v3/ChangeLog:

2020-07-30  Andrew Luo  <andrewluotechnologies@outlook.com>
	    Jonathan Wakely  <jwakely@redhat.com>

	* config/abi/pre/gnu.ver (GLIBCXX_3.4): Use less greedy
	patterns for basic_string members.
	(GLIBCXX_3.4.29): Export new basic_string::reserve symbols.
	* doc/xml/manual/status_cxx2020.xml: Update P0966 status.
	* include/bits/basic_string.h (shrink_to_fit()): Call reserve().
	(reserve(size_type)): Remove default argument.
	(reserve()): Declare new overload.
	[!_GLIBCXX_USE_CXX11_ABI] (shrink_to_fit, reserve): Likewise.
	* include/bits/basic_string.tcc (reserve(size_type)): Remove
	support for shrinking capacity.
	(reserve()): Perform shrink-to-fit operation.
	[!_GLIBCXX_USE_CXX11_ABI] (reserve): Likewise.
	* testsuite/21_strings/basic_string/capacity/1.cc: Adjust to
	reflect new behavior.
	* testsuite/21_strings/basic_string/capacity/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string/capacity/char/18654.cc:
	Likewise.
	* testsuite/21_strings/basic_string/capacity/char/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string/capacity/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string/capacity/wchar_t/18654.cc:
	Likewise.
	* testsuite/21_strings/basic_string/capacity/wchar_t/2.cc:
	Likewise.
2020-08-06 19:49:07 +01:00
Jonathan Wakely
4e39f563c0 libstdc++: Do not set eofbit eagerly in operator>>(istream&, char(&)[N])
Similar to the bugs I fixed recently in istream::ignore, we incorrectly
set eofbit too often in operator>>(istream&, string&) and
operator>>(istream&.  char(&)[N]).

We should only set eofbit if we reach EOF but would have kept going
otherwise. If we've already extracted the maximum number of characters
(whether that's because of the buffer size or the istream's width())
then we should not set eofbit.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.tcc
	(operator>>(basic_istream&, basic_string&)): Do not set eofbit
	if extraction stopped after in.width() characters.
	* src/c++98/istream-string.cc (operator>>(istream&, string&)):
	Likewise.
	* include/bits/istream.tcc (__istream_extract): Do not set
	eofbit if extraction stopped after n-1 characters.
	* src/c++98/istream.cc (__istream_extract): Likewise.
	* testsuite/21_strings/basic_string/inserters_extractors/char/13.cc: New test.
	* testsuite/21_strings/basic_string/inserters_extractors/wchar_t/13.cc: New test.
	* testsuite/27_io/basic_istream/extractors_character/char/5.cc: New test.
	* testsuite/27_io/basic_istream/extractors_character/wchar_t/5.cc: New test.
2020-08-06 19:23:14 +01:00
Jonathan Wakely
6a13a4e3f2 libstdc++: Fix unnecessary allocations in read_symlink [PR 96484]
libstdc++-v3/ChangeLog:

	PR libstdc++/96484
	* src/c++17/fs_ops.cc (fs::read_symlink): Return an error
	immediately for non-symlinks.
	* src/filesystem/ops.cc (fs::read_symlink): Likewise.
2020-08-06 18:44:50 +01:00
Jonathan Wakely
6251ea15f5 libstdc++: Adjust overflow prevention to operator>>
This adjusts the overflow prevention added to operator>> so that we can
distinguish "unknown size" from "zero size", and avoid writing anything
at all in to zero sized buffers.

This also removes the incorrect comment saying extraction stops at a
null byte.

libstdc++-v3/ChangeLog:

	* include/std/istream (operator>>(istream&, char*)): Add
	attributes to get warnings for pointers that are null or known
	to point to the end of a buffer. Request upper bound from
	__builtin_object_size check and handle zero-sized buffer case.
	(operator>>(istream&, signed char))
	(operator>>(istream&, unsigned char*)): Add attributes.
	* testsuite/27_io/basic_istream/extractors_character/char/overflow.cc:
	Check extracting into the middle of a buffer.
	* testsuite/27_io/basic_istream/extractors_character/wchar_t/overflow.cc: New test.
2020-08-06 18:26:45 +01:00
GCC Administrator
aa5ea20c2b Daily bump. 2020-08-06 00:16:26 +00:00
Jonathan Wakely
b2d4ba65dc libstdc++: Break long lines to fit in 80 columns
libstdc++-v3/ChangeLog:

	* include/std/atomic (atomic<T>::store): Reformat.
2020-08-05 22:48:17 +01:00
Jonathan Wakely
54485adc77 libstdc++: Change URL for PSTL again
libstdc++-v3/ChangeLog:

	* doc/xml/manual/status_cxx2017.xml: Replace oneAPI DPC++ link
	with LLVM repo for PSTL.
	* doc/html/manual/status.html: Regenerate.
2020-08-05 22:46:32 +01:00
Jonathan Wakely
17abcc7734 libstdc++: Replace operator>>(istream&, char*) [LWG 2499]
P0487R1 resolved LWG 2499 for C++20 by removing the operator>> overloads
that have high risk of buffer overflows. They were replaced by
equivalents that only accept a reference to an array, and so can
guarantee not to write past the end of the array.

In order to support both the old and new functionality, this patch
introduces a new overloaded __istream_extract function which takes a
maximum length. The new operator>> overloads use the array size as the
maximum length. The old overloads now use __builtin_object_size to
determine the available buffer size if available (which requires -O2) or
use numeric_limits<streamsize>::max()/sizeof(char_type) otherwise. This
is a change in behaviour, as the old overloads previously always used
numeric_limits<streamsize>::max(), without considering sizeof(char_type)
and without attempting to prevent overflows.

Because they now do little more than call __istream_extract, the old
operator>> overloads are very small inline functions. This means there
is no advantage to explicitly instantiating them in the library (in fact
that would prevent the __builtin_object_size checks from ever working).
As a result, the explicit instantiation declarations can be removed from
the header. The explicit instantiation definitions are still needed, for
backwards compatibility with existing code that expects to link to the
definitions in the library.

While working on this change I noticed that src/c++11/istream-inst.cc
has the following explicit instantiation definition:
  template istream& operator>>(istream&, char*);
This had no effect (and so should not have been present in that file),
because there was an explicit specialization declared in <istream> and
defined in src/++98/istream.cc. However, this change removes the
explicit specialization, and now the explicit instantiation definition
is necessary to ensure the symbol gets defined in the library.

libstdc++-v3/ChangeLog:

	* config/abi/pre/gnu.ver (GLIBCXX_3.4.29): Export new symbols.
	* include/bits/istream.tcc (__istream_extract): New function
	template implementing both of operator>>(istream&, char*) and
	operator>>(istream&, char(&)[N]). Add explicit instantiation
	declaration for it. Remove explicit instantiation declarations
	for old function templates.
	* include/std/istream (__istream_extract): Declare.
	(operator>>(basic_istream<C,T>&, C*)): Define inline and simply
	call __istream_extract.
	(operator>>(basic_istream<char,T>&, signed char*)): Likewise.
	(operator>>(basic_istream<char,T>&, unsigned char*)): Likewise.
	(operator>>(basic_istream<C,T>&, C(7)[N])): Define for LWG 2499.
	(operator>>(basic_istream<char,T>&, signed char(&)[N])):
	Likewise.
	(operator>>(basic_istream<char,T>&, unsigned char(&)[N])):
	Likewise.
	* include/std/streambuf (basic_streambuf): Declare char overload
	of __istream_extract as a friend.
	* src/c++11/istream-inst.cc: Add explicit instantiation
	definition for wchar_t overload of __istream_extract. Remove
	explicit instantiation definitions of old operator>> overloads
	for versioned-namespace build.
	* src/c++98/istream.cc (operator>>(istream&, char*)): Replace
	with __istream_extract(istream&, char*, streamsize).
	* testsuite/27_io/basic_istream/extractors_character/char/3.cc:
	Do not use variable-length array.
	* testsuite/27_io/basic_istream/extractors_character/char/4.cc:
	Do not run test for C++20.
	* testsuite/27_io/basic_istream/extractors_character/char/9555-ic.cc:
	Do not test writing to pointers for C++20.
	* testsuite/27_io/basic_istream/extractors_character/char/9826.cc:
	Use array instead of pointer.
	* testsuite/27_io/basic_istream/extractors_character/wchar_t/3.cc:
	Do not use variable-length array.
	* testsuite/27_io/basic_istream/extractors_character/wchar_t/4.cc:
	Do not run test for C++20.
	* testsuite/27_io/basic_istream/extractors_character/wchar_t/9555-ic.cc:
	Do not test writing to pointers for C++20.
	* testsuite/27_io/basic_istream/extractors_character/char/lwg2499.cc:
	New test.
	* testsuite/27_io/basic_istream/extractors_character/char/lwg2499_neg.cc:
	New test.
	* testsuite/27_io/basic_istream/extractors_character/char/overflow.cc:
	New test.
	* testsuite/27_io/basic_istream/extractors_character/wchar_t/lwg2499.cc:
	New test.
	* testsuite/27_io/basic_istream/extractors_character/wchar_t/lwg2499_neg.cc:
	New test.
2020-08-05 22:17:18 +01:00
GCC Administrator
4967ca2f8b Daily bump. 2020-08-02 00:16:21 +00:00
Gerald Pfeifer
8dc5f8529b Move www.stroustrup.com to https
libstdc++-v3/ChangeLog:

2020-08-02  Gerald Pfeifer  <gerald@pfeifer.com>

	* doc/xml/manual/using_exceptions.xml: Move www.stroustrup.com to
	https.
	* doc/html/manual/using_exceptions.html: Regenerate.
2020-08-02 00:26:36 +02:00
GCC Administrator
48cc2e468c Daily bump. 2020-08-01 00:16:25 +00:00
Gerald Pfeifer
d1da25fe99 libstdc++: ParallelSTL is now part of oneAPI DPC++ Library
libstdc++-v3:
2020-07-31  Gerald Pfeifer  <gerald@pfeifer.com>

	* doc/xml/manual/status_cxx2017.xml: ParallelSTL is now part
	of oneAPI DPC++ Library on Github.
	* doc/html/manual/status.html: Regenerate.
2020-07-31 23:19:37 +02:00
François Dumont
6f00ccbad3 libstdc++: Fix and improve std::vector<bool> implementation.
Do not consider allocator noexcept qualification for vector<bool> move
constructor.
Improve swap performance using TBAA like in main vector implementation. Bypass
_M_initialize_dispatch/_M_assign_dispatch in post-c++11 modes.

libstdc++-v3/ChangeLog:

	* include/bits/stl_bvector.h
	[_GLIBCXX_INLINE_VERSION](_Bvector_impl_data::_M_start): Define as
	_Bit_type*.
	(_Bvector_impl_data(const _Bvector_impl_data&)): Default.
	(_Bvector_impl_data(_Bvector_impl_data&&)): Delegate to latter.
	(_Bvector_impl_data::operator=(const _Bvector_impl_data&)): Default.
	(_Bvector_impl_data::_M_move_data(_Bvector_impl_data&&)): Use latter.
	(_Bvector_impl_data::_M_reset()): Likewise.
	(_Bvector_impl_data::_M_swap_data): New.
	(_Bvector_impl::_Bvector_impl(_Bvector_impl&&)): Implement explicitely.
	(_Bvector_impl::_Bvector_impl(_Bit_alloc_type&&, _Bvector_impl&&)): New.
	(_Bvector_base::_Bvector_base(_Bvector_base&&, const allocator_type&)):
	New, use latter.
	(vector::vector(vector&&, const allocator_type&, true_type)): New, use
	latter.
	(vector::vector(vector&&, const allocator_type&, false_type)): New.
	(vector::vector(vector&&, const allocator_type&)): Use latters.
	(vector::vector(const vector&, const allocator_type&)): Adapt.
	[__cplusplus >= 201103](vector::vector(_InputIt, _InputIt,
	const allocator_type&)): Use _M_initialize_range.
	(vector::operator[](size_type)): Use iterator operator[].
	(vector::operator[](size_type) const): Use const_iterator operator[].
	(vector::swap(vector&)): Add assertions on allocators. Use _M_swap_data.
	[__cplusplus >= 201103](vector::insert(const_iterator, _InputIt,
	_InputIt)): Use _M_insert_range.
	(vector::_M_initialize(size_type)): Adapt.
	[__cplusplus >= 201103](vector::_M_initialize_dispatch): Remove.
	[__cplusplus >= 201103](vector::_M_insert_dispatch): Remove.
	* python/libstdcxx/v6/printers.py (StdVectorPrinter._iterator): Stop
	using start _M_offset.
	(StdVectorPrinter.to_string): Likewise.
	* testsuite/23_containers/vector/bool/allocator/swap.cc: Adapt.
	* testsuite/23_containers/vector/bool/cons/noexcept_move_construct.cc:
	Add check.
2020-07-31 23:18:51 +02:00
Jonathan Wakely
8011f718e2 libstdc++: Fix tests that fail for C++98
libstdc++-v3/ChangeLog:

	* testsuite/27_io/basic_istream/ignore/char/94749.cc: Use 0
	instead of nullptr.
	* testsuite/27_io/basic_istream/ignore/wchar_t/94749.cc:
	Likewise.
2020-07-31 19:58:36 +01:00
Jonathan Wakely
f07fa7a31c libstdc++: Fix test that fails for C++98
Local classes have no linkage so cannot be used as template arguments in
C++98.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/specialized_algorithms/uninitialized_fill_n/sizes.cc:
	Move struct to namespace scope.
2020-07-31 19:58:03 +01:00
Jonathan Wakely
dc8c00966e libstdc++: Avoid using __float128 in strict modes
libstdc++-v3/ChangeLog:

	* testsuite/26_numerics/numbers/float128.cc: Check
	__STRICT_ANSI__ before using __float128.
	* testsuite/std/concepts/concepts.lang/concept.arithmetic/floating_point.cc:
	Likewise.
2020-07-31 19:58:03 +01:00
Jonathan Wakely
9d613af2b4 libstdc++: Ensure c++NN effective-target present in more tests
Add effective-target keywords to tests that would fail for certain
standard modes without the -std=gnu++NN option.

libstdc++-v3/ChangeLog:

	* testsuite/18_support/set_terminate.cc: Require C++11 or
	higher.
	* testsuite/28_regex/simple_c++11.cc: Likewise.
	* testsuite/tr1/headers/c++200x/complex.cc: Likewise.
	* testsuite/24_iterators/headers/iterator/synopsis.cc:
	Require C++14 or lower.
2020-07-31 19:58:03 +01:00
Jonathan Wakely
a92e0f58d8 libstdc++: Add dg-require-effective-target to std::span assert tests
The current dg directives say that the tests can run for any standard
mode, but should fail for C++20. What we want is that they only run for
C++20, and are always expected to fail.

libstdc++-v3/ChangeLog:

	* testsuite/23_containers/span/back_assert_neg.cc: Split c++2a
	effective-target from xfail selector.
	* testsuite/23_containers/span/first_2_assert_neg.cc: Likewise.
	* testsuite/23_containers/span/first_assert_neg.cc: Likewise.
	* testsuite/23_containers/span/front_assert_neg.cc: Likewise.
	* testsuite/23_containers/span/index_op_assert_neg.cc: Likewise.
	* testsuite/23_containers/span/last_2_assert_neg.cc: Likewise.
	* testsuite/23_containers/span/last_assert_neg.cc: Likewise.
	* testsuite/23_containers/span/subspan_2_assert_neg.cc:
	Likewise.
	* testsuite/23_containers/span/subspan_3_assert_neg.cc:
	Likewise.
	* testsuite/23_containers/span/subspan_4_assert_neg.cc:
	Likewise.
	* testsuite/23_containers/span/subspan_5_assert_neg.cc:
	Likewise.
	* testsuite/23_containers/span/subspan_6_assert_neg.cc:
	Likewise.
	* testsuite/23_containers/span/subspan_assert_neg.cc: Likewise.
2020-07-31 19:58:02 +01:00
Jonathan Wakely
566f422734 libstdc++: Use c++NN_only effective target to tests
Some tests really are only intended for a specific -std mode, so add a
target selector to make that explicit.

Also reorder the dg-do directives to come after the dg-options ones, so
that the target selector in the dg-do directive is applied after the
dg-options that sets the -std option.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/reference_wrapper/83427.cc: Adjust
	effective-target to specific language mode only.
	* testsuite/24_iterators/headers/iterator/range_access_c++11.cc:
	Likewise.
	* testsuite/24_iterators/headers/iterator/range_access_c++14.cc:
	Likewise.
	* testsuite/24_iterators/headers/iterator/synopsis_c++11.cc:
	Likewise.
	* testsuite/24_iterators/headers/iterator/synopsis_c++14.cc:
	Likewise.
	* testsuite/26_numerics/valarray/69116.cc:
	Likewise.
	* testsuite/30_threads/headers/condition_variable/std_c++0x_neg.cc:
	Remove whitespace at end of file.
	* testsuite/30_threads/headers/future/std_c++0x_neg.cc:
	Likewise.
2020-07-31 19:58:02 +01:00
Jonathan Wakely
6458742a15 libstdc++: Ensure c++NN effective target present in all C++17 tests
Also reorder some directives so that the dg-options setting -std=gnu++17
comes before the dg-do that requires c++17.

libstdc++-v3/ChangeLog:

	* testsuite/17_intro/headers/c++2017/all_attributes.cc: Add
	c++17 effective-target.
	* testsuite/17_intro/headers/c++2017/all_no_exceptions.cc:
	Likewise.
	* testsuite/17_intro/headers/c++2017/all_no_rtti.cc: Likewise.
	* testsuite/17_intro/headers/c++2017/all_pedantic_errors.cc:
	Likewise.
	* testsuite/17_intro/headers/c++2017/operator_names.cc:
	Likewise.
	* testsuite/17_intro/headers/c++2017/stdc++.cc: Likewise.
	* testsuite/17_intro/headers/c++2017/stdc++_multiple_inclusion.cc:
	Likewise.
	* testsuite/18_support/uncaught_exceptions/uncaught_exceptions.cc:
	Likewise.
	* testsuite/19_diagnostics/error_code/is_error_code_v.cc:
	Likewise.
	* testsuite/20_util/any/assign/1.cc: Likewise.
	* testsuite/20_util/any/assign/2.cc: Likewise.
	* testsuite/20_util/any/assign/emplace.cc: Likewise.
	* testsuite/20_util/any/assign/exception.cc: Likewise.
	* testsuite/20_util/any/assign/self.cc: Likewise.
	* testsuite/20_util/any/cons/1.cc: Likewise.
	* testsuite/20_util/any/cons/2.cc: Likewise.
	* testsuite/20_util/any/cons/aligned.cc: Likewise.
	* testsuite/20_util/any/cons/explicit.cc: Likewise.
	* testsuite/20_util/any/cons/in_place.cc: Likewise.
	* testsuite/20_util/any/cons/nontrivial.cc: Likewise.
	* testsuite/20_util/any/make_any.cc: Likewise.
	* testsuite/20_util/any/misc/any_cast.cc: Likewise.
	* testsuite/20_util/any/misc/any_cast_no_rtti.cc: Likewise.
	* testsuite/20_util/any/misc/swap.cc: Likewise.
	* testsuite/20_util/any/modifiers/1.cc: Likewise.
	* testsuite/20_util/any/observers/type.cc: Likewise.
	* testsuite/20_util/any/requirements.cc: Likewise.
	* testsuite/20_util/any/typedefs.cc: Likewise.
	* testsuite/20_util/as_const/1.cc: Likewise.
	* testsuite/20_util/as_const/rvalue_neg.cc: Likewise.
	* testsuite/20_util/bind/is_placeholder_v.cc: Likewise.
	* testsuite/20_util/bool_constant/requirements.cc: Likewise.
	* testsuite/20_util/duration/requirements/treat_as_floating_point_v.cc:
	Likewise.
	* testsuite/20_util/duration_cast/rounding.cc: Likewise.
	* testsuite/20_util/enable_shared_from_this/members/weak_from_this.cc:
	Likewise.
	* testsuite/20_util/function_objects/invoke/59768.cc: Likewise.
	* testsuite/20_util/function_objects/not_fn/1.cc: Likewise.
	* testsuite/20_util/function_objects/searchers.cc: Likewise.
	* testsuite/20_util/in_place/requirements.cc: Likewise.
	* testsuite/20_util/is_invocable/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/is_invocable/requirements/typedefs.cc:
	Likewise.
	* testsuite/20_util/is_invocable/value.cc: Likewise.
	* testsuite/20_util/is_nothrow_invocable/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/is_nothrow_invocable/requirements/typedefs.cc:
	Likewise.
	* testsuite/20_util/is_nothrow_swappable/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/is_nothrow_swappable/requirements/typedefs.cc:
	Likewise.
	* testsuite/20_util/is_nothrow_swappable/value.cc: Likewise.
	* testsuite/20_util/is_nothrow_swappable_with/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/is_nothrow_swappable_with/requirements/typedefs.cc:
	Likewise.
	* testsuite/20_util/is_nothrow_swappable_with/value.cc:
	Likewise.
	* testsuite/20_util/is_swappable/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/is_swappable/requirements/typedefs.cc:
	Likewise.
	* testsuite/20_util/is_swappable/value.cc: Likewise.
	* testsuite/20_util/is_swappable_with/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/is_swappable_with/requirements/typedefs.cc:
	Likewise.
	* testsuite/20_util/is_swappable_with/value.cc: Likewise.
	* testsuite/20_util/logical_traits/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/logical_traits/requirements/typedefs.cc:
	Likewise.
	* testsuite/20_util/logical_traits/value.cc: Likewise.
	* testsuite/20_util/optional/constexpr/make_optional.cc: Likewise.
	* testsuite/20_util/optional/constexpr/observers/2.cc: Likewise.
	* testsuite/20_util/optional/constexpr/observers/3.cc: Likewise.
	* testsuite/20_util/optional/hash.cc: Likewise.
	* testsuite/20_util/pair/swap_cxx17.cc: Likewise.
	* testsuite/20_util/ratio/requirements/ratio_equal_v.cc: Likewise.
	* testsuite/20_util/shared_ptr/requirements/weak_type.cc:
	Likewise.
	* testsuite/20_util/specialized_algorithms/memory_management_tools/1.cc:
	Likewise.
	* testsuite/20_util/tuple/apply/1.cc: Likewise.
	* testsuite/20_util/tuple/make_from_tuple/1.cc: Likewise.
	* testsuite/20_util/tuple/swap_cxx17.cc: Likewise.
	* testsuite/20_util/tuple/tuple_size_v.cc: Likewise.
	* testsuite/20_util/unique_ptr/specialized_algorithms/swap_cxx17.cc:
	Likewise.
	* testsuite/20_util/uses_allocator/requirements/uses_allocator_v.cc:
	Likewise.
	* testsuite/20_util/variant/any.cc: Likewise.
	* testsuite/20_util/variant/compile.cc: Likewise.
	* testsuite/20_util/variant/hash.cc: Likewise.
	* testsuite/20_util/variant/index_type.cc: Likewise.
	* testsuite/20_util/variant/run.cc: Likewise.
	* testsuite/20_util/void_t/1.cc: Likewise.
	* testsuite/21_strings/basic_string/79162.cc: Likewise.
	* testsuite/21_strings/basic_string/cons/char/7.cc: Likewise.
	* testsuite/21_strings/basic_string/cons/wchar_t/7.cc: Likewise.
	* testsuite/21_strings/basic_string/lwg2758.cc: Likewise.
	* testsuite/21_strings/basic_string/lwg2946.cc: Likewise.
	* testsuite/21_strings/basic_string/modifiers/append/char/4.cc:
	Likewise.
	* testsuite/21_strings/basic_string/modifiers/append/wchar_t/4.cc:
	Likewise.
	* testsuite/21_strings/basic_string/modifiers/assign/char/4.cc:
	Likewise.
	* testsuite/21_strings/basic_string/modifiers/assign/wchar_t/4.cc:
	Likewise.
	* testsuite/21_strings/basic_string/modifiers/insert/char/3.cc:
	Likewise.
	* testsuite/21_strings/basic_string/modifiers/insert/wchar_t/3.cc:
	Likewise.
	* testsuite/21_strings/basic_string/modifiers/replace/char/7.cc:
	Likewise.
	* testsuite/21_strings/basic_string/modifiers/replace/wchar_t/7.cc:
	Likewise.
	* testsuite/21_strings/basic_string/operations/compare/char/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string/operations/compare/wchar_t/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string/operations/data/char/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string/operations/data/wchar_t/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string/operations/find/char/5.cc:
	Likewise.
	* testsuite/21_strings/basic_string/operations/find/wchar_t/5.cc:
	Likewise.
	* testsuite/21_strings/basic_string/operators/char/5.cc: Likewise.
	* testsuite/21_strings/basic_string/operators/wchar_t/5.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/capacity/1.cc: Likewise.
	* testsuite/21_strings/basic_string_view/cons/char/1.cc: Likewise.
	* testsuite/21_strings/basic_string_view/cons/char/2.cc: Likewise.
	* testsuite/21_strings/basic_string_view/cons/char/3.cc: Likewise.
	* testsuite/21_strings/basic_string_view/cons/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/cons/wchar_t/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/cons/wchar_t/3.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/char/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/char/empty.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/char/front_back.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/empty.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/front_back.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/include.cc: Likewise.
	* testsuite/21_strings/basic_string_view/inserters/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/inserters/char/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/inserters/char/3.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/inserters/pod/10081-out.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/inserters/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/inserters/wchar_t/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/inserters/wchar_t/3.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/literals/types-char8_t.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/literals/types.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/literals/values-char8_t.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/literals/values.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/modifiers/remove_prefix/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/modifiers/remove_suffix/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/compare/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/compare/char/13650.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/compare/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/compare/wchar_t/13650.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/copy/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/copy/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/data/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/data/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/find/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/find/char/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/find/char/3.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/find/char/4.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/find/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/find/wchar_t/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/find/wchar_t/3.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/find/wchar_t/4.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/rfind/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/rfind/char/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/rfind/char/3.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/rfind/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/rfind/wchar_t/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/rfind/wchar_t/3.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/string_conversion/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/substr/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/substr/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/range_access/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/range_access/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char16_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char32_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char8_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/requirements/typedefs.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/typedefs.cc: Likewise.
	* testsuite/21_strings/basic_string_view/types/1.cc: Likewise.
	* testsuite/23_containers/array/specialized_algorithms/swap_cxx17.cc:
	Likewise.
	* testsuite/23_containers/map/modifiers/extract.cc: Likewise.
	* testsuite/23_containers/map/modifiers/insert_or_assign/1.cc:
	Likewise.
	* testsuite/23_containers/map/modifiers/merge.cc: Likewise.
	* testsuite/23_containers/map/modifiers/try_emplace/1.cc: Likewise.
	* testsuite/23_containers/multimap/modifiers/extract.cc: Likewise.
	* testsuite/23_containers/multimap/modifiers/merge.cc: Likewise.
	* testsuite/23_containers/multiset/modifiers/extract.cc: Likewise.
	* testsuite/23_containers/multiset/modifiers/merge.cc: Likewise.
	* testsuite/23_containers/set/modifiers/extract.cc: Likewise.
	* testsuite/23_containers/set/modifiers/merge.cc: Likewise.
	* testsuite/23_containers/unordered_map/modifiers/extract.cc:
	Likewise.
	* testsuite/23_containers/unordered_map/modifiers/insert_or_assign.cc:
	Likewise.
	* testsuite/23_containers/unordered_map/modifiers/merge.cc:
	Likewise.
	* testsuite/23_containers/unordered_map/modifiers/try_emplace.cc:
	Likewise.
	* testsuite/23_containers/unordered_multimap/modifiers/extract.cc:
	Likewise.
	* testsuite/23_containers/unordered_multimap/modifiers/merge.cc:
	Likewise.
	* testsuite/23_containers/unordered_multiset/modifiers/extract.cc:
	Likewise.
	* testsuite/23_containers/unordered_multiset/modifiers/merge.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/modifiers/extract.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/modifiers/merge.cc:
	Likewise.
	* testsuite/24_iterators/headers/iterator/range_access_c++17.cc:
	Likewise.
	* testsuite/24_iterators/headers/iterator/synopsis_c++17.cc:
	Likewise.
	* testsuite/25_algorithms/clamp/1.cc: Likewise.
	* testsuite/25_algorithms/clamp/2.cc: Likewise.
	* testsuite/25_algorithms/clamp/constexpr.cc: Likewise.
	* testsuite/25_algorithms/clamp/requirements/explicit_instantiation/1.cc:
	Likewise.
	* testsuite/25_algorithms/clamp/requirements/explicit_instantiation/pod.cc:
	Likewise.
	* testsuite/26_numerics/headers/cmath/functions_std_c++17.cc:
	Likewise.
	* testsuite/26_numerics/headers/cmath/special_functions_global.cc:
	Likewise.
	* testsuite/27_io/basic_ostream/inserters_other/char/lwg2221.cc:
	Likewise.
	* testsuite/29_atomics/atomic/is_always_lock_free.cc: Likewise.
	* testsuite/29_atomics/atomic_integral/is_always_lock_free.cc:
	Likewise.
	* testsuite/30_threads/shared_lock/70766.cc: Likewise.
	* testsuite/30_threads/shared_mutex/cons/1.cc: Likewise.
	* testsuite/30_threads/shared_mutex/cons/assign_neg.cc:
	Likewise.
	* testsuite/30_threads/shared_mutex/cons/copy_neg.cc:
	Likewise.
	* testsuite/30_threads/shared_mutex/requirements/standard_layout.cc:
	Likewise.
	* testsuite/30_threads/shared_mutex/try_lock/1.cc: Likewise.
	* testsuite/30_threads/shared_mutex/try_lock/2.cc: Likewise.
	* testsuite/30_threads/shared_mutex/unlock/1.cc: Likewise.
2020-07-31 19:58:02 +01:00
Jonathan Wakely
8abab28bb5 libstdc++: Remove condition around friend declaration (PR 96382)
libstdc++-v3/ChangeLog:

	PR libstdc++/96382
	* include/bits/stl_iterator.h (reverse_iterator): Friend
	declaration should not depend on __cplusplus.
2020-07-31 19:55:46 +01:00
Jonathan Wakely
ed0b4bb29a libstdc++: Remove accidental -std=gnu++17 from test
This was probably copied from a std::filesystem test and the -std option
wasn't removed.

libstdc++-v3/ChangeLog:

	* testsuite/experimental/filesystem/filesystem_error/cons.cc:
	Remove -std=gnu++17 option.
2020-07-31 18:02:10 +01:00
Jonathan Wakely
8e2592a888 libstdc++: Adjust tests that give different results in C++20
libstdc++-v3/ChangeLog:

	* testsuite/20_util/is_aggregate/value.cc: Adjust for changes to
	definition of aggregates in C++20.
	* testsuite/20_util/optional/requirements.cc: Adjust for
	defaulted comparisons in C++20.
2020-07-31 17:51:00 +01:00
Jonathan Wakely
95edead9aa libstdc++: Add -Wno-deprecated for tests that warn in C++20
libstdc++-v3/ChangeLog:

	* testsuite/20_util/tuple/78939.cc: Suppress warnings about
	deprecation of volatile-qualified structured bindings in C++20.
	* testsuite/20_util/variable_templates_for_traits.cc: Likewise
	for deprecation of is_pod in C++20
2020-07-31 17:51:00 +01:00
Jonathan Wakely
351f60794c libstdc++: Remove duplicate dg-do directive
Also add an effective target to clarify it should only run for C++17 and
later.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/time_point_cast/rounding.cc: Remove
	duplicate dg-do directive and add c++17 effective target.
2020-07-31 17:51:00 +01:00
Jonathan Wakely
4143efc1ee libstdc++: Fix use of newlocale in std:::from_chars
libstdc++-v3/ChangeLog:

	* src/c++17/floating_from_chars.cc (from_chars_impl): Use
	LC_ALL_MASK not LC_ALL.
2020-07-31 14:36:56 +01:00
Richard Biener
c6ef9d8d3f debug/96383 - emit debug info for used external functions
This makes sure to emit full declaration DIEs including
formal parameters for used external functions.  This helps
debugging when debug information of the external entity is
not available and also helps external tools cross-checking
ABI compatibility which was the bug reporters use case.

For cc1 this affects debug information size as follows:

     VM SIZE                     FILE SIZE
 ++++++++++++++ GROWING       ++++++++++++++
  [ = ]       0 .debug_info   +1.63Mi  +1.3%
  [ = ]       0 .debug_str     +263Ki  +3.4%
  [ = ]       0 .debug_abbrev  +101Ki  +4.9%
  [ = ]       0 .debug_line   +5.71Ki  +0.0%
   +44%     +16 [Unmapped]        +48  +1.2%

 -------------- SHRINKING     --------------
  [ = ]       0 .debug_loc       -213  -0.0%
  -0.0%     -48 .text             -48  -0.0%
  [ = ]       0 .debug_ranges     -16  -0.0%

  -0.0%     -32 TOTAL         +1.99Mi  +0.6%

and DWARF compression via DWZ can only shave off minor bits
here.

Previously we emitted no DIEs for external functions at all
unless they were referenced via DW_TAG_GNU_call_site which
for some GCC revs caused a regular DIE to appear and since
GCC 4.9 only a stub without formal parameters.  This means
at -O0 we did not emit any DIE for external functions
but with optimization we emitted stubs.

2020-07-30  Richard Biener  <rguenther@suse.de>

	PR debug/96383
	* langhooks-def.h (lhd_finalize_early_debug): Declare.
	(LANG_HOOKS_FINALIZE_EARLY_DEBUG): Define.
	(LANG_HOOKS_INITIALIZER): Amend.
	* langhooks.c: Include cgraph.h and debug.h.
	(lhd_finalize_early_debug): Default implementation from
	former code in finalize_compilation_unit.
	* langhooks.h (lang_hooks::finalize_early_debug): Add.
	* cgraphunit.c (symbol_table::finalize_compilation_unit):
	Call the finalize_early_debug langhook.

gcc/c-family/
	* c-common.h (c_common_finalize_early_debug): Declare.
	* c-common.c: Include debug.h.
	(c_common_finalize_early_debug): finalize_early_debug langhook
	implementation generating debug for extern declarations.

gcc/c/
	* c-objc-common.h (LANG_HOOKS_FINALIZE_EARLY_DEBUG):
	Define to c_common_finalize_early_debug.

gcc/cp/
	* cp-objcp-common.h (LANG_HOOKS_FINALIZE_EARLY_DEBUG):
	Define to c_common_finalize_early_debug.

gcc/testsuite/
	* gcc.dg/debug/dwarf2/pr96383-1.c: New testcase.
	* gcc.dg/debug/dwarf2/pr96383-2.c: Likewise.

libstdc++-v3/
	* testsuite/20_util/assume_aligned/3.cc: Use -g0.
2020-07-31 15:19:13 +02:00
Jonathan Wakely
89db36b05e libstdc++: Add PR number to ChangeLog entry 2020-07-31 14:15:43 +01:00
GCC Administrator
d48cca8f21 Daily bump. 2020-07-31 00:16:26 +00:00
Jonathan Wakely
684d6ee140 libstdc++: Make COW string use allocator_traits for nested types
When compiled as C++20 the COW std::string fails due to assuming that
the allocator always defines size_type and difference_type. That has
been incorrect since C++11, but we got away with it for specializations
using std::allocator until those members were removed in C++20.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.h (size_type, difference_type):
	Use allocator_traits to obtain the allocator's size_type and
	difference_type.
2020-07-30 20:58:09 +01:00
Jonathan Wakely
e513e9aa53 libstdc++: Check _GLIBCXX_USE_C99_STDLIB for strtof and strtold
On broken systems we only have strtod, not strtof and strtold. Just use
strtod for all types, even though that will produce incorrect results in
some cases.

Similarly, if _GLIBCXX_USE_C99_MATH is not defined then std::isinf won't
be declared. Just refer to it unqualified, which should find the C
library's isinf macro if that hasn't been #undef'd by <cmath>.

libstdc++-v3/ChangeLog:

	* src/c++17/floating_from_chars.cc (from_chars_impl): Use
	isinf unqualified.
	[!_GLIBCXX_USE_C99_STDLIB]: Use strtod for float and long
	double.
2020-07-30 20:55:56 +01:00
Jonathan Wakely
357beca8bc libstdc++: Fix tests using wrong allocator type
libstdc++-v3/ChangeLog:

	* testsuite/23_containers/unordered_multiset/cons/noexcept_default_construct.cc:
	Use allocator with the correct value type.
	* testsuite/23_containers/unordered_set/cons/noexcept_default_construct.cc:
	Likewise.
2020-07-30 18:41:59 +01:00
Jonathan Wakely
561a19c301 libstdc++: Fix test for old string ABI
The COW string doesn't accept const_iterator arguments in insert and
related member functions. Pass a mutable iterator instead.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/from_chars/4.cc: Pass non-const iterator
	to string::insert.
2020-07-30 16:04:59 +01:00
Jonathan Wakely
9e67b4356e libstdc++: cv bool can't be an integer-like type (LWG 3467)
libstdc++-v3/ChangeLog:

	* include/bits/iterator_concepts.h (__detail::__cv_bool): New
	helper concept.
	(__detail::__integral_nonbool): Likewise.
	(__detail::__is_integer_like): Use __integral_nonbool.
	* testsuite/std/ranges/access/lwg3467.cc: New test.
2020-07-30 13:09:18 +01:00
Jonathan Wakely
eeb45f8a41 libstdc++: Add options for ieee float to relevant tests
libstdc++-v3/ChangeLog:

	* testsuite/20_util/from_chars/4.cc: Use dg-add-options ieee.
	* testsuite/29_atomics/atomic_float/1.cc: Likewise.
2020-07-30 12:50:03 +01:00
Jonathan Wakely
4c27c6584d libstdc++: Make testsuite usable with -fno-exceptions
Previously it was not possible to add -fno-exceptions to the testsuite
flags, because some files that are compiled by the v3-build_support
procedure failed with exceptions disabled.

This adjusts those files to still compile without exceptions (with
degraded functionality in some cases).

The sole testcase that explicitly checks for -fno-exceptions has also
been adjusted to use the more robust exceptions_enabled effective-target
keyword from gcc/testsuite/lib/target-supports.exp.

libstdc++-v3/ChangeLog:

	* testsuite/23_containers/vector/bool/72847.cc: Use the
	exceptions_enabled effective-target keyword instead of
	checking for an explicit -fno-exceptions option.
	* testsuite/util/testsuite_abi.cc (examine_symbol): Remove
	redundant try-catch.
	* testsuite/util/testsuite_allocator.h [!__cpp_exceptions]:
	Do not define check_allocate_max_size and memory_resource.
	* testsuite/util/testsuite_containers.h: Replace comment with
	#error if wrong standard dialect used.
	* testsuite/util/testsuite_shared.cc: Likewise.
2020-07-30 12:50:02 +01:00
GCC Administrator
bea7a39103 Daily bump. 2020-07-30 00:16:24 +00:00
François Dumont
acc1d1a954 libstdc++: Review _Local_iterator/_Local_const_iterator implementations.
_Local_iterator_base inherits _Node_iterator_base and so share the same
comparison operators. It avoids to expose special method _M_curr for debug
mode to compare such iterators.

libstdc++-v3/ChangeLog:

	* include/bits/hashtable_policy.h (_Node_iterator_base()): New.
	(operator==(const _Node_iterator_base&, const _Node_iterator_base&)):
	Make hidden friend.
	(operator!=(const _Node_iterator_base&, const _Node_iterator_base&)):
	Make hidden friend.
	(_Local_iterator_base<>): Inherits _Node_iterator_base.
	(_Local_iterator_base<>::_M_cur): Remove.
	(_Local_iterator_base<>::_M_curr()): Remove.
	(operator==(const _Local_iterator_base&, const _Local_iterator_base&)):
	Remove.
	(operator!=(const _Local_iterator_base&, const _Local_iterator_base&)):
	Remove.
	* include/debug/unordered_map (unordered_map<>::_M_invalidate): Adapt.
	(unordered_multimap<>::_M_invalidate): Adapt.
	* include/debug/unordered_set (unordered_set<>::_M_invalidate): Adapt.
	(unordered_multiset<>::_M_invalidate): Adapt.
2020-07-29 20:46:09 +02:00
David Edelsohn
55ede0bb87 testsuite: libstdc++ atomic_float/value_init.cc requires libatomic
atomic_float/value_init.cc requires libatomic for some targets, i.e., when
it tries to perform an atomic operation with a 64 bit floating point
double type on a 32 bit target.  This patch adds AIX and Darwin to the
list of targets that require the libatomic option and adds the option to
the atomic_float/value_init.cc testcase.

libstdc++-v3/ChangeLog:

2020-07-28  David Edelsohn  <dje.gcc@gmail.com>
	    Jonathan Wakely  <jwakely@redhat.com>
	    Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* testsuite/lib/dg-options.exp (add_options_for_libatomic): Add
	target powerpc-ibm-aix* and powerpc*-*-darwin*.
	* testsuite/29_atomics/atomic_float/value_init.cc: Add options
	for libatomic.
2020-07-29 10:00:05 -04:00
François Dumont
12324b9a93 libstdc++: Fix unordered containers move constructors noexcept qualification
_Hashtable move constructor is wrongly qualified as noexcept(true) regardless of
_Equal and _H1 copy constructor qualifications.
_Hashtable allocator-aware move constructor is missing its noexcept
qualification like the depending unordered containers ones.

libstdc++-v3/ChangeLog:

	* include/bits/hashtable.h
	(_Hashtable(_Hashtable&& __ht, __node_alloc_type&& __a, true_type)):
	Add noexcept qualification.
	(_Hashtable(_Hashtable&&)): Fix noexcept qualification.
	(_Hashtable(_Hashtable&&, const allocator_type&)): Add noexcept
	qualification.
	* include/bits/unordered_map.h
	(unordered_map(unordered_map&&, const allocator_type&)): Add noexcept
	qualification.
	(unordered_multimap(unordered_multimap&&, const allocator_type&)):
	Likewise.
	* include/bits/unordered_set.h
	(unordered_set(unordered_set&&, const allocator_type&)): Likewise.
	(unordered_multiset(unordered_multiset&&, const allocator_type&)):
	Likewise.
	* include/debug/unordered_map
	(unordered_map(unordered_map&&, const allocator_type&)): Likewise.
	(unordered_multimap(unordered_multimap&&, const allocator_type&)):
	Likewise.
	* include/debug/unordered_set
	(unordered_set(unordered_set&&, const allocator_type&)): Likewise.
	(unordered_multiset(unordered_multiset&&, const allocator_type&)):
	Likewise.
	* testsuite/23_containers/unordered_map/allocator/default_init.cc:
	New test.
	* testsuite/23_containers/unordered_map/cons/noexcept_default_construct.cc:
	New test.
	* testsuite/23_containers/unordered_map/cons/noexcept_move_construct.cc:
	New test.
	* testsuite/23_containers/unordered_map/modifiers/move_assign.cc:
	New test.
	* testsuite/23_containers/unordered_multimap/cons/noexcept_default_construct.cc:
	New test.
	* testsuite/23_containers/unordered_multimap/cons/noexcept_move_construct.cc:
	New test.
	* testsuite/23_containers/unordered_multiset/cons/noexcept_default_construct.cc:
	New test.
	* testsuite/23_containers/unordered_multiset/cons/noexcept_move_construct.cc:
	New test.
	* testsuite/23_containers/unordered_set/allocator/default_init.cc:
	New test.
	* testsuite/23_containers/unordered_set/cons/noexcept_default_construct.cc:
	New test.
	* testsuite/23_containers/unordered_set/cons/noexcept_move_construct.cc:
	New test.
2020-07-29 11:26:42 +02:00
GCC Administrator
7ebb7d0ce1 Daily bump. 2020-07-29 00:16:24 +00:00
François Dumont
6dcf042368 libstdc++: Do not over-size hashtable buckets on range insertion
We used to consider range size on insertion but on unique keys container
not all range values might be inserted resulting in over-sizing. In this
case we just consider user reservation and if none then the container will
adapt to actually inserted elements.

libstdc++-v3/ChangeLog:

	* include/bits/hashtable.h
	(_Hashtable<>(_InputIterator, _InputIterator, size_t, const _H1&,
	const _H2&, const _Hash&, const _Equal&, const _ExtractKey&,
	const allocator_type&, true_type)): New.
	(_Hashtable<>(_InputIterator, _InputIterator, size_t, const _H1&,
	const _H2&, const _Hash&, const _Equal&, const _ExtractKey&,
	const allocator_type&, false_type)): New.
	(_Hashtable<>(_InputIterator, _InputIterator, size_t, const _H1&,
	const _H2&, const _Hash&, const _Equal&, const _ExtractKey&,
	const allocator_type&)): Delegate to latters.
	(operator=(initializer_list<value_type>)): Rehash if too small.
	(_M_insert(_Arg&&, const _NodeGenerator&, true_type)): Remove
	size_t len parameter.
	* include/bits/hashtable_policy.h (_Insert_base<>::_M_insert_range):
	Do not try to get input range distance.
	* testsuite/23_containers/unordered_set/cons/bucket_hint.cc: New test.
	* testsuite/23_containers/unordered_set/modifiers/insert.cc: New test.
2020-07-28 14:37:16 +02:00
GCC Administrator
e71dab8774 Daily bump. 2020-07-28 00:16:25 +00:00
François Dumont
f9d98fa748 libstdc++: Review _Hashtable count, equal_range _M_erase(false_type,) code
Simplify operator[] implementation using find method. Review several
_Hashtable method implementations to limit the computation of bucket index.
Introduce _M_update_bbegin to simplify code.

libstdc++-v3/ChangeLog:

	* include/bits/hashtable_policy.h (_Map_base<>::at): Use
	_Hashtable<>::find.
	(_Hashtable_base<>::_Equal_hash_code<>::_S_node_equals):New.
	(_Hashtable_base<>::_M_node_equals): New, use latter.
	(_Equality<_Key, _Value, _Alloc, _ExtractKey, _Equal, _H1, _H2, _Hash,
	_RehashPolicy, false>::_M_equal): Adapt to use latter.
	* include/bits/hashtable.h (_Hashtable<>::_M_update_bbegin): New.
	(_Hashtable<>::_M_assign): Use latter.
	(_Hashtable<>::_M_move_assign): Likewise.
	(_Hashtable<>(_Hashtable<>&&)): Likewise.
	(_Hashtable<>(_Hashtable<>&&, const allocator_type&)): Likewise.
	(_Hashtable<>::swap): Likewise.
	(_Hashtable<>::find): Build iterator directly from _M_find_node result.
	(_Hashtable<>::count): Use _Hashtable<>::find.
	(_Hashtable<>::equal_range): Likewise.
	(_Hashtable<>::_M_erase(false_type, const key_type&)): Use
	_M_node_equals.
2020-07-27 21:55:49 +02:00
Jonathan Wakely
2251b4a542 libstdc++: Make std::from_chars always round to nearest
Also fix the tests that fail on targets without uselocale.

libstdc++-v3/ChangeLog:

	* src/c++17/floating_from_chars.cc (from_chars_impl): Ensure
	that FE_NEAREST is used.
	* testsuite/20_util/from_chars/4.cc: Do not use if constexpr in
	a { target c++14 } test.
	[!_GLIBCXX_HAVE_USELOCALE]: Disable all tests.
	* testsuite/20_util/from_chars/5.cc [!_GLIBCXX_HAVE_USELOCALE]:
	Likewise.
	* testsuite/20_util/from_chars/6.cc: New test.
2020-07-27 15:51:24 +01:00
GCC Administrator
3ea9abca71 Daily bump. 2020-07-23 00:16:28 +00:00
Jonathan Wakely
1f53367fb5 libstdc++: Add static assertions to futures and promises [LWG 3458]
LWG recently decided it should be ill-formed to instantiate std::future
and std::shared_future for types that can't be returned from a function.
This adds static assertions to enforce it (std::future already failed,
but this makes the error more understandable).

LWG 3466 extends that to std::promise. The actual constraint is that
t.~T() is well-formed for the primary template, but rejecting arrays and
functions as done for futures matches that condition.

libstdc++-v3/ChangeLog:

	* include/std/future (future, shared_future, promise): Add
	static assertions to the primary template to reject array and
	function types.
	* testsuite/30_threads/future/requirements/lwg3458.cc: New test.
	* testsuite/30_threads/promise/requirements/lwg3466.cc: New test.
	* testsuite/30_threads/shared_future/requirements/lwg3458.cc: New test.
2020-07-22 20:11:00 +01:00
Jonathan Wakely
a5a8a4e615 libstdc++: Constrain reverse_iterator and move_iterator conversions [LWG 3435]
libstdc++-v3/ChangeLog:

	* include/bits/stl_iterator.h (reverse_iterator): Constrain
	converting constructor and converting assignment operator.
	Access source iterator's data member directly instead of
	calling base().
	(move_iterator): Likewise.
	* testsuite/24_iterators/move_iterator/dr3435.cc: New test.
	* testsuite/24_iterators/reverse_iterator/dr3435.cc: New test.
2020-07-22 15:10:29 +01:00
GCC Administrator
0933f50859 Daily bump. 2020-07-21 00:16:28 +00:00
Jonathan Wakely
932fbc868a libstdc++: Add std::from_chars for floating-point types
This adds the missing std::from_chars overloads for floating-point
types, as required for C++17 conformance.

The implementation is a hack and not intended to be used in the long
term. Rather than parsing the string directly, this determines the
initial portion of the string that matches the pattern determined by the
chars_format parameter, then creates a NTBS to be parsed by strtod (or
strtold or strtof).

Because creating a NTBS requires allocating memory, but std::from_chars
is noexcept, we need to be careful to minimise allocation. Even after
being careful, allocation failure is still possible, and so a
non-conforming std::no_more_memory error code might be returned.

Because strtod et al depend on the current locale, but std::from_chars
does not, we change the current thread's locale to "C" using newlocale
and uselocale before calling strtod, and restore it afterwards.

Because strtod doesn't have the equivalent of a std::chars_format
parameter, it has to examine the input to determine the format in use,
even though the std::from_chars code has already parsed it once (or
twice for large input strings!)

By replacing the use of strtod we could avoid allocation, avoid changing
locale, and use optimised code paths specific to each std::chars_format
case. We would also get more portable behaviour, rather than depending
on the presence of uselocale, and on any bugs or quirks of the target
libc's strtod. Replacing strtod is a project for a later date.

libstdc++-v3/ChangeLog:

	* acinclude.m4 (libtool_VERSION): Bump version.
	* config.h.in: Regenerate.
	* config/abi/pre/gnu.ver: Add GLIBCXX_3.4.29 version and new
	exports.
	* config/os/gnu-linux/ldbl-extra.ver: Add _GLIBCXX_LDBL_3.4.29
	version and new export.
	* configure: Regenerate.
	* configure.ac: Check for <xlocale.h> and uselocale.
	* crossconfig.m4: Add macro or checks for uselocale.
	* include/std/charconv (from_chars): Declare overloads for
	float, double, and long double.
	* src/c++17/Makefile.am: Add new file.
	* src/c++17/Makefile.in: Regenerate.
	* src/c++17/floating_from_chars.cc: New file.
	(from_chars): Define for float, double, and long double.
	* testsuite/20_util/from_chars/1_c++20_neg.cc: Prune extra
	diagnostics caused by new overloads.
	* testsuite/20_util/from_chars/1_neg.cc: Likewise.
	* testsuite/20_util/from_chars/2.cc: Check leading '+'.
	* testsuite/20_util/from_chars/4.cc: New test.
	* testsuite/20_util/from_chars/5.cc: New test.
	* testsuite/util/testsuite_abi.cc: Add new symbol versions.
2020-07-20 23:49:27 +01:00
Jonathan Wakely
4d1c5b4957 libstdc++: Avoid overflow in istream::get(streambuf&) [LWG 3464]
Similar to the recent changes to basic_istream::ignore, this change
ensures that _M_gcount doesn't overflow when extracting characters and
inserting them into another streambuf.

The solution used here is to use unsigned long long for the count. We
assume that the number of characters extracted won't exceed the maximum
value for that type, but even if it does we avoid any undefined
behaviour.

libstdc++-v3/ChangeLog:

	* include/bits/istream.tcc
	(basic_istream::get(__streambuf_type&, char_type): Use unsigned
	long long for counter and check if it would overflow _M_gcount.
	* testsuite/27_io/basic_istream/get/char/lwg3464.cc: New test.
	* testsuite/27_io/basic_istream/get/wchar_t/lwg3464.cc: New test.
2020-07-20 20:06:46 +01:00
GCC Administrator
ab660b01c3 Daily bump. 2020-07-18 00:16:24 +00:00
Iain Sandoe
f1b6e46c41 libstdc++, coroutine: Add missing constexpr markers.
The methods of the trivial awaitables are intended to
be constexpr.

libstdc++-v3/ChangeLog:

	* include/std/coroutine: Mark the methods of the
	trivial awaitables as constexpr.
2020-07-17 19:51:09 +01:00
GCC Administrator
8ca07a3072 Daily bump. 2020-07-15 00:16:35 +00:00
David Edelsohn
4f97bed9a7 aix: FAT libraries: test native compiler mode directly
The FAT libraries config fragments need to know which library is native
and which is a multilib to choose the correct multilib from which to
append the additional object file or shared object file.  Testing the
top-level archive is fragile because it will fail if rebuilding.  This
patch tests the compiler preprocessing macros for the 64 bit AIX specific
__64BIT__ to determine the native mode of the compiler in MULTILIBTOP.

2020-07-14  David Edelsohn  <dje.gcc@gmail.com>

libatomic/ChangeLog

	* config/t-aix: Set BITS from compiler cpp macro.

libgcc/ChangeLog

	* config/rs6000/t-slibgcc-aix: Set BITS from compiler cpp macro.

libgfortran/ChangeLog

	* config/t-aix: Set BITS from compiler cpp macro.

libgomp/ChangeLog

	* config/t-aix: Set BITS from compiler cpp macro.

libstdc++-v3/ChangeLog

	* config/os/aix/t-aix: Set BITS from compiler cpp macro.
2020-07-14 10:41:40 -04:00
GCC Administrator
ea69fcf9a0 Daily bump. 2020-07-14 00:16:30 +00:00
Jonathan Wakely
ba8fe4b483 libstdc++: Fix istream::ignore exit conditions (PR 94749, PR 96161)
My previous fix for PR 94749 did fix the reported case, so that the next
character is not discarded if it happens to equal the delimiter when __n
characters have already been read. But it introduced a new bug, which is
that the delimiter character would *not* be discarded if the number of
characters discarded is numeric_limits<streamsize>::max() or more before
reaching the delimiter.

The new bug happens because I changed the code to check _M_gcount < __n.
But when __n == numeric_limits<streamsize>::max() that is false, and so
we don't discard the delimiter. It's not sufficient to check for the
delimiter when the __large_ignore condition is true, because there's an
edge case where the delimiter is reached when _M_gcount == __n and so
we break out of the loop without setting __large_ignore.

PR 96161 is a similar bug to the original PR 94749 report, where eofbit
is set after discarding __n characters if there happen to be no more
characters in the stream.

This patch fixes both cases (and the regression) by checking different
conditions for the __n == max case and the __n < max case. For the
former case, we know that we must have either reached the delimiter or
EOF, and the value of _M_gcount doesn't matter (except to avoid integer
overflow). For the latter case we need to check _M_gcount first and only
set eofbit or discard the delimiter if it didn't reach __n. For the
latter case overflow can't happen because _M_gcount <= __n < max.

libstdc++-v3/ChangeLog:

	PR libstdc++/94749
	PR libstdc++/96161
	* include/bits/istream.tcc (basic_istream::ignore(streamsize))
	[n == max]: Check overflow conditions on _M_gcount. Rely on
	the fact that either EOF or the delimiter was reached.
	[n < max]: Check _M_gcount < n before checking for EOF or
	delimiter.
	(basic_istream::ignore(streamsize, char_type): Likewise.
	* src/c++98/compatibility.cc (istream::ignore(streamsize))
	(wistream::ignore(streamsize)): Likewise.
	* src/c++98/istream.cc (istream::ignore(streamsize, char_type))
	(wistream::ignore(streamsize, char_type)): Likewise.
	* testsuite/27_io/basic_istream/ignore/char/94749.cc: Check that
	delimiter is discarded if the number of characters ignored
	doesn't fit in streamsize.
	* testsuite/27_io/basic_istream/ignore/wchar_t/94749.cc:
	Likewise.
	* testsuite/27_io/basic_istream/ignore/char/96161.cc: New test.
	* testsuite/27_io/basic_istream/ignore/wchar_t/96161.cc: New test.
2020-07-13 12:09:44 +01:00
GCC Administrator
50873cc588 Daily bump. 2020-07-09 00:16:44 +00:00
François Dumont
c832cf1c1d libstdc++: Fix [multi]map/[multi]set move constructors noexcept qualification
Container move constructors shall not consider their allocator move
constructor qualification.

libstdc++-v3/ChangeLog:

	* include/bits/stl_tree.h (_Rb_tree_impl(_Rb_tree_impl&&)): Add noexcept
	qualification based only on _Compare one.
	* testsuite/23_containers/map/cons/noexcept_move_construct.cc: Add
	static asserts.
	* testsuite/23_containers/multimap/cons/noexcept_move_construct.cc:
	Likewise.
	* testsuite/23_containers/multiset/cons/noexcept_move_construct.cc:
	Likewise.
	* testsuite/23_containers/set/cons/noexcept_move_construct.cc: Likewise.
2020-07-08 08:02:16 +02:00
GCC Administrator
f60ee68de3 Daily bump. 2020-07-08 00:16:40 +00:00
Jonathan Wakely
161aa50ee2 libstdc++: Whitespace changes to remove spaces before tabs
libstdc++-v3/ChangeLog:

	* include/std/limits: Whitespace changes.
2020-07-07 23:39:44 +01:00
Jonathan Wakely
eb04805be4 libstdc++: Replace __int_limits with __numeric_traits_integer
I recently added std::__detail::__int_limits as a lightweight
alternative to std::numeric_limits, forgetting that the values it
provides (digits, min and max) are already provided by
__gnu_cxx::__numeric_traits.

This change adds __int_traits as an alias for __numeric_traits_integer.
This avoids instantiating __numeric_traits to decide whether to use
__numeric_traits_integer or __numeric_traits_floating. Then all uses of
__int_limits can be replaced with __int_traits, and __int_limits can be
removed.

libstdc++-v3/ChangeLog:

	* include/Makefile.am: Remove bits/int_limits.h.
	* include/Makefile.in: Regenerate.
	* include/bits/int_limits.h: Removed.
	* include/bits/parse_numbers.h (_Select_int_base): Replace
	__int_limits with __int_traits.
	* include/bits/range_access.h (_SSize::operator()): Likewise.
	* include/ext/numeric_traits.h (__numeric_traits_integer): Add
	static assertion.
	(__int_traits): New alias template.
	* include/std/bit (__rotl, __rotr, __countl_zero, __countl_one)
	(__countr_zero, __countr_one, __popcount, __bit_ceil)
	(__bit_floor, __bit_width) Replace __int_limits with
	__int_traits.
	* include/std/charconv (__to_chars_8, __from_chars_binary)
	(__from_chars_alpha_to_num, from_chars): Likewise.
	* include/std/memory_resource (polymorphic_allocator::allocate)
	(polymorphic_allocator::allocate_object): Likewise.
	* include/std/string_view (basic_string_view::_S_compare):
	Likewise.
	* include/std/utility (cmp_equal, cmp_less, in_range): Likewise.
2020-07-07 23:36:29 +01:00
Jonathan Wakely
9ca8fefeb7 libstdc++: Whitespace changes to keep lines below 80 columns
Also remove leading spaces that are followed by tabs.

libstdc++-v3/ChangeLog:

	* include/std/limits: Whitespace changes.
2020-07-07 23:35:10 +01:00
Jonathan Wakely
92cae0785e libstdc++: Add PR number to ChangeLog entry and fix typos 2020-07-07 08:23:12 +01:00
GCC Administrator
4077d74c6d Daily bump. 2020-07-07 00:16:40 +00:00
Jonathan Wakely
6e1c9715b3 libstdc++: Cleanup whitespace and type trait usage in <optional>
This makes the formatting in <optional> consistent and also removes
redundant && tokens from template arguments for traits like
is_constructible and is_convertible.

libstdc++-v3/ChangeLog:

	* include/std/optional (_Optional_payload_base, _Optional_base)
	(optional, __optional_hash_call_base): Adjust whitespace and
	other formatting. Remove redundant && tokens on template
	arguments to type traits.
2020-07-06 21:55:50 +01:00
Jonathan Wakely
bcfe4681f9 libstdc++: Constrain std::make_optional
The standard rquires that std::make_optional is constrained similarly to
the std::optional constructors, which our implementation fails to do.

As a conforming extension this also adds a noexcept-specifier to each
std::make_optional overload.

libstdc++-v3/ChangeLog:

	* include/std/optional (make_optional): Add enable_if
	constraints and noexcept-specifier to each overload.
	* testsuite/20_util/optional/make_optional-2.cc: New test.
2020-07-06 21:54:59 +01:00
Jonathan Wakely
8992cd1892 libstdc++: Add noexcept to std::optional initialization (PR 96036)
libstdc++-v3/ChangeLog:

	PR libstdc++/96036
	* include/std/optional (optional): Add noexcept-specifier to
	every constructor, assignment operator, emplace function and
	dereference operator.
	* testsuite/20_util/optional/assignment/noexcept.cc: New test.
	* testsuite/20_util/optional/cons/noexcept.cc: New test.
2020-07-06 21:54:12 +01:00
Jonathan Wakely
0e5abeb0cb libstdc++: Fix -Wmismatched-tags warnings (PR 96063)
libstdc++-v3/ChangeLog:

	* include/bits/fs_dir.h: Use consistent tag in class-head.
	* include/bits/localefwd.h: Likwise.
	* include/bits/regex.h: Likwise.
	* include/bits/stl_map.h: Likwise.
	* include/bits/stl_multimap.h: Likwise.
	* include/bits/stl_multiset.h: Likwise.
	* include/bits/stl_set.h: Likwise.
	* include/std/complex: Likwise.
	* include/std/functional: Likwise.
	* include/std/future: Likwise.
	* include/std/system_error: Likwise.
	* include/std/thread: Likwise.
	* include/std/tuple: Likwise.
	* include/std/type_traits: Likwise.
	* include/std/valarray: Likwise.
2020-07-06 17:12:29 +01:00
GCC Administrator
b5f2473963 Daily bump. 2020-07-03 00:16:25 +00:00
Jonathan Wakely
5079855e7e libstdc++: Require c++98_only effective target for a test
This test checks a conversion which only exists in C++98 and won't
compile since C++11. It uses { dg-options "-std=gnu++98" } so that it is
explicitly run in C++98 mode. This change also adds a target selector so
that the test will be skipped if the dg-options directive is filtered
out or overridden.

libstdc++-v3/ChangeLog:

	* testsuite/27_io/basic_ios/conv/voidptr.cc: Add c++98_only
	target selector.
2020-07-02 21:27:22 +01:00
Jonathan Wakely
b857b17977 libstdc++: Require c++98_only effective target for some tests
These tests verify that including C++11 headers fails to compile in
C++98 mode. They use { dg-options "-std=gnu++98" } so that they are
explicitly run in C++98 mode. This change also adds a target selector so
that the tests will be skipped even if the dg-options directive is
filtered out or overridden. This is in preparation for a desired future
change where tests do not use -std options, so that they can be tested
with e.g. --target_board=unix\"{-std=gnu++17,-std=gnu++20}\"

In some cases the dg-options and dg-do directives need to be reordered,
so that the -std=gnu++98 option is already added to the options before
the target selector is checked.

libstdc++-v3/ChangeLog:

	* testsuite/18_support/headers/cstdalign/std_c++0x_neg.cc: Add
	c++98_only target selector.
	* testsuite/18_support/headers/cstdbool/std_c++0x_neg.cc:
	Likewise.
	* testsuite/18_support/headers/cstdint/std_c++0x_neg.cc:
	Likewise.
	* testsuite/18_support/headers/new/synopsis_cxx98.cc: Likewise.
	* testsuite/19_diagnostics/headers/system_error/std_c++0x_neg.cc:
	Likewise.
	* testsuite/20_util/headers/type_traits/std_c++0x_neg.cc:
	Likewise.
	* testsuite/23_containers/headers/array/std_c++0x_neg.cc:
	Likewise.
	* testsuite/23_containers/headers/tuple/std_c++0x_neg.cc:
	Likewise.
	* testsuite/23_containers/headers/unordered_map/std_c++0x_neg.cc:
	Likewise.
	* testsuite/23_containers/headers/unordered_set/std_c++0x_neg.cc:
	Likewise.
	* testsuite/26_numerics/headers/ccomplex/std_c++0x_neg.cc:
	Likewise.
	* testsuite/26_numerics/headers/cfenv/std_c++0x_neg.cc:
	Likewise.
	* testsuite/26_numerics/headers/cmath/c99_classification_macros_c++98.cc:
	Likewise.
	* testsuite/26_numerics/headers/ctgmath/std_c++0x_neg.cc:
	Likewise.
	* testsuite/26_numerics/headers/random/std_c++0x_neg.cc:
	Likewise.
	* testsuite/27_io/headers/cinttypes/std_c++0x_neg.cc: Likewise.
	* testsuite/28_regex/headers/regex/std_c++0x_neg.cc: Likewise.
	* testsuite/29_atomics/headers/atomic/std_c++0x_neg.cc:
	Likewise.
	* testsuite/30_threads/headers/condition_variable/std_c++0x_neg.cc:
	Likewise.
	* testsuite/30_threads/headers/future/std_c++0x_neg.cc:
	Likewise.
	* testsuite/30_threads/headers/mutex/std_c++0x_neg.cc: Likewise.
	* testsuite/30_threads/headers/thread/std_c++0x_neg.cc:
	Likewise.
2020-07-02 21:27:12 +01:00
Ville Voutilainen
dbca7a69f2 PR libstdc++/91807
PR libstdc++/91807
	* include/std/variant
	(_Copy_assign_base::operator=(const _Copy_assign_base&):
	Do the move-assignment from a temporary so that the temporary
	is constructed with an explicit index.
	* testsuite/20_util/variant/91807.cc: New.
2020-07-02 22:16:39 +03:00
Jonathan Wakely
c6f431bba5 libstdc++: Fix atomic<long double> tests (PR 91153, PR 93224)
These tests fail with AIX double double. Use different floating point
values that behave less surprisingly.

libstdc++-v3/ChangeLog:

	PR libstdc++/91153
	PR target/93224
	* testsuite/29_atomics/atomic_float/1.cc: Use different values
	for tests.
	* testsuite/29_atomics/atomic_ref/float.cc: Likewise.
2020-07-02 19:05:13 +01:00
GCC Administrator
64f761e4ac Daily bump. 2020-07-02 00:16:26 +00:00
Jonathan Wakely
a1a0dc4548 libstdc++: Remove noexcept from match_results comparisons (PR 94627)
These functions can't be noexcept because the iterators stored in the
sub_match objects can throw on any operation.

libstdc++-v3/ChangeLog:

	PR libstdc++/94627
	* include/bits/regex.h (operator==, operator!=): Remove noexcept
	equality comparisons for match_results.
	* testsuite/28_regex/match_results/94627.cc: New test.
2020-07-01 21:06:42 +01:00
Martin Sebor
8461191b82 Adjust text of expected warnings changed in PR c++/86568.
libstdc++-v3/ChangeLog:

	* testsuite/21_strings/basic_string_view/cons/char/nonnull.cc: Adjust
	text of expected warning.
	* testsuite/21_strings/basic_string_view/cons/wchar_t/nonnull.cc: Same.
	* testsuite/21_strings/basic_string_view/operations/compare/char/nonnull.cc: Same.
	* testsuite/21_strings/basic_string_view/operations/find/char/nonnull.cc: Same.
	* testsuite/21_strings/basic_string_view/operations/rfind/char/nonnull.cc: Same.
2020-07-01 08:33:29 -06:00
GCC Administrator
458f12eda1 Daily bump. 2020-06-30 09:02:21 +00:00
Ville Voutilainen
2635f9e508 Revert "Add a __nonnnull__ attribute to std::string's _CharT* constructor"
This reverts commit b26fd416fb.
2020-06-30 01:59:34 +03:00
GCC Administrator
69273534c6 Daily bump. 2020-06-29 00:16:29 +00:00
Ville Voutilainen
b26fd416fb Add a __nonnnull__ attribute to std::string's _CharT* constructor
Add a __nonnnull__ attribute to std::string's _CharT* constructor
	* include/bits/basic_string.h (string(_CharT*, const _Alloc&)):
	Add a __nonnull__ attribute.
	* testsuite/21_strings/basic_string/cons/char/nonnull.cc: New.
	* testsuite/21_strings/basic_string/cons/wchar_t/nonnull.cc: Likewise.
2020-06-29 00:47:05 +03:00
Ville Voutilainen
24b54628cf PR libstdc++/95915
PR libstdc++/95915
	* include/std/type_traits (is_literal_type, is_literal_type_v):
	Deprecate in C++17.
	* include/std/variant (_Uninitialized):
	Adjust the condition and the comment.
	* testsuite/20_util/is_literal_type/deprecated-1z.cc: New.
	* testsuite/20_util/is_literal_type/requirements/explicit_instantiation.cc:
	Adjust.
	* testsuite/20_util/is_literal_type/requirements/typedefs.cc: Likewise.
	* testsuite/20_util/is_literal_type/value.cc: Likewise.
	* testsuite/20_util/optional/constexpr/nullopt.cc:
	Use __is_literal_type directly.
	* testsuite/20_util/optional/nullopt.cc: Likewise.
	* testsuite/20_util/variable_templates_for_traits.cc: Adjust.
	* testsuite/20_util/variant/95915.cc: New.
	* testsuite/20_util/variant/compile.cc: Add new test.
	* testsuite/experimental/optional/constexpr/nullopt.cc:
	Use __is_literal_type directly.
	* testsuite/experimental/optional/nullopt.cc: Likewise.
	* testsuite/experimental/type_traits/value.cc: Adjust.
	* testsuite/util/testsuite_common_types.h:
	Use __is_literal_type directly.
2020-06-29 00:36:38 +03:00
GCC Administrator
2e546c261b Daily bump. 2020-06-25 00:16:30 +00:00
Jonathan Wakely
eb0ff770e2 libstdc++: Fix std::from_chars to ignore leading zeros in base 2
The parser for binary numbers returned an error if the entire string
contains more digits than the result type. Leading zeros should be
ignored.

libstdc++-v3/ChangeLog:

	* include/std/charconv (__from_chars_binary): Ignore leading zeros.
	* testsuite/20_util/from_chars/1.cc: Check "0x1" for all bases,
	not just 10 and 16.
	* testsuite/20_util/from_chars/3.cc: New test.
2020-06-24 12:35:59 +01:00
Jonathan Wakely
25920dd18a libstdc++: Fix warnings with -Wsystem-headers
libstdc++-v3/ChangeLog:

	* include/bits/stl_algobase.h (__find_if): Add FALLTHRU markers.
	* include/std/charconv (__detail::__to_chars): Avoid
	-Wsign-compare warning.
2020-06-24 12:34:17 +01:00
Jonathan Wakely
be50843754 libstdc++: Fix std::to_chars buffer overflow (PR 95851)
The __detail::__to_chars_2 function assumes it won't be called with zero
values. However, when the output buffer is empty the caller doesn't
handle zero values correctly, and calls __to_chars_2 with a zero value,
resulting in an overflow of the empty buffer.

The __detail::__to_chars_i function should just return immediately for
an empty buffer, and otherwise ensure zero values are handled properly.

libstdc++-v3/ChangeLog:

	PR libstdc++/95851
	* include/std/charconv (__to_chars_i): Check for zero-sized
	buffer unconditionally.
	* testsuite/20_util/to_chars/95851.cc: New test.
2020-06-24 12:28:13 +01:00
GCC Administrator
4543acc874 Daily bump. 2020-06-24 00:16:31 +00:00
Jonathan Wakely
b81d4f1e3d libstdc++: Adjust std::from_chars negative tests
Also test with an enumeration type. Move the dg-error directives outside
the #if block, because DejaGnu would process them whether or not wchar_t
support is present.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/from_chars/1_c++20_neg.cc: Check enumeration
	type.
	* testsuite/20_util/from_chars/1_neg.cc: Likewise. Move dg-error
	directives outside preprocessor condition.
2020-06-23 12:20:26 +01:00
Jonathan Wakely
c98fc4eb3a libstdc++: Implement P1972R2 changes to std::variant (PR 95832)
G++ implements P1972R2 since r11-1597-0ca22d027ecc and so we no longer
need the P0608R3 special case to prevent narrowing conversions to bool.

Since non-GNU compilers don't necessarily implment P1972R2 yet, this
may cause a regression for those compilers. There is no feature-test
macro we can use to detect it though, so we'll have to live with it.

libstdc++-v3/ChangeLog:

	PR libstdc++/95832
	* include/std/variant (__detail::__variant::_Build_FUN): Remove
	partial specialization to prevent narrowing conversions to bool.
	* testsuite/20_util/variant/compile.cc: Test non-narrowing
	conversions to bool.
	* testsuite/20_util/variant/run.cc: Likewise.
2020-06-23 10:25:26 +01:00
Jonathan Wakely
a2c5150e40 libstdc++: Regenerate makefiles
libstdc++-v3/ChangeLog:

	* doc/Makefile.in: Regenerate.
	* include/Makefile.in: Regenerate.
	* libsupc++/Makefile.in: Regenerate.
	* po/Makefile.in: Regenerate.
	* python/Makefile.in: Regenerate.
	* src/Makefile.in: Regenerate.
	* src/c++11/Makefile.in: Regenerate.
	* src/c++17/Makefile.in: Regenerate.
	* src/c++98/Makefile.in: Regenerate.
	* src/filesystem/Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.
2020-06-23 07:59:40 +01:00
GCC Administrator
605a8f3bbc Daily bump. 2020-06-23 00:16:23 +00:00
David Edelsohn
0164e59835 build: Use -include instead of conditional include.
Automake and GNU Make both use the endif keyword, which conflicts and
elicits an error for matching if/ifdef and endif.

This patch changes the conditional include to use "-include" to prevent
a warning about a possible empty tmake_file.

libgomp/ChangeLog

2020-06-22  David Edelsohn  <dje.gcc@gmail.com>

	* Makefile.am: Use -include.
	* Makefile.in: Regenerate.

libatomic/ChangeLog

2020-06-22  David Edelsohn  <dje.gcc@gmail.com>

	* Makefile.am: Use -include.
	* Makefile.in: Regenerate.

libstdc++-v3/ChangeLog

2020-06-22  David Edelsohn  <dje.gcc@gmail.com>

	* Makefile.am: Use -include.
	* Makefile.in: Regenerate.

libgfortran/ChangeLog

2020-06-22  David Edelsohn  <dje.gcc@gmail.com>

	* Makefile.am: Use -include.
	* Makefile.in: Regenerate.
2020-06-22 21:31:48 +00:00
GCC Administrator
f86e11a267 Daily bump. 2020-06-22 00:16:23 +00:00
David Edelsohn
47ddb895df aix: Add GCC64 configuration and FAT target libraries.
This patch adds the ability to configure GCC on AIX to build as a
64 bit application and to build target libraries "FAT" libraries in both
32 bit and 64 bit mode.

The patch adds makefile fragment hooks to target libraries that allows
them to include target-specific rules.  The target specific rules for
AIX place both 32 bit and 64 bit objects and shared objects
in archives at the top-level, not multilib subdirectories.  The
multilibs are built in subdirectories, but must be combined during the
last parts of the target library build process.  Because of the way
that GCC bootstrap works, the libraries must be combined during the
multiple stages of GCC bootstrap, not solely when installed in the
final destination, so the libraries are correct at the end of
each target library build stage, not solely an install recipe.

gcc/ChangeLog

2020-06-21  David Edelsohn  <dje.gcc@gmail.com>

	* config.gcc: Use t-aix64, biarch64 and default64 for cpu_is_64bit.
	* config/rs6000/aix72.h (ASM_SPEC): Remove aix64 option.
	(ASM_SPEC32): New.
	(ASM_SPEC64): New.
	(ASM_CPU_SPEC): Remove vsx and altivec options.
	(CPP_SPEC_COMMON): Rename from CPP_SPEC.
	(CPP_SPEC32): New.
	(CPP_SPEC64): New.
	(CPLUSPLUS_CPP_SPEC): Rename to CPLUSPLUS_CPP_SPEC_COMMON..
	(TARGET_DEFAULT): Only define if not BIARCH.
	(LIB_SPEC_COMMON): Rename from LIB_SPEC.
	(LIB_SPEC32): New.
	(LIB_SPEC64): New.
	(LINK_SPEC_COMMON): Rename from LINK_SPEC.
	(LINK_SPEC32): New.
	(LINK_SPEC64): New.
	(STARTFILE_SPEC): Add 64 bit version of crtcxa and crtdbase.
	(ASM_SPEC): Define 32 and 64 bit alternatives using DEFAULT_ARCH64_P.
	(CPP_SPEC): Same.
	(CPLUSPLUS_CPP_SPEC): Same.
	(LIB_SPEC): Same.
	(LINK_SPEC): Same.
	(SUBTARGET_EXTRA_SPECS): Add new 32/64 specs.
	* config/rs6000/defaultaix64.h: New file.
	* config/rs6000/t-aix64: New file.

libgcc/ChangeLog

2020-06-21  David Edelsohn  <dje.gcc@gmail.com>

	* config.host (extra_parts): Add crtcxa_64 and crtdbase_64.
	* config/rs6000/t-aix-cxa: Explicitly compile 32 bit with -maix32
	and 64 bit with -maix64.
	* config/rs6000/t-slibgcc-aix: Remove extra @multilib_dir@ level.
	Build and install AIX-style FAT libraries.

libgomp/ChangeLog

2020-06-21  David Edelsohn  <dje.gcc@gmail.com>

	* Makefile.am (tmake_file): Build and install AIX-style FAT libraries.
	* Makefile.in: Regenerate
	* configure.ac (tmake_file): Substitute.
	* configure: Regenerate.
	* configure.tgt (powerpc-ibm-aix*): Define tmake_file.
	* config/t-aix: New file.

libstdc++-v3/ChangeLog

2020-06-21  David Edelsohn  <dje.gcc@gmail.com>

	* Makefile.am (tmake_file): Build and install AIX-style FAT libraries.
	* Makefile.in: Regenerate.
	* configure.ac (tmake_file): Substitute.
	* configure: Regenerate.
	* configure.host (aix*): Define tmake_file.
	* config/os/aix/t-aix: New file.

libatomic/ChangeLog

2020-06-21  David Edelsohn  <dje.gcc@gmail.com>

	* Makefile.am (tmake_file): Build and install AIX-style FAT libraries.
	* Makefile.in: Regenerate.
	* configure.ac (tmake_file): Substitute.
	* configure: Regenerate.
	* configure.tgt (powerpc-ibm-aix*): Define tmake_file.
	* config/t-aix: New file.

libgfortran/ChangeLog

2020-06-21  David Edelsohn  <dje.gcc@gmail.com>

	* Makefile.am (tmake_file): Build and install AIX-style FAT libraries.
	* Makefile.in: Regenerate.
	* configure.ac (tmake_file): Substitute.
	* configure: Regenerate.
	* configure.host: Add system configury stanza. Define tmake_file.
	* config/t-aix: New file.
2020-06-21 14:14:46 -04:00
GCC Administrator
bbac3886a2 Daily bump. 2020-06-21 00:16:21 +00:00
Jason Merrill
57b4daf8dc c++: Refinements to "more constrained".
P2113 from the last C++ meeting clarified that we only compare constraints
on functions or function templates that have equivalent template parameters
and function parameters.

I'm not currently implementing the complicated handling of reversed
comparison operators here; thinking about it now, it seems like a lot of
complexity to support a very weird usage.  If I write two similar comparison
operators to be distinguished by their constraints, why would I write one
reversed?  If they're two unrelated operators, they're very unlikely to be
similar enough for the complexity to help.  I've started a discussion on the
committee reflector about changing these rules.

This change breaks some greedy_ops tests in libstdc++ that were relying on
comparing constraints on unrelated templates, which seems pretty clearly
wrong, so I'm removing those tests for now.

gcc/cp/ChangeLog:

	* call.c (joust): Only compare constraints for non-template
	candidates with matching parameters.
	* pt.c (tsubst_pack_expansion): Fix getting a type parameter
	pack.
	(more_specialized_fn): Only compare constraints for candidates with
	matching parameters.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/concepts-return-req1.C: Expect error.
	* g++.dg/cpp2a/concepts-p2113a.C: New test.
	* g++.dg/cpp2a/concepts-p2113b.C: New test.

libstdc++-v3/ChangeLog:

	* testsuite/24_iterators/move_iterator/rel_ops_c++20.cc:
	Remove greedy_ops tests.
	* testsuite/24_iterators/reverse_iterator/rel_ops_c++20.cc:
	Remove greedy_ops tests.
2020-06-20 10:57:21 -04:00
GCC Administrator
e37658dffd Daily bump. 2020-06-20 00:16:27 +00:00
Jonathan Wakely
5b6215083b libstdc++: Fix some -Wsystem-headers warnings (PR 95765)
PR libstdc++/95765
	* include/bits/stl_algobase.h (__size_to_integer(float))
	(__size_to_integer(double), __size_to_integer(long double))
	(__size_to_integer(__float128)): Cast return type explicitly.
	* include/bits/stl_uninitialized.h (__uninitialized_default_1<true>):
	Remove unused typedef.
2020-06-19 18:20:05 +01:00
Jonathan Wakely
a7a3932e4b libstdc++: Remove redundant std:: qualification
* include/bits/stl_pair.h (_Index_tuple): Remove redundant
	namespace qualification.
	(pair::pair(tuple<>&, tuple<>&, _Index_tuple, _Index_tuple)):
	Likewise.
	* include/std/tuple (_Head_base, _Tuple_impl, tuple_size)
	(tuple_element, __get_helper, get, __make_tuple_impl)
	(__make_1st_indices, __tuple_concater)
	(pair::pair(tuple<>&, tuple<>&, _Index_tuple, _Index_tuple)):
	Likewise.
	* include/std/utility (tuple_element, __is_tuple_like_impl)
	(tuple_size, __pair_get, get): Likewise.
2020-06-19 15:02:54 +01:00
Jonathan Wakely
abed8b56b9 libstdc++: Define all std::function members inline
* include/bits/std_function.h (function): Define all member
	functions inline.
2020-06-19 14:37:52 +01:00
Marc Glisse
465520e3eb libstdc++: std::includes performance tweak
A small tweak to the implementation of __includes, which in my
application saves 20% of the running time. I noticed it because using
range-v3 was giving unexpected performance gains.

Some of the gain comes from pulling the 2 calls ++__first1 out of the
condition so there is just one call. And most of the gain comes from
replacing the resulting

if (__comp(__first1, __first2))
  ;
else
  ++__first2;

with

if (!__comp(__first1, __first2))
  ++__first2;

I was very surprised that the code ended up being so different for such
a change, and I still don't really understand where the extra time is
going...

Anyway, while I blame the compiler for not generating very good code
with the current implementation, I believe the change can be seen as a
simplification.

libstdc++-v3/ChangeLog:

	* include/bits/stl_algo.h (__includes): Simplify the code.
2020-06-19 13:03:45 +01:00
Marc Glisse
bafd12cb22 libstdc++: Optimize std::optional default constructor
The attached patch changes the code generated for

std::optional<std::array<int,1024>>f(){return{};}

from

        movq    $0, (%rdi)
        movq    %rdi, %r8
        leaq    8(%rdi), %rdi
        xorl    %eax, %eax
        movq    $0, 4084(%rdi)
        movq    %r8, %rcx
        andq    $-8, %rdi
        subq    %rdi, %rcx
        addl    $4100, %ecx
        shrl    $3, %ecx
        rep stosq
        movq    %r8, %rax

or with different tuning

        subq    $8, %rsp
        movl    $4100, %edx
        xorl    %esi, %esi
        call    memset
        addq    $8, %rsp

to the much shorter

        movb    $0, 4096(%rdi)
        movq    %rdi, %rax

i.e. the same as the nullopt constructor.

The constructor was already non-trivial, so we don't lose that. It passes the
testsuite without regression, but there is no new testcase to verify the
better codegen.

libstdc++-v3/ChangeLog:

	* include/std/optional (optional()): Explicitly define it.
2020-06-19 12:15:43 +01:00
GCC Administrator
aff95ee7cc Daily bump. 2020-06-18 00:16:37 +00:00
Jonathan Wakely
632183ddcc libstdc++: Avoid stack overflow in std::vector (PR 94540)
The std::__uninitialized_default_n algorithm used by std::vector creates
an initial object as a local variable then copies that into the
destination range. If the object is too large for the stack this
crashes. We should create the first object directly into the
destination and then copy it from there.

This doesn't fix the bug for C++98, because in that case the initial
value is created as a default argument of the vector constructor i.e. in
the user's code, not inside libstdc++. We can't prevent that.

	PR libstdc++/94540
	* include/bits/stl_uninitialized.h (__uninitialized_default_1<true>):
	Construct the first value at *__first instead of on the stack.
	(__uninitialized_default_n_1<true>): Likewise.
	Improve comments on several of the non-standard algorithms.
	* testsuite/20_util/specialized_algorithms/uninitialized_default/94540.cc:
	New test.
	* testsuite/20_util/specialized_algorithms/uninitialized_default_n/94540.cc:
	New test.
	* testsuite/20_util/specialized_algorithms/uninitialized_value_construct/94540.cc:
	New test.
	* testsuite/20_util/specialized_algorithms/uninitialized_value_construct_n/94540.cc:
	New test.
	* testsuite/23_containers/vector/cons/94540.cc: New test.
2020-06-17 22:49:06 +01:00
Jonathan Wakely
94b94c0bb1 libstdc++: Fix tests for uninitialized_value_construct_n
In my recent r11-1460 commit the tests had been "improved" before
commit, and no longer exercised the code paths changed by the patch.

This restores what I originally tested, so that the tests fail before
the r11-1460 change and pass after it.

	* testsuite/20_util/specialized_algorithms/uninitialized_default_n/sizes.cc:
	Replace Value type with int so trivial code path is used.
	* testsuite/20_util/specialized_algorithms/uninitialized_value_construct_n/sizes.cc:
	Likewise.
2020-06-17 21:23:35 +01:00
Jonathan Wakely
c9dce3b15e libstdc++: Handle non-integral sizes in std::uninitialized_fill_n
The std::uninitialized_fill_n algorithm uses sd::fill_n for trivial
types, but that algorithm has a stronger requirement that the Size
parameter is convertible to an integral type. As the new test shows,
there are types which are valid for std::uninitialized_fill_n but which
produce a different result when converted to an integral type, or cannot
be converted at all. Only use the std::fill_n optimization when the Size
type is already an integral type.

The std::__uninitialized_default_n extension has the same problem, and
so does C++17's std::uninitialized_value_construct_n which uses it.

	* include/bits/stl_uninitialized.h (uninitialized_fill_n): Only
	use std::fill_n when the size is an integral type.
	(__uninitialized_default_n): Likewise.
	* testsuite/20_util/specialized_algorithms/uninitialized_default_n/sizes.cc:
	New test.
	* testsuite/20_util/specialized_algorithms/uninitialized_fill_n/sizes.cc:
	New test.
	* testsuite/20_util/specialized_algorithms/uninitialized_value_construct_n/sizes.cc:
	New test.
2020-06-17 20:55:06 +01:00
GCC Administrator
56638b9b18 Daily bump. 2020-06-17 00:16:36 +00:00
Jonathan Wakely
e40b11a91c libstdc++: Strip cv-qualifiers in std::atomic<FP> (PR 95282)
This improves the previous fix for PR 95282, and extends it to also
apply to the exchange function (which has a similar problem and would
become ill-formed with my proposed fix for PR 95378).

	PR libstdc++/95282
	* include/bits/atomic_base.h (__atomic_impl::load): Use the _Val
	alias instead of deducing _Tp as an unqualified type.
	(__atomic_impl::exchange): Use the _Val alias to remove volatile
	from the reinterpret_cast result type.
2020-06-16 22:34:55 +01:00
Jonathan Wakely
cc799df98f libstdc++: Enforce copyable/movable checks in std::atomic
C++20 adds some new preconditions to std::atomic, which weren't
previously checked by our implementation.

	* include/std/atomic (atomic): Add static assertions.
	* testsuite/29_atomics/atomic/requirements/types_neg.cc: New test.
2020-06-16 22:34:55 +01:00
Patrick Palka
92bed03609 c++: Improve access checking inside templates [PR41437]
This patch generalizes our existing functionality for deferring access
checking of typedefs when parsing a function or class template to now
defer all kinds of access checks until template instantiation time,
including member function and member object accesses.

Since all access checks eventually go through enforce_access, the main
component of this patch is new handling inside enforce_access to defer
the current access check if we're inside a template.  The bulk of the
rest of the patch consists of removing now-unneeded code pertaining to
suppressing access checks inside templates or pertaining to
typedef-specific access handling.  Renamings and other changes with no
functional impact have been split off into the followup patch.

gcc/cp/ChangeLog:

	PR c++/41437
	PR c++/47346
	* call.c (enforce_access): Move to semantics.c.
	* cp-tree.h (enforce_access): Delete.
	(get_types_needing_access_check): Delete.
	(add_typedef_to_current_template_for_access_check): Delete.
	* decl.c (make_typename_type): Adjust accordingly.  Use
	check_accessibility_of_qualified_id instead of directly using
	perform_or_defer_access_check.
	* parser.c (cp_parser_template_declaration_after_parameters):
	Don't push a dk_no_check access state when parsing a template.
	* pt.c (get_types_needing_access_check): Delete.
	(append_type_to_template_for_access_check_1): Delete.
	(perform_typedefs_access_check): Adjust.  If type_decl is a
	FIELD_DECL, also check its DECL_CONTEXT for dependence. Use
	tsubst_copy instead of tsubst to substitute into type_decl so
	that we substitute into the DECL_CONTEXT of a FIELD_DECL.
	(append_type_to_template_for_access_check): Delete.
	* search.c (accessible_p): Remove the processing_template_decl
	early exit.
	* semantics.c (enforce_access): Moved from call.c.  If we're
	parsing a template and the access check failed, add the check to
	TI_TYPEDEFS_NEEDING_ACCESS_CHECKING.
	(perform_or_defer_access_check): Adjust comment.
	(add_typedef_to_current_template_for_access_check): Delete.
	(check_accessibility_of_qualified_id):  Adjust accordingly.
	Exit early if the scope is dependent.

gcc/testsuite/ChangeLog:

	PR c++/41437
	PR c++/47346
	* g++.dg/cpp2a/concepts-using2.C: Adjust.
	* g++.dg/lto/20081219_1.C: Adjust.
	* g++.dg/lto/20091002-1_0.C: Adjust.
	* g++.dg/lto/pr65475c_0.C: Adjust.
	* g++.dg/opt/dump1.C: Adjust.
	* g++.dg/other/pr53574.C: Adjust.
	* g++.dg/template/access30.C: New test.
	* g++.dg/template/access31.C: New test.
	* g++.dg/wrappers/wrapper-around-type-pack-expansion.C: Adjust.

libstdc++-v3/ChangeLog:

	PR libstdc++/94003
	* testsuite/20_util/is_constructible/94003.cc: New test.
2020-06-16 08:21:33 -04:00
GCC Administrator
6fb94d67f1 Daily bump. 2020-06-16 00:16:28 +00:00
Jonathan Wakely
b6ab9ecd55 libstdc++: Update value of __cpp_lib_constexpr_char_traits for C++20
Although not required by SD-6 or the C++20 draft, we define the macro
__cpp_lib_constexpr_char_traits to indicate support for P0432R1. This
updates the value in C++20 mode for the P1032R1 changes to char_traits.

	* include/bits/char_traits.h (__cpp_lib_constexpr_char_traits):
	Update value for C++20.
	* include/std/version (__cpp_lib_constexpr_char_traits): Likewise.
	* testsuite/21_strings/char_traits/requirements/constexpr_functions_c++17.cc:
	Update expected value.
	* testsuite/21_strings/char_traits/requirements/constexpr_functions_c++20.cc:
	Likewise.
2020-06-15 14:31:26 +01:00
Paul Keir
eb11134d0c libstdc++: Fix char_traits move with overlap
Upon constexpr evaluation, char_traits move uses copy_backward, but its
last argument should be to the range end rather than its beginning.

2020-06-12  Paul Keir  <paul.keir@uws.ac.uk>

	* include/bits/char_traits.h (char_traits::move): constexpr move with
	overlap was using copy_backward incorrectly.
	* testsuite/21_strings/char_traits/requirements/constexpr_functions_c++20.cc:
	New test.
2020-06-15 14:31:26 +01:00
GCC Administrator
8e3b453e08 Daily bump. 2020-06-13 00:16:25 +00:00
Jonathan Wakely
e784f98027 libstdc++: Improve tests for std::atomic_flag
The tests for clear() and test_and_set() didn't cover all cases.

	* testsuite/29_atomics/atomic_flag/clear/1.cc: Also test clear()
	when the value is currently set.
	* testsuite/29_atomics/atomic_flag/test_and_set/explicit.cc:
	Actually check the return value.
	* testsuite/29_atomics/atomic_flag/test_and_set/implicit.cc:
	Likewise.
2020-06-12 10:43:06 +01:00
Jonathan Wakely
17412a74c5 libstdc++: Make std::atomic_flag::test members const
Also fix the tests so they run without an explicit -std=gnu++2a in the
RUNTESTFLAGS, and test the new function on const-qualified objects.

	* include/bits/atomic_base.h (atomic_flag::test): Add missing
	const qualifiers.
	* testsuite/29_atomics/atomic_flag/test/explicit.cc: Add
	dg-options and verify results of test function.
	* testsuite/29_atomics/atomic_flag/test/implicit.cc: Likewise.
2020-06-12 10:31:07 +01:00
GCC Administrator
e68e80c8dd Daily bump. 2020-06-12 00:16:29 +00:00
Jonathan Wakely
b32eea9c0c libstdc++: Fix istream::ignore discarding too many chars (PR 94749)
The current code assumes that if the next character in the stream is
equal to the delimiter then we stopped because we saw that delimiter,
and so discards it.  But in the testcase for the PR we stop because we
reached the maximum number of characters, and it's coincidence that the
next character equals the delimiter. We should not discard the next
character in that case.

The fix is to check that we haven't discarded __n characters already,
instead of checking whether the next character equals __delim. Because
we've already checked for EOF, if we haven't discarded __n yet then we
know we stopped because we saw the delimiter. On the other hand, if the
next character is the delimiter we don't know if that's why we stopped.

	PR libstdc++/94749
	* include/bits/istream.tcc (basic_istream::ignore(streamsize, CharT)):
	Only discard an extra character if we didn't already reach the
	maximum number.
	* src/c++98/istream.cc (istream::ignore(streamsiz, char))
	(wistream::ignore(streamsize, wchar_t)): Likewise.
	* testsuite/27_io/basic_istream/ignore/char/94749.cc: New test.
	* testsuite/27_io/basic_istream/ignore/wchar_t/94749.cc: New test.
2020-06-11 18:41:37 +01:00
GCC Administrator
ec6ffbb919 Daily bump. 2020-06-11 00:16:45 +00:00
Patrick Palka
a73051a0ea libstdc++: Fix some ranges algos optimizations [PR95578]
ranges::copy and a number of other ranges algorithms have unwrapping
optimizations for iterators of type __normal_iterator, move_iterator and
reverse_iterator.  But in the checks that guard these optimizations we
currently only test that the iterator of the iterator/sentinel pair has
the appropriate type before proceeding with the corresponding
optimization, and do not also test the sentinel type.

This breaks the testcase in this PR because this testcase constructs via
range adaptors a range whose begin() is a __normal_iterator and whose
end() is a custom sentinel type, and then performs ranges::copy on it.
From there we bogusly perform the __normal_iterator unwrapping
optimization on this iterator/sentinel pair, which immediately leads to
a constraint failure since the custom sentinel type does not model
sentinel_for<int*>.

This patch fixes this issue by refining each of the problematic checks
to also test that the iterator and sentinel types are the same before
applying the corresponding unwrapping optimization.  Along the way, some
code simplifications are made.

libstdc++-v3/ChangeLog:

	PR libstdc++/95578
	* include/bits/ranges_algo.h (__lexicographical_compare_fn):
	Also check that the iterator and sentinel have the same type before
	applying the unwrapping optimization for __normal_iterator.
	Split the check into two, one for the first iterator/sentinel
	pair and another for second iterator/sentinel pair.  Remove uses
	of __niter_base, and remove uses of std::move on a
	__normal_iterator.
	* include/bits/ranges_algobase.h (__equal_fn): Likewise.
	(__copy_or_move): Likewise.  Perform similar adjustments for
	the reverse_iterator and move_iterator optimizations.  Inline
	the checks into the if-constexprs, and use using-declarations to
	make them less visually noisy.  Remove uses of __niter_wrap.
	(__copy_or_move_backward): Likewise.
	* testsuite/25_algorithms/copy/95578.cc: New test.
	* testsuite/25_algorithms/copy_backward/95578.cc: New test.
	* testsuite/25_algorithms/equal/95578.cc: New test.
	* testsuite/25_algorithms/lexicographical_compare/95578.cc: New test.
	* testsuite/25_algorithms/move/95578.cc: New test.
	* testsuite/25_algorithms/move_backward/95578.cc: New test.
2020-06-10 17:37:53 -04:00
François Dumont
3a391adf7a libstdc++: Extend memcmp optimization in std::lexicographical_compare
Make the memcmp optimization work for std::deque iterators and safe
iterators.

Co-authored-by: Jonathan Wakely  <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

2020-06-08  François Dumont  <fdumont@gcc.gnu.org>
	    Jonathan Wakely  <jwakely@redhat.com>

	* include/bits/deque.tcc (__lex_cmp_dit): New.
	(__lexicographical_compare_aux1): Define overloads for deque
	iterators.
	* include/bits/stl_algobase.h (__lexicographical_compare::__3way):
	New static member function.
	(__lexicographical_compare<true>::__3way): Likewise.
	(__lexicographical_compare<true>::__lc): Use __3way.
	(__lexicographical_compare_aux): Rename to
	__lexicographical_compare_aux1 and declare overloads for deque
	iterators.
	(__lexicographical_compare_aux): Define new forwarding function
	that calls __lexicographical_compare_aux1 and declare new overloads
	for safe iterators.
	(lexicographical_compare): Do not use __niter_base on
	parameters.
	* include/debug/safe_iterator.tcc
	(__lexicographical_compare_aux): Define overloads for safe
	iterators.
	* testsuite/25_algorithms/lexicographical_compare/1.cc: Add
	checks with random access iterators.
	* testsuite/25_algorithms/lexicographical_compare/deque_iterators/1.cc:
	New test.
2020-06-10 17:48:56 +01:00
GCC Administrator
b952c2cfcd Daily bump. 2020-06-10 00:16:47 +00:00
Jonathan Wakely
733167f9d5 libstdc++: Define converting assignment operator for std::move_iterator
As clarified by LWG 3265, std::move_iterator is supposed to have an
assignment operator that converts from a different specialization of
std::move_iterator, which performs an assignment. That has always been
missing from libstdc++, so assigning a different type actually performs
a converting construction, then an assignment. This is non-conforming
for the (fairly contrived) case where the converting assignment is
well-formed but the converting construction is not.

	* include/bits/stl_iterator.h (move_iterator::operator=): Define.
	* testsuite/24_iterators/move_iterator/dr3265.cc: New test.
2020-06-09 22:16:24 +01:00
Jonathan Wakely
d364705791 libstdc++: Define std::bad_optional_access constructor as defaulted
The standard requires that std::bad_optional_access' default
constructor has a non-throwing exception specification.

	* include/std/optional (bad_optional_access): Define default
	constructor and destructor as defaulted.
	* testsuite/20_util/optional/bad_access.cc: New test.
2020-06-09 22:14:43 +01:00
GCC Administrator
2c455ae06c Daily bump. 2020-06-09 00:16:47 +00:00
Jonathan Wakely
a37fbff12c libstdc++: Fix failing tests
These started failing with the previous commit, because I forgot to add
the tests after adjusting them.

	* testsuite/20_util/default_delete/48631_neg.cc: Adjust dg-error
	line number.
	* testsuite/20_util/default_delete/void_neg.cc: Likewise.
2020-06-08 21:34:46 +01:00
Jonathan Wakely
187da2ce31 libstdc++: Implement operator<< for std::unique_ptr (LWG 2948)
libstdc++-v3/ChangeLog:

	* include/bits/unique_ptr.h (operator<<): Define for C++20.
	* testsuite/20_util/unique_ptr/io/lwg2948.cc: New test.
2020-06-08 21:21:31 +01:00
GCC Administrator
3add342502 Daily bump. 2020-06-05 00:16:30 +00:00
Jonathan Wakely
f2242ec0d3 libstdc++: Remove workarounds for constrained nested class templates
With PR c++/92078 and PR c++/92103 both fixed, nested class templates
can now be constrained. That means a number of namespace-scope helpers
can be moved to the class scope, so they're only visible where they're
needed.

	* include/bits/iterator_concepts.h (__detail::__ptr, __detail::__ref)
	(__detail::__cat, __detail::__diff): Move to class scope in the
	relevant __iterator_traits specializations.
	(__iterator_traits<>): Use nested class templates instead of ones from
	namespace __detail.
	* include/bits/stl_iterator.h (__detail::__common_iter_ptr): Move to
	class scope in iterator_traits<common_iterator<I, S>>.
	(iterator_traits<common_iterator<I, S>>): Use nested class template
	instead of __detail::__common_iter_ptr.
2020-06-04 23:20:49 +01:00
François Dumont
4e05c918d2 libstdc++: Specialize copy/copy_n for istreambuf_iterator and deque iterators
Add __copy_n_a overloads for std::deque iterators to replace with C memmove
when possible. Expose std::copy_n implementation details in pre-C++11 modes
and use it for std::copy overloads.

libstdc++-v3/ChangeLog

	* include/bits/stl_algo.h (__copy_n_a): Move to ...
	* include/bits/stl_algobase.h (__copy_n_a): ...here. Add __strict
	parameter.
	(__copy_n_a(istreambuf_iterator<>, _Size, _Deque_iterator<>, bool)):
	Declare.
	(__niter_base(const _Safe_iterator<_Ite, _Seq,
	random_access_iterator_tag>&)): Declare.
	(__copy_move_a2(istreambuf_iterator<>, istreambuf_iterator<>,
	_Deque_iterator<>)): Declare.
	* include/bits/deque.tcc
	(__copy_move_a2(istreambuf_iterator<>, istreambuf_iterator<>,
	_Deque_iterator<>)): New.
	(__copy_n_a(istreambuf_iterator<>, _Size, _Deque_iterator<>, bool)):
	New.
	* include/bits/streambuf_iterator.h
	(__copy_n_a(istreambuf_iterator<>, _Size, _CharT*, bool)): Adapt.
	* include/debug/safe_iterator.tcc (__niter_base): New.
	* testsuite/25_algorithms/copy/streambuf_iterators/char/4.cc
	(test03): New.
	* testsuite/25_algorithms/copy/streambuf_iterators/char/debug/deque_neg.cc:
	New test.
	* testsuite/25_algorithms/copy_n/debug/istreambuf_ite_deque_neg.cc:
	New test.
	* testsuite/25_algorithms/copy_n/istreambuf_iterator/2.cc: New test.
	* testsuite/25_algorithms/copy_n/istreambuf_iterator/deque.cc:
	New test.
2020-06-04 22:27:47 +02:00
Jonathan Wakely
e1008cd1d8 libstdc++: Make std::copy_n work with negative and non-integral sizes
Since it was added in C++11, std::copy_n and std::ranges::copy_n should
do nothing given a negative size, but for random access iterators we add
the size to the iterator, possibly resulting in undefined behaviour.

Also, C++20 clarified that std::copy_n requires the Size type to be
convertible to an integral type. We previously assumed that it could be
directly used in arithmetic expressions, without conversion to an
integral type.

This also fixes a bug in the random_access_iterator_wrapper helper adds
some convenience aliases for using the iterator wrappers.

libstdc++-v3/ChangeLog:

	* include/bits/ranges_algobase.h (__copy_n_fn): Only call
	ranges::copy for positive values.
	* include/bits/stl_algo.h (copy_n): Convert Size argument to an
	integral type and only call __copy_n for positive values.
	* testsuite/util/testsuite_iterators.h
	(random_access_iterator_wrapper::operator+=): Fix range check for
	negative values.
	(output_container, input_container, forward_container)
	(bidirectional_container, random_access_container): New alias
	templates.
	* testsuite/25_algorithms/copy_n/5.cc: New test.
2020-06-04 14:21:34 +01:00
GCC Administrator
a9312a7926 Daily bump. 2020-06-03 00:16:34 +00:00
Jonathan Wakely
eca833b812 libstdc++: Make debug containers prefer copy ctor to base ctor (PR 90102)
When given a type which can convert to any container-like type, the
C(const C&) copy constructor and C(const C::_Base&) converting
constructor are ambiguous. This change replaces the converting
constructor's parameter with a reference_wrapper-like type so that
calling that constructor requires an additional user-defined conversion.
This gives it a lower rank than the copy constructor, avoiding the
ambiguity.

While testing this change I discovered that __gnu_debug::forward_list
doesn't have a convering constructor from the std::forward_list base, so
this adds it.

We should probably consider whether the converting constructors should
be 'explicit' but I'm not changing that now.

libstdc++-v3/ChangeLog:

	PR libstdc++/90102
	* include/debug/deque (deque(const _Base&)): Replace parameter
	with a struct that wraps a const _Base&.
	* include/debug/forward_list (forward_list(_Base_ref)): New
	constructor.
	* include/debug/list (list(const _Base&)): Replace parameter
	with a struct that wraps a const _Base&.
	* include/debug/map.h (map(const _Base&)): Likewise.
	* include/debug/multimap.h (multimap(const _Base&)): Likewise.
	* include/debug/multiset.h (multiset(const _Base&)): Likewise.
	* include/debug/set.h (set(const _Base&)): Likewise.
	* include/debug/unordered_map (unordered_map(const _Base&))
	(unordered_multimap(const _Base&)): Likewise.
	* include/debug/unordered_set (unordered_set(const _Base&))
	(unordered_multiset(const _Base&)): Likewise.
	* testsuite/23_containers/vector/cons/destructible_debug_neg.cc:
	Adjust dg-error line number.
	* include/debug/vector (vector(const _Base&)): Likewise.
	* testsuite/23_containers/deque/debug/90102.cc: New test.
	* testsuite/23_containers/forward_list/debug/90102.cc: New test.
	* testsuite/23_containers/list/debug/90102.cc: New test.
	* testsuite/23_containers/map/debug/90102.cc: New test.
	* testsuite/23_containers/multimap/debug/90102.cc: New test.
	* testsuite/23_containers/multiset/debug/90102.cc: New test.
	* testsuite/23_containers/set/debug/90102.cc: New test.
	* testsuite/23_containers/unordered_map/debug/90102.cc: New test.
	* testsuite/23_containers/unordered_multimap/debug/90102.cc: New test.
	* testsuite/23_containers/unordered_multiset/debug/90102.cc: New test.
	* testsuite/23_containers/unordered_set/debug/90102.cc: New test.
	* testsuite/23_containers/vector/debug/90102.cc: New test.
2020-06-02 18:13:33 +01:00
GCC Administrator
4a9aa9dec7 Daily bump. 2020-06-02 00:16:25 +00:00
Jonathan Wakely
cd3f067b82 libstdc++: Fix filesystem::u8path for mingw targets (PR 95392)
When I refactored filesystem::path string conversions in
r11-587-584d52b088f9fcf78704b504c3f1f07e17c1cded I failed to update the
mingw-specific code in filesystem::u8path, causing a bootstrap failure.

This fixes it, and further refactors the mingw-specific code along the
same lines as the previous commit. All conversions from UTF-8 strings to
wide strings now use the same helper function, __wstr_from_utf8.

	PR libstdc++/95392
	* include/bits/fs_path.h (path::_S_to_string): Move to
	namespace-scope and rename to ...
	(__detail::__string_from_range): ... this.
	[WINDOWS] (__detail::__wstr_from_utf8): New function template to
	convert a char sequence containing UTF-8 to wstring.
	(path::_S_convert(Iter, Iter)): Adjust call to _S_to_string.
	(path::_S_convert_loc(Iter, Iter, const locale&)): Likewise.
	(u8path(InputIterator, InputIterator)) [WINDOWS]: Use
	__string_from_range to obtain a contiguous range and
	__wstr_from_utf8 to obtain a wide string.
	(u8path(const Source&)) [WINDOWS]: Use __effective_range to
	obtain a contiguous range and __wstr_from_utf8 to obtain a wide
	string.
	(path::_S_convert(const _EcharT*, const _EcharT)) [WINDOWS]:
	Use __wstr_from_utf8.
2020-06-02 00:07:05 +01:00
Jonathan Wakely
118158b646 libstdc++: Fix __gnu_test::input_iterator_wrapper::operator++(int)
I noticed recently that our input_iterator_wrapper utility for writing
tests has the following post-increment operator:

    void
    operator++(int)
    {
      ++*this;
    }

That fails to meet the Cpp17InputIterator requirement that *r++ is
valid. This change makes it return a non-void proxy type that can be
deferenced to produce another proxy, which is convertible to the
value_type. The second proxy converts to const T& to ensure it can't be
written to.

	* testsuite/util/testsuite_iterators.h:
	(input_iterator_wrapper::operator++(int)): Return proxy object.
2020-06-01 18:30:47 +01:00
Jonathan Wakely
258059d91b libstdc++: Document API changes in GCC 10
* doc/xml/manual/evolution.xml: Document deprecation of
	__is_nullptr_t and removal of std::allocator members.
	* doc/html/manual/api.html: Regenerate.
2020-06-01 16:50:53 +01:00
Jonathan Wakely
a1ffe9b6f4 libstdc++: Fix incorrect Docbook links
The <xref> element creates the link text automatically from the link
target, rather than using the text node child of the element. This can
be changed by using an endterm attribute, but it's simpler to just use
the <link> element instead.

	* doc/xml/manual/containers.xml: Replace <xref> with <link>.
	* doc/xml/manual/evolution.xml: Likewise.
	* doc/html/manual/api.html: Regenerate.
	* doc/html/manual/containers.html: Regenerate.
2020-06-01 16:49:31 +01:00
Gerald Pfeifer
e41b988cc5 libstdc++: Update/streamline Valgrind references
* doc/xml/faq.xml: Adjust Valgrind reference and remove another.
	* doc/html/faq.html: Regenerate.
2020-06-01 17:04:22 +02:00
GCC Administrator
e7340ed74a Daily bump. 2020-06-01 00:16:26 +00:00
Gerald Pfeifer
0feb332152 libstdc++: Remove stray change from previous commit
There is a stray change (introducing a bogus line at the top) that
came via 2babbb6760c43bcd803a5e168ef5ecb0be8a5121; remove that again.

	* doc/xml/manual/policy_data_structures_biblio.xml: Remove
	stray change.
2020-06-01 02:10:24 +02:00
Gerald Pfeifer
2babbb6760 libstdc++: Switch www.cs.princeton.edu to https
* doc/xml/manual/policy_data_structures_biblio.xml: Switch
	www.cs.princeton.edu to https.
	* doc/html/manual/policy_data_structures.html: Regenerate.
2020-06-01 02:03:48 +02:00
Douglas B Rupp
0edfc1fd22 Check for more missing math decls on vxworks.
Use the GLIBCXX_CHECK_MATH_DECL macro to check for the full list of
vxworks math decls.

libstdc++-v3/ChangeLog

	* crossconfig.m4 (<*-vxworks>): Check for more math decls.
	* configure: Rebuild.
2020-05-31 14:32:27 -07:00
GCC Administrator
885ef72f27 Daily bump. 2020-05-30 00:16:27 +00:00
H.J. Lu
9051b54827 Avoid nested save_CFLAGS and save_LDFLAGS
Avoid nested save_CFLAGS and save_LDFLAGS by replacing save_CFLAGS and
save_LDFLAGS with cet_save_CFLAGS and cet_save_LDFLAGS in cet.m4.

config/

	PR bootstrap/95413
	* cet.m4: Replace save_CFLAGS and save_LDFLAGS with
	cet_save_CFLAGS and cet_save_LDFLAGS.

gcc/

	PR bootstrap/95413
	* configure: Regenerated.

libatomic/

	PR bootstrap/95413
	* configure: Regenerated.

libbacktrace/

	PR bootstrap/95413
	* configure: Regenerated.

libcc1/

	PR bootstrap/95413
	* configure: Regenerated.

libcpp/

	PR bootstrap/95413
	* configure: Regenerated.

libdecnumber/

	PR bootstrap/95413
	* configure: Regenerated.

libgcc/

	PR bootstrap/95413
	* configure: Regenerated.

libgfortran/

	PR bootstrap/95413
	* configure: Regenerated.

libgomp/

	PR bootstrap/95413
	* configure: Regenerated.

libiberty/

	PR bootstrap/95413
	* configure: Regenerated.

libitm/

	PR bootstrap/95413
	* configure: Regenerated.

libobjc/

	PR bootstrap/95413
	* configure: Regenerated.

libphobos/

	PR bootstrap/95413
	* configure: Regenerated.

libquadmath/

	PR bootstrap/95413
	* configure: Regenerated.

libsanitizer/

	PR bootstrap/95413
	* configure: Regenerated.

libssp/

	PR bootstrap/95413
	* configure: Regenerated.

libstdc++-v3/

	PR bootstrap/95413
	* configure: Regenerated.

libvtv/

	PR bootstrap/95413
	* configure: Regenerated.

lto-plugin/

	PR bootstrap/95413
	* configure: Regenerated.

zlib/

	PR bootstrap/95413
	* configure: Regenerated.
2020-05-29 12:56:40 -07:00
François Dumont
7688e5e8c4 libstdc++: Review unordered_map insert_or_assign/try_emplace (PR 95079)
Those methods are making a double lookup in case of insertion, they can
perform only one.

	PR libstdc++/95079
	* include/bits/hashtable_policy.h (_Insert_base<>::try_emplace): New.
	* include/bits/unordered_map.h (unordered_map<>::try_emplace): Adapt.
	(unordered_map<>::insert_or_assign): Adapt.
2020-05-29 13:12:36 +02:00
GCC Administrator
61f3b60556 Daily bump. 2020-05-28 04:23:50 +00:00
Jonathan Wakely
bbaec68c86 libstdc++: Fix atomic<FP>::load (PR 95282)
PR libstdc++/95282
	* include/bits/atomic_base.h (__atomic_impl::load): Add
	cv-qualifiers to parameter so that _Tp is deduced as the
	unqualified type.
	* testsuite/29_atomics/atomic_float/95282.cc: New test.
2020-05-27 22:55:21 +01:00
Jonathan Wakely
6c2582c040 libstdc++: Fix view adaptors for mixed-const sentinels and iterators (PR 95322)
The bug report is that transform_view's sentinel<false> cannot be
compared to its iterator<true>.  The comparison is supposed to use
operator==(iterator<Const>, sentinel<Const>) after converting
sentinel<false> to sentinel<true>. However, the operator== is a hidden
friend so is not a candidate when comparing iterator<true> with
sentinel<false>. The required conversion would only happen if we'd found
the operator, but we can't find the operator until after the conversion
happens.

A new LWG issue has been reported, but not yet assigned a number.  The
solution suggested by Casey Carter is to make the hidden friends of the
sentinel types work with iterators of any const-ness, so that no
conversions are required.

Patrick Palka observed that join_view has a similar problem and a
similar fix is used for its sentinel.

	PR libstdc++/95322
	* include/std/ranges (transform_view::_Sentinel): Allow hidden
	friends to work with _Iterator<true> and _Iterator<false>.
	(join_view::_Sentinel): Likewise.
	* testsuite/std/ranges/adaptors/95322.cc: New test.
2020-05-27 22:08:15 +01:00
Jonathan Wakely
979e89a9a9 libstdc++: Fix std::reverse_iterator comparisons (PR 94354)
The std::reverse_iterator comparisons have always been implemented only
in terms of equality and less than. In C++98 that made no difference for
reasonable code, because when the underlying operators are the same type
they are required to support all comparisons anyway.

But since LWG 280 it's possible to compare reverse_iterator<X> and
reverse_iterator<Y>, and comparisons between X and Y might not support
the full set of equality and relational operators. This means that it
matters whether we implement operator!= as x.base() != y.base() or
!(x.base() == y.base()), and the current implementation is
non-conforming.

This was already fixed in GCC 10.1 for C++20, this change also fixes it
for all other -std modes.

	PR libstdc++/94354
	* include/bits/stl_iterator.h (reverse_iterator): Fix comparison
	operators to use the correct operations on the underlying
	iterators.
	* testsuite/24_iterators/reverse_iterator/rel_ops.cc: New test.
2020-05-27 21:58:56 +01:00
Jonathan Wakely
116e3cfc7b libstdc++: Add new testcase for comparison category types
Comparing a comparison category type to anything except a literal 0 is
undefined. This verifies that at least some misuses are diagnosed at
compile time.

	* testsuite/18_support/comparisons/categories/zero_neg.cc: New test.
2020-05-27 13:14:17 +01:00
GCC Administrator
c3a4169be9 Daily bump. 2020-05-27 07:45:56 +00:00
Patrick Palka
3bf5e7657b libstdc++: Fix common_iterator::operator-> [PR95322]
This patch fixes the definition of common_iterator::operator-> when the
underlying iterator's operator* returns a non-reference.

The first problem is that the class __detail::_Common_iter_proxy is used
unqualified.  Fixing that revealed another problem: the class's template
friend declaration of common_iterator doesn't match up with the
definition of common_iterator, because the friend declaration isn't
constrained.

If we try to make the friend declaration match up by adding constraints,
we run into frontend bug PR93467.  So we currently can't correctly
express this friend relation between __detail::_Common_iter_proxy and
common_iterator.

As a workaround to this frontend bug, this patch moves the definition of
_Common_iter_proxy into the class template of common_iterator so that we
could instead express the friend relation via the injected-class-name.

(This bug was found when attempting to use views::common to work around
the compile failure with the testcase in PR95322.)

libstdc++-v3/ChangeLog:

	PR libstdc++/95322
	* include/bits/stl_iterator.h (__detail::_Common_iter_proxy):
	Remove and instead define it ...
	(common_iterator::_Proxy): ... here.
	(common_iterator::operator->): Use it.
	* testsuite/24_iterators/common_iterator/2.cc: New test.
	* testsuite/std/ranges/adaptors/95322.cc: New test.
2020-05-26 16:17:34 -04:00
Patrick Palka
a57aa11191 libstdc++: Compile PR93978 testcase with -Wall
Now that the frontend issue PR c++/94038 is thoroughly fixed, the
testcase for PR93978 no longer fails to compile with -O -Wall, so add
-Wall to the testcase's compile flags to help ensure we don't regress
here.

libstdc++-v3/ChangeLog:

	PR libstdc++/93978
	* testsuite/std/ranges/adaptors/93978.cc: Add -Wall to
	dg-additional-options.  Avoid unused-but-set-variable warning.
2020-05-23 15:25:40 -04:00
Jonathan Wakely
3cb0c7cc16 libstdc++: Fix function that can't be constexpr in C++11 (PR 95289)
The body of this function isn't just a return statement, so it can't be
constexpr until C++14.

	PR libstdc++/95289
	* include/debug/helper_functions.h (__get_distance): Only declare
	as a constexpr function for C++14 and up.
	* testsuite/25_algorithms/copy/debug/95289.cc: New test.
2020-05-23 18:27:35 +01:00
Jonathan Wakely
584d52b088 libstdc++: Refactor filesystem::path string conversions
This simplifies the logic of converting Source arguments and pairs of
InputIterator arguments into the native string format. For any input
that is a contiguous range of path::value_type (or char8_t for POSIX)
a string view can be created and the conversion can be done directly,
with no intermediate allocation. Previously some cases created a
basic_string unnecessarily, for example construction from a pair of
path::string_type::iterators, or a pair of non-const value_type*
pointers.

	* include/bits/fs_path.h (__detail::_S_range_begin)
	(__detail::_S_range_end, path::_S_string_from_iter): Replace with
	overloaded function template __detail::__effective_range.
	(__detail::__effective_range): New overloaded function template to
	create a basic_string or basic_string_view for an effective range.
	(__detail::__value_type_is_char): Use __detail::__effective_range.
	Do not use remove_const on value type.
	(__detail::__value_type_is_char_or_char8_t): Likewise.
	(path::path(const Source&, format))
	(path::path(const Source&, const locale&))
	(path::operator/=(const Source&), path::append(const Source&))
	(path::concat(const Source&)): Use __detail::__effective_range.
	(path::_S_to_string(InputIterator, InputIterator)): New function
	template to create a string view if possible, or string otherwise.
	(path::_S_convert): Add overloads that convert a string returned
	by __detail::__effective_range. Use if-constexpr to inline conversion
	logic from all overloads of _Cvt::_S_convert.
	(path::_S_convert_loc): Add overload that converts a string. Use
	_S_to_string to avoid allocation when possible.
	(path::_Cvt): Remove.
	(path::operator+=(CharT)): Remove indirection through path::concat.
	* include/experimental/bits/fs_path.h (path::_S_convert_loc): Add
	overload for non-const pointers, to avoid constructing a std::string.
	* src/c++17/fs_path.cc (path::_S_convert_loc): Replace conditional
	compilation with call to _S_convert.
2020-05-23 09:40:16 +01:00
Jonathan Wakely
00c8f2a5e3 libstdc++: Remove incorrect static specifiers
These functions were originally static members of the path class, but
the 'static' specifiers were not removed when they were moved to
namespace scope. This causes ODR violations when the functions are
called from functions defined in the header, which is incompatible with
Nathan's modules branch.  Change them to 'inline' instead.

	* include/bits/fs_path.h (__detail::_S_range_begin)
	(__detail::_S_range_end): Remove unintentional static specifiers.
	* include/experimental/bits/fs_path.h (__detail::_S_range_begin)
	(__detail::_S_range_end): Likewise.
2020-05-23 09:40:16 +01:00