Commit Graph

11064 Commits

Author SHA1 Message Date
Jonathan Wakely
081f3c3c2f Regenerate libstdc++ HTML docs
* doc/html/*: Regenerate.

From-SVN: r277699
2019-10-31 23:03:26 +00:00
Jonathan Wakely
2670a7aa8f Add remaining changes from P1065R2 "constexpr INVOKE"
* include/bits/refwrap.h (reference_wrapper, ref, cref): Add constexpr
	specifiers for C++20.
	* include/std/functional (_Mem_fn, mem_fn, _Bind, _Bind_result, bind)
	(bind_front, _Not_fn, not_fn): Likewise.
	* testsuite/20_util/bind/constexpr.cc: New test.
	* testsuite/20_util/function_objects/bind_front/constexpr.cc: New test.
	* testsuite/20_util/function_objects/mem_fn/constexpr.cc: New test.
	* testsuite/20_util/function_objects/not_fn/constexpr.cc: New test.
	* testsuite/20_util/reference_wrapper/constexpr.cc: New test.

From-SVN: r277698
2019-10-31 23:03:22 +00:00
Jonathan Wakely
328b52d675 Partial implementation of C++20 of <ranges> header
* doc/doxygen/user.cfg.in: Add new header.
	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/precompiled/stdc++.h: Include new header.
	* include/std/ranges: New header.
	(ranges::sentinel_t, ranges::range_value_t, ranges::range_reference_t)
	(ranges::range_rvalue_reference_t, ranges::sized_range)
	(ranges::output_range, ranges::input_ranges, ranges::forward_range)
	(ranges::bidirectional_range, ranges::random_access_range)
	(ranges::contiguous_range, ranges::common::range): Define.
	* testsuite/24_iterators/headers/iterator/synopsis_c++20.cc: Check
	that disabled_sized_sentinel can be specialized.
	* testsuite/std/ranges/access/begin.cc: Include <ranges> instead of
	<iterator>.
	* testsuite/std/ranges/access/cbegin.cc: Likewise.
	* testsuite/std/ranges/access/cdata.cc: Likewise.
	* testsuite/std/ranges/access/cend.cc: Likewise.
	* testsuite/std/ranges/access/crbegin.cc: Likewise.
	* testsuite/std/ranges/access/crend.cc: Likewise.
	* testsuite/std/ranges/access/data.cc: Likewise.
	* testsuite/std/ranges/access/empty.cc: Likewise.
	* testsuite/std/ranges/access/end.cc: Likewise.
	* testsuite/std/ranges/access/end_neg.cc: Likewise.
	* testsuite/std/ranges/access/rbegin.cc: Likewise.
	* testsuite/std/ranges/access/rend.cc: Likewise.
	* testsuite/std/ranges/access/size.cc: Likewise.
	* testsuite/std/ranges/access/size_neg.cc: Likewise.
	* testsuite/std/ranges/headers/ranges/synopsis.cc: New test.
	* testsuite/std/ranges/range.cc: New test.
	* testsuite/std/ranges/refinements.cc: New test.
	* testsuite/std/ranges/sized.cc: New test.
	* testsuite/util/testsuite_iterators.h: Add aliases for range types.
	(output_iterator_wrapper::WritableObject::operator=): Add const
	qualifier so that output_iterator_wrapper satisfies writable.

From-SVN: r277697
2019-10-31 21:42:18 +00:00
Jonathan Wakely
b9ff4d7c48 Improve tests for std::add_pointer
The type trait depends on is_void so the tests should check those cases.

	* testsuite/20_util/add_pointer/value.cc: Check void types.

From-SVN: r277672
2019-10-31 14:07:11 +00:00
Jonathan Wakely
b3ffa117e5 Remove PR 92268 workaround and fix new test failures
With the compiler bug fixed we can simplify the __sizable concept to use
a return-type-requirement again. I also realised it was redundantly
re-checking a subset of the sized_sentinel_for requirements.

The compiler fix also revealed bugs in two tests which started to fail
and are fixed by this patch.

	* include/bits/range_access.h (__sizable): Rename to __sentinel_size.
	Remove workaround for PR c++/92268 and remove redundant requirements
	that are already checked by sized_sentinel_for.
	* testsuite/std/ranges/access/cend.cc: Fix failures.
	* testsuite/std/ranges/access/end.cc: Likewise.

From-SVN: r277667
2019-10-31 13:17:48 +00:00
Jonathan Wakely
beaecb2d6b Fix handling of arrays in range access customization points
This combines the overloads for arrays with the non-array overloads,
using if-constexpr to choose between the cases, and also enforces the
following:

- ADL should only be used for class types and enumeration types.
- ranges::begin should be ill-formed for rvalue arrays.
- ranges::end should be ill-formed for rvalue arrays, unbounded
  arrays, and arrays of incomplete type.
- ranges::size should be ill-formed for unbounded arrays.

	* include/bits/range_access.h (ranges::begin): Combine array and
	non-array overloads into one function template. Only use ADL for
	classes and enums
	(ranges::end, ranges::size): Likewise. Make unbounded arrays
	ill-formed.
	(ranges::rbegin, ranges::rend): Only use ADL for classes and enums.
	Reformat _S_noexcept() functions to mirror operator() structure.
	* testsuite/std/ranges/access/begin.cc: Check incomplete array.
	* testsuite/std/ranges/access/end_neg.cc: New test.
	* testsuite/std/ranges/access/size.cc: Check array of incomplete type.
	* testsuite/std/ranges/access/size_neg.cc: New test.

From-SVN: r277666
2019-10-31 13:17:42 +00:00
Jonathan Wakely
164abd6786 Check precondition for std::ssize(const Container&)
This precondition is the subject of a national body comment on the C++20
CD. This just adds a test to ensure we enforce the precondition.

Also move existing 24_iterator/range_access*.cc tests to a dedicated
directory for the [iterator.range] subclause.

	* testsuite/24_iterators/range_access*.cc: Move to ...
	* testsuite/24_iterators/range_access/range_access*.cc: ... here.
	* testsuite/24_iterators/range_access/range_access_cpp20_neg.cc: New
	test.

From-SVN: r277658
2019-10-31 09:39:48 +00:00
Jonathan Wakely
ce001b300f Use if-constexpr instead of overloading for customization point
This combines two of the std::ranges::swap.operator() overloads into a
single function template. Using if-constexpr to choose between
implementations should give the compiler less work to do than using
overloading.

	* include/std/concepts (std::ranges::swap): Use a single overload for
	the non-array cases, and switch using if-constexpr.

From-SVN: r277635
2019-10-30 17:42:04 +00:00
Jonathan Wakely
411679568b Fix another compilation error with Clang
* include/bits/stl_iterator.h (__normal_iterator::iterator_concept):
	Guard with __cpp_lib_concepts macro.

From-SVN: r277634
2019-10-30 16:57:19 +00:00
Jonathan Wakely
0d58d88db6 Fix some missing/incorrect feature test macros
* include/std/bit (__cpp_lib_bitops): Define.
	* include/std/version (__cpp_lib_constexpr): Remove.
	(__cpp_lib_bitops, __cpp_lib_constexpr_dynamic_alloc): Define.
	* testsuite/26_numerics/bit/header.cc: New test.
	* testsuite/26_numerics/bit/header-2.cc: New test.
	* testsuite/20_util/allocator_traits/header.cc: New test.
	* testsuite/20_util/allocator_traits/header-2.cc: New test.

From-SVN: r277633
2019-10-30 16:57:13 +00:00
Jonathan Wakely
d03eca30d7 Remove some more using-declarations from namespace __gnu_cxx
Similar to some recent patches, this removes using-declarations for
names from namespace std, so that they are not redeclared in __gnu_cxx.

	* include/bits/stl_iterator.h (namespace __gnu_cxx): Remove
	using-declarations for std::iterator and std::iterator_traits.
	(__gnu_cxx::__normal_iterator): Qualify iterator_traits.
	* include/ext/algorithm (namespace __gnu_cxx): Remove
	using-declarations for std names and qualify those names when used.
	Also refer to std::min in parentheses to protect against function-like
	macros.
	* include/ext/rc_string_base.h: Qualify iterator_traits.
	* include/ext/sso_string_base.h: Qualify iterator_traits.

From-SVN: r277630
2019-10-30 15:48:23 +00:00
Jonathan Wakely
9aeb3bef2c Apply C++20 changes to various iterator types
This ensures that __normal_iterator<T*, C> satisfies the
contiguous_iterator concept, by defining the iterator_concept member
type.

Also update vector<bool>'s iterators, reverse_iterator,
istreambuf_iterator and ostreambuf_iterator to meet the C++20
requirements.

	PR libstdc++/92272
	* include/bits/stl_bvector.h (_Bit_iterator::pointer)
	(_Bit_const_iterator::pointer): Define as void for C++20.
	* include/bits/stl_iterator.h (reverse_iterator::operator->()): Add
	constraints for C++20.
	(__normal_iterator::iterator_concept): Define for C++20.
	* include/bits/streambuf_iterator.h (istreambuf_iterator::pointer):
	Define as void for C++20.
	(ostreambuf_iterator::difference_type): Define as ptrdiff_t for C++20.
	(ostreambuf_iterator::ostreambuf_iterator()): Add default constructor
	for C++20.
	* testsuite/23_containers/vector/bool/iterator_c++20.cc: New test.
	* testsuite/24_iterators/bidirectional/concept.cc: New test.
	* testsuite/24_iterators/bidirectional/tag.cc: New test.
	* testsuite/24_iterators/contiguous/concept.cc: New test.
	* testsuite/24_iterators/contiguous/tag.cc: New test.
	* testsuite/24_iterators/forward/concept.cc: New test.
	* testsuite/24_iterators/forward/tag.cc: New test.
	* testsuite/24_iterators/input/concept.cc: New test.
	* testsuite/24_iterators/input/tag.cc: New test.
	* testsuite/24_iterators/istreambuf_iterator/requirements/typedefs.cc:
	New test.
	* testsuite/24_iterators/ostreambuf_iterator/requirements/typedefs.cc:
	New test.
	* testsuite/24_iterators/output/concept.cc: New test.
	* testsuite/24_iterators/output/tag.cc: New test.
	* testsuite/24_iterators/random_access/concept.cc: New test.
	* testsuite/24_iterators/random_access/tag.cc: New test.
	* testsuite/24_iterators/range_operations/advance_debug_neg.cc: New
	test.
	* testsuite/24_iterators/random_access_iterator/26020.cc: Move to ...
	* testsuite/24_iterators/operations/26020.cc: ... here.
	* testsuite/24_iterators/random_access_iterator/
	string_vector_iterators.cc: Move to ...
	* testsuite/24_iterators/random_access/string_vector_iterators.cc: ...
	here.

From-SVN: r277629
2019-10-30 15:48:11 +00:00
Jonathan Wakely
5211593c58 Fix typo in preprocessor check
* testsuite/util/testsuite_iterators.h: Fix typo in __cplusplus check.

From-SVN: r277628
2019-10-30 15:47:39 +00:00
Jonathan Wakely
6cd96bad60 Fix compilation errors with Clang
* include/bits/range_access.h (ranges::disable_sized_range)
	(ranges::begin, ranges::end, ranges::cbegin, ranges::cend)
	(ranges::rbegin, ranges::rend, ranges::crbegin, ranges::crend)
	(ranges::size, ranges::empty, ranges::data, ranges::cdata)
	(ranges::range, ranges::sized_range, ranges::advance, ranges::distance)
	(ranges::next, ranges::prev): Guard with __cpp_lib_concepts.
	* include/bits/stl_iterator.h (disable_sized_sentinel): Likewise.

From-SVN: r277589
2019-10-29 20:17:02 +00:00
Jonathan Wakely
540218dd24 Fix compilation errors with Clang
* include/bits/alloc_traits.h (__cpp_lib_constexpr_dynamic_alloc):
	Define.
	(allocator_traits::_S_construct, allocator_traits::_S_destroy)
	(__alloc_on_copy, __alloc_on_move, __alloc_on_swap): Use
	_GLIBCXX14_CONSTEXPR instead of constexpr.
	* include/bits/stl_construct.h (_Destroy): Likewise.

From-SVN: r277588
2019-10-29 20:16:57 +00:00
Jonathan Wakely
6d0dff49ca Add iterator concepts and range access customization points for C++20
This adds most of the new C++20 features to <iterator>, as well as a few
initial pieces of <ranges> (but no actual <ranges> header just yet).

	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/bits/iterator_concepts.h: New header.
	(contiguous_iterator_tag, iter_reference_t, ranges::iter_move)
	(iter_rvalue_reference_t, incrementable_traits, iter_difference_t)
	(readable_traits, iter_value_t, readable, iter_common_reference_t)
	(writable, waekly_incrementable, incrementable)
	(input_or_output_iterator, sentinel_for, disable_sized_sentinel)
	(sized_sentinel_for, input_iterator, output_iterator)
	(forward_iterator, bidirectional_iterator, random_access_iterator)
	(contiguous_iterator, indirectly_unary_invocable)
	(indirectly_regular_unary_invocable, indirect_unary_predicate)
	(indirect_relation, indirect_strict_weak_order, indirect_result_t)
	(projected, indirectly_movable, indirectly_movable_storable)
	(indirectly_copyable, indirectly_copyable_storable, ranges::iter_swap)
	(indirectly_swappable, indirectly_comparable, permutable, mergeable)
	(sortable, unreachable_sentinel_t, unreachable_sentinel)
	(default_sentinel_t, default_sentinel): Define.
	(__detail::__cpp17_iterator, __detail::__cpp17_input_iterator)
	(__detail::__cpp17_fwd_iterator, __detail::__cpp17_bidi_iterator)
	(__detail::__cpp17_randacc_iterator): Define.
	(__iterator_traits): Define constrained specializations.
	* include/bits/move.h (move): Only use old concept check for C++98.
	* include/bits/range_access.h (ranges::disable_sized_range)
	(ranges::begin, ranges::end, ranges::cbegin, ranges::cend)
	(ranges::rbegin, ranges::rend, ranges::crbegin, ranges::crend)
	(ranges::size, ranges::empty, ranges::data, ranges::cdata): Define
	new customization points for C++20.
	(ranges::range, ranges::sized_range): Define new concepts for C++20.
	(ranges::advance, ranges::distance, ranges::next, ranges::prev):
	Define new functions for C++20.
	(__adl_end, __adl_cdata, __adl_cbegin, __adl_cend, __adl_rbegin)
	(__adl_rend, __adl_crbegin, __adl_crend, __adl_cdata, __adl_size)
	(__adl_empty): Remove.
	* include/bits/stl_iterator.h (disable_sized_sentinel): Specialize
	for reverse_iterator.
	* include/bits/stl_iterator_base_types.h (contiguous_iterator_tag):
	Define new struct for C++20.
	(iterator_traits<_Tp*>): Constrain partial specialization in C++20.
	* include/std/concepts (__is_class_or_enum): Move to __detail
	namespace.
	* testsuite/20_util/forward/c_neg.cc: Adjust dg-error line number.
	* testsuite/20_util/forward/f_neg.cc: Likewise.
	* testsuite/24_iterators/associated_types/incrementable.traits.cc: New
	test.
	* testsuite/24_iterators/associated_types/readable.traits.cc: New test.
	* testsuite/24_iterators/contiguous/concept.cc: New test.
	* testsuite/24_iterators/contiguous/tag.cc: New test.
	* testsuite/24_iterators/customization_points/iter_move.cc: New test.
	* testsuite/24_iterators/customization_points/iter_swap.cc: New test.
	* testsuite/24_iterators/headers/iterator/synopsis_c++20.cc: New test.
	* testsuite/24_iterators/range_operations/advance.cc: New test.
	* testsuite/24_iterators/range_operations/distance.cc: New test.
	* testsuite/24_iterators/range_operations/next.cc: New test.
	* testsuite/24_iterators/range_operations/prev.cc: New test.
	* testsuite/26_numerics/adjacent_difference/requirements/
	explicit_instantiation/2.cc: Rename types that conflict with C++20
	concepts.
	* testsuite/26_numerics/adjacent_difference/requirements/
	explicit_instantiation/pod.cc: Likewise.
	* testsuite/26_numerics/partial_sum/requirements/
	explicit_instantiation/2.cc: Likewise.
	* testsuite/26_numerics/partial_sum/requirements/
	explicit_instantiation/pod.cc: Likewise.
	* testsuite/experimental/iterator/requirements.cc: Likewise.
	* testsuite/std/ranges/access/begin.cc: New test.
	* testsuite/std/ranges/access/cbegin.cc: New test.
	* testsuite/std/ranges/access/cdata.cc: New test.
	* testsuite/std/ranges/access/cend.cc: New test.
	* testsuite/std/ranges/access/crbegin.cc: New test.
	* testsuite/std/ranges/access/crend.cc: New test.
	* testsuite/std/ranges/access/data.cc: New test.
	* testsuite/std/ranges/access/empty.cc: New test.
	* testsuite/std/ranges/access/end.cc: New test.
	* testsuite/std/ranges/access/rbegin.cc: New test.
	* testsuite/std/ranges/access/rend.cc: New test.
	* testsuite/std/ranges/access/size.cc: New test.
	* testsuite/util/testsuite_iterators.h (contiguous_iterator_wrapper)
	(test_range, test_sized_range): New test utilities.

From-SVN: r277579
2019-10-29 17:44:18 +00:00
Jonathan Wakely
9921ac3db3 Minor improvements to testsuite iterator utilities
* testsuite/util/testsuite_iterators.h (BoundsContainer::size()): Add
	new member function.
	(WritableObject::operator=): Constrain with enable_if when available.
	(remove_cv): Use std::remove_if when available.
	(test_container::it(int)): Use size().
	(test_container::size()): Use BoundsContainer::size().

From-SVN: r277578
2019-10-29 17:15:04 +00:00
Jonathan Wakely
0ed4d40833 PR libstdc++/92267 fix ABI change in deque iterators
Defaulting the copy constructor on its first declaration made it change
from user-provided (and non-trivial) to implicitly-defined (and
trivial). This caused an ABI incompatibility between GCC 8 and GCC 9,
where functions taking a deque iterator disagree on the argument passing
convention.

	PR libstdc++/92267
	* include/bits/stl_deque.h (_Deque_iterator(const _Deque_iterator&)):
	Do not define as defaulted.
	* testsuite/23_containers/deque/types/92267.cc: New test.

From-SVN: r277577
2019-10-29 17:14:55 +00:00
Gerald Pfeifer
c61f8150f0 codecvt.xml: Switch pubs.opengroup.org to https.
* doc/xml/manual/codecvt.xml: Switch pubs.opengroup.org to https.
	* doc/xml/manual/locale.xml (LC_ALL): Ditto.
	* doc/xml/manual/messages.xml: Ditto.

From-SVN: r277476
2019-10-26 21:57:56 +00:00
John David Anglin
65ab2a54a4 baseline_symbols.txt: Update.
* config/abi/post/hppa-linux-gnu/baseline_symbols.txt: Update.

From-SVN: r277475
2019-10-26 20:12:20 +00:00
Jonathan Wakely
0a70fb8750 Use implicitly-defined copy operations for test iterators
All of these special member functions do exactly what the compiler would
do anyway. By defining them as defaulted for C++11 and later we prevent
move constructors and move assignment operators being defined (which is
consistent with the previous semantics).

Also move default init of the input_iterator_wrapper members from the
derived constructor to the protected base constructor.

	* testsuite/util/testsuite_iterators.h (output_iterator_wrapper)
	(input_iterator_wrapper, forward_iterator_wrapper)
	bidirectional_iterator_wrapper, random_access_iterator_wrapper): Remove
	user-provided copy constructors and copy assignment operators so they
	are defined implicitly.
	(input_iterator_wrapper): Initialize members in default constructor.
	(forward_iterator_wrapper): Remove assignments to members of base.

From-SVN: r277459
2019-10-25 18:02:43 +01:00
Jonathan Wakely
eadcde8e8f Fix compilation with Clang
The new constexpr destructor on std::allocator breaks compilation with
Clang in C++2a mode. This only makes it constexpr if the compiler
supports the P0784R7 features.

	* include/bits/allocator.h: Check __cpp_constexpr_dynamic_alloc
	before making the std::allocator destructor constexpr.
	* testsuite/20_util/allocator/requirements/constexpr.cc: New test.

From-SVN: r277458
2019-10-25 18:02:35 +01:00
Jonathan Wakely
f4568f030e Guard use of concepts with feature test macro
This fixes a regression when using Clang.

	* include/bits/range_cmp.h: Check __cpp_lib_concepts before defining
	concepts. Fix comment.

From-SVN: r277449
2019-10-25 14:29:37 +01:00
Gerald Pfeifer
a0f9baa295 policy_data_structures_biblio.xml: Switch pubs.opengroup.org to https.
* doc/xml/manual/policy_data_structures_biblio.xml: Switch
	pubs.opengroup.org to https.

From-SVN: r277436
2019-10-25 05:37:34 +00:00
Gerald Pfeifer
19dc1c310f * doc/xml/gnu/gpl-3.0.xml: Switch www.gnu.org to https.
From-SVN: r277435
2019-10-25 05:19:50 +00:00
Edward Smith-Rowland
d57ebc3415 status_cxx2020.xml: Add rows and update status.
2019-09-09  Edward Smith-Rowland  <3dw4rd@verizon.net>

	* doc/xml/manual/status_cxx2020.xml: Add rows and update status.

From-SVN: r277434
2019-10-25 01:44:10 +00:00
Jonathan Wakely
75c6a925da Revert ABI changes to std::allocator in C++20
The recent C++20 changes to remove the std::allocator<void> explicit
specialization and the destructor in the std::allocator primary template
change the result of some is_trivially_xxx type traits. To avoid those
changes, this patch restores the explicit specialization and the
destructor.

In order to meet the C++20 requirements the std::allocator<void>
explicit specialization must provide the same interface as the primary
template (except for the unusable allocate and deallocate member
functions) and the destructor in the primary template must be constexpr.

	* include/bits/allocator.h (allocator<void>): Restore the explicit
	specialization for C++20, but make its API consistent with the primary
	template.
	(allocator::~allocator()): Restore the destructor for C++20, but make
	it constexpr.
	* testsuite/20_util/allocator/rebind_c++20.cc: Check allocator<void>.
	* testsuite/20_util/allocator/requirements/typedefs_c++20.cc: Likewise.
	* testsuite/20_util/allocator/void.cc: Check that constructors and
	destructors are trivial. Check for converting constructor in C++20.
	* testsuite/ext/malloc_allocator/variadic_construct.cc: Simplify
	dejagnu target selector.
	* testsuite/ext/new_allocator/variadic_construct.cc: Likewise.

From-SVN: r277410
2019-10-24 16:29:41 +01:00
Jonathan Wakely
5ce55f3ff5 Simplify common case of use_future_t that uses std::allocator
There is no need to store and pass around the allocator object when it's
an instance of std::allocator. Define a partial specialization of
std::use_future_t and the corresponding completion token so that no
allocator is stored. Overload the completion handler constructor to not
expect an allocator to be stored.

	* include/experimental/executor (__use_future_ct, use_future_t):
	Define partial specializations for std::allocator.
	(__use_future_ch): Overload constructor for completion tokens using
	std::allocator.

From-SVN: r277404
2019-10-24 15:39:57 +01:00
Jonathan Wakely
02819d3919 PR libstdc++/88338 Implement P0898R3, C++20 concepts library
The implementation is already complete but this updates the docs and
adds tests for the feature test macro.

	* doc/xml/manual/status_cxx2020.xml: Update status.
	* doc/html/*: Regenerate.
	* testsuite/std/concepts/1.cc: New test.
	* testsuite/std/concepts/2.cc: New test.

From-SVN: r277371
2019-10-24 10:47:25 +01:00
Jonathan Wakely
bbf0495dd2 Define std::uniform_random_bit_generator concept for C++20
* include/bits/random.h (uniform_random_bit_generator): Define for
	C++20.
	* testsuite/26_numerics/random/concept.cc: New test.
	* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error line.

From-SVN: r277369
2019-10-24 10:35:07 +01:00
Jonathan Wakely
6d188e4fdd Make std::invoke usable in constant expressions
* include/std/functional (invoke): Add constexpr for C++20.
	* include/std/version (__cpp_lib_constexpr_invoke): Define.
	* testsuite/20_util/function_objects/invoke/constexpr.cc: New test.

From-SVN: r277343
2019-10-23 18:42:16 +01:00
Jonathan Wakely
85f2411493 PR c++/91369 Implement P0784R7 changes to allocation and construction
This patch is the first part of library support for constexpr
std::vector and std::string. This only includes the changes to
std::allocator, std::allocator_traits, std::construct_at,
std::destroy_at, std::destroy and std::destroy_n.

std::allocator::allocate and std::allocator::deallocate need to be
added so that they can be intercepted by the compiler during constant
evaluation. Outside of constant evaluation those new member functions
just forward to the existing implementation in the base class.

	PR c++/91369 Implement P0784R7 changes to allocation and construction
	* include/bits/alloc_traits.h: Include <bits/stl_construct.h>.
	(allocator_traits::_S_allocate, allocator_traits::_S_construct)
	(allocator_traits::_S_destroy, allocator_traits::_S_max_size)
	(allocator_traits::_S_select, allocator_traits::allocate)
	(allocator_traits::deallocate, allocator_traits::construct)
	(allocator_traits::destroy, allocator_traits::max_size)
	(allocator_traits::select_on_container_copy_construction)
	(allocator_traits<allocator<T>>): Add constexpr specifier for C++20.
	(allocator_traits<allocator<T>>::construct): Use construct_at.
	(allocator_traits<allocator<T>>::destroy): Use destroy_at.
	(__alloc_on_copy, __alloc_on_move, __alloc_on_swap): Add constexpr
	specifier.
	(_Destroy(ForwardIterator, ForwardIterator, Alloc&))
	(_Destroy(ForwardIterator, ForwardIterator, allocator<T>&)): Move here
	from <bits/stl_construct.h>.
	* include/bits/allocator.h (allocator::~allocator): Remove for C++20.
	(allocator::allocate, allocate::deallocate): Define for C++20 and up.
	(operator==, operator!=): Add constexpr specifier for C++20.
	* include/bits/stl_construct.h: Don't include <ext/alloc_traits.h>.
	(destroy_at): For C++20 add constexpr specifier and support for
	destroying arrays.
	(construct_at): Define new function for C++20.
	(_Construct): Return result of placement new-expression. For C++11 and
	up add constexpr. For C++20 dispatch to std::construct_at during
	constant evaluation.
	(_Destroy(pointer)): Add constexpr specifier. For C++20 dispatch to
	std::destroy_at during constant evaluation.
	(_Destroy_aux::__destroy, _Destroy_n_aux::__destroy_n): Add constexpr
	specifier for C++20.
	(_Destroy(ForwardIterator, ForwardIterator))
	(_Destroy(ForwardIterator, Size)): Likewise. Do not elide trivial
	destructors during constant evaluation.
	(destroy, destroy_n): Add constexpr specifier for C++20.
	(_Destroy(ForwardIterator, ForwardIterator, Alloc&))
	(_Destroy(ForwardIterator, ForwardIterator, allocator<T>&)): Move to
	<bits/alloc_traits.h>, to remove dependency on allocators.
	* include/bits/stl_uninitialized.h: Include <ext/alloc_traits.h>.
	Include <bits/stl_pair.h> instead of <utility>.
	* include/ext/alloc_traits.h: Always include <bits/alloc_traits.h>.
	(__alloc_traits::construct, __alloc_traits::destroy)
	(__alloc_traits::_S_select_on_copy, __alloc_traits::_S_on_swap): Add
	constexpr specifier.
	* include/ext/malloc_allocator.h  (operator==, operator!=): Add
	constexpr specifier for C++20.
	* include/ext/new_allocator.h (operator==, operator!=): Likewise.
	* testsuite/20_util/headers/memory/synopsis.cc: Add constexpr.
	* testsuite/20_util/scoped_allocator/69293_neg.cc: Ignore additional
	errors due to constexpr function called after failed static_assert.
	* testsuite/20_util/specialized_algorithms/construct_at/1.cc: New test.
	* testsuite/23_containers/vector/cons/destructible_debug_neg.cc:
	Ignore additional errors due to constexpr function called after failed
	static_assert.
	* testsuite/23_containers/vector/cons/destructible_neg.cc: Likewise.

From-SVN: r277342
2019-10-23 18:42:11 +01:00
Jonathan Wakely
161c3bf9ee Replace C++14 feature used in C++11 test
* testsuite/20_util/bind/91371.cc: Fix test to compile as C++11.

From-SVN: r277339
2019-10-23 17:14:54 +01:00
Jonathan Wakely
30a761c4b5 Only qualify function as constexpr for C++14 and later
This helper function is not a valid constexpr function in C++11, so
should only be marked constexpr for C++14 and later.

	* include/debug/helper_functions.h (__valid_range): Change
	_GLIBCXX_CONSTEXPR to _GLIBCXX14_CONSTEXPR.

From-SVN: r277338
2019-10-23 17:14:50 +01:00
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