Commit graph

13643 commits

Author SHA1 Message Date
GCC Administrator
1f16a020ac Daily bump. 2022-09-28 00:17:27 +00:00
Jonathan Wakely
3f7eea4411 c++: Make __is_{,nothrow_}convertible SFINAE on access [PR107049]
The is_convertible built-ins should return false if the conversion fails
an access check, not report an error.

	PR c++/107049

gcc/cp/ChangeLog:

	* method.cc (is_convertible_helper): Use access check sentinel.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/is_convertible4.C: New test.
	* g++.dg/ext/is_nothrow_convertible4.C: New test.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/is_convertible/requirements/access.cc: New
	test.
2022-09-27 11:59:53 +01:00
Jonathan Wakely
614e5696d7 libstdc++: Adjust deduction guides for static operator() [PR106651]
Adjust the deduction guides for std::function and std::packaged_task to
work with static call operators. This finishes the implementation of
P1169R4 for C++23.

libstdc++-v3/ChangeLog:

	PR c++/106651
	* include/bits/std_function.h (__function_guide_t): New alias
	template.
	[__cpp_static_call_operator] (__function_guide_static_helper):
	New class template.
	(function): Use __function_guide_t in deduction guide.
	* include/std/future (packaged_task): Use __function_guide_t in
	deduction guide.
	* testsuite/20_util/function/cons/deduction_c++23.cc: New test.
	* testsuite/30_threads/packaged_task/cons/deduction_c++23.cc:
	New test.
2022-09-27 11:59:53 +01:00
GCC Administrator
220c4d8e44 Daily bump. 2022-09-27 00:17:52 +00:00
Jonathan Wakely
03cb9ed8dd libstdc++: Update std::pointer_traits to match new LWG 3545 wording
It was pointed out in recent LWG 3545 discussion that having a
constrained partial specialization of std::pointer_traits can cause
ambiguities with program-defined specializations. For example, the
addition to the testcase has:

template<typename P> requires std::derived_from<P, base_type
struct std::pointer_traits<P>;

This would be ambiguous with the library's own constrained partial
specialization:

template<typename Ptr> requires requires { typename Ptr::element_type; }
struct std::pointer_traits<Ptr>;

Neither specialization is more specialized than the other for a type
that is derived from base_type and also has an element_type member.

The solution is to remove the library's partial specialization, and do
the check for Ptr::element_type in the __ptr_traits_elem helper (which
is what we already do for !__cpp_concepts anyway).

libstdc++-v3/ChangeLog:

	* include/bits/ptr_traits.h (__ptr_traits_elem) [__cpp_concepts]:
	Also define the __ptr_traits_elem class template for the
	concepts case.
	(pointer_traits<Ptr>): Remove constrained partial
	specialization.
	* testsuite/20_util/pointer_traits/lwg3545.cc: Check for
	ambiguitiy with program-defined partial specialization.
2022-09-26 23:47:37 +01:00
Jonathan Wakely
af85ad8917 libstdc++: Use new built-ins for std::is_convertible traits
libstdc++-v3/ChangeLog:

	* include/std/type_traits (is_convertible, is_convertible_v):
	Define using new built-in.
	(is_nothrow_convertible is_nothrow_convertible_v): Likewise.
2022-09-26 23:47:37 +01:00
Jonathan Wakely
6904ed80a2 libstdc++: Add #if around non-C++03 code in std::bitset [PR107037]
libstdc++-v3/ChangeLog:

	PR libstdc++/107037
	* include/std/bitset (_Base_bitset::_M_do_reset): Use
	preprocessor conditional around non-C++03 code.
	* testsuite/20_util/bitset/107037.cc: New test.
2022-09-26 12:00:07 +01:00
GCC Administrator
28a61ecdc1 Daily bump. 2022-09-25 00:18:01 +00:00
Jonathan Wakely
2b667beba6 libstdc++: Simplify detection idiom using concepts
Add a simpler definition of std::__detected_or using concepts.  This
also replaces the __detector::value_t member which should have been using
a reserved name.

Use __detected_or in pointer_traits.

libstdc++-v3/ChangeLog:

	* include/bits/alloc_traits.h (allocator_traits::is_always_equal):
	Only instantiate is_empty if needed.
	* include/bits/ptr_traits.h (__ptr_traits_impl::difference_type)
	(__ptr_traits_impl::rebind): Use __detected_or.
	* include/experimental/type_traits (is_same_v): Add a partial
	specialization instead of instantiating the std::is_same class
	template.
	(detected_t): Redefine in terms of detected_or_t.
	(is_detected, is_detected_v): Redefine in terms of detected_t.
	* include/std/type_traits [__cpp_concepts] (__detected_or): Add
	new definition using concepts.
	(__detector::value_t): Rename to __is_detected.
	* testsuite/17_intro/names.cc: Check value_t isn't used.
2022-09-24 15:18:11 +01:00
GCC Administrator
4afaeaab52 Daily bump. 2022-09-24 00:16:37 +00:00
Jonathan Wakely
5924c7d584 libstdc++: Add test for type traits not having friend access
This ensures that the std::is_assignable and std::is_assignable_v
traits are evaluated "in a context unrelated" to the argument types.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/is_assignable/requirements/access.cc:
	New test.
2022-09-23 23:22:37 +01:00
Jonathan Wakely
71c828f845 libstdc++: Fix std::is_nothrow_invocable_r for uncopyable prvalues [PR91456]
This is the last missing piece of PR 91456.

This also removes the only use of the C++11 version of
std::is_nothrow_invocable, which was just renamed to
__is_nothrow_invocable_lib. We can remove that now.

libstdc++-v3/ChangeLog:

	PR libstdc++/91456
	* include/std/type_traits (__is_nothrow_invocable_lib): Remove.
	(__is_invocable_impl::__nothrow_type): New member type which
	checks if the conversion can throw.
	(__is_nt_invocable_impl): Replace class template with alias
	template to __is_nt_invocable_impl::__nothrow_type.
	* testsuite/20_util/is_nothrow_invocable/91456.cc: New test.
	* testsuite/20_util/is_nothrow_convertible/value.cc: Remove
	macro used by value_ext.cc test.
	* testsuite/20_util/is_nothrow_convertible/value_ext.cc: Remove
	test for non-standard __is_nothrow_invocable_lib trait.
2022-09-23 23:22:37 +01:00
Marek Polacek
8a7bcf95a8 c++: Implement __is_{nothrow_,}convertible [PR106784]
To improve compile times, the C++ library could use compiler built-ins
rather than implementing std::is_convertible (and _nothrow) as class
templates.  This patch adds the built-ins.  We already have
__is_constructible and __is_assignable, and the nothrow forms of those.

Microsoft (and clang, for compatibility) also provide an alias called
__is_convertible_to.  I did not add it, but it would be trivial to do
so.

I noticed that our __is_assignable doesn't implement the "Access checks
are performed as if from a context unrelated to either type" requirement,
therefore std::is_assignable / __is_assignable give two different results
here:

  class S {
    operator int();
    friend void g(); // #1
  };

  void
  g ()
  {
    // #1 doesn't matter
    static_assert(std::is_assignable<int&, S>::value, "");
    static_assert(__is_assignable(int&, S), "");
  }

This is not a problem if __is_assignable is not meant to be used by
the users.

This patch doesn't make libstdc++ use the new built-ins, but I had to
rename a class otherwise its name would clash with the new built-in.

	PR c++/106784

gcc/c-family/ChangeLog:

	* c-common.cc (c_common_reswords): Add __is_convertible and
	__is_nothrow_convertible.
	* c-common.h (enum rid): Add RID_IS_CONVERTIBLE and
	RID_IS_NOTHROW_CONVERTIBLE.

gcc/cp/ChangeLog:

	* constraint.cc (diagnose_trait_expr): Handle CPTK_IS_CONVERTIBLE
	and CPTK_IS_NOTHROW_CONVERTIBLE.
	* cp-objcp-common.cc (names_builtin_p): Handle RID_IS_CONVERTIBLE
	RID_IS_NOTHROW_CONVERTIBLE.
	* cp-tree.h (enum cp_trait_kind): Add CPTK_IS_CONVERTIBLE and
	CPTK_IS_NOTHROW_CONVERTIBLE.
	(is_convertible): Declare.
	(is_nothrow_convertible): Likewise.
	* cxx-pretty-print.cc (pp_cxx_trait_expression): Handle
	CPTK_IS_CONVERTIBLE and CPTK_IS_NOTHROW_CONVERTIBLE.
	* method.cc (is_convertible): New.
	(is_nothrow_convertible): Likewise.
	* parser.cc (cp_parser_primary_expression): Handle RID_IS_CONVERTIBLE
	and RID_IS_NOTHROW_CONVERTIBLE.
	(cp_parser_trait_expr): Likewise.
	* semantics.cc (trait_expr_value): Handle CPTK_IS_CONVERTIBLE and
	CPTK_IS_NOTHROW_CONVERTIBLE.
	(finish_trait_expr): Likewise.

libstdc++-v3/ChangeLog:

	* include/std/type_traits: Rename __is_nothrow_convertible to
	__is_nothrow_convertible_lib.
	* testsuite/20_util/is_nothrow_convertible/value_ext.cc: Likewise.

gcc/testsuite/ChangeLog:

	* g++.dg/ext/has-builtin-1.C: Enhance to test __is_convertible and
	__is_nothrow_convertible.
	* g++.dg/ext/is_convertible1.C: New test.
	* g++.dg/ext/is_convertible2.C: New test.
	* g++.dg/ext/is_nothrow_convertible1.C: New test.
	* g++.dg/ext/is_nothrow_convertible2.C: New test.
2022-09-23 12:12:41 -04:00
Jonathan Wakely
ab98b4c072 libstdc++: Micro-optimizaion for std::bitset stream extraction
Don't bother trying to copy any characters for bitset<0>.

libstdc++-v3/ChangeLog:

	* include/std/bitset (operator>>): Do not copy for N==0.
	* testsuite/20_util/bitset/io/input.cc: Add comment.
2022-09-23 15:10:51 +01:00
Jonathan Wakely
4ceb5bc42d libstdc++: Enable constexpr std::bitset for debug mode
We already disable all debug mode checks for C++11 and later, so we can
easily make everything constexpr. This fixes the FAIL results for the
new tests when using -D_GLIBCXX_DEBUG.

Also fix some other tests failing with non-default test flags.

libstdc++-v3/ChangeLog:

	* include/debug/bitset (__debug::bitset): Add constexpr to all
	member functions.
	(operator&, operator|, operator^): Add inline and constexpr.
	(operator>>, operator<<): Add inline.
	* testsuite/20_util/bitset/access/constexpr.cc: Only check using
	constexpr std::string for the cxx11 ABI.
	* testsuite/20_util/bitset/cons/constexpr_c++23.cc: Likewise.
	* testsuite/20_util/headers/bitset/synopsis.cc: Check constexpr
	for C++23.
2022-09-23 12:53:51 +01:00
Jonathan Wakely
ffb03fa128 libstdc++: Optimize std::bitset<N>::to_string
This makes to_string approximately twice as fast at any optimization
level. Instead of iterating through every bit, jump straight to the next
bit that is set, by using _Find_first and _Find_next.

libstdc++-v3/ChangeLog:

	* include/std/bitset (bitset::_M_copy_to_string): Find set bits
	instead of iterating over individual bits.
2022-09-23 12:53:51 +01:00
GCC Administrator
279c671509 Daily bump. 2022-09-23 00:18:01 +00:00
Jonathan Wakely
9194c13909 libstdc++: Implement constexpr std::bitset for C++23 (P2417R2)
Also add _GLIBCXX_HOSTED checks to simplify making <bitset>
freestanding in the near future.

libstdc++-v3/ChangeLog:

	* include/std/bitset (bitset): Add constexpr for C++23. Guard
	members using std::string with _GLIBCXX_HOSTED.
	* include/std/version (__cpp_lib_constexpr_bitset): Define.
	* testsuite/20_util/bitset/access/constexpr.cc: New test.
	* testsuite/20_util/bitset/cons/constexpr_c++23.cc: New test.
	* testsuite/20_util/bitset/count/constexpr.cc: New test.
	* testsuite/20_util/bitset/ext/constexpr.cc: New test.
	* testsuite/20_util/bitset/operations/constexpr_c++23.cc: New test.
	* testsuite/20_util/bitset/version.cc: New test.
2022-09-22 15:18:00 +01:00
Jonathan Wakely
4b4b51445f libstdc++: Rearrange tests for <bitset>
In C++03 std::bitset was in the Container clause, but since C++11 it has
been in the Utilties clause. This moves the tests to the 20_util
directory, where most people probably expect to find them.

Also create 'access', 'observers', and 'io' subdirectories and group
some tests under there, rather than having one directory per function
name, and only a single test in that directory.

libstdc++-v3/ChangeLog:

	* testsuite/23_containers/bitset/18604.cc: Moved to...
	* testsuite/20_util/bitset/18604.cc: ...here.
	* testsuite/23_containers/bitset/45713.cc: Moved to...
	* testsuite/20_util/bitset/45713.cc: ...here.
	* testsuite/23_containers/bitset/to_string/dr396.cc: Moved to...
	* testsuite/20_util/bitset/access/dr396.cc: ...here.
	* testsuite/23_containers/bitset/to_string/1.cc: Moved to...
	* testsuite/20_util/bitset/access/to_string.cc: ...here.
	* testsuite/23_containers/bitset/to_ullong/1.cc: Moved to...
	* testsuite/20_util/bitset/access/to_ullong.cc: ...here.
	* testsuite/23_containers/bitset/to_ulong/1.cc: Moved to...
	* testsuite/20_util/bitset/access/to_ulong.cc: ...here.
	* testsuite/23_containers/bitset/cons/1.cc: Moved to...
	* testsuite/20_util/bitset/cons/1.cc: ...here.
	* testsuite/23_containers/bitset/cons/16020.cc: Moved to...
	* testsuite/20_util/bitset/cons/16020.cc: ...here.
	* testsuite/23_containers/bitset/cons/2.cc: Moved to...
	* testsuite/20_util/bitset/cons/2.cc: ...here.
	* testsuite/23_containers/bitset/cons/3.cc: Moved to...
	* testsuite/20_util/bitset/cons/3.cc: ...here.
	* testsuite/23_containers/bitset/cons/38244.cc: Moved to...
	* testsuite/20_util/bitset/cons/38244.cc: ...here.
	* testsuite/23_containers/bitset/cons/50268.cc: Moved to...
	* testsuite/20_util/bitset/cons/50268.cc: ...here.
	* testsuite/23_containers/bitset/cons/6282.cc: Moved to...
	* testsuite/20_util/bitset/cons/6282.cc: ...here.
	* testsuite/23_containers/bitset/cons/constexpr.cc: Moved to...
	* testsuite/20_util/bitset/cons/constexpr.cc: ...here.
	* testsuite/23_containers/bitset/cons/dr1325-1.cc: Moved to...
	* testsuite/20_util/bitset/cons/dr1325-1.cc: ...here.
	* testsuite/23_containers/bitset/cons/dr1325-2.cc: Moved to...
	* testsuite/20_util/bitset/cons/dr1325-2.cc: ...here.
	* testsuite/23_containers/bitset/cons/dr396.cc: Moved to...
	* testsuite/20_util/bitset/cons/dr396.cc: ...here.
	* testsuite/23_containers/bitset/debug/invalidation/1.cc: Moved to...
	* testsuite/20_util/bitset/debug/invalidation/1.cc: ...here.
	* testsuite/23_containers/bitset/ext/15361.cc: Moved to...
	* testsuite/20_util/bitset/ext/15361.cc: ...here.
	* testsuite/23_containers/bitset/hash/1.cc: Moved to...
	* testsuite/20_util/bitset/hash/1.cc: ...here.
	* testsuite/23_containers/bitset/input/1.cc: Moved to...
	* testsuite/20_util/bitset/io/input.cc: ...here.
	* testsuite/23_containers/bitset/count/6124.cc: Moved to...
	* testsuite/20_util/bitset/observers/6124.cc: ...here.
	* testsuite/23_containers/bitset/all/1.cc: Moved to...
	* testsuite/20_util/bitset/observers/all.cc: ...here.
	* testsuite/23_containers/bitset/test/1.cc: Moved to...
	* testsuite/20_util/bitset/observers/test.cc: ...here.
	* testsuite/23_containers/bitset/operations/1.cc: Moved to...
	* testsuite/20_util/bitset/operations/1.cc: ...here.
	* testsuite/23_containers/bitset/operations/13838.cc: Moved to...
	* testsuite/20_util/bitset/operations/13838.cc: ...here.
	* testsuite/23_containers/bitset/operations/2.cc: Moved to...
	* testsuite/20_util/bitset/operations/2.cc: ...here.
	* testsuite/23_containers/bitset/operations/96303.cc: Moved to...
	* testsuite/20_util/bitset/operations/96303.cc: ...here.
	* testsuite/23_containers/bitset/operations/constexpr-2.cc: Moved to...
	* testsuite/20_util/bitset/operations/constexpr-2.cc: ...here.
	* testsuite/23_containers/bitset/operations/constexpr.cc: Moved to...
	* testsuite/20_util/bitset/operations/constexpr.cc: ...here.
	* testsuite/23_containers/bitset/requirements/constexpr_functions.cc: Moved to...
	* testsuite/20_util/bitset/requirements/constexpr_functions.cc: ...here.
	* testsuite/23_containers/bitset/requirements/explicit_instantiation/1.cc: Moved to...
	* testsuite/20_util/bitset/requirements/explicit_instantiation/1.cc: ...here.
	* testsuite/23_containers/bitset/requirements/explicit_instantiation/1_c++0x.cc: Moved to...
	* testsuite/20_util/bitset/requirements/explicit_instantiation/1_c++0x.cc: ...here.
	* testsuite/23_containers/headers/bitset/synopsis.cc: Moved to...
	* testsuite/20_util/headers/bitset/synopsis.cc: ...here.
2022-09-22 14:49:51 +01:00
François Dumont
42630dc056 libstdc++: Remove useless gdb printer registrations
libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py: Remove ptinter registration for non-existing
	types std::__debug::unique_ptr, std::__debug::stack, std::__debug::queue,
	std::__debug::priority_queue.
2022-09-22 06:22:59 +02:00
GCC Administrator
f85847bd40 Daily bump. 2022-09-22 00:19:09 +00:00
Jonathan Wakely
5814816641 libstdc++: Fix accidental duplicate test [PR91456]
It looks like I committed the testcase for std::function twice, instead
of one for std::function and one for std::is_invocable_r. This replaces
the is_invocable_r one with the example from the PR.

libstdc++-v3/ChangeLog:

	PR libstdc++/91456
	* testsuite/20_util/function/91456.cc: Add comment with PR
	number.
	* testsuite/20_util/is_invocable/91456.cc: Likewise. Replace
	std::function checks with std::is_invocable_r checks.
2022-09-21 15:01:37 +01:00
Jonathan Wakely
16fe325a43 libstdc++: Remove main() from some compile-only tests
libstdc++-v3/ChangeLog:

	* testsuite/17_intro/headers/c++1998/all_attributes.cc: Remove
	unnecessary main function.
	* testsuite/17_intro/headers/c++2011/all_attributes.cc:
	Likewise.
	* testsuite/17_intro/headers/c++2014/all_attributes.cc:
	Likewise.
	* testsuite/17_intro/headers/c++2017/all_attributes.cc:
	Likewise.
	* testsuite/17_intro/headers/c++2020/all_attributes.cc:
	Likewise.
2022-09-21 15:01:28 +01:00
Jonathan Wakely
980aa91e9c libstdc++: Update <memory> synopsis test for C++11 and later
libstdc++-v3/ChangeLog:

	* testsuite/20_util/headers/memory/synopsis.cc: Add declarations
	from C++11 and later.
2022-09-21 15:01:28 +01:00
Jonathan Wakely
9c23fe08c1 libstdc++: Remove trailing whitespace in documentation sources
libstdc++-v3/ChangeLog:

	* doc/xml/manual/documentation_hacking.xml: Remove trailing
	whitespace.
	* doc/xml/manual/policy_data_structures.xml: Likewise.
2022-09-21 08:44:22 +01:00
Jonathan Wakely
cb29396e67 libstdc++: Add _Exit to <stdlib.h> for freestanding
When I added std::_Exit to the freestanding declarations in <cstdlib> I
should also have added it to <stdlib.h>.

libstdc++-v3/ChangeLog:

	* include/c_compatibility/stdlib.h [!_GLIBCXX_HOSTED]: Add
	using-declaration for _Exit.
2022-09-21 08:44:21 +01:00
Jonathan Wakely
d784c5cfe6 libstdc++: Qualify std::abort() in test
This test includes <cstdlib> so should use std::abort not ::abort.

libstdc++-v3/ChangeLog:

	* testsuite/18_support/uncaught_exception/14026.cc: Qualify
	call to std::abort.
2022-09-21 08:44:21 +01:00
Jonathan Wakely
26cb69f8b4 libstdc++: Add <initializer_list> to ranges_base.h header
The header should be included explicitly to use std::initializer_list.
With the upcoming changes to make <ranges> available for freestanding
this becomes an error, because <initializer_list> is no longer provided
by any of the other headers involved here.

libstdc++-v3/ChangeLog:

	* include/bits/ranges_base.h: Include <initializer_list>.
2022-09-21 08:42:00 +01:00
GCC Administrator
5e4f5c25d6 Daily bump. 2022-09-21 00:19:14 +00:00
Jonathan Wakely
5ed0c11ec2 libstdc++: Fix typo in <cstdlib> for freestanding
libstdc++-v3/ChangeLog:

	* include/c_global/cstdlib [!_GLIBCXX_HOSTED] (quick_exit): Fix
	missing space.
2022-09-20 13:21:36 +01:00
GCC Administrator
7ee0fa100f Daily bump. 2022-09-17 00:17:20 +00:00
Jonathan Wakely
cf0fded5d8 libstdc++: Add preprocessor conditions for freestanding [PR106953]
This adds checks for _GLIBCXX_HOSTED to a number of headers which are
not currently installed for freestanding, but need to be for P1642R11
support. For example, <iterator> needs to be installed for C++23
freestanding mode, but without stream iterators and streambuf iterators.
Similarly, <memory> needs to be installed, but without std::allocator
and std::shared_ptr. This change disables the non-freestanding parts of
those headers.

libstdc++-v3/ChangeLog:

	PR libstdc++/106953
	* include/backward/auto_ptr.h [!_GLIBCXX_HOSTED]: Do not define
	shared_ptr members.
	* include/bits/alloc_traits.h [!_GLIBCXX_HOSTED]: Do not declare
	std::allocator_traits<std::allocator<T>> specializations for
	freestanding.
	* include/bits/memoryfwd.h [!_GLIBCXX_HOSTED] (allocator): Do
	not declare for freestanding.
	* include/bits/stl_algo.h [!_GLIBCXX_HOSTED] (stable_partition):
	Do not define for freestanding.
	[!_GLIBCXX_HOSTED] (merge, stable_sort): Do not use temporary
	buffers for freestanding.
	* include/bits/stl_algobase.h [!_GLIBCXX_HOSTED]: Do not declare
	streambuf iterators and overloaded algorithms using them.
	* include/bits/stl_uninitialized.h [!_GLIBCXX_HOSTED]: Do not
	define specialized overloads for std::allocator.
	* include/bits/unique_ptr.h [!_GLIBCXX_HOSTED] (make_unique)
	(make_unique_for_overwrite, operator<<): Do not define for
	freestanding.
	* include/c_global/cstdlib [!_GLIBCXX_HOSTED] (_Exit): Declare.
	Use _GLIBCXX_NOTHROW instead of throw().
	* include/debug/assertions.h [!_GLIBCXX_HOSTED]: Ignore
	_GLIBCXX_DEBUG for freestanding.
	* include/debug/debug.h [!_GLIBCXX_DEBUG]: Likewise.
	* include/std/bit [!_GLIBCXX_HOSTED]: Do not use the custom
	__int_traits if <ext/numeric_traits.h> is available.
	* include/std/functional [!_GLIBCXX_HOSTED]: Do not include
	headers that aren't valid for freestanding.
	(boyer_moore_searcher, boyer_moore_horspool_searcher): Do not
	define for freestanding.
	* include/std/iterator [!_GLIBCXX_HOSTED]: Do not include
	headers that aren't valid for freestanding.
	* include/std/memory [!_GLIBCXX_HOSTED]: Likewise.
	* include/std/ranges [!_GLIBCXX_HOSTED] (istream_view): Do not
	define for freestanding.
	(views::__detail::__is_basic_string_view) [!_GLIBCXX_HOSTED]:
	Do not define partial specialization for freestanding.
2022-09-16 21:47:19 +01:00
Jonathan Wakely
7f4c37099a libstdc++: Move allocator-related helpers to <bits/alloc_traits.h>
The __alloc_swap and __shrink_to_fit_aux helpers are not specific to
std::allocator, so don't belong in <bits/allocator.h>. This also
simplifies enabling <memory> for freestanding, as now we can just omit
the whole of <bits/allocator.h> for freestanding.

libstdc++-v3/ChangeLog:

	* include/bits/alloc_traits.h (__alloc_swap)
	(__shrink_to_fit_aux): Move here, from ...
	* include/bits/allocator.h: ... here.
	* include/ext/alloc_traits.h: Do not include allocator.h.
2022-09-16 21:35:43 +01:00
Jonathan Wakely
d31e19e440 libstdc++: Make more internal headers include their own dependencies
This adds required headers to a few internal headers that currently
assume their deps will be included first. It's more robust to make them
include their own dependencies, so that later refactoring or reuse of
those headers in new contexts doesn't break.

libstdc++-v3/ChangeLog:

	* include/bits/stl_algo.h: Include <bits/stl_algobase.h>.
	* include/bits/stl_tempbuf.h: Include headers for __try and
	__catch macros, std::pair, and __gnu_cxx::__numeric_traits.
	* include/bits/stream_iterator.h: Include <iosfwd> and headers
	for std::addressof and std::iterator.
	* include/bits/streambuf_iterator.h: Include header for
	std::iterator.
	* include/std/iterator: Do not include <iosfwd>.
2022-09-16 21:23:24 +01:00
Jonathan Wakely
47deb1ef87 libstdc++: Fix compare_exchange_padding.cc test for std::atomic_ref
This test was written assuming that std::atomic_ref clears its target's
padding on construction, but that could introduce data races. Change the
test to store a value after construction and check that its padding is
cleared by the store.

libstdc++-v3/ChangeLog:

	* testsuite/29_atomics/atomic_ref/compare_exchange_padding.cc:
	Store value with non-zero padding bits after construction.
2022-09-16 21:19:09 +01:00
Jonathan Wakely
b6adc6255f libstdc++: Fix tr1::variate_generator::engine_value_type
The tr1/5_numerical_facilities/random/variate_generator/37986.cc test
fails for strict -std=c++98 mode because _Adaptor(const _Engine&) is
ill-formed in C++98 when _Engine is a reference type.

Rather than attempt to make the _Adaptor handle references and pointers,
just strip references and pointers from the _Engine type before we adapt
it. That removes the need for the _Adaptor<_Engine*> partial
specialization and avoids the reference-to-reference problem for c++98
mode.

While looking into this I noticed that the TR1 spec requires the
variate_generator<E,D>::engine_value_type to be the underlying engine
type, whereas we make it the _Adaptor<E> type that wraps the engine.

libstdc++-v3/ChangeLog:

	* include/tr1/random.h (__detail::_Adaptor::_BEngine): Remove.
	(__detail::_Adaptor::_M_g): Make public.
	(__detail::_Adaptor<_Engine*, _Dist>): Remove partial
	specialization.
	(variate_generate::_Value): New helper to simplify handling of
	_Engine* and _Engine& template arguments.
	(variate_generate::engine_value_type): Define to underlying
	engine type, not adapted type.
	(variate_generate::engine()): Return underlying engine instead
	of adaptor.
	* testsuite/tr1/5_numerical_facilities/random/variate_generator/37986.cc:
	Fix comment.
	* testsuite/tr1/5_numerical_facilities/random/variate_generator/requirements/typedefs.cc:
	Check member typedefs have the correct types.
2022-09-16 15:54:42 +01:00
Jonathan Wakely
5ad435f2a0 libstdc++: Do not use nullptr in C++03-compatible code
This has to be valid as C++98/C++03.

libstdc++-v3/ChangeLog:

	* include/debug/formatter.h [_GLIBCXX_DEBUG_BACKTRACE]
	(_Error_formatter): Use 0 as null pointer constant.
2022-09-16 15:54:42 +01:00
Jonathan Wakely
1594328586 libstdc++: Remove __alloc_neq helper
This class template and partial specialization were added 15 years ago
to optimize allocator equality comparisons in std::list. I think it's
safe to assume that GCC is now capable of optimizing an inline
operator!= that just returns false at least as well as an inline member
function that just returns false.

libstdc++-v3/ChangeLog:

	* include/bits/allocator.h (__alloc_neq): Remove.
	* include/bits/stl_list.h (list::_M_check_equal_allocators):
	Compare allocators directly, without __alloc_neq.
2022-09-16 15:54:41 +01:00
Jonathan Wakely
64f9580423 libstdc++: Fix Doxygen commands
Remove the bogus -D__allocator_base=std::__new_allocator macro
definition for Doxygen, because that's an alias template for C++11 and
later, not a macro.

Fix the @cond/@endcond pair that span the end of an @addtogroup group.
Add another @endcond inside the group, and another @cond after it.

libstdc++-v3/ChangeLog:

	* doc/doxygen/user.cfg.in (PREDEFINED): Remove __allocator_base.
	* include/bits/allocator.h: Fix nesting of Doxygen commands.
2022-09-16 15:54:41 +01:00
Jonathan Wakely
4c156ead37 libstdc++: Document new libstdc++.so symbol versions
libstdc++-v3/ChangeLog:

	* doc/xml/manual/abi.xml: Document GLIBCXX_3.4.30 and
	GLIBCXX_3.4.31 versions.
	* doc/html/manual/abi.html: Regenerate.
2022-09-16 10:50:28 +01:00
GCC Administrator
d0fc05e860 Daily bump. 2022-09-16 00:16:53 +00:00
Jonathan Wakely
d6ccad7641 libstdc++: Remove unnecessary header from <memory>
Previously <memory> included <bits/stl_algobase.h> so that std::copy,
std::fill etc. could be used by <bits/stl_uninitialized.h>. But that
includes it explicitly now, so that it can be compiled as a header unit.
There's no need to include it in <memory>, where its purpose isn't
obvious.

libstdc++-v3/ChangeLog:

	* include/std/memory: Do not include <bits/stl_algobase.h>.
2022-09-15 23:57:32 +01:00
Jonathan Wakely
ecbdfa8b31 libstdc++: Tweak TSan annotations for std::atomic<shared_ptr<T>>
Do not use the __tsan_mutex_not_static flag for annotation functions
where it's not a valid flag.  Also use the try_lock and try_lock_failed
flags to more precisely annotate the CAS loop used to acquire a lock.

libstdc++-v3/ChangeLog:

	* include/bits/shared_ptr_atomic.h (_GLIBCXX_TSAN_MUTEX_PRE_LOCK):
	Replace with ...
	(_GLIBCXX_TSAN_MUTEX_TRY_LOCK): ... this, add try_lock flag.
	(_GLIBCXX_TSAN_MUTEX_TRY_LOCK_FAILED): New macro using
	try_lock_failed flag
	(_GLIBCXX_TSAN_MUTEX_POST_LOCK): Rename to ...
	(_GLIBCXX_TSAN_MUTEX_LOCKED): ... this.
	(_GLIBCXX_TSAN_MUTEX_PRE_UNLOCK): Remove invalid flag.
	(_GLIBCXX_TSAN_MUTEX_POST_UNLOCK): Remove invalid flag.
	(_Sp_atomic::_Atomic_count::lock): Use new macros.
2022-09-15 21:04:36 +01:00
Patrick Palka
29b39d4b0e libstdc++: Implement ranges::chunk_by_view from P2443R1
libstdc++-v3/ChangeLog:

	* include/bits/ranges_algo.h (__adjacent_find_fn, adjacent_find):
	Move to ...
	* include/bits/ranges_util.h: ... here.
	* include/std/ranges (chunk_by_view): Define.
	(chunk_by_view::_Iterator): Define.
	(__detail::__can_chunk_by_view): Define.
	(_ChunkBy, chunk_by): Define.
	* testsuite/std/ranges/adaptors/chunk_by/1.cc: New test.
2022-09-15 13:16:51 -04:00
François Dumont
db58fa0b05 libstdc++: [_GLIBCXX_INLINE_VERSION] Fix test dg-prune-output
libstdc++-v3/ChangeLog:

	* testsuite/20_util/is_complete_or_unbounded/memoization_neg.cc:
	Adapt dg-prune-output to _GLIBCXX_INLINE_VERSION mode.
2022-09-15 18:59:49 +02:00
François Dumont
d26bcff991 libstdc++: [_GLIBCXX_INLINE_VERSION] Cleanup gnu-versioned-namespace.ver
Remove expressions for symbols in std::__detail::__8 namespace, they are obsolete since
version namespace applies only at std:: level, not at sub-levels.

libstdc++-v3/ChangeLog:

	* config/abi/pre/gnu-versioned-namespace.ver: Remove obsolete std::__detail::__8
	symbols.
2022-09-15 18:58:50 +02:00
GCC Administrator
ff822367bb Daily bump. 2022-09-15 00:17:35 +00:00
Jonathan Wakely
0abc63a5ea libstdc++: Add TSan annotations to std::atomic<shared_ptr<T>>
This adds annotations to std::atomic<shared_ptr<T>> to enable TSan to
understand the custom locking. Without this, TSan reports data races for
accesses to the _M_ptr member, even though those are correctly
synchronized using atomic operations on the tagged pointer.

libstdc++-v3/ChangeLog:

	* include/bits/shared_ptr_atomic.h (_GLIBCXX_TSAN_MUTEX_DESTROY)
	(_GLIBCXX_TSAN_MUTEX_PRE_LOCK, _GLIBCXX_TSAN_MUTEX_POST_LOCK)
	(_GLIBCXX_TSAN_MUTEX_PRE_UNLOCK, _GLIBCXX_TSAN_MUTEX_POST_UNLOCK)
	(_GLIBCXX_TSAN_MUTEX_PRE_SIGNAL, _GLIBCXX_TSAN_MUTEX_POST_SIGNAL):
	Define macros for TSan annotation functions.
	(_Sp_atomic::_Atomic_count): Add annotations.
2022-09-14 19:17:37 +01:00
Jonathan Wakely
7f1e3d06bb libstdc++: Add missing <new> header to <bits/stl_tempbuf.h>
This is needed for std::nothrow and the nothrow operator new overload,
so should be included explicitly.

libstdc++-v3/ChangeLog:

	* include/bits/stl_tempbuf.h: Include <new>.
2022-09-14 19:17:36 +01:00
Jonathan Wakely
9a1bc4b463 libstdc++: Add comment to 17_intro/names.cc test
libstdc++-v3/ChangeLog:

	* testsuite/17_intro/names.cc: Explain why poison pragma can't
	be used.
2022-09-14 19:17:36 +01:00