Commit Graph

9296 Commits

Author SHA1 Message Date
Jonathan Wakely
da8ddcec0c Define [range.cmp] comparisons for C++20
Define std::identity, std::ranges::equal_to, std::ranges::not_equal_to,
std::ranges::greater, std::ranges::less, std::ranges::greater_equal and
std::ranges::less_equal.

	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/bits/range_cmp.h: New header for C++20 function objects.
	* include/std/functional: Include new header.
	* testsuite/20_util/function_objects/identity/1.cc: New test.
	* testsuite/20_util/function_objects/range.cmp/equal_to.cc: New test.
	* testsuite/20_util/function_objects/range.cmp/greater.cc: New test.
	* testsuite/20_util/function_objects/range.cmp/greater_equal.cc: New
	test.
	* testsuite/20_util/function_objects/range.cmp/less.cc: New test.
	* testsuite/20_util/function_objects/range.cmp/less_equal.cc: New test.
	* testsuite/20_util/function_objects/range.cmp/not_equal_to.cc: New
	test.

From-SVN: r277120
2019-10-17 16:40:00 +01:00
Jonathan Wakely
47519a5687 PR libstdc++/92124 fix incorrect container move assignment
The container requirements say that for move assignment "All existing
elements of [the target] are either move assigned or destroyed". Some of
our containers currently use __make_move_if_noexcept which makes the
move depend on whether the element type is nothrow move constructible.
This is incorrect, because the standard says we must move assign, not
move or copy depending on the move constructor.

Use make_move_iterator instead so that we move unconditionally. This
ensures existing elements won't be copy assigned.

	PR libstdc++/92124
	* include/bits/forward_list.h
	(_M_move_assign(forward_list&&, false_type)): Do not use
	__make_move_if_noexcept, instead move unconditionally.
	* include/bits/stl_deque.h (_M_move_assign2(deque&&, false_type)):
	Likewise.
	* include/bits/stl_list.h (_M_move_assign(list&&, false_type)):
	Likewise.
	* include/bits/stl_vector.h (_M_move_assign(vector&&, false_type)):
	Likewise.
	* testsuite/23_containers/vector/92124.cc: New test.

From-SVN: r277113
2019-10-17 15:21:27 +01:00
Jonathan Wakely
44af818f00 Only use GCC-specific __is_same_as built-in conditionally
Clang doesn't support __is_same_as but provides __is_same instead.
Restore the original implementation (pre r276891) when neither of those
built-ins is available.

	* include/bits/c++config (_GLIBCXX_BUILTIN_IS_SAME_AS): Define to
	one of __is_same_as or __is_same when available.
	* include/std/concepts (__detail::__same_as): Use std::is_same_v.
	* include/std/type_traits (is_same) [_GLIBCXX_BUILTIN_IS_SAME_AS]:
	Use new macro instead of __is_same_as.
	(is_same) [!_GLIBCXX_BUILTIN_IS_SAME_AS]: Restore partial
	specialization.
	(is_same_v) [_GLIBCXX_BUILTIN_IS_SAME_AS]: Use new macro.
	(is_same_v) [!_GLIBCXX_BUILTIN_IS_SAME_AS]: Use std::is_same.

From-SVN: r277058
2019-10-16 11:26:05 +01:00
François Dumont
8cf9bbd247 [_GLIBCXX_DEBUG] Clarify constness and state <unknown> entries.
* src/c++11/debug.cc (print_field): Replace constness_names <unknown>
	entry with <unknown constness>. Replace state_names <unknown> entry with
	<unknown state>.

From-SVN: r277049
2019-10-16 05:05:27 +00:00
Jonathan Wakely
cfc219ae68 Implement <concepts> header for C++20
There are currently no tests for [concepts.compare], but they will be
added ASAP.

	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/precompiled/stdc++.h: Include <concepts>.
	* include/std/concepts: New header for C++20.
	* include/std/version (__cpp_lib_concepts): Define.
	* scripts/create_testsuite_files: Look for test files in new std
	directory.
	* testsuite/libstdc++-dg/conformance.exp: Likewise.
	* testsuite/std/concepts/concepts.callable/invocable.cc: New test.
	* testsuite/std/concepts/concepts.callable/regular_invocable.cc: New
	test.
	* testsuite/std/concepts/concepts.callable/relation.cc: New test.
	* testsuite/std/concepts/concepts.callable/strictweakorder.cc: New
	test.
	* testsuite/std/concepts/concepts.lang/concept.arithmetic/
	floating_point.cc: New test.
	* testsuite/std/concepts/concepts.lang/concept.arithmetic/integral.cc:
	New test.
	* testsuite/std/concepts/concepts.lang/concept.arithmetic/
	signed_integral.cc: New test.
	* testsuite/std/concepts/concepts.lang/concept.arithmetic/
	unsigned_integral.cc: New test.
	* testsuite/std/concepts/concepts.lang/concept.assignable/1.cc: New
	test.
	* testsuite/std/concepts/concepts.lang/concept.common/1.cc: New test.
	* testsuite/std/concepts/concepts.lang/concept.commonref/1.cc: New
	test.
	* testsuite/std/concepts/concepts.lang/concept.constructible/1.cc:
	New test.
	* testsuite/std/concepts/concepts.lang/concept.convertible/1.cc:
	New test.
	* testsuite/std/concepts/concepts.lang/concept.copyconstructible/1.cc:
	New test.
	* testsuite/std/concepts/concepts.lang/concept.defaultconstructible/
	1.cc: New test.
	* testsuite/std/concepts/concepts.lang/concept.derived/1.cc:
	New test.
	* testsuite/std/concepts/concepts.lang/concept.destructible/1.cc:
	New test.
	* testsuite/std/concepts/concepts.lang/concept.moveconstructible/1.cc:
	New test.
	* testsuite/std/concepts/concepts.lang/concept.same/1.cc:
	New test.
	* testsuite/std/concepts/concepts.lang/concept.swappable/swap.cc:
	New test.
	* testsuite/std/concepts/concepts.lang/concept.swappable/swappable.cc:
	New test.
	* testsuite/std/concepts/concepts.lang/concept.swappable/
	swappable_with.cc: New test.
	* testsuite/std/concepts/concepts.object/copyable.cc: New test.
	* testsuite/std/concepts/concepts.object/movable.cc: New test.
	* testsuite/std/concepts/concepts.object/regular.cc: New test.
	* testsuite/std/concepts/concepts.object/semiregular.cc: New test.

From-SVN: r276892
2019-10-11 16:53:52 +01:00
Jonathan Wakely
02f6fdff65 Use __is_same_as for std::is_same and std::is_same_v
By using the built-in we don't need to match a partial specialization
for std::is_same and don't need to instantiate std::is_same at all for
uses of std::is_same_v.

	* include/std/type_traits (is_same): Replace partial specialization
	by using __is_same_as built-in in primary template.
	(is_same_v): Use __is_same_as built-in instead of instantiating the
	is_same trait.

From-SVN: r276891
2019-10-11 16:53:44 +01:00
Jonathan Wakely
07758d90c7 PR libstdc++/92059 fix several bugs in tr2::dynamic_bitset
PR libstdc++/92059
	* include/tr2/dynamic_bitset (__dynamic_bitset_base): Define all
	special member functions as defaulted. Add noexcept to most members.
	(__dynamic_bitset_base(size_t, unsigned long long, const _Alloc&)):
	Mask off unwanted bits in the __val parameter. Avoid undefined left
	shifts.
	(__dynamic_bitset_base::_M_assign): Remove.
	(__dynamic_bitset_base::_M_do_reset): Use std::fill.
	(__dynamic_bitset_base::_M_are_all_aux): Avoid integer promotion when
	block_type has lower rank than int.
	(dynamic_bitset): Add noexcept to most members. Use injected-class-name
	in return types and parameter types.
	(dynamic_bitset::_M_Nb): Add default member initializer.
	(dynamic_bitset(), dynamic_bitset(const dynamic_bitset&)): Define as
	defaulted.
	(dynamic_bitset(dynamic_bitset&&)): Clear source object after move.
	(dynamic_bitset::operator=(const dynamic_bitset&)): Define as
	defaulted.
	(dynamic_bitset::operator=(dynamic_bitset&&)): Add noexcept-specifier.
	Define without using swap, to propagate allocator correctly.
	(dynamic_bitset(const char*, const _Alloc&)): Use strlen.
	(dynamic_bitset::_M_do_sanitize, dynamic_bitset::_M_do_fill): Use
	casts to avoid unwanted integer promotions.
	(dynamic_bitset::_M_copy_from_ptr): Rearrange template parameters and
	add default template arguments and default argument to simplify usage.
	(dynamic_bitset::_M_copy_from_string): Adjust call to _M_copy_from_ptr.
	(operator==(const dynamic_bitset&, const dynamic_bitset&))
	(operator<(const dynamic_bitset&, const dynamic_bitset&)): Use _M_Nb.
	* include/tr2/dynamic_bitset.tcc (dynamic_bitset::_M_copy_from_ptr):
	Adjust template parameters to match declaration.
	* testsuite/tr2/dynamic_bitset/cmp.cc: New test.
	* testsuite/tr2/dynamic_bitset/cons.cc: New test.
	* testsuite/tr2/dynamic_bitset/copy.cc: New test.
	* testsuite/tr2/dynamic_bitset/move.cc: New test.
	* testsuite/tr2/dynamic_bitset/pr92059.cc: New test.

From-SVN: r276890
2019-10-11 16:29:55 +01:00
Jonathan Wakely
2bf2dacb35 Avoid warnings in <charconv>
* include/bits/charconv.h (__to_chars_len): Avoid -Wsign-compare
	warnings.

From-SVN: r276889
2019-10-11 16:29:50 +01:00
Jonathan Wakely
9cfc400f3f PR libstdc++/91057 fix bootstrap failure on powerpc
PR libstdc++/91057
	* src/c++98/locale.cc [_GLIBCXX_LONG_DOUBLE_COMPAT]
	(find_ldbl_sync_facet): Fix parameter type and missing return.

From-SVN: r276840
2019-10-10 17:16:17 +01:00
Marek Polacek
89e0a492af Implement C++20 P0388R4, DR 1307, and DR 330.
This patch implements P0388R4, Permit conversions to arrays of unknown bound,
<http://wg21.link/p0388r4>.  CWG 393 allowed references to arrays of unknown
bound and this C++20 feature allows conversions like

  void f(int(&)[]);
  int arr[1];

  void g() { f(arr); }
  int(&r)[] = arr;

The proposal seemed fairly straightforward but it turned out to be quite
shifty.  I found out that I needed to implement DR 2352 (done), and also
DR 1307 (done in this patch).  The latter DR added wording for
list-initialization ranking of references to arrays which this proposal
extends.  DR 330 was also implemented in this patch.

	PR c++/91364 - P0388R4: Permit conversions to arrays of	unknown bound.
	PR c++/69531 - DR 1307: Differently bounded array parameters.
	PR c++/88128 - DR 330: Qual convs and pointers to arrays of pointers.
	* call.c (build_array_conv): Build ck_identity at the beginning
	of the conversion.
	(standard_conversion): Pass bounds_none to comp_ptr_ttypes_const.
	(maybe_warn_array_conv): New.
	(convert_like_real): Call it.  Add an error message about converting
	from arrays of unknown bounds.
	(conv_get_original_expr): New.
	(nelts_initialized_by_list_init): New.
	(conv_binds_to_array_of_unknown_bound): New.
	(compare_ics): Implement list-initialization ranking based on
	array sizes, as specified in DR 1307 and P0388R.
	* cp-tree.h (comp_ptr_ttypes_const): Adjust declaration.
	(compare_bounds_t): New enum.
	* typeck.c (comp_array_types): New bool and compare_bounds_t
	parameters.  Use them.
	(structural_comptypes): Adjust the call to comp_array_types.
	(similar_type_p): Handle ARRAY_TYPE.
	(build_const_cast_1): Pass bounds_none to comp_ptr_ttypes_const.
	(comp_ptr_ttypes_real): Don't check cv-quals of ARRAY_TYPEs.  Use
	comp_array_types to compare array types.  Look through arrays as per
	DR 330.
	(comp_ptr_ttypes_const): Use comp_array_types to compare array types.
	Look through arrays as per DR 330.

	* g++.dg/conversion/qual1.C: New test.
	* g++.dg/conversion/qual2.C: New test.
	* g++.dg/conversion/qual3.C: New test.
	* g++.dg/conversion/ref2.C: New test.
	* g++.dg/conversion/ref3.C: New test.
	* g++.dg/cpp0x/initlist-array3.C: Remove dg-error.
	* g++.dg/cpp0x/initlist-array7.C: New test.
	* g++.dg/cpp0x/initlist-array8.C: New test.
	* g++.dg/cpp2a/array-conv1.C: New test.
	* g++.dg/cpp2a/array-conv10.C: New test.
	* g++.dg/cpp2a/array-conv11.C: New test.
	* g++.dg/cpp2a/array-conv12.C: New test.
	* g++.dg/cpp2a/array-conv13.C: New test.
	* g++.dg/cpp2a/array-conv14.C: New test.
	* g++.dg/cpp2a/array-conv15.C: New test.
	* g++.dg/cpp2a/array-conv16.C: New test.
	* g++.dg/cpp2a/array-conv17.C: New test.
	* g++.dg/cpp2a/array-conv2.C: New test.
	* g++.dg/cpp2a/array-conv3.C: New test.
	* g++.dg/cpp2a/array-conv4.C: New test.
	* g++.dg/cpp2a/array-conv5.C: New test.
	* g++.dg/cpp2a/array-conv6.C: New test.
	* g++.dg/cpp2a/array-conv7.C: New test.
	* g++.dg/cpp2a/array-conv8.C: New test.
	* g++.dg/cpp2a/array-conv9.C: New test.
	* g++.old-deja/g++.bugs/900321_01.C: Adjust dg-error.

	* testsuite/23_containers/span/lwg3255.cc: Adjust test to match the
	post-P0388R4 behavior.

From-SVN: r276771
2019-10-09 20:58:00 +00:00
Jonathan Wakely
cc386cf233 PR libstdc++/91057 set locale:🆔:_M_index atomically
If two threads see _M_index==0 concurrently they will both try to set
it, potentially storing the facet at two different indices in the array.

Either set the _M_index data member using an atomic compare-exchange
operation or while holding a mutex.

Also move the LONG_DOUBLE_COMPAT code into a separate function to remove
the visual noise it creates.

	PR libstdc++/91057
	* src/c++98/locale.cc (locale:🆔:_M_id()) [__GTHREADS]: Use atomic
	compare-exchange or double-checked lock to ensure only one thread sets
	the _M_index variable.
	[_GLIBCXX_LONG_DOUBLE_COMPAT]: Call find_ldbl_sync_facet to detect
	facets that share another facet's ID.
	[_GLIBCXX_LONG_DOUBLE_COMPAT] (find_ldbl_sync_facet): New function.

From-SVN: r276762
2019-10-09 16:59:56 +01:00
Jonathan Wakely
531b0a3172 PR libstdc++/78552 only construct std::locale for C locale once
PR libstdc++/78552
	* src/c++98/locale_init.cc (locale::classic()): Do not construct a new
	locale object for every call.
	(locale::_S_initialize_once()): Construct C locale here.

From-SVN: r276758
2019-10-09 13:55:39 +01:00
Jonathan Wakely
07f37a7fd4 Add makefile target to update HTML files in source tree
Also remove the creation of the html/ext sub-directory, which has been
unused since revision r245258.

	* doc/Makefile.am (doc-html-docbook-regenerate): New target.
	(${docbook_outdir}/html): Do not create unused 'html/ext' directory.
	* doc/Makefile.in: Regenerate.
	* doc/xml/manual/documentation_hacking.xml: Document new target.
	* doc/html/*: Regenerate.

From-SVN: r276695
2019-10-08 12:01:44 +01:00
Jonathan Wakely
db4fd46519 Restore URL for Austern article on allocators
This reverts "Remove broken URL from libstdc++ manual" by restoring the
link, but using an archived copy from the Wayback Machine.

	* doc/xml/manual/allocator.xml: Use archived copy of CUJ article.
	* doc/html/*: Regenerate.

From-SVN: r276693
2019-10-08 11:41:28 +01:00
François Dumont
8ab38f6cbc Add std::copy_n istreambuf_iterator specialization
* include/bits/stl_algo.h
	(__copy_n_a(_IIte, _Size, _OIte)): New.
	(__copy_n_a(istreambuf_iterator<>, _Size, _CharT*)): New declaration.
	(__copy_n(_IIte, _Size, _OIte, input_iterator_tag)): Adapt to use
	latter.
	* include/bits/streambuf_iterator.h (istreambuf_iterator<>): Declare
	std::__copy_n_a friend.
	(__copy_n_a(istreambuf_iterator<>, _Size, _CharT*)): New.
	* testsuite/25_algorithms/copy_n/istreambuf_iterator/1.cc: New.
	* testsuite/25_algorithms/copy_n/istreambuf_iterator/1_neg.cc: New.
	* testsuite/25_algorithms/copy_n/istreambuf_iterator/2_neg.cc: New.

From-SVN: r276638
2019-10-06 15:29:04 +00:00
François Dumont
6e55630310 Add C++11 __iterator_category_t template alias.
* include/bits/stl_iterator_base_types.h (__iterator_category_t): Define
	for C++11.
	(_RequireInputIte): Likewise and use __enable_if_t.
	* include/std/numeric
	(__is_random_access_iter): Use __iterator_category_t.

From-SVN: r276637
2019-10-06 15:10:40 +00:00
François Dumont
2c6374228b Add std::copy_n __glibcxx_requires_can_increment checks.
* include/bits/stl_algo.h (copy_n): Add __glibcxx_requires_can_increment
	debug checks.
	* testsuite/25_algorithms/copy_n/debug/1_neg.cc: New.
	* testsuite/25_algorithms/copy_n/debug/2_neg.cc: New.

From-SVN: r276636
2019-10-06 10:29:35 +00:00
François Dumont
36edf9cab1 Improve _GLIBCXX_DEBUG safe iterator range size computation.
* include/debug/forward_list
	(_Sequence_traits<__debug::forward_list<>>::_S_size): Returns __dp_sign
	distance when not empty.
	* include/debug/list (_Sequence_traits<__debug::list<>>::_S_size):
	Likewise.
	* include/debug/helper_functions.h (__dp_sign_max_size): New
	_Distance_precision enum entry.
	(__valid_range_aux(_IIte, _IIte, _Distance_traits<>::__type,
	__false_type)): Adapt.
	* include/debug/safe_iterator.tcc
	(_Safe_iterator<>::_M_get_distance_to(const _Safe_iterator&)): Review
	distance computation.

From-SVN: r276600
2019-10-04 20:22:11 +00:00
Jonathan Wakely
2fc115875e Build filesystem library with large file support
Enable AC_SYS_LARGEFILE to set the macros needed for large file APIs to
be used by default. We do not want to define those macros in the
public headers that users include. The values of the macros are copied
to a separate file that is only included by the filesystem sources
during the build, and then the macros in <bits/c++config.h> are renamed
so that they don't have any effect in user code including our headers.

Also use larger type for result of filesystem::file_size to avoid
truncation of large values on 32-bit systems (PR 91947).

	PR libstdc++/81091
	PR libstdc++/91947
	* configure.ac: Use AC_SYS_LARGEFILE to enable 64-bit file APIs.
	* config.h.in: Regenerate:
	* configure: Regenerate:
	* include/Makefile.am (${host_builddir}/largefile-config.h): New
	target to generate config header for filesystem library.
	(${host_builddir}/c++config.h): Rename macros for large file support.
	* include/Makefile.in: Regenerate.
	* src/c++17/fs_dir.cc: Include new config header.
	* src/c++17/fs_ops.cc: Likewise.
	(filesystem::file_size): Use uintmax_t for size.
	* src/filesystem/dir.cc: Include new config header.
	* src/filesystem/ops.cc: Likewise.
	(experimental::filesystem::file_size): Use uintmax_t for size.

From-SVN: r276585
2019-10-04 16:08:23 +01:00
Jonathan Wakely
0a789c10e9 Replace uses of std::tr1::unordered_map in testsuite
* testsuite/util/testsuite_abi.h: Use std::unordered_map instead of
	std::tr1::unordered_map.
	* testsuite/util/testsuite_allocator.h: Likewise.

From-SVN: r276584
2019-10-04 16:08:14 +01:00
Jonathan Wakely
3459c90545 Add missing header required by previous change
* include/tr1/hashtable.h: Add header for __gnu_cxx::__alloc_traits.

From-SVN: r276576
2019-10-04 14:17:54 +01:00
Jonathan Wakely
44e4da6505 Adjust tr1::_Hashtable to work with std::allocator in C++20
In C++20 std::allocator will no longer define construct and destroy
member functions, so using them needs to go via allocator_traits.

	* include/tr1/hashtable.h (tr1::_Hashtable::_M_allocate_node): Use
	__gnu_cxx::__alloc_traits for allocator construct function.
	(tr1::_Hashtable::_M_deallocate_node): Likewise for destroy function.

From-SVN: r276575
2019-10-04 13:17:01 +01:00
Jonathan Wakely
8384956a1b Add <span> to <bits/stdc++.h> precompiled header
* include/precompiled/stdc++.h: Include <span> for C++20.
	* testsuite/17_intro/names.cc: Do not define 'e' for C++20.

From-SVN: r276574
2019-10-04 13:16:56 +01:00
Rainer Orth
ebf8247e7b Avoid reserved identifier in include/parallel/multiway_merge.h
* include/parallel/multiway_merge.h (_RAIter3): Replace _C by _Cp.

From-SVN: r276515
2019-10-03 14:35:35 +00:00
Jonathan Wakely
352d2690f1 Remove greedy wildcards from libstdc++ linker script
The only symbols matched by std::e[a-q]* and std::e[s-z]* that are
supposed to be in the GLIBCXX_3.4 version are std::exception::* and
std::endl and std::ends. The latter two already have explicit patterns
matching them, so we just need to match std::exception::*.

This change ensures that any new symbols with a return type of
std::enable_if<...> are not added to the GLIBCXX_3.4 version.

	* config/abi/pre/gnu.ver: Tighten up greedy wildcards.

From-SVN: r276468
2019-10-02 16:52:41 +01:00
Jonathan Wakely
709310e7a4 Document non-conformance of parallel mode to recent C++ standards
* doc/xml/manual/parallel_mode.xml: Add caveat about support for
	recent standards.
	* doc/html/*: Regenerate.

From-SVN: r276463
2019-10-02 15:56:57 +01:00
Jonathan Wakely
a16bc2f317 Make some new algorithms work in parallel mode
* include/experimental/algorithm (experimental::sample): Qualify call
	to __sample correctly.
	* include/parallel/algo.h (sample, for_each_n): Add using-declarations
	for algorithms that don't have parallel implementations.

From-SVN: r276432
2019-10-01 22:02:27 +01:00
Jonathan Wakely
e12097eda0 Make some parallel mode algorithms usable in constexpr contexts
This makes the __parallel::equal and __parallel:lexicographical_compare
algorithms usable in constant expressions, by dispatching to the
sequential algorithm when calling during constant evaluation.

	* include/parallel/algobase.h (equal, lexicographical_compare): Add
	_GLIBCXX20_CONSTEXPR and dispatch to sequential algorithm when being
	constant evaluated.
	* include/parallel/algorithmfwd.h (equal, lexicographical_compare):
	Add _GLIBCXX20_CONSTEXPR.

From-SVN: r276431
2019-10-01 22:02:22 +01:00
Jonathan Wakely
61e619b4fd Disable tests that aren't valid in parallel mode
Tests that depend on debug mode can't be tested in parallel mode.

	* testsuite/17_intro/using_namespace_std_tr1_neg.cc: Skip test for
	parallel mode.
	* testsuite/20_util/hash/84998.cc: Likewise.
	* testsuite/23_containers/deque/types/pmr_typedefs_debug.cc: Likewise.
	* testsuite/23_containers/forward_list/pmr_typedefs_debug.cc: Likewise.
	* testsuite/23_containers/list/pmr_typedefs_debug.cc: Likewise.
	* testsuite/23_containers/map/pmr_typedefs_debug.cc: Likewise.
	* testsuite/23_containers/multimap/pmr_typedefs_debug.cc: Likewise.
	* testsuite/23_containers/multiset/pmr_typedefs_debug.cc: Likewise.
	* testsuite/23_containers/set/pmr_typedefs_debug.cc: Likewise.
	* testsuite/23_containers/unordered_map/pmr_typedefs_debug.cc:
	Likewise.
	* testsuite/23_containers/unordered_multimap/pmr_typedefs_debug.cc:
	Likewise.
	* testsuite/23_containers/unordered_multiset/pmr_typedefs_debug.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/pmr_typedefs_debug.cc:
	Likewise.
	* testsuite/23_containers/vector/cons/destructible_debug_neg.cc:
	Likewise.
	* testsuite/23_containers/vector/types/pmr_typedefs_debug.cc: Likewise.
	* testsuite/25_algorithms/binary_search/partitioned.cc: Likewise.
	* testsuite/25_algorithms/copy/86658.cc: Likewise.
	* testsuite/25_algorithms/equal_range/partitioned.cc: Likewise.
	* testsuite/25_algorithms/lexicographical_compare/71545.cc: Likewise.
	* testsuite/25_algorithms/lower_bound/partitioned.cc: Likewise.
	* testsuite/25_algorithms/upper_bound/partitioned.cc: Likewise.

From-SVN: r276430
2019-10-01 22:02:17 +01:00
Jonathan Wakely
577663511e Fix non-reserved names in Parallel Mode headers
* include/parallel/algo.h: Replace non-reserved names.
	* include/parallel/multiway_merge.h: Likewise.
	* include/parallel/multiway_mergesort.h: Likewise.
	* include/parallel/numericfwd.h: Likewise.
	* testsuite/17_intro/names.cc: Add RAI to test macros.

From-SVN: r276429
2019-10-01 22:02:01 +01:00
François Dumont
3d0f0d3a85 Implement C++20 constexpr comparison operators for __debug::array (P1023).
Add missing ChangeLog entry.

From-SVN: r276376
2019-09-30 20:38:15 +00:00
Andreas Tobler
b54453598a Include netinet/in.h in include/experimental/internet
2019-09-30  Andreas Tobler  <andreast@gcc.gnu.org>

	* include/experimental/internet: Include netinet/in.h if we have
	_GLIBCXX_HAVE_NETINET_IN_H defined.

From-SVN: r276374
2019-09-30 22:26:57 +02:00
Andreas Tobler
4aec299125 libstdc++ testsuite, silence a FreeBSD libm warning
Add missing ChangeLog entry for the previous commit.

From-SVN: r276373
2019-09-30 22:25:37 +02:00
Jonathan Wakely
582c57a17e Implement LWG 3255 for std::span constructors
Also fix the constraints on span(Container&) and span(const Container&)
constructors so that they aren't used for const spans or const arrays.

	* include/std/span (span(element_type(&)[N]))
	(span(array<value_type, N>&), span(const array<value_type, N>&)):
	Deduce array element type to allow safe const conversions (LWG 3255).
	[!_GLIBCXX_P1394] (span(Container&), span(const Container&)): Use
	remove_cv_t on arguments to __is_std_span and __is_std_array.
	* testsuite/23_containers/span/lwg3255.cc: New test.

From-SVN: r276298
2019-09-30 12:52:08 +01:00
Jonathan Wakely
6438d29fb1 PR libstdc++/77936 remove unused variable
PR libstdc++/77936
	* include/parallel/checkers.h (__is_sorted): Remove unused variable.

From-SVN: r276297
2019-09-30 12:52:01 +01:00
François Dumont
97d5766531 stl_algo.h (merge): Fix documentation.
2019-09-28  François Dumont  <fdumont@gcc.gnu.org>

	* include/bits/stl_algo.h (merge): Fix documentation.
	* include/debug/functions.h (__check_sorted_aux): Add C++20 constexpr.
	(__check_sorted): Likewise and remove nested irreflexive check.
	(__check_sorted_set_aux, __check_sorted_set): Add C++20 constexpr.
	(__check_partitioned_lower, __check_partitioned_upper): Likewise.
	(_Irreflexive_checker::_S_is_valid): Likewise.
	(__is_irreflexive, __is_irreflexive_pred): Likewise.
	* include/debug/helper_functions.h (__get_distance): Add constexpr.
	(__valid_range_aux): Add C++20 constexpr.
	(__valid_range(_Iter, _Iter, _Distance_traits<_Iter>::__type&)):
	Likewise and add std::is_constant_evaluated check.
	(__valid_range_aux(_Iter, _Iter, std::input_iterator_tag)): New.
	(__valid_range_aux(_Iter, _Iter, std::random_accss_iterator_tag)): New.
	(__valid_range_aux(_Integral, _Integral, std::__true_type)): New,
	use latter.
	(__valid_range(_Iter, _Iter)): Adapt to use latter, add constexpr and
	__builtin_is_contant_evaludated check..
	(__can_advance, __base): Add constexpr.
	* include/debug/macros.h [_GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED]
	(_GLIBCXX_DEBUG_VERIFY_COND_AT): New.
	(__glibcxx_check_sorted): Use __glibcxx_check_irreflexive.
	(__glibcxx_check_sorted_pred): Use __glibcxx_check_irreflexive_pred.
	* testsuite/25_algorithms/binary_search/constexpr.cc: Use irreflexive
	std::less.
	* testsuite/25_algorithms/is_sorted/constexpr.cc: Likewise.
	* testsuite/25_algorithms/merge/constexpr.cc: Fix order in camm. Fix
	lambda to be irreflexive.

From-SVN: r276260
2019-09-28 21:11:55 +00:00
Maciej W. Rozycki
e9085da528 Regenerate configure' scripts for uclinuxfdpiceabi' libtool.m4 update
A change made with r275564 ("[ARM/FDPIC v6 02/24] [ARM] FDPIC: Handle 
arm*-*-uclinuxfdpiceabi in configure scripts") to libtool.m4 has not 
regenerated all the `configure' scripts affected.  Fix it.

	gcc/
	* configure: Regenerate.

	libatomic/
	* configure: Regenerate.

	libbacktrace/
	* configure: Regenerate.

	libcc1/
	* configure: Regenerate.

	libffi/
	* configure: Regenerate.

	libgfortran/
	* configure: Regenerate.

	libgomp/
	* configure: Regenerate.

	libhsail-rt/
	* configure: Regenerate.

	libitm/
	* configure: Regenerate.

	libobjc/
	* configure: Regenerate.

	liboffloadmic/
	* configure: Regenerate.

	libphobos/
	* configure: Regenerate.

	libquadmath/
	* configure: Regenerate.

	libsanitizer/
	* configure: Regenerate.

	libssp/
	* configure: Regenerate.

	libstdc++-v3/
	* configure: Regenerate.

	libvtv/
	* configure: Regenerate.

	lto-plugin/
	* configure: Regenerate.

	zlib/
	* configure: Regenerate.

From-SVN: r276213
2019-09-27 21:24:42 +00:00
Jonathan Wakely
f7a3a38227 PR libstdc++/91910 fix data race in Debug Mode destructors
Fix data race when _Safe_iterator_base::_M_detach() runs concurrently with
the _Safe_container_base destructor.

	PR libstdc++/91910
	* src/c++11/debug.cc (_Safe_iterator_base::_M_detach()): Load pointer
	atomically and lock the mutex before accessing the sequence.
	(_Safe_local_iterator_base::_M_detach()): Likewise.
	(_Safe_iterator_base::_M_reset()): Clear _M_sequence atomically.

From-SVN: r276184
2019-09-27 17:20:40 +01:00
Jonathan Wakely
c9fb0a85b6 Define std::to_array for Debug Mode
* include/debug/array (to_array): Define for debug mode.

From-SVN: r276155
2019-09-26 17:08:44 +01:00
Jonathan Wakely
7a9942f521 Implement C++20 constexpr changes to std::pair (P1032R1)
* include/bits/stl_pair.h (pair): Add _GLIBCXX20_CONSTEXPR to
	piecewise construction constructor, assignment operators, and swap.
	* include/std/tuple (pair::pair(piecewise_construct_t, tuple, tuple)):
	Add _GLIBCXX20_CONSTEXPR.
	(pair::pair(tuple, tuple, _Index_tuple, _Index_tuple)): Likewise.
	* testsuite/20_util/pair/constexpr_assign.cc: New test.
	* testsuite/20_util/pair/constexpr_swap.cc: New test.

From-SVN: r276154
2019-09-26 17:08:39 +01:00
Jonathan Wakely
d5f7e04923 Fix array index error in address_v6 comparisons
* include/experimental/internet (operator==, operator<): Fix loop
	condition to avoid reading past the end of the array.

From-SVN: r276153
2019-09-26 17:08:33 +01:00
Jonathan Wakely
8eb60b2f22 Remove include directives for deleted Profile Mode headers
* include/std/array: Remove references to profile mode.
	* include/std/bitset: Likewise.
	* include/std/deque: Likewise.
	* include/std/forward_list: Likewise.
	* include/std/list: Likewise.
	* include/std/map: Likewise.
	* include/std/set: Likewise.
	* include/std/unordered_map: Likewise.
	* include/std/unordered_set: Likewise.
	* include/std/vector: Likewise.
	* testsuite/17_intro/headers/c++1998/profile_mode.cc: New test.
	* testsuite/17_intro/headers/c++2011/profile_mode.cc: New test.

From-SVN: r276152
2019-09-26 17:08:24 +01:00
Jonathan Wakely
21f7f9980c Implement LWG 3296 for basic_regex::assign
* include/bits/regex.h
	(basic_regex::assign(const C*, size_t, flag_type)): Add default
	argument (LWG 3296).
	* testsuite/28_regex/basic_regex/assign/char/lwg3296.cc: New test.
	* testsuite/28_regex/basic_regex/assign/wchar_t/lwg3296.cc: New test.

From-SVN: r276121
2019-09-25 13:31:53 +01:00
Jonathan Wakely
fe69bee34c Remove check for impossible condition in std::variant::index()
The __index_type is only ever unsigned char or unsigned short, so not
the same type as size_t.

	* include/std/variant (variant::index()): Remove impossible case.

From-SVN: r276100
2019-09-24 15:17:08 +01:00
Jonathan Wakely
47d17f7058 PR libstdc++/91871 fix Clang warnings in testsuite
PR libstdc++/91871
	* testsuite/util/testsuite_hooks.h
	(conversion::iterator_to_const_iterator()): Do not return an invalid
	iterator. Test direct-initialization and direct-list-initialization
	as well as implicit conversion.

From-SVN: r276091
2019-09-24 11:09:18 +01:00
Jonathan Wakely
1e8822d360 PR libstdc++/91788 improve codegen for std::variant<T...>::index()
If __index_type is a smaller type than size_t, then the result of
size_t(__index_type(-1)) is not equal to size_t(-1), but to an incorrect
value such as size_t(255) or size_t(65535). The old implementation of
variant<T...>::index() uses (size_t(__index_type(_M_index + 1)) - 1)
which is always correct, but generates suboptimal code for many common
cases.

When the __index_type is size_t or valueless variants are not possible
we can just return the value directly.

When the number of alternatives is sufficiently small the result of
converting the _M_index value to the corresponding signed type will be
either non-negative or -1. In those cases converting to the signed type
and then to size_t will either produce the correct positive value or
will sign extend -1 to (size_t)-1 as desired.

For the remaining case we keep the existing arithmetic operations to
ensure the correct result.

	PR libstdc++/91788 (partial)
	* include/std/variant (variant::index()): Improve codegen for cases
	where conversion to size_t already works correctly.

From-SVN: r276056
2019-09-23 16:54:16 +01:00
Andreas Schwab
193410e311 * config/abi/post/riscv64-linux-gnu/baseline_symbols.txt: Update.
From-SVN: r276048
2019-09-23 08:33:10 +00:00
Jonathan Wakely
52f6afe06d PR libstdc++/91748 fix std::for_each_n for random access iterators
PR libstdc++/91748
	* include/bits/stl_algo.h (for_each_n): Fix random access iterator
	case.
	* testsuite/25_algorithms/for_each/for_each_n.cc: Test with random
	access iterators.

From-SVN: r275683
2019-09-12 11:51:39 +01:00
Jonathan Wakely
c5748fdbf4 Fix Xmethod for shared_ptr::use_count()
This was reported in https://bugzilla.redhat.com/show_bug.cgi?id=1749578

	* python/libstdcxx/v6/xmethods.py (SharedPtrUseCountWorker.__call__):
	Fix syntax error.

From-SVN: r275644
2019-09-11 12:38:23 +01:00
Jonathan Wakely
ce7f1ce4d0 Fix libstdc++ tests for -Wvolatile warnings in C++2a mode
* testsuite/20_util/result_of/sfinae_friendly_1.cc: Add -Wno-volatile
	for C++2a and up. Define HAS_52748_FIXED and fix incorrect tests.
	* testsuite/tr1/3_function_objects/result_of.cc: Add -Wno-volatile
	for C++2a and up.

From-SVN: r275643
2019-09-11 12:38:15 +01:00