Commit graph

14881 commits

Author SHA1 Message Date
GCC Administrator
e255454046 Daily bump. 2024-02-02 00:18:18 +00:00
Patrick Palka
65b4cba9d6 libstdc++: Implement P2165R4 changes to std::pair/tuple/etc [PR113309]
This implements the C++23 paper P2165R4 Compatibility between tuple,
pair and tuple-like objects, which builds upon many changes from the
earlier C++23 paper P2321R2 zip.

Some declarations had to be moved around so that they're visible from
<bits/stl_pair.h> without introducing new includes and bloating the
header.  In the end, the only new include is for <bits/utility.h> from
<bits/stl_iterator.h>, for tuple_element_t.

	PR libstdc++/113309
	PR libstdc++/109203

libstdc++-v3/ChangeLog:

	* include/bits/ranges_util.h (__detail::__pair_like): Don't
	define in C++23 mode.
	(__detail::__pair_like_convertible_from): Adjust as per P2165R4.
	(__detail::__is_subrange<subrange>): Moved from <ranges>.
	(__detail::__is_tuple_like_v<subrange>): Likewise.
	* include/bits/stl_iterator.h: Include <bits/utility.h> for
	C++23.
	(__different_from): Move to <concepts>.
	(__iter_key_t): Adjust for C++23 as per P2165R4.
	(__iter_val_t): Likewise.
	* include/bits/stl_pair.h (pair, array): Forward declare.
	(get): Forward declare all overloads relevant to P2165R4
	tuple-like constructors.
	(__is_tuple_v): Define for C++23.
	(__is_tuple_like_v): Define for C++23.
	(__tuple_like): Define for C++23 as per P2165R4.
	(__pair_like): Define for C++23 as per P2165R4.
	(__eligibile_tuple_like): Define for C++23.
	(__eligibile_pair_like): Define for C++23.
	(pair::_S_constructible_from_pair_like): Define for C++23.
	(pair::_S_convertible_from_pair_like): Define for C++23.
	(pair::_S_dangles_from_pair_like): Define for C++23.
	(pair::pair): Define overloads taking a tuple-like type for
	C++23 as per P2165R4.
	(pair::_S_assignable_from_tuple_like): Define for C++23.
	(pair::_S_const_assignable_from_tuple_like): Define for C++23.
	(pair::operator=): Define overloads taking a tuple-like type for
	C++23 as per P2165R4.
	* include/bits/utility.h (ranges::__detail::__is_subrange):
	Moved from <ranges>.
	* include/bits/version.def (tuple_like): Define for C++23.
	* include/bits/version.h: Regenerate.
	* include/std/concepts (__different_from): Moved from
	<bits/stl_iterator.h>.
	(ranges::__swap::__adl_swap): Clarify which __detail namespace.
	* include/std/map (__cpp_lib_tuple_like): Define C++23.
	* include/std/ranges (__detail::__is_subrange): Moved to
	<bits/utility.h>.
	(__detail::__is_subrange<subrange>): Moved to <bits/ranges_util.h>
	(__detail::__has_tuple_element): Adjust for C++23 as per P2165R4.
	(__detail::__tuple_or_pair): Remove as per P2165R4.  Replace all
	uses with plain tuple as per P2165R4.
	* include/std/tuple (__cpp_lib_tuple_like): Define for C++23.
	(__tuple_like_tag_t): Define for C++23.
	(__tuple_cmp): Forward declare for C++23.
	(_Tuple_impl::_Tuple_impl): Define overloads taking
	__tuple_like_tag_t and a tuple-like type for C++23.
	(_Tuple_impl::_M_assign): Likewise.
	(tuple::__constructible_from_tuple_like): Define for C++23.
	(tuple::__convertible_from_tuple_like): Define for C++23.
	(tuple::__dangles_from_tuple_like): Define for C++23.
	(tuple::tuple): Define overloads taking a tuple-like type for
	C++23 as per P2165R4.
	(tuple::__assignable_from_tuple_like): Define for C++23.
	(tuple::__const_assignable_from_tuple_like): Define for C++23.
	(tuple::operator=): Define overloads taking a tuple-like type
	for C++23 as per P2165R4.
	(tuple::__tuple_like_common_comparison_category): Define for C++23.
	(tuple::operator<=>): Define overload taking a tuple-like type
	for C++23 as per P2165R4.
	(array, get): Forward declarations moved to <bits/stl_pair.h>.
	(tuple_cat): Constrain with __tuple_like for C++23 as per P2165R4.
	(apply): Likewise.
	(make_from_tuple): Likewise.
	(__tuple_like_common_reference): Define for C++23.
	(basic_common_reference): Adjust as per P2165R4.
	(__tuple_like_common_type): Define for C++23.
	(common_type): Adjust as per P2165R4.
	* include/std/unordered_map (__cpp_lib_tuple_like): Define for
	C++23.
	* include/std/utility (__cpp_lib_tuple_like): Define for C++23.
	* testsuite/std/ranges/zip/1.cc (test01): Adjust to handle pair
	and 2-tuple interchangeably.
	(test05): New test.
	* testsuite/20_util/pair/p2165r4.cc: New test.
	* testsuite/20_util/tuple/p2165r4.cc: New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2024-02-01 14:59:46 -05:00
Patrick Palka
87d162383e libstdc++/pair: Factor out const-assignability helper for C++20
This is consistent with std::tuple's __const_assignable helper, and will
be useful for implementing the new pair::operator= overloads from P2165R4.

libstdc++-v3/ChangeLog:

	* include/bits/stl_pair.h (pair::_S_const_assignable): Define,
	factored out from ...
	(pair::operator=): ... the constraints of the const overloads.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2024-02-01 14:56:02 -05:00
Jonathan Wakely
314cbfe298 libstdc++: Do not use def-file-line for each macro in <bits/version.h>
These line markers are not needed, because searching <bits/version.def>
for a macro name works fine. Removing them means that small changes to
<bits/version.def> do not result in large diffs to <bits/version.h>
because of all the changed line numbers.

libstdc++-v3/ChangeLog:

	* include/bits/version.tpl: Do not use def-file-line for each
	macro being defined.
	* include/bits/version.h: Regenerate.
2024-02-01 15:26:54 +00:00
Jonathan Wakely
52e9b70830 libstdc++: Update expected error for debug/constexpr*_neg.cc tests
We no longer hit a __builtin_unreachable() in these tests, so we need to
update the dg-error patterns to match _Error_formatter::_M_error().

We can also remove some dg-prune-output directives matching notes saying
"in 'constexpr' expansion" because that's done globally in prune.exp.

libstdc++-v3/ChangeLog:

	* testsuite/25_algorithms/copy/debug/constexpr_neg.cc: Adjust
	dg-error pattern.
	* 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.
2024-02-01 15:26:53 +00:00
Jonathan Wakely
e81a697577 libstdc++: Fix -Wdeprecated warning about implicit capture of 'this'
In C++20 it's deprecated for a [=] lambda capture to capture the 'this'
pointer. Using resize_and_overwrite with a lambda seems like overkill to
write three chars to the string anyway. Just resize the string and
overwrite the end of it directly.

libstdc++-v3/ChangeLog:

	* include/experimental/internet (network_v4::to_string()):
	Remove lambda and use of resize_and_overwrite.
2024-02-01 15:26:53 +00:00
GCC Administrator
dd3455f695 Daily bump. 2024-02-01 11:40:50 +00:00
Jonathan Wakely
9bf91fa360 libstdc++: Enable std::text_encoding for darwin and FreeBSD
The <xlocale.h> header is needed for newlocale and locale_t on these
targets.

libstdc++-v3/ChangeLog:

	* acinclude.m4 (GLIBCXX_CHECK_TEXT_ENCODING): Use <xlocale.h> if
	needed for newlocale.
	* configure: Regenerate.
	* src/c++26/text_encoding.cc: Use <xlocale.h>.

Reviewed-by: Iain Sandoe <iain@sandoe.co.uk>
2024-01-31 09:42:39 +00:00
Jonathan Wakely
358fd42aab libstdc++: Add "ASCII" as an alias for std::text_encoding:🆔:ASCII
As noted in LWG 4043, "ASCII" is not an alias for any known registered
character encoding, so std::text_encoding("ASCII").mib() == id::other.
Add the alias "ASCII" to the implementation-defined superset of aliases
for that encoding.

libstdc++-v3/ChangeLog:

	* include/bits/text_encoding-data.h: Regenerate.
	* scripts/gen_text_encoding_data.py: Add extra_aliases dict
	containing "ASCII".
	* testsuite/std/text_encoding/cons.cc: Check "ascii" is known.

Co-authored-by: Ewan Higgs <ewan.higgs@gmail.com>
Signed-off-by: Ewan Higgs <ewan.higgs@gmail.com>
2024-01-31 09:42:38 +00:00
Jonathan Wakely
00b2d7d17c libstdc++: Add all supported headers to lists in the manual
libstdc++-v3/ChangeLog:

	* doc/xml/manual/using.xml: Update tables of supported headers.
	* doc/html/*: Regenerate.
2024-01-31 09:42:38 +00:00
Jonathan Wakely
86302e1a76 libstdc++: Fix -Wshift-count-overflow warning in std::bitset
This shift only happens if the unsigned long long type is wider than
unsigned long but the compiler warns when it sees the shift, without
caring if it's reachable.

Use the preprocessor to compare the sizes and just reuse _M_to_ulong()
if sizeof(long) == sizeof(long long).

libstdc++-v3/ChangeLog:

	* include/std/bitset (_Base_bitset::_M_do_to_ullong): Avoid
	-Wshift-count-overflow warning.
2024-01-31 09:42:38 +00:00
GCC Administrator
097ddd552d Daily bump. 2024-01-31 00:19:27 +00:00
Jonathan Wakely
5525dd754b libstdc++: Fix check in testsuite/std/time/clock/gps/io.cc
The test_format() function contained an incorrect assertion but wasn't
actually being called from main.

libstdc++-v3/ChangeLog:

	* testsuite/std/time/clock/gps/io.cc: Fix expected result in
	assertion and call test_format() from main.
2024-01-30 14:50:07 +00:00
GCC Administrator
f07068197d Daily bump. 2024-01-30 00:18:41 +00:00
François Dumont
8d59b93239 libstdc++: Fix _GLIBCXX_DEBUG_BACKTRACE macro documentation
libstdc++-v3/ChangeLog:

	* doc/xml/manual/debug_mode.xml: Link against libstdc++exp.a to use
	_GLIBCXX_DEBUG_BACKTRACE macro.
2024-01-29 21:00:58 +01:00
GCC Administrator
2a9637b229 Daily bump. 2024-01-25 00:19:12 +00:00
Huanghui Nie
ec0a68b9ee libstdc++: [_Hashtable] Remove useless check for _M_before_begin node
When removing the first node of a bucket it is useless to check if this bucket
is the one containing the _M_before_begin node. The bucket before-begin node is
already transfered to the next pointed-to bucket regardeless if it is the container
before-begin node.

libstdc++-v3/ChangeLog:

	* include/bits/hashtable.h (_Hahstable<>::_M_remove_bucket_begin): Remove
	_M_before_begin check and cleanup implementation.

Co-authored-by: Théo Papadopoulo  <papadopoulo@gmail.com>
2024-01-24 06:36:04 +01:00
GCC Administrator
e2d1f8587c Daily bump. 2024-01-23 00:18:32 +00:00
Jonathan Wakely
8229214fae libstdc++: Fix check in testsuite/std/time/clock/file/io.cc
The test_format() function contained an incorrect assertion but wasn't
actually being called from main.

libstdc++-v3/ChangeLog:

	* testsuite/std/time/clock/file/io.cc: Fix expected result in
	assertion and call test_format() from main.
2024-01-22 13:06:00 +00:00
GCC Administrator
d9ed3ac20e Daily bump. 2024-01-22 00:17:47 +00:00
Jonathan Wakely
7431fcea6b libstdc++: Fix std::format for floating-point chrono::time_point [PR113500]
Currently trying to use std::format with certain specializations of
std::chrono::time_point is ill-formed, due to one member function of the
__formatter_chrono type which tries to write a time_point to an ostream.
For sys_time<floating-point> or sys_time with a period greater than days
there is no operator<< that can be used.

That operator<< is only needed when using an empty chrono-specs in the
format string, like "{}", but the ill-formed expression gives an error
even if not actually used. This means it's not possible to format some
other specializations of chrono::time_point, even when using a non-empty
chrono-specs.

This fixes it by avoiding using 'os << t' for all chrono::time_point
specializations, and instead using std::format("{:L%F %T}", t). So that
we continue to reject std::format("{}", sys_time{1.0s}) a check for
empty chrono-specs is added to the formatter<sys_time<D>, C>
specialization.

While testing this I noticed that the output for %S with a
floating-point duration was incorrect, as the subseconds part was being
appended to the seconds without a decimal point, and without the correct
number of leading zeros.

libstdc++-v3/ChangeLog:

	PR libstdc++/113500
	* include/bits/chrono_io.h (__formatter_chrono::_M_S): Fix
	printing of subseconds with floating-point rep.
	(__formatter_chrono::_M_format_to_ostream): Do not write
	time_point specializations directly to the ostream.
	(formatter<chrono::sys_time<D>, C>::parse): Do not allow an
	empty chrono-spec if the type fails to meet the constraints for
	writing to an ostream with operator<<.
	* testsuite/std/time/clock/file/io.cc: Check formatting
	non-integral times with empty chrono-specs.
	* testsuite/std/time/clock/gps/io.cc: Likewise.
	* testsuite/std/time/clock/utc/io.cc: Likewise.
	* testsuite/std/time/hh_mm_ss/io.cc: Likewise.
2024-01-21 22:15:06 +00:00
Jonathan Wakely
fba15da8fa libstdc++: Fix std::chrono::file_clock conversions for low-precision times
THe std::chrono::file_clock conversions were not using common_type and
so failed to compile when converting anything that should have increased
precision after arithmetic with a std::chrono::seconds value.

libstdc++-v3/ChangeLog:

	* include/bits/chrono.h (__file_clock::from_sys)
	(__file_clock::to_sys, __file_clock::_S_from_sys)
	(__file_clock::_S_to_sys): Use common_type for return type.
	* testsuite/std/time/clock/file/members.cc: Check round trip
	conversion for time with lower precision that seconds.
2024-01-21 22:15:06 +00:00
Jonathan Wakely
a57439d619 libstdc++: Fix std::format floating-point alternate forms [PR113512]
The logic for handling '#' forms was ... not good. The count of
significant figures just counted digits, instead of ignoring leading
zeros. And when moving the result from the stack buffer to a dynamic
string the exponent could get lost in some cases.

libstdc++-v3/ChangeLog:

	PR libstdc++/113512
	* include/std/format (__formatter_fp::format): Fix logic for
	alternate forms.
	* testsuite/std/format/functions/format.cc: Check buggy cases of
	alternate forms with g presentation type.
2024-01-21 13:31:28 +00:00
GCC Administrator
11a5f26c4e Daily bump. 2024-01-21 00:17:42 +00:00
Marek Polacek
7db802d972 libstdc++: suppress -Wdangling-reference with operator| [PR111410]
It seems to me that we should exclude std::ranges::views::__adaptor::operator|
from the -Wdangling-reference warning.  It's commonly used when handling
ranges.

	PR c++/111410

libstdc++-v3/ChangeLog:

	* include/std/ranges: Add #pragma to disable -Wdangling-reference with
	std::ranges::views::__adaptor::operator|.

gcc/testsuite/ChangeLog:

	* g++.dg/warn/Wdangling-reference17.C: New test.
2024-01-20 15:41:52 -05:00
GCC Administrator
c2544854ca Daily bump. 2024-01-20 00:18:14 +00:00
Jonathan Wakely
631a922e5c libstdc++: Do not use CTAD for _Utf32_view alias template (redux)
My change in r14-8181-g665a3ff1539ce2 was incomplete as there's a second
place using CTAD with the _Utf32_view alias template. This fixes it.

libstdc++-v3/ChangeLog:

	* include/std/format (_Spec::_M_parse_fill_and_align): Do not
	use CTAD for _Utf32_view.
2024-01-19 19:13:15 +00:00
Jonathan Wakely
502a3c03e4 libstdc++: Fix P2255R2 dangling checks for std::tuple in C++17 [PR108822]
I accidentally used && in a fold-expression instead of || which meant
that in C++17 the tuple(UElements&&...) constructor only failed its
debug assertion if all tuple elements were dangling references. Some
missing tests (noted as "TODO") meant this wasn't tested.

This fixes the fold expression and adds the missing tests.

libstdc++-v3/ChangeLog:

	PR libstdc++/108822
	* include/std/tuple (__glibcxx_no_dangling_refs) [C++17]: Fix
	wrong fold-operator.
	* testsuite/20_util/tuple/dangling_ref.cc: Check tuples with one
	element and three elements. Check allocator-extended
	constructors.
2024-01-19 19:12:38 +00:00
Patrick Palka
d44b603916 libstdc++: Add <print> and <text_encoding> to stdc++.h
libstdc++-v3/ChangeLog:

	* include/precompiled/stdc++.h [_GLIBCXX_HOSTED]: Include
	<print> and <text_encoding> for C++23 and C++26 respectively.
2024-01-19 10:21:47 -05:00
GCC Administrator
bb0f96abb1 Daily bump. 2024-01-19 00:18:21 +00:00
Patrick Palka
8cddf6f833 libstdc++/pair: Guard P2321R2 changes with __glibcxx_ranges_zip
Similar to the previous change for <tuple>, but since stl_pair.h is an
internal header we need to use the corresponding internal macro instead.

libstdc++-v3/ChangeLog:

	* include/bits/stl_pair.h [__cplusplus > 202002L]:
	Guard P2321R2 changes with __glibcxx_ranges_zip instead.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2024-01-18 11:21:34 -05:00
Patrick Palka
ae8581ea5c libstdc++/tuple: Guard P2321R2 changes with __cpp_lib_ranges_zip
Guard <tuple> additions from P2321R2 zip with __cpp_lib_ranges_zip
instead of __cplusplus > 202020L.

libstdc++-v3/ChangeLog:

	* include/std/tuple [__cplusplus > 202002L]: Guard P2321R2
	changes with __cpp_lib_ranges_zip instead.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2024-01-18 11:21:16 -05:00
Patrick Palka
3d3145e9e1 libstdc++/debug: Fix constexpr _Safe_iterator in C++20 mode [PR109536]
Some _Safe_iterator member functions define a variable of non-literal
type __gnu_cxx::__scoped_lock, which automatically disqualifies them from
being constexpr in C++20 mode even if that code path is never constant
evaluated.  This restriction was lifted by P2242R3 for C++23, but we
need to work around it in C++20 mode.  To that end this patch defines
a pair of macros that encapsulate the lambda-based workaround mentioned
in that paper and uses it to make these functions valid C++20 constexpr
functions.  The augmented std::vector test element_access/constexpr.cc
now successfully compiles in C++20 mode with -D_GLIBCXX_DEBUG (and it
should test all member functions modified by this patch).

	PR libstdc++/109536

libstdc++-v3/ChangeLog:

	* include/debug/safe_base.h (_Safe_sequence_base::_M_swap):
	Remove _GLIBCXX20_CONSTEXPR from non-inline member function.
	* include/debug/safe_iterator.h
	(_GLIBCXX20_CONSTEXPR_NON_LITERAL_SCOPE_BEGIN): Define.
	(_GLIBCXX20_CONSTEXPR_NON_LITERAL_SCOPE_END): Define.
	(_Safe_iterator::operator=): Use them around the code path that
	defines a variable of type __gnu_cxx::__scoped_lock.
	(_Safe_iterator::operator++): Likewise.
	(_Safe_iterator::operator--): Likewise.
	(_Safe_iterator::operator+=): Likewise.
	(_Safe_iterator::operator-=): Likewise.
	* testsuite/23_containers/vector/element_access/constexpr.cc
	(test_iterators): Test more iterator operations.
	* testsuite/23_containers/vector/bool/element_access/constexpr.cc
	(test_iterators): Likewise.
	* testsuite/std/ranges/adaptors/all.cc (test08) [_GLIBCXX_DEBUG]:
	Remove.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2024-01-18 10:36:07 -05:00
Jonathan Wakely
ac913d5d51 libstdc++: Avoid -Wmaybe-uninitialized warnings in text_encoding.cc
These variables are only read from if we haven't reached the end of
either range, in which case they're guaranteed to be initialized to the
next alphanumeric character. But we can just initialize them to make the
compiler happy.

libstdc++-v3/ChangeLog:

	* include/bits/unicode.h (__charset_alias_match): Initialize
	__var_a and __var_b.
2024-01-18 12:43:32 +00:00
Jonathan Wakely
db42a0a989 libstdc++: Fix std::format test for Solaris [PR113450]
When int8_t is a typedef for char (rather than signed char) this test
fails because it tries to format a char, which is treated differently
from formatting other integral types (including signed char).

Use signed char explicitly so the result doesn't depend on the
non-portable definition of int8_t.

libstdc++-v3/ChangeLog:

	PR libstdc++/113450
	* testsuite/std/format/functions/format.cc: Use signed char
	instead of int8_t.
2024-01-18 12:43:31 +00:00
GCC Administrator
2c213ac9fa Daily bump. 2024-01-18 00:18:14 +00:00
Jonathan Wakely
df0a668b78 libstdc++: Implement C++26 std::text_encoding (P1885R12) [PR113318]
This is another C++26 change, approved in Varna 2023. We require a new
static array of data that is extracted from the IANA Character Sets
database. A new Python script to generate a header from the IANA CSV
file is added.

The text_encoding class is basically just a pointer to an {ID,name} pair
in the static array. The aliases view is also just the same pointer (or
empty), and the view's iterator moves forwards and backwards in the
array while the array elements have the same ID (or to one element
further, for a past-the-end iterator).

Because those iterators refer to a global array that never goes out of
scope, there's no reason they should every produce undefined behaviour
or indeterminate values.  They should either have well-defined
behaviour, or abort. The overhead of ensuring those properties is pretty
low, so seems worth it.

This means that an aliases_view iterator should never be able to access
out-of-bounds. A non-value-initialized iterator always points to an
element of the static array even when not dereferenceable (the array has
unreachable entries at the start and end, which means that even a
past-the-end iterator for the last encoding in the array still points to
valid memory).  Dereferencing an iterator can always return a valid
array element, or "" for a non-dereferenceable iterator (but doing so
will abort when assertions are enabled).  In the language being proposed
for C++26, dereferencing an invalid iterator erroneously returns "".
Attempting to increment/decrement past the last/first element in the
view is erroneously a no-op, so aborts when assertions are enabled, and
doesn't change value otherwise.

Similarly, constructing a std::text_encoding with an invalid id (one
that doesn't have the value of an enumerator) erroneously behaves the
same as constructing with id::unknown, or aborts with assertions
enabled.

libstdc++-v3/ChangeLog:

	PR libstdc++/113318
	* acinclude.m4 (GLIBCXX_CONFIGURE): Add c++26 directory.
	(GLIBCXX_CHECK_TEXT_ENCODING): Define.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Use GLIBCXX_CHECK_TEXT_ENCODING.
	* include/Makefile.am: Add new headers.
	* include/Makefile.in: Regenerate.
	* include/bits/locale_classes.h (locale::encoding): Declare new
	member function.
	* include/bits/unicode.h (__charset_alias_match): New function.
	* include/bits/text_encoding-data.h: New file.
	* include/bits/version.def (text_encoding): Define.
	* include/bits/version.h: Regenerate.
	* include/std/text_encoding: New file.
	* src/Makefile.am: Add new subdirectory.
	* src/Makefile.in: Regenerate.
	* src/c++26/Makefile.am: New file.
	* src/c++26/Makefile.in: New file.
	* src/c++26/text_encoding.cc: New file.
	* src/experimental/Makefile.am: Include c++26 convenience
	library.
	* src/experimental/Makefile.in: Regenerate.
	* python/libstdcxx/v6/printers.py (StdTextEncodingPrinter): New
	printer.
	* scripts/gen_text_encoding_data.py: New file.
	* testsuite/22_locale/locale/encoding.cc: New test.
	* testsuite/ext/unicode/charset_alias_match.cc: New test.
	* testsuite/std/text_encoding/cons.cc: New test.
	* testsuite/std/text_encoding/members.cc: New test.
	* testsuite/std/text_encoding/requirements.cc: New test.

Reviewed-by: Ulrich Drepper <drepper.fsp@gmail.com>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
2024-01-17 11:49:11 +00:00
Jonathan Wakely
665a3ff153 libstdc++: Do not use CTAD for _Utf32_view alias template
We were relying on P1814R0 (CTAD for alias templates) which isn't
supported by Clang. We can just not use CTAD and provide an explicit
template argument list for _Utf32_view.

Ideally we'd define a deduction guide for _Grapheme_cluster_view that
uses views::all_t to properly convert non-views to views, but all_t is
defined in <ranges> and we don't want to include all of that in
<bits/unicode.h>. So just make it require a view for now, which can be
cheaply copied.

Although it's not needed yet, it would also be more correct to
specialize enable_borrowed_range for the views in <bits/unicode.h>.

libstdc++-v3/ChangeLog:

	* include/bits/unicode.h (_Grapheme_cluster_view): Require view.
	Do not use CTAD for _Utf32_view.
	(__format_width, __truncate): Do not use CTAD.
	(enable_borrowed_range<_Utf_view<T, R>>): Define specialization.
	(enable_borrowed_range<_Grapheme_cluster_view<R>>): Likewise.
2024-01-17 11:49:10 +00:00
Patrick Palka
98966f32f9 libstdc++: Implement P2540R1 change to views::cartesian_product()
This paper changes the identity element of views::cartesian_product to a
singleton range instead of an empty range.  It was approved alongside
the main cartesian_product paper P2374R4, but unfortunately was overlooked
when implementing the main paper.

libstdc++-v3/ChangeLog:

	* include/std/ranges (views::_CartesianProduct::operator()):
	Adjust identity case as per P2540R1.
	* testsuite/std/ranges/cartesian_product/1.cc (test01):
	Adjust expected result of the identity case.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2024-01-16 21:20:12 -05:00
GCC Administrator
be035ec4f0 Daily bump. 2024-01-16 00:18:46 +00:00
Patrick Palka
2d55d94e5d libstdc++: Reduce std::variant template instantiation depth
The recursively defined constraints on _Variadic_union's user-defined
destructor (used for maintaining trivial destructibility of the variant
iff all of its alternatives are) turn out to require a template
instantiation depth of 3x the number of variants in C++20 mode, with the
instantiation stack looking like

  ...
  _Variadic_union<B, C, ...>
  std::is_trivially_destructible_v<_Variadic_union<B, C, ...>>
  _Variadic_union<A, B, C, ...>::~_Variadic_union()
  _Variadic_union<A, B, C, ...>
  ...

Ideally the template depth should be ~equal to the number of variants
(plus a constant).  Luckily it seems we don't need to compute trivial
destructibility of the alternatives at all from _Variadic_union, since
its only user _Variant_storage already has that information.  To that
end this patch removes these recursive constraints and instead passes
this information down from _Variant_storage.  After this patch, the
template instantiation depth for 87619.cc in C++20 mode is ~270 instead
of ~780.

libstdc++-v3/ChangeLog:

	* include/std/variant (__detail::__variant::_Variadic_union):
	Add bool __trivially_destructible template parameter.
	(__detail::__variant::_Variadic_union::~_Variadic_union):
	Use __trivially_destructible in constraints instead.
	(__detail::__variant::_Variant_storage): Pass
	__trivially_destructible value to _Variadic_union.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2024-01-15 16:41:42 -05:00
Patrick Palka
731444b3c3 libstdc++: Implement P2836R1 changes to const_iterator
libstdc++-v3/ChangeLog:

	* include/bits/stl_iterator.h (const_iterator): Define conversion
	operators as per P2836R1.
	* include/bits/version.def (ranges_as_const): Update value.
	* include/bits/version.h: Regenerate.
	* testsuite/24_iterators/const_iterator/1.cc (test04): New test.
	* testsuite/std/ranges/adaptors/as_const/1.cc: Adjust expected
	value of __cpp_lib_ranges_as_const.
	* testsuite/std/ranges/version_c++23.cc: Likewise.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2024-01-15 15:13:53 -05:00
Jonathan Wakely
1e88a151f8 libstdc++: Fix redefinition error in std::tuple [PR108822]
When using a compiler that doesn't define __cpp_conditional_explicit
there's a redefinition error for tuple::__nothrow_assignable. This is
because it's defined in different places for the pre-C++20 and C++20
implementations, which are controled by different preprocessor
conditions. For certain combinations of C++20 feature test macros it's
possible for both __nothrow_assignable definitions to be in scope.

Move the pre-C++20 __assignable and __nothrow_assignable definitions adjacent to
their use, so that only one set of definitions is visible for any given
set of feature test macros.

libstdc++-v3/ChangeLog:

	PR libstdc++/108822
	* include/std/tuple (__assignable, __is_nothrow_assignable):
	Move pre-C++20 definitions adjacent to their use.
2024-01-15 17:18:53 +00:00
Jonathan Wakely
6c703b4eb6 libstdc++: Use variable template to fix -fconcepts-ts error [PR113366]
There's an error for -fconcepts-ts due to using a concept where a bool
NTTP is required, which is fixed by using the vraiable template that
already exists in the class scope.

This doesn't fix the problem with -fconcepts-ts as changes to the
placement of attributes is also needed.

libstdc++-v3/ChangeLog:

	PR testsuite/113366
	* include/std/format (basic_format_arg): Use __formattable
	variable template instead of __format::__formattable_with
	concept.
2024-01-15 16:59:27 +00:00
Jonathan Wakely
4f141b051e libstdc++: Update tzdata to 2023d
Import the new 2023d tzdata.zi file. The leapseconds file was also
updated to have a new expiry (no new leap seconds were added).

libstdc++-v3/ChangeLog:

	* src/c++20/tzdata.zi: Import new file from 2023d release.
	* src/c++20/tzdb.cc (tzdb_list::_Node::_S_read_leap_seconds)
	Update expiry date for leap seconds list.
2024-01-15 16:59:27 +00:00
GCC Administrator
ed5bf2080c Daily bump. 2024-01-14 00:17:47 +00:00
Jonathan Wakely
f8a5298c97 libstdc++: Implement P2255R2 dangling checks for std::tuple [PR108822]
This is the last part of PR libstdc++/108822 implementing P2255R2, which
makes it ill-formed to create a std::tuple that would bind a reference
to a temporary.

The dangling checks are implemented as deleted constructors for C++20
and higher, and as Debug Mode static assertions in the constructor body
for older standards. This is similar to the r13-6084-g916ce577ad109b
changes for std::pair.

As part of this change, I've reimplemented most of std::tuple for C++20,
making use of concepts to replace the enable_if constraints, and using
conditional explicit to avoid duplicating most constructors. We could
use conditional explicit for the C++11 implementation too (with pragmas
to disables the -Wc++17-extensions warnings), but that should be done as
a stage 1 change for GCC 15 rather than now.

The partial specialization for std::tuple<T1, T2> is no longer used for
C++20 (or more precisely, for a C++20 compiler that supports concepts
and conditional explicit). The additional constructors and assignment
operators that take std::pair arguments have been added to the C++20
implementation of the primary template, with sizeof...(_Elements)==2
constraints. This avoids reimplementing all the other constructors in
the std::tuple<T1, T2> partial specialization to use concepts. This way
we avoid four implementations of every constructor and only have three!
(The primary template has an implementation of each constructor for
C++11 and another for C++20, and the tuple<T1,T2> specialization has an
implementation of each for C++11, so that's three for each constructor.)

In order to make the constraints more efficient on the C++20 version of
the default constructor I've also added a variable template for the
__is_implicitly_default_constructible trait, implemented using concepts.

libstdc++-v3/ChangeLog:

	PR libstdc++/108822
	* include/std/tuple (tuple): Add checks for dangling references.
	Reimplement constraints and constant expressions using C++20
	features.
	* include/std/type_traits [C++20]
	(__is_implicitly_default_constructible_v): Define.
	(__is_implicitly_default_constructible): Use variable template.
	* testsuite/20_util/tuple/dangling_ref.cc: New test.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
2024-01-13 11:14:09 +00:00
Patrick Palka
ac1a399bf6 libstdc++: Implement C++23 std::bind_back from P2387R3 [PR108827]
The implementation is based off of std::bind_front.  Since this is a
C++23 feature we use deducing this unconditionally.

	PR libstdc++/108827
	PR libstdc++/111327

libstdc++-v3/ChangeLog:

	* include/bits/version.def (bind_back): Define.
	* include/bits/version.h: Regenerate.
	* include/std/functional (_Bind_back): Define for C++23.
	(bind_back): Likewise.
	* testsuite/20_util/function_objects/bind_back/1.cc: New test
	(adapted from corresponding bind_front test).
	* testsuite/20_util/function_objects/bind_back/111327.cc: Likewise.
2024-01-12 23:02:12 -05:00
Patrick Palka
3e1ffa7dd1 libstdc++: Use C++23 deducing this in std::bind_front
This simplifies the operator() of _Bind_front using C++23 deducing
this, allowing us to condense multiple operator() overloads into one.

In passing I think we can remove _Bind_front's defaulted special member
declarations and just let the compiler implicitly generate them for us.

libstdc++-v3/ChangeLog:

	* include/std/functional (_Bind_front): Remove =default special
	member function declarations.
	(_Bind_front::operator()): Implement using C++23 deducing this
	when available.
	* testsuite/20_util/function_objects/bind_front/111327.cc:
	Adjust testcase to expect better errors in C++23 mode.
2024-01-12 22:55:43 -05:00
Patrick Palka
c48bedd180 libstdc++/ranges: Use perfect forwarding in _Pipe and _Partial ctors
This avoids redundant moves when composing and partially applying range
adaptor objects.

libstdc++-v3/ChangeLog:

	* include/std/ranges (views::__adaptor::operator|): Perform
	perfect forwarding of arguments.
	(views::__adaptor::_RangeAdaptor::operator()): Pass dummy
	first argument to _Partial.
	(views::__adaptor::_Partial::_Partial): Likewise.  Add dummy
	first parameter.
	(views::__adaptor::_Pipe::_Pipe): Perform perfect forwarding
	of arguments.
	(to): Pass dummy first argument to _Partial.
2024-01-12 22:54:59 -05:00