Commit Graph

5374 Commits

Author SHA1 Message Date
Jonathan Wakely
ea5674687a libstdc++: Add another non-reserved name to tests
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* testsuite/17_intro/names.cc: Check 'sz'.
2021-08-26 00:09:13 +01:00
Jonathan Wakely
f1a08f4d78 libstdc++: Fix names.cc test failures on Windows
The Windows CRT headers define structs with members called f, x, y etc
so don't check those. There are also lots of unnecessary function
parameters in mingw headers using non-reserved names, e.g.

<time.h> uses p and z as parameters of mingw_gettimeofday
<inttypes.h> uses j as a parameter of imaxabs
<pthread.h> uses l, o and func as parameter names

Those should be fixed in the headers instead.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* testsuite/17_intro/names.cc: Adjust for Windows.
2021-08-25 22:29:27 +01:00
Jonathan Wakely
0163bbaaef libstdc++: Fix non-reserved names in <valarray>
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/std/valarray: Uglify 'func' parameters.
	* testsuite/17_intro/names.cc: Add 'func' to checks.
2021-08-25 22:29:26 +01:00
Jonathan Wakely
ead408529d libstdc++: Fix conditions for optimizing uninitialized algos [PR102064]
While laying some groundwork for constexpr std::vector, I noticed some
bugs in the std::uninitialized_xxx algorithms. The conditions being
checked for optimizing trivial cases were not quite right, as shown in
the examples in the PR.

This consolidates the checks into a single macro. The macro has
appropriate definitions for C++98 or for later standards, to avoid a #if
everywhere the checks are used. For C++11 and later the check makes a
call to a new function doing a static_assert to ensure we don't use
assignment in cases where construction would have been invalid.
Extracting that check to a separate function will be useful for
constexpr std::vector, as that can't use std::uninitialized_copy
directly because it isn't constexpr).

The consolidated checks mean that some slight variations in static
assert message are gone, as there is only one place that does the assert
now. That required adjusting some tests. As part of that the redundant
89164_c++17.cc test was merged into 89164.cc which is compiled as C++17
by default now, but can also use other -std options if the
C++17-specific error is made conditional with a target selector.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/102064
	* include/bits/stl_uninitialized.h (_GLIBCXX_USE_ASSIGN_FOR_INIT):
	Define macro to check conditions for optimizing trivial cases.
	(__check_constructible): New function to do static assert.
	(uninitialized_copy, uninitialized_fill, uninitialized_fill_n):
	Use new macro.
	* testsuite/20_util/specialized_algorithms/uninitialized_copy/1.cc:
	Adjust dg-error pattern.
	* testsuite/23_containers/vector/cons/89164.cc: Likewise. Add
	C++17-specific checks from 89164_c++17.cc.
	* testsuite/23_containers/vector/cons/89164_c++17.cc: Removed.
	* testsuite/20_util/specialized_algorithms/uninitialized_copy/102064.cc:
	New test.
	* testsuite/20_util/specialized_algorithms/uninitialized_copy_n/102064.cc:
	New test.
	* testsuite/20_util/specialized_algorithms/uninitialized_fill/102064.cc:
	New test.
	* testsuite/20_util/specialized_algorithms/uninitialized_fill_n/102064.cc:
	New test.
2021-08-25 22:28:47 +01:00
Jonathan Wakely
037ef219b2 libstdc++: Add std::is_layout_compatible trait for C++20
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/std/type_traits (is_layout_compatible): Define.
	(is_corresponding_member): Define.
	* include/std/version (__cpp_lib_is_layout_compatible): Define.
	* testsuite/20_util/is_layout_compatible/is_corresponding_member.cc:
	New test.
	* testsuite/20_util/is_layout_compatible/value.cc: New test.
	* testsuite/20_util/is_layout_compatible/version.cc: New test.
	* testsuite/20_util/is_pointer_interconvertible/with_class.cc:
	New test.
	* testsuite/23_containers/span/layout_compat.cc: Do not use real
	std::is_layout_compatible trait if available.
2021-08-24 16:12:44 +01:00
Jonathan Wakely
1a129376bb libstdc++: Add default template argument to basic_istream_view
The standard shows this default template argument in the <ranges>
synopsis, but it was missing in libstdc++.

libstdc++-v3/ChangeLog:

	* include/std/ranges (basic_istream_view): Add default template
	argument.
	* testsuite/std/ranges/istream_view.cc: Check it.
2021-08-23 16:17:10 +01:00
Jonathan Wakely
bc97e736a5 libstdc++: Make permissions_are_testable function inline [PR90787]
This function should be inline, so that's it's not emitted in tests that
don't use it, to avoid undefined references to geteuid().

libstdc++-v3/ChangeLog:

	PR libstdc++/90787
	* testsuite/util/testsuite_fs.h (permissions_are_testable):
	Define as inline.
2021-08-23 14:44:48 +01:00
Jonathan Wakely
29b2fd371f libstdc++: Skip filesystem tests that depend on permissions [PR90787]
Tests that depend on filesystem permissions FAIL if run on Windows or as
root. Add a helper function to detect those cases, so the tests can skip
those checks gracefully.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/90787
	* testsuite/27_io/filesystem/iterators/directory_iterator.cc:
	Use new __gnu_test::permissions_are_testable() function.
	* testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc:
	Likewise.
	* testsuite/27_io/filesystem/operations/exists.cc: Likewise.
	* testsuite/27_io/filesystem/operations/is_empty.cc: Likewise.
	* testsuite/27_io/filesystem/operations/remove.cc: Likewise.
	* testsuite/27_io/filesystem/operations/remove_all.cc: Likewise.
	* testsuite/27_io/filesystem/operations/status.cc: Likewise.
	* testsuite/27_io/filesystem/operations/symlink_status.cc:
	Likewise.
	* testsuite/27_io/filesystem/operations/temp_directory_path.cc:
	Likewise.
	* testsuite/experimental/filesystem/iterators/directory_iterator.cc:
	Likewise.
	* testsuite/experimental/filesystem/iterators/recursive_directory_iterator.cc:
	Likewise.
	* testsuite/experimental/filesystem/operations/exists.cc:
	Likewise.
	* testsuite/experimental/filesystem/operations/is_empty.cc:
	Likewise.
	* testsuite/experimental/filesystem/operations/remove.cc:
	Likewise.
	* testsuite/experimental/filesystem/operations/remove_all.cc:
	Likewise.
	* testsuite/experimental/filesystem/operations/temp_directory_path.cc:
	Likewise.
	* testsuite/util/testsuite_fs.h (__gnu_test::permissions_are_testable):
	New function to guess whether testing permissions will work.
2021-08-20 15:15:22 +01:00
Jonathan Wakely
0187e0d736 libstdc++: Fix move construction of std::tuple with array elements [PR101960]
An array member cannot be direct-initialized in a ctor-initializer-list,
so use the base class' move constructor, which does the right thing for
both arrays and non-arrays.

This constructor could be defaulted, but that would make it trivial for
some specializations, which would change the argument passing ABI. Do
that for the versioned namespace only.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/101960
	* include/std/tuple (_Tuple_impl(_Tuple_impl&&)): Use base
	class' move constructor. Define as defaulted for versioned
	namespace.
	* testsuite/20_util/tuple/cons/101960.cc: New test.
2021-08-19 13:02:12 +01:00
Jonathan Wakely
c883d1dcde libstdc++: Fix vector<bool> printer tests to work in debug mode
This fixes a compilation error in debug mode, due to std::_Bit_reference
not being defined, because it's in namespace std::__cxx1998 instead. We
can refer to it as vector<bool>::reference instead, which always works.

That fixes some compilation errors in debug mode, but the tests fail at
run-time instead because the printers for vector<bool> helpers are only
registered for the std namespace, not std::__cxx1998. That is fixed by
using add_container to register the printers instead of add_version, as
the former registers them in the std and std::__cxx1998 namespaces.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdBitReferencePrinter): Use
	'std::vector<bool>::reference' as type name, not _Bit_reference.
	(build_libstdcxx_dictionary): Register printers for vector<bool>
	types in debug mode too.
	* testsuite/libstdc++-prettyprinters/simple.cc: Adjust expected
	output for invalid _Bit_reference. Use vector<bool>::reference
	instead of _Bit_reference.
	* testsuite/libstdc++-prettyprinters/simple11.cc: Likewise.
2021-08-18 14:26:38 +01:00
Thomas Schwinge
60b94d8bd2 libstdc++: Avoid illegal argument to verbose in dg-test callback, continued
This is a follow-up to commit 697b94cfae
"libstdc++: Avoid illegal argument to verbose in dg-test callback".
I'm confirming the original problem, but on one system, it's not
resolved by this change, because instead we get:

    extra_tool_flags are:
    ERROR: tcl error sourcing [...]/libstdc++-v3/testsuite/libstdc++-dg/conformance.exp.
    ERROR: usage: send [args] string
        while executing
    "send_log "$message\n""
        (procedure "verbose" line 48)
        invoked from within
    "verbose -log -- $extra_tool_flags"
        (procedure "libstdc++-dg-test" line 45)
        invoked from within
    "${tool}-dg-test $prog [lindex ${dg-do-what} 0] "$tool_flags ${dg-extra-tool-flags}""
        (procedure "saved-dg-test" line 115)
        invoked from within
    [...]

That's Ubuntu's dejagnu 1.5-3ubuntu1 being so old that it doesn't include
DejaGnu commit 57c22601afe43d2c2b8819df4f2ecacb034516fd "Protect from leading
dash in message".  (I suppose that's what'd make this work, but have not
verified.)

	libstdc++-v3/
	* testsuite/lib/libstdc++.exp: Avoid illegal argument to verbose,
	continued.
2021-08-17 21:05:27 +02:00
Luc Michel
817766f4dd libstdc++: Fix testsuite for skipping gdb tests on remote/non-native target
This fixes an incorrect invocation of gdb on remote targets where
DejaGNU would try to run host's gdb in remote target simulator.
gdb-test skips the testing when target is remote or non native but the
gdb version check function does not.

Suggested-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Luc Michel <lmichel@kalray.eu>

Co-authored-by: Marc Poulhies <mpoulhies@kalrayinc.com>

libstdc++-v3/ChangeLog:

	* testsuite/lib/gdb-test.exp (gdb_version_check)
	(gdb_version_check_xmethods): Only check the GDB version for
	local native targets.
2021-08-17 16:54:44 +01:00
Antony Polukhin
174f9257a7 libstdc++: Optimize std::seed_seq construction
When std::seed_seq is constructed from random access iterators we can
detect the internal vector size in O(1). Reserving memory for elements
in such cases may avoid multiple memory allocations.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/random.tcc (seed_seq::seed_seq): Reserve capacity
	if distance is O(1).
	* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error
	line number.

Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
2021-08-17 16:53:19 +01:00
Jonathan Wakely
20698ec5b6 libstdc++: Test std::seed_seq construction from input iterators
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* testsuite/26_numerics/random/seed_seq/cons/range.cc: Check
	construction from input iterators.
2021-08-17 14:31:21 +01:00
Jonathan Wakely
42cfa1bd6c libstdc++: Add conditional noexcept to std::exchange
This is not required by the standard, but seems useful.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/std/utility (exchange): Add noexcept-specifier.
	* testsuite/20_util/exchange/noexcept.cc: New test.
2021-08-17 14:22:49 +01:00
Jonathan Wakely
2db38d9fca libstdc++: Add pretty printer for std::error_code and std::error_condition
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdErrorCodePrinter): Define.
	(build_libstdcxx_dictionary): Register printer for
	std::error_code and std::error_condition.
	* testsuite/libstdc++-prettyprinters/cxx11.cc: Test it.
2021-08-17 14:22:49 +01:00
Jonathan Wakely
9017326e19 libstdc++: Add additional overload of std::lerp [PR101870]
The [cmath.syn] p1 wording about additional overloads sufficient to
handle any arithmetic types also applies to std::lerp. This adds a new
overload of std::lerp that does the required promotions to support
arguments of arbitrary arithmetic types.

A new __promoted_t alias template is added, which the C++17 function
templates std::hypot and std::lerp can use to avoid instantiating the
__promote_3 class template.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/101870
	* include/c_global/cmath (hypot): Use __promoted_t.
	(lerp): Add new overload accepting any arithmetic types.
	* include/ext/type_traits.h (__promoted_t): New alias template.
	* testsuite/26_numerics/lerp.cc: Moved to...
	* testsuite/26_numerics/lerp/1.cc: ...here.
	* testsuite/26_numerics/lerp/constexpr.cc: New test.
	* testsuite/26_numerics/lerp/version.cc: New test.
2021-08-12 19:46:16 +01:00
Jonathan Wakely
b1c0e8599a libstdc++: Make some #error strings consistent with other tests
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* testsuite/26_numerics/lerp.cc: Add header name to #error.
	* testsuite/26_numerics/midpoint/integral.cc: Likewise.
	* testsuite/26_numerics/midpoint/version.cc: New test.
2021-08-12 19:46:16 +01:00
Jonathan Wakely
93f1dbc7cd libstdc++: Fix test that fails randomly [PR101866]
This test assumes that the same sequence of three values cannot occur,
which is incorect. It's unlikely, but not impossible.

Perform the check in a loop, so that in the unlikely event of an
identical sequence, we retry. If the library code is buggy it will keep
producing the same sequence and the test will time out. If the code is
working correctly then we will usually break out of the loop after one
iteration, or very rarely after two or three.

libstdc++-v3/ChangeLog:

	PR libstdc++/101866
	* testsuite/experimental/random/randint.cc: Loop and retry if
	reseed() produces the same sequence.
2021-08-11 23:39:34 +01:00
Jonathan Wakely
4fa6c0ec35 libstdc++: Define std::is_pointer_interconvertible_base_of for C++20
Implement these traits using the new built-ins that Jakub added
recently.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/std/type_traits (__cpp_lib_is_pointer_interconvertible)
	(is_pointer_interconvertible_base_of_v)
	(is_pointer_interconvertible_base_of): Define for C++20.
	* include/std/version (__cpp_lib_is_pointer_interconvertible):
	Define.
	* testsuite/23_containers/span/layout_compat.cc: Use correct
	feature test macro for std::is_layout_compatible_v.
	* testsuite/20_util/is_pointer_interconvertible/value.cc: New test.
	* testsuite/20_util/is_pointer_interconvertible/version.cc: New test.
2021-08-11 16:53:22 +01:00
Jonathan Wakely
2eff2a3cb5 libstdc++: Make allocator equality comparable in tests
libstdc++-v3/ChangeLog:

	* testsuite/23_containers/unordered_map/cons/default.cc: Add
	equality comparison operators to allocator.
	* testsuite/23_containers/unordered_set/cons/default.cc:
	Likewise.
2021-08-09 11:43:50 +01:00
François Dumont
ad9c394114 libstdc++: Fix dg-prune-output assertion message
Since __glibcxx_assert changes in r6b42b5a the generated assertion message
has changed.

libstdc++-v3/ChangeLog:

	* testsuite/25_algorithms/copy/debug/constexpr_neg.cc: Replace 'failed_assertion'
	dg-prune-output reason with 'builtin_unreachable'.
	* testsuite/25_algorithms/copy_backward/debug/constexpr_neg.cc: Likewise.
	* testsuite/25_algorithms/equal/debug/constexpr_neg.cc: Likewise.
	* testsuite/25_algorithms/lower_bound/debug/constexpr_partitioned_neg.cc: Likewise.
	* testsuite/25_algorithms/lower_bound/debug/constexpr_partitioned_pred_neg.cc: Likewise.
	* testsuite/25_algorithms/lower_bound/debug/constexpr_valid_range_neg.cc: Likewise.
	* testsuite/25_algorithms/upper_bound/debug/constexpr_partitioned_neg.cc: Likewise.
	* testsuite/25_algorithms/upper_bound/debug/constexpr_partitioned_pred_neg.cc: Likewise.
	* testsuite/25_algorithms/upper_bound/debug/constexpr_valid_range_neg.cc: Likewise.
2021-08-08 19:12:22 +02:00
Hans-Peter Nilsson
e9b639c4b5 libstdc++: Tweak timeout for testsuite/std/ranges/iota/max_size_type.cc
A simulator can easily spend more than 10 minutes running
this test-case, and the default timeout is at 5 minutes.
Better allow even slower machines; use 4 as the factor.

Regarding relative runtime numbers (very local; mmixware simulator for
mmix-knuth-mmixware): test01 and test05 finish momentarily; test02 at
about 2 minutes, and test03 about 2m30, but test04 itself runs for
more than 6 minues and so times out.

Not sure if it's better to split up this test, as the excessive
runtime may be unintended, but this seemed simplest.

libstdc++-v3:
	* testsuite/std/ranges/iota/max_size_type.cc: Set
	dg-timeout-factor to 4.
2021-08-08 10:52:50 +02:00
Jonathan Wakely
8dec72aeb5 libstdc++: Add [[nodiscard]] to <compare>
This adds the [[nodiscard]] attribute to all conversion operators,
comparison operators, call operators and non-member functions in
<compare>. Nothing in this header except constructors has side effects.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* libsupc++/compare (partial_ordering, weak_ordering)
	(strong_ordering, is_eq, is_neq, is_lt, is_lteq, is_gt, is_gteq)
	(compare_three_way, strong_order, weak_order, partial_order)
	(compare_strong_order_fallback, compare_weak_order_fallback)
	(compare_partial_order_fallback, __detail::__synth3way): Add
	nodiscard attribute.
	* testsuite/18_support/comparisons/categories/zero_neg.cc: Add
	-Wno-unused-result to options.
2021-08-05 15:16:58 +01:00
Jonathan Wakely
7b1de3eb9e libstdc++: Move attributes that follow requires-clauses [PR101782]
As explained in the PR, the grammar in the Concepts TS means that a [
token following a requires-clause is parsed as part of the
logical-or-expression rather than the start of an attribute. That makes
the following ill-formed when using -fconcepts-ts:

  template<typename T> requires foo<T> [[nodiscard]] int f(T);

This change moves all attributes that follow a requires-clause to the
end of the function declarator.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/101782
	* include/bits/ranges_base.h (ranges::begin, ranges::end)
	(ranges::rbegin, ranges::rend, ranges::size, ranges::ssize)
	(ranges::empty, ranges::data): Move attribute to the end of
	the declarator.
	* include/bits/stl_iterator.h (__gnu_cxx::__normal_iterator)
	(common_iterator): Likewise for non-member operator functions.
	* include/std/ranges (views::all, views::filter)
	(views::transform, views::take, views::take_while, views::drop)
	(views::drop_while, views::join, views::lazy_split)
	(views::split, views::counted, views::common, views::reverse)
	(views::elements): Likewise.
	* testsuite/std/ranges/access/101782.cc: New test.
2021-08-05 15:16:58 +01:00
Jonathan Wakely
0d04fe4923 libstdc++: Add [[nodiscard]] to sequence containers
... and container adaptors.

This adds the [[nodiscard]] attribute to functions with no side-effects
for the sequence containers and their iterators, and the debug versions
of those containers, and the container adaptors,

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/forward_list.h: Add [[nodiscard]] to functions
	with no side-effects.
	* include/bits/stl_bvector.h: Likewise.
	* include/bits/stl_deque.h: Likewise.
	* include/bits/stl_list.h: Likewise.
	* include/bits/stl_queue.h: Likewise.
	* include/bits/stl_stack.h: Likewise.
	* include/bits/stl_vector.h: Likewise.
	* include/debug/deque: Likewise.
	* include/debug/forward_list: Likewise.
	* include/debug/list: Likewise.
	* include/debug/safe_iterator.h: Likewise.
	* include/debug/vector: Likewise.
	* include/std/array: Likewise.
	* testsuite/23_containers/array/creation/3_neg.cc: Use
	-Wno-unused-result.
	* testsuite/23_containers/array/debug/back1_neg.cc: Cast result
	to void.
	* testsuite/23_containers/array/debug/back2_neg.cc: Likewise.
	* testsuite/23_containers/array/debug/front1_neg.cc: Likewise.
	* testsuite/23_containers/array/debug/front2_neg.cc: Likewise.
	* testsuite/23_containers/array/debug/square_brackets_operator1_neg.cc:
	Likewise.
	* testsuite/23_containers/array/debug/square_brackets_operator2_neg.cc:
	Likewise.
	* testsuite/23_containers/array/tuple_interface/get_neg.cc:
	Adjust dg-error line numbers.
	* testsuite/23_containers/deque/cons/clear_allocator.cc: Cast
	result to void.
	* testsuite/23_containers/deque/debug/invalidation/4.cc:
	Likewise.
	* testsuite/23_containers/deque/types/1.cc: Use
	-Wno-unused-result.
	* testsuite/23_containers/list/types/1.cc: Cast result to void.
	* testsuite/23_containers/priority_queue/members/7161.cc:
	Likewise.
	* testsuite/23_containers/queue/members/7157.cc: Likewise.
	* testsuite/23_containers/vector/59829.cc: Likewise.
	* testsuite/23_containers/vector/ext_pointer/types/1.cc:
	Likewise.
	* testsuite/23_containers/vector/ext_pointer/types/2.cc:
	Likewise.
	* testsuite/23_containers/vector/types/1.cc: Use
	-Wno-unused-result.
2021-08-04 12:54:29 +01:00
Jonathan Wakely
240b01b021 libstdc++: Add [[nodiscard]] to iterators and related utilities
This adds [[nodiscard]] throughout <iterator>, as proposed by P2377R0
(with some minor corrections).

The attribute is added for all modes from C++11 up, using
[[__nodiscard__]] or _GLIBCXX_NODISCARD where C++17 [[nodiscard]] can't
be used directly.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/iterator_concepts.h (iter_move): Add
	[[nodiscard]].
	* include/bits/range_access.h (begin, end, cbegin, cend)
	(rbegin, rend, crbegin, crend, size, data, ssize): Likewise.
	* include/bits/ranges_base.h (ranges::begin, ranges::end)
	(ranges::cbegin, ranges::cend, ranges::rbegin, ranges::rend)
	(ranges::crbegin, ranges::crend, ranges::size, ranges::ssize)
	(ranges::empty, ranges::data, ranges::cdata): Likewise.
	* include/bits/stl_iterator.h (reverse_iterator, __normal_iterator)
	(back_insert_iterator, front_insert_iterator, insert_iterator)
	(move_iterator, move_sentinel, common_iterator)
	(counted_iterator): Likewise.
	* include/bits/stl_iterator_base_funcs.h (distance, next, prev):
	Likewise.
	* include/bits/stream_iterator.h (istream_iterator)
	(ostream_iterartor): Likewise.
	* include/bits/streambuf_iterator.h (istreambuf_iterator)
	(ostreambuf_iterator): Likewise.
	* include/std/ranges (views::single, views::iota, views::all)
	(views::filter, views::transform, views::take, views::take_while)
	(views::drop, views::drop_while, views::join, views::lazy_split)
	(views::split, views::counted, views::common, views::reverse)
	(views::elements): Likewise.
	* testsuite/20_util/rel_ops.cc: Use -Wno-unused-result.
	* testsuite/24_iterators/move_iterator/greedy_ops.cc: Likewise.
	* testsuite/24_iterators/normal_iterator/greedy_ops.cc:
	Likewise.
	* testsuite/24_iterators/reverse_iterator/2.cc: Likewise.
	* testsuite/24_iterators/reverse_iterator/greedy_ops.cc:
	Likewise.
	* testsuite/21_strings/basic_string/range_access/char/1.cc:
	Cast result to void.
	* testsuite/21_strings/basic_string/range_access/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/range_access/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/range_access/wchar_t/1.cc:
	Likewise.
	* testsuite/23_containers/array/range_access.cc: Likewise.
	* testsuite/23_containers/deque/range_access.cc: Likewise.
	* testsuite/23_containers/forward_list/range_access.cc:
	Likewise.
	* testsuite/23_containers/list/range_access.cc: Likewise.
	* testsuite/23_containers/map/range_access.cc: Likewise.
	* testsuite/23_containers/multimap/range_access.cc: Likewise.
	* testsuite/23_containers/multiset/range_access.cc: Likewise.
	* testsuite/23_containers/set/range_access.cc: Likewise.
	* testsuite/23_containers/unordered_map/range_access.cc:
	Likewise.
	* testsuite/23_containers/unordered_multimap/range_access.cc:
	Likewise.
	* testsuite/23_containers/unordered_multiset/range_access.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/range_access.cc:
	Likewise.
	* testsuite/23_containers/vector/range_access.cc: Likewise.
	* testsuite/24_iterators/customization_points/iter_move.cc:
	Likewise.
	* testsuite/24_iterators/istream_iterator/sentinel.cc:
	Likewise.
	* testsuite/24_iterators/istreambuf_iterator/sentinel.cc:
	Likewise.
	* testsuite/24_iterators/move_iterator/dr2061.cc: Likewise.
	* testsuite/24_iterators/operations/prev_neg.cc: Likewise.
	* testsuite/24_iterators/ostreambuf_iterator/2.cc: Likewise.
	* testsuite/24_iterators/range_access/range_access.cc:
	Likewise.
	* testsuite/24_iterators/range_operations/100768.cc: Likewise.
	* testsuite/26_numerics/valarray/range_access2.cc: Likewise.
	* testsuite/28_regex/range_access.cc: Likewise.
	* testsuite/experimental/string_view/range_access/char/1.cc:
	Likewise.
	* testsuite/experimental/string_view/range_access/wchar_t/1.cc:
	Likewise.
	* testsuite/ext/vstring/range_access.cc: Likewise.
	* testsuite/std/ranges/adaptors/take.cc: Likewise.
	* testsuite/std/ranges/p2259.cc: Likewise.
2021-08-04 12:54:28 +01:00
Jonathan Wakely
a77a46d9ae libstdc++: Suppress redundant definitions of inline variables
In C++17 the out-of-class definitions for static constexpr variables are
redundant, because they are implicitly inline. This change avoids
"redundant redeclaration" warnings from -Wsystem-headers -Wdeprecated.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/random.tcc (linear_congruential_engine): Do not
	define static constexpr members when they are implicitly inline.
	* include/std/ratio (ratio, __ratio_multiply, __ratio_divide)
	(__ratio_add, __ratio_subtract): Likewise.
	* include/std/type_traits (integral_constant): Likewise.
	* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error
	line number.
2021-08-03 15:41:11 +01:00
Jonathan Wakely
5c6759e416 libstdc++: Replace TR1 components with C++11 ones in test utils
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* testsuite/util/testsuite_common_types.h: Replace uses of
	tr1::unordered_map and tr1::unordered_set with their C++11
	equivalents.
	* 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_integral/cons/assign_neg.cc:
	Likewise.
	* testsuite/29_atomics/atomic_integral/cons/copy_neg.cc:
	Likewise.
	* testsuite/29_atomics/atomic_integral/operators/bitwise_neg.cc:
	Likewise.
	* testsuite/29_atomics/atomic_integral/operators/decrement_neg.cc:
	Likewise.
	* testsuite/29_atomics/atomic_integral/operators/increment_neg.cc:
	Likewise.
2021-08-03 15:40:42 +01:00
Jonathan Wakely
9bd87e3887 libstdc++: Remove trailing whitespace in some tests
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* testsuite/20_util/function_objects/binders/3113.cc: Remove
	trailing whitespace.
	* testsuite/20_util/shared_ptr/assign/auto_ptr.cc: Likewise.
	* testsuite/20_util/shared_ptr/assign/auto_ptr_neg.cc: Likewise.
	* testsuite/20_util/shared_ptr/assign/auto_ptr_rvalue.cc:
	Likewise.
	* testsuite/20_util/shared_ptr/creation/dr925.cc: Likewise.
	* testsuite/25_algorithms/headers/algorithm/synopsis.cc:
	Likewise.
	* testsuite/25_algorithms/random_shuffle/requirements/explicit_instantiation/2.cc:
	Likewise.
	* testsuite/25_algorithms/random_shuffle/requirements/explicit_instantiation/pod.cc:
	Likewise.
2021-08-03 15:30:36 +01:00
Jonathan Wakely
7f2f4b8791 libstdc++: Deprecate std::random_shuffle for C++14
The std::random_shuffle algorithm was removed in C++14 (without
deprecation). This adds the deprecated attribute for C++14 and later, so
that users are warned they should not be using it in those dialects.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* doc/xml/manual/evolution.xml: Document deprecation.
	* doc/html/*: Regenerate.
	* include/bits/c++config (_GLIBCXX14_DEPRECATED): Define.
	(_GLIBCXX14_DEPRECATED_SUGGEST): Define.
	* include/bits/stl_algo.h (random_shuffle): Deprecate for C++14
	and later.
	* testsuite/25_algorithms/headers/algorithm/synopsis.cc: Adjust
	for C++11 and C++14 changes to std::random_shuffle and
	std::shuffle.
	* testsuite/25_algorithms/random_shuffle/1.cc: Add options to
	use deprecated algorithms.
	* testsuite/25_algorithms/random_shuffle/59603.cc: Likewise.
	* testsuite/25_algorithms/random_shuffle/moveable.cc: Likewise.
	* testsuite/25_algorithms/random_shuffle/requirements/explicit_instantiation/2.cc:
	Likewise.
	* testsuite/25_algorithms/random_shuffle/requirements/explicit_instantiation/pod.cc:
	Likewise.
2021-08-03 15:30:35 +01:00
Jonathan Wakely
07b70dfc4e libstdc++: Add testsuite proc for testing deprecated features
This change adds options to tests that explicitly use deprecated
features, so that -D_GLIBCXX_USE_DEPRECATED=0 can be used to run the
rest of the testsuite. The tests that explicitly/intentionally use
deprecated features will still be able to use them, but they can be
disabled for the majority of tests.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* testsuite/23_containers/forward_list/operations/3.cc:
	Use lambda instead of std::bind2nd.
	* testsuite/20_util/function_objects/binders/3113.cc: Add
	options for testing deprecated features.
	* testsuite/20_util/pair/cons/99957.cc: Likewise.
	* testsuite/20_util/shared_ptr/assign/auto_ptr.cc: Likewise.
	* testsuite/20_util/shared_ptr/assign/auto_ptr_neg.cc: Likewise.
	* testsuite/20_util/shared_ptr/assign/auto_ptr_rvalue.cc:
	Likewise.
	* testsuite/20_util/shared_ptr/cons/43820_neg.cc: Likewise.
	* testsuite/20_util/shared_ptr/cons/auto_ptr.cc: Likewise.
	* testsuite/20_util/shared_ptr/cons/auto_ptr_neg.cc: Likewise.
	* testsuite/20_util/shared_ptr/creation/dr925.cc: Likewise.
	* testsuite/20_util/unique_ptr/cons/auto_ptr.cc: Likewise.
	* testsuite/20_util/unique_ptr/cons/auto_ptr_neg.cc: Likewise.
	* testsuite/ext/pb_ds/example/priority_queue_erase_if.cc:
	Likewise.
	* testsuite/ext/pb_ds/example/priority_queue_split_join.cc:
	Likewise.
	* testsuite/lib/dg-options.exp (dg_add_options_using-deprecated):
	New proc.
2021-08-03 15:30:17 +01:00
Jonathan Wakely
e9f64fff64 libstdc++: Reduce header dependencies in <regex>
This reduces the size of <regex> a little. This is one of the largest
and slowest headers in the library.

By using <bits/stl_algobase.h> and <bits/stl_algo.h> instead of
<algorithm> we don't need to parse all the parallel algorithms and
std::ranges:: algorithms that are not needed by <regex>. Similarly, by
using <bits/stl_tree.h> and <bits/stl_map.h> instead of <map> we don't
need to parse the definition of std::multimap.

The _State_info type is not movable or copyable, so doesn't need to use
std::unique_ptr<bool[]> to manage a bitset, we can just delete it in the
destructor. It would use a lot less space if we used a bitset instead,
but that would be an ABI break. We could do it for the versioned
namespace, but this patch doesn't do so. For future reference, using
vector<bool> would work, but would increase sizeof(_State_info) by two
pointers, because it's three times as large as unique_ptr<bool[]>. We
can't use std::bitset because the length isn't constant. We want a
bitset with a non-constant but fixed length.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/regex_executor.h (_State_info): Replace
	unique_ptr<bool[]> with array of bool.
	* include/bits/regex_executor.tcc: Likewise.
	* include/bits/regex_scanner.tcc: Replace std::strchr with
	__builtin_strchr.
	* include/std/regex: Replace standard headers with smaller
	internal ones.
	* testsuite/28_regex/traits/char/lookup_classname.cc: Include
	<string.h> for strlen.
	* testsuite/28_regex/traits/char/lookup_collatename.cc:
	Likewise.
2021-08-03 15:24:52 +01:00
Patrick Palka
14d8a5ae47 libstdc++: Add missing std::move to ranges::copy/move/reverse_copy [PR101599]
In passing, this also renames the template parameter _O2 to _Out2 in
ranges::partition_copy and uglifies two of its function parameters,
out_true and out_false.

	PR libstdc++/101599

libstdc++-v3/ChangeLog:

	* include/bits/ranges_algo.h (__reverse_copy_fn::operator()):
	Add missing std::move in return statement.
	(__partition_copy_fn::operator()): Rename templtae parameter
	_O2 to _Out2.  Uglify function parameters out_true and out_false.
	* include/bits/ranges_algobase.h (__copy_or_move): Add missing
	std::move to recursive call that unwraps a __normal_iterator
	output iterator.
	* testsuite/25_algorithms/copy/constrained.cc (test06): New test.
	* testsuite/25_algorithms/move/constrained.cc (test05): New test.
2021-08-02 15:30:15 -04:00
Jonathan Wakely
2aaf69133f libstc++: Add dg-error for additional error in C++11 mode
When the comparison with a nullptr_t is ill-formed, there is an
additional error for C++11 mode due to the constexpr function body being
invalid.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* testsuite/20_util/tuple/comparison_operators/overloaded2.cc:
	Add dg-error for c++11_only target.
2021-08-02 16:22:24 +01:00
Jonathan Wakely
3dbd4d94bf libstdc++: Use secure_getenv for filesystem::temp_directory_path() [PR65018]
This adds a configure check for the GNU extension secure_getenv and then
uses it for looking up TMPDIR and similar variables.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/65018
	* configure.ac: Check for secure_getenv.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* src/filesystem/ops-common.h (get_temp_directory_from_env): New
	helper function to obtain path from the environment.
	* src/c++17/fs_ops.cc (fs::temp_directory_path): Use new helper.
	* src/filesystem/ops.cc (fs::temp_directory_path): Likewise.
	* testsuite/27_io/filesystem/operations/temp_directory_path.cc:
	Print messages if test cannot be run.
	* testsuite/experimental/filesystem/operations/temp_directory_path.cc:
	Likewise. Fix incorrect condition. Use "TMP" to work with
	Windows as well as POSIX.
2021-07-30 18:12:39 +01:00
Marek Polacek
bee2f80b90 c++: Reject ordered comparison of null pointers [PR99701]
When implementing DR 1512 in r11-467 I neglected to reject ordered
comparison of two null pointers, like nullptr < nullptr.  This patch
fixes that omission.

	DR 1512
	PR c++/99701

gcc/cp/ChangeLog:

	* cp-gimplify.c (cp_fold): Remove {LE,LT,GE,GT_EXPR} from
	a switch.
	* typeck.c (cp_build_binary_op): Reject ordered comparison
	of two null pointers.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/nullptr11.C: Remove invalid tests.
	* g++.dg/cpp0x/nullptr46.C: Add dg-error.
	* g++.dg/cpp2a/spaceship-err7.C: New test.
	* g++.dg/expr/ptr-comp4.C: New test.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/tuple/comparison_operators/overloaded.cc:
	Move a line...
	* testsuite/20_util/tuple/comparison_operators/overloaded2.cc:
	...here.  New test.
2021-07-27 11:38:59 -04:00
Jonathan Wakely
16158c9649 libstdc++: Remove unnecessary uses of <utility>
The <algorithm> header includes <utility>, with a comment referring to
UK-300, a National Body comment on the C++11 draft. That comment
proposed to move std::swap to <utility> and then require <algorithm> to
include <utility>. The comment was rejected, so we do not need to
implement the suggestion. For backwards compatibility with C++03 we do
want <algorithm> to define std::swap, but it does so anyway via
<bits/move.h>. We don't need the whole of <utility> to do that.

A few other headers that need std::swap can include <bits/move.h> to
get it, instead of <utility>.

There are several headers that include <utility> to get std::pair, but
they can use <bits/stl_pair.h> to get it without also including the
rel_ops namespace and other contents of <utility>.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/std/algorithm: Do not include <utility>.
	* include/std/functional: Likewise.
	* include/std/regex: Include <bits/stl_pair.h> instead of
	<utility>.
	* include/debug/map.h: Likewise.
	* include/debug/multimap.h: Likewise.
	* include/debug/multiset.h: Likewise.
	* include/debug/set.h: Likewise.
	* include/debug/vector: Likewise.
	* include/bits/fs_path.h: Likewise.
	* include/bits/unique_ptr.h: Do not include <utility>.
	* include/experimental/any: Likewise.
	* include/experimental/executor: Likewise.
	* include/experimental/memory: Likewise.
	* include/experimental/optional: Likewise.
	* include/experimental/socket: Use __exchange instead
	of std::exchange.
	* src/filesystem/ops-common.h: Likewise.
	* testsuite/20_util/default_delete/48631_neg.cc: Adjust expected
	errors to not use a hardcoded line number.
	* testsuite/20_util/default_delete/void_neg.cc: Likewise.
	* testsuite/20_util/specialized_algorithms/uninitialized_copy/constrained.cc:
	Include <utility> for std::as_const.
	* testsuite/20_util/specialized_algorithms/uninitialized_default_construct/constrained.cc:
	Likewise.
	* testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc:
	Likewise.
	* testsuite/20_util/specialized_algorithms/uninitialized_value_construct/constrained.cc:
	Likewise.
	* testsuite/23_containers/vector/cons/destructible_debug_neg.cc:
	Adjust dg-error line number.
2021-07-27 12:04:18 +01:00
Jonathan Wakely
261d5a4a45 libstdc++: Reduce header dependencies on <array> and <utility>
This refactoring reduces the memory usage and compilation time to parse
a number of headers that depend on std::pair, std::tuple or std::array.
Previously the headers for these class templates were all intertwined,
due to the common dependency on std::tuple_size, std::tuple_element and
their std::get overloads. This decouples the headers by moving some
parts of <utility> into a new <bits/utility.h> header. This means that
<array> and <tuple> no longer need to include the whole of <utility>,
and <tuple> no longer needs to include <array>.

This decoupling benefits headers such as <thread> and <scoped_allocator>
which only need std::tuple, and so no longer have to parse std::array.

Some other headers such as <any>, <optional> and <variant> no longer
need to include <utility> just for the std::in_place tag types, so
do not have to parse the std::pair definitions.

Removing direct uses of <utility> also means that the std::rel_ops
namespace is not transitively declared by other headers.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/Makefile.am: Add bits/utility.h header.
	* include/Makefile.in: Regenerate.
	* include/bits/utility.h: New file.
	* include/std/utility (tuple_size, tuple_element): Move
	to new header.
	* include/std/type_traits (__is_tuple_like_impl<tuple<T...>>):
	Move to <tuple>.
	(_Index_tuple, _Build_index_tuple, integer_sequence): Likewise.
	(in_place_t, in_place_index_t, in_place_type_t): Likewise.
	* include/bits/ranges_util.h: Include new header instead of
	<utility>.
	* include/bits/stl_pair.h (tuple_size, tuple_element): Move
	partial specializations for std::pair here.
	(get): Move overloads for std::pair here.
	* include/std/any: Include new header instead of <utility>.
	* include/std/array: Likewise.
	* include/std/memory_resource: Likewise.
	* include/std/optional: Likewise.
	* include/std/variant: Likewise.
	* include/std/tuple: Likewise.
	(__is_tuple_like_impl<tuple<T...>>): Move here.
	(get) Declare overloads for std::array.
	* include/std/version (__cpp_lib_tuples_by_type): Change type
	to long.
	* testsuite/20_util/optional/84601.cc: Include <utility>.
	* testsuite/20_util/specialized_algorithms/uninitialized_fill/constrained.cc:
	Likewise.
	* testsuite/23_containers/array/tuple_interface/get_neg.cc:
	Adjust dg-error line numbers.
	* testsuite/std/ranges/access/cbegin.cc: Include <utility>.
	* testsuite/std/ranges/access/cend.cc: Likewise.
	* testsuite/std/ranges/access/end.cc: Likewise.
	* testsuite/std/ranges/single_view.cc: Likewise.
2021-07-27 12:04:18 +01:00
Jonathan Wakely
8ed6cfbbee libstdc++: Fix non-default constructors for hash containers [PR101583]
When I added the new mixin to _Hashtable, I forgot to explicitly
construct it in each non-default constructor. That means you can't
use any constructors unless all three of the hash function, equality
function, and allocator are all default constructible.

libstdc++-v3/ChangeLog:

	PR libstdc++/101583
	* include/bits/hashtable.h (_Hashtable): Replace mixin with
	_Enable_default_ctor. Construct it explicitly in all
	non-forwarding, non-defaulted constructors.
	* testsuite/23_containers/unordered_map/cons/default.cc: Check
	non-default constructors can be used.
	* testsuite/23_containers/unordered_set/cons/default.cc:
	Likewise.
2021-07-22 19:39:58 +01:00
Jonathan Wakely
aca7a0253d libstdc++: Use std::addressof in ranges::uninitialized_xxx [PR101571]
Make the ranges::uninitialized_xxx algorithms use std::addressof to
protect against iterator types that overload operator&.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/101571
	* include/bits/ranges_uninitialized.h (_DestroyGuard): Change
	constructor parameter to reference and use addressof.
	* testsuite/util/testsuite_iterators.h: Define deleted operator&
	overloads for test iterators.
2021-07-22 14:37:24 +01:00
Jonathan Wakely
8edb614205 libstdc++: Make __gnu_cxx::sequence_buffer move-aware [PR101542]
The PR explains that Clang trunk now selects a different constructor
when a non-const sequence_buffer is returned in a context where it
qualifies as an implicitly-movable entity. Because lookup is first
performed using an rvalue, the sequence_buffer(const sequence_buffer&)
constructor gets chosen, which makes a copy instead of a "pseudo-move"
via the sequence_buffer(sequence_buffer&) constructor. The problem isn't
seen with GCC because as noted in the r11-2412 commit log, GCC actually
implements a slightly modified rule that avoids breaking exactly this
type of code.

This patch adds a move constructor to sequence_buffer, so that implicit
or explicit moves will have the same effect, calling the
sequence_buffer(sequence_buffer&) constructor. A move assignment
operator is also added to make move assignment work similarly.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/101542
	* include/ext/rope (sequence_buffer): Add move constructor and
	move assignment operator.
	* testsuite/ext/rope/101542.cc: New test.
2021-07-21 17:20:37 +01:00
Jonathan Wakely
124eaa50e0 libstdc++: Fix create_directories to resolve symlinks [PR101510]
When filesystem__create_directories checks to see if the path already
exists and resovles to a directory, it uses filesystem::symlink_status,
which means it reports an error if the path is a symlink. It should use
filesystem::status, so that the target directory is detected, and no
error is reported.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/101510
	* src/c++17/fs_ops.cc (fs::create_directories): Use status
	instead of symlink_status.
	* src/filesystem/ops.cc (fs::create_directories): Likewise.
	* testsuite/27_io/filesystem/operations/create_directories.cc:
	* testsuite/27_io/filesystem/operations/create_directory.cc: Do
	not test with symlinks on Windows.
	* testsuite/experimental/filesystem/operations/create_directories.cc:
	* testsuite/experimental/filesystem/operations/create_directory.cc:
	Do not test with symlinks on Windows.
2021-07-20 20:34:47 +01:00
Jonathan Wakely
89ec3b67db libstdc++: fix is_default_constructible for hash containers [PR 100863]
The recent change to _Hashtable_ebo_helper for this PR broke the
is_default_constructible trait for a hash container with a non-default
constructible allocator. That happens because the constructor needs to
be user-provided in order to initialize the member, and so is not
defined as deleted when the type is not default constructible.

By making _Hashtable derive from _Enable_special_members we can ensure
that the default constructor for the std::unordered_xxx containers is
deleted when it would be ill-formed. This makes the trait give the
correct answer.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/100863
	* include/bits/hashtable.h (_Hashtable): Conditionally delete
	default constructor by deriving from _Enable_special_members.
	* testsuite/23_containers/unordered_map/cons/default.cc: New test.
	* testsuite/23_containers/unordered_set/cons/default.cc: New test.
2021-07-20 16:22:26 +01:00
Jonathan Wakely
0c4ae4ff46 libstdc++: Add more tests for filesystem::create_directory [PR101510]
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/101510
	* src/c++17/fs_ops.cc (create_dir): Adjust whitespace.
	* testsuite/27_io/filesystem/operations/create_directory.cc:
	Test creating directory with name of existing symlink to
	directory.
	* testsuite/experimental/filesystem/operations/create_directory.cc:
	Likewise.
2021-07-20 12:54:30 +01:00
Jonathan Wakely
3dbc7b809a libstdc++: Improve diagnostics for std::get with invalid tuple index
This adds a deleted overload of std::get<I>(const tuple<Types...>&).
Invalid calls with an out of range index will match the deleted overload
and give a single, clear error about calling a deleted function, instead
of overload resolution errors for every std::get overload in the
library.

This changes the current output of 15+ errors (plus notes and associated
header context) into just two errors (plus context):

error: static assertion failed: tuple index must be in range
error: use of deleted function 'constexpr std::__enable_if_t<(__i >= sizeof... (_Types))> std::get(const std::tuple<_Types ...>&) [with long unsigned int __i = 1; _Elements = {int}; std::__enable_if_t<(__i >= sizeof... (_Types))> = void]'

This seems like a nice improvement, although PR c++/66968 means that
"_Types" is printed in the signature rather than "_Elements".

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/std/tuple (get<I>): Add deleted overload for bad
	index.
	* testsuite/20_util/tuple/element_access/get_neg.cc: Adjust
	expected errors.
2021-07-16 22:24:34 +01:00
Jonathan Wakely
95891ca020 libstdc++: Modernize <bits/random.h> helpers
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/random.h (_Shift::__value): Use constexpr.
	(_Select_uint_least_t::type): Use using-declaration.
	(_Mod): Likewise.
	* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error
	line number.
2021-07-16 15:03:03 +01:00
Patrick Palka
1af937eb62 libstdc++: invalid default init in _CachedPosition [PR101231]
The primary template for _CachedPosition is a dummy implementation for
non-forward ranges, the iterators for which generally can't be cached.
Because this implementation doesn't actually cache anything, _M_has_value
is defined to be false and so calls to _M_get (which are always guarded
by _M_has_value) are unreachable.

Still, to suppress a "control reaches end of non-void function" warning
I made _M_get return {}, but after P2325 input iterators are no longer
necessarily default constructible so this workaround now breaks valid
programs.

This patch fixes this by instead using __builtin_unreachable to squelch
the warning.

	PR libstdc++/101231

libstdc++-v3/ChangeLog:

	* include/std/ranges (_CachedPosition::_M_get): For non-forward
	ranges, just call __builtin_unreachable.
	* testsuite/std/ranges/istream_view.cc (test05): New test.
2021-07-16 09:44:42 -04:00
Patrick Palka
73464a472a libstdc++: Give split_view::_Sentinel a default ctor [PR101214]
This gives the new split_view's sentinel type a defaulted default
constructor, something which was overlooked in r12-1665.  This patch
also fixes a couple of other issues with the new split_view as reported
in the PR.

	PR libstdc++/101214

libstdc++-v3/ChangeLog:

	* include/std/ranges (split_view::split_view): Use std::move.
	(split_view::_Iterator::_Iterator): Remove redundant
	default_initializable constraint.
	(split_view::_Sentinel::_Sentinel): Declare.
	* testsuite/std/ranges/adaptors/split.cc (test02): New test.
2021-07-16 09:44:32 -04:00
Marek Polacek
e32234536f c++: Don't hide narrowing errors in system headers
Jonathan pointed me at this issue where

  constexpr unsigned f() { constexpr int n = -1; return unsigned{n}; }

is accepted in system headers, despite the narrowing conversion from
a constant.  I suspect that whereas narrowing warnings should be
disabled, ill-formed narrowing of constants should be a hard error
(which can still be disabled by -Wno-narrowing).

gcc/cp/ChangeLog:

	* typeck2.c (check_narrowing): Don't suppress the pedantic error
	in system headers.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Add
	dg-error.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1y/Wnarrowing2.C: New test.
	* g++.dg/cpp1y/Wnarrowing2.h: New test.
2021-07-16 09:28:37 -04:00
Jonathan Wakely
17855eed7f libstdc++: Fix std::get<T> for std::tuple [PR101427]
The std::get<T> functions relied on deduction failing if more than one
base class existed for the type T.  However the implementation of Core
DR 2303 (in r11-4693) made deduction succeed (and select the
more-derived base class).

This rewrites the implementation of std::get<T> to explicitly check for
more than one occurrence of T in the tuple elements, making it
ill-formed again. Additionally, the large wall of overload resolution
errors described in PR c++/101460 is avoided by making std::get<T> use
__get_helper<I> directly instead of calling std::get<I>, and by adding a
deleted overload of __get_helper<N> for out-of-range N.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/101427
	* include/std/tuple (tuple_element): Improve static_assert text.
	(__get_helper): Add deleted overload.
	(get<i>(tuple<T...>&&), get<i>(const tuple<T...>&&)): Use
	__get_helper directly.
	(__get_helper2): Remove.
	(__find_uniq_type_in_pack): New constexpr helper function.
	(get<T>): Use __find_uniq_type_in_pack and __get_helper instead
	of __get_helper2.
	* testsuite/20_util/tuple/element_access/get_neg.cc: Adjust
	expected errors.
	* testsuite/20_util/tuple/element_access/101427.cc: New test.
2021-07-15 16:25:42 +01:00
Jonathan Wakely
f9c2ce1dae libstdc++: Add noexcept-specifier to basic_string_view(It, End)
This adds a conditional noexcept to the C++20 constructor. The
std::to_address call cannot throw, so only taking the difference of the
two iterators can throw.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/std/string_view (basic_string_view(It, End)): Add
	noexcept-specifier.
	* testsuite/21_strings/basic_string_view/cons/char/range.cc:
	Check noexcept-specifier. Also check construction without CTAD.
2021-07-14 12:23:33 +01:00
Jonathan Wakely
9d4393af9d libstdc++: Constrain std::as_writable_bytes [PR101411]
The std::as_writable_bytes function should be constrained to only accept
writable spans. Currently it can be called but then gives an error in
the function body.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/101411
	* include/std/span (as_writable_bytes): Add requires-clause.
	* testsuite/23_containers/span/101411.cc: New test.
2021-07-12 18:35:27 +01:00
Jonathan Wakely
bc8f0ed704 libstdc++: Revert changes to std::unique_ptr<T[]>::operator[] [PR 101271]
This reverts the changes in r12-1778 which added a noexcept-specifier to
std::unique_ptr<T[]>::operator[], and the changes in r12-1844 which
tried to make it work with incomplete types (for PR 101236).

The noexcept-specifier is not required by the standard, and is causing
regressions, so just remove it.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/101271
	* include/bits/unique_ptr.h (unique_ptr<T[],D>::operator[]):
	Remove noexcept-specifier.
	(unique_ptr<T[],D>::_S_nothrow_deref): Remove.
	* testsuite/20_util/unique_ptr/lwg2762.cc: Remove checks for
	operator[].
2021-07-02 12:15:28 +01:00
Jonathan Wakely
6963c3b9ed libstdc++: Improve Doxygen documentation groups [PR 101258]
This defines some new Doxygen groups for C++17 variable templates and
for the contents of <experimental/type_traits>. By documenting the group
as a whole and adding each template to a group we don't need to document
them individually.

Also mark more internals with "@cond undocumented" so that Doxygen
ignores them by default. Also make Doxygen process <experimental/simd>.

For some reason, many of the class templates in <type_traits> do not
appear in the "Metaprogramming" group. For example, add_cv,
remove_extent, and all the is_xxx_constructible and is_xxx_assignable
traits. For some reason, Doxygen doesn't include them in the group,
despite doing it correctly for other traits in the same header.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/101258
	* doc/doxygen/user.cfg.in (INPUT): Add <experimental/simd>.
	(COLS_IN_ALPHA_INDEX): Remove obsolete tag.
	(PREDEFINED): Add/fix some more macros that need to be expanded.
	* include/bits/random.h: Stop Doxygen from documenting internal
	implementation details.
	* include/bits/random.tcc: Likewise.
	* include/bits/this_thread_sleep.h: Fix @file name.
	* include/experimental/bits/simd.h: Add to Doxygen group. Do not
	document internal implementation details.
	* include/experimental/bits/simd_detail.h: Do not document
	internal implementation details.
	* include/experimental/simd: Define Doxygen groups.
	* include/experimental/type_traits: Improve documentation for
	the header file. Define groups. Use @since commands.
	* include/std/scoped_allocator (scoped_allocator_adaptor): Move
	declaration before undocumented region.
	* include/std/type_traits (true_type, false_type): Use using
	declaration instead of typedef.
	(is_invocable_v, is_nothrow_invocable_v, is_invocable_r_v)
	(is_nothrow_invocable_r_v): Move definitions next to other C++17
	variable templates.
	Do not document internal implementation details. Move misplaced
	group-end command. Define group for variable templates.
	* include/std/variant: Do not document internal implementation
	details.
	* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error
	line number.
2021-07-01 00:25:46 +01:00
Jonathan Wakely
996be6b670 libstdc++: Suppress redundant definitions of static members in <random>
Since C++17 the static members of the random number engines are
implicitly inline, so don't need definitions.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/random.tcc [__cpp_inline_variables]: Remove
	redundant definitions of static constexpr member variables.
	* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error
	line number.
2021-07-01 00:15:29 +01:00
Jonathan Wakely
75f948f089 libstdc++: Fix backwards logic in 17_intro/names.cc test [PR 97088]
I meant to undef the names that clash with newlib headers for newlib,
but I only undef'd them for non-newlib targets. This means they still
cause errors for newlib, and aren't tested for other targets.

This fixes the test to check those names for non-newlib targets, and to
undef them to avoid errors for newlib.

libstdc++-v3/ChangeLog:

	PR libstdc++/97088
	* testsuite/17_intro/names.cc: Fix #if condition for names used
	by newlib headers.
2021-06-28 15:15:16 +01:00
Jonathan Wakely
b7a89c041a libstdc++: Allow unique_ptr<Incomplete[]>::operator[] [PR 101236]
PR libstdc++/101236 shows that LLVM depends on being able to use
unique_ptr<T[]>::operator[] when T is incomplete. This is undefined, but
previously worked with libstdc++. When I added the conditional noexcept
to that operator we started to diagnose the incomplete type.

This change restores support for that case, by making the noexcept
condition check that the type is complete before checking whether
indexing on the pointer can throw.  A workaround for PR c++/101239 is
needed to avoid a bogus error where G++ fails to do SFINAE on the
ill-formed p[n] expression and gets an ICE. Instead of checking that the
p[n] expression is valid in the trailing-return-type, we only check that
the element_type is complete.

libstdc++-v3/ChangeLog:

	PR libstdc++/101236
	* include/bits/unique_ptr.h (unique_ptr<T[], D>::operator[]):
	Fail gracefully if element_type is incomplete.
	* testsuite/20_util/unique_ptr/cons/incomplete.cc: Clarify that
	the standard doesn't require this test to work for array types.
	* testsuite/20_util/unique_ptr/lwg2762.cc: Check that incomplete
	types can be used with array specialization.
	* testsuite/20_util/unique_ptr/101236.cc: New test.
2021-06-28 14:20:55 +01:00
Jonathan Wakely
e5c422b7d8 libstdc++: Implement LWG 415 for std::ws
For C++11 std::ws changed to be an unformatted input function, meaning
it constructs a sentry and sets badbit on exceptions.

libstdc++-v3/ChangeLog:

	* doc/xml/manual/intro.xml: Document LWG 415 change.
	* doc/html/manual/bugs.html: Regenerate.
	* include/bits/istream.tcc (ws): Create sentry and catch
	exceptions.
	* testsuite/27_io/basic_istream/ws/char/lwg415.cc: New test.
	* testsuite/27_io/basic_istream/ws/wchar_t/lwg415.cc: New test.
2021-06-28 13:34:49 +01:00
Jonathan Wakely
f8c5b542f6 libstdc++: Implement LWG 581 for std:ostream::flush()
LWG 581 changed ostream::flush() to an unformatted output function for
C++11, but it was never implemented in libstdc++.

libstdc++-v3/ChangeLog:

	* doc/xml/manual/intro.xml: Document LWG 581 change.
	* doc/html/manual/bugs.html: Regenerate.
	* include/bits/basic_ios.tcc: Whitespace.
	* include/bits/ostream.tcc (basic_ostream::flush()): Construct
	sentry.
	* testsuite/27_io/basic_ostream/flush/char/2.cc: Check
	additional cases.
	* testsuite/27_io/basic_ostream/flush/char/exceptions_badbit_throw.cc:
	Likewise.
	* testsuite/27_io/basic_ostream/flush/wchar_t/2.cc: Likewise.
	* testsuite/27_io/basic_ostream/flush/wchar_t/exceptions_badbit_throw.cc:
	Likewise.
2021-06-25 18:47:39 +01:00
Jonathan Wakely
9b6c65c754 libstdc++: Fix exception handling in std::ostream seek functions
N3168 added the requirement that the [ostream.seeks] functions create a
sentry object. Nothing in the requirements of those functions says
anything about catching exceptions and setting badbit.

As well as not catching exceptions, this change results in another
observable behaviour change. Previously seeking on a stream with eofbit
set would work (as long as badbit and failbit weren't set). The
construction of a sentry causes failbit to be set when eofbit is set,
which causes the seek to fail. It is necessary to clear the eofbit
before seeking now.

libstdc++-v3/ChangeLog:

	* include/bits/ostream.tcc (sentry): Only set failbit if badbit
	is set, not if eofbit is set.
	(tellp, seekp, seekp): Create sentry object. Do not set badbit
	on exceptions.
	* testsuite/27_io/basic_ostream/seekp/char/exceptions_badbit_throw.cc:
	Adjust expected behaviour.
	* testsuite/27_io/basic_ostream/seekp/wchar_t/exceptions_badbit_throw.cc:
	Likewise.
	* testsuite/27_io/basic_ostream/tellp/char/exceptions_badbit_throw.cc:
	Likewise.
	* testsuite/27_io/basic_ostream/tellp/wchar_t/exceptions_badbit_throw.cc:
	Likewise.
	* testsuite/27_io/basic_ostream/seekp/char/n3168.cc: New test.
	* testsuite/27_io/basic_ostream/seekp/wchar_t/n3168.cc: New test.
	* testsuite/27_io/basic_ostream/tellp/char/n3168.cc: New test.
	* testsuite/27_io/basic_ostream/tellp/wchar_t/n3168.cc: New test.
2021-06-25 18:47:23 +01:00
Jonathan Wakely
e83a5a6b68 libstdc++: More workarounds in 17_intro/names.cc test [PR 97088]
Conditionally #undef some more names that are used in system headers.

libstdc++-v3/ChangeLog:

	PR libstdc++/97088
	* testsuite/17_intro/names.cc: Undef more names for newlib and
	also for arm-none-linux-gnueabi.
	* testsuite/experimental/names.cc: Disable PCH.
2021-06-25 18:41:24 +01:00
Matthias Kretz
74ebd1297e libstdc++: Make use of __builtin_bit_cast for simd
The __bit_cast function was a hack to achieve what __builtin_bit_cast
can do, therefore use __builtin_bit_cast if possible. However,
__builtin_bit_cast cannot be used to cast from/to fixed_size_simd, since
it isn't trivially copyable (in the language sense — in principle it
is). Therefore add __proposed::simd_bit_cast to enable the use case
required in the test framework.

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

libstdc++-v3/ChangeLog:

	* include/experimental/bits/simd.h (__bit_cast): Implement via
	__builtin_bit_cast #if available.
	(__proposed::simd_bit_cast): Add overloads for simd and
	simd_mask, which use __builtin_bit_cast (or __bit_cast #if not
	available), which return an object of the requested type with
	the same bits as the argument.
	* include/experimental/bits/simd_math.h: Use simd_bit_cast
	instead of __bit_cast to allow casts to fixed_size_simd.
	(copysign): Remove branch that was only required if __bit_cast
	cannot be constexpr.
	* testsuite/experimental/simd/tests/bits/test_values.h: Switch
	from __bit_cast to __proposed::simd_bit_cast since the former
	will not cast fixed_size objects anymore.
2021-06-25 17:32:13 +02:00
Jonathan Wakely
07ba52849f libstdc++: Fix typos and markdown errors in new simd/README.md
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* testsuite/experimental/simd/README.md: Fix typos.
2021-06-24 14:04:02 +01:00
Jonathan Wakely
17bc3848e0 libstdc++: Implement LWG 2762 for std::unique_ptr::operator*
The LWG issue proposes to add a conditional noexcept-specifier to
std::unique_ptr's dereference operator. The issue is currently in
Tentatively Ready status, but even if it isn't voted into the draft, we
can do it as a conforming extensions. This commit also adds a similar
noexcept-specifier to operator[] for the unique_ptr<T[], D> partial
specialization.

Also ensure that all dereference operators for shared_ptr are noexcept,
and adds tests for the std::optional accessors modified by the issue,
which were already noexcept in our implementation.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/shared_ptr_base.h (__shared_ptr_access::operator[]):
	Add noexcept.
	* include/bits/unique_ptr.h (unique_ptr::operator*): Add
	conditional noexcept as per LWG 2762.
	* testsuite/20_util/shared_ptr/observers/array.cc: Check that
	dereferencing cannot throw.
	* testsuite/20_util/shared_ptr/observers/get.cc: Likewise.
	* testsuite/20_util/optional/observers/lwg2762.cc: New test.
	* testsuite/20_util/unique_ptr/lwg2762.cc: New test.
2021-06-24 14:04:02 +01:00
Patrick Palka
7da4eae3dc c++: excessive instantiation during CTAD [PR101174]
We set DECL_CONTEXT on implicitly generated deduction guides so that
their access is consistent with that of the constructor.  But this
apparently leads to excessive instantiation in some cases, ultimately
because instantiation of a deduction guide should be independent of
instantiation of the resulting class specialization, but setting the
DECL_CONTEXT of the former to the latter breaks this independence.

To fix this, this patch makes push_access_scope handle artificial
deduction guides specifically rather than setting their DECL_CONTEXT
in build_deduction_guide.  We could alternatively make the class
befriend the guide via DECL_BEFRIENDING_CLASSES, but that wouldn't
be a complete fix and would break class-deduction-access3.C below
since friendship isn't transitive.

	PR c++/101174

gcc/cp/ChangeLog:

	* pt.c (push_access_scope): For artificial deduction guides,
	set the access scope to that of the constructor.
	(pop_access_scope): Likewise.
	(build_deduction_guide): Don't set DECL_CONTEXT on the guide.

libstdc++-v3/ChangeLog:

	* testsuite/23_containers/multiset/cons/deduction.cc:
	Uncomment CTAD example that was rejected by this bug.
	* testsuite/23_containers/set/cons/deduction.cc: Likewise.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/class-deduction-access3.C: New test.
	* g++.dg/cpp1z/class-deduction91.C: New test.
2021-06-23 17:23:39 -04:00
Matthias Kretz
8509a50010 libstdc++: Document simd testsuite
Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

libstdc++-v3/ChangeLog:

	* testsuite/experimental/simd/README.md: New file.
2021-06-23 18:29:06 +01:00
Matthias Kretz
848bc05a98 libstdc++: Improve output verbosity options and default
For most uses --quiet was too quiet while the default was too noisy. Now
the default output, if stdout is a tty, shows the last successful test
on the same line. With --percentage it adds a percentage at the start of
the line. --percentage is not default because it requires more resources
and might not be 100% compatible to all environments.
If stdout is not a tty the default is quiet output like for dejagnu.

Additionally, argument parsing now recognizes contracted short options
which is easier to use with e.g. DRIVEROPTS=-pxk.

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

libstdc++-v3/ChangeLog:

	* testsuite/experimental/simd/driver.sh: Rewrite output
	verbosity logic. Add -p/--percentage option. Allow -v/--verbose
	to be used twice. Add -x and -o short options. Parse long
	options with = instead of separating space generically. Parce
	contracted short options. Make unrecognized options an error.
	If same-line output is active, trap on EXIT to increment the
	progress (only with --percentage), erase the line and print the
	current status.
	* testsuite/experimental/simd/generate_makefile.sh: Initialize
	helper files for progress account keeping. Update help target
	for changes to DRIVEROPTS.
2021-06-23 18:29:06 +01:00
Matthias Kretz
15f2669c9d libstdc++: Remove -fno-tree-vrp after PR98834 was resolved
Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

libstdc++-v3/ChangeLog:

	* testsuite/Makefile.am (check-simd): Remove -fno-tree-vrp flag
	and associated warning.
	* testsuite/Makefile.in: Regenerate.
2021-06-23 18:28:59 +01:00
Patrick Palka
3eecc1db4c c++: CTAD and deduction guide selection [PR86439]
During CTAD, we select the best viable deduction guide using
build_new_function_call, which performs overload resolution on the set
of candidate guides and then forms a call to the guide.  As the PR
points out, this latter step is unnecessary and occasionally incorrect
since a call to the selected guide may be ill-formed, or forming the
call may have side effects such as prematurely deducing the type of a {}.

So this patch introduces a specialized subroutine based on
build_new_function_call that stops short of building a call to the
selected function, and makes do_class_deduction use this subroutine
instead.  And since a call is no longer built, do_class_deduction
doesn't need to set tf_decltype or cp_unevaluated_operand anymore.

This change causes us to reject some container CTAD examples in the
libstdc++ testsuite due to deduction failure for {}, which AFAICT is the
correct behavior.  Previously in e.g. the first removed example

  std::map{{std::pair{1, 2.0}, {2, 3.0}, {3, 4.0}}, {}},

the type of the {} would get deduced to less<int> as a side effect of
forming a call to the chosen guide

  template<typename _Key, typename _Tp, typename _Compare = less<_Key>,
           typename _Allocator = allocator<pair<const _Key, _Tp>>>
      map(initializer_list<pair<_Key, _Tp>>,
          _Compare = _Compare(), _Allocator = _Allocator())
      -> map<_Key, _Tp, _Compare, _Allocator>;

which made later overload resolution for the constructor call
unambiguous.  Now, the type of the {} remains undeduced until
constructor overload resolution, and we complain about ambiguity
for the two equally good constructor candidates

  map(initializer_list<value_type>,
      const _Compare& = _Compare(),
      const allocator_type& = allocator_type())

  map(initializer_list<value_type>, const allocator_type&).

This patch fixes these problematic container CTAD examples by giving
the {} an appropriate concrete type.  Two of these adjusted CTAD
examples (one for std::set and one for std::multiset) end up triggering
an unrelated CTAD bug on trunk, PR101174, so these two adjusted examples
are commented out for now.

	PR c++/86439

gcc/cp/ChangeLog:

	* call.c (print_error_for_call_failure): Constify 'args' parameter.
	(perform_dguide_overload_resolution): Define.
	* cp-tree.h: (perform_dguide_overload_resolution): Declare.
	* pt.c (do_class_deduction): Use perform_dguide_overload_resolution
	instead of build_new_function_call.  Don't use tf_decltype or
	set cp_unevaluated_operand.  Remove unnecessary NULL_TREE tests.

libstdc++-v3/ChangeLog:

	* testsuite/23_containers/map/cons/deduction.cc: Replace ambiguous
	CTAD examples.
	* testsuite/23_containers/multimap/cons/deduction.cc: Likewise.
	* testsuite/23_containers/multiset/cons/deduction.cc: Likewise.
	Mention one of the replaced examples is broken due to PR101174.
	* testsuite/23_containers/set/cons/deduction.cc: Likewise.
	* testsuite/23_containers/unordered_map/cons/deduction.cc: Replace
	ambiguous CTAD examples.
	* testsuite/23_containers/unordered_multimap/cons/deduction.cc:
	Likewise.
	* testsuite/23_containers/unordered_multiset/cons/deduction.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/cons/deduction.cc: Likewise.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1z/class-deduction88.C: New test.
	* g++.dg/cpp1z/class-deduction89.C: New test.
	* g++.dg/cpp1z/class-deduction90.C: New test.
2021-06-23 08:24:34 -04:00
Jonathan Wakely
75404109dc libstdc++: Avoid "__lockable" name defined as macro by newlib
libstdc++-v3/ChangeLog:

	* include/std/mutex (__detail::__try_lock_impl): Rename
	parameter to avoid clashing with newlib's __lockable macro.
	(try_lock): Add 'inline' specifier.
	* testsuite/17_intro/names.cc: Add check for __lockable.
	* testsuite/30_threads/try_lock/5.cc: Add options for pthreads.
2021-06-23 11:05:51 +01:00
Jonathan Wakely
c556596119 libstdc++: Simplify std::try_lock and std::lock further
The std::try_lock and std::lock algorithms can use iteration instead of
recursion when all lockables have the same type and can be held by an
array of unique_lock<L> objects.

By making this change to __detail::__try_lock_impl it also benefits
__detail::__lock_impl, which uses it. For std::lock we can just put the
iterative version directly in std::lock, to avoid making any call to
__detail::__lock_impl.

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

Co-authored-by: Matthias Kretz <m.kretz@gsi.de>

libstdc++-v3/ChangeLog:

	* include/std/mutex (lock): Replace recursion with iteration
	when lockables all have the same type.
	(__detail::__try_lock_impl): Likewise. Pass lockables as
	parameters, instead of a tuple. Always lock the first one, and
	recurse for the rest.
	(__detail::__lock_impl): Adjust call to __try_lock_impl.
	(__detail::__try_to_lock): Remove.
	* testsuite/30_threads/lock/3.cc: Check that mutexes are locked.
	* testsuite/30_threads/lock/4.cc: Also test non-heterogeneous
	arguments.
	* testsuite/30_threads/unique_lock/cons/60497.cc: Also check
	std::try_lock.
	* testsuite/30_threads/try_lock/5.cc: New test.
2021-06-22 21:17:25 +01:00
Jonathan Wakely
b5a29741db libstdc++: Remove garbage collection support for C++23 [P2186R2]
This removes the non-functional garbage colection support from <memory>,
as proposed for C++23 by P2186R2.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/std/memory (declare_reachable, undeclare_reachable)
	(declare_no_pointers, undeclare_no_pointers, get_pointer_safety)
	(pointer_safety): Only define for C++11 to C++20 inclusive.
	* testsuite/20_util/pointer_safety/1.cc: Do not run for C++23.
2021-06-22 20:58:43 +01:00
Jonathan Wakely
6c63cb231e libstdc++: Implement LWG 3422 for std::seed_seq
This ensures that the std::seed_seq initializer-list constructor will
not be used for list-initialization unless the initializers in the list
are integers. This allows list-initialization syntax to be used with a
pair of pointers and for that to use the appropriate constructor.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/random.h (seed_seq): Constrain initializer-list
	constructor.
	* include/bits/random.tcc (seed_seq): Add template parameter.
	* testsuite/26_numerics/random/seed_seq/cons/default.cc: Check
	for noexcept.
	* testsuite/26_numerics/random/seed_seq/cons/initlist.cc: Check
	constraints.
2021-06-22 20:58:25 +01:00
Thomas Rodgers
e02840c1a9 libstdc++: Fix for deadlock in std::counting_semaphore [PR100806]
libstdc++-v3/ChangeLog:
	PR libstdc++/100806
	* include/bits/semaphore_base.h (__atomic_semaphore::_M_release):
	Force _M_release() to wake all waiting threads.
	* testsuite/30_threads/semaphore/100806.cc: New test.
2021-06-22 11:06:07 -07:00
Patrick Palka
69d80f0f2f libstdc++: Implement new views::split as per P2210
This implements the new views::split from P2210R2 "Superior String
Splitting".

libstdc++-v3/ChangeLog:

	* include/std/ranges (__non_propagating_cache::operator bool):
	Define for split_view::begin().
	(split_view): Define as per P2210.
	(views::__detail::__can_split_view): Define.
	(views::_Split, views::split): Define.
	* testsuite/std/ranges/adaptors/100577.cc (test01, test02):
	Test views::split.
	* testsuite/std/ranges/adaptors/split.cc: New test.
	* testsuite/std/ranges/p2325.cc (test08a): New test.
	* testsuite/std/ranges/p2367.cc (test01): Test views::split.
2021-06-20 12:47:18 -04:00
Patrick Palka
adbd2c7102 libstdc++: Implement P2210 changes to rename views::split to lazy_split
This mostly mechanical patch renames split to lazy_split throughout.

libstdc++-v3/ChangeLog:

	* include/std/ranges: Rename views::split to views::lazy_split,
	split_view to lazy_split_view, etc. throughout.
	* testsuite/std/ranges/*: Likewise.
2021-06-20 12:41:42 -04:00
Patrick Palka
3f631671f1 libstdc++: Implement P2210 changes to split_view resolving LWG 3478
This implements the part of P2210R2 "Superior String Splitting" that
resolves LWG 3478.

libstdc++-v3/ChangeLog:

	* include/std/ranges (split_view::_OuterIter::__at_end):
	Check _M_trailing_empty.
	(split_view::_OuterIter::_M_trailing_empty): Define this
	data member.
	(split_view::_OuterIter::operator++): Set _M_trailing_empty
	appropriately.
	(split_view::_OuterIter::operator==): Compare
	_M_trailing_empty.
	* testsuite/std/ranges/adaptors/100479.cc (test03): Expect two
	split parts instead of one.
	* testsuite/std/ranges/adaptors/split.cc (test11): New test.
2021-06-20 12:38:43 -04:00
Patrick Palka
cc9c94d43d libstdc++: Reduce ranges::minmax/minmax_element comparison complexity
This rewrites ranges::minmax and ranges::minmax_element so that it
performs at most 3*N/2 many comparisons, as required by the standard.
In passing, this also fixes PR100387 by avoiding a premature std::move
in ranges::minmax and in std::shift_right.

	PR libstdc++/100387

libstdc++-v3/ChangeLog:

	* include/bits/ranges_algo.h (__minmax_fn::operator()): Rewrite
	to limit comparison complexity to 3*N/2.
	(__minmax_element_fn::operator()): Likewise.
	(shift_right): Avoid premature std::move of __result.
	* testsuite/25_algorithms/minmax/constrained.cc (test04, test05):
	New tests.
	* testsuite/25_algorithms/minmax_element/constrained.cc (test02):
	Likewise.
2021-06-18 19:33:39 -04:00
Jonathan Wakely
0532452dcd libstdc++: Replace incorrect static assertion in std::reduce [PR95833]
The standard does not require the iterator's value type to be
convertible to the result type, it only requires that the result of
dereferencing the iterator can be passed to the binary function.

libstdc++-v3/ChangeLog:

	PR libstdc++/95833
	* include/std/numeric (reduce(Iter, Iter, T, BinaryOp)): Replace
	incorrect static_assert with ones matching the 'Mandates'
	conditions in the standard.
	* testsuite/26_numerics/reduce/95833.cc: New test.
2021-06-18 14:46:58 +01:00
Jonathan Wakely
92edc4a768 libstdc++: Suppress -Wstringop-overread warning in test
When compiled with -m32 -O2 -D_GLIBCXX_USE_CXX11_ABI=0 we get a warning
for 21_strings/basic_string/cons/char/1.cc:

bits/char_traits.h:409:56: warning: ‘void* __builtin_memcpy(void*, const void*, unsigned int)’ reading 1073741821 bytes from a region of size 19 [-Wstringop-overread]

The warning is legitimate, even if that line cannot be reached because
we throw std::length_error before getting there. Since the invalid
length is deliberate (and mentioned in a comment) just suppress the
warning, so that the test can verify we get the exception.

Also remove an unused typedef that produces another warning.

libstdc++-v3/ChangeLog:

	* testsuite/21_strings/basic_string/cons/char/1.cc: Use
	diagnostic pragma to suppress -Wstringop-overread error.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
2021-06-18 11:15:28 +01:00
Patrick Palka
4b4f5666b4 libstdc++: Implement P2325 changes to default-constructibility of views
This implements the wording changes of P2325R3 "Views should not be
required to be default constructible".  Changes are relatively
straightforward, besides perhaps those to __box (which now stands
for copyable-box instead of semiregular-box) and __non_propagating_cache.

For __box, this patch implements the recommended practice to also avoid
std::optional when the boxed type is nothrow_move/copy_constructible.

For __non_propagating_cache, now that it's used by split_view::_M_current,
we need to add assignment from a value of the underlying type to the
subset of the std::optional API implemented for the cache (needed by
split_view::begin()).  Hence the new __non_propagating_cache::operator=
overload.

In passing, this fixes the undesirable list-init in the constructors of
the partial specialization of __box as reported in PR100475 comment #7.

libstdc++-v3/ChangeLog:

	* include/bits/iterator_concepts.h (weakly_incrementable): Remove
	default_initializable requirement.
	* include/bits/ranges_base.h (ranges::view): Likewise.
	* include/bits/ranges_util.h (subrange): Constrain the default
	ctor.
	* include/bits/stl_iterator.h (back_insert_iterator): Remove the
	default ctor.
	(front_insert_iterator): Likewise.
	(insert_iterator): Likewise.  Remove NSDMIs.
	(common_iterator): Constrain the default ctor.
	(counted_iterator): Likewise.
	* include/bits/stream_iterator.h (ostream_iterator): Remove the
	default ctor.
	* include/std/ranges (__detail::__box::operator=): Handle
	self-assignment in the primary template.
	(__detail::__box): In the partial specialization: adjust
	constraints as per P2325.  Add specialized operator= for the
	case when the wrapped type is not copyable.  Constrain the
	default ctor.  Avoid list-initialization.
	(single_view): Constraint the default ctor.
	(iota_view): Relax semiregular constraint to copyable.
	Constrain the default ctor.
	(iota_view::_Iterator): Constraint the default ctor.
	(basic_istream_view): Remove the default ctor.  Remove NSDMIs.
	Remove redundant checks for empty _M_stream.
	(basic_istream_view::_Iterator): Likewise.
	(ref_view): Remove the default ctor.  Remove NSDMIs.
	(ref_view::_Iterator): Constrain the default ctor.
	(__detail::__non_propagating_cache::operator=): Define overload
	for assigning from a value of the underlying type.
	(filter_view): Likewise.
	(filter_view::_Iterator): Likewise.
	(transform_view): Likewise.
	(transform_view::_Iterator): Likewise.
	(take_view): Likewise.
	(take_view::_Iterator): Likewise.
	(take_while_view): Likewise.
	(take_while_view::_Iterator): Likewise.
	(drop_while_view): Likewise.
	(drop_while_view::_Iterator): Likewise.
	(join_view): Likewise.
	(split_view::_OuterIter::__current): Adjust after changing the
	type of _M_current.
	(split_view::_M_current): Wrap it in a __non_propagating_cache.
	(split_view::split_view): Constrain the default ctor.
	(common_view): Constrain the default ctor.
	(reverse_view): Likewise.
	(elements_view): Likewise.
	* include/std/span (enable_view<span<_ElementType, _Extent>>):
	Define this partial specialization to true unconditionally.
	* include/std/version (__cpp_lib_ranges): Adjust value.
	* testsuite/24_iterators/back_insert_iterator/constexpr.cc:
	Don't attempt to default construct a back_insert_iterator.
	* testsuite/24_iterators/front_insert_iterator/constexpr.cc:
	Don't attempt to default construct a front_insert_iterator.
	* testsuite/24_iterators/insert_iterator/constexpr.cc:
	Don't attempt to default construct an insert_iterator.
	* testsuite/24_iterators/ostream_iterator/requirements/constexpr.cc:
	Remove this test for default constructibility of ostream_iterator.
	* testsuite/std/ranges/97600.cc: Don't attempt to default
	construct a basic_istream_view.
	* testsuite/std/ranges/adaptors/detail/semiregular_box.cc:
	Rename to ...
	* testsuite/std/ranges/adaptors/detail/copyable_box.cc: ... this.
	(test02): Adjust now that __box is copyable-box not
	semiregular-box.
	(test03): New test.
	* testsuite/std/ranges/p2325.cc: New test.
	* testsuite/std/ranges/single_view.cc (test06): New test.
	* testsuite/std/ranges/view.cc: Adjust now that view doesn't
	require default_initializable.
2021-06-17 22:29:03 -04:00
Patrick Palka
2b87f3318c libstdc++: Non-triv-copyable extra args aren't simple [PR100940]
This force-enables perfect forwarding call wrapper semantics whenever
the extra arguments of a partially applied range adaptor aren't all
trivially copyable, so as to avoid incurring unnecessary copies of
potentially expensive-to-copy objects (such as std::function objects)
when invoking the adaptor.

	PR libstdc++/100940

libstdc++-v3/ChangeLog:

	* include/std/ranges (__adaptor::_Partial): For the "simple"
	forwarding partial specializations, also require that
	the extra arguments are trivially copyable.
	* testsuite/std/ranges/adaptors/100577.cc (test04): New test.
2021-06-17 09:46:07 -04:00
Patrick Palka
0f4a2fb44d libstdc++: Refine range adaptors' "simple extra args" mechanism [PR100940]
The _S_has_simple_extra_args mechanism is used to simplify forwarding
of range adaptor's extra arguments when perfect forwarding call wrapper
semantics isn't required for correctness, on a per-adaptor basis.
Both views::take and views::drop are flagged as such, but it turns out
perfect forwarding semantics are needed for these adaptors in some
contrived cases, e.g. when their extra argument is a move-only class
that's implicitly convertible to an integral type.

To fix this, we could just clear the flag for views::take/drop as with
views::split, but that'd come at the cost of acceptable diagnostics
for ill-formed uses of these adaptors (see PR100577).

This patch instead allows adaptors to parameterize their
_S_has_simple_extra_args flag according the types of the captured extra
arguments, so that we could conditionally disable perfect forwarding
semantics only when the types of the extra arguments permit it.  We
then use this finer-grained mechanism to safely disable perfect
forwarding semantics for views::take/drop when the extra argument is
integer-like, rather than incorrectly always disabling it.  Similarly,
for views::split, rather than always enabling perfect forwarding
semantics we now safely disable it when the extra argument is a scalar
or a view, and recover good diagnostics for these common cases.

	PR libstdc++/100940

libstdc++-v3/ChangeLog:

	* include/std/ranges (__adaptor::_RangeAdaptor): Document the
	template form of _S_has_simple_extra_args.
	(__adaptor::__adaptor_has_simple_extra_args): Add _Args template
	parameter pack.  Try to treat _S_has_simple_extra_args as a
	variable template parameterized by _Args.
	(__adaptor::_Partial): Pass _Arg/_Args to the constraint
	__adaptor_has_simple_extra_args.
	(views::_Take::_S_has_simple_extra_args): Templatize according
	to the type of the extra argument.
	(views::_Drop::_S_has_simple_extra_args): Likewise.
	(views::_Split::_S_has_simple_extra_args): Define.
	* testsuite/std/ranges/adaptors/100577.cc (test01, test02):
	Adjust after changes to _S_has_simple_extra_args mechanism.
	(test03): Define.
2021-06-17 09:46:04 -04:00
Jonathan Wakely
b9e35ee6d6 libstdc++: Revert final/non-addressable changes to ranges CPOs
In r12-1489-g8b93548778a487f31f21e0c6afe7e0bde9711fc4 I made the
[range.access] CPO types final and non-addressable. Tim Song pointed out
this is wrong. Only the [range.iter.ops] functions should be final and
non-addressable. Revert the changes to the [range.access] objects.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/ranges_base.h (ranges::begin, ranges::end)
	(ranges::cbegin, ranges::cend, ranges::rbeing, ranges::rend)
	(ranges::crbegin, ranges::crend, ranges::size, ranges::ssize)
	(ranges::empty, ranges::data, ranges::cdata): Remove final
	keywords and deleted operator& overloads.
	* testsuite/24_iterators/customization_points/iter_move.cc: Use
	new is_customization_point_object function.
	* testsuite/24_iterators/customization_points/iter_swap.cc:
	Likewise.
	* testsuite/std/concepts/concepts.lang/concept.swappable/swap.cc:
	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/empty.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/access/size.cc: Likewise.
	* testsuite/std/ranges/access/ssize.cc: Likewise.
	* testsuite/util/testsuite_iterators.h
	(is_customization_point_object): New function.
2021-06-16 14:31:04 +01:00
Jonathan Wakely
8b93548778 libstdc++: Make ranges CPOs final and not addressable
This restricts the API of the CPOs and other function objects so they
cannot be misused by deriving from them or taking their addresses.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/ranges_base.h (ranges::begin, ranges::end)
	(ranges::cbegin, ranges::cend, ranges::rbeing, ranges::rend)
	(ranges::crbegin, ranges::crend, ranges::size, ranges::ssize)
	(ranges::empty, ranges::data, ranges::cdata): Make types final.
	Add deleted operator& overloads.
	(ranges::advance, ranges::distance, ranges::next, ranges::prev):
	Likewise.
	* testsuite/std/ranges/headers/ranges/synopsis.cc: Replace
	ill-formed & expressions with using-declarations. Add checks for
	other function objects.
2021-06-15 18:20:06 +01:00
Jonathan Wakely
9245b0e84c libstdc++: Add noexcept specifiers to some range adaptors
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/ranges_util.h (view_interface): Add noexcept to
	empty, operator bool, data and size members.
	(subrange): Add noexcept to constructors.
	* include/std/ranges (single_view, ref_view): Add noexcept to
	constructors.
	(views::single, views::all): Add noexcept.
	* testsuite/std/ranges/adaptors/all.cc: Check noexcept.
	* testsuite/std/ranges/single_view.cc: Likewise.
2021-06-15 18:20:06 +01:00
Jonathan Wakely
a88fc03ba7 libstdc++: Remove precondition checks from ranges::subrange
The assertion in the subrange constructor causes semantic changes,
because the call to ranges::distance performs additional operations that
are not part of the constructor's specification. That will fail to
compile if the iterator is move-only, because the argument to
ranges::distance is passed by value. It will modify the subrange if the
iterator is not a forward iterator, because incrementing the copy also
affects the _M_begin member. Those problems could be prevented by using
if-constexpr to only do the assertion for copyable forward iterators,
but the call to ranges::distance can also prevent the constructor being
usable in constant expressions. If the member initializers are usable in
constant expressions, but iterator increments of equality comparisons
are not, then the checks done by __glibcxx_assert might
make constant evaluation fail.

This change removes the assertion. Additionally, a new typedef is
introduced to simplify the declarations using __make_unsigned_like_t on
the iterator's difference type.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/ranges_util.h (subrange): Add __size_type typedef
	and use it to simplify declarations.
	(subrange(i, s, n)): Remove assertion.
	* testsuite/std/ranges/subrange/constexpr.cc: New test.
2021-06-15 18:20:06 +01:00
Jonathan Wakely
f9598d89a9 libstdc++: Fix noexcept-specifier for ranges::empty
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/ranges_base.h (ranges::empty): Check whether
	conversion to bool can throw.
	* testsuite/std/ranges/access/empty.cc: Check for correct
	noexcept-specifier.
2021-06-14 23:13:16 +01:00
Jonathan Wakely
c37b5ddcc8 libstdc++: Fix common_reference for non-reference results [PR100894]
The result of COMMON-REF(A&, B&&) where they have no common reference
type should not be a reference. The implementation of COMMON-REF fails
to check that the result is a reference, so is well-formed when it
shouldn't be. This means that common_reference uses that result when it
shouldn't.

The fix is to reject the result of COMMON-REF(A, B) if it's not a
reference, so that common_reference falls through to the next case,
which uses COND-RES, which yields a non-reference result.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/100894
	* include/std/type_traits (__common_ref_impl<X&, Y&>): Only
	use the type if it's a reference.
	* testsuite/20_util/common_reference/100894.cc: New test.
2021-06-14 21:17:53 +01:00
Jonathan Wakely
a40d2293a7 libstdc++: Only run Filesystem TS test if supported
libstdc++-v3/ChangeLog:

	* testsuite/experimental/filesystem/path/native/conv_c++23.cc:
	Add dg-require-filesystem-ts directive.
2021-06-14 15:10:56 +01:00
Jonathan Wakely
14f26c75d2 libstdc++: Fix std::any constraints [PR101034]
PR libstdc++/101034

libstdc++-v3/ChangeLog:

	* include/std/any (any(in_place_t<T>, initializer_list<U>, A&&...))
	(any::emplace<T>(initializer_list<U>, A&&...)): Fix constraint
	to use lvalue.
	* testsuite/20_util/any/cons/101034.cc: New test.
2021-06-14 15:10:56 +01:00
Jonathan Wakely
45fb3d45a4 libstdc++: Add explicit -std=gnu++17 option to test
This test has no -std option so when the testsuite is run with
-std=gnu++20 or later, this test will use that. The recent addition of
no_unique_address will cause it to FAIL, because that's a reserved word
after C++17. Add an explicit option, so that this test alays uses
exactly C++17.

libstdc++-v3/ChangeLog:

	* testsuite/17_intro/headers/c++2017/all_attributes.cc: Add
	-std=gnu++17 option.
2021-06-14 14:04:45 +01:00
Jonathan Wakely
b76a529c09 libstdc++: Implement LWG 3465 for std::compare_partial_order_fallback [PR101056]
libstdc++-v3/ChangeLog:

	PR libstdc++/101056
	* libsupc++/compare (compare_partial_order_fallback): Add
	constraint using reversed parameter order, as per LWG 3465.
	* testsuite/18_support/comparisons/algorithms/fallback.cc:
	Adjust expected result.
2021-06-14 14:04:45 +01:00
Jonathan Wakely
e2c79b968f libstdc++: Change [cmp.alg] assertions to constraints
This moves the same_as<decay_t<_Tp>, decay_t<_Up>> checks from the
[cmp.alg] function bodies into their constraints.

Also add a test for the compare_xxx_order_fallback algorithms.

libstdc++-v3/ChangeLog:

	* libsupc++/compare (__decayed_same_as): New helper concept.
	(strong_order, weak_order, partial_order): Constrain with new
	concept instead of using static_assert.
	(compare_strong_order_fallback, compare_weak_order_fallback)
	(compare_partial_order_fallback): Likewise. Do not deduce return
	types. Remove redundant if-constexpr checks.
	* testsuite/18_support/comparisons/algorithms/fallback.cc: New test.
2021-06-14 14:04:45 +01:00
Jonathan Wakely
917efba2dd libstdc++: Use reserved name for attribute [PR101055]
The no_unique_address attribute is not a reserved name until C++20, so
to use it in C++11/14/17 modes we should use the __no_unique_address_
form. We already use that form when using the attribute, but not in the
__has_cpp_attribute check.

libstdc++-v3/ChangeLog:

	PR libstdc++/101055
	* include/std/tuple: Use reserved form of attribute name.
	* testsuite/17_intro/headers/c++2011/all_attributes.cc: Add
	check for no_unique_address.
	* testsuite/17_intro/headers/c++2014/all_attributes.cc:
	Likewise.
	* testsuite/17_intro/headers/c++2017/all_attributes.cc:
	Likewise.
2021-06-14 11:53:29 +01:00
Jonathan Wakely
1e690757d3 libstdc++: Fix filesystem::path comparisons for C++23
In C++23 there is a basic_string_view(Range&&) constructor, which is
constrained to take a range (specifically, a contiguous_range). When the
filesystem::path comparison operators call lhs.compare(rhs) the overload
taking a string_view is considered, which means checking whether path
satisfies the range concept. That satisfaction result changes depending
whether path::iterator is complete, which is ill-formed; no diagnostic
required. To avoid the problem, this change ensures that the overload
resolution is performed in a context where path::iterator is complete
and the range concept is satisfied. (The result of overload resolution
is always that the compare(const path&) overload is the best match, but
we still have to consider the compare(basic_string_view<value_type>) one
to decide if it even participates in overload resolution).

For std::filesystem::path we can't define the comparison operators later
in the file, because they are hidden friends, so a new helper is
introduced that gets defined when everything else is complete.

For std::experimental::filesystem::path we can just move the definitions
of the comparison operators later in the file.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/fs_path.h (operator==, operator<=>): Use new
	_S_compare function.
	(path::_S_compare): New function to call path::compare in a
	context where path::iterator is complete.
	* include/experimental/bits/fs_path.h (operator<, operator==):
	Define after path::iterator is complete.
	* testsuite/27_io/filesystem/path/native/conv_c++23.cc: New
	test.
	* testsuite/experimental/filesystem/path/native/conv_c++23.cc:
	New test.
2021-06-11 19:18:11 +01:00
Thomas Rodgers
eb3a3bb8ce libstd++: Only support atomic_ref::wait tests which are always lockfree
Fixes a regression on arm32 targets.

libstdc++-v3/ChangeLog:
	* testsuite/29_atomics/atomic_ref/wait_notify.cc: Guard
	test logic with constexpr check for is_always_lock_free.
2021-06-09 13:46:03 -07:00
Jonathan Wakely
b3fce1bd45 libstdc++: Fix constraint on std::optional assignment [PR 100982]
libstdc++-v3/ChangeLog:

	PR libstdc++/100982
	* include/std/optional (optional::operator=(const optional<U>&)):
	Fix value category used in is_assignable check.
	* testsuite/20_util/optional/assignment/100982.cc: New test.
2021-06-09 12:45:11 +01:00
Jonathan Wakely
5bfcfe3087 libstdc++: Add warnings for some C++23 deprecations
LWG 3036 deprecates std::pmr::polymorphic_allocator<T>::destroy in
favour of the equivalent member of std::allocator_traits.

LWG 3170 deprecates std::allocator<T>::is_always_equal in favour of
the equivalent member of std::allocator_traits.

This also updates a comment to note that we support the LWG 3541 change
(even before the issue was opened).

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/allocator.h (allocator::is_always_equal): Deprecate.
	* include/bits/iterator_concepts.h (indirectly_readable_traits):
	Add LWG issue number to comment.
	* include/std/memory_resource (polymorphic_allocator::release):
	Deprecate.
	* testsuite/20_util/allocator/requirements/typedefs.cc: Add
	dg-warning for deprecation. Also check std::allocator<void>.
2021-06-09 10:32:43 +01:00
Thomas Rodgers
25e5ecdf82 libstdc++: Fix Wrong param type in :atomic_ref<_Tp*>::wait [PR100889]
libstdc++-v3/ChangeLog:

	PR libstdc++/100889
	* include/bits/atomic_base.h (atomic_ref<_Tp*>::wait):
	Change parameter type from _Tp to _Tp*.
	* testsuite/29_atomics/atomic_ref/wait_notify.cc: Extend
	coverage of types tested.
2021-06-08 15:55:10 -07:00
Jonathan Wakely
d319517e80 libstdc++: Finish implementing LWG 3413 for propagate_const
We already have conditional noexcept so this just constrains the
non-member swap overload.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/experimental/propagate_const (swap): Constrain.
	* testsuite/experimental/propagate_const/swap/lwg3413.cc: New test.
2021-06-08 15:01:06 +01:00
Jonathan Wakely
adec148117 libstdc++: Constrain three-way comparison for std::optional [PR 98842]
The operator<=>(const optional<T>&, const U&) operator is supposed to be
constrained with three_way_comparable_with<U, T> so that it can only be
used when T and U are weakly-equality-comparable and also three-way
comparable.

Adding that constrain completely breaks std::optional comparisons,
because it causes constraint recursion. To avoid that, an additional
check that U is not a specialization of std::optional is needed. That
appears to be a defect in the standard and should be reported to LWG.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/98842
	* include/std/optional (operator<=>(const optional<T>& const U&)):
	Add missing constraint and add workaround for template
	recursion.
	* testsuite/20_util/optional/relops/three_way.cc: Check that
	type without equality comparison cannot be compared when wrapped
	in std::optional.
2021-06-07 15:45:14 +01:00
Jonathan Wakely
96963713f6 libstdc++: Fix return type of ranges::ssize for 128-bit integer [PR 100824]
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/100824
	* include/bits/ranges_base.h (_SSize): Return signed type.
	* testsuite/std/ranges/access/ssize.cc: Check with __int128.
2021-06-05 11:44:51 +01:00
Jonathan Wakely
621ea10ca0 libstdc++: Implement LWG 3403 for std::ranges::ssize
I already changed the constraints for ranges::ssize to use ranges::size,
this implements the rest of LWG 3403, so that the returned type is the
signed type corresponding to the result of ranges::size.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/ranges_base.h (_SSize): Return the result of
	ranges::size converted to the wider of make-signed-like-t<S> and
	ptrdiff_t, rather than the ranges different type.
	* testsuite/std/ranges/access/ssize.cc: Adjust expected result
	for an iota_view that uses an integer class type for its
	difference_type.
2021-06-04 21:33:59 +01:00
Jonathan Wakely
3e5f2425f8 libstdc++: Fix helper concept for ranges::data [PR 100824]
We need to decay the result of t.data() before checking if it's a
pointer.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/100824
	* include/bits/ranges_base.h (__member_data): Use __decay_copy.
	* testsuite/std/ranges/access/data.cc: Add testcase from PR.
2021-06-04 21:33:53 +01:00
Jonathan Wakely
ee9548b36a libstdc++: Fix value categories used by ranges access CPOs [PR 100824]
The implementation of P2091R0 was incomplete, so that some range access
CPOs used perfect forwarding where they should not. This fixes it by
consistently operating on lvalues.

Some additional changes that are not necessary to fix the bug:

Modify the __as_const helper to simplify its usage. Instead of deducing
the value category from its argument, and requiring callers to forward
the argument as the correct category, add a non-deduced template
parameter which is used for the value category and accept the argument
as an lvalue. This means callers say __as_const<T>(t) instead of
__as_const(std::forward<T>(t)).

Always use an lvalue reference type as the template argument for the
_S_noexcept helpers, so that we only instantiate one specialization for
lvalues and rvalues of the same type.

Move some helper concepts and functions from namespace std::__detail
to ranges::__cust_access, to be consistent with the ranges::begin CPO.
This ensures that the __adl_begin concept and the _Begin::operator()
function are in the same namespace, so unqualified lookup is consistent
and the poison pills for begin are visible to both.

Simplified static assertions for arrays, because the expression a+0 is
already ill-formed for an array of incomplete type.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/100824
	* include/bits/iterator_concepts.h (__detail::__decay_copy)
	(__detail::__member_begin, __detail::__adl_begin): Move to
	namespace ranges::__cust_access.
	(__detail::__ranges_begin): Likewise, and rename to __begin.
	Remove redundant static assertion.
	* include/bits/ranges_base.h (_Begin, _End, _RBegin, _REnd):
	Use lvalue in noexcept specifier.
	(__as_const): Add non-deduced parameter for value category.
	(_CBegin, _CEnd, _CRBegin, _CREnd, _CData): Adjust uses of
	__as_const.
	(__member_size, __adl_size, __member_empty, __size0_empty):
	(__eq_iter_empty, __adl_data): Use lvalue objects in
	requirements.
	(__sentinel_size): Likewise. Add check for conversion to
	unsigned-like.
	(__member_data): Allow non-lvalue types to satisfy the concept,
	but use lvalue object in requirements.
	(_Size, _SSize): Remove forwarding to always use an lvalue.
	(_Data): Likewise. Add static assertion for arrays.
	* testsuite/std/ranges/access/cdata.cc: Adjust expected
	behaviour for rvalues. Add negative tests for ill-formed
	expressions.
	* testsuite/std/ranges/access/data.cc: Likewise.
	* testsuite/std/ranges/access/empty.cc: Adjust expected
	behaviour for rvalues.
	* testsuite/std/ranges/access/size.cc: Likewise.
2021-06-04 15:59:38 +01:00
Jonathan Wakely
f78f25f438 libstdc++: Add feature test macro for heterogeneous lookup in unordered containers
Also update the C++20 status docs.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* doc/xml/manual/status_cxx2020.xml:
	* doc/html/*: Regenerate.
	* include/bits/hashtable.h (__cpp_lib_generic_unordered_lookup):
	Define.
	* include/std/version (__cpp_lib_generic_unordered_lookup):
	Define.
	* testsuite/23_containers/unordered_map/operations/1.cc: Check
	feature test macro.
	* testsuite/23_containers/unordered_set/operations/1.cc:
	Likewise.
2021-06-04 15:59:37 +01:00
Patrick Palka
0614bbbe59 libstdc++: Avoid hard error in ranges::unique_copy [PR100770]
Here, in the constexpr if condition within ranges::unique_copy, when
input_iterator<_Out> isn't satisfied we must avoid substituting into
iter_value_t<_Out> because the latter isn't necessarily well-formed
then.  To that end, this patch factors out the condition into a concept
and uses it throughout.

This patch also makes the definition of our testsuite
output_iterator_wrapper more minimal by setting its value_type, pointer
and reference member types to void.  This means our existing tests for
unique_copy already exercise the fix for this bug, so we don't need
to add another test.  The only other fallout of this testsuite iterator
change appears in std/ranges/range.cc, where the use of range_value_t
on a test_output_range is now ill-formed.

libstdc++-v3/ChangeLog:

	* include/bits/ranges_algo.h (__detail::__can_reread_output):
	Factor out this concept from ...
	(__unique_copy_fn::operator()): ... here.  Use the concept
	throughout.
	* testsuite/std/ranges/range.cc: Remove now ill-formed use
	of range_value_t on an output_range.
	* testsuite/util/testsuite_iterators.h (output_iterator_wrapper):
	Define value_type, pointer and reference member types to void.
2021-06-03 12:30:29 -04:00
Patrick Palka
57ed620ebf libstdc++: Simplify range adaptors' forwarding of bound args [PR100577]
r11-8053 rewrote the range adaptor implementation in conformance with
P2281R1, making partial application act like a SFINAE-friendly perfect
forwarding call wrapper.  Making SFINAE-friendliness coexist with
perfect forwarding here requires adding fallback deleted operator()
overloads (as described in e.g. section 5.5 of P0847R6).  But
unfortunately, as reported in PR100577, this necessary technique of
using of deleted overloads regresses diagnostics for ill-formed calls to
partially applied range adaptors in GCC.

Although GCC's diagnostics can arguably be improved here by having the
compiler explain why the other candidates weren't viable when overload
resolution selects a deleted candidate, we can also largely work around
this on the library side (and achieve more concise diagnostics than by
a frontend-side improvement alone) if we take advantage of the
observation that not all range adaptors need perfect forwarding call
wrapper semantics, in fact only views::split currently needs it, because
all other range adaptors either take no extra arguments or only
arguments that are expected to be freely/cheaply copyable, e.g. function
objects and integer-like types.  (The discussion section in P2281R1 goes
into detail about why views::split is special.)

To that end, this introduces opt-in flags for denoting a range adaptor
as having "simple" extra arguments (in the case of a range adaptor
non-closure) or having a "simple" call operator (in the case of a range
adaptor closure).  These flags are then used to conditionally simplify
the operator() for the generic _Partial and _Pipe class templates, down
from needing three overloads thereof (including one defined as deleted)
to just needing a single overload.  The end result is that diagnostic
quality is restored for all adaptors except for views::split, and
diagnostics for the adaptors are generally made more concise since
there's only a single _Partial/_Pipe overload to diagnose instead of
three of them.

libstdc++-v3/ChangeLog:

	PR libstdc++/100577
	* include/std/ranges (_RangeAdaptorClosure): Document
	_S_has_simple_call_op mechanism.
	(_RangeAdaptor): Document _S_has_simple_extra_args mechanism.
	(__closure_has_simple_call_op): New concept.
	(__adaptor_has_simple_extra_args): Likewise.
	(_Partial<_Adaptor, _Args...>): New partial specialization.
	(_Partial<_Adaptor, _Arg>): Likewise.
	(_Pipe<_Lhs, _Rhs>): Likewise.
	(views::_All::_S_has_simple_call_op): Define to true.
	(views::_Filter::_S_has_simple_extra_args): Likewise.
	(views::_Transform::_S_has_simple_extra_args): Likewise.
	(views::_Take::_S_has_simple_extra_args): Likewise.
	(views::_TakeWhile::_S_has_simple_extra_args): Likewise.
	(views::_Drop::_S_has_simple_extra_args): Likewise.
	(views::_DropWhile::_S_has_simple_extra_args): Likewise.
	(views::_Join::_S_has_simple_call_op): Likewise.
	(views::_Split): Document why we don't define
	_S_has_simple_extra_args to true for this adaptor.
	(views::_Common::_S_has_simple_call_op): Define to true.
	(views::_Reverse::_S_has_simple_call_op): Likewise.
	(views::_Elements::_S_has_simple_call_op): Likewise.
	* testsuite/std/ranges/adaptors/100577.cc: New test.
2021-06-03 09:49:30 -04:00
Jonathan Wakely
f8f0193b5b libstdc++: Value-initialize objects held by EBO helpers [PR 100863]
The allocator, hash function and equality function should all be
value-initialized by the default constructor of an unordered container.
Do it in the EBO helper, so we don't have to get it right in multiple
places.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/100863
	PR libstdc++/65816
	* include/bits/hashtable_policy.h (_Hashtable_ebo_helper):
	Value-initialize subobject.
	* testsuite/23_containers/unordered_map/allocator/default_init.cc:
	Remove XFAIL.
	* testsuite/23_containers/unordered_set/allocator/default_init.cc:
	Remove XFAIL.
2021-06-02 13:33:41 +01:00
Jonathan Wakely
81eab204a5 libstdc++: Fix tests for COW std::string [PR 96088]
The expected number of allocations is different when copying COW
strings.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/96088
	* testsuite/23_containers/unordered_map/96088.cc: Adjust
	expected number of allocations.
	* testsuite/23_containers/unordered_set/96088.cc: Likewise.
2021-06-02 13:33:24 +01:00
Patrick Palka
ac0bc21bd6 c++: value-init vs zero-init in expand_aggr_init_1 [PR65816]
In the case of value-initializing an object of class type T,
[dcl.init.general]/8 says:

  - if T has either no default constructor ([class.default.ctor]) or
    a default constructor that is user-provided or deleted, then the
    object is default-initialized;
  - otherwise, the object is zero-initialized and ...  if T has a
    non-trivial default constructor, the object is default-initialized;

But when determining whether to first zero-initialize the object,
expand_aggr_init_1 incorrectly considers the user-providedness of _all_
constructors rather than only that of the _default_ constructors.  This
causes us to skip the zero-initialization step when the class type has a
defaulted default constructor alongside a user-defined constructor.

It seems the predicate type_has_non_user_provided_default_constructor
accurately captures the above rule for when to first perform a
zero-initialization during value-initialization, so this patch adjusts
expand_aggr_init_1 to use this predicate instead.

	PR c++/65816

gcc/cp/ChangeLog:

	* init.c (expand_aggr_init_1): Check
	type_has_non_user_provided_default_constructor instead of
	type_has_user_provided_constructor.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/constexpr-delegating3.C: New test.
	* g++.dg/cpp0x/dc10.C: New test.
	* g++.dg/cpp0x/initlist-base4.C: New test.
	* g++.dg/cpp2a/constexpr-init22.C: New test.

libstdc++-v3/ChangeLog:

	* testsuite/23_containers/deque/allocator/default_init.cc,
	testsuite/23_containers/forward_list/allocator/default_init.cc,
	testsuite/23_containers/list/allocator/default_init.cc,
	testsuite/23_containers/map/allocator/default_init.cc,
	testsuite/23_containers/set/allocator/default_init.cc,
	testsuite/23_containers/vector/allocator/default_init.cc,
	testsuite/23_containers/vector/bool/allocator/default_init.cc:
	Remove xfail.
2021-06-01 16:21:10 -04:00
Jonathan Wakely
833d348aec libstdc++: Fix effective target for new tests [PR 96088]
These tests use <string_view> so must not run for anything older than
C++17.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* testsuite/23_containers/unordered_map/96088.cc: Change
	effective target to c++17.
	* testsuite/23_containers/unordered_set/96088.cc: Likewise.
2021-06-01 19:09:27 +01:00
Jonathan Wakely
b514fce354 libstdc++: Fix new test for C++98 mode [PR 89728]
The isblank class is not supported until C++11.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* testsuite/22_locale/ctype/is/string/89728_neg.cc: Only test
	isblank for C++11 and later.
2021-06-01 19:02:42 +01:00
Jonathan Wakely
d832629169 libstdc++: Fix return value of std::ranges::advance [PR 100833]
The three-argument form of ranges::advance is supposed to return the
difference between the second argument and the distance the iterator was
advanced. When a non-random-access iterator is not advanced (because it
already equals the sentinel) we were returning 0 rather than n - 0.

libstdc++-v3/ChangeLog:

	PR libstdc++/100833
	* include/bits/ranges_base.h (ranges::advance(iter, n, sentinel)):
	Fix return value for no-op case.
	* testsuite/24_iterators/range_operations/advance.cc: Test
	return values of three-argument overload.
2021-06-01 17:09:06 +01:00
Jonathan Wakely
a49a045b92 libstdc++: Change [range.iter.op] functions to function objects [PR 100768]
The standard specifies std::ranges::distance etc as function templates,
but it also requires them to not be found by ADL, and to suppress ADL
when normal unqualified lookup does find them. That means they need to
be function objects.

libstdc++-v3/ChangeLog:

	PR libstdc++/100768
	* include/bits/ranges_base.h (advance, distance, next, prev):
	Replace function templates with function objects.
	* testsuite/24_iterators/headers/iterator/synopsis_c++20.cc:
	Adjust for changes to function objects.
	* testsuite/std/ranges/adaptors/elements.cc: Add using
	declarations for names from namespace ranges.
	* testsuite/std/ranges/adaptors/transform.cc: Likewise.
	* testsuite/24_iterators/range_operations/100768.cc: New test.
2021-05-26 19:15:34 +01:00
François Dumont
2c43f5ec9d libstdc++: Limit allocation on iterator insertion in Hashtable [PR 96088]
When inserting into unordered_multiset or unordered_multimap first instantiate
the node to store and compute the hash code from it to avoid a potential
intermediate key_type instantiation.

When inserting into unordered_set or unordered_map check if invoking the hash
functor with container key_type is noexcept and invoking the same hash functor
with key part of the iterator value_type can throw. In this case create a
temporary key_type instance at Hashtable level and use it to compute the hash
code. This temporary instance is moved to the final storage location if needed.

libstdc++-v3/ChangeLog:

	PR libstdc++/96088
	* include/bits/hashtable_policy.h (_Select2nd): New.
	(_NodeBuilder<>): New.
	(_ReuseOrAllocNode<>::operator()): Use variadic template args.
	(_AllocNode<>::operator()): Likewise.
	* include/bits/hashtable.h
	(_Hashtable<>::__node_builder_t): New.
	(_Hashtable<>::_M_insert_unique<>(_Kt&&, _Arg&&, const _NodeGenerator&)):
	 New.
	(_Hashtable<>::_S_forward_key): New.
	(_Hashtable<>::_M_insert): Use latter.
	(_Hashtable<>::_M_insert(const_iterator, _Arg&&, const _NodeGenerator&, false_type)):
	Instantiate node first, compute hash code second.
	* testsuite/23_containers/unordered_map/96088.cc: New test.
	* testsuite/23_containers/unordered_multimap/96088.cc: New test.
	* testsuite/23_containers/unordered_multiset/96088.cc: New test.
	* testsuite/23_containers/unordered_set/96088.cc: New test.
	* testsuite/util/replacement_memory_operators.h
	(counter::_M_increment): New.
	(counter::_M_decrement): New.
	(counter::reset()): New.
2021-05-24 21:51:06 +02:00
Patrick Palka
46ed811bcb libstdc++: Fix iterator caching inside range adaptors [PR100479]
This fixes two issues with our iterator caching as described in detail
in the PR.  Since we recently added the __non_propagating_cache class
template as part of r12-336 for P2328, this patch just rewrites the
problematic _CachedPosition partial specialization in terms of this
class template.

For the offset partial specialization, it's safe to propagate the cached
offset on copy/move, but we should still invalidate the cached offset in
the source object on move.

libstdc++-v3/ChangeLog:

	PR libstdc++/100479
	* include/std/ranges (__detail::__non_propagating_cache): Move
	definition up to before that of _CachedPosition.  Make base
	class _Optional_base protected instead of private.  Add const
	overload for operator*.
	(__detail::_CachedPosition): Rewrite the partial specialization
	for forward ranges as a derived class of __non_propagating_cache.
	Remove the size constraint on the partial specialization for
	random access ranges.  Add copy/move/copy-assignment/move-assignment
	members to the offset partial specialization for random
	access ranges that propagate the cached value but additionally
	invalidate it in the source object on move.
	* testsuite/std/ranges/adaptors/100479.cc: New test.
2021-05-24 15:24:44 -04:00
Jonathan Wakely
6fdc59f196 libstdc++: Qualify functions used in tests
These tests rely on ADL for some functions, probably unintentionally.
The calls only work because the iterator wrappers derive from
std::iterator and so namespace std is an associated namespace.

libstdc++-v3/ChangeLog:

	* testsuite/25_algorithms/inplace_merge/constrained.cc: Qualify
	call to ranges::next.
	* testsuite/25_algorithms/is_sorted/constrained.cc: Likewise.
	* testsuite/25_algorithms/is_sorted_until/constrained.cc:
	Likewise.
	* testsuite/25_algorithms/swap_ranges/1.cc: Qualify call to
	swap_ranges.
2021-05-24 18:42:09 +01:00
Patrick Palka
317a38cd46 libstdc++: Fix access issue in iota_view::_Sentinel [PR100690]
libstdc++-v3/ChangeLog:

	PR libstdc++/100690
	* include/std/ranges (iota_view::_Sentinel::_M_distance_from):
	Split out this member function from ...
	(iota_view::_Sentinel::operator-): ... here, for sake of access
	control.
	* testsuite/std/ranges/iota/iota_view.cc (test05): New test.
2021-05-20 23:39:05 -04:00
Jonathan Wakely
6b42b5a8a2 libstdc++: Use __builtin_unreachable for constexpr assertions [PR 100676]
The current implementation of compile-time precondition checks causes
compilation to fail by calling a non-constexpr function declared at
block scope. This breaks the CUDA compiler, which wraps some libstdc++
headers in a pragma that declares everything as a __host__ __device__
function, but others are not wrapped and so everything is a __host__
function. The local declaration thus gets redeclared as two different
types of function, which doesn't work.

Just use __builtin_unreachable to make constant evaluation fail, instead
of the local function declaration. Also simplify the assertion macros,
which has the side effect of giving simpler compilation errors when
using Clang.

libstdc++-v3/ChangeLog:

	PR libstdc++/100676
	* include/bits/c++config (__glibcxx_assert_1): Rename to ...
	(__glibcxx_constexpr_assert): ... this.
	(__glibcxx_assert_impl): Use __glibcxx_constexpr_assert.
	(__glibcxx_assert): Define as either __glibcxx_constexpr_assert
	or __glibcxx_assert_impl.
	(__glibcxx_assert_2): Remove
	* include/debug/macros.h (_GLIBCXX_DEBUG_VERIFY_AT_F): Use
	__glibcxx_constexpr_assert instead of __glibcxx_assert_1.
	* testsuite/21_strings/basic_string_view/element_access/char/back_constexpr_neg.cc:
	Adjust expected error.
	* testsuite/21_strings/basic_string_view/element_access/char/constexpr_neg.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/char/front_constexpr_neg.cc:
	Likewise.
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/back_constexpr_neg.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/constexpr_neg.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/front_constexpr_neg.cc:
	Likewise.
	* testsuite/23_containers/span/back_neg.cc: Likewise.
	* testsuite/23_containers/span/front_neg.cc: Likewise.
	* testsuite/23_containers/span/index_op_neg.cc: Likewise.
2021-05-20 20:49:57 +01:00
Patrick Palka
d5cbe0f0d4 libstdc++: Implement missing P0896R4 changes to reverse_iterator [PR100639]
This implements the P0896R4 changes to reverse_iterator's member types
value_type, difference_type and reference in C++20 mode, which fixes
taking the reverse_iterator of an iterator with a non-integral
difference_type (such as iota_view<long long>).

libstdc++-v3/ChangeLog:

	PR libstdc++/100639
	* include/bits/stl_iterator.h (reverse_iterator::difference_type):
	In C++20 mode, define in terms of iter_difference_t as per P0896R4.
	(reverse_iterator::reference): Likewise, but with iter_reference_t.
	(reverse_iterator::value_type): Likewise, but with iter_value_t.
	* testsuite/std/ranges/adaptors/reverse.cc (test08): New test.
	* testsuite/24_iterators/reverse_iterator/100639.cc: New test.
2021-05-20 14:08:17 -04:00
Joern Rennecke
66c5f24788 libstdc++: Disable floating_to_chars.cc on 16 bit targets
This patch conditionally disables the compilation of floating_to_chars.cc
on 16 bit targets, thus fixing a build failure for these targets as
the POW10_SPLIT_2 array exceeds the maximum object size.

libstdc++-v3/
	PR libstdc++/100361
	* include/std/charconv (to_chars): Hide the overloads for
	floating-point types for 16 bit targets.
	* src/c++17/floating_to_chars.cc: Don't compile for 16 bit targets.
	* testsuite/20_util/to_chars/double.cc: Run this test only on
	size32plus targets.
	* testsuite/20_util/to_chars/float.cc: Likewise.
	* testsuite/20_util/to_chars/long_double.cc: Likewise.
2021-05-20 13:21:41 +01:00
Patrick Palka
38751c4d5e libstdc++: Fix access issue in elements_view::_Sentinel [PR100631]
In the earlier commit r12-854 I forgot to also rewrite the other operator-
overload in terms of the split-out member function _M_distance_from.

libstdc++-v3/ChangeLog:

	PR libstdc++/100631
	* include/std/ranges (elements_view::_Sentinel::operator-): Use
	_M_distance_from in the other operator- overload too.
	* testsuite/std/ranges/adaptors/elements.cc (test06): Augment test.
2021-05-18 10:21:27 -04:00
Thomas Schwinge
03eb779141 Add 'dg-note', 'dg-lto-note'
That's 'dg-message "note: [...]"' with a twist: inhibit default notes pruning,
such that "if 'dg-note' is used at least once in a testcase, [notes] are not
pruned and instead must *all* be handled explicitly".

The rationale is that either you're not interested in notes at all (default
behavior of pruning all notes), but often, when you're interested in one note,
you're in fact interested in all notes, and especially interested if
*additional* notes appear over time, as GCC evolves.

	gcc/testsuite/
	* lib/gcc-dg.exp: Implement 'dg-note'.
	* lib/prune.exp: Likewise.
	* gcc.dg/vect/nodump-vect-opt-info-2.c: Use 'dg-note', and
	'dg-prune-output "note: ".
	* gfortran.dg/goacc/routine-external-level-of-parallelism-2.f: Use
	'dg-note', match up additional notes, one class of them with
	XFAILed 'dg-bogus'.
	* lib/lto.exp: Implement 'dg-lto-note'.
	* g++.dg/lto/odr-1_0.C: Use 'dg-lto-note', match up additional
	notes.
	* g++.dg/lto/odr-1_1.C: Likewise.
	* g++.dg/lto/odr-2_1.C: Likewise.
	libstdc++-v3/
	* testsuite/lib/prune.exp: Add note about 'dg-note'.
	gcc/
	* doc/sourcebuild.texi: Document 'dg-note'.
2021-05-18 12:39:57 +02:00
Patrick Palka
fe993b469c libstdc++: Fix up semiregular-box partial specialization [PR100475]
This makes the in-place constructor of our partial specialization of
__box for already-semiregular types perform direct-non-list-initialization
(in accordance with the specification of the primary template), and
additionally makes the member function data() use std::__addressof.

libstdc++-v3/ChangeLog:

	PR libstdc++/100475
	* include/std/ranges (__box::__box): Use non-list-initialization
	in member initializer list of in-place constructor of the
	partial specialization for semiregular types.
	(__box::operator->): Use std::__addressof.
	* testsuite/std/ranges/adaptors/detail/semiregular_box.cc
	(test02): New test.
	* testsuite/std/ranges/single_view.cc (test04): New test.
2021-05-18 00:28:44 -04:00
Patrick Palka
2e2eef80ac libstdc++: Fix miscellaneous issues with elements_view::_Sentinel [PR100631]
libstdc++-v3/ChangeLog:

	PR libstdc++/100631
	* include/std/ranges (elements_view::_Iterator): Also befriend
	_Sentinel<!_Const>.
	(elements_view::_Sentinel::_M_equal): Templatize.
	(elements_view::_Sentinel::_M_distance_from): Split out from ...
	(elements_view::_Sentinel::operator-): ... here.  Depend on
	_Base2 instead of _Base in the return type.
	* testsuite/std/ranges/adaptors/elements.cc (test06, test07):
	New tests.
2021-05-18 00:26:07 -04:00
Thomas Rodgers
346cbaf578 libstdc++: Fix wrong thread waking on notify [PR100334]
Fixes https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100334

libstdc++-v3/ChangeLog:
	* include/bits/atomic_wait.h (__waiter::_M_do_wait_v): loop
	until value change observed.
	(__waiter_base::_M_laundered): New member.
	(__waiter_base::_M_notify): Check _M_laundered to determine
	whether to wake one or all.
	(__detail::__atomic_compare): Return true if call to
	__builtin_memcmp() == 0.
	(__waiter_base::_S_do_spin_v): Adjust predicate.
	* testsuite/29_atomics/atomic/wait_notify/100334.cc: New
	test.
2021-05-17 12:05:06 -07:00
Jonathan Wakely
45aa7a4476 libstdc++: Fix filesystem::path constraints for volatile [PR 100630]
The constraint check for filesystem::path construction uses
decltype(__is_path_src(declval<Source>())) which mean it considers
conversion from an rvalue.  When Source is a volatile-qualified type
it cannot use is_path_src(const Unknown&) because a const lvalue
reference can only bind to a non-volatile rvalue.

Since the relevant path members all have a const Source& parameter,
the constraint should be defined in terms of declval<const Source&>(),
not declval<Source>(). This avoids the problem of volatile-qualified
rvalues, because we no longer use an rvalue at all.

libstdc++-v3/ChangeLog:

	PR libstdc++/100630
	* include/experimental/bits/fs_path.h (__is_constructible_from):
	Test construction from a const lvalue, not an rvalue.
	* testsuite/27_io/filesystem/path/construct/100630.cc: New test.
	* testsuite/experimental/filesystem/path/construct/100630.cc:
	New test.
2021-05-17 17:58:46 +01:00
Antony Polukhin
fd89fc7763 libstdc++: diagnose some misuses of [locale.convenience] functions [PR 89728]
This patch provides better diagnostics for common misuse of
[locale.convenience] functions with std::string as a character type.

libstdc++-v3/ChangeLog:

	PR libstdc++/89728
	* include/bits/locale_facets.h (ctype<basic_string<C,T,A>>):
	Declare (but do not define) partial specialization.
	* testsuite/22_locale/ctype/is/string/89728_neg.cc: New test.
2021-05-17 17:58:14 +01:00
Jonathan Wakely
60a156ae53 libstdc++: Fix std::jthread assertion and re-enable skipped test
libstdc++-v3/ChangeLog:

	* include/std/thread (jthread::_S_create): Fix static assert
	message.
	* testsuite/30_threads/jthread/95989.cc: Re-enable test.
	* testsuite/30_threads/jthread/jthread.cc: Do not require
	pthread effective target.
	* testsuite/30_threads/jthread/2.cc: Moved to...
	* testsuite/30_threads/jthread/version.cc: ...here.
2021-05-17 17:56:57 +01:00
Jonathan Wakely
d1adbe5c1b libstdc++: Fix some problems in PSTL tests
libstdc++-v3/ChangeLog:

	* testsuite/25_algorithms/pstl/alg_nonmodifying/find_end.cc:
	Increase dg-timeout-factor to 4. Fix -Wunused-parameter
	warnings. Replace bitwise AND with logical AND in loop
	condition.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/search_n.cc:
	Replace bitwise AND with logical AND in loop condition.
	* testsuite/util/pstl/test_utils.h: Remove unused parameter
	names.
2021-05-12 14:51:15 +01:00
Patrick Palka
84b384a16f libstdc++: Remove extern "C" from Ryu sources
floating_to_chars.cc includes the Ryu sources into an anonymous
namespace as a convenient way to give all its symbols internal linkage.
But an entity declared extern "C" always has external linkage even
from within an anonymous namespace, so this trick doesn't work in the
presence of extern "C", and it causes the Ryu function generic_to_chars
to be visible from libstdc++.a.

This patch removes the only use of extern "C" from our local copy of
Ryu along with some declarations for never-defined functions that GCC
now warns about.

libstdc++-v3/ChangeLog:

	* src/c++17/ryu/LOCAL_PATCHES: Update.
	* src/c++17/ryu/ryu_generic_128.h: Remove extern "C".
	Remove declarations for never-defined functions.
	* testsuite/20_util/to_chars/4.cc: New test.
2021-05-11 13:19:46 -04:00
Jonathan Wakely
37407a2ae7 libstdc++: Fix tests that fail in C++98 mode
The header synopsis test fails to define NOTHROW for C++98.

The shared_ptr test should be skipped for C++98.

The debug mode one should work for C++98 too, it just needs to avoid
C++11 syntax that isn't valid in C++98.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/headers/memory/synopsis.cc: Define C++98
	alternative for macro.
	* testsuite/20_util/shared_ptr/creation/99006.cc: Add effective
	target keyword.
	* testsuite/25_algorithms/copy/debug/99402.cc: Avoid C++11
	syntax.
2021-05-11 17:21:08 +01:00
Jonathan Wakely
5e3a1ea3d8 libstdc++: Fix missing members in std::allocator<void>
The changes in 75c6a925da were slightly
incorrect, because the converting constructor should be noexcept, and
the POCMA and is_always_equal traits should still be present in C++20.
This fixes it, and slightly refactors the preprocessor conditions and
order of members. Also add comments explaining things.

The non-standard construct and destroy members added for PR 78052 can be
private if allocator_traits<allocator<void>> is made a friend.

libstdc++-v3/ChangeLog:

	* include/bits/allocator.h (allocator<void>) [C++20]: Add
	missing noexcept to constructor. Restore missing POCMA and
	is_always_equal_traits.
	[C++17]: Make construct and destroy members private and
	declare allocator_traits as a friend.
	* include/bits/memoryfwd.h (allocator_traits): Declare.
	* include/ext/malloc_allocator.h (malloc_allocator::allocate):
	Add nodiscard attribute. Add static assertion for LWG 3307.
	* include/ext/new_allocator.h (new_allocator::allocate): Add
	static assertion for LWG 3307.
	* testsuite/20_util/allocator/void.cc: Check that converting
	constructor is noexcept. Check for propagation traits and
	size_type and difference_type. Check that pointer and
	const_pointer are gone in C++20.
2021-05-11 16:11:01 +01:00
Jonathan Wakely
5edc0c15f1 libstdc++: Implement proposed resolution to LWG 3548
This has been tentatively approved by LWG. The deleter from a unique_ptr
can be moved into the shared_ptr (at least, since LWG 2802). This uses
std::forward<_Del>(__r.get_deleter()) not std::move(__r.get_deleter())
because we don't want to convert the deleter to an rvalue when _Del is
an lvalue reference type.

This also adds a missing is_move_constructible_v<D> constraint to the
shared_ptr(unique_ptr<Y, D>&&) constructor, which is inherited from the
shared_ptr(Y*, D) constructor due to the use of "equivalent to" in the
specified effects.

libstdc++-v3/ChangeLog:

	* include/bits/shared_ptr_base.h (__shared_count(unique_ptr&&)):
	Initialize a non-reference deleter from an rvalue, as per LWG
	3548.
	(__shared_ptr::_UniqCompatible): Add missing constraint.
	* testsuite/20_util/shared_ptr/cons/lwg3548.cc: New test.
	* testsuite/20_util/shared_ptr/cons/unique_ptr_deleter.cc: Check
	constraints.
2021-05-10 21:10:33 +01:00
Jonathan Wakely
0498d2d09a libstdc++: Remove redundant -std=gnu++17 option from remaining tests
GCC defaults to -std=gnu++17 now anyway, and using it explicitly in the
dg-options directive prevents running these tests with different modes
such as -std=c++17 or -std=gnu++20.

libstdc++-v3/ChangeLog:

	* testsuite/17_intro/headers/c++2017/all_attributes.cc: Remove
	-std=gnu++17 from dg-options directive.
	* testsuite/17_intro/headers/c++2017/all_no_exceptions.cc:
	Likewise.
	* testsuite/17_intro/headers/c++2017/all_pedantic_errors.cc:
	Likewise.
	* testsuite/17_intro/headers/c++2017/operator_names.cc:
	Likewise.
	* testsuite/17_intro/headers/c++2017/parallel_mode.cc: Likewise.
	* testsuite/17_intro/headers/c++2017/stdc++.cc: Likewise.
	* testsuite/17_intro/headers/c++2017/stdc++_multiple_inclusion.cc:
	Likewise.
	* testsuite/18_support/aligned_alloc/aligned_alloc.cc: Likewise.
	* testsuite/18_support/byte/81076.cc: Likewise.
	* testsuite/18_support/byte/global_neg.cc: Likewise.
	* testsuite/18_support/byte/ops.cc: Likewise.
	* testsuite/18_support/byte/requirements.cc: Likewise.
	* testsuite/18_support/headers/cfloat/values_c++17.cc: Likewise.
	* testsuite/18_support/launder/1.cc: Likewise.
	* testsuite/18_support/launder/nodiscard.cc: Likewise.
	* testsuite/18_support/launder/requirements.cc: Likewise.
	* testsuite/18_support/launder/requirements_neg.cc: Likewise.
	* testsuite/18_support/new_aligned.cc: Likewise.
	* testsuite/18_support/uncaught_exceptions/uncaught_exceptions.cc:
	Likewise.
	* testsuite/19_diagnostics/error_code/is_error_code_v.cc:
	Likewise.
	* testsuite/19_diagnostics/error_condition/hash.cc: Likewise.
	* testsuite/20_util/addressof/requirements/constexpr.cc:
	Likewise.
	* testsuite/20_util/as_const/1.cc: Likewise.
	* testsuite/20_util/as_const/rvalue_neg.cc: Likewise.
	* testsuite/20_util/bind/83427.cc: Likewise.
	* testsuite/20_util/bind/is_placeholder_v.cc: Likewise.
	* testsuite/20_util/bool_constant/requirements.cc: Likewise.
	* testsuite/20_util/duration/arithmetic/constexpr_c++17.cc:
	Likewise.
	* testsuite/20_util/duration/requirements/treat_as_floating_point_v.cc:
	Likewise.
	* testsuite/20_util/duration_cast/rounding.cc: Likewise.
	* testsuite/20_util/enable_shared_from_this/members/weak_from_this.cc:
	Likewise.
	* testsuite/20_util/from_chars/1_neg.cc: Likewise.
	* testsuite/20_util/from_chars/requirements.cc: Likewise.
	* testsuite/20_util/function/91456.cc: Likewise.
	* testsuite/20_util/function/cons/deduction.cc: Likewise.
	* testsuite/20_util/function_objects/83607.cc: Likewise.
	* testsuite/20_util/function_objects/invoke/59768.cc: Likewise.
	* testsuite/20_util/function_objects/mem_fn/80478.cc: Likewise.
	* testsuite/20_util/function_objects/not_fn/1.cc: Likewise.
	* testsuite/20_util/function_objects/not_fn/87538.cc: Likewise.
	* testsuite/20_util/has_unique_object_representations/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/has_unique_object_representations/requirements/typedefs.cc:
	Likewise.
	* testsuite/20_util/has_unique_object_representations/value.cc:
	Likewise.
	* testsuite/20_util/hash/nullptr.cc: Likewise.
	* testsuite/20_util/in_place/requirements.cc: Likewise.
	* testsuite/20_util/is_aggregate/incomplete_neg.cc: Likewise.
	* testsuite/20_util/is_aggregate/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/is_aggregate/requirements/typedefs.cc:
	Likewise.
	* testsuite/20_util/is_aggregate/value.cc: Likewise.
	* testsuite/20_util/is_invocable/83395.cc: Likewise.
	* testsuite/20_util/is_invocable/91456.cc: Likewise.
	* testsuite/20_util/is_invocable/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/is_invocable/requirements/typedefs.cc:
	Likewise.
	* testsuite/20_util/is_invocable/value.cc: Likewise.
	* testsuite/20_util/is_literal_type/deprecated-1z.cc: Likewise.
	* testsuite/20_util/is_nothrow_constructible/94003.cc: Likewise.
	* testsuite/20_util/is_nothrow_invocable/83395.cc: Likewise.
	* testsuite/20_util/is_nothrow_invocable/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/is_nothrow_invocable/requirements/typedefs.cc: Likewise.
	* testsuite/20_util/is_nothrow_invocable/value.cc: Likewise.
	* testsuite/20_util/is_nothrow_swappable/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/is_nothrow_swappable/requirements/typedefs.cc:
	Likewise.
	* testsuite/20_util/is_nothrow_swappable/value.cc: Likewise.
	* testsuite/20_util/is_nothrow_swappable_with/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/is_nothrow_swappable_with/requirements/typedefs.cc:
	Likewise.
	* testsuite/20_util/is_nothrow_swappable_with/value.cc:
	Likewise.
	* testsuite/20_util/is_swappable/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/is_swappable/requirements/typedefs.cc:
	Likewise.
	* testsuite/20_util/is_swappable/value.cc: Likewise.
	* testsuite/20_util/is_swappable_with/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/is_swappable_with/requirements/typedefs.cc:
	Likewise.
	* testsuite/20_util/is_swappable_with/value.cc: Likewise.
	* testsuite/20_util/logical_traits/83134.cc: Likewise.
	* testsuite/20_util/logical_traits/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/logical_traits/requirements/typedefs.cc:
	Likewise.
	* testsuite/20_util/logical_traits/value.cc: Likewise.
	* testsuite/20_util/pair/cons/deduction.cc: Likewise.
	* testsuite/20_util/pair/swap_cxx17.cc: Likewise.
	* testsuite/20_util/ratio/requirements/ratio_equal_v.cc:
	Likewise.
	* testsuite/20_util/reference_wrapper/83427.cc: Likewise.
	* testsuite/20_util/reference_wrapper/deduction.cc: Likewise.
	* testsuite/20_util/shared_ptr/casts/reinterpret.cc: Likewise.
	* testsuite/20_util/shared_ptr/cons/deduction.cc: Likewise.
	* testsuite/20_util/shared_ptr/requirements/weak_type.cc:
	Likewise.
	* testsuite/20_util/time_point/arithmetic/constexpr.cc:
	Likewise.
	* testsuite/20_util/time_point_cast/rounding.cc: Likewise.
	* testsuite/20_util/to_chars/3.cc: Likewise.
	* testsuite/20_util/to_chars/chars_format.cc: Likewise.
	* testsuite/20_util/to_chars/lwg3266.cc: Likewise.
	* testsuite/20_util/to_chars/requirements.cc: Likewise.
	* testsuite/20_util/tuple/78939.cc: Likewise.
	* testsuite/20_util/tuple/apply/1.cc: Likewise.
	* testsuite/20_util/tuple/apply/2.cc: Likewise.
	* testsuite/20_util/tuple/cons/deduction.cc: Likewise.
	* testsuite/20_util/tuple/make_from_tuple/1.cc: Likewise.
	* testsuite/20_util/tuple/make_from_tuple/2.cc: Likewise.
	* testsuite/20_util/tuple/swap_cxx17.cc: Likewise.
	* testsuite/20_util/tuple/tuple_size_v.cc: Likewise.
	* testsuite/20_util/unique_ptr/cons/deduction_neg.cc: Likewise.
	* testsuite/20_util/uses_allocator/requirements/uses_allocator_v.cc:
	Likewise.
	* testsuite/20_util/variable_templates_for_traits.cc: Likewise.
	* testsuite/20_util/void_t/1.cc: Likewise.
	* testsuite/20_util/weak_ptr/cons/deduction.cc: Likewise.
	* testsuite/24_iterators/container_access.cc: Likewise.
	* testsuite/24_iterators/headers/iterator/range_access_c++17.cc:
	Likewise.
	* testsuite/24_iterators/headers/iterator/synopsis_c++17.cc:
	Likewise.
	* testsuite/24_iterators/range_access/range_access_cpp17.cc:
	Likewise.
	* testsuite/24_iterators/range_access/range_access_cpp17_neg.cc:
	Likewise.
	* testsuite/26_numerics/gcd/gcd_neg.cc: Likewise.
	* testsuite/26_numerics/headers/cmath/functions_std_c++17.cc:
	Likewise.
	* testsuite/26_numerics/headers/cmath/hypot.cc: Likewise.
	* testsuite/26_numerics/headers/cmath/special_functions_global.cc:
	Likewise.
	* testsuite/26_numerics/lcm/1.cc: Likewise.
	* testsuite/26_numerics/lcm/lcm_neg.cc: Likewise.
	* testsuite/26_numerics/valarray/deduction.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_other/char/lwg2221.cc:
	Likewise.
	* testsuite/27_io/manipulators/standard/char/quoted_sv.cc:
	Likewise.
	* testsuite/27_io/manipulators/standard/wchar_t/quoted_sv.cc:
	Likewise.
	* testsuite/27_io/types/4.cc: Likewise.
	* testsuite/28_regex/basic_regex/ctors/deduction.cc: Likewise.
	* testsuite/libstdc++-prettyprinters/91997.cc: Likewise.
	* testsuite/libstdc++-prettyprinters/cxx17.cc: Likewise.
2021-05-10 16:22:54 +01:00
Jonathan Wakely
d7b2d92747 libstdc++: Remove redundant -std=gnu++17 option from algorithm tests
GCC defaults to -std=gnu++17 now anyway, and using it explicitly in the
dg-options directive prevents running these tests with different modes
such as -std=c++17 or -std=gnu++20.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/function_objects/searchers.cc: Remove
	-std=gnu++17 from dg-options directive.
	* testsuite/20_util/specialized_algorithms/memory_management_tools/1.cc:
	Likewise.
	* testsuite/20_util/specialized_algorithms/memory_management_tools/destroy_neg.cc:
	Likewise.
	* testsuite/20_util/specialized_algorithms/uninitialized_value_construct/94540.cc:
	Likewise.
	* testsuite/20_util/specialized_algorithms/uninitialized_value_construct/94831.cc:
	Likewise.
	* testsuite/20_util/specialized_algorithms/uninitialized_value_construct_n/94540.cc:
	Likewise.
	* testsuite/20_util/specialized_algorithms/uninitialized_value_construct_n/sizes.cc:
	Likewise.
	* testsuite/20_util/unique_ptr/specialized_algorithms/swap_cxx17.cc:
	Likewise.
	* testsuite/25_algorithms/clamp/1.cc: Likewise.
	* testsuite/25_algorithms/clamp/2.cc: Likewise.
	* testsuite/25_algorithms/clamp/constexpr.cc: Likewise.
	* testsuite/25_algorithms/clamp/requirements/explicit_instantiation/1.cc:
	Likewise.
	* testsuite/25_algorithms/clamp/requirements/explicit_instantiation/pod.cc:
	Likewise.
	* testsuite/25_algorithms/for_each/for_each_n.cc: Likewise.
	* testsuite/25_algorithms/for_each/for_each_n_debug.cc:
	Likewise.
	* testsuite/25_algorithms/sample/1.cc: Likewise.
	* testsuite/25_algorithms/sample/2.cc: Likewise.
	* testsuite/25_algorithms/sample/3.cc: Likewise.
	* testsuite/25_algorithms/sample/81221.cc: Likewise.
	* testsuite/25_algorithms/search/searcher.cc: Likewise.
	* testsuite/26_numerics/exclusive_scan/1.cc: Likewise.
	* testsuite/26_numerics/inclusive_scan/1.cc: Likewise.
	* testsuite/26_numerics/reduce/1.cc: Likewise.
	* testsuite/26_numerics/reduce/2.cc: Likewise.
	* testsuite/26_numerics/transform_exclusive_scan/1.cc: Likewise.
	* testsuite/26_numerics/transform_inclusive_scan/1.cc: Likewise.
	* testsuite/26_numerics/transform_reduce/1.cc: Likewise.
2021-05-10 16:22:54 +01:00
Jonathan Wakely
7c85abec76 libstdc++: Remove redundant -std=gnu++17 option from containers tests
GCC defaults to -std=gnu++17 now anyway, and using it explicitly in the
dg-options directive prevents running these tests with different modes
such as -std=c++17 or -std=gnu++20.

libstdc++-v3/ChangeLog:

	* testsuite/23_containers/array/cons/deduction.cc: Remove
	-std=gnu++17 from dg-options directive.
	* testsuite/23_containers/array/cons/deduction_neg.cc: Likewise.
	* testsuite/23_containers/array/element_access/constexpr_c++17.cc:
	Likewise.
	* testsuite/23_containers/array/requirements/constexpr_iter.cc:
	Likewise.
	* testsuite/23_containers/array/specialized_algorithms/swap_cxx17.cc:
	Likewise.
	* testsuite/23_containers/deque/cons/deduction.cc: Likewise.
	* testsuite/23_containers/deque/modifiers/emplace/cxx17_return.cc:
	Likewise.
	* testsuite/23_containers/forward_list/cons/deduction.cc:
	Likewise.
	* testsuite/23_containers/forward_list/modifiers/emplace_cxx17_return.cc:
	Likewise.
	* testsuite/23_containers/list/cons/deduction.cc: Likewise.
	* testsuite/23_containers/list/modifiers/emplace/cxx17_return.cc:
	Likewise.
	* testsuite/23_containers/map/cons/deduction.cc: Likewise.
	* testsuite/23_containers/map/modifiers/extract.cc: Likewise.
	* testsuite/23_containers/map/modifiers/insert/83226.cc:
	Likewise.
	* testsuite/23_containers/map/modifiers/insert_or_assign/1.cc:
	Likewise.
	* testsuite/23_containers/map/modifiers/merge.cc: Likewise.
	* testsuite/23_containers/map/modifiers/try_emplace/1.cc:
	Likewise.
	* testsuite/23_containers/multimap/cons/deduction.cc: Likewise.
	* testsuite/23_containers/multimap/modifiers/extract.cc:
	Likewise.
	* testsuite/23_containers/multimap/modifiers/merge.cc: Likewise.
	* testsuite/23_containers/multiset/cons/deduction.cc: Likewise.
	* testsuite/23_containers/multiset/modifiers/extract.cc:
	Likewise.
	* testsuite/23_containers/multiset/modifiers/merge.cc: Likewise.
	* testsuite/23_containers/priority_queue/deduction.cc: Likewise.
	* testsuite/23_containers/queue/deduction.cc: Likewise.
	* testsuite/23_containers/queue/members/emplace_cxx17_return.cc:
	Likewise.
	* testsuite/23_containers/set/cons/deduction.cc: Likewise.
	* testsuite/23_containers/set/modifiers/extract.cc: Likewise.
	* testsuite/23_containers/set/modifiers/merge.cc: Likewise.
	* testsuite/23_containers/set/modifiers/node_swap.cc: Likewise.
	* testsuite/23_containers/stack/deduction.cc: Likewise.
	* testsuite/23_containers/stack/members/emplace_cxx17_return.cc:
	Likewise.
	* testsuite/23_containers/unordered_map/cons/deduction.cc:
	Likewise.
	* testsuite/23_containers/unordered_map/modifiers/extract.cc:
	Likewise.
	* testsuite/23_containers/unordered_map/modifiers/insert_or_assign.cc:
	Likewise.
	* testsuite/23_containers/unordered_map/modifiers/merge.cc:
	Likewise.
	* testsuite/23_containers/unordered_map/modifiers/try_emplace.cc:
	Likewise.
	* testsuite/23_containers/unordered_multimap/cons/deduction.cc:
	Likewise.
	* testsuite/23_containers/unordered_multimap/modifiers/extract.cc:
	Likewise.
	* testsuite/23_containers/unordered_multimap/modifiers/merge.cc:
	Likewise.
	* testsuite/23_containers/unordered_multiset/cons/deduction.cc:
	Likewise.
	* testsuite/23_containers/unordered_multiset/modifiers/extract.cc:
	Likewise.
	* testsuite/23_containers/unordered_multiset/modifiers/merge.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/cons/deduction.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/modifiers/extract.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/modifiers/merge.cc:
	Likewise.
	* testsuite/23_containers/vector/bool/emplace_cxx17_return.cc:
	Likewise.
	* testsuite/23_containers/vector/cons/89164_c++17.cc: Likewise.
	* testsuite/23_containers/vector/cons/deduction.cc: Likewise.
	* testsuite/23_containers/vector/modifiers/emplace/cxx17_return.cc:
	Likewise.
2021-05-10 16:22:53 +01:00
Jonathan Wakely
8087e70267 libstdc++: Remove redundant -std=gnu++17 option from strings tests
GCC defaults to -std=gnu++17 now anyway, and using it explicitly in the
dg-options directive prevents running these tests with different modes
such as -std=c++17 or -std=gnu++20.

libstdc++-v3/ChangeLog:

	* testsuite/21_strings/basic_string/79162.cc: Remove
	-std=gnu++17 from dg-options directive.
	* testsuite/21_strings/basic_string/cons/char/7.cc: Likewise.
	* testsuite/21_strings/basic_string/cons/char/79162.cc:
	Likewise.
	* testsuite/21_strings/basic_string/cons/char/86138.cc:
	Likewise.
	* testsuite/21_strings/basic_string/cons/char/9.cc: Likewise.
	* testsuite/21_strings/basic_string/cons/char/deduction.cc:
	Likewise.
	* testsuite/21_strings/basic_string/cons/char/moveable2_c++17.cc:
	Likewise.
	* testsuite/21_strings/basic_string/cons/wchar_t/7.cc: Likewise.
	* testsuite/21_strings/basic_string/cons/wchar_t/79162.cc:
	Likewise.
	* testsuite/21_strings/basic_string/cons/wchar_t/86138.cc:
	Likewise.
	* testsuite/21_strings/basic_string/cons/wchar_t/9.cc: Likewise.
	* testsuite/21_strings/basic_string/cons/wchar_t/deduction.cc:
	Likewise.
	* testsuite/21_strings/basic_string/cons/wchar_t/moveable2_c++17.cc:
	Likewise.
	* testsuite/21_strings/basic_string/hash/hash.cc: Likewise.
	* testsuite/21_strings/basic_string/lwg2758.cc: Likewise.
	* testsuite/21_strings/basic_string/lwg2946.cc: Likewise.
	* testsuite/21_strings/basic_string/modifiers/append/char/4.cc:
	Likewise.
	* testsuite/21_strings/basic_string/modifiers/append/wchar_t/4.cc:
	Likewise.
	* testsuite/21_strings/basic_string/modifiers/assign/char/4.cc:
	Likewise.
	* testsuite/21_strings/basic_string/modifiers/assign/wchar_t/4.cc:
	Likewise.
	* testsuite/21_strings/basic_string/modifiers/insert/char/3.cc:
	Likewise.
	* testsuite/21_strings/basic_string/modifiers/insert/wchar_t/3.cc:
	Likewise.
	* testsuite/21_strings/basic_string/modifiers/replace/char/7.cc:
	Likewise.
	* testsuite/21_strings/basic_string/modifiers/replace/wchar_t/7.cc:
	Likewise.
	* testsuite/21_strings/basic_string/operations/compare/char/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string/operations/compare/wchar_t/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string/operations/data/char/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string/operations/data/char/86169.cc:
	Likewise.
	* testsuite/21_strings/basic_string/operations/data/wchar_t/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string/operations/find/char/5.cc:
	Likewise.
	* testsuite/21_strings/basic_string/operations/find/wchar_t/5.cc:
	Likewise.
	* testsuite/21_strings/basic_string/operators/char/5.cc:
	Likewise.
	* testsuite/21_strings/basic_string/operators/wchar_t/5.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/capacity/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/capacity/empty_neg.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/cons/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/cons/char/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/cons/char/3.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/cons/char/nonnull.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/cons/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/cons/wchar_t/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/cons/wchar_t/3.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/cons/wchar_t/nonnull.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/char/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/char/back_constexpr_neg.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/char/constexpr.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/char/constexpr_neg.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/char/empty.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/char/front_back.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/char/front_back_constexpr.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/char/front_constexpr_neg.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/back_constexpr_neg.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/constexpr.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/constexpr_neg.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/empty.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/front_back.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/front_constexpr_neg.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/include.cc: Likewise.
	* testsuite/21_strings/basic_string_view/inserters/94051.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/inserters/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/inserters/char/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/inserters/char/3.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/inserters/pod/10081-out.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/inserters/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/inserters/wchar_t/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/inserters/wchar_t/3.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/literals/types-char8_t.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/literals/types.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/literals/values-char8_t.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/literals/values.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/modifiers/remove_prefix/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/modifiers/remove_suffix/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/modifiers/swap/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/modifiers/swap/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/compare/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/compare/char/13650.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/compare/char/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/compare/char/70483.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/compare/char/nonnull.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/compare/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/compare/wchar_t/13650.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/compare/wchar_t/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/copy/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/copy/char/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/copy/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/copy/wchar_t/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/data/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/data/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/find/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/find/char/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/find/char/3.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/find/char/4.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/find/char/nonnull.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/find/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/find/wchar_t/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/find/wchar_t/3.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/find/wchar_t/4.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/rfind/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/rfind/char/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/rfind/char/3.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/rfind/char/nonnull.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/rfind/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/rfind/wchar_t/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/rfind/wchar_t/3.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/string_conversion/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/substr/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/substr/char/83511.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/substr/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/substr/wchar_t/83511.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operators/char/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operators/char/89446.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operators/wchar_t/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operators/wchar_t/89446.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/range_access/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/range_access/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char16_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char32_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char8_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/wchar_t/1.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/requirements/traits_neg.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/requirements/typedefs.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/typedefs.cc: Likewise.
	* testsuite/21_strings/basic_string_view/types/1.cc: Likewise.
	* testsuite/21_strings/char_traits/requirements/char/99181.cc:
	Likewise.
	* testsuite/21_strings/char_traits/requirements/constexpr_functions_c++17.cc:
2021-05-10 16:22:53 +01:00
Jonathan Wakely
7a4e52e44a libstdc++: Remove redundant -std=gnu++17 option from PMR tests
GCC defaults to -std=gnu++17 now anyway, and using it explicitly in the
dg-options directive prevents running these tests with different modes
such as -std=c++17 or -std=gnu++20.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/memory_resource/1.cc: Remove -std=gnu++17
	from dg-options directive.
	* testsuite/20_util/memory_resource/2.cc: Likewise.
	* testsuite/20_util/monotonic_buffer_resource/1.cc: Likewise.
	* testsuite/20_util/monotonic_buffer_resource/93208.cc:
	Likewise.
	* testsuite/20_util/monotonic_buffer_resource/allocate.cc:
	Likewise.
	* testsuite/20_util/monotonic_buffer_resource/deallocate.cc:
	Likewise.
	* testsuite/20_util/monotonic_buffer_resource/release.cc:
	Likewise.
	* testsuite/20_util/monotonic_buffer_resource/upstream_resource.cc:
	Likewise.
	* testsuite/20_util/polymorphic_allocator/1.cc: Likewise.
	* testsuite/20_util/polymorphic_allocator/construct_pair.cc:
	Likewise.
	* testsuite/20_util/polymorphic_allocator/resource.cc: Likewise.
	* testsuite/20_util/polymorphic_allocator/select.cc: Likewise.
	* testsuite/20_util/synchronized_pool_resource/allocate.cc:
	Likewise.
	* testsuite/20_util/synchronized_pool_resource/allocate_single.cc:
	Likewise.
	* testsuite/20_util/synchronized_pool_resource/cons.cc:
	Likewise.
	* testsuite/20_util/synchronized_pool_resource/cons_single.cc:
	Likewise.
	* testsuite/20_util/synchronized_pool_resource/is_equal.cc:
	Likewise.
	* testsuite/20_util/synchronized_pool_resource/multithreaded.cc:
	Likewise.
	* testsuite/20_util/synchronized_pool_resource/options.cc:
	Likewise.
	* testsuite/20_util/synchronized_pool_resource/release.cc:
	Likewise.
	* testsuite/20_util/synchronized_pool_resource/release_single.cc:
	Likewise.
	* testsuite/20_util/unsynchronized_pool_resource/allocate-max-chunks.cc:
	Likewise.
	* testsuite/20_util/unsynchronized_pool_resource/allocate.cc:
	Likewise.
	* testsuite/20_util/unsynchronized_pool_resource/cons.cc:
	Likewise.
	* testsuite/20_util/unsynchronized_pool_resource/is_equal.cc:
	Likewise.
	* testsuite/20_util/unsynchronized_pool_resource/options.cc:
	Likewise.
	* testsuite/20_util/unsynchronized_pool_resource/release.cc:
	Likewise.
	* testsuite/21_strings/basic_string/types/pmr_typedefs.cc:
	Likewise.
	* testsuite/23_containers/deque/types/pmr_typedefs.cc: Likewise.
	* testsuite/23_containers/deque/types/pmr_typedefs_debug.cc:
	Likewise.
	* testsuite/23_containers/forward_list/pmr_typedefs.cc:
	Likewise.
	* testsuite/23_containers/forward_list/pmr_typedefs_debug.cc:
	Likewise.
	* testsuite/23_containers/list/pmr_typedefs.cc: Likewise.
	* testsuite/23_containers/list/pmr_typedefs_debug.cc: Likewise.
	* testsuite/23_containers/map/pmr_typedefs.cc: Likewise.
	* testsuite/23_containers/map/pmr_typedefs_debug.cc: Likewise.
	* testsuite/23_containers/multimap/pmr_typedefs.cc: Likewise.
	* testsuite/23_containers/multimap/pmr_typedefs_debug.cc:
	Likewise.
	* testsuite/23_containers/multiset/pmr_typedefs.cc: Likewise.
	* testsuite/23_containers/multiset/pmr_typedefs_debug.cc:
	Likewise.
	* testsuite/23_containers/set/pmr_typedefs.cc: Likewise.
	* testsuite/23_containers/set/pmr_typedefs_debug.cc: Likewise.
	* testsuite/23_containers/unordered_map/pmr_typedefs.cc:
	Likewise.
	* testsuite/23_containers/unordered_map/pmr_typedefs_debug.cc:
	Likewise.
	* testsuite/23_containers/unordered_multimap/pmr_typedefs.cc:
	Likewise.
	* testsuite/23_containers/unordered_multimap/pmr_typedefs_debug.cc:
	Likewise.
	* testsuite/23_containers/unordered_multiset/pmr_typedefs.cc:
	Likewise.
	* testsuite/23_containers/unordered_multiset/pmr_typedefs_debug.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/pmr_typedefs.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/pmr_typedefs_debug.cc:
	Likewise.
	* testsuite/23_containers/vector/pmr_typedefs.cc: Likewise.
	* testsuite/23_containers/vector/types/pmr_typedefs_debug.cc:
	Likewise.
	* testsuite/28_regex/match_results/pmr_typedefs.cc: Likewise.
2021-05-10 16:22:53 +01:00
Jonathan Wakely
9cd88c022f libstdc++: Remove redundant -std=gnu++17 option from concurrency tests
GCC defaults to -std=gnu++17 now anyway, and using it explicitly in the
dg-options directive prevents running these tests with different modes
such as -std=c++17 or -std=gnu++20.

libstdc++-v3/ChangeLog:

	* testsuite/29_atomics/atomic/69769.cc: Remove -std=gnu++17 from
	dg-options.
	* testsuite/29_atomics/atomic/is_always_lock_free.cc:
	* testsuite/29_atomics/atomic/requirements/typedefs.cc:
	* testsuite/29_atomics/atomic_integral/is_always_lock_free.cc:
	* testsuite/29_atomics/atomic_integral/requirements/typedefs.cc:
	* testsuite/30_threads/lock_guard/cons/deduction.cc: Likewise.
	* testsuite/30_threads/scoped_lock/cons/1.cc: Likewise.
	* testsuite/30_threads/scoped_lock/cons/deduction.cc: Likewise.
	* testsuite/30_threads/scoped_lock/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/30_threads/scoped_lock/requirements/typedefs.cc:
	Likewise.
	* testsuite/30_threads/shared_lock/70766.cc: Likewise.
	* testsuite/30_threads/shared_mutex/cons/1.cc: Likewise.
	* testsuite/30_threads/shared_mutex/cons/assign_neg.cc:
	Likewise.
	* testsuite/30_threads/shared_mutex/cons/copy_neg.cc: Likewise.
	* testsuite/30_threads/shared_mutex/requirements/standard_layout.cc:
	Likewise.
	* testsuite/30_threads/shared_mutex/try_lock/1.cc: Likewise.
	* testsuite/30_threads/shared_mutex/try_lock/2.cc: Likewise.
	* testsuite/30_threads/shared_mutex/unlock/1.cc: Likewise.
	* testsuite/30_threads/unique_lock/cons/deduction.cc: Likewise.
2021-05-10 16:22:53 +01:00
Jonathan Wakely
8240175b87 libstdc++: Remove redundant -std=gnu++17 option from any/optional/variant tests
GCC defaults to -std=gnu++17 now anyway, and using it explicitly in the
dg-options directive prevents running these tests with different modes
such as -std=c++17 or -std=gnu++20.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/any/assign/1.cc: Remove -std=gnu++17 from
	dg-options directive.
	* testsuite/20_util/any/assign/2.cc: Likewise.
	* testsuite/20_util/any/assign/emplace.cc: Likewise.
	* testsuite/20_util/any/assign/exception.cc: Likewise.
	* testsuite/20_util/any/assign/self.cc: Likewise.
	* testsuite/20_util/any/cons/1.cc: Likewise.
	* testsuite/20_util/any/cons/2.cc: Likewise.
	* testsuite/20_util/any/cons/90415.cc: Likewise.
	* testsuite/20_util/any/cons/92156.cc: Likewise.
	* testsuite/20_util/any/cons/aligned.cc: Likewise.
	* testsuite/20_util/any/cons/explicit.cc: Likewise.
	* testsuite/20_util/any/cons/in_place.cc: Likewise.
	* testsuite/20_util/any/cons/nontrivial.cc: Likewise.
	* testsuite/20_util/any/make_any.cc: Likewise.
	* testsuite/20_util/any/misc/any_cast.cc: Likewise.
	* testsuite/20_util/any/misc/any_cast_neg.cc: Likewise.
	* testsuite/20_util/any/misc/any_cast_no_rtti.cc: Likewise.
	* testsuite/20_util/any/misc/swap.cc: Likewise.
	* testsuite/20_util/any/modifiers/1.cc: Likewise.
	* testsuite/20_util/any/modifiers/83658.cc: Likewise.
	* testsuite/20_util/any/modifiers/92156.cc: Likewise.
	* testsuite/20_util/any/observers/type.cc: Likewise.
	* testsuite/20_util/any/requirements.cc: Likewise.
	* testsuite/20_util/any/typedefs.cc: Likewise.
	* testsuite/20_util/optional/77288.cc: Likewise.
	* testsuite/20_util/optional/84601.cc: Likewise.
	* testsuite/20_util/optional/assignment/1.cc: Likewise.
	* testsuite/20_util/optional/assignment/2.cc: Likewise.
	* testsuite/20_util/optional/assignment/3.cc: Likewise.
	* testsuite/20_util/optional/assignment/4.cc: Likewise.
	* testsuite/20_util/optional/assignment/5.cc: Likewise.
	* testsuite/20_util/optional/assignment/6.cc: Likewise.
	* testsuite/20_util/optional/assignment/7.cc: Likewise.
	* testsuite/20_util/optional/assignment/8.cc: Likewise.
	* testsuite/20_util/optional/assignment/9.cc: Likewise.
	* testsuite/20_util/optional/bad_access.cc: Likewise.
	* testsuite/20_util/optional/cons/77727.cc: Likewise.
	* testsuite/20_util/optional/cons/85642.cc: Likewise.
	* testsuite/20_util/optional/cons/copy.cc: Likewise.
	* testsuite/20_util/optional/cons/deduction.cc: Likewise.
	* testsuite/20_util/optional/cons/default.cc: Likewise.
	* testsuite/20_util/optional/cons/move.cc: Likewise.
	* testsuite/20_util/optional/cons/trivial.cc: Likewise.
	* testsuite/20_util/optional/cons/value.cc: Likewise.
	* testsuite/20_util/optional/cons/value_neg.cc: Likewise.
	* testsuite/20_util/optional/constexpr/cons/default.cc:
	Likewise.
	* testsuite/20_util/optional/constexpr/cons/value.cc: Likewise.
	* testsuite/20_util/optional/constexpr/in_place.cc: Likewise.
	* testsuite/20_util/optional/constexpr/make_optional.cc:
	Likewise.
	* testsuite/20_util/optional/constexpr/nullopt.cc: Likewise.
	* testsuite/20_util/optional/constexpr/observers/1.cc: Likewise.
	* testsuite/20_util/optional/constexpr/observers/2.cc: Likewise.
	* testsuite/20_util/optional/constexpr/observers/3.cc: Likewise.
	* testsuite/20_util/optional/constexpr/observers/4.cc: Likewise.
	* testsuite/20_util/optional/constexpr/observers/5.cc: Likewise.
	* testsuite/20_util/optional/constexpr/relops/1.cc: Likewise.
	* testsuite/20_util/optional/constexpr/relops/2.cc: Likewise.
	* testsuite/20_util/optional/constexpr/relops/3.cc: Likewise.
	* testsuite/20_util/optional/constexpr/relops/4.cc: Likewise.
	* testsuite/20_util/optional/constexpr/relops/5.cc: Likewise.
	* testsuite/20_util/optional/constexpr/relops/6.cc: Likewise.
	* testsuite/20_util/optional/hash.cc: Likewise.
	* testsuite/20_util/optional/in_place.cc: Likewise.
	* testsuite/20_util/optional/make_optional.cc: Likewise.
	* testsuite/20_util/optional/nullopt.cc: Likewise.
	* testsuite/20_util/optional/observers/1.cc: Likewise.
	* testsuite/20_util/optional/observers/2.cc: Likewise.
	* testsuite/20_util/optional/observers/3.cc: Likewise.
	* testsuite/20_util/optional/observers/4.cc: Likewise.
	* testsuite/20_util/optional/observers/5.cc: Likewise.
	* testsuite/20_util/optional/observers/6.cc: Likewise.
	* testsuite/20_util/optional/relops/1.cc: Likewise.
	* testsuite/20_util/optional/relops/2.cc: Likewise.
	* testsuite/20_util/optional/relops/3.cc: Likewise.
	* testsuite/20_util/optional/relops/4.cc: Likewise.
	* testsuite/20_util/optional/relops/5.cc: Likewise.
	* testsuite/20_util/optional/relops/6.cc: Likewise.
	* testsuite/20_util/optional/relops/7.cc: Likewise.
	* testsuite/20_util/optional/requirements.cc: Likewise.
	* testsuite/20_util/optional/swap/1.cc: Likewise.
	* testsuite/20_util/optional/swap/2.cc: Likewise.
	* testsuite/20_util/optional/typedefs.cc: Likewise.
	* testsuite/20_util/variant/80165.cc: Likewise.
	* testsuite/20_util/variant/85183.cc: Likewise.
	* testsuite/20_util/variant/86874.cc: Likewise.
	* testsuite/20_util/variant/87431.cc: Likewise.
	* testsuite/20_util/variant/87619.cc: Likewise.
	* testsuite/20_util/variant/91807.cc: Likewise.
	* testsuite/20_util/variant/any.cc: Likewise.
	* testsuite/20_util/variant/compile.cc: Likewise.
	* testsuite/20_util/variant/deduction.cc: Likewise.
	* testsuite/20_util/variant/exception_safety.cc: Likewise.
	* testsuite/20_util/variant/hash.cc: Likewise.
	* testsuite/20_util/variant/index_type.cc: Likewise.
	* testsuite/20_util/variant/relops/89851.cc: Likewise.
	* testsuite/20_util/variant/relops/90008.cc: Likewise.
	* testsuite/20_util/variant/run.cc: Likewise.
	* testsuite/20_util/variant/visit.cc: Likewise.
2021-05-10 16:22:53 +01:00
Jonathan Wakely
aa60ff1c88 libstdc++: Remove redundant -std=gnu++17 options from filesystem tests
GCC defaults to -std=gnu++17 now anyway, and using it explicitly in the
dg-options directive prevents running these tests with different modes
such as -std=c++17 or -std=gnu++20.

libstdc++-v3/ChangeLog:

	* testsuite/27_io/basic_filebuf/open/char/path.cc: Remove
	-std=gnu++17 from dg-options directive.
	* testsuite/27_io/basic_fstream/cons/char/path.cc: Likewise.
	* testsuite/27_io/basic_fstream/open/char/path.cc: Likewise.
	* testsuite/27_io/basic_ifstream/cons/char/path.cc: Likewise.
	* testsuite/27_io/basic_ifstream/open/char/path.cc: Likewise.
	* testsuite/27_io/basic_ofstream/cons/char/path.cc: Likewise.
	* testsuite/27_io/basic_ofstream/open/char/path.cc: Likewise.
	* testsuite/27_io/filesystem/directory_entry/86597.cc: Likewise.
	* testsuite/27_io/filesystem/directory_entry/lwg3171.cc:
	Likewise.
	* testsuite/27_io/filesystem/file_status/1.cc: Likewise.
	* testsuite/27_io/filesystem/filesystem_error/cons.cc: Likewise.
	* testsuite/27_io/filesystem/filesystem_error/copy.cc: Likewise.
	* testsuite/27_io/filesystem/iterators/91067.cc: Likewise.
	* testsuite/27_io/filesystem/iterators/caching.cc: Likewise.
	* testsuite/27_io/filesystem/iterators/directory_iterator.cc:
	Likewise.
	* testsuite/27_io/filesystem/iterators/pop.cc: Likewise.
	* testsuite/27_io/filesystem/iterators/recursion_pending.cc:
	Likewise.
	* testsuite/27_io/filesystem/iterators/recursive_directory_iterator.cc:
	Likewise.
	* testsuite/27_io/filesystem/operations/absolute.cc: Likewise.
	* testsuite/27_io/filesystem/operations/all.cc: Likewise.
	* testsuite/27_io/filesystem/operations/canonical.cc: Likewise.
	* testsuite/27_io/filesystem/operations/copy.cc: Likewise.
	* testsuite/27_io/filesystem/operations/copy_file.cc: Likewise.
	* testsuite/27_io/filesystem/operations/create_directories.cc:
	Likewise.
	* testsuite/27_io/filesystem/operations/create_directory.cc:
	Likewise.
	* testsuite/27_io/filesystem/operations/create_symlink.cc:
	Likewise.
	* testsuite/27_io/filesystem/operations/current_path.cc:
	Likewise.
	* testsuite/27_io/filesystem/operations/equivalent.cc: Likewise.
	* testsuite/27_io/filesystem/operations/exists.cc: Likewise.
	* testsuite/27_io/filesystem/operations/file_size.cc: Likewise.
	* testsuite/27_io/filesystem/operations/is_empty.cc: Likewise.
	* testsuite/27_io/filesystem/operations/last_write_time.cc:
	Likewise.
	* testsuite/27_io/filesystem/operations/permissions.cc:
	Likewise.
	* testsuite/27_io/filesystem/operations/proximate.cc: Likewise.
	* testsuite/27_io/filesystem/operations/read_symlink.cc:
	Likewise.
	* testsuite/27_io/filesystem/operations/relative.cc: Likewise.
	* testsuite/27_io/filesystem/operations/remove.cc: Likewise.
	* testsuite/27_io/filesystem/operations/remove_all.cc: Likewise.
	* testsuite/27_io/filesystem/operations/rename.cc: Likewise.
	* testsuite/27_io/filesystem/operations/resize_file.cc:
	Likewise.
	* testsuite/27_io/filesystem/operations/space.cc: Likewise.
	* testsuite/27_io/filesystem/operations/status.cc: Likewise.
	* testsuite/27_io/filesystem/operations/symlink_status.cc:
	Likewise.
	* testsuite/27_io/filesystem/operations/temp_directory_path.cc:
	Likewise.
	* testsuite/27_io/filesystem/operations/weakly_canonical.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/append/path.cc: Likewise.
	* testsuite/27_io/filesystem/path/append/source.cc: Likewise.
	* testsuite/27_io/filesystem/path/assign/assign.cc: Likewise.
	* testsuite/27_io/filesystem/path/assign/copy.cc: Likewise.
	* testsuite/27_io/filesystem/path/compare/compare.cc: Likewise.
	* testsuite/27_io/filesystem/path/compare/lwg2936.cc: Likewise.
	* testsuite/27_io/filesystem/path/compare/path.cc: Likewise.
	* testsuite/27_io/filesystem/path/compare/strings.cc: Likewise.
	* testsuite/27_io/filesystem/path/concat/92853.cc: Likewise.
	* testsuite/27_io/filesystem/path/concat/94063.cc: Likewise.
	* testsuite/27_io/filesystem/path/concat/path.cc: Likewise.
	* testsuite/27_io/filesystem/path/concat/strings.cc: Likewise.
	* testsuite/27_io/filesystem/path/construct/80762.cc: Likewise.
	* testsuite/27_io/filesystem/path/construct/90281.cc: Likewise.
	* testsuite/27_io/filesystem/path/construct/90634.cc: Likewise.
	* testsuite/27_io/filesystem/path/construct/copy.cc: Likewise.
	* testsuite/27_io/filesystem/path/construct/default.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/construct/format.cc: Likewise.
	* testsuite/27_io/filesystem/path/construct/locale.cc: Likewise.
	* testsuite/27_io/filesystem/path/construct/range.cc: Likewise.
	* testsuite/27_io/filesystem/path/construct/string_view.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/decompose/extension.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/decompose/filename.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/decompose/parent_path.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/decompose/relative_path.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/decompose/root_directory.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/decompose/root_name.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/decompose/root_path.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/decompose/stem.cc: Likewise.
	* testsuite/27_io/filesystem/path/factory/u8path-char8_t.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/factory/u8path.cc: Likewise.
	* testsuite/27_io/filesystem/path/generation/normal.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/generation/normal2.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/generation/proximate.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/generation/relative.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/generic/94242.cc: Likewise.
	* testsuite/27_io/filesystem/path/generic/generic_string.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/generic/utf.cc: Likewise.
	* testsuite/27_io/filesystem/path/generic/wchar_t.cc: Likewise.
	* testsuite/27_io/filesystem/path/io/dr2989.cc: Likewise.
	* testsuite/27_io/filesystem/path/itr/components.cc: Likewise.
	* testsuite/27_io/filesystem/path/itr/traversal.cc: Likewise.
	* testsuite/27_io/filesystem/path/modifiers/clear.cc: Likewise.
	* testsuite/27_io/filesystem/path/modifiers/make_preferred.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/modifiers/remove_filename.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/modifiers/replace_extension.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/modifiers/replace_filename.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/modifiers/swap.cc: Likewise.
	* testsuite/27_io/filesystem/path/native/alloc.cc: Likewise.
	* testsuite/27_io/filesystem/path/native/string-char8_t.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/native/string.cc: Likewise.
	* testsuite/27_io/filesystem/path/nonmember/append.cc: Likewise.
	* testsuite/27_io/filesystem/path/nonmember/cmp.cc: Likewise.
	* testsuite/27_io/filesystem/path/nonmember/hash_value.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/query/empty.cc: Likewise.
	* testsuite/27_io/filesystem/path/query/empty_neg.cc:
	* testsuite/27_io/filesystem/path/query/has_extension.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/query/has_filename.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/query/has_parent_path.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/query/has_relative_path.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/query/has_root_directory.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/query/has_root_name.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/query/has_root_path.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/query/has_stem.cc: Likewise.
	* testsuite/27_io/filesystem/path/query/is_absolute.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/query/is_relative.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/construct/string_view.cc:
	Likewise.
2021-05-10 16:22:53 +01:00
Jonathan Wakely
646e6c6524 libstdc++: Remove redundant -std=gnu++17 options from PSTL tests
GCC defaults to -std=gnu++17 now anyway, and using it explicitly in the
dg-options directive prevents running these tests with different modes
such as -std=c++17 or -std=gnu++20.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/specialized_algorithms/pstl/uninitialized_construct.cc:
	Remove -std=gnu++17 from dg-options.
	* testsuite/20_util/specialized_algorithms/pstl/uninitialized_copy_move.cc:
	Likewise.
	* testsuite/20_util/specialized_algorithms/pstl/uninitialized_fill_destroy.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/copy_if.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/copy_move.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/fill.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/generate.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/is_partitioned.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/partition.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/partition_copy.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/remove.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/remove_copy.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/replace.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/replace_copy.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/rotate.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/rotate_copy.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/swap_ranges.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/transform_binary.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/transform_unary.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/unique.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/unique_copy_equal.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/adjacent_find.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/all_of.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/any_of.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/count.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/equal.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/find.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/find_end.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/find_first_of.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/find_if.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/for_each.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/mismatch.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/none_of.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/nth_element.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/reverse.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/reverse_copy.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/search_n.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_sorting/includes.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_sorting/is_heap.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_sorting/is_sorted.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_sorting/lexicographical_compare.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_sorting/minmax_element.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/set.cc: Likewise.
	* testsuite/25_algorithms/pstl/alg_sorting/sort.cc: Likewise.
	* testsuite/25_algorithms/pstl/feature_test-2.cc: Likewise.
	* testsuite/25_algorithms/pstl/feature_test-3.cc: Likewise.
	* testsuite/25_algorithms/pstl/feature_test-4.cc: Likewise.
	* testsuite/25_algorithms/pstl/feature_test-5.cc: Likewise.
	* testsuite/25_algorithms/pstl/feature_test.cc: Likewise.
	* testsuite/26_numerics/pstl/numeric_ops/adjacent_difference.cc:
	Likewise.
	* testsuite/26_numerics/pstl/numeric_ops/reduce.cc: Likewise.
	* testsuite/26_numerics/pstl/numeric_ops/scan.cc: Likewise.
	* testsuite/26_numerics/pstl/numeric_ops/transform_reduce.cc:
	Likewise.
	* testsuite/26_numerics/pstl/numeric_ops/transform_scan.cc:
	Likewise.
2021-05-10 16:22:53 +01:00
Jonathan Wakely
23972128c8 libstdc++: Adjust expected errors in tests when compiled as C++20
libstdc++-v3/ChangeLog:

	* testsuite/20_util/scoped_allocator/69293_neg.cc: Add dg-error
	for additional errors in C++20.
	* testsuite/20_util/specialized_algorithms/memory_management_tools/destroy_neg.cc:
	Likewise.
	* testsuite/20_util/uses_allocator/69293_neg.cc: Likewise.
	* testsuite/27_io/filesystem/path/io/dr2989.cc: Likewise.
2021-05-10 15:54:43 +01:00
Jonathan Wakely
2bbacc18b3 libstdc++: Rename test type to avoid clashing with std::any
When PCH are enabled this test file includes <any> and so the
using-directive brings std::any into the global scope. It isn't
currently a problem, because the -std option in the dg-options means
that PCH is not used. If that option is removed, the test fails with PCH
and passes without.

This just renames the type to avoid the name classh (and also the 'none'
type for consistency).

libstdc++-v3/ChangeLog:

	* testsuite/20_util/variant/compile.cc: Rename 'any' to avoid
	clash with std::any.
2021-05-10 15:00:06 +01:00
Jonathan Wakely
a87ceadf17 libstdc++: Fix constraints for rvalue stream insertion/extraction
The __rval_streamable() function was an attempt to test for
convertibility cheaply and without confusing diagnostics. It doesn't
work with Clang though, and is probably ill-formed.

Replace that helper function with a check for derivation from ios_base,
and use that in the alias templates __rvalue_stream_insertion_t and
__rvalue_stream_extraction_t. Use concepts for the constraints when
available.

libstdc++-v3/ChangeLog:

	* include/std/istream (__rvalue_stream_extraction_t): Replace
	use of __rval_streamable.
	* include/std/ostream (__rvalue_stream_insertion_t): Likewise.
	(__rval_streamable): Remove.
	(_Require_derived_from_ios_base, __derived_from_ios_base): New
	helper for checking constraints.
	* testsuite/27_io/basic_istream/extractors_other/char/4.cc: Fix
	reference to the wrong subclause of the standard.
	* testsuite/27_io/basic_istream/extractors_other/wchar_t/4.cc:
	Likewise.
	* testsuite/27_io/basic_ostream/inserters_other/char/6.cc:
	Likewise.
	* testsuite/27_io/basic_ostream/inserters_other/wchar_t/6.cc:
	Likewise.
	* testsuite/27_io/basic_ostream/inserters_other/char/99692.cc:
	New test.
	* testsuite/27_io/filesystem/path/io/dr2989.cc: Adjust pruned
	errors.
2021-05-07 23:45:52 +01:00
Jonathan Wakely
07dd185755 libstdc++: Improve static assert messages
The message used for static assertions should be phrased so that it's
unambiguous whether the condition should be true or false. The message
should definitely not state the negative condition.

libstdc++-v3/ChangeLog:

	* include/bits/stl_algobase.h (__copy_move, __copy_move_backward):
	Improve static_assert messages.
	* testsuite/25_algorithms/copy/58982.cc: Adjust expected output.
	* testsuite/25_algorithms/copy_n/58982.cc: Likewise.
2021-05-06 16:07:10 +01:00
Patrick Palka
08f3287eef libstdc++: Implement LWG 3391 changes to move/counted_iterator::base()
libstdc++-v3/ChangeLog:

	* include/bits/stl_iterator.h (move_iterator::base): Make the
	const& overload unconstrained and return a const reference as
	per LWG 3391.  Make unconditionally noexcept.
	(counted_iterator::base): Likewise.
	* testsuite/24_iterators/move_iterator/lwg3391.cc: New test.
	* testsuite/24_iterators/move_iterator/move_only.cc: Adjust
	has_member_base concept to decay-copy the result of base().
2021-05-06 09:11:42 -04:00
Jonathan Wakely
0e79e63026 libstdc++: Fix definition of std::remove_cvref_t
I originally defined std::remove_cvref_t in terms of the internal
__remove_cvref_t trait, to avoid instantiating the remove_cvref class
template. However, as described in P1715R0 that is observable by users
and is thus non-conforming.

This defines remove_cvref_t as specified in the standard.

libstdc++-v3/ChangeLog:

	* include/std/type_traits (remove_cvref_t): Define in terms of
	remove_cvref.
	* testsuite/20_util/remove_cvref/value.cc: Check alias.
2021-05-06 13:41:15 +01:00
Jonathan Wakely
29745bf062 libstdc++: Add tests for std::invoke feature test macro
libstdc++-v3/ChangeLog:

	* testsuite/20_util/function_objects/invoke/3.cc: Check feature
	test macro.
	* testsuite/20_util/function_objects/invoke/version.cc: New test.
2021-05-05 12:50:45 +01:00
Corentin Gay
523ca6403c ctype support for libstdc++ on VxWorks
for  libstdc++-v3/ChangeLog

	* acinclude.m4: Add VxWorks-specific case for the
	configuration of ctypes.
	* configure: Regenerate.
	* config/locale/vxworks/ctype_members.cc: Add VxWorks-specific
	version.
	* config/os/vxworks/ctype_base.h: Adjust for VxWorks7+.
	* config/os/vxworks/ctype_configure_char.cc: Likewise.
	* config/os/vxworks/ctype_inline.h: Likewise.
	* testsuite/28_regex/traits/char/isctype.cc: Defines
	NEWLINE_IN_CLASS_BLANK if the target is VxWorks.
	* testsuite/28_regex/traits/wchar_t/isctype.cc: Likewise.
2021-05-04 21:49:43 -03:00
Jonathan Wakely
058d6acefe libstdc++: Fix null dereferences in std::promise
This fixes some ubsan errors in std::promise:

future:1153:34: runtime error: member call on null pointer of type 'struct element_type'
future:1153:34: runtime error: member access within null pointer of type 'struct element_type'

The problem is that the check for a null pointer is done inside the
_State::__Setter function, which is only evaluated after evaluating the
_M_future->_M_set_result postfix-expression.

This change adds a new promise::_M_state() helper for accessing
_M_future, and moves the check for no shared state into there, instead
of inside the __setter functions. The __setter functions are made
always_inline, to avoid the situation where the linker selects the old
version of set_value (without the _S_check call) and the new version of
__setter (without the _S_check call) and so there is no check. With the
always_inline attribute the old version of set_value will either inline
the old __setter or call an extern definition of it, and the new
set_value will do the check itself, so both versions do the check.

libstdc++-v3/ChangeLog:

	* include/std/future (promise::set_value): Check for existence
	of shared state before dereferncing it.
	(promise::set_exception, promise::set_value_at_thread_exit)
	(promise::set_exception_at_thread_exit): Likewise.
	(promise<R&>::set_value, promise<R&>::set_exception)
	(promise<R&>::set_value_at_thread_exit)
	(promise<R&>::set_exception_at_thread_exit): Likewise.
	(promise<void>::set_value, promise<void>::set_exception)
	(promise<void>::set_value_at_thread_exit)
	(promise<void>::set_exception_at_thread_exit): Likewise.
	* testsuite/30_threads/promise/members/at_thread_exit2.cc:
	Remove unused variable.
2021-05-04 22:46:24 +01:00
Jonathan Wakely
6fb8b67089 libstdc++ Fix undefined behaviour in testsuite
Fix some test bugs found by ubsan.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/from_chars/3.cc: Use unsigned type to avoid
	overflow.
	* testsuite/24_iterators/reverse_iterator/2.cc: Do not add
	non-zero value to null pointer.
	* testsuite/25_algorithms/copy_backward/move_iterators/69478.cc:
	Use past-the-end iterator for result.
	* testsuite/25_algorithms/move_backward/69478.cc: Likewise.
	* testsuite/25_algorithms/move_backward/93872.cc: Likewise.
2021-05-04 22:34:20 +01:00
Jonathan Wakely
af5b2b911d libstdc++: Do not use deduced return type for std::visit [PR 100384]
This avoids errors outside the immediate context when std::visit is an
overload candidate because of ADL, but not actually viable.

The solution is to give std::visit a non-deduced return type. New
helpers are introduced for that, and existing ones refactored slightly.

libstdc++-v3/ChangeLog:

	PR libstdc++/100384
	* include/std/variant (__get_t): New alias template yielding the
	return type of std::get<N> on a variant.
	(__visit_result_t): New alias template yielding the result of
	std::visit.
	(__same_types): Move into namespace __detail::__variant.
	(__check_visitor_results): Likewise. Use __invoke_result_t and
	__get_t.
	(__check_visitor_result): Remove.
	(visit): Use __visit_result_t for return type.
	* testsuite/20_util/variant/100384.cc: New test.
2021-05-04 12:16:46 +01:00
Patrick Palka
237dde3d03 libstdc++: Implement P2328 changes to join_view
This implements the wording changes of P2328R0 "join_view should join
all views of ranges".

libstdc++-v3/ChangeLog:

	* include/std/ranges (__detail::__non_propating_cache): Define
	as per P2328.
	(join_view): Remove constraints on the value and reference types
	of the wrapped iterator type as per P2328.
	(join_view::_Iterator::_M_satisfy): Adjust as per P2328.
	(join_view::_Iterator::operator++): Likewise.
	(join_view::_M_inner): Use __non_propating_cache as per P2328.
	Remove now-redundant use of __maybe_present_t.
	* testsuite/std/ranges/adaptors/join.cc: Include <array>.
	(test10): New test.
2021-04-30 18:45:46 -04:00
Patrick Palka
6e00d9bb11 libstdc++: Implement P2367 changes to avoid some list-initialization
This implements the wording changes of P2367R0 "Remove misuses of
list-initialization from Clause 24", modulo the parts that depend
on P1739R4 which we don't yet implement (due to LWG 3407).

libstdc++-v3/ChangeLog:

	* include/bits/ranges_util.h (subrange::subrange): Avoid
	list-initialization in delegating constructor.
	* include/std/ranges (single_view): Replace implicit guide
	with explicit deduction guide that decays its argument.
	(_Single::operator()): Avoid CTAD when constructing the
	single_view object.
	(_Iota::operator()): Avoid list-initialization.
	(__detail::__can_filter_view, _Filter::operator()): Likewise.
	(__detail::__can_transform_view, _Transform::operator()): Likewise.
	(take_view::begin): Likewise.
	(__detail::__can_take_view, _Take::operator()): Likewise.
	(__detail::__can_take_while_view, _TakeWhile::operator()): Likewise.
	(__detail::__can_drop_view, _Drop::operator()): Likewise.
	(__detail::__can_drop_while_view, _DropWhile::operator()): Likewise.
	(split_view::split_view): Use views::single when initializing
	_M_pattern.
	(__detail::__can_split_view, _Split::operator()): Avoid
	list-initialization.
	(_Counted::operator()): Likewise.
	* testsuite/std/ranges/p2367.cc: New test.
2021-04-30 10:59:20 -04:00
Jonathan Wakely
aa475c4ac8 libstdc++: Implement LWG 1203 for rvalue iostreams
This implements the resolution of LWG 1203 so that the constraints for
rvalue stream insertion/extraction are simpler, and the return type is
the original rvalue stream type not its base class.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/std/istream (operator>>(Istream&&, x&)): Simplify, as
	per LWG 1203.
	* include/std/ostream (operator<<(Ostream&&, const x&)):
	Likewise.
	* testsuite/27_io/basic_istream/extractors_character/char/lwg2499_neg.cc:
	Adjust dg-error pattern.
	* testsuite/27_io/basic_istream/extractors_character/wchar_t/lwg2499_neg.cc:
	Likewise.
	* testsuite/27_io/basic_istream/extractors_other/char/4.cc: Define
	is_extractable trait to replace std::__is_extractable. Make it
	work with rvalue streams as well as lvalues, to replace f() and
	g() helper functions.
	* testsuite/27_io/basic_istream/extractors_other/wchar_t/4.cc:
	Likewise.
	* testsuite/27_io/basic_ostream/inserters_other/char/6.cc:
	Define is_insertable trait to replace std::__is_insertable. Make
	it work with rvalue streams as well as lvalues, to replace f()
	and g() helper functions.
	* testsuite/27_io/basic_ostream/inserters_other/wchar_t/6.cc:
	Likewise.
	* testsuite/27_io/filesystem/path/io/dr2989.cc: Prune additional
	errors from new constraints.
	* testsuite/27_io/rvalue_streams-2.cc: Remove PR 80675 checks,
	which are no longer expected to compile.
	* testsuite/27_io/rvalue_streams.cc: Adjust existing test.
	Verify LWG 1203 changes.
2021-04-30 14:33:19 +01:00
Jonathan Wakely
0d501c3385 libstdc++: Use <sys/socket.h> features conditionally [PR 100285]
This makes the uses of getsockopt and setsockopt in
<experimental/socket> conditional on the availability of <sys/socket.h>.

It also fixes a test to check for <sys/socket.h> instead of <socket.h>.

libstdc++-v3/ChangeLog:

	PR libstdc++/100285
	* include/experimental/socket (__basic_socket_impl::set_option)
	(__basic_socket_impl::get_option) [!_GLIBCXX_HAVE_SYS_SOCKET_H]:
	Just set error code.
	* testsuite/experimental/net/socket/socket_base.cc: CHeck
	for <sys/socket.h> not <socket.h>.
2021-04-30 14:29:20 +01:00
Jonathan Wakely
57028ff2d3 libstdc++: Define effective-target for net::ip features [PR 100351]
Define a new effective-target keyword so that tests for the Networking
TS <experimental/internet> header can be skipped on targets where none
of it can be usefully defined.

libstdc++-v3/ChangeLog:

	PR libstdc++/100180
	PR libstdc++/100286
	PR libstdc++/100351
	* testsuite/experimental/net/internet/address/v4/comparisons.cc:
	Use new effective-target keyword.
	* testsuite/experimental/net/internet/address/v4/cons.cc:
	Likewise.
	* testsuite/experimental/net/internet/address/v4/creation.cc:
	Likewise.
	* testsuite/experimental/net/internet/address/v4/members.cc:
	Likewise.
	* testsuite/experimental/net/internet/address/v6/members.cc:
	Likewise.
	* testsuite/experimental/net/internet/resolver/base.cc:
	Likewise.
	* testsuite/experimental/net/internet/resolver/ops/lookup.cc:
	Likewise.
	* testsuite/experimental/net/internet/resolver/ops/reverse.cc:
	Likewise.
	* testsuite/experimental/net/internet/socket/opt.cc:
	Likewise.
	* testsuite/experimental/net/internet/tcp.cc:
	Likewise.
	* testsuite/experimental/net/internet/udp.cc:
	Likewise.
	* testsuite/lib/libstdc++.exp (check_effective_target_net_ts_ip):
	New proc to check net_ts_ip et.
2021-04-30 14:25:08 +01:00
Jonathan Wakely
c8767ee9f9 libstdc++: Add testcase for std::pair as a structural type [PR 97930]
This PR was fixed by r12-221-ge1543e694dadf1ea70eb72325219bc0cdc914a35
(for compilers that support C++20 Concepts) so this adds the testcase.

libstdc++-v3/ChangeLog:

	PR libstdc++/97930
	* testsuite/20_util/pair/requirements/structural.cc: New test.
2021-04-28 18:17:40 +01:00
Jonathan Wakely
e1543e694d libstdc++: Simplify std::pair constraints using concepts
This re-implements the constraints on the std::pair constructors and
assignment operators in C++20 mode, to use concepts.

The non-standard constructors deprecated for PR 99957 are no longer
supported in C++20 mode, which requires some minor testsuite changes.
Otherwise all tests pass in C++20 mode.

libstdc++-v3/ChangeLog:

	* include/bits/stl_pair.h (pair) [__cplusplus > 202002]: Add
	new definitions for constructors and assignment operators using
	concepts for constraints.
	* testsuite/20_util/pair/cons/99957.cc: Disable for C++20 and
	later.
	* testsuite/20_util/pair/cons/explicit_construct.cc: Adjust
	expected error messages to also match C++20 errors.
2021-04-28 17:56:51 +01:00
Jonathan Wakely
d96db15967 libstdc++: Deprecate non-standard std::pair constructors [PR 99957]
This deprecates the non-standard std::pair constructors that support
construction from an rvalue and a literal zero used as a null pointer
constant. We can't just add the deprecated attribute to those
constructors, because they're currently used by correct code when they
are a better match than the constructors required by the standard e.g.

  int i = 0;
  const int j = 0;
  std::pair<int, int> p(i, j); // uses pair(U1&&, const int&)

This patch adjusts the parameter types and constraints of those
constructors so that they only get used for literal zeros, and the
pair(U1&&, U2&&) constructor gets used otherwise. Once they're only used
for initializations that should be ill-formed we can add the deprecated
attribute.

The deprecated attribute is used to suggest that the user code uses
nullptr, which avoids the problem of 0 deducing as int instead of a null
pointer constant.

libstdc++-v3/ChangeLog:

	PR libstdc++/99957
	* include/bits/stl_pair.h (_PCC::_MoveCopyPair, _PCC::_CopyMovePair):
	Combine and replace with ...
	(_PCC::_DeprConsPair): New SFINAE helper function.
	(pair): Merge preprocessor blocks so that all C++03 members
	are defined together at the end.
	(pair::pair(const _T1&, _U2&&), pair::pair(_U1&&, const _T2&)):
	Replace _T1 and _T2 parameters with __null_ptr_constant and
	adjust constraints.
	* testsuite/20_util/pair/40925.cc: Use nullptr instead of 0.
	* testsuite/20_util/pair/cons/explicit_construct.cc: Likewise.
	* testsuite/20_util/pair/cons/99957.cc: New test.
2021-04-28 17:56:50 +01:00
Jonathan Wakely
3da80ed7ef libstdc++: Define __cpp_lib_constexpr_string macro
As noted in r11-1339-gb6ab9ecd550227684643b41e9e33a4d3466724d8 we define
a non-standard __cpp_lib_constexpr_char_traits feature test macro to
indicate support for P0426R1 and P1032R1. At some point last year the
__cpp_lib_constexpr_string macro was retconned to indicate support for
those papers. This adds the new macro (which we didn't previously
define, because it referred to P0980R1 "Making std::string constexpr"
which we don't support).

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.h (__cpp_lib_constexpr_string): Define.
	* include/std/version (__cpp_lib_constexpr_string): Define.
	* testsuite/21_strings/char_traits/requirements/constexpr_functions_c++17.cc:
	Check for __cpp_lib_constexpr_string.
	* testsuite/21_strings/char_traits/requirements/constexpr_functions_c++20.cc:
	Likewise.
	* testsuite/21_strings/char_traits/requirements/version.cc: New test.
2021-04-28 15:56:04 +01:00
Patrick Palka
85ef4b8d4e libstdc++: Fix up lambda in join_view::_Iterator::operator++ [PR100290]
Currently, the return type of this lambda is decltype(auto), so the
lambda ends up returning a copy of _M_parent->_M_inner rather than a
reference to it when _S_ref_glvalue is false.  This means _M_inner and
ranges::end(__inner_range) are respectively an iterator and sentinel for
different ranges, so comparing them is undefined.

libstdc++-v3/ChangeLog:

	PR libstdc++/100290
	* include/std/ranges (join_view::_Iterator::operator++): Correct
	the return type of the lambda to avoid returning a copy of
	_M_parent->_M_inner.
	* testsuite/std/ranges/adaptors/join.cc (test10): New test.
2021-04-27 14:07:46 -04:00
Jakub Jelinek
26690993d0 Revert "libstdc++: Add workaround for ia32 floating atomics miscompilations [PR100184]"
This reverts commit 0f4588141f.
2021-04-27 15:29:26 +02:00
Jonathan Wakely
39073938b4 libstdc++: Minor refactoring in <experimental/internet>
libstdc++-v3/ChangeLog:

	* include/experimental/internet (address_v6::bytes_type): Adjust
	formatting.
	(basic_endpoint): Define _M_is_v6() to put all checks for
	AF_INET6 in one place.
	(basic_endpoint::resize): Simplify.
	(operator==(const tcp&, const tcp&)): Add constexpr and noexcept.
	(operator!=(const tcp&, const tcp&)): Likewise.
	(operator==(const udp&, const udp&)): Likewise.
	(operator!=(const udp&, const udp&)): Likewise.
	* testsuite/experimental/net/internet/tcp.cc: New test.
	* testsuite/experimental/net/internet/udp.cc: New test.
2021-04-27 14:04:36 +01:00
Jonathan Wakely
9ee35a8685 libstdc++: Better preprocessor conditions in net::ip [PR 100286]
This improves the use of preprocessor conditionas to enable/disable
members of namespace net::ip according to what is supported by the
target. This fixes PR 100286 by ensuring that the to_string member
functions are always defined for the address_v4 and address_v6 classes.
On the other hand, the IP protocol classes and internet socket option
classes aren't useful at all if the corresponding constants (such as
IPPROTO_TCP or IPV6_MULTICAST_HOPS) aren't define. So those types are
not defined at all if they can't be used.

The net/internet/socket/opt.cc test uses __has_include to check whether
or not to expect the types to be available.

libstdc++-v3/ChangeLog:

	PR libstdc++/100286
	* include/experimental/internet (resolver_errc, resolver_category())
	(make_error_code, make_error_condition): Define unconditionally,
	only make enumerators and use of gai_strerror depend on the
	availability of <netdb.h>.
	(address_v4::to_string): Use correct constant for string length.
	(address_v4::to_string, address_v6::to_string): Define
	unconditionally, throw if unsupported.
	(make_address_v4, make_address_v6): Define unconditionally.
	Return an error if unsupported.
	(tcp, udp, v6_only, unicast::hops, multicast::*): Define
	conditionally,
	* testsuite/experimental/net/internet/socket/opt.cc: Check for
	<netinet/in.h> and <netinet/tcp.h> before using types from
	namespace net::ip.
2021-04-27 14:04:36 +01:00
Jonathan Wakely
2e0b1c6ce3 libstdc++: Fix internet socket option classes
Similar to the previous commit, this fixes various problems with the
socket options classes in the <internet> header:

- The constructors were not noexcept.
- The __sockopt_base<T>::value() member function was present
  unconditionally (so was defined for socket_base::linger which is
  incorrect).
- The __socket_crtp<C, T>::operator=(T) assignment operator was not
  noexcept, and was hidden in the derived classes.
- The MulticastSocketOptions incorrectly used a union, incorrectly
  defined resize and const data() member functions, and their
  constructors were unimplemented.

Also, where appropriate:

- Use class instead of struct for the socket option types.
- Define the _S_level and _S_name constants as private.
- Declare the __socket_crtp base as a friend.

libstdc++-v3/ChangeLog:

	* include/experimental/internet (tcp::no_delay, v6_only)
	(unicast::hops, multicast::hops, multicast::enable_loopback):
	Change access of base class and static data members. Add
	using-declaration for __socket_crtp::operator=(_Tp).
	(multicast::__mcastopt): New type.
	(multicast::join_group, multicast::leave_group): Derive from
	__mcastopt for common implementation.
	* include/experimental/socket: Add comment.
	* testsuite/experimental/net/internet/socket/opt.cc: New test.
	* testsuite/experimental/net/socket/socket_base.cc: Check for
	protected constructor/destructor of socket_base. Check for
	explicit constructors of socket option classes.
2021-04-26 21:16:21 +01:00
Jonathan Wakely
06c86a4f21 libstdc++: Fix socket option classes
This fixes some flaws in the socket option types defined in
net::socket_base:

- The constructors were not noexcept.
- The __sockopt_base<T>::value() member function was present
  unconditionally (so was defined for socket_base::linger which is
  incorrect).
- The __socket_crtp<C, T>::operator=(T) assignment operator was not
  noexcept, and was hidden in the derived classes.

Also:

- Use class instead of struct for the socket option types.
- Define the _S_level and _S_name constants as private.
- Declare the __socket_crtp base as a friend.

libstdc++-v3/ChangeLog:

	* include/experimental/bits/net.h (__socket_base): Add
	bool template parameter to allow BooleanSocketOption and
	IntegerSocketOption to have different __socket_base<int>
	base classes.
	(__socket_base<bool>): Adjust base class.
	(__socket_base<int>): Add partial specialization.
	(__socket_crtp::operator=(_Tp)): Add noexcept-specifier.
	* include/experimental/socket (socket_base::broadcast)
	(socket_base::debug, socket_base::do_not_route)
	(socket_base::keep_alive, socket_base::linger)
	(socket_base::out_of_band_inline)
	(socket_base::receive_buffer_size)
	(socket_base::receive_low_watermark)
	(socket_base::reuse_address, socket_base::send_buffer_size)
	(socket_base::send_low_watermark): Add using-declaration for
	__socket_crtp::operator=(_Tp).
	* testsuite/experimental/net/socket/socket_base.cc: Check
	properties of socket option types.
2021-04-26 21:16:21 +01:00
Jonathan Wakely
49adc06672 libstdc++: Simplify definition of net::ip::resolver_base constants
libstdc++-v3/ChangeLog:

	* include/experimental/internet (resolver_base::flags): Remove
	enumerators. Initialize constants directly with desired values.
	Make all operators constexpr and noexcept.
	* testsuite/experimental/net/internet/resolver/base.cc: Use
	__gnu_test::test_bitmask_values for bitmask type. Check
	construction and destruction is protected.
2021-04-26 21:16:20 +01:00
David Edelsohn
fb6b24c66e testuite: fix libtdc++ libatomic flags
Some ports require libatomic for atomic operations, at least for some
data types and widths.  The libstdc++ testsuite previously was updated
to link against libatomic, but the search path was hard-coded to
something that is not always correct, and the shared library search
path was not set.

The search path was hard-coded to the expected location of the
libatomic build directory relative to the libstdc++ testsuite
directory, but if one uses parallelism when invoking the libstdc++
testsuite, the tests are run in the "normalXX" sub-directories, for
which the hard-coded search path is incorrect. The path also is
incorrect for alternative multilib and tool options.

This patch adopts the logic from gcc/testsuite/lib/atomic-dg.exp to
search for the library and adds the logic to the libstdc++ testsuite
libatomic seatch path code.  Previously the libstdc++ testsuite atomic
tests failed depending on the build configuration and if a build of
libatomic was installed in the default search path.

Bootstrapped on powerpc-ibm-aix7.2.3.0.

libstdc++-v3/ChangeLog:

	* testsuite/lib/dg-options.exp (atomic_link_flags): New.
	(add_options_for_libatomic): Use atomic_link_flags.
2021-04-24 11:57:05 -04:00
Jonathan Wakely
a752a43073 libstdc++ Simplify definition of net::socket_base constants
libstdc++-v3/ChangeLog:

	* include/experimental/socket (socket_base::shutdown_type):
	(socket_base::wait_type, socket_base::message_flags):
	Remove enumerators. Initialize constants directly with desired
	values.
	(socket_base::message_flags): Make all operators constexpr and
	noexcept.
	* testsuite/util/testsuite_common_types.h (test_bitmask_values):
	New test utility.
	* testsuite/experimental/net/socket/socket_base.cc: New test.
2021-04-23 13:54:34 +01:00
Jonathan Wakely
6924588774 libstdc++: Fix semaphore to work with system_clock timeouts
The __cond_wait_until_impl function takes a steady_clock timeout, but
then sometimes tries to compare it to a time from the system_clock,
which won't compile.  Additionally, that function gets called with
system_clock timeouts, which also won't compile. This makes the function
accept timeouts for either clock, and compare to the time from the right
clock.

This fixes the compilation error that was causing two tests to fail on
non-futex targets, so we can revert the r12-11 change to disable them.

libstdc++-v3/ChangeLog:

	* include/bits/atomic_timed_wait.h (__cond_wait_until_impl):
	Handle system_clock as well as steady_clock.
	* testsuite/30_threads/semaphore/try_acquire_for.cc: Re-enable.
	* testsuite/30_threads/semaphore/try_acquire_until.cc:
	Re-enable.
2021-04-22 17:35:00 +01:00
Jonathan Wakely
58871c0331 libstdc++: Add options for libatomic to test
This fixes a linker error on AIX:

FAIL: 30_threads/semaphore/try_acquire_posix.cc (test for excess errors)
Excess errors:
ld: 0711-317 ERROR: Undefined symbol: .__atomic_fetch_add_8
ld: 0711-317 ERROR: Undefined symbol: .__atomic_load_8
ld: 0711-317 ERROR: Undefined symbol: .__atomic_fetch_sub_8
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
collect2: error: ld returned 8 exit status

libstdc++-v3/ChangeLog:

	* testsuite/30_threads/semaphore/try_acquire_posix.cc: Add
	options for libatomic.
2021-04-22 15:51:08 +01:00
Jonathan Wakely
55650236cd libstdc++: Reject std::make_shared<T[]> [PR 99006]
Prior to C++20 it should be ill-formed to use std::make_shared with an
array type (and we don't support the C++20 feature to make it valid yet
anyway).

libstdc++-v3/ChangeLog:

	PR libstdc++/99006
	* include/bits/shared_ptr.h (allocate_shared): Assert that _Tp
	is not an array type.
	* include/bits/shared_ptr_base.h (__allocate_shared): Likewise.
	* testsuite/20_util/shared_ptr/creation/99006.cc: New test.
2021-04-22 15:49:27 +01:00
Jakub Jelinek
0f4588141f libstdc++: Add workaround for ia32 floating atomics miscompilations [PR100184]
gcc on ia32 miscompiles various atomics involving floating point,
unfortunately I'm afraid it is too late to fix that for 11.1 and
as I'm quite lost on it, it might take a while for 12 too
(disabling all the 8 peephole2s would be easiest, but then we'd
run into optimization regressions).

While 1.cc just FAILs, with dejagnu 1.6.1 wait_notify.cc hangs the
make check even after the timeout fires.  The following patch therefore
xfails the former and skips the latter.

Tested on x86_64-linux where
make check RUNTESTFLAGS='conformance.exp=atomic_float/*.cc'
is still
                === libstdc++ Summary ===

 # of expected passes            8
and on i686-linux, where it is now
                === libstdc++ Summary ===

 # of expected passes            5
 # of expected failures          1
 # of unsupported tests          1

2021-04-22  Jakub Jelinek  <jakub@redhat.com>

	PR target/100182
	* testsuite/29_atomics/atomic_float/1.cc: Add dg-xfail-run-if for
	ia32.
	* testsuite/29_atomics/atomic_float/wait_notify.cc: Add dg-skip-if for
	ia32.
2021-04-22 15:09:58 +02:00
Thomas Rodgers
7eeb8c04e5 [libstdc++] Fix test timeout in stop_calback/destroy.cc
A change was made to __atomic_semaphore::_S_do_try_acquire() to
(ideally) let the compare_exchange reload the value of __old rather than
always reloading it twice. This causes _M_acquire to spin indefinitely
if the value of __old is already 0.

libstdc++-v3/ChangeLog:
	* include/bits/semaphore_base.h: Always reload __old in
	__atomic_semaphore::_S_do_try_acquire().
	* testsuite/30_threads/stop_token/stop_callback/destroy.cc:
	re-enable testcase.
2021-04-21 13:28:08 -07:00
Jonathan Wakely
54995d98cc libstdc++: Disable tests that fail after atomic wait/notify rewrite
These tests are currently failing, but should be analyzed and
re-enabled.

libstdc++-v3/ChangeLog:

	* testsuite/30_threads/semaphore/try_acquire_for.cc: Disable
	test for targets not using futexes for semaphores.
	* testsuite/30_threads/semaphore/try_acquire_until.cc: Likewise.
	* testsuite/30_threads/stop_token/stop_callback/destroy.cc:
	Disable for all targets.
2021-04-20 15:14:58 +01:00
Thomas Rodgers
b52aef3a8c libstdc++: Refactor/cleanup of C++20 atomic wait implementation
This is a substantial rewrite of the atomic wait/notify (and timed wait
counterparts) implementation.

The previous __platform_wait looped on EINTR however this behavior is
not required by the standard. A new _GLIBCXX_HAVE_PLATFORM_WAIT macro
now controls whether wait/notify are implemented using a platform
specific primitive or with a platform agnostic mutex/condvar. This
patch only supplies a definition for linux futexes. A future update
could add support __ulock_wait/wake on Darwin, for instance.

The members of __waiters were lifted to a new base class. The members
are now arranged such that overall sizeof(__waiter_pool_base) fits in
two cache lines (on platforms with at least 64 byte cache lines). The
definition will also use destructive_interference_size for this if it is
available.

The __waiters type is now specific to untimed waits, and is renamed to
__waiter_pool. Timed waits have a corresponding __timed_waiter_pool
type.  Much of the code has been moved from the previous __atomic_wait()
free function to the __waiter_base template and a __waiter derived type
is provided to implement the un-timed wait operations. A similar change
has been made to the timed wait implementation.

The __atomic_spin code has been extended to take a spin policy which is
invoked after the initial busy wait loop. The default policy is to
return from the spin. The timed wait code adds a timed backoff spinning
policy. The code from <thread> which implements this_thread::sleep_for,
sleep_until has been moved to a new <bits/std_thread_sleep.h> header
which allows the thread sleep code to be consumed without pulling in the
whole of <thread>.

The entry points into the wait/notify code have been restructured to
support either -
   * Testing the current value of the atomic stored at the given address
     and waiting on a notification.
   * Applying a predicate to determine if the wait was satisfied.
The entry points were renamed to make it clear that the wait and wake
operations operate on addresses. The first variant takes the expected
value and a function which returns the current value that should be used
in comparison operations, these operations are named with a _v suffix
(e.g. 'value'). All atomic<_Tp> wait/notify operations use the first
variant. Barriers, latches and semaphores use the predicate variant.

This change also centralizes what it means to compare values for the
purposes of atomic<T>::wait rather than scattering through individual
predicates.

This change also centralizes the repetitive code which adjusts for
different user supplied clocks (this should be moved elsewhere
and all such adjustments should use a common implementation).

This change also removes the hashing of the pointer and uses
the pointer value directly for indexing into the waiters table.

libstdc++-v3/ChangeLog:

	* include/Makefile.am: Add new <bits/this_thread_sleep.h> header.
	* include/Makefile.in: Regenerate.
	* include/bits/this_thread_sleep.h: New file.
	* include/bits/atomic_base.h: Adjust all calls
	to __atomic_wait/__atomic_notify for new call signatures.
	* include/bits/atomic_timed_wait.h: Extensive rewrite.
	* include/bits/atomic_wait.h: Likewise.
	* include/bits/semaphore_base.h: Adjust all calls
	to __atomic_wait/__atomic_notify for new call signatures.
	* include/std/atomic: Likewise.
	* include/std/barrier: Likewise.
	* include/std/latch: Likewise.
	* include/std/semaphore: Likewise.
	* include/std/thread (this_thread::sleep_for)
	(this_thread::sleep_until): Move to new header.
	* testsuite/29_atomics/atomic/wait_notify/bool.cc: Simplify
	test.
	* testsuite/29_atomics/atomic/wait_notify/generic.cc: Likewise.
	* testsuite/29_atomics/atomic/wait_notify/pointers.cc: Likewise.
	* testsuite/29_atomics/atomic_flag/wait_notify/1.cc: Likewise.
	* testsuite/29_atomics/atomic_float/wait_notify.cc: Likewise.
	* testsuite/29_atomics/atomic_integral/wait_notify.cc: Likewise.
	* testsuite/29_atomics/atomic_ref/wait_notify.cc: Likewise.
2021-04-20 15:14:58 +01:00
Patrick Palka
902b40c797 libstdc++: Implement P2259R1 changes [PR95983]
This implements the wording changes of P2259R1 "Repairing input range
adaptors and counted_iterator", which resolves LWG 3283, 3289 and 3408.

The wording changes are relatively straightforward, but they require
some boilerplate to implement: the changes to make a type alias
"conditionally present" in some iterator class are realized by defining
a base class template and an appropriately constrained partial
specialization thereof that contains the type alias, and having the
iterator class derive from this base class.  Sometimes the relevant
condition depend on members from the iterator class, but because a
class is incomplete when instantiating its bases, the constraints on
the partial specialization can't use anything from the iterator class.
This patch works around this by hoisting these members out to the
enclosing scope (e.g. transform_view::_Iterator::_Base is hoisted out
to transform_view::_Base so that transform_view::__iter_cat can use it).

This patch also implements the proposed resolution of LWG 3291 to rename
iota_view::iterator_category to iota_view::iterator_concept, which was
previously problematic due to LWG 3408.

libstdc++-v3/ChangeLog:

	PR libstdc++/95983
	* include/bits/stl_iterator.h (__detail::__move_iter_cat):
	Define.
	(move_iterator): Derive from the above in C++20 in order to
	conditionally define iterator_category as per P2259.
	(move_iterator::__base_cat): No longer used, so remove.
	(move_iterator::iterator_category): Remove in C++20.
	(__detail::__common_iter_use_postfix_proxy): Define.
	(common_iterator::_Proxy): Rename to ...
	(common_iterator:__arrow_proxy): ... this.
	(common_iterator::__postfix_proxy): Define as per P2259.
	(common_iterator::operator->): Adjust.
	(common_iterator::operator++): Adjust as per P2259.
	(iterator_traits<common_iterator>::_S_iter_cat): Define.
	(iterator_traits<common_iterator>::iterator_category): Change as
	per P2259.
	(__detail::__counted_iter_value_type): Define.
	(__detail::__counted_iter_concept): Define.
	(__detail::__counted_iter_cat): Define.
	(counted_iterator): Derive from the above three classes in order
	to conditionally define value_type, iterator_concept and
	iterator category respectively as per P2259.
	(counted_iterator::operator->): Define as per P2259.
	(incrementable_traits<counted_iterator>): Remove as per P2259.
	(iterator_traits<counted_iterator>): Adjust as per P2259.
	* include/std/ranges (__detail::__iota_view_iter_cat): Define.
	(iota_view::_Iterator): Derive from the above in order to
	conditionally define iterator_category as per P2259.
	(iota_view::_S_iter_cat): Rename to ...
	(iota_view::_S_iter_concept): ... this.
	(iota_view::iterator_concept): Use it to apply LWG 3291 changes.
	(iota_view::iterator_category): Remove.
	(__detail::__filter_view_iter_cat): Define.
	(filter_view::_Iterator): Derive from the above in order to
	conditionally define iterator_category as per P2259.
	(filter_view::_Iterator): Move to struct __filter_view_iter_cat.
	(filter_view::_Iterator::iterator_category): Remove.
	(transform_view::_Base): Define.
	(transform_view::__iter_cat): Define.
	(transform_view::_Iterator): Derive from the above in order to
	conditionally define iterator_category as per P2259.
	(transform_view::_Iterator::_Base): Just alias
	transform_view::_Base.
	(transform_view::_Iterator::_S_iter_cat): Move to struct
	transform_view::__iter_cat.
	(transform_view::_Iterator::iterator_category): Remove.
	(transform_view::_Sentinel::_Base): Just alias
	transform_view::_Base.
	(join_view::_Base): Define.
	(join_view::_Outer_iter): Define.
	(join_view::_Inner_iter): Define.
	(join_view::_S_ref_is_glvalue): Define.
	(join_view::__iter_cat): Define.
	(join_view::_Iterator): Derive from it in order to conditionally
	define iterator_category as per P2259.
	(join_view::_Iterator::_Base): Just alias join_view::_Base.
	(join_view::_Iterator::_S_ref_is_glvalue): Just alias
	join_view::_S_ref_is_glvalue.
	(join_view::_Iterator::_S_iter_cat): Move to struct
	transform_view::__iter_cat.
	(join_view::_Iterator::_Outer_iter): Just alias
	join_view::_Outer_iter.
	(join_view::_Iterator::_Inner_iter): Just alias
	join_view::_Inner_iter.
	(join_view::_Iterator::iterator_category): Remove.
	(join_view::_Sentinel::_Base): Just alias join_view::_Base.
	(__detail::__split_view_outer_iter_cat): Define.
	(__detail::__split_view_inner_iter_cat): Define.
	(split_view::_Base): Define.
	(split_view::_Outer_iter): Derive from __split_view_outer_iter_cat
	in order to conditionally define iterator_category as per P2259.
	(split_view::_Outer_iter::iterator_category): Remove.
	(split_view::_Inner_iter): Derive from __split_view_inner_iter_cat
	in order to conditionally define iterator_category as per P2259.
	(split_view::_Inner_iter::_S_iter_cat): Move to
	__split_view_inner_iter_cat.
	(split_view::_Inner_iter::iterator_category): Remove.
	(elements_view::_Base): Define.
	(elements_view::__iter_cat): Define.
	(elements_view::_Iterator): Derive from the above in order to
	conditionall define iterator_category as per P2259.
	(elements_view::_Iterator::_Base): Just alias
	elements_view::_Base.
	(elements_view::_Iterator::_S_iter_concept)
	(elements_view::_Iterator::iterator_concept): Define as per
	P2259.
	(elements_view::_Iterator::iterator_category): Remove.
	(elements_view::_Sentinel::_Base): Just alias
	elements_view::_Base.
	* testsuite/24_iterators/headers/iterator/synopsis_c++20.cc:
	Adjust constraints on iterator_traits<counted_iterator>.
	* testsuite/std/ranges/p2259.cc: New test.
2021-04-20 09:18:50 -04:00
Jonathan Wakely
f1a68574b1 libstdc++: Define __cpp_lib_to_chars for C++20 [PR 100146]
This defines the feature test macro when uselocale is available, because
the floating-point std::from_chars support currently depends on that.

Co-authored-by: Jakub Jelinek <jakub@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/100146
	* include/std/charconv (__cpp_lib_to_chars): Define
	conditionally.
	* include/std/version (__cpp_lib_to_chars): Likewise..
	* testsuite/20_util/from_chars/4.cc: Only check feature test
	macro, not _GLIBCXX_HAVE_USELOCALE.
	* testsuite/20_util/from_chars/5.cc: Likewise.
	* testsuite/20_util/from_chars/6.cc: Likewise.
	* testsuite/20_util/to_chars/long_double.cc: Likewise.
2021-04-20 12:50:50 +01:00
Jakub Jelinek
96de14f46f libstdc++: Update ppc64le baseline_symbols.txt
> Tested on powerpc64{,le}-linux now (-m32/-m64 on be) and while the first
> patch works fine, the second one unfortunately doesn't on either be or le,
> so more work is needed there.

Here are the needed changes to make it work.
For symbols with _LDBL_ substring in version name we already have code to
ignore those if no such symbols appear (but it is slightly incorrect, see
below).
So, this patch does the same thing for symbol versions with _IEEE128_
substring.
The previously incorrectly handled case is that in addition to
FUNC:_ZNKSt17__gnu_cxx_ieee1287num_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE14_M_extract_intImEES4_S4_S4_RSt8ios_baseRSt12_Ios_IostateRT_@@GLIBCXX_IEEE128_3.4.29
or
OBJECT:12:_ZTSu9__ieee128@@CXXABI_IEEE128_1.3.13
cases we also have the
OBJECT:0:CXXABI_IEEE128_1.3.13
OBJECT:0:GLIBCXX_IEEE128_3.4.29
cases, which have empty version_name and the name is in that case the
symbol version.  Those need to be ignored too.

2021-04-20  Jakub Jelinek  <jakub@redhat.com>

	* testsuite/util/testsuite_abi.cc (compare_symbols): If any symbol
	versions with _IEEE128_ substring are found, set ieee_version_found
	to true.  Ignore missing symbols with _IEEE128_ in version name if
	!ieee_version_found.  Use i->first as version_name instead of
	i->second.version_name if the latter is empty.
	* config/abi/post/powerpc64-linux-gnu/baseline_symbols.txt: Update.
2021-04-20 12:48:12 +02:00
Jonathan Wakely
a25590f29d libstdc++: Add -latomic to test flags for 32-bit sparc-linux
Without this I see a number of tests failing when -m32 is used.

libstdc++-v3/ChangeLog:

	* testsuite/lib/dg-options.exp (add_options_for_libatomic): Also
	add libatomic options for 32-bit sparc*-*-linux-gnu.
2021-04-15 17:42:44 +01:00
Jonathan Wakely
6c0c7fc623 libstdc++: Move atomic functions to libsupc++ [PR 96657]
The changes for PR libstdc++/64735 mean that libsupc++ function might
now depend on the __exchange_and_add and __atomic_add functions defined
in config/cpu/*/atomicity.h which is not compiled into libsupc++. This
causes a link failure for some targets when trying to use libsupc++
without the rest of libstdc++.

This patch simply moves the definitions of those functions into
libsupc++ so that they are available there.

libstdc++-v3/ChangeLog:

	PR libstdc++/96657
	* libsupc++/Makefile.am: Add atomicity.cc here.
	* src/c++98/Makefile.am: Remove it from here.
	* libsupc++/Makefile.in: Regenerate.
	* src/c++98/Makefile.in: Regenerate.
	* testsuite/18_support/exception_ptr/96657.cc: New test.
2021-04-15 16:56:44 +01:00
Jonathan Wakely
7569ce583f libstdc++: Implement LWG 3404 for C++20 subrange [PR 100044]
These deduction guides became useless with LWG 3282 (implemented in
commit r10-6741) and so were removed by LWG 3404.

libstdc++-v3/ChangeLog:

	PR libstdc++/100044
	* include/bits/ranges_util.h (__detail::__iterator_sentinel_pair):
	Remove helper concept.
	(subrange(_Pr), subrange(Pr, __make_unsigned_like<...>)): Remove
	deduction guides, as per LWG 3404.
	* testsuite/std/ranges/subrange/lwg3282_neg.cc: Check that class
	template argument deduction fails.
2021-04-12 13:31:17 +01:00
Jonathan Wakely
91dd7954c4 libstdc++: Fix some tests that fail in C++20 mode
The linear_congruential_engine negative tests fail with a different
error in C++20 mode, because double is no longer an invalid type for
NTTP. Adjust the expected errors.

libstdc++-v3/ChangeLog:

	* testsuite/26_numerics/random/linear_congruential_engine/requirements/non_uint_neg.cc:
	Adjust expected error for C++20 mode.
	* testsuite/tr1/5_numerical_facilities/random/linear_congruential/requirements/non_uint_neg.cc:
	Likewise.
2021-04-12 12:30:07 +01:00
Jonathan Wakely
29046e02b8 libstdc++: Fix test that fails in C++20 mode [PR 99995]
The 17_intro/headers/c++1998/49745.cc test fails for C++20 mode with PCH
enabled, because PCH makes it include <bits/stdc++.h>, which includes
<atomic>, and that includes <unistd.h> in C++20 mode. The <unistd.h>
dependency should go away when C++20 atomic waiting is stable, but will
probably remain while the feature is experimental. Change the test to
always include <bits/stdc++.h>, and XFAIL for C++20 and later.

libstdc++-v3/ChangeLog:

	PR libstdc++/99995
	* testsuite/17_intro/headers/c++1998/49745.cc: Include all
	standard headers and XFAIL for effective-target c++20.
2021-04-12 11:34:19 +01:00
François Dumont
cc79682046 libstdc++: [_GLIBCXX_DEBUG] Fix management of __dp_sign_max_size [PR 99402]
__dp_sign precision indicates that we found out what iterator comes first or
last in the range. __dp_sign_max_size is the same plus it gives the information
of the max size of the range that is to say the max_size value such that
distance(lhs, rhs) < max_size.
Thanks to this additional information we are able to tell when a copy of n elements
to that range will fail even if we do not know exactly how large it is.

This patch makes sure that we are properly using this information.

libstdc++-v3/ChangeLog:

	PR libstdc++/99402
	* include/debug/helper_functions.h (__can_advance(_InputIterator,
	const std::pair<_Diff, _Distance_precision>&, int)): New.
	(__can_advance(const _Safe_iterator<>&,
	const std::pair<_Diff, _Distance_precision>&, int)): New.
	* include/debug/macros.h (__glibcxx_check_can_increment_dist): New,
	use latter.
	(__glibcxx_check_can_increment_range): Adapt to use latter.
	(__glibcxx_check_can_decrement_range): Likewise.
	* include/debug/safe_iterator.h
	(_Safe_iterator<>::_M_can_advance(const std::pair<_Diff, _Distance_precision>&,
	int)): New.
	(__can_advance(const _Safe_iterator<>&,
	const std::pair<_Diff, _Distance_precision>&, int)): New.
	* include/debug/safe_iterator.tcc
	(_Safe_iterator<>::_M_can_advance(const std::pair<_Diff, _Distance_precision>&,
	int)): New.
	(_Safe_iterator<>::_M_valid_range(const _Safe_iterator<>&,
	std::pair<difference_type, _Distance_precision>&, bool)): Adapt for
	__dp_sign_max_size.
	(__copy_move_a): Adapt to use __glibcxx_check_can_increment_dist.
	(__copy_move_backward_a): Likewise.
	(__equal_aux): Likewise.
	* include/debug/stl_iterator.h (__can_advance(const std::reverse_iterator<>&,
	const std::pair<_Diff, _Distance_precision>&, int)): New.
	(__can_advance(const std::move_iterator<>&,
	const std::pair<_Diff, _Distance_precision>&, int)): New.
	* testsuite/25_algorithms/copy/debug/99402.cc: New test.
2021-04-09 21:46:35 +02:00
Jonathan Wakely
40ccb47b50 libstdc++: Fix invalid constexpr function in C++11 mode [PR 99985]
I keep forgetting that a constexpr function in C++11 has to be a single
return statement.

libstdc++-v3/ChangeLog:

	PR libstdc++/99985
	* include/bits/hashtable.h (_Hashtable::_S_nothrow_move()): Fix
	to be a valid constexpr function in C++11.
	* testsuite/23_containers/unordered_set/cons/99985.cc: New test.
2021-04-09 13:09:24 +01:00
Patrick Palka
b5242b2845 libstdc++: Fix split_view::_OuterIter::operator++ [LWG 3505]
libstdc++-v3/ChangeLog:

	* include/std/ranges (__detail::find): Define.
	(split_view::_OuterIter::operator++): Apply proposed resolution
	of LWG 3505.
	* testsuite/std/ranges/adaptors/split.cc (test10): New test.
2021-04-08 16:45:27 -04:00
Patrick Palka
c7fe68f365 libstdc++: Fix elements_view::operator* and operator[] [LWG 3502]
While we're modifying elements_view, this also implements the one-line
resolution of LWG 3492.

libstdc++-v3/ChangeLog:

	* include/std/ranges (__detail::__returnable_element): New
	concept.
	(elements_view): Use this concept in its constraints.  Add
	missing private access specifier.
	(elements_view::_S_get_element): Define as per LWG 3502.
	(elements_view::operator*, elements_view::operator[]): Use
	_S_get_element.
	(elements_view::operator++): Remove unnecessary constraint
	as per LWG 3492.
	* testsuite/std/ranges/adaptors/elements.cc (test05): New test.
2021-04-08 16:45:22 -04:00
Jonathan Wakely
1cbba49e34 libstdc++: Simplify noexcept-specifiers for move constructors
This puts the logic for the noexcept-specifier in one place, and then
reuses it elsewhere. This means checking whether the move constructor
can throw doesn't need to do overload resolution and then check whether
some other constructor can throw, we just get the answer directly.

libstdc++-v3/ChangeLog:

	* include/bits/hashtable.h (_Hashtable::_S_nothrow_move()):
	New function to determine noexcept-specifier for move
	constructors.
	(_Hashtable): Use _S_nothrow_move() on move constructors.
	* testsuite/23_containers/unordered_map/cons/noexcept_move_construct.cc:
	Correct static assertion message.
	* testsuite/23_containers/unordered_multimap/cons/noexcept_move_construct.cc:
	Likewise.
	* testsuite/23_containers/unordered_multiset/cons/noexcept_move_construct.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/cons/noexcept_move_construct.cc:
	Likewise.
2021-04-08 17:49:59 +01:00
Patrick Palka
ca4641a3b5 libstdc++: Address remaining to_chars/long_double.cc FAILs [PR98384]
This works around the remaining reported execution FAILs of this test on
AIX, Solaris and Darwin.  Eventually we should rewrite this test to be
less fragile, but there's not enough time to do that for GCC 11.

libstdc++-v3/ChangeLog:

	PR libstdc++/98384
	* testsuite/20_util/to_chars/long_double.cc: Don't run the test
	on targets without a large long double.  XFAIL the execution on
	targets with a non-conforming printf.
2021-04-08 11:10:58 -04:00
Patrick Palka
a25321ca06 libstdc++: Reimplement range adaptors [PR99433]
This rewrites our range adaptor implementation for more comprehensible
error messages, improved SFINAE behavior and conformance to P2281.

The diagnostic improvements mostly come from using appropriately named
functors instead of lambdas in the generic implementation of partial
application and composition of range adaptors, and in the definition of
each of the standard range adaptors.  This makes their pretty printed
types much shorter and more self-descriptive.

The improved SFINAE behavior comes from constraining the range adaptors'
member functions appropriately.  This improvement fixes PR99433, and is
also necessary in order to implement the wording changes of P2281.

Finally, P2281 clarified that partial application and composition of
range adaptors behaves like a perfect forwarding call wrapper.  This
patch implements this, except that we don't bother adding overloads for
forwarding captured state entities as non-const lvalues, since it seems
sufficient to handle the const lvalue and non-const rvalue cases for now,
given the current set of standard range adaptors.  But such overloads
can be easily added if they turn out to be needed.

libstdc++-v3/ChangeLog:

	PR libstdc++/99433
	* include/std/ranges (__adaptor::__maybe_refwrap): Remove.
	(__adaptor::__adaptor_invocable): New concept.
	(__adaptor::__adaptor_partial_app_viable): New concept.
	(__adaptor::_RangeAdaptorClosure): Rewrite, turning it into a
	non-template base class.
	(__adaptor::_RangeAdaptor): Rewrite, turning it into a CRTP base
	class template.
	(__adaptor::_Partial): New class template that represents
	partial application of a range adaptor non-closure.
	(__adaptor::__pipe_invocable): New concept.
	(__adaptor::_Pipe): New class template.
	(__detail::__can_ref_view): New concept.
	(__detail::__can_subrange): New concept.
	(all): Replace the lambda here with ...
	(_All): ... this functor.  Add appropriate constraints.
	(__detail::__can_filter_view): New concept.
	(filter, _Filter): As in all/_All.
	(__detail::__can_transform): New concept.
	(transform, _Transform): As in all/_All.
	(__detail::__can_take_view): New concept.
	(take, _Take): As in all/_All.
	(__detail::__can_take_while_view): New concept.
	(take_while, _TakeWhile): As in all/_All.
	(__detail::__can_drop_view): New concept.
	(drop, _Drop): As in all/_All.
	(__detail::__can_drop_while_view): New concept.
	(drop_while, _DropWhile): As in all/_All.
	(__detail::__can_join_view): New concept.
	(join, _Join): As in all/_All.
	(__detail::__can_split_view): New concept.
	(split, _Split): As in all/_All.  Rename template parameter
	_Fp to _Pattern.
	(__detail::__already_common): New concept.
	(__detail::__can_common_view): New concept.
	(common, _Common): As in all/_All.
	(__detail::__can_reverse_view): New concept.
	(reverse, _Reverse): As in all/_All.
	(__detail::__can_elements_view): New concept.
	(elements, _Elements): As in all/_All.
	(keys, values): Adjust.
	* testsuite/std/ranges/adaptors/99433.cc: New test.
	* testsuite/std/ranges/adaptors/all.cc: No longer expect that
	adding empty range adaptor closure objects to a pipeline doesn't
	increase the size of the pipeline.
	(test05): New test.
	* testsuite/std/ranges/adaptors/common.cc (test03): New test.
	* testsuite/std/ranges/adaptors/drop.cc (test09): New test.
	* testsuite/std/ranges/adaptors/drop_while.cc (test04): New test.
	* testsuite/std/ranges/adaptors/elements.cc (test04): New test.
	* testsuite/std/ranges/adaptors/filter.cc (test06): New test.
	* testsuite/std/ranges/adaptors/join.cc (test09): New test.
	* testsuite/std/ranges/adaptors/p2281.cc: New test.
	* testsuite/std/ranges/adaptors/reverse.cc (test07): New test.
	* testsuite/std/ranges/adaptors/split.cc (test01, test04):
	Adjust.
	(test09): New test.
	* testsuite/std/ranges/adaptors/split_neg.cc (test01): Adjust
	expected error message.
	(test02): Likewise.  Extend test.
	* testsuite/std/ranges/adaptors/take.cc (test06): New test.
	* testsuite/std/ranges/adaptors/take_while.cc (test05): New test.
	* testsuite/std/ranges/adaptors/transform.cc (test07, test08):
	New test.
2021-04-08 10:40:19 -04:00
Jonathan Wakely
43ab1dc24a libstdc++: Make std::is_scoped_enum work with incomplete types
Tim Song pointed out that using __underlying_type is ill-formed for
incomplete enumeration types, and is_scoped_enum doesn't require a
complete type. This changes the trait to check for conversion to int
instead of to the underlying type.

In order to give the correct result when the trait is used in the
enumerator-list of an incomplete type the partial specialization for
enums has an additional check that fails for incomplete types. This
assumes that an incompelte enumeration type must be an unscoped
enumeration, and so the primary template (with a std::false_type base
characteristic) can be used. This isn't necessarily true, but it is not
currently possible to refer to a scoped enumeration type before its type
is complete (PR c++/89025).

It should be possible to use requires(remove_cv_t<_Tp> __t) in the
partial specialization's assignablility check, but that currently gives
an ICE (PR c++/99968) so there is an extra partial specialization of
is_scoped_enum<const _Tp> to handle const types.

libstdc++-v3/ChangeLog:

	* include/std/type_traits (is_scoped_enum<T>): Constrain partial
	specialization to not match incomplete enum types. Use a
	requires-expression instead of instantiating is_convertible.
	(is_scoped_enum<const T>): Add as workaround for PR c++/99968.
	* testsuite/20_util/is_scoped_enum/value.cc: Check with
	incomplete types and opaque-enum-declarations.
2021-04-08 11:56:59 +01:00
Jonathan Wakely
e06d3f5dd7 libstdc++: Fix filesystem::path construction from COW string [PR 99805]
Calling the non-const data() member on a COW string makes it "leaked",
possibly resulting in reallocating the string to ensure a unique owner.

The path::_M_split_cmpts() member parses its _M_pathname string using
string_view objects and then calls _M_pathname.data() to find the offset
of each string_view from the start of the string. However because
_M_pathname is non-const that will cause a COW string to reallocate if
it happens to be shared with another string object. This results in the
offsets calculated for each component being wrong (i.e. undefined)
because the string views no longer refer to substrings of the
_M_pathname member. The fix is to use the parse.offset(c) member which
gets the offset safely.

The bug only happens for the path(string_type&&) constructor and only
for COW strings. When constructed from an lvalue string the string's
contents are copied rather than just incrementing the refcount, so
there's no reallocation when calling the non-const data() member. The
testsuite changes check the lvalue case anyway, because we should
probably change the deep copying to just be a refcount increment (by
adding a path(const string_type&) constructor or an overload for
__effective_range(const string_type&), for COW strings only).

libstdc++-v3/ChangeLog:

	PR libstdc++/99805
	* src/c++17/fs_path.cc (path::_M_split_cmpts): Do not call
	non-const member on _M_pathname, to avoid copy-on-write.
	* testsuite/27_io/filesystem/path/decompose/parent_path.cc:
	Check construction from strings that might be shared.
2021-04-07 16:39:24 +01:00
Jonathan Wakely
41019bfae2 libstdc++: Clarify static_assert message
libstdc++-v3/ChangeLog:

	* include/bits/move.h (forward): Change static_assert message
	to be unambiguous about what must be true.
	* testsuite/20_util/forward/c_neg.cc: Adjust dg-error.
	* testsuite/20_util/forward/f_neg.cc: Likewise.
2021-04-06 16:43:24 +01:00