Commit graph

5912 commits

Author SHA1 Message Date
Jonathan Wakely
52841fb703 libstdc++: Replace dg-options "-std=c++11" with dg-add-options strict_std
These tests can (and should) also be run for later standards, so replace
the { dg-options "-std=c++11" } with { dg-add-options strict_std } and a
target selector for c++11.

libstdc++-v3/ChangeLog:

	* testsuite/23_containers/deque/48101-2_neg.cc: Replace
	dg-options with target selector.
	* testsuite/23_containers/forward_list/48101-2_neg.cc: Likewise.
	* testsuite/23_containers/list/48101-2_neg.cc: Likewise.
	* testsuite/23_containers/map/48101-2_neg.cc: Likewise.
	* testsuite/23_containers/map/48101_neg.cc: Likewise.
	* testsuite/23_containers/multimap/48101-2_neg.cc: Likewise.
	* testsuite/23_containers/multimap/48101_neg.cc: Likewise.
	* testsuite/23_containers/multiset/48101-2_neg.cc: Likewise.
	* testsuite/23_containers/set/48101-2_neg.cc: Likewise.
	* testsuite/23_containers/unordered_map/48101-2_neg.cc:
	Likewise.
	* testsuite/23_containers/unordered_multimap/48101-2_neg.cc:
	Likewise.
	* testsuite/23_containers/unordered_multiset/48101-2_neg.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/48101-2_neg.cc:
	Likewise.
	* testsuite/23_containers/vector/48101-2_neg.cc: Likewise.
2023-09-15 21:57:38 +01:00
Jonathan Wakely
3a0e01f6bb libstdc++: Add support for running tests with multiple -std options
This copies the code from the compiler's gcc/testsuite/lib/g++-dg.exp so
that each test can be run multiple times, with different -std options.
This means that we can remove most { dg-options "-std=gnu++20" }
directives from tests, because the testsuite will automatically select
a set of -std options that includes that version.

Tests that should only run for a specific standard (e.g. ones that use
something like { dg-do run { target c++11_only } }) should still specify
that standard with { dg-options "-std=gnu++11" }, which overrides the
automatic selection. But a dg-options that selects a newer standard than
the default can be removed, because that standard will be selected
automatically based on a selector like { target c++20 } in the dg-do
directive. This will allow those tests to be run for more than just the
one they currently hardcode, so that e.g. std::format tests can be run
for all of C++20, C++23 and C++26. Currently that has to be done by
adding a second test file that uses a different dg-options line.

By default most tests will continue to run with only the default dialect
(currently -std=gnu++17) so that the time to run the entire testsuite is
not increased. We can revisit this later if increasing the testsuite
time (and coverage) is acceptable. Libstdc++ developers can easily
override the defaults to run for multiple versions. To test all
versions, either add 'set v3_std_list { 98 11 14 17 20 23 26 }' to
~/.dejagnurc or define GLIBCXX_TESTSUITE_STDS="98,11,14,17,20,23,26" in
the environment.

This should be more efficient than the current way to test with multple
standards, i.e. --target_board=unix{-std=c++14,-std=c++17,-std=c++20},
because today all tests with an explicit -std option hardcoded in them
get run for each target board variation but using the exact same
hardcoded -std every time. With the new approach you can just use the
default --target_board=unix and set GLIBCXX_TESTSUITE_STDS="14,17,20"
and now a test that has { target c++20 } will only run once (and be
UNSUPPORTED twice), instead of running with identical options three
times.

In order to support ~/.dejagnurc and $DEJAGNU files that need to work
with versions of GCC without this change, a new variable is added to
site.tmp to detect whether v3_std_list is supported. That allows e.g.

if { [info exists v3-use-std-list] } {
  set v3_std_list { 11 17 23 }
  set target_list { "unix{,-m32}" }
} else {
  set target_list { "unix{,-std=gnu++2b,-std=gnu++11,-m32}" }
}

libstdc++-v3/ChangeLog:

	* doc/xml/manual/test.xml: Update documentation on running and
	writing tests.
	* doc/html/manual/test.html: Regenerate.
	* testsuite/Makefile.am: Add v3-use-std-list to site.tmp
	* testsuite/Makefile.in: Regenerate.
	* testsuite/lib/dg-options.exp (add_options_for_strict_std): New
	proc.
	* testsuite/lib/libstdc++.exp (search_for): New utility proc.
	(v3-dg-runtest): New proc to replace dg-runtest.
	* testsuite/libstdc++-dg/conformance.exp: Use v3-dg-runtest.
2023-09-15 21:57:38 +01:00
Jonathan Wakely
038c0afa89 libstdc++: Fix 29_atomics/headers/atomic/types_std_c++2a_neg.cc for C++23
This test fails when run as C++23 because the <bits/stdc++.h> PCH
includes <stdatomic.h> which declares ::memory_order, invalidating the
test's assumptions. Disable PCH so that the test verifies that <atomic>
doesn't declare ::memory_order, as originally intended.

Also fix the using-declaration which would be invalid even if the type
was declared in the global namespace, and adjust the expected error.

libstdc++-v3/ChangeLog:

	* testsuite/29_atomics/headers/atomic/types_std_c++2a_neg.cc:
	Fix test to work for C++23 and C++26 too.
2023-09-15 21:57:38 +01:00
Jonathan Wakely
5daeda573c libstdc++: Fix constraints for std::variant default constructor
The standard says the default ctor should be constrained, not deleted.
Our use of a defaulted default ctor and _Enable_default_constructor base
class results in it being deleted.

libstdc++-v3/ChangeLog:

	* include/std/variant (variant): Remove derivation from
	_Enable_default_constructor base class.
	(variant::variant()): Constrain.
	* testsuite/20_util/variant/default_ctor.cc: New test.
2023-09-15 10:24:01 +01:00
Jonathan Wakely
8fa1430bb2 libstdc++: Add operator bool to <charconv> result types (P2497R0)
C++26 adds these convenience conversions.

libstdc++-v3/ChangeLog:

	* include/bits/version.def (to_chars): Define new value for
	C++26.
	* include/bits/version.h: Regenerate.
	* include/std/charconv (to_chars_result::operator bool): New
	function.
	(from_chars_result::operator bool): New function.
	* testsuite/20_util/to_chars/version.cc: Update expected value.
	* testsuite/20_util/from_chars/result.cc: New test.
	* testsuite/20_util/to_chars/result.cc: New test.
2023-09-15 10:24:01 +01:00
Jonathan Wakely
557a858f2e libstdc++: Add testcase for std::make_integer_sequence bug [PR111357]
The compiler bug has been fixed on trunk, but this adds a regression test
for the library component.

libstdc++-v3/ChangeLog:

	PR c++/111357
	* testsuite/20_util/integer_sequence/pr111357.cc: New test.
2023-09-14 14:26:03 +01:00
Jonathan Wakely
9da3c935e3 libstdc++: Support dg-additional-files in tests
Some tests rely on text files with specific content being present in the
test directory.  This has historically been done by copying
testsuite/data/*.tst and testsuite/data/*.txt to the test dir at the
start, in the libstdc++_init procedure.  Some tests modify their data
files, so if the same test runs more than once in the same directory the
second and subsequent tests will see the modified files, and FAIL
because the content of the file is not in the expected state.

This change adds support for the dg-additional-files directive from the
main compiler testsuite and changes v3_target_compile to copy the
specified files to the directory where the test will run.  This ensures
that a fresh copy of the files is present each time the test runs.

Eventually all tests could be transitioned to use dg-additional-files
and then libstdc++_init could be changed to remove the initial copy of
all files.  This change only adds dg-additional-files to the tests that
modify their files and FAIL when re-run in the same directory.

The tests that rely on additional data files have comments containing
the strings "@require@" and "@diff@" which seem to be related to the
libstdc++-v3/mkcheck.in testing script that was removed in 2003.  Those
comments can be used to find tests that should be migrated to use the
new dg-additional-files support, and then the comments can be removed.

libstdc++-v3/ChangeLog:

	* testsuite/27_io/basic_filebuf/seekoff/char/1-io.cc: Use
	dg-additional-files. Remove @require@ and @diff@ comments.
	* testsuite/27_io/basic_filebuf/seekoff/char/2-io.cc: Likewise.
	* testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc: Likewise.
	* testsuite/27_io/basic_filebuf/seekpos/char/2-io.cc: Likewise.
	* testsuite/lib/dg-options.exp (v3_additional_files): New
	global variable.
	(dg-additional-files): New proc.
	* testsuite/lib/libstdc++.exp (v3_target_compile): Copy
	additional files to test directory.
2023-09-14 13:58:34 +01:00
Christophe Lyon
62b29347c3 libstdc++: Add dg-require-thread-fence in several tests
Some targets like arm-eabi with newlib and default settings rely on
__sync_synchronize() to ensure synchronization.  Newlib does not
implement it by default, to make users aware they have to take special
care.

This makes a few tests fail to link.

This patch requires the missing thread-fence effective target in the
tests that need it, making them UNSUPPORTED instead of FAIL and
UNRESOLVED.

2023-09-10  Christophe Lyon  <christophe.lyon@linaro.org>

	libstdc++-v3/
	* testsuite/29_atomics/atomic/compare_exchange_padding.cc: Likewise.
	* testsuite/29_atomics/atomic/cons/value_init.cc: Likewise.
	* testsuite/29_atomics/atomic_float/value_init.cc: Likewise.
	* testsuite/29_atomics/atomic_integral/cons/value_init.cc: Likewise.
	* testsuite/29_atomics/atomic_ref/compare_exchange_padding.cc: Likewise.
	* testsuite/29_atomics/atomic_ref/generic.cc: Likewise.
	* testsuite/29_atomics/atomic_ref/integral.cc: Likewise.
	* testsuite/29_atomics/atomic_ref/pointer.cc: Likewise.
2023-09-14 09:31:48 +00:00
François Dumont
5079b62098 libstdc++: Limit <stacktrace> synopsis test to normal namespace
libstdc++-v3/ChangeLog

	* testsuite/19_diagnostics/stacktrace/synopsis.cc: Add
	{ dg-require-normal-namespace "" }.
2023-09-14 06:26:18 +02:00
Patrick Palka
52f65d17c8 libstdc++: Fix std::not_fn perfect forwarding [PR111327]
The previous patch fixed perfect forwarding in std::bind_front.
This patch fixes the same issue in std::not_fn.

	PR libstdc++/111327

libstdc++-v3/ChangeLog:

	* include/std/functional (_GLIBCXX_NOT_FN_CALL_OP): Also define
	a deleted fallback operator() overload.  Constrain both the
	enabled and deleted overloads accordingly.
	* testsuite/20_util/function_objects/not_fn/111327.cc: New test.
2023-09-12 11:26:50 -04:00
Patrick Palka
4289f6ceef libstdc++: Fix std::bind_front perfect forwarding [PR111327]
In order to properly implement a perfect forwarding call wrapper (without
C++23 deducing 'this') we need a total of 8 operator() overloads, 4
enabled ones and 4 deleted ones, i.e. two for each const/ref qual pair,
as described in section 5.5 of P0847R6.  Otherwise the wrapper may not
do the right thing if the underlying function object has a deleted
const/ref-qualified operator() overload.  This patch fixes this issue in
std::bind_front.

	PR libstdc++/111327

libstdc++-v3/ChangeLog:

	* include/std/functional (_Bind_front::operator()): Add deleted
	fallback overloads for each const/ref qualifier pair.  Give the
	enabled overloads dummy constraints to make each one more
	specialized than the corresponding deleted overload.
	* testsuite/20_util/function_objects/bind_front/111327.cc: New test.
2023-09-12 11:23:12 -04:00
Jonathan Wakely
f1dd83b720 libstdc++: Formatting std:🧵:id and std::stacktrace (P2693R1)
New std::formatter specializations for C++23.

libstdc++-v3/ChangeLog:

	* include/bits/version.def (__cpp_lib_formatters): Define.
	* include/bits/version.h: Regenerate.
	* include/std/stacktrace (formatter<stacktrace_entry>)
	(formatter<basic_stacktrace<Alloc>>): Define.
	* include/std/thread (formatter<thread::id, charT>): Define.
	* testsuite/19_diagnostics/stacktrace/output.cc: New test.
	* testsuite/19_diagnostics/stacktrace/synopsis.cc: Add
	std::formatter specializations.
	* testsuite/19_diagnostics/stacktrace/version.cc: Check
	__cpp_lib_formatters macro.
	* testsuite/30_threads/thread/id/hash.cc: Remove gthreads
	dependency.
	* testsuite/30_threads/thread/id/operators.cc: Likewise.
	* testsuite/30_threads/thread/id/operators_c++20.cc: Likewise.
	* testsuite/30_threads/thread/id/output.cc: New test.
2023-09-11 14:56:58 +01:00
Jonathan Wakely
b96b554592 libstdc++: Add Filesystem TS and std::stacktrace symbols to libstdc++exp.a
This consolidates the three static archives for extensions into one, so
that -lstdc++exp can be used to provide the definitions of all unstable
library features.

The libstdc++_libbacktrace.a archive is now just a "noinst" convenience
library that is only used during the build, not installed. Its contents
are added to libstdc++exp.a, along with the new non-inline definitions
of std::stacktrace symbols.

The libstdc++fs.a archive is still installed, but its contents are
duplicated in libstdc++exp.a now. This means -lstdc++exp can be used
instead of -lstdc++fs. For targets using the GNU linker we should
consider replacing libstdc++fs.a with a linker script that does
INPUT(libstdc++exp.a).

The tests for <experimental/filesystem> could be changed to use
-lstdc++exp instead of -lstdc++fs, which would allow removing
src/filesystem/.libs from the LDFLAGS in scripts/testsuite_flags.in,
but that can be done at a later date.

libstdc++-v3/ChangeLog:

	* acinclude.m4 (GLIBCXX_CONFIGURE): Add c++23 directory.
	* configure: Regenerate.
	* doc/html/manual/*: Regenerate.
	* doc/xml/manual/using.xml: Update documentation on linking.
	* include/std/stacktrace: Remove declarations of libbacktrace
	APIs.
	(stacktrace_entry::_S_err_handler, stacktrace_entry::_S_init):
	Remove.
	(stacktrace_entry::_Info): New class.
	(stacktrace_entry::_M_get_info): Use _Info.
	(__stacktrace_impl): New class.
	(basic_stacktrace): Derive from __stacktrace_impl.
	(basic_stacktrace::current): Use __stacktrace_impl::_S_current.
	* scripts/testsuite_flags.in: Adjust LDFLAGS to find
	libstdc++exp instead of libstdc++_libbacktrace.
	* src/Makefile.am (SUBDIRS): Add c++23 directory.
	* src/Makefile.in: Regenerate.
	* src/c++20/Makefile.am: Fix comment.
	* src/c++20/Makefile.in: Regenerate.
	* src/c++23/Makefile.am: New file.
	* src/c++23/Makefile.in: New file.
	* src/c++23/stacktrace.cc: New file with definitions of
	stacktrace_entry::_Info and __stacktrace_impl members.
	* src/experimental/Makefile.am: Use LIBADD to include other
	libraries.
	* src/experimental/Makefile.in: Regenerate.
	* src/libbacktrace/Makefile.am: Use noinst_LTLIBRARIES.
	* src/libbacktrace/Makefile.in: Regenerate.
	* testsuite/19_diagnostics/stacktrace/current.cc: Adjust
	dg-options to use -lstdc++exp.
	* testsuite/19_diagnostics/stacktrace/entry.cc: Likewise.
	* testsuite/19_diagnostics/stacktrace/stacktrace.cc: Likewise.
	* testsuite/23_containers/vector/debug/assign4_backtrace_neg.cc:
	Likewise.
2023-09-08 18:04:12 +01:00
Jonathan Wakely
67009f143f libstdc++: Reduce output of 'make check'
This removes the 39 lines of shell commands that get echoed when
starting the testsuite. The fact that near the end of that output it
prints `echo "WARNING: could not find \`runtest'" 1>&2; :;` makes it
look like that warning is actually being shown to the user.

Suppress echoing the recipe, so that users only see the actual output
from the testsuite, not the makefile recipe as well.

libstdc++-v3/ChangeLog:

	* testsuite/Makefile.am (check-DEJAGNU): Use @ in recipe.
	* testsuite/Makefile.in: Regenerate.
2023-09-08 18:04:12 +01:00
Jonathan Wakely
3b1b24fb2a libstdc++: Simplify dejagnu target selector
A target selector allows multiple target triplets, it's not necessary to
use the || operator in a logical expression.

libstdc++-v3/ChangeLog:

	* testsuite/27_io/filesystem/path/concat/94063.cc: Simplify
	dg-do target selector.
2023-09-07 17:05:54 +01:00
Jonathan Wakely
bd3d7e1146 libstdc++: Remove trailing whitespace from dejagnu files
Also fix the name of a source file used by an effective target check.

libstdc++-v3/ChangeLog:

	* testsuite/config/default.exp: Remove trailing whitespace.
	* testsuite/lib/dg-options.exp: Likewise.
	* testsuite/lib/prune.exp: Likewise.
	* testsuite/libstdc++-abi/abi.exp: Likewise.
	* testsuite/libstdc++-dg/conformance.exp: Likewise.
	* testsuite/libstdc++-prettyprinters/prettyprinters.exp:
	Likewise.
	* testsuite/libstdc++-xmethods/xmethods.exp: Likewise.
	* testsuite/lib/libstdc++.exp: Likewise.
	(check_v3_target_c_std): Fix filename for temporary source file.
2023-09-07 17:05:54 +01:00
Jonathan Wakely
b1ca841b89 libstdc++: Fix missing/misplaced { dg-options "-std=gnu++20" } in tests
These tests do not run by default, because the c++20 effective target
selector isn't matched.

libstdc++-v3/ChangeLog:

	* testsuite/23_containers/unordered_map/operations/1.cc: Add
	dg-options for C++20 mode.
	* testsuite/23_containers/unordered_multimap/operations/1.cc:
	Likewise.
	* testsuite/23_containers/unordered_multiset/operations/1.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/operations/1.cc:
	Likewise.
	* testsuite/std/time/parse.cc: Move dg-options before dg-do.
2023-09-07 08:10:53 +01:00
Jonathan Wakely
f12e26f349 libstdc++: Fix <ranges> tests that fail in C++23
The tests for the std::ranges access CPOs (ranges::begin etc) use
pathological types with ridiculous overload sets for begin/end/data
members, to exercise all the corner cases in the specification.

Since P2278R4 "cbegin should always return a constant iterator" was
implemented for C++23 mode, some of the range access CPOs now require
the argument to satisfy the range concept, which was not previously
required. The behaviour of the CPO also changes for corner cases where
the type is a range R for which constant_range<R> is satisfied in
addition to constant_range<const R> (meaning there's no need to wrap its
iterators in const_iterator). Adjust the expected results for those
pathological types that changed meaning in C++23, and add some new types
to verify other corner cases.

Some other range adaptor tests fail for C++20 because they assert that
ranges::end and ranges::cend return different types, which is not true
when the type satisfies constant_range.

This fixes the tests to PASS for both C++20 and C++23 (and later).

libstdc++-v3/ChangeLog:

	* testsuite/std/ranges/access/cbegin.cc: Adjust for C++23
	compatibility.
	* 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/adaptors/take.cc: Likewise.
	* testsuite/std/ranges/adaptors/take_while.cc: Likewise.
	* testsuite/std/ranges/adaptors/transform.cc: Likewise.
2023-09-07 08:09:58 +01:00
Jonathan Wakely
6854e3ac71 libstdc++: Simplify C++20 poison pill overloads (P2602R2)
This implements the C++23 change "Poison Pills are Too Toxic". This
makes sense to do unconditionally for C++20, as the corner cases that it
fixes are considered to be defects in the C++20 design (e.g. LWG3480 was
needed to fix directory iterators because of these pills being too
toxic).

libstdc++-v3/ChangeLog:

	* include/bits/iterator_concepts.h (__imove::iter_move): Define
	poison pill as deleted for consistency.
	(__access::begin): Replace with a single declaration.
	* include/bits/ranges_base.h (__access::end, __access::rbegin)
	(__access::rend, __access::size): Likewise.
	* include/bits/version.def (ranges): Update value for C++23.
	* include/bits/version.h: Regenerate.
	* libsupc++/compare (__compare): Add missing poison pill
	overloads.
	* testsuite/std/ranges/version_c++23.cc: Adjust expected value
	of __cpp_lib_ranges.
	* testsuite/std/ranges/access/p2602.cc: New test.
2023-09-07 08:08:12 +01:00
Jonathan Wakely
9f41791eff libstdc++: Relax range adaptors for move-only types (P2494R2)
This is a C++23 feature that relaxes the constraints on some range
adaptors, to support move-only types.

libstdc++-v3/ChangeLog:

	* include/bits/version.def (ranges): Update value.
	* include/bits/version.h: Regenerate.
	* include/std/ranges (__detail::__boxable): Use
	move_constructible instead of copy_constructible for C++23.
	(__detail::__box<T>): Adjust constraints for partial
	specialization.
	(single_view, transform_view): Use __box_constructible instead
	of copy_constructible in constraints.
	(zip_transform_view, adjacent_transform_view, repeat_view): Use
	move_constructible instead of copy_constructible in constraints.
	* testsuite/std/ranges/adaptors/adjacent_transform/1.cc: Check
	construction from move-only argument.
	* testsuite/std/ranges/adaptors/transform.cc: Likewise.
	* testsuite/std/ranges/repeat/1.cc: Likewise.
	* testsuite/std/ranges/single_view.cc: Likewise.
	* testsuite/std/ranges/zip_transform/1.cc: Likewise.
	* testsuite/std/ranges/version_c++23.cc: Adjust expected value
	of __cpp_lib_ranges.
2023-09-07 08:05:15 +01:00
Jonathan Wakely
833733702a libstdc++: Avoid -Wunused-parameter warning in testsuite helper
libstdc++-v3/ChangeLog:

	* testsuite/util/testsuite_iterators.h (is_customization_point_object):
	Remove parameter name.
2023-09-07 08:02:49 +01:00
Jonathan Wakely
270e702eda libstdc++: Remove unnecessary dg-options and outdated comment
It's no longer true that 1.0if has type float _Complex when GNU
extensions are enabled, so remove the hardcoded -std option.

libstdc++-v3/ChangeLog:

	* testsuite/26_numerics/complex/literals/types.cc: Remove
	dg-options and add target selector instead.
2023-09-04 16:24:35 +01:00
Jonathan Wakely
455907564c libstdc++: Remove dg-options "-std=c++98" from TR1 tests
These tests need slight adjustments to be valid in C++11 and later, but
there's no reason that can't be done, so that we test them in more
modes.

libstdc++-v3/ChangeLog:

	* testsuite/tr1/6_containers/utility/pair.cc: Remove dg-options
	and qualify ambiguous calls to get.
	* testsuite/tr1/8_c_compatibility/cmath/pow_cmath.cc: Adjust
	expected result for std::pow(float, int) as per DR 550.
2023-09-04 16:24:35 +01:00
Jonathan Wakely
678834e9ff libstdc++: Enable std::auto_ptr tests for C++11 and later
There is no reason to only test std::auto_ptr with -std=c++03, we just
need to handle the deprecated warnings for C++11 and later.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/auto_ptr/1.cc: Remove dg-options -std=c++03
	and add dg-warning for deprecation warnings.
	* testsuite/20_util/auto_ptr/2.cc: Likewise.
	* testsuite/20_util/auto_ptr/3.cc: Likewise.
	* testsuite/20_util/auto_ptr/3946.cc: Likewise.
	* testsuite/20_util/auto_ptr/4.cc: Likewise.
	* testsuite/20_util/auto_ptr/5.cc: Likewise.
	* testsuite/20_util/auto_ptr/6.cc: Likewise.
	* testsuite/20_util/auto_ptr/7.cc: Likewise.
	* testsuite/20_util/auto_ptr/assign_neg.cc: Likewise.
	* testsuite/20_util/auto_ptr/requirements/explicit_instantiation/1.cc:
	Likewise.
	* testsuite/tr1/2_general_utilities/shared_ptr/assign/auto_ptr.cc:
	Likewise.
	* testsuite/tr1/2_general_utilities/shared_ptr/assign/auto_ptr_neg.cc:
	Likewise.
	* testsuite/tr1/2_general_utilities/shared_ptr/assign/auto_ptr_rvalue_neg.cc:
	Likewise.
	* testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc:
	Likewise.
	* testsuite/tr1/2_general_utilities/shared_ptr/cons/auto_ptr.cc:
	Likewise.
	* testsuite/tr1/2_general_utilities/shared_ptr/cons/auto_ptr_neg.cc:
	Likewise.
2023-09-04 16:24:35 +01:00
Jonathan Wakely
affbb7b432 libstdc++: Fix filenames and comments in tests [PR26142]
These tests have transposed digits in the filenames and comments.

libstdc++-v3/ChangeLog:

	PR libstdc++/26142
	* testsuite/23_containers/vector/26412-1.cc: Moved to...
	* testsuite/23_containers/vector/26142-1.cc: ...here.
	* testsuite/23_containers/vector/26412-2.cc: Moved to...
	* testsuite/23_containers/vector/26142-2.cc: ...here.
2023-09-04 16:24:35 +01:00
Jonathan Wakely
4bbe1414e1 libstdc++: Add { target c++98_only } to tests
These test behaviour only seen with -std=c++03 so the target selector
should match.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/bitset/107037.cc: Add c++98_only selector.
	* testsuite/26_numerics/complex/56111.cc: Likewise.
2023-09-04 16:24:34 +01:00
Jonathan Wakely
0eb35092de libstdc++: Add explicit -std=gnu++98 to tests that use { target c++98_only }
libstdc++-v3/ChangeLog:

	* testsuite/23_containers/deque/requirements/explicit_instantiation/2.cc:
	Add dg-options to restrict the test to C++98 mode.
	* testsuite/23_containers/list/requirements/explicit_instantiation/2.cc:
	Likewise.
2023-09-04 16:04:26 +01:00
Jonathan Wakely
c34ad4bc19 libstdc++: Add missing target selector to std::expected test
This test should use a target selector of c++23 so that the explicit
-std=gnu++23 option can be removed, to allow testing with later
standards too.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/expected/bad.cc: Add missing target
	selector.
2023-09-04 16:04:26 +01:00
Jonathan Wakely
b0d75f7d3b libstdc++: Fix debug-mode tests for constexpr algorithms
These tests started failing at some point:
FAIL: 25_algorithms/copy/debug/constexpr_neg.cc  (test for errors, line 49)
FAIL: 25_algorithms/copy/debug/constexpr_neg.cc (test for excess errors)
FAIL: 25_algorithms/equal/debug/constexpr_neg.cc  (test for errors, line 47)
FAIL: 25_algorithms/equal/debug/constexpr_neg.cc (test for excess errors)

They only run with -D_GLIBCXX_DEBUG or make check-debug so seem to have
gone unnoticed until now.

libstdc++-v3/ChangeLog:

	* testsuite/25_algorithms/copy/debug/constexpr_neg.cc: Adjust
	expected errors.
	* testsuite/25_algorithms/equal/debug/constexpr_neg.cc:
	Likewise.
2023-09-01 17:52:41 +01:00
Jonathan Wakely
e3d25188b0 libstdc++: Add -Wno-self-move to two filesystem tests
libstdc++-v3/ChangeLog:

	* testsuite/27_io/filesystem/iterators/91067.cc: Add
	-Wno-self-move to options.
	* testsuite/27_io/filesystem/path/assign/copy.cc: Likewise.
2023-09-01 17:52:41 +01:00
Jonathan Wakely
dcbec954fc libstdc++: Use a loop in atomic_ref::compare_exchange_strong [PR111077]
We need to use a loop in std::atomic_ref::compare_exchange_strong in
order to properly implement the C++20 requirement that padding bits do
not participate when checking the value for equality. The variable being
modified by a std::atomic_ref might have an initial value with non-zero
padding bits, so when the __atomic_compare_exchange built-in returns
false we need to check whether that was only because of non-equal
padding bits that are not part of the value representation. If the value
bits differ, it's just a failed compare-exchange. If the value bits are
the same, we need to retry the __atomic_compare_exchange using the value
that was just read by the previous failed call. As noted in the
comments, it's possible for that second try to also fail due to another
thread storing the same value but with differences in padding.

Because it's undefined to access a variable directly while it's held by
a std::atomic_ref, and because std::atomic_ref will only ever store
values with zeroed padding, we know that padding bits will never go from
zero to non-zero during the lifetime of a std::atomic_ref. They can only
go from an initial non-zero state to zero. This means the loop will
terminate, rather than looping indefinitely as padding bits flicker on
and off. In theory users could call __atomic_store etc. directly and
write a value with non-zero padding bits, but we don't need to support
that. Users doing that should ensure they do not write non-zero padding,
to be compatibile with our std::atomic_ref's invariants.

This isn't a problem for std::atomic<T>::compare_exchange_strong because
the initial value (and all later stores to the variable) are performed
by the library, so we ensure that stored values always have padding bits
cleared. That means we can simply clear the padding bits of the
'expected' value and we will be comparing two values with equal padding
bits. This means we don't need the loop for std::atomic, so update the
__atomic_impl::__compare_exchange function to take a bool parameter that
says whether it's being used by std::atomic_ref. If not, we can use a
simpler, non-looping implementation.

libstdc++-v3/ChangeLog:

	PR libstdc++/111077
	* include/bits/atomic_base.h (__atomic_impl::__compare_exchange):
	Add _AtomicRef non-type template parameter and use a loop if it
	is true.
	(__atomic_impl::compare_exchange_weak): Add _AtomicRef NTTP.
	(__atomic_impl::compare_exchange_strong): Likewise.
	(atomic_ref::compare_exchange_weak): Use true for NTTP.
	(atomic_ref::compare_exchange_strong): Use true for NTTP.
	* testsuite/29_atomics/atomic_ref/compare_exchange_padding.cc:
	Fix test to not rely on atomic_ref::load() to return an object
	with padding preserved.
2023-09-01 16:01:18 +01:00
Jonathan Wakely
c07d82c12f libstdc++: Use dg-require-filesystem-ts in link test
This test expects to be able to link, which fails if there are undefined
references to chdir, mkdir etc. in fs_ops.o in the libstdc++.a archive.

libstdc++-v3/ChangeLog:

	* testsuite/27_io/filesystem/path/108636.cc: Add dg-require for
	filesystem support.
2023-09-01 12:13:34 +01:00
Jonathan Wakely
e5af77adef libstdc++: Fix how chrono::parse handles errors for time-of-day values
We fail to diagnose an error and extract an incorrect time for cases
like "25:59" >> parse("%H:%M", mins). The bad "25" hour value gets
ignored (on the basis that we might not care about it if trying to
extract something like a weekday or a month name), but then when we get
to the end of the function we think we have a valid time from "59" and
so the result is 00:59.

The problem is that the '__bad_h' value is used for "no hour value read
yet" as well as "bad hour value read". If we just set __h = __bad_h and
continue, we can't tell later that we read an invalid hour.

The fix is to set failbit early when we're trying to extract a
time-of-day (e.g. duration or time_point) and we encounter an invalid
hour, minute, or second value. We can still delay other error checking
to the end.

libstdc++-v3/ChangeLog:

	* include/bits/chrono_io.h (_Parser::operator()): Set failbit
	early if invalid values are read when _M_need & _TimeOfDay is
	non-zero.
	* testsuite/std/time/parse.cc: Check that "25:59" cannot be
	parsed for "%H:%M".
2023-09-01 09:55:48 +01:00
Jonathan Wakely
207c507499 libstdc++: Do not allow chrono::parse to overflow for %C [PR111162]
libstdc++-v3/ChangeLog:

	PR libstdc++/111162
	* include/bits/chrono_io.h (_Parser::Operator()): Check %C
	values are in range of year::min() to year::max().
	* testsuite/std/time/parse.cc: Check out of range centuries.
2023-09-01 09:55:48 +01:00
Paul Dreik
7564fe9865 libstdc++: Add test for illegal pointer arithmetic in format [PR111102]
libstdc++-v3/ChangeLog:

	PR libstdc++/111102
	* testsuite/std/format/string.cc: Check wide character format
	strings with out-of-range widths.
2023-08-24 13:44:39 +01:00
Jonathan Wakely
d6271d600d libstdc++: Fix -Wunused-but-set-variable in std::format_to test
libstdc++-v3/ChangeLog:

	* testsuite/std/format/functions/format_to.cc: Avoid warning for
	unused variables.
2023-08-24 13:44:38 +01:00
Jonathan Wakely
c47430bba6 libstdc++: Implement new SI prefixes in <ratio> for C++23 (P2734R0)
This is a no-op for libstdc++, because our intmax_t is a 64-bit type and
so is incapable of representing the largest and smallest ratios from
C++11, let alone the new ones. I've added them to the file anyway (and
defined the feature test macro) so that if somebody ports libstdc++ to a
target with 128-bit intmax_t then they'll be present.

libstdc++-v3/ChangeLog:

	* include/bits/version.def (__cpp_lib_ratio): Define.
	* include/bits/version.h: Regenerate.
	* include/std/ratio (quecto, ronto, yocto, zepto)
	(zetta, yotta, ronna, quetta): Define.
	* testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Adjust
	dg-error line numbers.
2023-08-24 13:44:38 +01:00
Jonathan Wakely
3d2e240af7 libstdc++: Add pretty printer for std::locale
Print the locale's name, except when it uses the same named C locale for
all categories except one, in which case print something like:
std::locale = "en_GB.UTF-8" with "LC_CTYPE=en_US.UTF-8"

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdLocalePrinter): New
	printer class.
	* testsuite/libstdc++-prettyprinters/locale.cc: New test.
2023-08-24 13:40:25 +01:00
Jonathan Wakely
701ce3c723 libstdc++: Declutter std::optional and std:variant pretty printers [PR110944]
As the PR says, including the template arguments in the GDB output of
these class templates can result in very long names, especially for
std::variant. You can use 'whatis' or other GDB commands to get details
of the type, we don't need to include it in the value.

We could consider including the type if it's not too long, but I think
consistency is better (and we already omit the template arguments for
std::vector and other class templates).

libstdc++-v3/ChangeLog:

	PR libstdc++/110944
	* python/libstdcxx/v6/printers.py (StdExpOptionalPrinter): Do
	not show template arguments.
	(StdVariantPrinter): Likewise.
	* testsuite/libstdc++-prettyprinters/compat.cc: Adjust expected
	output.
	* testsuite/libstdc++-prettyprinters/cxx17.cc: Likewise.
	* testsuite/libstdc++-prettyprinters/libfundts.cc: Likewise.
2023-08-24 13:40:24 +01:00
François Dumont
2aa8ebc0a6 libstdc++: Fix tests relying on operator new/delete overload
Fix tests that are checking for an expected allocation plan. They are failing if
an allocation is taking place outside the test main.

libstdc++-v3/ChangeLog

	* testsuite/util/replacement_memory_operators.h
	(counter::scope): New, capture and reset counter count at construction and
	restore it at destruction.
	(counter::check_new): Add scope instantiation.
	* testsuite/23_containers/unordered_map/96088.cc (main):
	Add counter::scope instantiation.
	* testsuite/23_containers/unordered_multimap/96088.cc (main): Likewise.
	* testsuite/23_containers/unordered_multiset/96088.cc (main): Likewise.
	* testsuite/23_containers/unordered_set/96088.cc (main): Likewise.
	* testsuite/ext/malloc_allocator/deallocate_local.cc (main): Likewise.
	* testsuite/ext/new_allocator/deallocate_local.cc (main): Likewise.
	* testsuite/ext/throw_allocator/deallocate_local.cc (main): Likewise.
	* testsuite/ext/pool_allocator/allocate_chunk.cc (started): New global.
	(operator new(size_t)): Check started.
	(main): Set/Unset started.
	* testsuite/17_intro/no_library_allocation.cc: New test case.
2023-08-23 06:35:24 +02:00
Jonathan Wakely
03cb6904d1 libstdc++: Remove reliance on unspecified behaviour in std::rethrow_if_nested test
This test case calls std::set_terminate while there is an active
exception. Since LWG 2111 it is unspecified which terminate handler is
used when std::nested_exception::rethrow_nested() calls std::terminate.
With libsupc++ the global handler changed by std::set_terminate is used,
but libc++abi uses the active exception's handler (the one that was
current when the exception was first thrown).

Adjust the test case so that it works with either implementation choice.
So that the process doesn't exit cleanly if std::terminate happens
sooner than expected, use a global variable to control when the "clean
terminate" behaviour happens.

libstdc++-v3/ChangeLog:

	* testsuite/18_support/nested_exception/rethrow_if_nested-term.cc:
	Call std::set_terminate before throwing the nested exception.
2023-08-21 10:43:19 +01:00
Jonathan Wakely
6cf214b4fc libstdc++: Add std::formatter specializations for extended float types
This makes it possible to format _Float32, _Float64 etc. in C++20 mode.
Previously it was only possible to format them in C++23 when the
<stdfloat> typedefs and the std::to_chars overloads were defined.

Instead of relying on std::to_chars for those types, we can just reuse
the formatters for float, double and long double. This also avoids
template bloat by reusing the same specializations instead of
instantiating __formatter_fp for every different type.

libstdc++-v3/ChangeLog:

	* include/std/format (formatter): Add partial specializations
	for extended floating-point types.
	* testsuite/std/format/functions/format.cc: Move test_float128()
	to ...
	* testsuite/std/format/formatter/ext_float.cc: New test.
2023-08-17 20:24:18 +01:00
Jonathan Wakely
84cff28fd2 libstdc++: Make __cmp_cat::__unseq constructor consteval
This constructor should only ever be used with a literal 0 as the
argument, so we can make it consteval. This has the nice advantage that
it is expanded immediately in the front end, and so GDB will never step
into the __cmp_cat::__unseq::__unseq(__unseq*) constructor that is
uninteresting and probably confusing to users.

libstdc++-v3/ChangeLog:

	* libsupc++/compare (__cmp_cat::__unseq): Make ctor consteval.
	* testsuite/18_support/comparisons/categories/zero_neg.cc: Prune
	excess errors caused by invalid consteval calls.
2023-08-17 20:24:17 +01:00
Jonathan Wakely
023a62b77f libstdc++: Rework std::format support for wchar_t
This changes how std::format creates wide strings, by replacing uses of
std::ctype<wchar_t>::widen with the recently-added __to_wstring_numeric
helper function. This removes the dependency on the locale, which should
only be used for locale-specific formats such as {:Ld}.

Also disable all the wide string formatting support if the
_GLIBCXX_USE_WCHAR_T macro is not defined. This is consistent with other
wchar_t support being disabled if the library is built without that
macro defined.

libstdc++-v3/ChangeLog:

	* include/std/format [_GLIBCXX_USE_WCHAR_T]: Guard all wide
	string formatters with this macro.
	(__formatter_int::_M_format_int, __formatter_fp::format)
	(formatter<const void*, C>::format): Use __to_wstring_numeric
	instead of std::ctype::widen.
	(__formatter_fp::_M_localize): Use hardcoded wchar_t values
	instead of std::ctype::widen.
	* testsuite/std/format/functions/format.cc: Add more checks for
	wstring formatting of arithmetic types.
2023-08-17 20:24:17 +01:00
Jonathan Wakely
aeed687f4e libstdc++: Implement std::to_string in terms of std::format (P2587R3)
This change for C++26 affects std::to_string for floating-point
arguments, so that they should be formatted using std::format("{}", v)
instead of using sprintf. The modified specification in the standard
also affects integral arguments, but there's no observable difference
for them, and we already use std::to_chars for them anyway.

To avoid <string> depending on all of <format>, this change actually
just uses std::to_chars directly instead of using std::format. This is
equivalent, because the format spec "{}" doesn't use any of the other
features of std::format.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.h (to_string(floating-point-type)):
	Implement using std::to_chars for C++26.
	* include/bits/version.def (__cpp_lib_to_string): Define.
	* include/bits/version.h: Regenerate.
	* testsuite/21_strings/basic_string/numeric_conversions/char/dr1261.cc:
	Adjust expected result in C++26 mode.
	* testsuite/21_strings/basic_string/numeric_conversions/char/to_string.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/dr1261.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/to_wstring.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/char/to_string_float.cc:
	New test.
	* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/to_wstring_float.cc:
	New test.
	* testsuite/21_strings/basic_string/numeric_conversions/version.cc:
	New test.
2023-08-17 20:24:17 +01:00
Jonathan Wakely
51ec07b116 libstdc++: Optimize std::to_string using std::string::resize_and_overwrite
This uses std::string::__resize_and_overwrite to avoid initializing the
string buffer with characters that are immediately overwritten. This
results in about 6% better performance for the std_to_string case in
int-benchmark.cc from https://github.com/fmtlib/format-benchmark

This requires a change to a testcase. The previous implementation
guaranteed that the string returned from std::to_string(integral-type)
would have no excess capacity, because it was constructed with the
correct length. The new implementation constructs an empty string and
then resizes it with resize_and_overwrite, which over-allocates. This
means that the "no-excess capacity" guarantee no longer holds.

We can also greatly improve the performance of std::to_wstring by using
std::to_string and then widening it with a new helper function, instead
of using std::swprintf to do the formatting.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.h (to_string(integral-type)): Use
	resize_and_overwrite when available.
	(__to_wstring_numeric): New helper functions.
	(to_wstring): Use std::to_string then __to_wstring_numeric.
	* testsuite/21_strings/basic_string/numeric_conversions/char/to_string_int.cc:
	Remove check for no excess capacity.
2023-08-17 20:24:17 +01:00
Jonathan Wakely
95c2b0cc9e libstdc++: Define std::string::resize_and_overwrite for C++11 and COW string
There are several places in the library where we can improve performance
using resize_and_overwrite so it's inconvenient only being able to use
it in C++23 mode, and only for cxx11 strings. This adds it for COW
strings, and also adds __resize_and_overwrite as an extension for C++11
mode.

The new __resize_and_overwrite is available for C++11 and later, so
within the library we can use that consistently even in C++23.  In order
to avoid making a copy (which might not be possible for non-copyable,
non-movable types) the callable is passed to resize_and_overwrite as an
lvalue reference.  Unlike wrapping it in std::ref(op) this ensures that
invoking it as std::move(op)(n, p) will use the correct value category.
It also avoids any overhead that would be added by wrapping it in a
lambda like [&op](auto p, auto n) { return std::move(op)(p, n); }.

Adjust std::format to use the new __resize_and_overwrite, which we can
assume exists because we only use std::basic_string<char> and
std::basic_string<wchar_t>, so no program-defined specializations.

The uses in <experimental/internet> cannot be replaced, because those
are type-dependent on an Allocator template parameter, which could mean
they use program-defined specializations of std::basic_string that don't
have the __resize_and_overwrite extension.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.h (__resize_and_overwrite): New
	function.
	* include/bits/basic_string.tcc (__resize_and_overwrite): New
	function.
	(resize_and_overwrite): Simplify by using reserve instead of
	growing the string manually. Adjust for C++11 compatibility.
	* include/bits/cow_string.h (resize_and_overwrite): New
	function.
	(__resize_and_overwrite): New function.
	* include/bits/version.def (__cpp_lib_string_resize_and_overwrite):
	Do not depend on cxx11abi.
	* include/bits/version.h: Regenerate.
	* include/std/format (__formatter_fp::_S_resize_and_overwrite):
	Remove.
	(__formatter_fp::format, __formatter_fp::_M_localize): Use
	__resize_and_overwrite instead of _S_resize_and_overwrite.
	* testsuite/21_strings/basic_string/capacity/char/resize_and_overwrite.cc:
	Adjust for C++11 compatibility when included by ...
	* testsuite/21_strings/basic_string/capacity/char/resize_and_overwrite_ext.cc:
	New test.
2023-08-17 20:24:17 +01:00
Patrick Palka
bad357dd1b libstdc++: Implement P2770R0 changes to join_view / join_with_view
This C++23 paper fixes an issue in these views when adapting a certain
kind of non-forward range, and we treat it as a DR against C++20.

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

libstdc++-v3/ChangeLog:

	* include/bits/regex.h (regex_iterator::iterator_concept):
	Define for C++20 as per P2770R0.
	(regex_token_iterator::iterator_concept): Likewise.
	* include/std/ranges (__detail::__as_lvalue): Define.
	(join_view::_Iterator): Befriend join_view.
	(join_view::_Iterator::_M_satisfy): Use _M_get_outer
	instead of _M_outer.
	(join_view::_Iterator::_M_get_outer): Define.
	(join_view::_Iterator::_Iterator): Split constructor taking
	_Parent argument into two as per P2770R0.  Remove constraint on
	default constructor.
	(join_view::_Iterator::_M_outer): Make this data member present
	only when the underlying range is forward.
	(join_view::_Iterator::operator++): Use _M_get_outer instead of
	_M_outer.
	(join_view::_Iterator::operator--): Use __as_lvalue helper.
	(join_view::_Iterator::operator==): Adjust constraints as per
	P2770R0.
	(join_view::_Sentinel::__equal): Use _M_get_outer instead of
	_M_outer.
	(join_view::_M_outer): New data member when the underlying range
	is non-forward.
	(join_view::begin): Adjust definition as per P2770R0.
	(join_view::end): Likewise.
	(join_with_view::_M_outer_it): New data member when the
	underlying range is non-forward.
	(join_with_view::begin): Adjust definition as per P2770R0.
	(join_with_view::end): Likewise.
	(join_with_view::_Iterator::_M_outer_it): Make this data member
	present only when the underlying range is forward.
	(join_with_view::_Iterator::_M_get_outer): Define.
	(join_with_view::_Iterator::_Iterator): Split constructor
	taking _Parent argument into two as per P2770R0.  Remove
	constraint on default constructor.
	(join_with_view::_Iterator::_M_update_inner): Adjust definition
	as per P2770R0.
	(join_with_view::_Iterator::_M_get_inner): Likewise.
	(join_with_view::_Iterator::_M_satisfy): Adjust calls to
	_M_get_inner.  Use _M_get_outer instead of _M_outer_it.
	(join_with_view::_Iterator::operator==): Adjust constraints
	as per P2770R0.
	(join_with_view::_Sentinel::operator==): Use _M_get_outer
	instead of _M_outer_it.
	* testsuite/std/ranges/adaptors/p2770r0.cc: New test.
2023-08-17 12:56:32 -04:00
Patrick Palka
4a6f3676e7 libstdc++: Convert _RangeAdaptorClosure into a CRTP base [PR108827]
Using the CRTP idiom for this base class avoids bloating the size of a
pipeline when adding distinct empty range adaptor closure objects to it,
as detailed in section 4.1 of P2387R3.

But it means we can no longer define its operator| overloads as hidden
friends, since it'd mean each instantiation of _RangeAdaptorClosure
introduces its own distinct set of hidden friends.  So e.g. for the
outer | in

  x | (views::reverse | views::join)

ADL would find 6 distinct hidden operator| friends:

  two from _RangeAdaptorClosure<_Reverse>
  two from _RangeAdaptorClosure<_Join>
  two from _RangeAdaptorClosure<_Pipe<_Reverse, _Join>>

but we really only want to consider the last two.

We avoid this issue by instead defining the operator| overloads at
namespace scope alongside _RangeAdaptorClosure.  This should be fine
because the only types defined in this namespace are _RangeAdaptorClosure,
_RangeAdaptor, _Pipe and _Partial, so we don't have to worry about
unintentional ADL.

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

	PR libstdc++/108827

libstdc++-v3/ChangeLog:

	* include/std/ranges (__adaptor::_RangeAdaptorClosure):
	Convert into a CRTP class template.  Move hidden operator|
	friends into namespace scope and adjust their constraints.
	(__closure::__is_range_adaptor_closure_fn): Define.
	(__closure::__is_range_adaptor_closure): Define.
	(__adaptor::_Partial): Adjust use of _RangeAdaptorClosure.
	(__adaptor::_Pipe): Likewise.
	(views::_All): Likewise.
	(views::_Join): Likewise.
	(views::_Common): Likewise.
	(views::_Reverse): Likewise.
	(views::_Elements): Likewise.
	(views::_Adjacent): Likewise.
	(views::_AsRvalue): Likewise.
	(views::_Enumerate): Likewise.
	(views::_AsConst): Likewise.
	* testsuite/std/ranges/adaptors/all.cc: Reinstate assertion
	expecting that adding empty range adaptor closure objects to a
	pipeline doesn't increase the size of a pipeline.
2023-08-17 12:40:04 -04:00
Jonathan Wakely
d07bce478f libstdc++: Fix std::format("{:F}", inf) to use uppercase
std::format was treating {:f} and {:F} identically on the basis that for
the fixed 1.234567 format there are no alphabetical characters that need
to be in uppercase. But that's wrong for infinities and NaNs, which
should be formatted as "INF" and "NAN" for {:F}.

libstdc++-v3/ChangeLog:

	* include/std/format (__format::_Pres_type): Add _Pres_F.
	(__formatter_fp::parse): Use _Pres_F for 'F'.
	(__formatter_fp::format): Set __upper for _Pres_F.
	* testsuite/std/format/functions/format.cc: Check formatting of
	infinity and NaN for each presentation type.
2023-08-17 13:12:39 +01:00