Commit graph

13812 commits

Author SHA1 Message Date
Jeff Chapman II
ea63396f6b libstdc++: add experimental Contracts support
This patch adds the library support for the experimental C++ Contracts
implementation.  This now consists only of a default definition of the
violation handler, which users can override through defining their own
version.  To avoid ABI stability problems with libstdc++.so this is added to
a separate -lstdc++exp static library, which the driver knows to add when it
sees -fcontracts.

Co-authored-by: Andrew Marmaduke <amarmaduke@lock3software.com>
Co-authored-by: Jason Merrill  <jason@redhat.com>

libstdc++-v3/ChangeLog:

	* acinclude.m4 (glibcxx_SUBDIRS): Add src/experimental.
	* include/Makefile.am (experimental_headers): Add contract.
	* include/Makefile.in: Regenerate.
	* src/Makefile.am (SUBDIRS): Add experimental.
	* src/Makefile.in: Regenerate.
	* configure: Regenerate.
	* src/experimental/contract.cc: New file.
	* src/experimental/Makefile.am: New file.
	* src/experimental/Makefile.in: New file.
	* include/experimental/contract: New file.
2022-11-18 21:40:29 -05:00
GCC Administrator
add8984069 Daily bump. 2022-11-18 18:09:19 +00:00
Jonathan Wakely
f69a8299c1 libstdc++: Ensure std::to_chars overloads all declared in <format> [PR107720]
For powerpc64le we need to be able to format both of __ieee128 and
__ibm128, so we need the std::to_chars overloads for both types to be
visible at once. The __ieee128 overloads are always visible in C++23
mode, because they're used to implement the _Float128 overloads. The
__ibm128 overloads are only visible when long double is __ibm128.

libstdc++-v3/ChangeLog:

	PR libstdc++/107720
	* include/std/format [_GLIBCXX_LONG_DOUBLE_ALT128_COMPAT]:
	Declare overloads of std::to_chars for the alternative long
	double type.
2022-11-17 00:34:42 +00:00
GCC Administrator
80909529c9 Daily bump. 2022-11-17 00:16:52 +00:00
Jonathan Wakely
dbdce6adb7 libstdc++: Fix dumb typos in ALT128 support in <format> [PR107720]
This is only a partial fix for the PR.

libstdc++-v3/ChangeLog:

	PR libstdc++/107720
	* include/std/format (__format::_Arg_t): Fix typo in enumerator
	name.
	(_Arg_value::_S_get): Fix missing semi-colons.
2022-11-16 20:52:53 +00:00
Jonathan Wakely
629897ed80 libstdc++: Improve performance of chrono::utc_clock::now()
We can use an array instead of a std::vector, and we can avoid the
binary search for the common case of a time point after the most recent
leap second. On one system where I tested this, utc_clock::now() now
takes about 16ns instead of 31ns.

libstdc++-v3/ChangeLog:

	* include/std/chrono (get_leap_second_info): Optimize.
2022-11-16 20:52:53 +00:00
Jonathan Wakely
2f5c071860 libstdc++: Adjust <format> for Clang compatibility [PR107712]
Clang doesn't define __builtin_toupper, so use std::toupper.

Also add some (not actually required since C++20) typename keywords to
help Clang versions up to and including 15.

libstdc++-v3/ChangeLog:

	PR libstdc++/107712
	* include/std/format (__format::__formatter_int::format): Use
	std::toupper when __builtin_toupper isn't available.
	(basic_format_arg::handle): Add 'typename'.
	* include/std/complex (complex<T>): Add 'typename'.
2022-11-16 20:52:37 +00:00
Jonathan Wakely
22cb0fea71 libstdc++: Disable std::format of _Float128 if std::to_chars is innaccurate
This restricts std::format support for _Float128 (and __float128) to
targets where glibc provides __strfromf128 and so can give correct
output.

libstdc++-v3/ChangeLog:

	* include/std/format [__FLT128_DIG__] (_GLIBCXX_FORMAT_F128):
	Only support formatting _Float128 when glibc provides the
	functionality needed for accurate std::to_chars.
2022-11-16 20:52:03 +00:00
Jonathan Wakely
7026d0455d libstdc++: Add test for chrono::utc_clock leap second offset
This test of leap second handling is taken from the C++20 standard.

libstdc++-v3/ChangeLog:

	* testsuite/std/time/clock/utc/1.cc: Check handling across leap
	second insertion.
2022-11-16 15:07:17 +00:00
Patrick Palka
ec59848074 libstdc++: Fix stream initialization with static library [PR107701]
When linking with a static library, the linker seems to discard a
constituent .o object (including its global initializers) if nothing
defined in the object is referenced by the program (unless e.g.
--whole-archive is used).  This behavior breaks iostream with static
libstdc++.a (on systems that support init priorities) because we define
the global initializer for the standard stream objects in a separate TU
(ios_init.cc) from the stream object definitions (globals_io.cc).

This patch fixes this by moving the stream initialization object into
the same TU that defines the stream objects, so that any use of the
streams prevents the linker from discarding this global initializer.

	PR libstdc++/107701

libstdc++-v3/ChangeLog:

	* include/std/iostream (__ioinit): Adjust comment.
	* src/c++98/globals_io.cc: Include "io_base_init.h" here
	instead of ...
	* src/c++98/ios_init.cc: ... here.
	* src/c++98/ios_base_init.h (__ioinit): More comments.
	* testsuite/17_intro/static.cc: dg-do run instead of just link.
2022-11-16 08:53:51 -05:00
Jakub Jelinek
0e2c5510e0 libstdc++: Fix up <complex> for extended floating point types [PR107649]
As filed by Jonathan in the PR, I've screwed up the requires syntax
in the extended floating point specialization:
-    requires(__complex_type<_Tp>::type)
+    requires requires { typename __complex_type<_Tp>::type; }
and doing this change resulted in lots of errors because __complex_whatever
overfloads from extended floating point types were declared after the
templates which used them.

The following patch fixes that.

Bootstrapped/regtested on x86_64-linux and i686-linux, additionally
I've tested that with _GLIBCXX_HAVE_FLOAT128_MATH not being defined
while __STDCPP_FLOAT128_T__ defined one can still use
std::complex<std::float128_t> for basic arithmetic etc., just one can't
expect std::sin etc. to work in that case (because we don't have any
implementation).

2022-11-16  Jakub Jelinek  <jakub@redhat.com>
	    Jonathan Wakely  <jwakely@redhat.com>

	PR libstdc++/107649
	* include/std/complex (__complex_abs, __complex_arg, __complex_cos,
	__complex_cosh, __complex_exp, __complex_log, __complex_sin,
	__complex_sinh, __complex_sqrt, __complex_tan, __complex_tanh,
	__complex_pow): Move __complex__ _Float{16,32,64,128} and
	__complex__ decltype(0.0bf16) overloads earlier in the file.
	(complex): Fix up requires on the partial specialization for extended
	float types.
	(__complex_acos, __complex_asin, __complex_atan, __complex_acosh,
	__complex_asinh, __complex_atanh): Move
	__complex__ _Float{16,32,64,128} and __complex__ decltype(0.0bf16)
	overloads earlier in the file.
2022-11-16 14:45:40 +01:00
Jonathan Wakely
3c54805d03 libstdc++: Fix std::any pretty printer
The recent changes to FilteringTypePrinter affect the result of
gdb.lookup_type('std::string') in StdExpAnyPrinter, causing it to always
return the std::__cxx11::basic_string specialization. This then causes a
gdb.error exception when trying to lookup the std::any manager type for
a specliaization using that string, but that manager was never
instantiated in the program. This causes FAILs when running the tests
with -D_GLIBCXX_USE_CXX11_ABI=0:

FAIL: libstdc++-prettyprinters/libfundts.cc print as
FAIL: libstdc++-prettyprinters/libfundts.cc print as

The ugly solution used in this patch is to repeat the lookup for every
type that std::string could be a typedef for, and hope it only works for
one of them.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdExpAnyPrinter): Make
	expansion of std::string in manager name more robust.
2022-11-16 13:37:38 +00:00
Jonathan Wakely
9228162202 libstdc++: Improve comments on pretty printer code
libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (is_specialization_of): Fix
	incorrect terminology in docstring and describe arguments.
	(FilteringTypePrinter): Add default argument for new parameter,
	enhance docstring.
2022-11-16 13:37:37 +00:00
François Dumont
2b7f0378b9 libstdc++: Fix gdb FilteringTypePrinter
Once we found a matching FilteringTypePrinter instance we look for the associated
typedef and check that the returned Python Type is equal to the Type to recognize.
But gdb Python Type includes properties to distinguish a typedef from the actual
type. So use gdb.types.get_basic_type to check if we are indeed on the same type.

Additionnaly enhance FilteringTypePrinter matching mecanism by introducing targ1 that,
if not None, will be used as the 1st template parameter.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (FilteringTypePrinter): Rename 'match' field
	'template'. Add self.targ1 to specify the first template parameter of the instantiation
	to match.
	(add_one_type_printer): Add targ1 optional parameter, default to None.
	Use gdb.types.get_basic_type to compare the type to recognize and the type
	returned from the typedef lookup.
	(register_type_printers): Adapt calls to add_one_type_printers.
2022-11-16 06:53:31 +01:00
GCC Administrator
cdc34229c1 Daily bump. 2022-11-16 00:17:09 +00:00
Jonathan Wakely
c68c468e0e libstdc++: Fix std::format test for strict -std=c++20 mode
Adjust a test to avoid using std::make_unsigned_t<__int128>. That's
ill-formed in strict modes because std::is_integral_v<__int128> is
false.

libstdc++-v3/ChangeLog:

	* testsuite/std/format/functions/format.cc: Do not use
	std::make_unsigned_t<__int128>.
2022-11-15 14:24:57 +00:00
Jonathan Wakely
a5d4f38fbe libstc++: std::formattable concept should not be defined for C++20
This concept was added by a C++23 proposal, so don't define it for
C++20.

Split the format/formatter/formatter.cc test into two parts, one that
tests the C++20 requirements and one that tests the C++23 concept.

libstdc++-v3/ChangeLog:

	* include/std/format (formattable): Only define for C++23/
	* testsuite/std/format/formatter.cc: Moved to...
	* testsuite/std/format/formatter/requirements.cc: ...here.
	* testsuite/std/format/formatter/concept.cc: New test.
	* testsuite/std/format/functions/format.cc: Replace use of
	std::formattable in C++20.
2022-11-15 14:01:39 +00:00
Jonathan Wakely
ce86d9678b libstdc++: Fix detection of std::format support for __float128 [PR107693]
std::format gives linker errors on targets that define __float128 but
do not support using it with std::to_chars. This improves the handling
of 128-bit flaoting-point types so they are disabled if unsupportable.

libstdc++-v3/ChangeLog:

	PR libstdc++/107693
	* include/std/format (_GLIBCXX_FORMAT_F128): Define to 2 when
	basic_format_arg needs to use its _M_f128 member.
	(__extended_floating_point, __floating_point): Replace with ...
	(__formattable_floating_point): New concept.
	* testsuite/std/format/functions/format.cc: Check whether
	__float128 is supported. Also test _Float128.
2022-11-15 14:01:39 +00:00
Jonathan Wakely
d34dea05f8 libstdc++: Document use of Markdown for Doxygen comments
libstdc++-v3/ChangeLog:

	* doc/xml/manual/documentation_hacking.xml: Document use of
	Markdown for Doxygen comments. Tweak formatting.
	* doc/html/manual/documentation_hacking.html: Regenerate.
2022-11-15 11:35:52 +00:00
GCC Administrator
83d400bded Daily bump. 2022-11-15 08:32:29 +00:00
Jonathan Wakely
2b85d759da libstdc++: Fix installation of python files for debug lib
libstdc++-v3/ChangeLog:

	* python/Makefile.am (install-data-local): Use mkdirs_p for debug
	libdir.
	* python/Makefile.in: Regenerate.
2022-11-14 15:59:50 +00:00
Bernhard Reutner-Fischer
3c6721796d libstdc++: Fix install-debug makefile target
This target should have been changed by r13-3918-gba7551485bc576 and now
fails.

libstdc++-v3/ChangeLog:

	* src/Makefile.am (install-debug): Remove use of $(debugdir).
	* src/Makefile.in: Regenerate.
2022-11-14 10:16:11 +00:00
GCC Administrator
eefbfbc793 Daily bump. 2022-11-14 00:17:08 +00:00
Jonathan Wakely
1736bf5a61 libstdc++: Add C++20 clocks
Also add the basic types for timezones, without the non-inline
definitions needed to actually use them.

The get_leap_second_info function currently uses a hardcoded list of
leap seconds, correct as of the end of 2022. That needs to be replaced
with a dynamically generated list read from the system tzdata. That will
be done in a later patch.

libstdc++-v3/ChangeLog:

	* include/std/chrono (utc_clock, tai_clock, gps_clock): Define.
	(clock_time_conversion, clock_cast): Define.
	(sys_info, local_info): Define structs for timezone information.
	(nonexistent_local_time, ambiguous_local_time): Define
	exceptions for invalid times.
	(time_zone, time_zone_link, leap_second, zoned_traits, tzdb)
	(tzdb_list): Define classes representing time zones.
	(get_leap_second_info): Define new function returning leap
	second offset for a given time point.
	* testsuite/std/time/clock/gps/1.cc: New test.
	* testsuite/std/time/clock/tai/1.cc: New test.
	* testsuite/std/time/clock/utc/1.cc: New test.
2022-11-13 01:10:45 +00:00
Jonathan Wakely
1d9454aba6 libstdc++: Implement C++20 <format> [PR104166]
This doesn't add the newer C++23 features like formatting ranges
and escaped string prsentation types.

However, C++23 extended floating-point types are supported, as are
128-bit integers.

It could do with more tests.

libstdc++-v3/ChangeLog:

	PR libstdc++/104166
	* include/Makefile.am (std_headers): Add <format>.
	* include/Makefile.in: Regenerate.
	* include/precompiled/stdc++.h: Add <format>.
	* include/std/format: New file.
	* python/libstdcxx/v6/printers.py (StdFormatArgsPrinter): New
	printer for std::format_args.
	* testsuite/std/format/arguments/args.cc: New test.
	* testsuite/std/format/error.cc: New test.
	* testsuite/std/format/formatter.cc: New test.
	* testsuite/std/format/functions/format.cc: New test.
	* testsuite/std/format/functions/format_to_n.cc: New test.
	* testsuite/std/format/functions/size.cc: New test.
	* testsuite/std/format/functions/vformat_to.cc: New test.
	* testsuite/std/format/parse_ctx.cc: New test.
	* testsuite/std/format/string.cc: New test.
	* testsuite/std/format/string_neg.cc: New test.
2022-11-13 01:10:44 +00:00
Jonathan Wakely
d4ba3b369c libstdc++: Allow std::to_chars for 128-bit integers in strict mode
This allows std::format to support __int128 when __STRICT_ANSI__ is
defined, which previously failed because __int128 is not an integral
type in strict mode.

With these changes, std::to_chars still rejects 128-bit integers in
strict mode, but std::format will be able to use __detail::__to_chars_i
for unsigned __int128.

libstdc++-v3/ChangeLog:

	* include/bits/charconv.h (__integer_to_chars_is_unsigned):
	New variable template.
	(__to_chars_len, __to_chars_10_impl): Use variable template in
	assertions to allow unsigned __int128 in strict mode.
	* include/std/charconv (__to_chars, __to_chars_16)
	(__to_chars_10, __to_chars_8, __to_chars_2): Likewise.
2022-11-13 01:10:44 +00:00
GCC Administrator
30d77d4962 Daily bump. 2022-11-13 00:17:02 +00:00
Jakub Jelinek
ec6c202971 libstdc++: Fix up to_chars ppc64le _Float128 overloads [PR107636]
As reported, I've misplaced __extension__ keywords in these cases
(wanted not to have them on the whole inlines because _Float128 is
completely standard now while __float128 is not, but before return
it is a syntax error.
I've verified on a short testcase that both g++ and clang++ accept
__extension__ after return keyword.

2022-11-12  Jakub Jelinek  <jakub@redhat.com>

	PR libstdc++/107636
	* include/std/charconv (to_chars): Fix up powerpc64le _Float128
	overload __extension__ placement.
2022-11-12 21:56:47 +01:00
Jonathan Wakely
ba7551485b libstdc++: Simplify build targets for debug library
This rewrites the stamp-debug and build-debug targets in src/Makefile so
that each generated Makefile in the debug/$(SUBDIRS) directories is a
make target, instead of being created by a loop in the stamp-debug
recipe. The final adjustments to debug/Makefile are done as part of the
stamp-debug target instead of the build-debug target.

The advantage is that each $(SUBDIRS)/debug/Makefile now has the
corresponding $(SUBDIRS)/Makefile as a prerequisite, so they will be
regenerated if needed. Generating those can also be parallelized by
make, although those steps are very fast so that doesn't really matter.

This also removes the duplication in the stamp-debug recipe, which was
using exactly the same sed command for debug/Makefile and each
debug/$(SUBDIRS)/Makefile. That is done by adding "." to the list of
subdirectories to process. The recipes can also be simplified to use
separate shell commands per line, instead of using backslashes to join
the whole recipe into a single shell command.

Also replace 'echo `date` > stamp-xxx' with just 'date > stamp-xxx'
which is equivalent but simpler.

libstdc++-v3/ChangeLog:

	* src/Makefile.am: Simplify debug build targets.
	* src/Makefile.in: Regenerate.
2022-11-12 01:29:47 +00:00
Jonathan Wakely
a7f51059fb libstdc++: Define INSTANTIATE_FACET_ACCESSORS macro in compat source [PR103755]
compatibility-ldbl-alt128.cc re-includes locale-inst-numeric.h and
locale-inst-monetary.h but wasn't defining the macros added in
r13-3888-gb3ac43a3c05744.

Put those macros in a new internal header that can be included everywhere
they're used.

libstdc++-v3/ChangeLog:

	PR libstdc++/103755
	* src/c++11/locale-inst-monetary.h: Include new header.
	* src/c++11/locale-inst-numeric.h: Likewise.
	* src/c++11/locale-inst.cc: Likewise.
	(INSTANTIATE_USE_FACET, INSTANTIATE_FACET_ACCESSORS): Move
	macro definitions to ...
	* src/c++11/facet_inst_macros.h: New file.
2022-11-12 01:29:46 +00:00
GCC Administrator
5b6ce16ade Daily bump. 2022-11-12 00:17:25 +00:00
Jonathan Wakely
8214ec0cf3 libstdc++: Fix <experimental/filesystem> for Windows [PR95048]
I meant to include this change in r13-3909-gb331bf303bdc1e but I forgot
to sync it from the machine where I did the mingw testing to the one
where I pushed the commit.

libstdc++-v3/ChangeLog:

	PR libstdc++/95048
	* include/experimental/bits/fs_path.h (path::_Cvt::_S_wconvert):
	Construct codecvt directly instead of getting it from the
	locale.
2022-11-11 22:28:03 +00:00
Nathaniel Shead
52672be7d3 libstdc++: Set active union member in constexpr std::string [PR103295]
Clang still complains about using std::string in constexpr contexts due
to the changes made in commit 98a0d72a. This patch ensures that we set
the active member of the union as according to [class.union.general] p6.

libstdc++-v3/ChangeLog:

	PR libstdc++/103295
	* include/bits/basic_string.h (_M_use_local_data): Set active
	member to _M_local_buf.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
2022-11-11 17:57:37 +00:00
Jonathan Wakely
b331bf303b libstdc++: Fix wstring conversions in filesystem::path [PR95048]
In commit r9-7381-g91756c4abc1757 I changed filesystem::path to use
std::codecvt<CharT, char, mbstate_t> for conversions from all wide
strings to UTF-8, instead of using std::codecvt_utf8<CharT>. This was
done because for 16-bit wchar_t, std::codecvt_utf8<wchar_t> only
supports UCS-2 and not UTF-16. The rationale for the change was sound,
but the actual fix was not. It's OK to use std::codecvt for char16_t or
char32_t, because the specializations for those types always use UTF-8 ,
but std::codecvt<wchar_t, char, mbstate_t> uses the current locale's
encodings, and the narrow encoding is probably ASCII and can't support
non-ASCII characters.

The correct fix is to use std::codecvt only for char16_t and char32_t.
For 32-bit wchar_t we could have continued using std::codecvt_utf8
because that uses UTF-32 which is fine, switching to std::codecvt broke
non-Windows targets with 32-bit wchar_t. For 16-bit wchar_t we did need
to change, but should have changed to std::codecvt_utf8_utf16<wchar_t>
instead, as that always uses UTF-16 not UCS-2. I actually noted that in
the commit message for r9-7381-g91756c4abc1757 but didn't use that
option. Oops.

This replaces the unconditional std::codecvt<CharT, char, mbstate_t>
with a type defined via template specialization, so it can vary
depending on the wide character type. The code is also simplified to
remove some of the mess of #ifdef and if-constexpr conditions.

libstdc++-v3/ChangeLog:

	PR libstdc++/95048
	* include/bits/fs_path.h (path::_Codecvt): New class template
	that selects the kind of code conversion done.
	(path::_Codecvt<wchar_t>): Select based on sizeof(wchar_t).
	(_GLIBCXX_CONV_FROM_UTF8): New macro to allow the same code to
	be used for Windows and POSIX.
	(path::_S_convert(const EcharT*, const EcharT*)): Simplify by
	using _Codecvt and _GLIBCXX_CONV_FROM_UTF8 abstractions.
	(path::_S_str_convert(basic_string_view<value_type>, const A&)):
	Simplify nested conditions.
	* include/experimental/bits/fs_path.h (path::_Cvt): Define
	nested typedef controlling type of code conversion done.
	(path::_Cvt::_S_wconvert): Use new typedef.
	(path::string(const A&)): Likewise.
	* testsuite/27_io/filesystem/path/construct/95048.cc: New test.
	* testsuite/experimental/filesystem/path/construct/95048.cc: New
	test.
2022-11-11 17:16:42 +00:00
Jonathan Wakely
fbad7a74aa libstdc++: Fix tests with non-const operator==
These tests fail in strict -std=c++20 mode but their equality ops don't
need to be non-const, it looks like an accident.

This fixes two FAILs with -std=c++20:
FAIL: 20_util/tuple/swap.cc (test for excess errors)
FAIL: 26_numerics/valarray/87641.cc (test for excess errors)

libstdc++-v3/ChangeLog:

	* testsuite/20_util/tuple/swap.cc (MoveOnly::operator==): Add
	const qualifier.
	* testsuite/26_numerics/valarray/87641.cc (X::operator==):
	Likewise.
2022-11-11 04:00:58 +00:00
Jonathan Wakely
f54ae4da1f libstdc++: Add missing definition for <charconv> in C++14 mode
We support <charconv> in C++14 as an extension, but that means that
constexpr static data members are not implicitly inline. Add an
out-of-class definition for C++14 mode.

This fixes a FAIL when -std=gnu++14 is used:
FAIL: 20_util/from_chars/1.cc (test for excess errors)

libstdc++-v3/ChangeLog:

	* include/std/charconv (__from_chars_alnum_to_val_table::value):
	[!__cpp_inline_variables]: Add non-inline definition.
2022-11-11 04:00:58 +00:00
Jonathan Wakely
56d2222c58 libstdc++: Fix test that uses C++17 variable template in C++14
This test fails if run with -std=gnu++14 because it should be using
is_convertible instead of is_convertible_v.

libstdc++-v3/ChangeLog:

	* testsuite/experimental/propagate_const/observers/107525.cc:
	Use type trait instead of C++17 variable template.
2022-11-11 04:00:58 +00:00
Jonathan Wakely
b3ac43a3c0 libstdc++: Avoid redundant checks in std::use_facet [PR103755]
We do not need to do bounds checks or a runtime dynamic_cast when using
std::has_facet and std::use_facet to access the default facets that are
guaranteed to be present in every std::locale object. We can just index
straight into the array and use a static_cast for the conversion.

This patch adds a new std::__try_use_facet function that is like
std::use_facet but returns a pointer, so can be used to implement both
std::has_facet and std::use_facet. We can then do the necessary
metaprogramming to skip the redundant checks in std::__try_use_facet.

To avoid having to export (or hide) instantiations of the new function
from libstdc++.so the instantiations are given hidden visibility. This
allows them to be used in the library, but user code will instantiate it
again using the definition in the header. That would happen anyway,
because there are no explicit instantiation declarations for any of
std::has_facet, std::use_facet, or the new std::__try_use_facet.

libstdc++-v3/ChangeLog:

	PR libstdc++/103755
	* config/abi/pre/gnu.ver: Tighten patterns for facets in the
	base version. Add exports for __try_use_facet.
	* include/bits/basic_ios.tcc (basic_ios::_M_cache_locale): Use
	__try_use_facet instead of has_facet and use_facet.
	* include/bits/fstream.tcc (basic_filebuf::basic_filebuf()):
	Likewise.
	(basic_filebuf::imbue): Likewise.
	* include/bits/locale_classes.h (locale, locale::id)
	(locale::_Impl): Declare __try_use_facet as a friend.
	* include/bits/locale_classes.tcc (__try_use_facet): Define new
	function template with special cases for default facets.
	(has_facet, use_facet): Call __try_use_facet.
	* include/bits/locale_facets.tcc (__try_use_facet): Declare
	explicit instantiations.
	* include/bits/locale_facets_nonio.tcc (__try_use_facet):
	Likewise.
	* src/c++11/locale-inst-monetary.h (INSTANTIATE_FACET_ACCESSORS):
	Use new macro for facet accessor instantiations.
	* src/c++11/locale-inst-numeric.h (INSTANTIATE_FACET_ACCESSORS):
	Likewise.
	* src/c++11/locale-inst.cc (INSTANTIATE_USE_FACET): Define new
	macro for instantiating __try_use_facet and use_facet.
	(INSTANTIATE_FACET_ACCESSORS): Define new macro for also
	defining has_facet.
	* src/c++98/compatibility-ldbl.cc (__try_use_facet):
	Instantiate.
	* testsuite/22_locale/ctype/is/string/89728_neg.cc: Adjust
	expected errors.
2022-11-11 04:00:58 +00:00
GCC Administrator
f225b813e4 Daily bump. 2022-11-11 00:17:22 +00:00
Jonathan Wakely
0cbb756fe9 libstdc++: Optimize std::destructible concept
This uses variable templates and constraints to define a much simpler
std::destructible concept. This avoids instantiating the trait
std::is_nothrow_destructible and all its implementation in terms of
__is_destructible_safe and __is_destructible_impl.

If we had an intrinsic we could just use that (PR c++/107600).

libstdc++-v3/ChangeLog:

	* include/std/concepts (__detail::__destructible_impl)
	(__detail::__destructible): New variable templates.
	(destructible): Use __detail::__destructible.
	* testsuite/std/concepts/concepts.lang/concept.destructible/1.cc:
	Add more checks for array and reference types.
2022-11-10 01:59:34 +00:00
GCC Administrator
69023a9f95 Daily bump. 2022-11-09 00:19:55 +00:00
Jonathan Wakely
bbcb84bba0 libstdc++: Fix -Wsystem-headers warnings in tests
libstdc++-v3/ChangeLog:

	* testsuite/18_support/new_nothrow.cc: Add missing noexcept
	to operator delete replacements.
	* testsuite/20_util/any/cons/92156.cc: Disable
	-Winit-list-lifetime warnings from instantiating invalid
	specialization of manager function.
	* testsuite/20_util/any/modifiers/92156.cc: Likewise.
	* testsuite/20_util/default_delete/void_neg.cc: Prune additional
	diagnostics.
	* testsuite/20_util/headers/memory/synopsis.cc: Add missing
	noexcept.
	* testsuite/20_util/shared_ptr/cons/void_neg.cc: Prune
	additional diagnostic.
	* testsuite/20_util/unique_ptr/creation/for_overwrite.cc: Add
	missing noexcept to operator delete replacements.
	* testsuite/21_strings/basic_string/cons/char/103919.cc:
	Likewise.
	* testsuite/23_containers/map/modifiers/emplace/92300.cc:
	Likewise.
	* testsuite/23_containers/map/modifiers/insert/92300.cc:
	Likewise.
	* testsuite/24_iterators/headers/iterator/range_access_c++11.cc:
	Add missing noexcept to synopsis declarations.
	* testsuite/24_iterators/headers/iterator/range_access_c++14.cc:
	Likewise.
	* testsuite/24_iterators/headers/iterator/range_access_c++17.cc:
	Likewise.
2022-11-08 17:35:15 +00:00
Jonathan Wakely
8f6d25f19b libstdc++: Fix -Wsystem-headers warnings
Fix some problems noticed with -Wsystem-headers.

libstdc++-v3/ChangeLog:

	* include/bits/stl_tempbuf.h (_Temporary_buffer): Disable
	warnings about get_temporary_buffer being deprecated.
	* include/ext/functional (mem_fun1, mem_fun1_ref): Disable
	warnings about mem_fun1_t, const_mem_fun1_t, mem_fun1_ref_t and
	const_mem_fun1_ref_t being deprecated.
	* include/std/array (__array_traits<T, 0>): Remove artificial
	attributes which give warnings about being ignored.
	* include/std/spanstream (basic_spanbuf::setbuf): Add assertion
	and adjust to avoid narrowing warning.
	* libsupc++/exception_ptr.h [!__cpp_rtti && !__cpp_exceptions]
	(make_exception_ptr): Add missing inline specifier.
2022-11-08 17:35:15 +00:00
Jonathan Wakely
9d549401ae libstdc++: Add always_inline to most allocator functions
This reduces the abstraction penalty for allocator support in
unoptimized code. Constructing and using allocators in containers calls
many one-line (or completely empty) inline functions. Those can all be
inlined to reduce code size and function call overhead for -O0.

libstdc++-v3/ChangeLog:

	* include/bits/alloc_traits.h (allocator_traits): Add
	always_inline attribute to all member functions.
	(__do_alloc_on_copy, __alloc_on_copy, __do_alloc_on_move)
	(__alloc_on_move, __do_alloc_on_swap, __alloc_on_swap)
	(_Destroy(FwdIter, FwdIter, allocator<T>&)): : Add
	always_inline attribute.
	* include/bits/allocator.h (allocator): Add always_inline
	attribute to all member functions and equality operators.
	* include/bits/new_allocator.h (__new_allocator): Likewise.
	* include/ext/alloc_traits.h (__gnu_cxx::__alloc_traits):
	Likewise.
2022-11-08 17:35:15 +00:00
Charles-François Natali
3f1519eef5 libstdc++: basic_filebuf: don't flush more often than necessary [PR63746]
`basic_filebuf::xsputn` would bypass the buffer when passed a chunk of
size 1024 and above, seemingly as an optimisation.

This can have a significant performance impact if the overhead of a
`write` syscall is non-negligible, e.g. on a slow disk, on network
filesystems, or simply during IO contention because instead of flushing
every `BUFSIZ` (by default), we can flush every 1024 char.
The impact is even greater with custom larger buffers, e.g. for network
filesystems, because the code could issue `write` for example 1000X more
often than necessary with respect to the buffer size.
It also introduces a significant discontinuity in performance when
writing chunks of size 1024 and above.

Instead, it makes sense to only bypass the buffer if the amount of data
to be written is larger than the buffer capacity.

Signed-off-by: Charles-Francois Natali <cf.natali@gmail.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/63746
	* include/bits/fstream.tcc (basic_filbuf::xsputn): Remove
	1024-byte chunking that bypasses the buffer for large writes.
	* testsuite/27_io/basic_filebuf/sputn/char/63746.cc: New test.
2022-11-08 17:35:14 +00:00
Will Hawkins
c93baa93df libstdc++: Refactor implementation of operator+ for std::string
Until now operator+(char*, string) and operator+(string, char*) had
different performance characteristics. The former required a single
memory allocation and the latter required two. This patch makes the
performance equal.

After consultation with Jonathan, it seemed like a good idea to create a
single function that performed one-allocation string concatenation that
could be used by various different version of operator+. This patch adds
such a function and calls it from the relevant implementations.

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

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.h (__str_cat): Add common function
	that performs single-allocation string concatenation.
	(operator+): Use __str_cat.
	* include/bits/basic_string.tcc (operator+): Move to .h and
	define inline using __str_cat.

Signed-off-by: Will Hawkins <whh8b@obs.cr>
2022-11-08 17:35:14 +00:00
Jakub Jelinek
ee86bdd1d3 libstdc++: Uncomment denorm_min test
As r13-3609-g6d9dbdf51f9afe8 has been committed, we can now enable
even the denorm_min test.

2022-11-08  Jakub Jelinek  <jakub@redhat.com>

	* testsuite/20_util/to_chars/float128_c++23.cc (test): Uncomment
	denorm_min test.
2022-11-08 11:19:25 +01:00
Jonathan Wakely
acbfa2bc60 libstdc++: Update my author blurb in the manual
libstdc++-v3/ChangeLog:

	* doc/xml/authors.xml: Update the blurb listing my doc
	contributions.
2022-11-08 03:07:49 +00:00
Jonathan Wakely
4596339d9f libstdc++: Remove empty <author> elements in manual
This fixes a spurious comma before the list of authors in the PDF
version of the libstdc++ manual.

Also fix the commented-out examples which should show <personblurb> not
<authorblurb>.

libstdc++-v3/ChangeLog:

	* doc/xml/authors.xml: Remove empty author element.
	* doc/xml/manual/spine.xml: Likewise.
	* doc/html/manual/index.html: Regenerate.
2022-11-08 03:07:49 +00:00
Joseph Myers
8d0326943e libstdc++: Fix syntax error in old-glibc case in floating_from_chars.cc [PR107562]
PR libstdc++/107562
	* src/c++17/floating_from_chars.cc (from_chars_impl): Fix syntax
	error.
2022-11-08 01:41:00 +00:00