Commit Graph

11030 Commits

Author SHA1 Message Date
Jonathan Wakely 84a2f4b3a6 Qualify type names in <ext/throw_allocator.h>
* include/ext/throw_allocator.h (throw_allocator_base): Qualify
	size_t and ptrdiff_t.

From-SVN: r277337
2019-10-23 17:14:47 +01:00
Jonathan Wakely ec541f1bc1 Adjust pb_ds extensions to use allocator_traits
These changes are largely useless, because most of them are simply
allowing 'reference' and 'const_reference' types to be obtained from an
allocator, and since C++11 allocators don't define reference types (they
just use plain lvalue references. Pretending to support C++98 allocators
with user-defined reference types is a waste of time (especially as
several of the pb_ds types appear to use a static allocator object which
means stateful allocators are not supported).

	* include/ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp:
	Use detail::rebind_traits.
	* include/ext/pb_ds/detail/bin_search_tree_/node_iterators.hpp:
	Likewise.
	* include/ext/pb_ds/detail/bin_search_tree_/traits.hpp: Likewise.
	* include/ext/pb_ds/detail/binary_heap_/binary_heap_.hpp: Likewise.
	* include/ext/pb_ds/detail/binary_heap_/entry_cmp.hpp: Likewise.
	* include/ext/pb_ds/detail/binary_heap_/entry_pred.hpp: Likewise.
	* include/ext/pb_ds/detail/binary_heap_/point_const_iterator.hpp:
	Likewise.
	* include/ext/pb_ds/detail/binomial_heap_base_/binomial_heap_base_.hpp:
	Likewise.
	* include/ext/pb_ds/detail/branch_policy/branch_policy.hpp: Likewise.
	* include/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp: Likewise.
	* include/ext/pb_ds/detail/cond_dealtor.hpp: Likewise.
	* include/ext/pb_ds/detail/eq_fn/hash_eq_fn.hpp (has_eq_fn): Likewise.
	* include/ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp: Likewise.
	* include/ext/pb_ds/detail/hash_fn/ranged_hash_fn.hpp: Likewise.
	* include/ext/pb_ds/detail/hash_fn/ranged_probe_fn.hpp: Likewise.
	* include/ext/pb_ds/detail/left_child_next_sibling_heap_/
	left_child_next_sibling_heap_.hpp: Likewise.
	* include/ext/pb_ds/detail/left_child_next_sibling_heap_/node.hpp:
	Likewise.
	* include/ext/pb_ds/detail/left_child_next_sibling_heap_/
	point_const_iterator.hpp: Likewise.
	* include/ext/pb_ds/detail/list_update_map_/lu_map_.hpp: Likewise.
	* include/ext/pb_ds/detail/ov_tree_map_/
	constructors_destructor_fn_imps.hpp: Likewise.
	* include/ext/pb_ds/detail/ov_tree_map_/node_iterators.hpp: Likewise.
	* include/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp: Likewise.
	* include/ext/pb_ds/detail/pairing_heap_/pairing_heap_.hpp: Likewise.
	* include/ext/pb_ds/detail/pat_trie_/pat_trie_.hpp: Likewise.
	* include/ext/pb_ds/detail/pat_trie_/pat_trie_base.hpp: Likewise.
	* include/ext/pb_ds/detail/rb_tree_map_/node.hpp: Likewise.
	* include/ext/pb_ds/detail/rc_binomial_heap_/rc.hpp: Likewise.
	* include/ext/pb_ds/detail/splay_tree_/node.hpp: Likewise.
	* include/ext/pb_ds/detail/thin_heap_/thin_heap_.hpp: Likewise.
	* include/ext/pb_ds/detail/trie_policy/sample_trie_access_traits.hpp:
	Likewise.
	* include/ext/pb_ds/detail/type_utils.hpp: Fix typo in comment.
	* include/ext/pb_ds/detail/types_traits.hpp (stored_value): Add
	bool parameter to control whether the hash value is stored.
	(select_base_type): New class template and partial specialization.
	(maybe_null_type): Likewise.
	(rebind_traits): New class template.
	(type_base): Remove four nearly identical specializations.
	(type_dispatch): Remove.
	(type_traits): Use select_base_type and maybe_null_type instead of
	type_base to control differences between specializations.
	* include/ext/pb_ds/list_update_policy.hpp: Use detail::rebind_traits.
	* include/ext/pb_ds/priority_queue.hpp: Likewise.
	* include/ext/pb_ds/tree_policy.hpp: Likewise.
	* include/ext/pb_ds/trie_policy.hpp: Likewise.

From-SVN: r277336
2019-10-23 17:14:43 +01:00
Jonathan Wakely 603aec6775 Adjust extension types to use allocator_traits
This makes these extensions work with types meeting the Cpp17Allocator
requirements as well as the C++98 Allocator requirements.

	* include/backward/hash_set (hash_set): Use __alloc_traits.
	* include/backward/hashtable.h (_Hashtable): Likewise.
	* include/ext/alloc_traits.h (__alloc_traits::allocate): Add overload
	taking a hint.
	* include/ext/extptr_allocator.h (_ExtPtr_allocator::allocate): Ignore
	hint.
	* include/ext/slist (_Slist_base): Use __alloc_traits.
	* include/tr1/hashtable.h (_Hashtable): Likewise.
	* include/tr1/regex (match_results): Use vector::const_reference
	instead of assuming the allocator defines it.
	* testsuite/backward/hash_map/23528.cc: Use allocator_traits in C++11.
	* testsuite/tr1/6_containers/unordered_map/capacity/29134-map.cc: Use
	__gnu_test::max_size.
	* testsuite/tr1/6_containers/unordered_multimap/capacity/
	29134-multimap.cc: Likewise.
	* testsuite/tr1/6_containers/unordered_multiset/capacity/
	29134-multiset.cc: Likewise.
	* testsuite/tr1/6_containers/unordered_set/capacity/29134-set.cc:
	Likewise.

From-SVN: r277335
2019-10-23 17:14:28 +01:00
Jonathan Wakely 4190b7f17a Restore use of tr1::unordered_map in testsuite
My recent change to this file broke running the testsuite with
-std=c++98 because std::unordered_map isn't available. This fixes it.

	* testsuite/util/testsuite_abi.h: Restore use of tr1/unordered_map
	when compiled as C++98.

From-SVN: r277302
2019-10-22 22:48:57 +01:00
Jonathan Wakely 9e1f9bc544 Do not declare std::uses_allocator before C++11
* include/bits/memoryfwd.h (uses_allocator): Do not declare for C++98.
	* testsuite/17_intro/names.cc: Check uses_allocator in C++98.

From-SVN: r277301
2019-10-22 22:48:53 +01:00
Jonathan Wakely 2cae56bd61 Remove redundant std::allocator members for C++20
C++20 removes a number of std::allocator members that have correct
defaults provided by std::allocator_traits, so aren't needed.

Several extensions including __gnu_cxx::hash_map and tr1 containers are
no longer usable with std::allocator in C++20 mode. They need to be
updated to use __gnu_cxx::__alloc_traits in a follow-up patch.

	* include/bits/alloc_traits.h
	(allocator_traits<allocator<T>>::allocate): Ignore hint for C++20.
	(allocator_traits<allocator<T>>::construct): Perform placement new
	directly for C++20, instead of calling allocator<T>::construct.
	(allocator_traits<allocator<T>>::destroy): Call destructor directly
	for C++20, instead of calling allocator<T>::destroy.
	(allocator_traits<allocator<T>>::max_size): Return value directly
	for C++20, instead of calling std::allocator<T>::max_size().
	(__do_alloc_on_copy, __do_alloc_on_move, __do_alloc_on_swap): Do not
	define for C++17 and up.
	(__alloc_on_copy, __alloc_on_move, __alloc_on_swap): Use if-constexpr
	for C++17 and up, instead of tag dispatching.
	* include/bits/allocator.h (allocator<void>): Remove for C++20.
	(allocator::pointer, allocator::const_pointer, allocator::reference)
	(allocator::const_reference, allocator::rebind): Remove for C++20.
	* include/bits/basic_string.h (basic_string): Use __alloc_traits to
	rebind allocator.
	* include/bits/memoryfwd.h (allocator<void>): Remove for C++20.
	* include/ext/debug_allocator.h: Use __alloc_traits for rebinding.
	* include/ext/malloc_allocator.h (malloc_allocator::~malloc_allocator)
	(malloc_allocator::pointer, malloc_allocator::const_pointer)
	(malloc_allocator::reference, malloc_allocator::const_reference)
	(malloc_allocator::rebind, malloc_allocator::max_size)
	(malloc_allocator::construct, malloc_allocator::destroy): Do not
	define for C++20.
	(malloc_allocator::_M_max_size): Define new function.
	* include/ext/new_allocator.h (new_allocator::~new_allocator)
	(new_allocator::pointer, new_allocator::const_pointer)
	(new_allocator::reference, new_allocator::const_reference)
	(new_allocator::rebind, new_allocator::max_size)
	(new_allocator::construct, new_allocator::destroy): Do not
	define for C++20.
	(new_allocator::_M_max_size): Define new function.
	* include/ext/rc_string_base.h (__rc_string_base::_Rep): Use
	__alloc_traits to rebind allocator.
	* include/ext/rope (_Rope_rep_base, _Rope_base): Likewise.
	(rope::rope(CharT, const allocator_type&)): Use __alloc_traits
	to construct character.
	* include/ext/slist (_Slist_base): Use __alloc_traits to rebind
	allocator.
	* include/ext/sso_string_base.h (__sso_string_base::_M_max_size):
	Use __alloc_traits.
	* include/ext/throw_allocator.h (throw_allocator): Do not use optional
	members of std::allocator, use __alloc_traits members instead.
	* include/ext/vstring.h (__versa_string): Use __alloc_traits.
	* include/ext/vstring_util.h (__vstring_utility): Likewise.
	* include/std/memory: Include <bits/alloc_traits.h>.
	* testsuite/20_util/allocator/8230.cc: Use __gnu_test::max_size.
	* testsuite/20_util/allocator/rebind_c++20.cc: New test.
	* testsuite/20_util/allocator/requirements/typedefs.cc: Do not check
	for pointer, const_pointer, reference, const_reference or rebind in
	C++20.
	* testsuite/20_util/allocator/requirements/typedefs_c++20.cc: New test.
	* testsuite/23_containers/deque/capacity/29134.cc: Use
	__gnu_test::max_size.
	* testsuite/23_containers/forward_list/capacity/1.cc: Likewise.
	* testsuite/23_containers/list/capacity/29134.cc: Likewise.
	* testsuite/23_containers/map/capacity/29134.cc: Likewise.
	* testsuite/23_containers/multimap/capacity/29134.cc: Likewise.
	* testsuite/23_containers/multiset/capacity/29134.cc: Likewise.
	* testsuite/23_containers/set/capacity/29134.cc: Likewise.
	* testsuite/23_containers/vector/capacity/29134.cc: Likewise.
	* testsuite/ext/malloc_allocator/variadic_construct.cc: Do not run
	test for C++20.
	* testsuite/ext/new_allocator/variadic_construct.cc: Likewise.
	* testsuite/ext/vstring/capacity/29134.cc: Use __gnu_test::max_size.
	* testsuite/util/replacement_memory_operators.h: Do not assume
	Alloc::pointer exists.
	* testsuite/util/testsuite_allocator.h (__gnu_test::max_size): Define
	helper to call max_size for any allocator.

From-SVN: r277300
2019-10-22 22:48:39 +01:00
Andreas Schwab eefb129053 * config/abi/post/aarch64-linux-gnu/baseline_symbols.txt: Update.
From-SVN: r277285
2019-10-22 10:32:52 +00:00
Jonathan Wakely 15abd9320d PR libstdc++/92143 adjust for OS X aligned_alloc behaviour
OS X 10.15 adds aligned_alloc but it has the same restriction as the AIX
version, namely that alignments smaller than sizeof(void*) are not
supported.

	PR libstdc++/92143
	* libsupc++/new_opa.cc (operator new) [__APPLE__]: Increase alignment
	to at least sizeof(void*).

From-SVN: r277151
2019-10-18 12:27:31 +01:00
Jonathan Wakely 7e4b7d7bac Implement std::ranges::less without std::less
* include/bits/range_cmp.h (ranges::less::operator()): Inline the
	logic from std::less::operator() to remove the dependency on it.

From-SVN: r277150
2019-10-18 12:27:26 +01:00
Jonathan Wakely 1a45649501 Process new C++17 and C++20 headers with Doxygen
This won't do anything by default, because __cplusplus is set to 201402L
when Doxygen runs. If/when that changes, these headers should be
processed.

	* doc/doxygen/user.cfg.in (INPUT): Add new C++17 and C++20 headers.

From-SVN: r277121
2019-10-17 16:40:04 +01:00
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 5daedc0218 Add std::copy_n istreambuf_iterator specialization
Commit this missing part which had been rejected.

From-SVN: r276640
2019-10-06 15:53:51 +00: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
François Dumont 2d2ad752c0 Implement C++20 constexpr comparison operators for __debug::array (P1023).
* include/debug/array: Add C++20 constexpr to comparison operators.
	* testsuite/23_containers/array/tuple_interface/get_debug_neg.cc: Adapt
	dg-error line numbers.
	* testsuite/23_containers/array/tuple_interface/
	tuple_element_debug_neg.cc: Likewise.

From-SVN: r276375
2019-09-30 20:33:51 +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
Andreas Tobler ce3ecab493 libstdc++ testsuite, silence a FreeBSD libm warning
2019-09-30  Andreas Tobler  <andreast@gcc.gnu.org>

	* testsuite/ext/special_functions/airy_ai/check_nan.cc: Ignore the
	FreeBSD warning about lower advertised precision of tgammal.
	* testsuite/ext/special_functions/airy_bi/check_nan.cc: Likewise.
	* testsuite/special_functions/07_cyl_bessel_i/check_nan.cc: Likewise.
	* testsuite/special_functions/08_cyl_bessel_j/check_nan.cc: Likewise.
	* testsuite/special_functions/09_cyl_bessel_k/check_nan.cc: Likewise.
	* testsuite/special_functions/10_cyl_neumann/check_nan.cc: Likewise.
	* testsuite/special_functions/19_sph_bessel/check_nan.cc: Likewise.
	* testsuite/special_functions/21_sph_neumann/check_nan.cc: Likewise.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	08_cyl_bessel_i/check_nan.cc: Likewise.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	09_cyl_bessel_j/check_nan.cc: Likewise.
	* testuite/tr1/5_numerical_facilities/special_functions/
	10_cyl_bessel_k/check_nan.cc: Likewise.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	11_cyl_neumann/check_nan.cc: Likewise.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	21_sph_bessel/check_nan.cc: Likewise.
	* testsuite/tr1/5_numerical_facilities/special_functions/
	23_sph_neumann/check_nan.cc: Likewise.

From-SVN: r276372
2019-09-30 22:23:02 +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