Commit Graph

358 Commits

Author SHA1 Message Date
Jonathan Wakely afcbeb35e0 libstdc++: Fix unused variable warning
libstdc++-v3/ChangeLog:

	* testsuite/util/testsuite_performance.h (report_header): Remove
	unused variable.
2020-10-09 11:53:08 +01:00
Jonathan Wakely 1352ea1925 libstdc++: Inline std::exception_ptr members [PR 90295]
This inlines most members of std::exception_ptr so that all operations
on a null exception_ptr can be optimized away. This benefits code like
std::future and coroutines where an exception_ptr object is present to
cope with exceptional cases, but is usually not used and remains null.

Since those functions were previously non-inline we have to continue to
export them from the library, for objects that were compiled against the
old headers and expect to find definitions in the library.

In order to inline the copy constructor and destructor we need to export
the _M_addref() and _M_release() members that increment/decrement the
reference count when copying/destroying a non-null exception_ptr. The
copy ctor and dtor check for null and don't call _M_addref and
_M_release unless they need to. The checks for null pointers in
_M_addref and _M_release are still needed because old code might call
them without checking for null first. But we can use __builtin_expect to
predict that they are usually called for the non-null case.

libstdc++-v3/ChangeLog:

	PR libstdc++/90295
	* config/abi/pre/gnu.ver (CXXABI_1.3.13): New symbol version.
	(exception_ptr::_M_addref(), exception_ptr::_M_release()):
	Export symbols.
	* libsupc++/eh_ptr.cc (exception_ptr::exception_ptr()):
	Remove out-of-line definition.
	(exception_ptr::exception_ptr(const exception_ptr&)):
	Likewise.
	(exception_ptr::~exception_ptr()): Likewise.
	(exception_ptr::operator=(const exception_ptr&)):
	Likewise.
	(exception_ptr::swap(exception_ptr&)): Likewise.
	(exception_ptr::_M_addref()): Add branch prediction.
	* libsupc++/exception_ptr.h (exception_ptr::operator bool):
	Add noexcept.
	[!_GLIBCXX_EH_PTR_COMPAT] (operator==, operator!=): Define
	inline as hidden friends. Remove declarations at namespace
	scope.
	(exception_ptr::exception_ptr()): Define inline.
	(exception_ptr::exception_ptr(const exception_ptr&)):
	Likewise.
	(exception_ptr::~exception_ptr()): Likewise.
	(exception_ptr::operator=(const exception_ptr&)):
	Likewise.
	(exception_ptr::swap(exception_ptr&)): Likewise.
	* testsuite/util/testsuite_abi.cc: Add CXXABI_1.3.13.
	* testsuite/18_support/exception_ptr/90295.cc: New test.
2020-10-06 17:24:16 +01:00
Jonathan Wakely 4c27c6584d libstdc++: Make testsuite usable with -fno-exceptions
Previously it was not possible to add -fno-exceptions to the testsuite
flags, because some files that are compiled by the v3-build_support
procedure failed with exceptions disabled.

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

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

libstdc++-v3/ChangeLog:

	* testsuite/23_containers/vector/bool/72847.cc: Use the
	exceptions_enabled effective-target keyword instead of
	checking for an explicit -fno-exceptions option.
	* testsuite/util/testsuite_abi.cc (examine_symbol): Remove
	redundant try-catch.
	* testsuite/util/testsuite_allocator.h [!__cpp_exceptions]:
	Do not define check_allocate_max_size and memory_resource.
	* testsuite/util/testsuite_containers.h: Replace comment with
	#error if wrong standard dialect used.
	* testsuite/util/testsuite_shared.cc: Likewise.
2020-07-30 12:50:02 +01:00
Jonathan Wakely 932fbc868a libstdc++: Add std::from_chars for floating-point types
This adds the missing std::from_chars overloads for floating-point
types, as required for C++17 conformance.

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

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

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

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

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

libstdc++-v3/ChangeLog:

	* acinclude.m4 (libtool_VERSION): Bump version.
	* config.h.in: Regenerate.
	* config/abi/pre/gnu.ver: Add GLIBCXX_3.4.29 version and new
	exports.
	* config/os/gnu-linux/ldbl-extra.ver: Add _GLIBCXX_LDBL_3.4.29
	version and new export.
	* configure: Regenerate.
	* configure.ac: Check for <xlocale.h> and uselocale.
	* crossconfig.m4: Add macro or checks for uselocale.
	* include/std/charconv (from_chars): Declare overloads for
	float, double, and long double.
	* src/c++17/Makefile.am: Add new file.
	* src/c++17/Makefile.in: Regenerate.
	* src/c++17/floating_from_chars.cc: New file.
	(from_chars): Define for float, double, and long double.
	* testsuite/20_util/from_chars/1_c++20_neg.cc: Prune extra
	diagnostics caused by new overloads.
	* testsuite/20_util/from_chars/1_neg.cc: Likewise.
	* testsuite/20_util/from_chars/2.cc: Check leading '+'.
	* testsuite/20_util/from_chars/4.cc: New test.
	* testsuite/20_util/from_chars/5.cc: New test.
	* testsuite/util/testsuite_abi.cc: Add new symbol versions.
2020-07-20 23:49:27 +01:00
Ville Voutilainen 24b54628cf PR libstdc++/95915
PR libstdc++/95915
	* include/std/type_traits (is_literal_type, is_literal_type_v):
	Deprecate in C++17.
	* include/std/variant (_Uninitialized):
	Adjust the condition and the comment.
	* testsuite/20_util/is_literal_type/deprecated-1z.cc: New.
	* testsuite/20_util/is_literal_type/requirements/explicit_instantiation.cc:
	Adjust.
	* testsuite/20_util/is_literal_type/requirements/typedefs.cc: Likewise.
	* testsuite/20_util/is_literal_type/value.cc: Likewise.
	* testsuite/20_util/optional/constexpr/nullopt.cc:
	Use __is_literal_type directly.
	* testsuite/20_util/optional/nullopt.cc: Likewise.
	* testsuite/20_util/variable_templates_for_traits.cc: Adjust.
	* testsuite/20_util/variant/95915.cc: New.
	* testsuite/20_util/variant/compile.cc: Add new test.
	* testsuite/experimental/optional/constexpr/nullopt.cc:
	Use __is_literal_type directly.
	* testsuite/experimental/optional/nullopt.cc: Likewise.
	* testsuite/experimental/type_traits/value.cc: Adjust.
	* testsuite/util/testsuite_common_types.h:
	Use __is_literal_type directly.
2020-06-29 00:36:38 +03:00
Jonathan Wakely e1008cd1d8 libstdc++: Make std::copy_n work with negative and non-integral sizes
Since it was added in C++11, std::copy_n and std::ranges::copy_n should
do nothing given a negative size, but for random access iterators we add
the size to the iterator, possibly resulting in undefined behaviour.

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

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

libstdc++-v3/ChangeLog:

	* include/bits/ranges_algobase.h (__copy_n_fn): Only call
	ranges::copy for positive values.
	* include/bits/stl_algo.h (copy_n): Convert Size argument to an
	integral type and only call __copy_n for positive values.
	* testsuite/util/testsuite_iterators.h
	(random_access_iterator_wrapper::operator+=): Fix range check for
	negative values.
	(output_container, input_container, forward_container)
	(bidirectional_container, random_access_container): New alias
	templates.
	* testsuite/25_algorithms/copy_n/5.cc: New test.
2020-06-04 14:21:34 +01:00
Jonathan Wakely 118158b646 libstdc++: Fix __gnu_test::input_iterator_wrapper::operator++(int)
I noticed recently that our input_iterator_wrapper utility for writing
tests has the following post-increment operator:

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

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

	* testsuite/util/testsuite_iterators.h:
	(input_iterator_wrapper::operator++(int)): Return proxy object.
2020-06-01 18:30:47 +01:00
Jonathan Wakely c996029406 libstdc++: Fix testsuite utility's use of allocators
In C++20 the rebind and const_reference members of std::allocator are
gone, so this testsuite utility stopped working, causing
ext/pb_ds/regression/priority_queue_rand_debug.cc to FAIL.

	* testsuite/util/native_type/native_priority_queue.hpp: Use
	allocator_traits to rebind allocator.
2020-04-18 00:12:26 +01:00
Jonathan Wakely bf1fc37bb4 libstdc++: Define and use chrono::is_clock for C++20
For C++20 the wait_until members of mutexes and condition variables are
required to be ill-formed if given a clock that doesn't meet the
requirements for a clock type. To implement that requirement this patch
adds static assertions using the chrono::is_clock trait, and defines
that trait.

To avoid expensive checks for the common cases, the trait (and
associated variable template) are explicitly specialized for the
standard clock types.

This also moves the filesystem::__file_clock type from <filesystem> to
<chrono>, so that chrono::file_clock and chrono::file_time can be
defined in <chrono> as required.

	* include/bits/fs_fwd.h (filesystem::__file_clock): Move to ...
	* include/std/chrono (filesystem::__file_clock): Here.
	(filesystem::__file_clock::from_sys, filesystem::__file_clock::to_sys):
	Define public member functions for C++20.
	(is_clock, is_clock_v): Define traits for C++20.
	* include/std/condition_variable (condition_variable::wait_until): Add
	check for valid clock.
	* include/std/future (_State_baseV2::wait_until): Likewise.
	* include/std/mutex (__timed_mutex_impl::_M_try_lock_until): Likewise.
	* include/std/shared_mutex (shared_timed_mutex::try_lock_shared_until):
	Likewise.
	* include/std/thread (this_thread::sleep_until): Likewise.
	* testsuite/30_threads/condition_variable/members/2.cc: Qualify
	slow_clock with new namespace.
	* testsuite/30_threads/condition_variable/members/clock_neg.cc: New
	test.
	* testsuite/30_threads/condition_variable_any/members/clock_neg.cc:
	New test.
	* testsuite/30_threads/future/members/clock_neg.cc: New test.
	* testsuite/30_threads/recursive_timed_mutex/try_lock_until/3.cc:
	Qualify slow_clock with new namespace.
	* testsuite/30_threads/recursive_timed_mutex/try_lock_until/
	clock_neg.cc: New test.
	* testsuite/30_threads/shared_future/members/clock_neg.cc: New
	test.
	* testsuite/30_threads/shared_lock/locking/clock_neg.cc: New test.
	* testsuite/30_threads/shared_timed_mutex/try_lock_until/clock_neg.cc:
	New test.
	* testsuite/30_threads/timed_mutex/try_lock_until/3.cc: Qualify
	slow_clock with new namespace.
	* testsuite/30_threads/timed_mutex/try_lock_until/4.cc: Likewise.
	* testsuite/30_threads/timed_mutex/try_lock_until/clock_neg.cc: New
	test.
	* testsuite/30_threads/unique_lock/locking/clock_neg.cc: New test.
	* testsuite/std/time/traits/is_clock.cc: New test.
	* testsuite/util/slow_clock.h (slow_clock): Move to __gnu_test
	namespace.
2020-03-25 22:07:02 +00:00
Patrick Palka 4512b7d851 libstdc++: Add a test that takes the split_view of a non-forward range
This adds a tests that verifies taking the split_view of a non-forward range
works correctly.  Doing so revealed a typo in one of _OuterIter's constructors.

It also revealed that the default constructor of
__gnu_test::test_range::iterator misbehaves, because by delegating to
Iter<T>(nullptr, nullptr) we perform a null-pointer deref at runtime in
input_iterator_wrapper's constructor due to the ITERATOR_VERIFY check therein.
Instead of delegating to this constructor it seems we can just inherit the
protected default constructor, which does not contain this ITERATOR_VERIFY
check.

libstdc++-v3/ChangeLog:

	* include/std/ranges (split_view::_OuterIter::_OuterIter): Typo fix,
	'address' -> 'std::__addressof'.
	* testsuite/std/ranges/adaptors/split.cc: Test taking the split_view of
	a non-forward input_range.
	* testsuite/util/testsuite_iterators.h (output_iterator_wrapper): Make
	default constructor protected instead of deleted, like with
	input_iterator_wrapper.
	(test_range::iterator): Add comment explaining that this type is used
	only when the underlying wrapper is input_iterator_wrapper or
	output_iterator_wrapper.  Remove delegating defaulted constructor so
	that the inherited default constructor is used instead.
2020-03-11 14:56:52 -04:00
Patrick Palka 26af9cd8af libstdc++: Add a testsuite range type that has a sized sentinel
This adds a testsuite range type whose end() is a sized sentinel to
<testsuite_iterators.h>, which will be used in the tests that verify LWG 3355.

libstdc++-v3/ChangeLog:

	* testsuite/util/testsuite_iterators.h (test_range::get_iterator): Make
	protected instead of private.
	(test_sized_range_sized_sent): New.
2020-03-03 22:44:39 -05:00
Patrick Palka d6d4b339f5 libstdc++: Add a move-only testsuite iterator type
This adds a move-only testsuite iterator wrapper to <testsuite_iterators.h>
which will be used in the tests for LWG 3355.  The tests for LWG 3389 and 3390
are adjusted to use this new iterator wrapper.

libstdc++-v3/ChangeLog:

	* testsuite/util/testsuite_iterators.h (input_iterator_wrapper_nocopy):
	New testsuite iterator.
	* testsuite/24_iterators/counted_iterator/lwg3389.cc: Use it.
	* testsuite/24_iterators/move_iterator/lwg3390.cc: Likewise.
2020-03-03 22:44:35 -05:00
Jonathan Wakely e94f254230 libstdc++: Support N3644 "Null Forward Iterators" for testsuite iterators
Comparing value-initialized forward_iterator_wrapper<T> objects fails an
assertion, but should be valid in C++14 and later.

	* testsuite/util/testsuite_iterators.h (forward_iterator_wrapper): Add
	equality comparisons that support value-initialized iterators.
2020-02-27 13:01:14 +00:00
Jonathan Wakely 15411a6453 libstdc++: "safe" in several library names is misleading (LWG 3379)
* include/bits/range_access.h (enable_safe_range): Rename to
	enable_borrowed_range.
	(__detail::__maybe_safe_range): Rename to __maybe_borrowed_range.
	(safe_range): Rename to borrowed_range.
	* include/bits/ranges_algo.h: Adjust to use new names.
	* include/bits/ranges_algobase.h: Likewise.
	* include/bits/ranges_uninitialized.h: Likewise.
	* include/std/ranges: Likewise.
	(safe_iterator_t): Rename to borrowed_iterator_t.
	(safe_subrange_t): Rename to borrowed_subrange_t.
	* include/std/span: Adjust to use new names.
	* include/std/string_view: Likewise.
	* include/experimental/string_view: Likewise.
	* testsuite/std/ranges/access/begin.cc: Likewise.
	* 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/end.cc: Likewise.
	* testsuite/std/ranges/access/rbegin.cc: Likewise.
	* testsuite/std/ranges/access/rend.cc: Likewise.
	* testsuite/std/ranges/safe_range.cc: Likewise.
	* testsuite/std/ranges/safe_range_types.cc: Likewise.
	* testsuite/util/testsuite_iterators.h: Likewise.
2020-02-19 12:46:57 +00:00
Patrick Palka 6e5a196399 libstdc++: Always return a sentinel<I> from __gnu_test::test_range::end()
It seems that in practice std::sentinel_for<I, I> is always true, and so the
test_range container doesn't help us detect bugs in ranges code in which we
wrongly assume that a sentinel can be manipulated like an iterator.  Make the
test_range range more strict by having end() unconditionally return a
sentinel<I>, and adjust some tests accordingly.

libstdc++-v3/ChangeLog:

	* testsuite/24_iterators/range_operations/distance.cc: Do not assume
	test_range::end() returns the same type as test_range::begin().
	* testsuite/24_iterators/range_operations/next.cc: Likewise.
	* testsuite/24_iterators/range_operations/prev.cc: Likewise.
	* testsuite/util/testsuite_iterators.h (__gnu_test::test_range::end):
	Always return a sentinel<I>.
2020-01-31 12:17:10 -05:00
Jonathan Wakely 5cd2e126f5 libstdc++: Make tests for std::ranges access functions more robust
* testsuite/std/ranges/access/end.cc: Do not assume test_range::end()
	returns the same type as test_range::begin(). Add comments.
	* testsuite/std/ranges/access/rbegin.cc: Likewise.
	* testsuite/std/ranges/access/rend.cc: Likewise.
	* testsuite/std/ranges/range.cc: Do not assume the sentinel for
	test_range is the same as its iterator type.
	* testsuite/util/testsuite_iterators.h (test_range::sentinel): Add
	operator- overloads to satisfy sized_sentinel_for when the iterator
	satisfies random_access_iterator.
2020-01-29 13:36:15 +00:00
Jonathan Wakely e4379a931d libstdc++: Value-initialize std::atomic for C++20 (P0883R2)
This implements the new requirements for C++20 that std::atomic should
initialize the atomic variable in its default constructor.

This patch does not add the deprecated attribute to atomic_init, but
that should be done at some point as it's deprecated in C++20.

The paper also deprecates the ATOMIC_FLAG_INIT macro, although we can't
apply the deprecated attribute to a macro.

	PR libstdc++/58605
	* include/bits/atomic_base.h (__cpp_lib_atomic_value_initialization):
	Define.
	(__atomic_flag_base, __atomic_base, __atomic_base<_PTp*>)
	(__atomic_float): Add default member initializer for C++20.
	* include/std/atomic (atomic): Likewise.
	(atomic::atomic()): Remove noexcept-specifier on default constructor.
	* include/std/version (__cpp_lib_atomic_value_initialization): Define.
	* testsuite/29_atomics/atomic/cons/assign_neg.cc: Adjust dg-error line
	number.
	* testsuite/29_atomics/atomic/cons/copy_neg.cc: Likewise.
	* testsuite/29_atomics/atomic/cons/value_init.cc: New test.
	* testsuite/29_atomics/atomic_flag/cons/value_init.cc: New test.
	* testsuite/29_atomics/atomic_flag/requirements/trivial.cc: Adjust
	expected result for is_trivially_default_constructible.
	* testsuite/29_atomics/atomic_float/requirements.cc: Likewise.
	* testsuite/29_atomics/atomic_float/value_init.cc: New test.
	* testsuite/29_atomics/atomic_integral/cons/assign_neg.cc: Likewise.
	* testsuite/29_atomics/atomic_integral/cons/copy_neg.cc: Likewise.
	* testsuite/29_atomics/atomic_integral/cons/value_init.cc
	* testsuite/29_atomics/atomic_integral/requirements/trivial.cc: Adjust
	expected results for is_trivially_default_constructible.
	* testsuite/util/testsuite_common_types.h (has_trivial_dtor): Add
	new test generator.
2020-01-13 13:22:28 +00:00
Jonathan Wakely 68be73fc42 libstdc++: Improve comment about testsuite utilities
This fixes a typo and also explains why test_container is not a range
when used with output_iterator_wrapper or input_iterator_wrapper.

	* testsuite/util/testsuite_iterators.h: Improve comment.

From-SVN: r280146
2020-01-10 22:10:48 +00:00
Jakub Jelinek 8d9254fc8a Update copyright years.
From-SVN: r279813
2020-01-01 12:51:42 +01:00
Jonathan Wakely b5b2e3879d libstdc++: Implement ranges::safe_range for C++20 (P1870R1)
This change replaces the __forwarding_range implementation detail with
the ranges::safe_range concept and adds the ranges::enable_safe_range
variable template for opt-in in to the concept.

It also adjusts the begin/end/rbegin/rend customization point objects to
match the new rules for accessing rvalue ranges only when safe to do so.

	* include/bits/range_access.h (ranges::enable_safe_range): Define.
	(ranges::begin, ranges::end, ranges::rbegin, ranges::rend): Constrain
	to only accept types satisfying safe_range and treat argument as an
	lvalue when calling a member of performing ADL.
	(ranges::__detail::__range_impl, ranges::__detail::__forwarding_range):
	Remove.
	(ranges::range): Adjust definition.
	(ranges::safe_range): Define.
	(ranges::iterator_t, ranges::range_difference_t): Reorder definitions
	to match the synopsis in the working draft.
	(ranges::disable_sized_range): Remove duplicate definition.
	* include/experimental/string_view (ranges::enable_safe_range): Add
	partial specialization for std::experimental::basic_string_view.
	* include/std/ranges (ranges::viewable_range, ranges::subrange)
	(ranges::empty_view, ranges::iota_view): Use safe_range. Specialize
	enable_safe_range.
	(ranges::safe_iterator_t, ranges::safe_subrange_t): Define.
	* include/std/span (ranges::enable_safe_range): Add partial
	specialization for std::span.
	* include/std/string_view (ranges::enable_safe_range): Likewise for
	std::basic_string_view.
	* testsuite/std/ranges/access/begin.cc: Adjust expected results.
	* 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/end.cc: Likewise.
	* testsuite/std/ranges/access/rbegin.cc: Likewise.
	* testsuite/std/ranges/access/rend.cc: Likewise.
	* testsuite/std/ranges/empty_view.cc: Test ranges::begin and
	ranges::end instead of unqualified calls to begin and end.
	* testsuite/std/ranges/safe_range.cc: New test.
	* testsuite/std/ranges/safe_range_types.cc: New test.
	* testsuite/util/testsuite_iterators.h: Add comment about safe_range.

From-SVN: r279135
2019-12-09 17:35:24 +00:00
Jonathan Wakely 819fb01933 libstdc++: Fix copyright date on new test header
The slow_clock type was introduced to the testsuite in 2018 in the
testsuite/30_threads/condition_variable/members/2.cc test, so the new
header should have that date.

	* testsuite/util/slow_clock.h: Fix copyright date.

From-SVN: r278926
2019-12-03 09:51:49 +00:00
Mike Crowe a7334019b1 libstdc++: Fix timed_mutex::try_lock_until on arbitrary clock (PR 91906)
A non-standard clock may tick more slowly than
std::chrono::steady_clock.  This means that we risk returning false
early when the specified timeout may not have expired. This can be
avoided by looping until the timeout time as reported by the
non-standard clock has been reached.

Unfortunately, we have no way to tell whether the non-standard clock
ticks more quickly that std::chrono::steady_clock. If it does then we
risk returning later than would be expected, but that is unavoidable and
permitted by the standard.

2019-12-02  Mike Crowe  <mac@mcrowe.com>

	PR libstdc++/91906 Fix timed_mutex::try_lock_until on arbitrary clock
	* include/std/mutex (__timed_mutex_impl::_M_try_lock_until): Loop
	until the absolute timeout time is reached as measured against the
	appropriate clock.
	* testsuite/util/slow_clock.h: New file. Move implementation of
	slow_clock test class.
	* testsuite/30_threads/condition_variable/members/2.cc: Include
	slow_clock from header.
	* testsuite/30_threads/shared_timed_mutex/try_lock/3.cc: Convert
	existing test to templated function so that it can be called with
	both system_clock and steady_clock.
	* testsuite/30_threads/timed_mutex/try_lock_until/3.cc: Also run test
	using slow_clock to test above fix.
	* testsuite/30_threads/recursive_timed_mutex/try_lock_until/3.cc:
	Likewise.
	* testsuite/30_threads/recursive_timed_mutex/try_lock_until/4.cc: Add
	new test that try_lock_until behaves as try_lock if the timeout has
	already expired or exactly matches the current time.

From-SVN: r278902
2019-12-02 16:23:06 +00:00
Jonathan Wakely a31517cb9a libstdc++: Implement LWG 3149 for std::default_constructible
The change approved in Belfast did not actually rename the concept from
std::default_constructible to std::default_initializable, even though
that was intended. That is expected to be done soon as a separate issue,
so I'm implementing that now too.

	* include/bits/iterator_concepts.h (weakly_incrementable): Adjust.
	* include/std/concepts (default_constructible): Rename to
	default_initializable and require default-list-initialization and
	default-initialization to be valid (LWG 3149).
	(semiregular): Adjust to new name.
	* testsuite/std/concepts/concepts.lang/concept.defaultconstructible/
	1.cc: Rename directory to concept.defaultinitializable and adjust to
	new name.
	* testsuite/std/concepts/concepts.lang/concept.defaultinitializable/
	lwg3149.cc: New test.
	* testsuite/util/testsuite_iterators.h (test_range): Adjust.

From-SVN: r278314
2019-11-15 19:58:27 +00:00
Jonathan Wakely d37303d15a libstdc++: remove redundant equality operators
Now that operator<=> is supported, these operators can be generated by
the compiler.

	* include/bits/iterator_concepts.h (unreachable_sentinel_t): Remove
	redundant equality operators.
	* testsuite/util/testsuite_iterators.h (test_range::sentinel):
	Likewise.

From-SVN: r277888
2019-11-06 17:53:12 +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 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 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 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 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 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
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 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
François Dumont a37ab089c2 2019-09-01 François Dumont <fdumont@gcc.gnu.org>
* testsuite_files/util/testsuite_performance.h
	(resource_counter::start): Ignore unused malloc(0) result.

From-SVN: r275284
2019-09-01 20:11:42 +00:00
Jonathan Wakely d02a041242 PR libstdc++/91067 add more missing exports for directory iterators
PR libstdc++/91067
	* acinclude.m4 (libtool_VERSION): Bump to 6:28:0.
	* configure: Regenerate.
	* config/abi/pre/gnu.ver (GLIBCXX_3.4.28): Add new version. Export
	missing symbols.
	* testsuite/27_io/filesystem/iterators/91067.cc: Test move
	constructors.
	* testsuite/util/testsuite_abi.cc: Add new symbol version.

From-SVN: r275032
2019-08-29 13:16:27 +01:00
François Dumont ac2dca4daf 2019-07-26 François Dumont <fdumont@gcc.gnu.org>
* testsuite/util/testsuite_iterators.h
	(bidirectional_iterator_wrapper): Fix type comment.
	(random_access_iterator_wrapper): Likewise.

From-SVN: r273824
2019-07-26 05:05:48 +00:00
Jonathan Wakely 67699bf667 PR libstdc++/91067 fix missing exports for filesystem iterators
The copy assignment operator for recursive_directory_iterator was not
exported despite being needed. The __shared_ptr default constructors are
not needed when compiling with GCC but Clang requires them for -O1.

	PR libstdc++/91067
	* acinclude.m4 (libtool_VERSION): Bump to 6:27:0.
	* configure: Regenerate.
	* config/abi/pre/gnu.ver (GLIBCXX_3.4.27): Add new version. Export
	missing symbols.
	* testsuite/27_io/filesystem/iterators/91067.cc: New test.
	* testsuite/util/testsuite_abi.cc: Add new symbol version.

From-SVN: r273023
2019-07-03 22:06:25 +01:00
Jonathan Wakely ed920373a5 Implement new serial algorithms from Parallelism TS (P0024R2)
These new (non-parallel) algorithms were added to C++17 along with the
parallel algorithms, but were missing from libstdc++.

	* include/bits/algorithmfwd.h: Change title of doc group.
	* include/bits/stl_algo.h (for_each_n): Add new C++17 algorithm from
	P0024R2.
	* include/bits/stl_numeric.h: Define doc group and add algos to it.
	* include/std/numeric (__is_random_access_iter): New internal trait.
	(reduce, transform_reduce, exclusive_scan, inclusive_scan)
	(transform_exclusive_scan, transform_inclusive_scan): Likewise.
	* testsuite/25_algorithms/for_each/for_each_n.cc: New test.
	* testsuite/26_numerics/exclusive_scan/1.cc: New test.
	* testsuite/26_numerics/inclusive_scan/1.cc: New test.
	* testsuite/26_numerics/reduce/1.cc: New test.
	* testsuite/26_numerics/transform_exclusive_scan/1.cc: New test.
	* testsuite/26_numerics/transform_inclusive_scan/1.cc: New test.
	* testsuite/26_numerics/transform_reduce/1.cc: New test.
	* testsuite/util/testsuite_iterators.h (test_container::size()): New
	member function.

From-SVN: r272459
2019-06-19 00:01:16 +01:00
Thomas Rodgers f32ee8a25e Synchronize libstdc++ PSTL with upstream LLVM PSTL
Rename PSTL macro's consistent with libstdc++ (and llvm upstream
	project) standards.
	* include/bits/c++config: Rename all macros of the form __PSTL* to
	_PSTL*.
	* include/std/algorithm: Likewise.
	* include/std/execution: Likewise.
	* include/std/numeric: Likewise.
	* include/std/memory: Likewise.
	* include/pstl/glue_memory_impl.h: Likewise.
	* include/pstl/numeric_impl.h: Likewise.
	* include/pstl/glue_memory_defs.h: Likewise.
	* include/pstl/execution_defs.h: Likewise.
	* include/pstl/utils.h: Likewise.
	* include/pstl/algorithm_fwd.h: Likewise.
	* include/pstl/unseq_backend_simd.h: Likewise.
	* include/pstl/glue_execution_defs.h: Likewise.
	* include/pstl/algorithm_impl.h: Likewise.
	* include/pstl/parallel_impl.h: Likewise.
	* include/pstl/memory_impl.h: Likewise.
	* include/pstl/glue_numeric_defs.h: Likewise.
	* include/pstl/parallel_backend_utils.h: Likewise.
	* include/pstl/glue_algorithm_defs.h: Likewise.
	* include/pstl/parallel_backend.h: Likewise.
	* include/pstl/glue_numeric_impl.h: Likewise.
	* include/pstl/parallel_backend_tbb.h: Likewise.
	* include/pstl/numeric_fwd.h: Likewise.
	* include/pstl/glue_algorithm_impl.h: Likewise.
	* include/pstl/execution_impl.h: Likewise.
	* include/pstl/pstl_config.h: Likewise.
	* testsuite/util/pstl/pstl_test_config.h: Likewise.
	* testsuite/util/pstl/test_utils.h: Likewise.
	* testsuite/20_util/specialized_algorithms/pstl/uninitialized_construct.cc:
	Likewise.
	* testsuite/20_util/specialized_algorithms/pstl/uninitialized_copy_move.cc:
	Likewise.
	* testsuite/26_numerics/pstl/numeric_ops/adjacent_difference.cc:
	Likewise.
	* testsuite/26_numerics/pstl/numeric_ops/scan.cc: Likewise.
	* testsuite/26_numerics/pstl/numeric_ops/transform_scan.cc: Likewise.
	* testsuite/26_numerics/pstl/numeric_ops/reduce.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/reverse.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/nth_element.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/find_end.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/find_if.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/none_of.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/count.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/reverse_copy.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/equal.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/search_n.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/find.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/all_of.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/find_first_of.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_sorting/is_heap.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_sorting/partial_sort.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_sorting/partial_sort_copy.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_sorting/lexicographical_compare.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_merge/inplace_merge.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_merge/merge.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/unique_copy_equal.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/replace_copy.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/is_partitioned.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/rotate_copy.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/remove.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/copy_if.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/partition_copy.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/partition.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/copy_move.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/unique.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/rotate.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/any_of.cc: Likewise.

	Rename header guards to be consistent with upstream project's
	conventions.
	* include/pstl/glue_memory_impl.h: Rename all macros of the form
	_PSTL_(.*)_H to _PSTL_\U\1_H.
	* include/pstl/numeric_impl.h: Likewise.
	* include/pstl/glue_memory_defs.h: Likewise.
	* include/pstl/execution_defs.h: Likewise.
	* include/pstl/utils.h: Likewise.
	* include/pstl/algorithm_fwd.h: Likewise.
	* include/pstl/unseq_backend_simd.h: Likewise.
	* include/pstl/glue_execution_defs.h: Likewise.
	* include/pstl/algorithm_impl.h: Likewise.
	* include/pstl/parallel_impl.h: Likewise.
	* include/pstl/memory_impl.h: Likewise.
	* include/pstl/glue_numeric_defs.h: Likewise.
	* include/pstl/parallel_backend_utils.h: Likewise.
	* include/pstl/glue_algorithm_defs.h: Likewise.
	* include/pstl/parallel_backend.h: Likewise.
	* include/pstl/glue_numeric_impl.h: Likewise.
	* include/pstl/parallel_backend_tbb.h: Likewise.
	* include/pstl/numeric_fwd.h: Likewise.
	* include/pstl/glue_algorithm_impl.h: Likewise.
	* include/pstl/execution_impl.h: Likewise.
	* include/pstl/pstl_config.h: Likewise.
	* testsuite/util/pstl/pstl_test_config.h: Likewise.

	Synchronize libstdc++ parallel algorithms with upstream
	project.
	* include/pstl/algorithm_fwd.h: Synchronize with
	upstream PSTL project.
	* include/pstl/algorithm_impl.h: Likewise.
	* include/pstl/execution_defs.h: Likewise.
	* include/pstl/execution_impl.h: Likewise.
	* include/pstl/glue_algorithm_impl.h: Likewise.
	* include/pstl/glue_execution_defs.h: Likewise.
	* include/pstl/numeric_fwd.h: Likewise.
	* include/pstl/numeric_impl.h: Likewise.
	* include/pstl/parallel_backend.h: Likewise.
	* include/pstl/pstl_config.h: Likewise.
	* include/pstl/unseq_backend_simd.h: Likewise.
	* include/pstl/parallel_backend_serial.h: New file.
	* include/Makefile.am (pstl_headers): Add
	parallel_backend_serial.h.
	* include/Makefile.in: Regenerate.

	Clean up non-conforming names
	* include/pstl/algorithm_impl.h (__parallel_set_union_op):
	Uglfiy copy_range1 and copy_range2
	(__pattern_walk2_n): Rename local n to __n
	* include/pstl/parallel_backend_tbb.h (struct __binary_no_op):
	Rename parameter _T to _Tp.

	Integrate non-TBB serial backend support
	* include/bits/c++config: Adjust TBB detection logic to select serial
	PSTL backend if no TBB present.
	* testsuite/utils/pstl/test_utils.h: Remove check for
	_PSTL_USE_PAR_POLICIES

From-SVN: r272056
2019-06-07 22:01:16 +00:00
Antony Polukhin 608a080c3f PR libstdc++/71579 assert that type traits are not misused with incomplete types
This patch adds static asserts for type traits misuse with incomplete
classes and unions. This gives a nice readable error message instead
of an UB and odr-violations.

Some features of the patch:
* each type trait has it's own static_assert inside. This gives better
diagnostics than the approach with putting the assert into a helper
structure and using it in each trait.
* the result of completeness check is not memorized by the compiler.
This gives no false positive after the first failed check.
* some of the compiler builtins already implement the check. But not
all of them! So the asserts are in all the type_traits that may
benefit from the check. This also makes the behavior of libstdc++ more
consistent across different (non GCC) compilers.
* std::is_base_of does not have the assert as it works well in many
cases with incomplete types

2019-05-31  Antony Polukhin  <antoshkka@gmail.com>

	PR libstdc++/71579
	* include/std/type_traits __type_identity, __is_complete_or_unbounded):
	New helpers for checking preconditions in traits.
	(is_trivial, is_trivially_copyable, is_standard_layout, is_pod)
	(is_literal_type, is_empty, is_polymorphic, is_final, is_abstract)
	(is_destructible, is_nothrow_destructible, is_constructible)
	(is_default_constructible, is_copy_constructible)
	(is_move_constructible, is_nothrow_default_constructible)
	(is_nothrow_constructible, is_nothrow_copy_constructible)
	(is_nothrow_move_constructible, is_copy_assignable, is_move_assignable)
	(is_nothrow_assignable, is_nothrow_copy_assignable)
	(is_nothrow_move_assignable, is_trivially_constructible)
	(is_trivially_copy_constructible, is_trivially_move_constructible)
	is_trivially_assignable, is_trivially_copy_assignable)
	(is_trivially_move_assignable, is_trivially_destructible)
	(alignment_of, is_swappable, is_nothrow_swappable, is_invocable)
	(is_invocable_r, is_nothrow_invocable)
	(has_unique_object_representations, is_aggregate): Add static_asserts
	to make sure that type traits are not misused with incomplete types.
	(__is_constructible_impl, __is_nothrow_default_constructible_impl)
	(__is_nothrow_constructible_impl, __is_nothrow_assignable_impl): New
	base characteristics without assertions that can be reused in other
	traits.
	* testsuite/20_util/is_complete_or_unbounded/memoization.cc: New test.
	* testsuite/20_util/is_complete_or_unbounded/memoization_neg.cc: New
	test.
	* testsuite/20_util/is_complete_or_unbounded/value.cc: New test.
	* testsuite/20_util/is_abstract/incomplete_neg.cc: New test.
	* testsuite/20_util/is_aggregate/incomplete_neg.cc: New test.
	* testsuite/20_util/is_class/value.cc: Check incomplete type.
	* testsuite/20_util/is_function/value.cc: Likewise.
	* testsuite/20_util/is_move_constructible/incomplete_neg.cc: New test.
	* testsuite/20_util/is_nothrow_move_assignable/incomplete_neg.cc: New
	test.
	* testsuite/20_util/is_polymorphic/incomplete_neg.cc: New test.
	* testsuite/20_util/is_reference/value.cc: Check incomplete types.
	* testsuite/20_util/is_unbounded_array/value.cc: Likewise.
	* testsuite/20_util/is_union/value.cc: Likewise.
	* testsuite/20_util/is_void/value.cc: Likewise.
	* testsuite/util/testsuite_tr1.h: Add incomplete union type.

From-SVN: r271806
2019-05-31 11:35:03 +01:00
Jonathan Wakely 65539b1ef3 Avoid -Wunused-parameter warnings from testsuite utility
* testsuite/util/testsuite_api.h: Remove names of unused parameters.

From-SVN: r271741
2019-05-29 15:45:50 +01:00
Jonathan Wakely d9b401df8f Fix C++14-only code in testsuite utility
* testsuite/util/testsuite_fs.h (compare_paths): Use three-argument
	form of std::equals for C++11 compatibility.

From-SVN: r271716
2019-05-28 20:39:41 +01:00
Jonathan Wakely f9b22a0c24 PR libstdc++/90557 fix path assignment that alters source
PR libstdc++/90557
	* src/c++17/fs_path.cc (path::_List::operator=(const _List&)): Fix
	reversed arguments to uninitialized_copy_n.
	* testsuite/27_io/filesystem/path/assign/copy.cc: Check that source
	is unchanged by copy assignment.
	* testsuite/util/testsuite_fs.h (compare_paths): Use std::equal to
	compare path components.

From-SVN: r271527
2019-05-22 23:14:34 +01:00
François Dumont 935469daaa Move from state of allocators (LWG2593)
2019-05-17  François Dumont  <fdumont@gcc.gnu.org>

	Move from state of allocators (LWG2593)
	* include/bits/stl_deque.h
	(_Deque_base(_Deque_base&&, false_type)): Remove.
	(_Deque_base(_Deque_base&&, true_type)): Remove.
	(_Deque_base(_Deque_base&&)): Adapt.
	(_Deque_base::_M_move_impl()): Remove.
	* testsuite/util/testsuite_allocator.h
	(propagating_allocator(propagating_allocator&&)): Preserve move from
	state.
	* testsuite/23_containers/deque/allocator/move_assign.cc (test02):
	Adapt.
	* testsuite/23_containers/forward_list/allocator/move_assign.cc (test02):
	Adapt.
	* testsuite/23_containers/list/allocator/move_assign.cc (test02): Adapt.
	* testsuite/23_containers/map/allocator/move_assign.cc (test02): Adapt.
	* testsuite/23_containers/multimap/allocator/move_assign.cc (test02):
	Adapt.
	* testsuite/23_containers/multiset/allocator/move_assign.cc (test02):
	Adapt.
	* testsuite/23_containers/set/allocator/move_assign.cc (test02): Adapt.
	* testsuite/23_containers/unordered_map/allocator/move_assign.cc
	(test02): Adapt.
	* testsuite/23_containers/unordered_multimap/allocator/move_assign.cc
	(test02): Adapt.
	* testsuite/23_containers/unordered_multiset/allocator/move_assign.cc
	(test02): Adapt.
	* testsuite/23_containers/unordered_set/allocator/move_assign.cc
	(test02): Adapt.
	* testsuite/23_containers/vector/allocator/move_assign.cc (test02):
	Adapt.
	* testsuite/23_containers/vector/bool/allocator/move_assign.cc (test02):
	Adapt.
	* testsuite/21_strings/basic_string/allocator/char/move_assign.cc
	(test02): Adapt.
	* testsuite/21_strings/basic_string/allocator/wchar_t/move_assign.cc
	(test02): Adapt.

From-SVN: r271309
2019-05-17 04:55:37 +00:00
Jonathan Wakely ff8b2a0acb Fix NullablePointer test utility
* testsuite/util/testsuite_allocator.h (NullablePointer::operator bool):
	Fix return value.

From-SVN: r271189
2019-05-14 21:01:28 +01:00
Jonathan Wakely c688848d6a Fix indentation in testsuite utility header
* testsuite/util/testsuite_allocator.h (memory_resource)
	(default_resource_mgr): Fix indentation.

From-SVN: r271161
2019-05-14 12:17:27 +01:00
Jonathan Wakely 066f9ea279 Add __gnu_test::NullablePointer utility to testsuite
* testsuite/20_util/allocator_traits/members/allocate_hint_nonpod.cc:
	Use operator-> to access raw pointer member.
	* testsuite/23_containers/vector/59829.cc: Likewise.
	* testsuite/23_containers/vector/bool/80893.cc: Likewise.
	* testsuite/libstdc++-prettyprinters/cxx11.cc: Use NullablePointer.
	* testsuite/util/testsuite_allocator.h (NullablePointer): New utility
	for tests.
	(PointerBase, PointerBase_void): Derive from NullablePointer and use
	its constructors and equality operators. Change converting
	constructors to use operator-> to access private member of the other
	pointer type.
	(PointerBase_void::operator->()): Add, for access to private member.
	(operator-(PointerBase, PointerBase)): Change to hidden friend.
	(operator==(PointerBase, PointerBase)): Remove.
	(operator!=(PointerBase, PointerBase)): Remove.

From-SVN: r271160
2019-05-14 12:17:23 +01:00
Jonathan Wakely 1a1e427caa PR libstdc++/81266 fix std:🧵:native_handle_type test
The test uses remove_pointer because in most cases native_handle_type is
a pointer to the actual type that the C++ class contains. However, for
std::thread, native_handle_type is the same type as the type contained
in std::thread, and so remove_pointer is not needed. On targets where
pthread_t is a pointer type remove_pointer<native_handle_type> is not a
no-op, instead it transforms pthread_t and causes the test to fail.

The fix is to not apply remove_pointer when testing std::thread.

	PR libstdc++/81266
	* testsuite/util/thread/all.h: Do not use remove_pointer for
	std:🧵:native_handle_type.

From-SVN: r271080
2019-05-10 22:41:23 +01:00
Jonathan Wakely ee2f721c2f PR libstdc++/90239 use uses_allocator_construction_args in <scoped_allocator>
PR libstdc++/90239
	* doc/xml/manual/status_cxx2020.xml: Amend P0591R4 status.
	* include/std/scoped_allocator [__cplusplus > 201703L]
	(scoped_allocator_adaptor::construct): Define in terms of
	uses_allocator_construction_args, as per P0591R4.
	* testsuite/20_util/scoped_allocator/construct_pair_c++2a.cc: New test.
	* testsuite/util/testsuite_allocator.h: Remove name of unused
	parameter.

From-SVN: r270588
2019-04-25 23:43:15 +01:00
Jonathan Wakely c7dde4a90a Share all recursive_directory_iterator state [LWG 2708]
Implement the proposed resolution of LWG 2708 by moving the _M_options
and _M_pending members out of the recursive_directory_iterator into the
shared _Dir_stack object. Because _Dir_stack is an opaque type, the
member functions that access the _M_options and _M_pending variables
cannot be inline. Move them into the library.

As a drive-by fix, add noexcept to the non-throwing member functions of
recursive_directory_iterator.

	* config/abi/pre/gnu.ver: Export new symbols.
	* include/bits/fs_dir.h (recursive_directory_iterator::options())
	(recursive_directory_iterator::recursion_pending())
	(recursive_directory_iterator::disable_recursion_pending()): Remove
	inline definitions. Make noexcept.
	(recursive_directory_iterator::depth())
	(recursive_directory_iterator::operator*())
	(recursive_directory_iterator::operator->()): Make noexcept.
	(recursive_directory_iterator::_M_options)
	(recursive_directory_iterator::_M_pending): Remove data members.
	* src/c++17/fs_path.cc (_Dir_stack): Add constructor and data members.
	(recursive_directory_iterator::recursive_directory_iterator): Remove
	ctor-initializer. Use new constructor for _Dir_stack.
	(recursive_directory_iterator::options())
	(recursive_directory_iterator::recursion_pending())
	(recursive_directory_iterator::disable_recursion_pending()): Add
	non-inline definitions.
	(recursive_directory_iterator::depth()): Make noexcept.
	(recursive_directory_iterator::increment(error_code&))
	(recursive_directory_iterator::pop(error_code&)): Adjust to new
	location of options and recursion_pending members.
	* testsuite/27_io/filesystem/iterators/recursion_pending.cc: New test.
	* testsuite/util/testsuite_fs.h (__gnu_test::scoped_file): Add
	user-declared move constructor and assignment operator, to make the
	type move-only.

From-SVN: r270173
2019-04-05 17:56:23 +01:00