Commit Graph

12870 Commits

Author SHA1 Message Date
Jonathan Wakely 65441d8fc3 libstdc++: Improve overflow check for file timestamps
The current code assumes that system_clock::duration is nanoseconds, and
also performs a value-changing conversion from nanoseconds::max() to
double (which doesn't matter after dividing by 1e9, but triggers a
warning with Clang nonetheless).

A better solution is to use system_clock::duration::max() and perform
the comparison entirely using the std::chrono types, rather than with
dimensionless arithmetic types.

This doesn't address the FIXME in the function, so the overflow check
still rejects some values that could be represented by the file_clock.

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

libstdc++-v3/ChangeLog:

	* src/filesystem/ops-common.h (filesystem::file_time): Improve
	overflow check by using system_clock::duration::max().
2021-08-19 13:02:11 +01:00
Jonathan Wakely c8a1cf1a7a libstdc++: Tweak whitespace
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/bits/stl_tree.h: Tweak whitespace.
2021-08-19 13:02:11 +01:00
GCC Administrator 6e529985d8 Daily bump. 2021-08-19 00:16:42 +00:00
Jonathan Wakely 4fb471afc4 libstdc++: Improve doxygen documentation for std::unique_ptr
Add more detailed documentation for unique_ptr and related components.

The new alias templates for the _MakeUniq SFINAE helper make the
generated docs look better too.

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

libstdc++-v3/ChangeLog:

	* include/bits/unique_ptr.h (default_delete): Add @since tag.
	(unique_ptr, unique_ptr<T[]>): Likewise. Improve @brief.
	(make_unique, make_unique_for_overwrite): Likewise. Add @tparam,
	@param, and @returns.
	(_MakeUniq): Move to __detail namespace. Add alias template
	helpers.
2021-08-18 15:13:08 +01:00
Jonathan Wakely 828176ba49 libstdc++: Improve doxygen comments in <bits/stl_function.h>
Add notes about deprecation and modern replacements. Fix bogus
"memory_adaptors" group name. Use markdown for formatting.

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

libstdc++-v3/ChangeLog:

	* include/bits/stl_function.h: Improve doxygen comments.
2021-08-18 15:07:16 +01:00
Jonathan Wakely aba938d6c3 libstdc++: Enable doxygen processing for C++20 components
Improve grouping, add @since and @deprecated information.

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

libstdc++-v3/ChangeLog:

	* doc/doxygen/user.cfg.in (PREDEFINED): Enable doxygen
	processing for C++20 components and components that depend on
	compiler features.
	* include/bits/stl_algo.h (random_shuffle): Use @deprecated.
	* include/std/type_traits: Improve doxygen comments for C++20
	traits.
2021-08-18 15:02:31 +01:00
Jonathan Wakely 37620d5751 libstdc++: Simplify n-ary arithmetic promotion traits
The std::complex partial specializations have been unnecessary since
774c3d8647

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

libstdc++-v3/ChangeLog:

	* include/ext/type_traits.h (__promote_2, __promote_3)
	(__promote_4): Redfine as alias templates using __promoted_t.
	* include/std/complex (__promote_2): Remove partial
	specializations for std::complex.
2021-08-18 14:26:39 +01:00
Jonathan Wakely de44eee5d5 libstdc++: Minor optimization for min/max/minmax
The debug mode checks for a valid range are redundant when we have an
initializer_list argument, because we know it's a valid range already.
By making std::min(initialier_list<T>) call the internal __min_element
function directly we avoid a function call and skip those checks. The
same can be done for the overload taking a comparison function, and also
for the std::max and std::minmax overloads for initializer_list
arguments.

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

libstdc++-v3/ChangeLog:

	* include/bits/stl_algo.h (min(initializer_list<T>))
	(min(initializer_list<T>, Compare)): Call __min_element directly to
	avoid redundant debug checks for valid ranges.
	(max(initializer_list<T>), max(initializer_list<T>, Compare)):
	Likewise, for __max_element.
	(minmax(initializer_list<T>), minmax(initializer_list<T>, Compare)):
	Likewise, for __minmax_element.
2021-08-18 14:26:39 +01:00
Jonathan Wakely 085c2f8f0e libstdc++: Fix CTAD for debug sequence containers
This fixes some 23_containers/*/cons/deduction.cc failures seen with
-std=c++17/-D_GLIBCXX_DEBUG, caused by non-immediate errors when
substituting template arguments into an incorrect specialization of the
std::__cxx1998 base class. This happens because the size_type member of
the debug container is _Base_type::size_type, so is non-deducible, and
the deduced types get substituted into _Base_type, triggering the
static_assert that checks the allocator's value_type matches the
container's.

The solution is to make the C(size_type, const T&, const Alloc&)
constructors of the debug sequence containers non-deducible. In order to
make CTAD work again deduction guides that use std::size_t for the first
argument are added.

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

libstdc++-v3/ChangeLog:

	* include/debug/deque (deque(size_type, const T&, const A&)):
	Prevent class template argument deduction and replace with a
	deduction guide.
	* include/debug/forward_list (forward_list(size_type, const T&, const A&)):
	Likewise.
	* include/debug/list (list(size_type, const T&, const A&)):
	Likewise.
	* include/debug/vector (vector(size_type, const T&, const A&)):
	Likewise.
2021-08-18 14:26:38 +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
GCC Administrator 2d14d64bf2 Daily bump. 2021-08-18 00:16:48 +00: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 8ea0fadc1b libstdc++: Remove pretty printer committed by mistake
The std::error_category printer wasn't meant to be part of the commit
adding std::error_code and std::error_condition printers.

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

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdErrorCatPrinter): Remove.
2021-08-17 14:31:21 +01:00
Jonathan Wakely 0808b0df9c libstdc++: Optimize std::function move constructor [PR101923]
PR 101923 points out that the unconditional swap in the std::function
move constructor makes it slower than copying an empty std::function.
The copy constructor has to check for the empty case before doing
anything, and that makes it very fast for the empty case.

Adding the same check to the move constructor avoids copying the
_Any_data POD when we don't need to. We can also inline the effects of
swap, by copying each member and then zeroing the pointer members.

This makes moving an empty object at least as fast as copying an empty
object.

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

libstdc++-v3/ChangeLog:

	PR libstdc++/101923
	* include/bits/std_function.h (function(function&&)): Check for
	non-empty parameter before doing any work.
2021-08-17 14:22:50 +01:00
Jonathan Wakely 3b3f2f7c26 libstdc++: Only define basic_string::contains for C++23
The new contains member of the COW string is defined for non-strict
gnu++20 mode as well as for C++23 modes. I think that was left in the
committed patch unintentionally. It is inconsistent with the SSO string,
and doesn't actually compile because it uses the
basic_string_view::contains member which only defined for C++23.

This makes it only defined for C++23.

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

libstdc++-v3/ChangeLog:

	* include/bits/cow_string.h (basic_string::contains): Do not
	define for -std=gnu++20.
2021-08-17 14:22:50 +01:00
Jonathan Wakely c09cabb239 libstdc++: Rename __detail::__not_same_as helper
This is done to match an editorial change in the working draft, to
rename the exposition-only not-same-as helper to different-from.

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

libstdc++-v3/ChangeLog:

	* include/bits/ranges_util.h (__not_same_as): Rename to
	__different_from.
	* include/std/ranges (__not_same_as): Likewise.
2021-08-17 14:22:49 +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
GCC Administrator 9d1d9fc8b4 Daily bump. 2021-08-17 00:16:32 +00:00
Jonathan Wakely 6c25932ac3 libstdc++: Use qualified-id for class member constant [PR101937]
The expression ctx._M_indent is not a constant expression when ctx is a
reference parameter, even though _M_indent is an enumerator. Rename it
to _S_indent to be consistent with our conventions, and refer to it as
PrintContext::_S_indent to be valid C++ code (at least until P2280 is
accepted as a DR).

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

libstdc++-v3/ChangeLog:

	PR libstdc++/101937
	* src/c++11/debug.cc (PrintContext::_M_indent): Replace with a
	static data member.
	(print_word): Use qualified-id to access it.
2021-08-16 17:52:02 +01:00
Jonathan Wakely db853ff78a libstdc++: Install GDB pretty printers for debug library
The additional libraries installed by --enable-libstdcxx-debug are built
without optimization to aid debugging, but the Python pretty printers
are not installed alongside them. This means that you can step through
the unoptimized library code, but at the expense of pretty printing the
library types.

This remedies the situation by installing another copy of the GDB hooks
alongside the debug version of libstdc++.so.

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

libstdc++-v3/ChangeLog:

	* python/Makefile.am [GLIBCXX_BUILD_DEBUG] (install-data-local):
	Install another copy of the GDB hook.
	* python/Makefile.in: Regenerate.
2021-08-16 17:51:42 +01:00
GCC Administrator 72be20e202 Daily bump. 2021-08-13 00:16:43 +00: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 20ce14c799 libstdc++: Add [[nodiscard]] to experimental::randint
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/experimental/random (experimental::randint): Add
	nodiscard attribute.
2021-08-12 19:46:16 +01:00
Jonathan Wakely d3a7fbcb7c libstdc++: Add #error to some files that depend on a specific standard mode
Give more explicit errors if these files are not built with the correct
-std options.

libstdc++-v3/ChangeLog:

	* src/c++98/locale_init.cc: Require C++11.
	* src/c++98/localename.cc: Likewise.
	* src/c++98/misc-inst.cc: Require C++98.
2021-08-12 15:03:22 +01:00
GCC Administrator 58f8750342 Daily bump. 2021-08-12 00:16:28 +00: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 04ddd108d1 libstdc++: Fix missing descriptions in ChangeLog entries 2021-08-11 16:53:22 +01:00
GCC Administrator 377681505f Daily bump. 2021-08-10 00:16:28 +00:00
Jonathan Wakely f5a2d78072 libstdc++: Reduce use of debug containers in <regex>
The std::regex code uses std::map and std::vector, which means that when
_GLIBCXX_DEBUG is defined it uses the debug versions of those
containers. That no longer compiles, because I changed <regex> to
include <bits/stl_map.h> and <bits/stl_vector.h> instead of <map> and
<vector>, so the debug versions aren't defined, and std::map doesn't
compile. There is also a use of std::stack, which defaults to std::deque
which is the debug deque when _GLIBCXX_DEBUG is defined.

Using std::map, std::vector, and std::deque is probably a mistake, and
we should qualify them with _GLIBCXX_STD_C instead so that the debug
versions aren't used. We do not need the overhead of checking our own
uses of those containers, which should be correct anyway. The exception
is the vector base class of std::match_results, which exposes iterators
to users, so can benefit from debug mode checks for its iterators. For
other accesses to the vector elements, match_results already does its
own checks, so can access the _GLIBCXX_STD_C::vector base class
directly.

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

libstdc++-v3/ChangeLog:

	* include/bits/regex.h (basic_regex::transform_primary): Use
	_GLIBCXX_STD_C::vector for local variable.
	* include/bits/regex.tcc (__regex_algo_impl): Use reference to
	_GLIBCXX_STD_C::vector base class of match_results.
	* include/bits/regex_automaton.tcc (_StateSeq:_M_clone): Use
	_GLIBCXX_STD_C::map and _GLIBCXX_STD_C::deque for local
	variables.
	* include/bits/regex_compiler.h (_BracketMatcher): Use
	_GLIBCXX_STD_C::vector for data members.
	* include/bits/regex_executor.h (_Executor): Likewise.
	* include/std/regex [_GLIBCXX_DEBUG]: Include <debug/vector>.
2021-08-09 20:46:56 +01:00
François Dumont 1354603bf7 libstdc++: [_GLIBCXX_DEBUG] Avoid allocator operator== when always equal
Use std::allocator_traits::is_always_equal to find out if we need to compare
allocator instances on safe container allocator aware move constructor.

libstdc++-v3/ChangeLog:

	* include/debug/safe_container.h
	(_Safe_container(_Safe_container&&, const _Alloc&, std::true_type)): New.
	(_Safe_container(_Safe_container&&, const _Alloc&, std::false_type)): New.
	(_Safe_container(_Safe_container&&, const _Alloc&)): Use latters.
2021-08-09 20:44:58 +02: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
GCC Administrator 844105d912 Daily bump. 2021-08-09 00:16:32 +00: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
GCC Administrator f92f477852 Daily bump. 2021-08-07 00:16:39 +00:00
Jonathan Wakely c2a984a357 libstdc++: Also move the [[nodiscard]] attributes in <compare>
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* libsupc++/compare (compare_three_way, strong_order)
	(weak_order, partial_order, compare_strong_order_fallback)
	(compare_weak_order_fallback, compare_partial_order_fallback):
	Move nodiscard attributes to correct location.
2021-08-06 13:43:26 +01:00
GCC Administrator 8ebf4fb54a Daily bump. 2021-08-06 00:16:29 +00:00
Jonathan Wakely c8b024fa4b libstdc++: Move [[nodiscard]] attributes again [PR101782]
Where I moved these nodiscard attributes to made them apply to the
function type, not to the function. This meant they no longer generated
the desired -Wunused-result warnings, and were ill-formed with Clang
(but only a pedwarn with GCC).

Clang also detected ill-formed attributes in <queue> which this fixes.

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 after the
	declarator-id instead of at the end of the declarator.
	* include/bits/stl_iterator.h (__gnu_cxx::__normal_iterator):
	Move attributes back to the start of the function declarator,
	but move the requires-clause to the end.
	(common_iterator): Move attribute after the declarator-id.
	* include/bits/stl_queue.h (queue): Remove ill-formed attributes
	from friend declaration that are not definitions.
	* 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): Move
	attributes after the declarator-id.
2021-08-05 19:01:51 +01: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
GCC Administrator 2697f8324f Daily bump. 2021-08-05 00:17:03 +00: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
GCC Administrator fa1407c761 Daily bump. 2021-08-04 00:16:51 +00: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 13a1ac9f6f libstdc++: Specialize allocator_traits<pmr::polymorphic_allocator<T>>
This adds a partial specialization of allocator_traits, similar to what
was already done for std::allocator. This means that most uses of
polymorphic_allocator via the traits can avoid the metaprogramming
overhead needed to deduce the properties from polymorphic_allocator.

In addition, I'm changing polymorphic_allocator::delete_object to invoke
the destructor (or pseudo-destructor) directly, rather than calling
allocator_traits::destroy, which calls polymorphic_allocator::destroy
(which is deprecated). This is observable if a user has specialized
allocator_traits<polymorphic_allocator<Foo>> and expects to see its
destroy member function called. I consider explicit specializations of
allocator_traits to be wrong-headed, and this use case seems unnecessary
to support. So delete_object just invokes the destructor directly.

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

libstdc++-v3/ChangeLog:

	* include/std/memory_resource (polymorphic_allocator::delete_object):
	Call destructor directly instead of using destroy.
	(allocator_traits<polymorphic_allocator<T>>): Define partial
	specialization.
2021-08-03 15:30:36 +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
Jonathan Wakely a1a2654cdc libstdc++: Avoid using std::unique_ptr in <locale>
std::wstring_convert and std::wbuffer_convert types are not copyable or
movable, and store a plain pointer without a deleter. That means a much
simpler type that just uses delete in its destructor can be used instead
of std::unique_ptr.

That avoids including and parsing all of <bits/unique_ptr.h> in every
header that includes <locale>. It also avoids instantiating
unique_ptr<C> and std::tuple<C*, default_delete<C>> when the conversion
utilities are used.

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

libstdc++-v3/ChangeLog:

	* include/bits/locale_conv.h (__detail::_Scoped_ptr): Define new
	RAII class template.
	(wstring_convert, wbuffer_convert): Use __detail::_Scoped_ptr
	instead of unique_ptr.
2021-08-03 15:06:56 +01:00
GCC Administrator 4d17ca1bc7 Daily bump. 2021-08-03 07:49:16 +00: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
Patrick Palka 4414057186 libstdc++: Fix up implementation of LWG 3533 [PR101589]
In r12-569 I accidentally applied the LWG 3533 change to
elements_view::iterator::base instead to elements_view::base.

This patch corrects this, and also applies the corresponding LWG 3533
change to lazy_split_view::inner-iter::base now that we implement P2210.

	PR libstdc++/101589

libstdc++-v3/ChangeLog:

	* include/std/ranges (lazy_split_view::_InnerIter::base): Make
	the const& overload unconstrained and return a const reference
	as per LWG 3533.  Make unconditionally noexcept.
	(elements_view::base): Revert accidental r12-569 change.
	(elements_view::_Iterator::base): Make the const& overload
	unconstrained and return a const reference as per LWG 3533.
	Make unconditionally noexcept.
2021-08-02 15:30:13 -04:00
Patrick Palka 0e1bb3c88c libstdc++: Add missing std::move to join_view::iterator ctor [PR101483]
PR libstdc++/101483

libstdc++-v3/ChangeLog:

	* include/std/ranges (join_view::_Iterator::_Iterator): Add
	missing std::move.
2021-08-02 15:30:10 -04:00
Jonathan Wakely 38fb24ba4d libstdc++: Fix filesystem::temp_directory_path [PR101709]
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/101709
	* src/filesystem/ops-common.h (get_temp_directory_from_env):
	Add error_code parameter.
	* src/c++17/fs_ops.cc (fs::temp_directory_path): Pass error_code
	argument to get_temp_directory_from_env and check it.
	* src/filesystem/ops.cc (fs::temp_directory_path): Likewise.
2021-08-02 16:33:44 +01: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
Hans-Peter Nilsson 4186cb9cc0 fix breakage from "libstdc++: Remove unnecessary uses of <utility>"
Commit r12-2534 was incomplete and (by inspection derived
from an MMIX build) failing for targets without an insn for
compare_and_swap for pointer-size objects, IOW for targets
for which "ATOMIC_POINTER_LOCK_FREE != 2" is true:

x/gcc/libstdc++-v3/src/c++17/memory_resource.cc: In member function
 'std::pmr::memory_resource*
std::pmr::{anonymous}::atomic_mem_res::exchange(std::pmr::memory_resource*)':
x/gcc/libstdc++-v3/src/c++17/memory_resource.cc:140:21: error:
 'exchange' is not a member of 'std'
  140 |         return std::exchange(val, r);
      |                     ^~~~~~~~
make[5]: *** [Makefile:577: memory_resource.lo] Error 1
make[5]: Leaving directory
 '/home/hp/tmp/newmmix-r12-2579-p3/gccobj/mmix/libstdc++-v3/src/c++17'

This fix was derived from edits elsewhere in that patch.

Tested mmix-knuth-mmixware, restoring build (together with
target-reviving patches as MMIX is currently and at that commit
broken for target-specific reasons).

libstdc++-v3/:
	* src/c++17/memory_resource.cc: Use __exchange instead
	of std::exchange.
2021-07-30 01:27:26 +02:00
GCC Administrator af3f12e6e8 Daily bump. 2021-07-28 00:16:25 +00:00
Jonathan Wakely 9360d6cd17 libstdc++: Simplify std::optional::value()
The structure of these functions likely dates from the time before G++
fully supported C++14 extended constexpr, so that the throw expression
had to be the operand of a conditional expression. That is not true now,
so we can use a more straightforward version of the code.

We can also simplify the declaration of __throw_bad_optional_access by
using the C++11-style [[noreturn]] attribute so that a separate
declaration isn't needed.

libstdc++-v3/ChangeLog:

	* include/experimental/optional (__throw_bad_optional_access):
	Replace GNU attribute with C++11 attribute.
	(optional::value, optional::value_or): Use if statements
	instead of conditional expressions.
	* include/std/optional (__throw_bad_optional_access)
	(optional::value, optional::value_or): Likewise.
2021-07-27 21:36:01 +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 7ffba77d01 libstdc++: Adjust whitespace in <bits/cow_string.h>
libstdc++-v3/ChangeLog:

	* include/bits/cow_string.h: Consistently use tab for
	indentation.
2021-07-27 12:13:42 +01:00
Jonathan Wakely 7b527614dd libstdc++: Move COW string definitions to separate header
This moves the definitions of the COW string to a separate file, so that
they don't need to be preprocessed for the common case. We could also
move the SSO string definitions to a new file, so that they don't need
to be preprocessed for the old ABI case, but that would require more
shovel work because there are some parts of <bits/basic_string.h> and
<bits/basic_string.tcc> that are common to both definitions.

libstdc++-v3/ChangeLog:

	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/bits/basic_string.h [!_GLIBCXX_USE_CXX11_ABI]
	(basic_string): Move definition of Copy-on-Write string to
	new file.
	* include/bits/basic_string.tcc: Likewise.
	* include/bits/cow_string.h: New file.
2021-07-27 12:04:18 +01: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
GCC Administrator ead235f601 Daily bump. 2021-07-24 00:16:44 +00:00
Jonathan Wakely 3ea62a2b2e libstdc++: Reduce headers included by <future>
The <future> header only needs std::atomic_flag, so can include
<bits/atomic_base.h> instead of the whole of <atomic>.

libstdc++-v3/ChangeLog:

	* include/std/future: Include <bits/atomic_base.h> instead of
	<atomic>.
2021-07-23 13:27:45 +01:00
Jonathan Wakely 5b965dc49a libstdc++: Update documentation comments for namespace rel_ops
The comments in <bits/stl_relops.h> describe problems that were solved
years ago (for GCC 3.1). The comparison operators in <iterator> are no
longer ambiguous with the rel_ops ones, so the linked mailing list
thread and FAQ entry aren't relevant now. The reference to std_utility.h
is also outdated as it's just called utility now, both in the source
tree and when installed.

The use of rel_ops is still frowned upon though, so replace the
discussion of ambiguities within libstdc++ headers with adminition about
using rel_ops in user code.

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

libstdc++-v3/ChangeLog:

	* include/bits/stl_relops.h: Update documentation comments.
2021-07-23 11:22:10 +01:00
GCC Administrator 01ac2f08b0 Daily bump. 2021-07-23 00:16:31 +00: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
David Edelsohn 3f7a2374d3 aix: Protect AIX math.h overloads with new macro.
AIX math.h provides C++ overloaded inlined math functions, which should
not be present for G++. The definitions have been guaded by
__COMPATMATH__, but that macro had other uses in IBM xlC++. A new
macro has been introduced with the sole purpose of guarding the functions.
This patch updates libstdc++ os_defines.h to define the additional macro.
The earlier macro definition is retained to guard the functions in the
math.h header of earlier AIX releases.

libstdc++-v3/ChangeLog:

	* config/os/aix/os_defines.h (__LIBC_NO_CPP_MATH_OVERLOADS__): Define.
2021-07-22 11:30:34 -04:00
Jonathan Wakely c9ca352186 libstdc++: Use __builtin_operator_new when available [PR94295]
Clang provides __builtin_operator_new and __builtin_operator_delete,
which have the same semantics as ::operator new and ::operator delete
except that the compiler is allowed to elide calls to them. This changes
std::allocator to use those built-in functions so that memory allocated
by std::allocator can be optimized away when using Clang. This avoids an
abstraction penalty for using std::allocator to allocate storage rather
than a new-expression.

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

libstdc++-v3/ChangeLog:

	PR libstdc++/94295
	* include/ext/new_allocator.h (_GLIBCXX_OPERATOR_NEW)
	(_GLIBCXX_OPERATOR_DELETE, _GLIBCXX_SIZED_DEALLOC): Define.
	(allocator::allocate, allocator::deallocate): Use new macros.
2021-07-22 14:38:34 +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 c22bcfd2f7 libstdc++: Initialize all subobjects of std::function
The std::function::swap member swaps each data member unconditionally,
resulting in -Wmaybe-uninitialized warnings for a default constructed
object. This happens because the _M_invoker and _M_functor members are
only initialized if the function has a target.

This change ensures that all subobjects are zero-initialized on
construction.

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

libstdc++-v3/ChangeLog:

	* include/bits/std_function.h (_Function_base): Add
	default member initializers and define constructor as defaulted.
	(function::_M_invoker): Add default member initializer.
2021-07-22 13:53:57 +01:00
Jonathan Wakely 254e5d19a1 libstdc++: Restore __gnu_debug::array [PR100682]
As the PR points out, we removed the debug version of std::array without
any period of deprecation. Although std::array contains all the actual
debug checks now, removing the <debug/arrray> header breaks any code
that was using that explicitly. The manual still lists doing that as
supported.

This restores the <debug/array> header, but simply defines
__gnu_debug::array as an alias for std::array, and declares the alias
with the deprecated attribute. The docs are updated to match.

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

libstdc++-v3/ChangeLog:

	PR libstdc++/100682
	* doc/xml/manual/debug_mode.xml: Update documentation about
	debug capability of std::array.
	* doc/html/*: Regenerate.
	* include/debug/array: New file.
2021-07-22 13:53:57 +01:00
GCC Administrator 419c6c68e6 Daily bump. 2021-07-22 00:16:46 +00: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
GCC Administrator 92d4550991 Daily bump. 2021-07-21 00:16:54 +00: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
GCC Administrator 87277b6a04 Daily bump. 2021-07-17 00:16:31 +00: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 7581559168 libstdc++: Fix ChangeLog entry for commit r12-2326 2021-07-16 15:03:04 +01:00
Jonathan Wakely bfb0586ebd libstdc++: Simplify numeric_limits<__max_size_type>
If __int128 is supported then __int_traits<__int128> is guaranteed to be
specialized, so we can remove the preprocessor condition inside the
std::numeric_traits<__detail::__max_size_type> specialization. Simply
using __int_traits<_Sp::__rep> gives the right answer.

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

libstdc++-v3/ChangeLog:

	* include/bits/max_size_type.h (numeric_limits<__max_size_type>):
	Use __int_traits unconditionally.
2021-07-16 15:03:03 +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
Jonathan Wakely 42167831ab libstdc++: Use __extension__ instead of diagnostic pragmas
This reverts c1676651b6 and uses the
__extension__ keyword to prevent pedantic warnings instead of diagnostic
pragmas.

This also adds the __extension__ keyword in <limits> and <bits/random.h>
where there are some more warnings that I missed in the previous commit.

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

libstdc++-v3/ChangeLog:

	* include/bits/cpp_type_traits.h (__INT_N): Use __extension__
	instead of diagnostic pragmas.
	* include/bits/functional_hash.h: Likewise.
	* include/bits/iterator_concepts.h (__is_signed_int128)
	(__is_unsigned_int128): Likewise.
	* include/bits/max_size_type.h (__max_size_type): Likewise.
	(numeric_limits<__max_size_type>): Likewise.
	* include/bits/std_abs.h (abs): Likewise.
	* include/bits/stl_algobase.h (__size_to_integer): Likewise.
	* include/bits/uniform_int_dist.h (uniform_int_distribution):
	Likewise.
	* include/ext/numeric_traits.h (_GLIBCXX_INT_N_TRAITS):
	Likewise.
	* include/std/type_traits (__is_integral_helper<INT_N>)
	(__is_signed_integer, __is_unsigned_integer)
	(__make_unsigned<INT_N>, __make_signed<INT_N>): Likewise.
	* include/std/limits (__INT_N): Add __extension__ keyword.
	* include/bits/random.h (_Select_uint_least_t)
	(random_device): Likewise.
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 adc03d72c3 libstdc++: Adjust doxygen markup for unique_ptr grouping
This reorders the @{ and @relates tags, and moves the definition of the
__cpp_lib_make_unique macro out of the group, as it seems to confuse
doxygen.

libstdc++-v3/ChangeLog:

	* include/bits/unique_ptr.h: Adjust doxygen markup.
2021-07-16 08:40:44 +01:00
Jonathan Wakely da89dfc2a0 libstdc++: Adjust doxygen markup for variable templates group [PR101307]
libstdc++-v3/ChangeLog:

	PR libstdc++/101307
	* include/std/type_traits: Adjust doxygen markup.
2021-07-16 08:40:43 +01:00
Jonathan Wakely c1676651b6 libstdc++: Suppress pedantic warnings about __int128
With -std=c++NN -pedantic -Wsystem-headers there are warnings about the
use of __int128, which can be suppressed using diagnostic pragmas.

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

libstdc++-v3/ChangeLog:

	* include/bits/cpp_type_traits.h: Add diagnostic pragmas around
	uses of non-standard integer types.
	* include/bits/functional_hash.h: Likewise.
	* include/bits/iterator_concepts.h: Likewise.
	* include/bits/max_size_type.h: Likewise.
	* include/bits/std_abs.h: Likewise.
	* include/bits/stl_algobase.h: Likewise.
	* include/bits/uniform_int_dist.h: Likewise.
	* include/ext/numeric_traits.h: Likewise.
	* include/std/type_traits: Likewise.
2021-07-16 08:40:43 +01:00
GCC Administrator d97d71a198 Daily bump. 2021-07-16 00:16:25 +00: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 1f7182d68c libstdc++: Add noexcept to __replacement_assert [PR101429]
This results in slightly smaller code when assertions are enabled when
either using Clang (because it adds code to call std::terminate when
potentially-throwing functions are called in a noexcept function) or a
freestanding or non-verbose build (because it doesn't use printf).

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

libstdc++-v3/ChangeLog:

	PR libstdc++/101429
	* include/bits/c++config (__replacement_assert): Add noexcept.
	[!_GLIBCXX_VERBOSE] (__glibcxx_assert_impl): Use __builtin_trap
	instead of __replacement_assert.
2021-07-15 16:25:42 +01:00
GCC Administrator c4fee1c646 Daily bump. 2021-07-15 00:16:54 +00: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
GCC Administrator 0e7754560f Daily bump. 2021-07-14 00:16:44 +00:00
Jonathan Wakely 4d3eaeb4f5 libstdc++: Simplify basic_string_view::ends_with [PR 101361]
The use of npos triggers a diagnostic as described in PR c++/101361.
This change replaces the use of npos with the exact length, which is
already known. We can further simplify it by inlining the effects of
compare and substr, avoiding the redundant range checks in the latter.

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

libstdc++-v3/ChangeLog:

	PR c++/101361
	* include/std/string_view (ends_with): Use traits_type::compare
	directly.
2021-07-13 15:21:26 +01:00
Jonathan Wakely bd1eb556b9 libstdc++: Remove duplicate #include in <string_view>
When I added the new C++23 constructor I added a conditional include of
<bits/ranges_base.h>, which was already being included unconditionally.
This removes the unconditional include but changes the condition for the
other one, so it's used for C++20 as well.

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

libstdc++-v3/ChangeLog:

	* include/std/string_view: Only include <bits/ranges_base.h>
	once, and only for C++20 and later.
2021-07-13 12:09:37 +01:00
GCC Administrator 07bcbf9cc2 Daily bump. 2021-07-13 00:16:30 +00: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
GCC Administrator ef2ace642a Daily bump. 2021-07-10 00:16:53 +00:00
Matheus Castanho 2e345e4ad6 libstdc++: Only use __gthread_yield if gthreads is available
libstdc++-v3/ChangeLog:

	* include/std/mutex (__lock_impl): Check
	_GLIBCXX_HAS_GTHREADS before using __gthread_yield.
2021-07-09 15:13:38 +01:00
GCC Administrator 7a60a6e8b3 Daily bump. 2021-07-03 00:16:31 +00: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
GCC Administrator bea7c16a46 Daily bump. 2021-07-02 00:16:47 +00:00
Jonathan Wakely f2ce64b53f libstdc++: Improvements to Doxygen markup
This attempst to improve the doxygen output to work around what seems to
be some bugs in doxygen (issues 8635 and 8638).

The @addtogroup command doesn't work for entities inside a nested
namespace (see 8635) so we need to close and reopen groups on entering
and elaving nested namespaces. This fixes the problem that
chrono::duration and chrono::time_point were not documented in the
"Time" documentation group. I am unable to make the path classes appear
as part of their relevant groups (File System and Filesystem TS), nor
the contents of <exception> or <system_error>. I have made some minor
improvements to the docs for those types, including starting to address
PR 97001 by adding @since to the doxygen comments.

This change also excludes the <experimental/bits/net.h> header from
Doxygen processing, so we don't get an unwanted "Networking-ts" group
in the documentation.

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

libstdc++-v3/ChangeLog:

	* doc/doxygen/doxygroups.cc: Fix docs for std::literals.
	* doc/doxygen/user.cfg.in: Exclude the Networking TS header.
	Add some more predefined macros.
	* include/bits/fs_fwd.h: Move @addtogroup commands inside
	namespaces. Add better documentation.
	* include/bits/fs_path.h: Likewise.
	* include/experimental/bits/fs_fwd.h: Likewise.
	* include/experimental/bits/fs_path.h: Likewise.
	* include/ext/throw_allocator.h: Fix typo and improve docs.
	* include/std/chrono: Move @addtogroup commands.
	* include/std/system_error: Move @addtogroup commands.
	* libsupc++/exception: Improve documentation.
	* libsupc++/exception.h: Add @since documentation.
2021-07-01 18:45:48 +01:00
GCC Administrator 25b6bfea5f Daily bump. 2021-07-01 00:16:41 +00: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 36adced3b6 libstdc++: Make <experimental/simd> depend on C++17
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/experimental/simd: Do not define anything pre-C++17.
2021-07-01 00:15:43 +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
GCC Administrator c8abc2058e Daily bump. 2021-06-29 00:16:42 +00:00
Jonathan Wakely 084635aa80 libstdc++: Remove redundant explicit instantiations
These function templates are explicitly specialized for char and wchar_t
streambufs, so the explicit instantiations do nothing. Remove them, to
avoid confusion.

libstdc++-v3/ChangeLog:

	* include/bits/streambuf.tcc (__copy_streambufs_eof): Remove
	explicit instantiation declarations.
	* src/c++11/streambuf-inst.cc (__copy_streambufs_eof): Remove
	explicit instantiation definitions.
2021-06-28 15:16:08 +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
GCC Administrator 90708f87b8 Daily bump. 2021-06-26 00:16:39 +00:00
Jonathan Wakely 4a52cf2eb9 libstdc++: Avoid intercepting exception in ostream::write
Currently if ostream::write fails and sets badbit and that causes an
exception, we will catch the exception, set badbit again, and rethrow
the exception.

This change delays setting badbit until after the try-catch block, so
that if it causes an exception we don't need to catch and rethrow it.

This removes the last remaining use of _M_write, so it can be made
private (or removed entirely for versioned namespace builds, where ABI
compatibility is not required). All other uses of _M_write were replaced
by calls to __ostream_insert, so make _M_write use that too.

libstdc++-v3/ChangeLog:

	* include/bits/ostream.tcc (basic_ostream::write): Call sputn
	directly instead of using _M_write. Do setstate(__err) all
	outside the try-catch block.
	* include/std/ostream (basic_ostream::_M_write): Declare
	private. Use __ostream_insert. Do not define for the versioned
	namespace.
2021-06-25 18:47:44 +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 7ab7fa1b51 libstdc++: Remove noexcept from syncbuf::swap (LWG 3498)
The proposed resolution for the inconsistent noexcept-specifiers in the
spec is to remove it from bto hthe assignment operator and swap.

libstdc++-v3/ChangeLog:

	* include/std/syncstream (basic_syncbuf::swap()): Remove
	noexcept, as per LWG 3498.
2021-06-25 18:41:30 +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
GCC Administrator 9aa8327e86 Daily bump. 2021-06-25 00:16:53 +00:00
Matthias Kretz addd5f0e61 libstdc++: Fix internal names: add missing underscores
Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

libstdc++-v3/ChangeLog:

	* include/experimental/bits/simd_math.h
	(_GLIBCXX_SIMD_MATH_CALL2_): Rename arg2_ to __arg2.
	(_GLIBCXX_SIMD_MATH_CALL3_): Rename arg2_ to __arg2 and arg3_ to
	__arg3.
2021-06-24 14:33:21 +01:00
Matthias Kretz 8888795ad1 libstdc++: Ensure unrolled loops inline the lambda
Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

libstdc++-v3/ChangeLog:

	* include/experimental/bits/simd.h (__execute_on_index_sequence)
	(__execute_on_index_sequence_with_return)
	(__call_with_n_evaluations, __call_with_subscripts): Add flatten
	attribute.
2021-06-24 14:33:21 +01:00
Matthias Kretz d5125819d8 libstdc++: Avoid raising fp exceptions in trunc, floor, and ceil
Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

libstdc++-v3/ChangeLog:

	* include/experimental/bits/simd_x86.h (_S_trunc, _S_floor)
	(_S_ceil): Set bit 8 (_MM_FROUND_NO_EXC) on AVX and SSE4.1
	roundp[sd] calls.
2021-06-24 14:33:20 +01:00
Matthias Kretz 5014f12509 libstdc++: Fix condition when AVX512F ldexp implementation is used
This improves codegen of ldexp if AVX512VL is available.

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

libstdc++-v3/ChangeLog:

	* include/experimental/bits/simd_x86.h (_S_ldexp): The AVX512F
	implementation doesn't require a _VecBltnBtmsk ABI tag, it
	requires either a 64-Byte input (in which case AVX512F must be
	available) or AVX512VL.
2021-06-24 14:33:20 +01:00
Matthias Kretz 62a989ea66 libstdc++: Minor simd_math cleanups
Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

libstdc++-v3/ChangeLog:

	* include/experimental/bits/simd_math.h: Undefine internal
	macros after use.
	(frexp): Move #if to a more sensible position and reformat
	preceding code.
	(logb): Call _SimdImpl::_S_logb for fixed_size instead of
	duplicating the code here.
	(modf): Simplify condition.
2021-06-24 14:33:20 +01:00
Matthias Kretz dd1c7792d6 libstdc++: Remove incorrect fabs(simd) overload
fabs(int) returns double, this one didn't. This overload is not
specified in the Parallelism TS 2. Also remove the comment about labs
and llabs: it doesn't belong here.

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

libstdc++-v3/ChangeLog:

	* include/experimental/bits/simd_math.h (fabs): Remove
	fabs(simd<integral>) overload.
2021-06-24 14:33:19 +01:00
Matthias Kretz 343f01f4cd libstdc++: Improve simd fixed_size codegen
Sometimes fixed_size objects will get unnecessarily copied on the stack.
The simd implementation should never pass _SimdTuple by value to avoid
requiring the optimizer to see through these copies.

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

libstdc++-v3/ChangeLog:

	* include/experimental/bits/simd_converter.h
	(_SimdConverter::operator()): Pass _SimdTuple by const-ref.
	* include/experimental/bits/simd_fixed_size.h
	(_GLIBCXX_SIMD_FIXED_OP): Pass binary operator _SimdTuple
	arguments by const-ref.
	(_S_masked_unary): Pass _SimdTuple by const-ref.
2021-06-24 14:20:14 +01:00
Matthias Kretz ebb45cb816 libstdc++: Remove dead code in simd
This helper type became unused at some point.

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

libstdc++-v3/ChangeLog:

	* include/experimental/bits/simd_fixed_size.h
	(_AbisInSimdTuple): Removed.
2021-06-24 14:20:14 +01:00
Matthias Kretz 0237aa8c70 libstdc++: Improve copysign(simd) codegen
This also resolves a test failure on aarch64 with -ffast-math and
fixed_size<N> with large N.

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

libstdc++-v3/ChangeLog:

	* include/experimental/bits/simd.h: Add missing operator~
	overload for simd<floating-point> to __float_bitwise_operators.
	* include/experimental/bits/simd_builtin.h
	(_SimdImplBuiltin::_S_complement): Bitcast to int (and back) to
	implement complement for floating-point vectors.
	* include/experimental/bits/simd_fixed_size.h
	(_SimdImplFixedSize::_S_copysign): New function, forwarding to
	copysign implementation of _SimdTuple members.
	* include/experimental/bits/simd_math.h (copysign): Call
	_SimdImpl::_S_copysign for fixed_size arguments. Simplify
	generic copysign implementation using the new ~ operator.
2021-06-24 14:20:13 +01: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
GCC Administrator fcf617f0d2 Daily bump. 2021-06-24 00:16:30 +00: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
Jonathan Wakely 4a404f66b0 libstdc++: Fix comment in chrono::year::is_leap()
libstdc++-v3/ChangeLog:

	* include/std/chrono (chrono::year::is_leap()): Fix incorrect
	logic in comment.
2021-06-23 18:50:03 +01: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
Cassio Neri b92d12d3fe libstdc++: More efficient std::chrono::year::leap
Simple change to std::chrono::year::is_leap. If a year is multiple of 100,
then it's divisible by 400 if and only if it's divisible by 16. The latter
allows for better code generation.

The expression is then either y%16 or y%4 which are both powers of two
and so it can be rearranged to use simple bitmask operations.

Co-authored-by: Jonathan Wakely <jwakely@redhat.com>
Co-authored-by: Ulrich Drepper <drepper@redhat.com>

libstdc++-v3/ChangeLog:

	* include/std/chrono (chrono::year::is_leap()): Optimize.
2021-06-23 18:28:08 +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
GCC Administrator 419af06a35 Daily bump. 2021-06-23 00:16:28 +00: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
GCC Administrator 2f080224cf Daily bump. 2021-06-22 00:16:29 +00:00
Jonathan Wakely 6cf0040fff libstdc++: Improve std::lock algorithm
The current std::lock algorithm is the one called "persistent" in Howard
Hinnant's https://howardhinnant.github.io/dining_philosophers.html post.
While it tends to perform acceptably fast, it wastes a lot of CPU cycles
by continuously locking and unlocking the uncontended mutexes.
Effectively, it's a spin lock with no back-off.

This replaces it with the one Howard calls "smart and polite". It's
smart, because when a Mi.try_lock() call fails because mutex Mi is
contended, the algorithm reorders the mutexes until Mi is first, then
calls Mi.lock(), to block until Mi is no longer contended.  It's
polite because it uses std::this_thread::yield() between the failed
Mi.try_lock() call and the Mi.lock() call. (In reality it uses
__gthread_yield() directly, because using this_thread::yield() would
require shuffling code around to avoid a circular dependency.)

This version of the algorithm is inspired by some hints from Howard, so
that it has strictly bounded stack usage. As the comment in the code
says:

// This function can recurse up to N levels deep, for N = 1+sizeof...(L1).
// On each recursion the lockables are rotated left one position,
// e.g. depth 0: l0, l1, l2; depth 1: l1, l2, l0; depth 2: l2, l0, l1.
// When a call to l_i.try_lock() fails it recurses/returns to depth=i
// so that l_i is the first argument, and then blocks until l_i is locked.

The 'i' parameter is the desired permuation of the lockables, and the
'depth' parameter is the depth in the call stack of the current
instantiation of the function template. If i == depth then the function
calls l0.lock() and then l1.try_lock()... for each lockable in the
parameter pack l1.  If i > depth then the function rotates the lockables
to the left one place, and calls itself again to go one level deeper.
Finally, if i < depth then the function returns to a shallower depth,
equivalent to a right rotate of the lockables.  When a call to
try_lock() fails, i is set to the index of the contended lockable, so
that the next call to l0.lock() will use the contended lockable as l0.

This commit also replaces the std::try_lock implementation details. The
new code is identical in behaviour, but uses a pair of constrained
function templates. This avoids instantiating a class template, and is a
litle simpler to call where used in std::__detail::__lock_impl and
std::try_lock.

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

libstdc++-v3/ChangeLog:

	* include/std/mutex (__try_to_lock): Move to __detail namespace.
	(struct __try_lock_impl): Replace with ...
	(__detail::__try_lock_impl<Idx>(tuple<Lockables...>&)): New
	function templates to implement std::try_lock.
	(try_lock): Use new __try_lock_impl.
	(__detail::__lock_impl(int, int&, L0&, L1&...)): New function
	template to implement std::lock.
	(lock): Use __lock_impl.
2021-06-21 18:29:58 +01:00
Patrick Palka 12bdd39755 libstdc++: Sync __cpp_lib_ranges macro defined in ranges_cmp.h
r12-1606 bumped the value of __cpp_lib_ranges defined in <version>,
but this macro is also defined in <bits/range_cmp.h>, so it needs to
be updated there as well.

libstdc++-v3/ChangeLog:

	* include/bits/ranges_cmp.h (__cpp_lib_ranges): Adjust value.
2021-06-21 09:45:31 -04:00
GCC Administrator 3e42ff7156 Daily bump. 2021-06-21 00:16:25 +00: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 85a594f7dc libstdc++: Define split_view::_InnerIter::base as per P2210
libstdc++-v3/ChangeLog:

	* include/std/ranges (split_view::_InnerIter::base): Define as
	per P2210.
2021-06-20 12:38:35 -04:00
GCC Administrator b245d1c3d6 Daily bump. 2021-06-20 00:16:21 +00:00
Patrick Palka bc046a60cf libstdc++: Implement LWG 3555 changes to transform/elements_view
libstdc++-v3/ChangeLog:

	* include/std/ranges (transform_view::_Iterator::_S_iter_concept):
	Consider _Base instead of _Vp as per LWG 3555.
	(elements_view::_Iterator::_S_iter_concept): Likewise.
2021-06-18 20:50:23 -04:00
Patrick Palka 15736576df libstdc++: Implement LWG 3553 changes to split_view
libstdc++-v3/ChangeLog:

	* include/std/ranges (split_view::_OuterIter::value_type::begin):
	Remove the non-const overload, and remove the copyable constraint
	on the const overload as per LWG 3553.
2021-06-18 20:50:22 -04:00
Patrick Palka 4123650bd0 libstdc++: Implement LWG 3546 changes to common_iterator
libstdc++-v3/ChangeLog:

	* include/bits/stl_iterator.h
	(__detail::__common_iter_use_postfix_proxy): Add
	move_constructible constraint as per LWG 3546.
	(common_iterator::__postfix_proxy): Adjust initializer of
	_M_keep as per LWG 3546.
2021-06-18 20:50:13 -04:00
GCC Administrator c5581d4842 Daily bump. 2021-06-19 00:16:33 +00: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
Patrick Palka 83faf7eacd libstdc++: Implement LWG 3557 change to convertible_to
libstdc++-v3/ChangeLog:

	* include/std/concepts (convertible_to): Just use declval as per
	LWG 3557.
2021-06-18 11:51:33 -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 2786064d91 libstdc++: Move ranges algos used by <ranges> into ranges_util.h
The <ranges> header defines simplified copies of some ranges algorithms
in order to avoid including the entirety of ranges_algo.h.  A subsequent
patch is going to want to use ranges::search in <ranges> as well, and
that algorithm is more complicated compared to the other copied ones.

So rather than additionally copying ranges::search into <ranges>, this
patch splits out all the ranges algos used by <ranges> (including
ranges::search) from ranges_algo.h to ranges_util.h, and deletes the
simplified copies in <ranges>.  This seems like the best place to
put these algorithms, as ranges_util.h is currently included only from
<ranges> and ranges_algo.h.

libstdc++-v3/ChangeLog:

	* include/bits/ranges_algo.h (__find_fn, find, __find_if_fn)
	(find_if, __find_if_not_fn, find_if_not, _in_in_result)
	(__mismatch_fn, mismatch, __search_fn, search): Move to ...
	* include/bits/ranges_util.h: ... here.
	* include/std/ranges (__detail::find, __detail::find_if)
	(__detail::find_if_not, __detail::mismatch): Remove.
	(filter_view): Use ranges::find_if instead.
	(drop_while_view): Use ranges::find_if_not instead.
	(split_view): Use ranges::find and ranges::mismatch instead.
2021-06-17 22:44:41 -04: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
GCC Administrator 688359a27d Daily bump. 2021-06-18 00:16:58 +00:00
Jonathan Wakely b376b1ef38 libstdc++: Simplify constexpr checks in std::char_traits [PR 91488]
This removes the helper functions added by r8-1294 to detect whether the
char_traits member functions can be evaluated at compile time. Instead,
we can just use __builtin_constant_evaluated directly, which is well
supported by non-GCC compilers by now.

As a result, there is a chance that those members will no longer be
usable in constant expressions when using old versions of non-GCC
compilers. Make the relevant feature test macros depend on the
availability of __builtin_constant_evaluated, so they are defined only
when the feature is actualyl available.

The new testcase from the PR is added to the libitm testsuite, because
that's where we can be sure it's OK to use the -fgnu-tm option.

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

	PR libstdc++/91488

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.h (__cpp_lib_constexpr_string): Only
	define when is_constant_evaluated is available.
	* include/bits/char_traits.h (__cpp_lib_constexpr_char_traits):
	Likewise.
	(__constant_string_p, __constant_array_p): Remove.
	(char_traits): Use is_constant_evaluated directly.
	* include/std/version (__cpp_lib_constexpr_char_traits)
	(__cpp_lib_constexpr_string): Only define when
	is_constant_evaluated is available.

libitm/ChangeLog:

	* testsuite/libitm.c++/libstdc++-pr91488.C: New test.
2021-06-17 22:00:58 +01: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
GCC Administrator 9a61dfdb5e Daily bump. 2021-06-17 00:16:54 +00:00
Jonathan Wakely c25e3bf879 libstdc++: Use named struct for __decay_copy
In r12-1486-gcb326a6442f09cb36b05ce556fc91e10bfeb0cf6 I changed
__decay_copy to be a function object of unnamed class type. This causes
problems when importing the library headers:

error: conflicting global module declaration 'constexpr const std::ranges::__cust_access::<unnamed struct> std::ranges::__cust_access::__decay_copy'

The fix is to use a named struct instead of an anonymous one.

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

libstdc++-v3/ChangeLog:

	* include/bits/iterator_concepts.h (__decay_copy): Name type.
2021-06-16 14:31:13 +01: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
GCC Administrator ede6c3568f Daily bump. 2021-06-16 00:17:05 +00: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 cb326a6442 libstdc++: Use function object for __decay_copy helper
By changing __cust_access::__decay_copy from a function template to a
function object we avoid ADL. That means it's fine to call it
unqualified (the compiler won't waste time doing ADL in associated
namespaces, and won't try to complete associated types).

This also makes some other minor simplications to other concepts for the
[range.access] CPOs.

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

libstdc++-v3/ChangeLog:

	* include/bits/iterator_concepts.h (__cust_access::__decay_copy):
	Replace with function object.
	(__cust_access::__member_begin, ___cust_access::_adl_begin): Use
	__decay_copy unqualified.
	* include/bits/ranges_base.h (__member_end, __adl_end):
	Likewise. Use __range_iter_t for type of ranges::begin.
	(__member_rend): Use correct value category for rbegin argument.
	(__member_data): Use __decay_copy unqualified.
	(__begin_data): Use __range_iter_t for type of ranges::begin.
2021-06-15 18:20:06 +01:00
GCC Administrator 8dc48181af Daily bump. 2021-06-15 00:16:37 +00: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
GCC Administrator f16f65f836 Daily bump. 2021-06-12 00:16:27 +00: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
GCC Administrator 4f625f47b4 Daily bump. 2021-06-10 00:16:30 +00: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
GCC Administrator c603872145 Daily bump. 2021-06-09 00:16:30 +00: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
Thomas Rodgers 16a8e18858 [libstdc++] Remove unused hasher instance.
This is a remnant of poorly executed refactoring.

libstdc++-v3/ChangeLog:

	* include/std/barrier (__tree_barrier::_M_arrive): Remove
	unnecessary hasher instantiation.
2021-06-08 15:41:31 -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
GCC Administrator 438aac594e Daily bump. 2021-06-08 00:16:44 +00:00
Avi Kivity 5e2e15f212 libstdc++: add missing typename for dependent type in ranges::elements_view [PR100900]
Clang complains about the missing typename. I believe it's not required
in a more complete implementation of C++, but it's nicer to support
less complete implementations.

	PR libstdc++/100900

libstdc++-v3/ChangeLog:

	* include/std/ranges (elements_view::__iter_cat::_S_iter_cat):
	Add missing typename.
2021-06-07 11:19:05 -04: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
GCC Administrator 28c6247505 Daily bump. 2021-06-06 00:16:22 +00: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
GCC Administrator 600f90cbbb Daily bump. 2021-06-05 00:16:29 +00: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
Tim Adye f6bb145c0b libstdc++: Optimize std::any_cast by replacing indirect call
This significantly improves the performance of std::any_cast, by
avoiding an indirect call to the _S_manage function through a function
pointer. Before we make that indirect call we've already established
that the contained value has the expected type, which means we also know
the manager type, and so can call one of its members directly.

We also know the precise type in the any::emplace functions, because
we've just constructed that type, so we can use the new member there
too. That doesn't seem to affect performance, but we might as well use
the new _S_access function anyway.

Signed-off-by: Tim Adye <Tim.Adye@cern.ch>
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* include/std/any (any::_Manager::_S_access): New static
	function to access the contained value.
	(any::emplace, __any_caster): Use _S_access member of the
	manager type.
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
GCC Administrator 440c8a0a91 Daily bump. 2021-06-04 00:16:24 +00: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
GCC Administrator 9663c744e2 Daily bump. 2021-06-03 00:16:23 +00: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
Jonathan Wakely ca35586cf5 libstdc++: Improve punctuation in implementation status docs
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

libstdc++-v3/ChangeLog:

	* doc/xml/manual/status_cxxis29124.xml: Improve punctuation.
	* doc/xml/manual/status_cxxtr1.xml: Likewise.
	* doc/xml/manual/status_cxxtr24733.xml: Likewise.
	* doc/html/*: Regenerate.
2021-06-02 12:32:13 +01:00
GCC Administrator b75978d14f Daily bump. 2021-06-02 00:16:43 +00: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 9f7bc160b4 libstdc++: Fix installation of python hooks [PR 99453]
When no shared library is installed, the new code to determine the name
of the -gdb.py file yields an empty string. Use the name of the static
library in that case.

libstdc++-v3/ChangeLog:

	PR libstdc++/99453
	* python/Makefile.am: Use archive name for printer hook if no
	dynamic library name is available.
	* python/Makefile.in: Regenerate.
2021-06-01 13:29:34 +01:00
GCC Administrator e21e934072 Daily bump. 2021-05-31 00:16:25 +00:00
Gerald Pfeifer a0a7adeea3 libstdc++: Remove "Intel Compilers" bibliography entry
The original link redirects to a very generic page that advertises
lots of tools and other things, just not this.

libstdc++-v3/ChangeLog:

2021-05-31  Gerald Pfeifer  <gerald@pfeifer.com>

	* doc/xml/manual/abi.xml: Remove dead reference to "Intel
	Compilers for Linux: Compatibility with GNU Compilers" article.
	* doc/html/manual/abi.html: Regenerate.
2021-05-31 00:27:17 +02:00
GCC Administrator 01c59ef2e5 Daily bump. 2021-05-27 00:16:53 +00:00
François Dumont a42220f016 libstdc++: [_GLIBCXX_DEBUG] Enhance rendering of assert message
Avoid building an intermediate buffer to print to stderr, push directly to stderr.

libstdc++-v3/ChangeLog:

	* include/debug/formatter.h
	(_Error_formatter::_Parameter::_Named): New.
	(_Error_formatter::_Parameter::_Type): Inherit latter.
	(_Error_formatter::_Parameter::_M_integer): Likewise.
	(_Error_formatter::_Parameter::_M_string): Likewise.
	* src/c++11/debug.cc: Include <cstring>.
	(_Print_func_t): New.
	(print_raw(PrintContext&, const char*, ptrdiff_t)): New.
	(print_word): Use '%.*s' format in fprintf to render only expected number of chars.
	(pretty_print(PrintContext&, const char*, _Print_func_t)): New.
	(print_type): Rename in...
	(print_type_info): ...this. Use pretty_print.
	(print_address, print_integer): New.
	(print_named_name, print_iterator_constness, print_iterator_state): New.
	(print_iterator_seq_type): New.
	(print_named_field, print_type_field, print_instance_field, print_iterator_field): New.
	(print_field): Use latters.
	(print_quoted_named_name, print_type_type, print_type, print_instance): New.
	(print_string(PrintContext&, const char*, const _Parameter*, size_t)):
	Change signature to...
	(print_string(PrintContext&, const char*, ptrdiff_t, const _Parameter*, size_t)):
	...this and adapt. Remove intermediate buffer to render input string.
	(print_string(PrintContext&, const char*, ptrdiff_t)): New.
2021-05-26 21:50:17 +02: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
GCC Administrator 637569df03 Daily bump. 2021-05-25 00:16:53 +00: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
GCC Administrator 2832d51b38 Daily bump. 2021-05-22 00:16:29 +00:00
Patrick Palka 11784fe27d libstdc++: Implement LWG 3490 change to drop_while_view::begin()
libstdc++-v3/ChangeLog:

	PR libstdc++/100606
	* include/std/ranges (drop_while_view::begin): Assert the
	precondition added by LWG 3490.
2021-05-21 00:05:18 -04: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
GCC Administrator ea34e2edd3 Daily bump. 2021-05-21 00:16:57 +00:00
Jonathan Wakely 64ba45c76e libstdc++: Do not use static_assert without message in C++11
libstdc++-v3/ChangeLog:

	* include/bits/random.tcc (__representable_as_double)
	(__p1_representable_as_double): Add "" to static asserts.
2021-05-20 21:12:15 +01: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