Commit Graph

13426 Commits

Author SHA1 Message Date
GCC Administrator
5a66d7dd2b Daily bump. 2022-06-18 00:16:19 +00:00
Jonathan Wakely
0f96ac43fa libstdc++: Add missing #include <string> to new test
Somehow I pushed a different version of this test to the one I actually
tested.

libstdc++-v3/ChangeLog:

	* testsuite/21_strings/basic_string/cons/char/105995.cc: Add
	missing #include.
2022-06-17 13:30:10 +01:00
GCC Administrator
bc7e9f7675 Daily bump. 2022-06-17 00:16:23 +00:00
Jonathan Wakely
98a0d72a61 libstdc++: Support constexpr global std::string for size < 15 [PR105995]
I don't think this is required by the standard, but it's easy to
support.

libstdc++-v3/ChangeLog:

	PR libstdc++/105995
	* include/bits/basic_string.h (_M_use_local_data): Initialize
	the entire SSO buffer.
	* testsuite/21_strings/basic_string/cons/char/105995.cc: New test.
2022-06-16 20:20:40 +01:00
Jonathan Wakely
51309d1158 libstdc++: Apply r13-1096-g6abe341558abec change to vstring too [PR101482]
As recently done for std::basic_string, __gnu_cxx::__versa_string
equality comparisons can check lengths first for any character type and
traits type, not only for std::char_traits<char>.

libstdc++-v3/ChangeLog:

	PR libstdc++/101482
	* include/ext/vstring.h (operator==): Always check lengths
	before comparing.
2022-06-16 20:20:39 +01:00
GCC Administrator
499b9c5f09 Daily bump. 2022-06-16 00:16:44 +00:00
François Dumont
dc9b92facf libstdc++: [_Hashtable] Insert range of types convertible to value_type PR 105717
Fix insertion of range of instances convertible to value_type.

libstdc++-v3/ChangeLog:

	PR libstdc++/105717
	* include/bits/hashtable_policy.h (_ConvertToValueType): New.
	* include/bits/hashtable.h (_Hashtable<>::_M_insert_unique_aux): New.
	(_Hashtable<>::_M_insert(_Arg&&, const _NodeGenerator&, true_type)): Use latters.
	(_Hashtable<>::_M_insert(_Arg&&, const _NodeGenerator&, false_type)): Likewise.
	(_Hashtable(_InputIterator, _InputIterator, size_type, const _Hash&, const _Equal&,
	const allocator_type&, true_type)): Use this.insert range.
	(_Hashtable(_InputIterator, _InputIterator, size_type, const _Hash&, const _Equal&,
	const allocator_type&, false_type)): Use _M_insert.
	* testsuite/23_containers/unordered_map/cons/56112.cc: Check how many times conversion
	is done.
	* testsuite/23_containers/unordered_map/insert/105717.cc: New test.
	* testsuite/23_containers/unordered_set/insert/105717.cc: New test.
2022-06-15 20:21:52 +02:00
GCC Administrator
4adc5350fe Daily bump. 2022-06-15 00:16:24 +00:00
Jonathan Wakely
6abe341558 libstdc++: Check lengths first in operator== for basic_string [PR62187]
As confirmed by LWG 2852, the calls to traits_type::compare do not need
to be obsvervable, so we can make operator== compare string lengths
first and return immediately for non-equal lengths. This avoids doing a
slow string comparison for "abc...xyz" == "abc...xy". Previously we only
did this optimization for std::char_traits<char>, but we can enable it
unconditionally thanks to LWG 2852.

For comparisons with a const char* we can call traits_type::length right
away to do the same optimization. That strlen call can be folded away
for constant arguments, making it very efficient.

For the pre-C++20 operator== and operator!= overloads we can swap the
order of the arguments to take advantage of the operator== improvements.

libstdc++-v3/ChangeLog:

	PR libstdc++/62187
	* include/bits/basic_string.h (operator==): Always compare
	lengths before checking string contents.
	[!__cpp_lib_three_way_comparison] (operator==, operator!=):
	Reorder arguments.
2022-06-14 21:07:48 +01:00
Jonathan Wakely
1b65779f46 libstdc++: Inline all basic_string::compare overloads [PR59048]
Defining the compare member functions inline allows calls to
traits_type::length and std::min to be inlined, taking advantage of
constant expression arguments. When not inline, the compiler prefers to
use the explicit instantiation definitions in libstdc++.so and can't
take advantage of constant arguments.

libstdc++-v3/ChangeLog:

	PR libstdc++/59048
	* include/bits/basic_string.h (compare): Define inline.
	* include/bits/basic_string.tcc (compare): Remove out-of-line
	definitions.
	* include/bits/cow_string.h (compare): Define inline.
	* testsuite/21_strings/basic_string/operations/compare/char/3.cc:
	New test.
2022-06-14 21:07:47 +01:00
Jonathan Wakely
29da01709f libstdc++: Fix indentation in allocator base classes
libstdc++-v3/ChangeLog:

	* include/bits/new_allocator.h: Fix indentation.
	* include/ext/malloc_allocator.h: Likewise.
2022-06-14 21:07:47 +01:00
Jonathan Wakely
0a9af7b4ef libstdc++: Check for size overflow in constexpr allocation [PR105957]
libstdc++-v3/ChangeLog:

	PR libstdc++/105957
	* include/bits/allocator.h (allocator::allocate): Check for
	overflow in constexpr allocation.
	* testsuite/20_util/allocator/105975.cc: New test.
2022-06-14 21:07:47 +01:00
GCC Administrator
c3642271e8 Daily bump. 2022-06-14 00:16:39 +00:00
Mark Mentovai
254e88b3d7 libstdc++: Rename __null_terminated to avoid collision with Apple SDK
The macOS 13 SDK (and equivalent-version iOS and other Apple OS SDKs)
contain this definition in <sys/cdefs.h>:

863  #define __null_terminated

This collides with the use of __null_terminated in libstdc++'s
experimental fs_path.h.

As libstdc++'s use of this token is entirely internal to fs_path.h, the
simplest workaround, renaming it, is most appropriate. Here, it's
renamed to __nul_terminated, referencing the NUL ('\0') value that is
used to terminate the strings in the context in which this tag structure
is used.

libstdc++-v3/ChangeLog:

	* include/experimental/bits/fs_path.h (__detail::__null_terminated):
	Rename to __nul_terminated to avoid colliding with a macro in
	Apple's SDK.

Signed-off-by: Mark Mentovai <mark@mentovai.com>
2022-06-13 20:25:49 +01:00
Jonathan Wakely
30cc1b65e4 libstdc++: Use type_identity_t for non-deducible std::atomic_xxx args
This is LWG 3220 which is about to become Tentatively Ready.

libstdc++-v3/ChangeLog:

	* include/std/atomic (__atomic_val_t): Use __type_identity_t
	instead of atomic<T>::value_type, as per LWG 3220.
	* testsuite/29_atomics/atomic/lwg3220.cc: New test.
2022-06-13 16:39:07 +01:00
GCC Administrator
ef1e4d80dd Daily bump. 2022-06-11 00:16:21 +00:00
Jonathan Wakely
671970a562 libstdc++: Make std::lcm and std::gcd detect overflow [PR105844]
When I fixed PR libstdc++/92978 I introduced a regression whereby
std::lcm(INT_MIN, 1) and std::lcm(50000, 49999) would no longer produce
errors during constant evaluation. Those calls are undefined, because
they violate the preconditions that |m| and the result can be
represented in the return type (which is int in both those cases). The
regression occurred because __absu<unsigned>(INT_MIN) is well-formed,
due to the explicit casts to unsigned in that new helper function, and
the out-of-range multiplication is well-formed, because unsigned
arithmetic wraps instead of overflowing.

To fix 92978 I made std::gcm and std::lcm calculate |m| and |n|
immediately, yielding a common unsigned type that was used to calculate
the result. That was partly correct, but there's no need to use an
unsigned type. Doing so only suppresses the overflow errors so the
compiler can't detect them. This change replaces __absu with __abs_r
that returns the common type (not its corresponding unsigned type). This
way we can detect overflow in __abs_r when required, while still
supporting the most-negative value when it can be represented in the
result type. To detect LCM results that are out of range of the result
type we still need explicit checks, because neither constant evaluation
nor UBsan will complain about unsigned wrapping for cases such as
std::lcm(500000u, 499999u). We can detect those overflows efficiently by
using __builtin_mul_overflow and asserting.

libstdc++-v3/ChangeLog:

	PR libstdc++/105844
	* include/experimental/numeric (experimental::gcd): Simplify
	assertions. Use __abs_r instead of __absu.
	(experimental::lcm): Likewise. Remove use of __detail::__lcm so
	overflow can be detected.
	* include/std/numeric (__detail::__absu): Rename to __abs_r and
	change to allow signed result type, so overflow can be detected.
	(__detail::__lcm): Remove.
	(gcd): Simplify assertions. Use __abs_r instead of __absu.
	(lcm): Likewise. Remove use of __detail::__lcm so overflow can
	be detected.
	* testsuite/26_numerics/gcd/gcd_neg.cc: Adjust dg-error lines.
	* testsuite/26_numerics/lcm/lcm_neg.cc: Likewise.
	* testsuite/26_numerics/gcd/105844.cc: New test.
	* testsuite/26_numerics/lcm/105844.cc: New test.
2022-06-10 15:24:29 +01:00
Jonathan Wakely
1e65f2ed99 libstdc++: Fix lifetime bugs for non-TLS eh_globals [PR105880]
This ensures that the single-threaded fallback buffer eh_globals is not
destroyed during program termination, using the same immortalization
technique used for error category objects.

Also ensure that init._M_init can still be read after init has been
destroyed, by making it a static data member.

libstdc++-v3/ChangeLog:

	PR libstdc++/105880
	* libsupc++/eh_globals.cc (eh_globals): Ensure constant init and
	prevent destruction during termination.
	(__eh_globals_init::_M_init): Replace with static member _S_init.
	(__cxxabiv1::__cxa_get_globals_fast): Update.
	(__cxxabiv1::__cxa_get_globals): Likewise.
2022-06-10 15:24:29 +01:00
Jonathan Wakely
b370ed0bf9 libstdc++: Make std::hash<basic_string<>> allocator-agnostic (LWG 3705)
This new library issue was recently moved to Tentatively Ready by an LWG
poll, so I'm making the change on trunk.

As noted in PR libstc++/105907 the std::hash specializations for PMR
strings were not treated as slow hashes by the unordered containers, so
this change preserves that. The new specializations for custom
allocators are also not treated as slow, for the same reason. For the
versioned namespace (i.e. unstable ABI) we don't have to worry about
that, so can enable hash code caching for all basic_string
specializations.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.h (__hash_str_base): New class
	template.
	(hash<basic_string<C, char_traits<C>, A>>): Define partial
	specialization for each of the standard character types.
	(hash<string>, hash<wstring>, hash<u8string>, hash<u16string>)
	(hash<u32string>): Remove explicit specializations.
	* include/std/string (__hash_string_base): Remove class
	template.
	(hash<pmr::string>, hash<pmr::wstring>, hash<pmr::u8string>)
	(hash<pmr::u16string>, hash<pmr::u32string>): Remove explicit
	specializations.
	* testsuite/21_strings/basic_string/hash/hash.cc: Test with
	custom allocators.
	* testsuite/21_strings/basic_string/hash/hash_char8_t.cc:
	Likewise.
2022-06-10 14:39:25 +01:00
GCC Administrator
d9176e643f Daily bump. 2022-05-28 00:16:40 +00:00
Jonathan Wakely
de57440858 libstdc++: Mark non-exported function always_inline [PR105671]
This new function was added for gcc 11.1 but is not exported from the
shared library. Depending on inlining decisions, its callers might get
inlined but an external definition be needed for this function. That
then fails to link.

Since we can't add the export to the gcc-11 release branch now, mark it
always_inline. We can consider exporting it for gcc-13 if/when we bump
the shared library version (and maybe also for gcc-12 which is currently
at the same version as trunk). For now, the attribute will solve the
problem on all affected branches. The function is small enough that
force-inlining it shouldn't cause problems.

libstdc++-v3/ChangeLog:

	PR libstdc++/105671
	* include/std/sstream (basic_stringbuf::_M_high_mark): Add
	always_inline attribute.
2022-05-27 15:21:07 +01:00
GCC Administrator
b2cb88fb45 Daily bump. 2022-05-27 00:16:19 +00:00
Jonathan Wakely
367740bf6d libstdc++: Fix narrowing conversions for 16-bit size_t [PR105681]
On a 16-bit target such as msp430 we get errors about narrowing long
values to size_t, which is only 16-bit. When --enable-libstdcxx-pch is
used the <bits/extc++.h> header breaks the build because of these
narrowing errors.

libstdc++-v3/ChangeLog:

	PR libstdc++/105681
	* include/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp:
	Limit ga_sizes array to values that fit in size_t.
	* include/ext/random [__SIZE_WIDTH < 32] (sfmt86243)
	(sfmt86243_64, sfmt132049, sfmt132049_64, sfmt216091)
	(sfmt216091_64): Do not declare.
2022-05-26 22:29:05 +01:00
Jonathan Wakely
11e1ee1b38 libstdc++: Fix atomic and error_code printers for versioned namespace
This fixes the printers to work with std::__8::atomic and
std::__v8::ios_errc and std::__v8::future_errc.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdErrorCodePrinter): Make
	lookup for ios_errc and future_errc check versioned namespace.
	(StdAtomicPrinter): Strip versioned namespace from typename.
2022-05-26 22:29:04 +01:00
Jonathan Wakely
ae3ea143ef libstdc++: Move std::iostream_category() definition to new file
This fixes a missing symbol when the dual ABI is disabled, e.g. for the
versioned namespace build.

libstdc++-v3/ChangeLog:

	* src/c++11/Makefile.am: Add new source file.
	* src/c++11/Makefile.in: Regenerate.
	* src/c++11/cxx11-ios_failure.cc (iostream_category):
	Move to ...
	* src/c++11/ios_errcat.cc: New file.
	* testsuite/27_io/ios_base/failure/error_code.cc: Check that
	std::iostream_category() is defined and used for std::io_errc.
2022-05-26 22:28:57 +01:00
Jonathan Wakely
47b20d027a libstdc++: Add constexpr to std::counted_iterator post-increment (LWG 3643)
libstdc++-v3/ChangeLog:

	* include/bits/stl_iterator.h (counted_iterator::operator++(int)):
	Add 'constexpr' as per LWG 3643.
	* testsuite/24_iterators/counted_iterator/lwg3643.cc: New test.
2022-05-26 17:14:40 +01:00
Jonathan Wakely
692643c3ed libstdc++: Refactor includes for unordered containers
This moves some #include directives to the relevant place. For example,
<bits/hashtable_policy.h> needs <bits/stl_pair.h> so should include it
directly instead of relying on <unordered_map> and <unordered_set> to do
so first.

libstdc++-v3/ChangeLog:

	* include/bits/functional_hash.h (__is_fast_hash): Add doxygen
	comment.
	* include/bits/hashtable.h: Do not include <bits/stl_function.h>
	here.
	* include/bits/hashtable_policy.h: Include <bits/stl_pair.h> and
	<bits/functional_hash.h>.
	* include/bits/unordered_map.h: Include required headers.
	* include/bits/unordered_set.h: Likewise.
	* include/std/unordered_map: Do not include headers for indirect
	dependencies.
	* include/std/unordered_set: Likewise.
2022-05-26 10:44:45 +01:00
Jonathan Wakely
650eadd630 libstdc++: Remove some unnecessary includes
These headers do not use anything in <bits/stl_iterator_base_types.h>
directly, and it's included by <bits/stl_iterator_base_funcs.h> and
<bits/stl_iterator.h> anyway, because they do need it.

libstdc++-v3/ChangeLog:

	* include/bits/ranges_algobase.h: Do not include
	<bits/stl_iterator_base_types.h>.
	* include/std/string: Likewise.
	* include/std/variant: Likewise.
2022-05-26 10:44:45 +01:00
Nathan Sidwell
a44380541f libstdc++: Make headers include their prerequisites
These headers were relying on their includers having already included
some prerequisites.  That makes them unsuitable to be header-units.

So directly include the needed headers.

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

libstdc++-v3/ChangeLog:

	* include/bits/hashtable.h: Include required headers.
	* include/bits/hashtable_policy.h: Likewise.
	* include/bits/stl_heap.h: Likewise.
	* include/bits/stl_iterator_base_funcs.h: Likewise.
2022-05-26 10:44:45 +01:00
François Dumont
ace4b7f295 libstdc++: Fix printing of std::span for versioned namespace
libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdSpanPrinter.__init__):
	Strip typename from version namespace.
2022-05-26 11:38:34 +02:00
Jonathan Wakely
634b0089f6 libstdc++: Fix printing of std::atomic<shared_ptr<T>> for versioned namespace
libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (SharedPointerPrinter): Strip
	versioned namespace from the template argument too.
2022-05-26 10:05:51 +01:00
Jonathan Wakely
6eb60ced21 libstdc++: Rename tests like .../wchar_t/1.cc to .../wchar_t.cc
There's no need to have directories containing a single test file, we
can rename the files to the directory names and remove the directories.

The dejagnu proc that filters out wchar_t tests just checks for
"wchar_t" anywhere in the path, so will work just as well on wchar_t.cc
or constexpr-wchar_t.cc paths.

libstdc++-v3/ChangeLog:

	* testsuite/21_strings/basic_string/modifiers/pop_back/char/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string/modifiers/pop_back/char.cc:
	...here.
	* testsuite/21_strings/basic_string/modifiers/pop_back/wchar_t/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string/modifiers/pop_back/wchar_t.cc:
	...here.
	* testsuite/21_strings/basic_string/modifiers/swap/wchar_t/constexpr.cc:
	Moved to...
	* testsuite/21_strings/basic_string/modifiers/swap/constexpr-wchar_t.cc:
	...here.
	* testsuite/21_strings/basic_string/modifiers/swap/char/constexpr.cc:
	Moved to...
	* testsuite/21_strings/basic_string/modifiers/swap/constexpr.cc:
	...here.
	* testsuite/21_strings/basic_string/operations/contains/char/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string/operations/contains/char.cc:
	...here.
	* testsuite/21_strings/basic_string/operations/contains/wchar_t/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string/operations/contains/wchar_t.cc:
	...here.
	* testsuite/21_strings/basic_string/operations/data/char/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string/operations/data/char.cc:
	...here.
	* testsuite/21_strings/basic_string/operations/data/wchar_t/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string/operations/data/wchar_t.cc:
	...here.
	* testsuite/21_strings/basic_string/operations/ends_with/char/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string/operations/ends_with/char.cc:
	...here.
	* testsuite/21_strings/basic_string/operations/ends_with/wchar_t/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string/operations/ends_with/wchar_t.cc:
	...here.
	* testsuite/21_strings/basic_string/operations/starts_with/char/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string/operations/starts_with/char.cc:
	...here.
	* testsuite/21_strings/basic_string/operations/starts_with/wchar_t/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string/operations/starts_with/wchar_t.cc:
	...here.
	* testsuite/21_strings/basic_string/operations/substr/char/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string/operations/substr/char.cc:
	...here.
	* testsuite/21_strings/basic_string/operations/substr/wchar_t/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string/operations/substr/wchar_t.cc:
	...here.
	* testsuite/21_strings/basic_string/range_access/char/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string/range_access/char.cc:
	...here.
	* testsuite/21_strings/basic_string/range_access/wchar_t/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string/range_access/wchar_t.cc:
	...here.
	* testsuite/21_strings/basic_string_view/modifiers/remove_prefix/char/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string_view/modifiers/remove_prefix/char.cc:
	...here.
	* testsuite/21_strings/basic_string_view/modifiers/remove_prefix/wchar_t/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string_view/modifiers/remove_prefix/wchar_t.cc:
	...here.
	* testsuite/21_strings/basic_string_view/modifiers/remove_suffix/char/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string_view/modifiers/remove_suffix/char.cc:
	...here.
	* testsuite/21_strings/basic_string_view/modifiers/remove_suffix/wchar_t/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string_view/modifiers/remove_suffix/wchar_t.cc:
	...here.
	* testsuite/21_strings/basic_string_view/modifiers/swap/char/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string_view/modifiers/swap/char.cc:
	...here.
	* testsuite/21_strings/basic_string_view/modifiers/swap/wchar_t/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string_view/modifiers/swap/wchar_t.cc:
	...here.
	* testsuite/21_strings/basic_string_view/operations/contains/char/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string_view/operations/contains/char.cc:
	...here.
	* testsuite/21_strings/basic_string_view/operations/contains/wchar_t/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string_view/operations/contains/wchar_t.cc:
	...here.
	* testsuite/21_strings/basic_string_view/operations/data/char/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string_view/operations/data/char.cc:
	...here.
	* testsuite/21_strings/basic_string_view/operations/data/wchar_t/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string_view/operations/data/wchar_t.cc:
	...here.
	* testsuite/21_strings/basic_string_view/operations/ends_with/char/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string_view/operations/ends_with/char.cc:
	...here.
	* testsuite/21_strings/basic_string_view/operations/ends_with/wchar_t/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string_view/operations/ends_with/wchar_t.cc:
	...here.
	* testsuite/21_strings/basic_string_view/operations/starts_with/char/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string_view/operations/starts_with/char.cc:
	...here.
	* testsuite/21_strings/basic_string_view/operations/starts_with/wchar_t/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string_view/operations/starts_with/wchar_t.cc:
	...here.
	* testsuite/21_strings/basic_string_view/operations/substr/char/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string_view/operations/substr/char.cc:
	...here.
	* testsuite/21_strings/basic_string_view/operations/substr/wchar_t/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string_view/operations/substr/wchar_t.cc:
	...here.
	* testsuite/21_strings/basic_string_view/range_access/char/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string_view/range_access/char.cc:
	...here.
	* testsuite/21_strings/basic_string_view/range_access/wchar_t/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string_view/range_access/wchar_t.cc:
	...here.
	* testsuite/21_strings/basic_string/requirements/explicit_instantiation/char/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string/requirements/explicit_instantiation/char.cc:
	...here.
	* testsuite/21_strings/basic_string/requirements/explicit_instantiation/char16_t/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string/requirements/explicit_instantiation/char16_t.cc:
	...here.
	* testsuite/21_strings/basic_string/requirements/explicit_instantiation/char32_t/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string/requirements/explicit_instantiation/char32_t.cc:
	...here.
	* testsuite/21_strings/basic_string/requirements/explicit_instantiation/char8_t/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string/requirements/explicit_instantiation/char8_t.cc:
	...here.
	* testsuite/21_strings/basic_string/requirements/explicit_instantiation/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string/requirements/explicit_instantiation/int.cc:
	...here.
	* testsuite/21_strings/basic_string/requirements/explicit_instantiation/wchar_t/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string/requirements/explicit_instantiation/wchar_t.cc:
	...here.
	* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char.cc:
	...here.
	* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char16_t/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char16_t.cc:
	...here.
	* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char32_t/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char32_t.cc:
	...here.
	* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char8_t/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/char8_t.cc:
	...here.
	* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/int.cc:
	...here.
	* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/wchar_t/1.cc:
	Moved to...
	* testsuite/21_strings/basic_string_view/requirements/explicit_instantiation/wchar_t.cc:
	...here.
	* testsuite/21_strings/char_traits/requirements/explicit_instantiation/char/1.cc:
	Moved to...
	* testsuite/21_strings/char_traits/requirements/explicit_instantiation/char.cc:
	...here.
	* testsuite/21_strings/char_traits/requirements/explicit_instantiation/char16_t/1.cc:
	Moved to...
	* testsuite/21_strings/char_traits/requirements/explicit_instantiation/char16_t.cc:
	...here.
	* testsuite/21_strings/char_traits/requirements/explicit_instantiation/char32_t/1.cc:
	Moved to...
	* testsuite/21_strings/char_traits/requirements/explicit_instantiation/char32_t.cc:
	...here.
	* testsuite/21_strings/char_traits/requirements/explicit_instantiation/char8_t/1.cc:
	Moved to...
	* testsuite/21_strings/char_traits/requirements/explicit_instantiation/char8_t.cc:
	...here.
	* testsuite/21_strings/char_traits/requirements/explicit_instantiation/short/1.cc:
	Moved to...
	* testsuite/21_strings/char_traits/requirements/explicit_instantiation/short.cc:
	...here.
	* testsuite/21_strings/char_traits/requirements/explicit_instantiation/wchar_t/1.cc:
	Moved to...
	* testsuite/21_strings/char_traits/requirements/explicit_instantiation/wchar_t.cc:
	...here.
2022-05-26 10:05:51 +01:00
Jonathan Wakely
f638f2b4b2 libstdc++: Remove redundancy in test pathnames
Repeating "explicit_instantiation" in these long pathnames is not
necessary.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/duration/requirements/explicit_instantiation/explicit_instantiation.cc:
	Moved to...
	* testsuite/20_util/duration/requirements/explicit_instantiation.cc: ...here.
	* testsuite/20_util/time_point/requirements/explicit_instantiation/explicit_instantiation.cc:
	Moved to...
	* testsuite/20_util/time_point/requirements/explicit_instantiation.cc: ...here.
	* testsuite/20_util/unique_ptr/requirements/explicit_instantiation/explicit_instantiation.cc:
	Moved to...
	* testsuite/20_util/unique_ptr/requirements/explicit_instantiation.cc: ...here.
2022-05-26 10:05:16 +01:00
GCC Administrator
3dff965cae Daily bump. 2022-05-26 00:16:30 +00:00
Jason Merrill
6209009df6 c++: strict constexpr and local vars
A change I was working on made constexpr_searcher.cc start to fail, and when
I looked at it I wondered why it had been accepted before.  This turned out
to be because we try to be more flexible about constant-evaluation of static
initializers, as allowed, but we were wrongly doing the same for non-static
initializers as well.

gcc/cp/ChangeLog:

	* constexpr.cc (maybe_constant_init_1): Only pass false for
	strict when initializing a variable of static duration.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/function_objects/constexpr_searcher.cc: Add
	constexpr.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp1y/constexpr-local4.C: New test.
2022-05-25 11:06:36 -04:00
GCC Administrator
57f2ce6a87 Daily bump. 2022-05-21 00:16:32 +00:00
Jonathan Wakely
e3b8b4f781 libstdc++: Reduce <random> test iterations for simulators
Some of these tests take several minutes on a simulator like cris-elf,
so we can conditionally run fewer iterations. The testDiscreteDist
helper already supports custom sizes so we just need to make use of that
when { target simulator } matches.

The relevant code is sufficiently tested on other targets, so we're not
losing anything by only running a small number of iterators for sims.

libstdc++-v3/ChangeLog:

	* testsuite/26_numerics/random/bernoulli_distribution/operators/values.cc:
	Run fewer iterations for simulator targets.
	* testsuite/26_numerics/random/binomial_distribution/operators/values.cc:
	Likewise.
	* testsuite/26_numerics/random/discrete_distribution/operators/values.cc:
	Likewise.
	* testsuite/26_numerics/random/geometric_distribution/operators/values.cc:
	Likewise.
	* testsuite/26_numerics/random/negative_binomial_distribution/operators/values.cc:
	Likewise.
	* testsuite/26_numerics/random/poisson_distribution/operators/values.cc:
	Likewise.
	* testsuite/26_numerics/random/uniform_int_distribution/operators/values.cc:
	Likewise.
2022-05-20 15:47:49 +01:00
GCC Administrator
12750f80bf Daily bump. 2022-05-20 00:16:32 +00:00
Jonathan Wakely
6f038efd93 libstdc++: Avoid including <cstdint> for std::char_traits
We should prefer the __UINT_LEAST16_TYPE__ and __UINT_LEAST32_TYPE__
macros, if available, so that we don't need all of <cstdint> in every
header that uses std::char_traits.

libstdc++-v3/ChangeLog:

	* include/bits/char_traits.h: Only include <cstdint> when
	necessary.
	* include/std/stacktrace: Use __UINTPTR_TYPE__ instead of
	uintptr_t.
	* src/c++11/cow-stdexcept.cc: Include <stdint.h>.
	* src/c++17/floating_to_chars.cc: Likewise.
	* testsuite/20_util/assume_aligned/1.cc: Include <cstdint>.
	* testsuite/20_util/assume_aligned/3.cc: Likewise.
	* testsuite/20_util/shared_ptr/creation/array.cc: Likewise.
2022-05-19 23:39:21 +01:00
Jonathan Wakely
f3e22baec0 libstdc++: Only include <ext/atomicity.h> for COW string
Since the COW std::string was moved to its own header, we don't need the
atomic dispatch helpers in the definition of std::__cxx11::string. Move
the inclusion of the <ext/atomicity.h> header to <bits/cow_string.h>
where it's needed.

libstdc++-v3/ChangeLog:

	* include/bits/basic_string.h: Do not include <ext/atomicity.h>
	here.
	* include/bits/cow_string.h: Include it here.
2022-05-19 23:39:20 +01:00
Jonathan Wakely
8ccdc7ce33 libstdc++: Ensure pmr aliases work without <memory_resource>
Currently the alias templates for std::pmr::vector, std::pmr::string
etc. are defined using a forward declaration for polymorphic_allocator.
This means you can't actually use the alias templates unless you also
include <memory_resource>. The rationale for that is that it's a fairly
large header, and most users don't need it. This isn't uncontroversial
though, and LWG 3681 questions whether it's even conforming.

This change adds a new <bits/memory_resource.h> header with the minimum
needed to use polymorphic_allocator and the std::pmr container aliases.
Including <memory_resource> is still necessary to use the program-wide
resource objects, or the pool resources or monotonic buffer resource.

libstdc++-v3/ChangeLog:

	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/bits/memory_resource.h: New file.
	* include/std/deque: Include <bits/memory_resource.h>.
	* include/std/forward_list: Likewise.
	* include/std/list: Likewise.
	* include/std/map: Likewise.
	* include/std/memory_resource (pmr::memory_resource): Move to
	new <bits/memory_resource.h> header.
	(pmr::polymorphic_allocator): Likewise.
	* include/std/regex: Likewise.
	* include/std/set: Likewise.
	* include/std/stacktrace: Likewise.
	* include/std/string: Likewise.
	* include/std/unordered_map: Likewise.
	* include/std/unordered_set: Likewise.
	* include/std/vector: Likewise.
	* testsuite/21_strings/basic_string/types/pmr_typedefs.cc:
	Remove <memory_resource> header and check construction.
	* testsuite/23_containers/deque/types/pmr_typedefs.cc: Likewise.
	* testsuite/23_containers/forward_list/pmr_typedefs.cc:
	Likewise.
	* testsuite/23_containers/list/pmr_typedefs.cc: Likewise.
	* testsuite/23_containers/map/pmr_typedefs.cc: Likewise.
	* testsuite/23_containers/multimap/pmr_typedefs.cc: Likewise.
	* testsuite/23_containers/multiset/pmr_typedefs.cc: Likewise.
	* testsuite/23_containers/set/pmr_typedefs.cc: Likewise.
	* testsuite/23_containers/unordered_map/pmr_typedefs.cc:
	Likewise.
	* testsuite/23_containers/unordered_multimap/pmr_typedefs.cc:
	Likewise.
	* testsuite/23_containers/unordered_multiset/pmr_typedefs.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/pmr_typedefs.cc:
	Likewise.
	* testsuite/23_containers/vector/pmr_typedefs.cc: Likewise.
	* testsuite/28_regex/match_results/pmr_typedefs.cc: Likewise.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/variadic-tuple.C: Qualify function to avoid ADL
	finding std::make_tuple.
2022-05-19 23:38:23 +01:00
Jonathan Wakely
f13f9c99db libstdc++: Implement LWG 3683 for pmr::polymorphic_allocator
This issue has recently been moved to Tentatively Ready, and seems
uncontroversial. This allows equality comparison with types that are
convertible to pmr::polymorphic_allocator, which fail deduction for the
existing equality operator.

libstdc++-v3/ChangeLog:

	* include/std/memory_resource (polymorphic_allocator): Add
	non-template equality operator, as proposed for LWG 3683.
	* testsuite/20_util/polymorphic_allocator/lwg3683.cc: New test.
2022-05-19 15:30:56 +01:00
GCC Administrator
3d9439b1bb Daily bump. 2022-05-18 00:16:36 +00:00
Jonathan Wakely
ddb1427def libstdc++: Relax memory ordering for default memory resource object
Currently pmr::set_default_resource and pmr::get_default_resource both
use sequentially consistent memory ordering. This is overkill. The
standard only requires that a call to set_default_resource synchronizes
with subsequent calls to set_default_resource and get_default_resource.

Using acquire-release for the setter and acquire for the getter is
sufficient to meet the requirement.

Reviewed-by: Thomas Rodgers  <trodgers@redhat.com>

libstdc++-v3/ChangeLog:

	* src/c++17/memory_resource.cc (set_default_resource): Use
	memory_order_acq_rel.
	(get_default_resource): Use memory_order_acquire.
2022-05-17 20:53:40 +01:00
Jonathan Wakely
5c2d703e6d libstdc++: Add attributes to functions in <memory_resource>
Add attributes to the accessors for the global memory resource objects,
to allow the compiler to eliminate redundant calls to them. For example,
multiple calls to std::pmr::new_delete_resource() will always return the
same object, and so the compiler can replace them with a single call.

Ideally we would like adjacent calls to std::pmr::get_default_resource()
to be combined into a single call by the CSE pass. The 'pure' attribute
would permit that. However, the standard requires that calls to
std::pmr::set_default_resource() synchronize with subsequent calls to
std::pmr::get_default_resource().  With 'pure' the DCE pass might
eliminate seemingly redundant calls to std::pmr::get_default_resource().
That might be unsafe, because the caller might be relying on the
associated synchronization. We could use a hypothetical attribute that
allows CSE but not DCE, but we don't have one. So it can't be 'pure'.

Also add [[nodiscard]] to equality operators.

libstdc++-v3/ChangeLog:

	* include/std/memory_resource (new_delete_resource): Add
	nodiscard, returns_nonnull and const attributes.
	(null_memory_resource): Likewise.
	(set_default_resource, get_default_resource): Add returns_nonnull
	attribute.
	(memory_resource::is_equal): Add nodiscard attribute.
	(operator==, operator!=): Likewise.
2022-05-17 20:51:04 +01:00
Jonathan Wakely
5f1ce85135 libstdc++: Add attributes to <system_error> and related
Add the const attribute to std::future_category() and
std::iostream_category(), to match the existing attributes on
std::generic_category() and std::system_category().

Also add [[nodiscard]] to those functions and to the comparison
operators for std::error_code and std::error_condition, and to
std::make_error_code and std::make_error_condition overloads.

libstdc++-v3/ChangeLog:

	* include/bits/ios_base.h (io_category): Add const and nodiscard
	attributes.
	(make_error_code, make_error_condition): Add nodiscard.
	* include/std/future (future_category): Add const and nodiscard.
	(make_error_code, make_error_condition): Add nodiscard.
	* include/std/system_error (generic_category system_category):
	Add nodiscard. Replace _GLIBCXX_CONST with C++11 attribute.
	(error_code::value, error_code::category, error_code::operator bool)
	(error_condition::value, error_condition::category)
	(error_condition::operator bool, make_error_code)
	(make_error_condition, operator==, operator!=, operator<=>): Add
	nodiscard.
2022-05-17 20:50:31 +01:00
Jonathan Wakely
1815462a6e libstdc++: Skip tests that fail for the versioned namespace
Most tests for the contents of header synopses need to be supressed for
the versioned namespace build, because redeclaring the entities in std
fails when they were originally declared in std::__8.

I added these tests recently without the suppression, so they fail.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/expected/synopsis.cc: Skip for versioned
	namespace.
	* testsuite/27_io/headers/iosfwd/synopsis.cc: Likewise.
2022-05-17 11:42:34 +01:00
Jonathan Wakely
357d6fcd41 libstdc++: Stop defining C++0x compat symbols for versioned namespace
The src/c++11/compatibility*-c++0x.cc files define symbols that need to
be exported for ancient versions of libstdc++.so.6 due to changes
between C++0x and the final C++11 standard. Those symbols are not needed
in the libstdc++.so.8 library, and we can skip building them entirely.

This also fixes the build failure I introduced last week when making the
versioned namespace config not use the _V2 namespace for compat symbols.

libstdc++-v3/ChangeLog:

	* src/Makefile.am [ENABLE_SYMVERS_GNU_NAMESPACE] (cxx11_sources):
	Do not build the compatibility*-c++0x.cc objects.
	* src/Makefile.in: Regenerate.
	* src/c++11/compatibility-c++0x.cc [_GLIBCXX_INLINE_VERSION]:
	Refuse to build for the versioned namespace.
	* src/c++11/compatibility-chrono.cc: Likewise.
	* src/c++11/compatibility-condvar.cc: Likewise.
	* src/c++11/compatibility-thread-c++0x.cc: Likewise.
	* src/c++11/chrono.cc (system_clock, steady_clock):
	Use macros to define in inline namespace _V2, matching the
	declarations in <system_error>.
	* src/c++11/system_error.cc (system_category, generic_category):
	Likewise.
2022-05-17 11:42:34 +01:00
GCC Administrator
702bd11fa7 Daily bump. 2022-05-17 00:16:28 +00:00
Jonathan Wakely
682e587f10 libstdc++: Fix hyperlink in docs
libstdc++-v3/ChangeLog:

	* doc/xml/manual/prerequisites.xml: Fix attributes for external
	hyperlink.
	* doc/html/manual/setup.html: Regenerate.
2022-05-16 14:54:07 +01:00