Commit graph

689 commits

Author SHA1 Message Date
Jonathan Wakely
6854e3ac71 libstdc++: Simplify C++20 poison pill overloads (P2602R2)
This implements the C++23 change "Poison Pills are Too Toxic". This
makes sense to do unconditionally for C++20, as the corner cases that it
fixes are considered to be defects in the C++20 design (e.g. LWG3480 was
needed to fix directory iterators because of these pills being too
toxic).

libstdc++-v3/ChangeLog:

	* include/bits/iterator_concepts.h (__imove::iter_move): Define
	poison pill as deleted for consistency.
	(__access::begin): Replace with a single declaration.
	* include/bits/ranges_base.h (__access::end, __access::rbegin)
	(__access::rend, __access::size): Likewise.
	* include/bits/version.def (ranges): Update value for C++23.
	* include/bits/version.h: Regenerate.
	* libsupc++/compare (__compare): Add missing poison pill
	overloads.
	* testsuite/std/ranges/version_c++23.cc: Adjust expected value
	of __cpp_lib_ranges.
	* testsuite/std/ranges/access/p2602.cc: New test.
2023-09-07 08:08:12 +01:00
Jonathan Wakely
faea9d92db libstdc++: Rename C++20 Customization Point Objects
This makes the naming of the CPO types and namespaces simpler and more
consistent. With this change the string "cust" won't appear in
diagnostics related to these CPOs, which avoids confusion about what it
means (customization? customer?). Users don't really need to care that
these are called "customization point objects", so don't show them the
string "cust". Names like "__imove::_IterMove" are preferable to names
like "__cust_imove::_IMove" as the former is more obviously related to
the public API "ranges::iter_move".

Instead of a plethora of inline namespaces for all the different CPO
objects, define them all in an inline namespace called _Cpo (which isn't
shown to users anyway, unlike the types of those objects).

libstdc++-v3/ChangeLog:

	* include/bits/iterator_concepts.h (ranges::__cust_imove):
	Rename to ranges::__imove.
	(_IMove): Rename to _IterMove.
	(ranges::__cust_iswap): Rename to ranges::__iswap.
	(ranges::__cust): Rename to ranges::_Cpo.
	(ranges::__cust_access): Rename to ranges::__access.
	* include/bits/ranges_base.h (ranges::__cust_access): Rename to
	ranges::__access.
	(ranges::__cust): Rename to ranges::_Cpo.
	* include/std/concepts (ranges::__cust_swap):  Rename to
	ranges::__swap.
	(ranges::__cust): Rename to ranges::_Cpo.
	* libsupc++/compare (__cmp_cust): Rename to __compare.
	(__cmp_algo): Rename to _Cpo.
2023-09-07 08:05:51 +01:00
Jonathan Wakely
84cff28fd2 libstdc++: Make __cmp_cat::__unseq constructor consteval
This constructor should only ever be used with a literal 0 as the
argument, so we can make it consteval. This has the nice advantage that
it is expanded immediately in the front end, and so GDB will never step
into the __cmp_cat::__unseq::__unseq(__unseq*) constructor that is
uninteresting and probably confusing to users.

libstdc++-v3/ChangeLog:

	* libsupc++/compare (__cmp_cat::__unseq): Make ctor consteval.
	* testsuite/18_support/comparisons/categories/zero_neg.cc: Prune
	excess errors caused by invalid consteval calls.
2023-08-17 20:24:17 +01:00
Arsen Arsenović
083b7f2833
libstdc++: Replace all manual FTM definitions and use
libstdc++-v3/ChangeLog:

	* libsupc++/typeinfo: Switch to bits/version.h for
	__cpp_lib_constexpr_typeinfo.
	* libsupc++/new: Switch to bits/version.h for
	__cpp_lib_{launder,hardware_interference_size,destroying_delete}.
	(launder): Guard behind __cpp_lib_launder.
	(hardware_destructive_interference_size)
	(hardware_constructive_interference_size): Guard behind
	__cpp_lib_hardware_interference_size.
	* libsupc++/exception: Switch to bits/version.h for
	__cpp_lib_uncaught_exceptions.
	(uncaught_exceptions): Guard behind __cpp_lib_uncaught_exceptions.
	* libsupc++/compare: Switch to bits/version.h for
	__cpp_lib_three_way_comparison.
	(three_way_comparable, three_way_comparable_with)
	(compare_three_way, weak_order, strong_order, partial_order):
	Guard behind __cpp_lib_three_way_comparison >= 201907L.
	* include/std/chrono: Drop __cpp_lib_chrono definition.
	* include/std/vector: Switch to bits/version.h for
	__cpp_lib_erase_if.
	(erase, erase_if): Guard behind __cpp_lib_erase_if.
	* include/std/variant: Switch to bits/version.h for
	__cpp_lib_variant.  Guard whole header behind that FTM.
	* include/std/utility: Switch to bits/version.h for
	__cpp_lib_{exchange_function,constexpr_algorithms,as_const},
	__cpp_lib_{integer_comparison_functions,to_underlying}, and
	__cpp_lib_unreachable.
	(exchange): Guard behind __cpp_lib_exchange_function.
	(cmp_equal, cmp_not_equal, cmp_less, cmp_greater, cmp_less_equal)
	(cmp_greater_equal, in_range): Guard behind
	__cpp_lib_integer_comparison_functions.
	(to_underlying): Guard behind __cpp_lib_to_underlying.
	(unreachable): Guard behind __cpp_lib_unreachable.
	* include/std/type_traits: Switch to bits/version.h for
	__cpp_lib_is_{null_pointer,final,nothrow_convertible,aggregate},
	__cpp_lib_is_{constant_evaluated,invocable,layout_compatible},
	__cpp_lib_is_{pointer_interconvertible,scoped_enum,swappable},
	__cpp_lib_{logical_traits,reference_from_temporary,remove_cvref},
	__cpp_lib_{result_of_sfinae,transformation_trait_aliases},
	__cpp_lib_{type_identity,type_trait_variable_templates},
	__cpp_lib_{unwrap_ref,void_t,integral_constant_callable},
	__cpp_lib_{bool_constant,bounded_array_traits}, and
	__cpp_lib_has_unique_object_representations.
	(integral_constant::operator()): Guard behind
	__cpp_lib_integral_constant_callable.
	(bool_constant): Guard behind __cpp_lib_bool_constant.
	(conjunction, disjunction, negation, conjunction_v, disjunction_v)
	(negation_v): Guard behind __cpp_lib_logical_traits.
	(is_null_pointer): Guard behind __cpp_lib_is_null_pointer.
	(is_final): Guard behind __cpp_lib_is_final.
	(is_nothrow_convertible, is_nothrow_convertible_v): Guard behind
	__cpp_lib_is_nothrow_convertible.
	(remove_const_t, remove_volatile_t, remove_cv_t)
	(add_const_t, add_volatile_t, add_cv_t): Guard behind
	__cpp_lib_transformation_trait_aliases.
	(void_t): Guard behind __cpp_lib_void_t.
	(is_swappable_with_v, is_nothrow_swappable_with_v)
	(is_swappable_with, is_nothrow_swappable_with): Guard behind
	__cpp_lib_is_swappable.
	(is_nothrow_invocable_r, is_invocable_r, invoke_result)
	(is_invocable, invoke_result_t): Guard behind
	__cpp_lib_is_invocable.
	(alignment_of_v, extent_v, has_virtual_destructor_v)
	(is_abstract_v, is_arithmetic_v, is_array_v)
	(is_assignable_v, is_base_of_v, is_class_v, is_compound_v)
	(is_constructible_v, is_const_v, is_convertible_v)
	(is_copy_assignable_v, is_copy_constructible_v)
	(is_default_constructible_v, is_destructible_v)
	(is_empty_v, is_enum_v, is_final_v, is_floating_point_v)
	(is_function_v, is_fundamental_v, is_integral_v)
	(is_invocable_r_v, is_invocable_v, is_literal_type_v)
	(is_lvalue_reference_v, is_member_function_pointer_v)
	(is_member_object_pointer_v, is_member_pointer_v)
	(is_move_assignable_v, is_move_constructible_v)
	(is_nothrow_assignable_v, is_nothrow_constructible_v)
	(is_nothrow_copy_assignable_v, is_nothrow_copy_constructible_v)
	(is_nothrow_default_constructible_v, is_nothrow_destructible_v)
	(is_nothrow_invocable_r_v, is_nothrow_invocable_v)
	(is_nothrow_move_assignable_v, is_nothrow_move_constructible_v)
	(is_null_pointer_v, is_object_v, is_pod_v, is_pointer_v)
	(is_polymorphic_v, is_reference_v, is_rvalue_reference_v)
	(is_same_v, is_scalar_v, is_signed_v, is_standard_layout_v)
	(is_trivially_assignable_v, is_trivially_constructible_v)
	(is_trivially_copyable_v, is_trivially_copy_assignable_v)
	(is_trivially_copy_constructible_v)
	(is_trivially_default_constructible_v)
	(is_trivially_destructible_v, is_trivially_move_assignable_v)
	(is_trivially_move_constructible_v, is_trivial_v, is_union_v)
	(is_unsigned_v, is_void_v, is_volatile_v, rank_v, as variadic):
	Guard behind __cpp_lib_type_trait_variable_templates.
	(has_unique_object_representations)
	(has_unique_object_representations_v): Guard behind
	__cpp_lib_has_unique_object_representation.
	(is_aggregate): Guard behind __cpp_lib_is_aggregate.
	(remove_cvref, remove_cvref_t): Guard behind
	__cpp_lib_remove_cvref.
	(type_identity, type_identity_t): Guard behind
	__cpp_lib_type_identity.
	(unwrap_reference, unwrap_reference_t, unwrap_ref_decay)
	(unwrap_ref_decay_t): Guard behind __cpp_lib_unwrap_ref.
	(is_bounded_array_v, is_unbounded_array_v, is_bounded_array)
	(is_unbounded_array): Guard behind __cpp_lib_bounded_array_traits.
	(is_scoped_enum, is_scoped_enum_v): Guard behind
	__cpp_lib_is_scoped_enum.
	(reference_constructs_from_temporary)
	(reference_constructs_from_temporary_v): Guard behind
	__cpp_lib_reference_from_temporary.
	* include/std/tuple: Switch to bits/version.h for
	__cpp_lib_{constexpr_tuple,tuple_by_type,apply_make_from_tuple}.
	(get<T>): Guard behind __cpp_lib_tuple_by_type.
	(apply): Guard behind __cpp_lib_apply.
	(make_from_tuple): Guard behind __cpp_lib_make_from_tuple.
	* include/std/syncstream: Switch to bits/version.h for
	__cpp_lib_syncbuf.  Guard header behind that FTM.
	* include/std/string_view: Switch to bits/version.h for
	__cpp_lib_{string_{view,contains},constexpr_string_view} and
	__cpp_lib_starts_ends_with.
	(basic_string_view::starts_with, basic_string_view::ends_with):
	Guard behind __cpp_lib_starts_ends_with.
	[C++23 && _GLIBCXX_HOSTED && !defined(__cpp_lib_string_contains)]:
	Assert as impossible ithout a bug in C++23.
	* include/std/string: Switch to bits/version.h for
	__cpp_lib_erase_if.
	(erase, erase_if): Guard behind __cpp_lib_erase_if.
	* include/std/thread: Switch to bits/version.h for
	__cpp_lib_jthread.
	* include/std/stop_token: Switch to bits/version.h for
	__cpp_lib_jthread.
	* include/std/spanstream: Switch to bits/version.h for
	__cpp_lib_spanstream.  Guard header behind that FTM.
	* include/std/span: Switch to bits/version.h for __cpp_lib_span.
	Guard header behind that FTM.
	* include/std/source_location: Switch to bits/version.h for
	__cpp_lib_source_location.  Guard header with that FTM.
	* include/std/shared_mutex: Switch to bits/version.h for
	__cpp_lib_shared{,_timed}_mutex.
	(shared_mutex): Guard behind __cpp_lib_shared_mutex.
	* include/std/semaphore: Switch to bits/version.h for
	__cpp_lib_semaphore.  Guard header behind that FTM.
	* include/std/ranges: Switch to bits/version.h for
	__cpp_lib_ranges_{zip,chunk{,_by},slide,join_with},
	__cpp_lib_ranges_{repeat_stride,cartesian_product,as_rvalue},
	and __cpp_lib_ranges_{as_const,enumerate,iota}.
	(ranges::zip et al, ranges::chunk et al, ranges::slide et al)
	(ranges::chunk_by et al, ranges::join_with et al)
	(ranges::stride et al, ranges::cartesian_product et al)
	(ranges::as_rvalue et al, ranges::as_const et al)
	(ranges::enumerate et al): Guard behind appropriate FTM.
	* include/std/optional: Switch to bits/version.h for
	__cpp_lib_optional.  Guard header behind that FTM.
	* include/std/numeric: Switch to bits/version.h for
	__cpp_lib_{gcd{,_lcm},lcm,constexpr_numeric,interpolate}
	and __cpp_lib_parallel_algorithm.
	(gcd, lcm): Guard behind __cpp_lib_gcd_lcm.
	(midpoint): Guard behind __cpp_lib_interpolate.
	* include/std/numbers: Switch to bits/version.h for
	__cpp_lib_math_constants.  Guard header behind that FTM.
	* include/std/mutex: Switch to bits/version.h for
	__cpp_lib_scoped_lock.
	(scoped_Lock): Guard behind __cpp_lib_scoped_lock.
	* include/std/memory_resource: Switch to bits/version.h for
	__cpp_lib_{polymorphic_allocator,memory_resource}.
	(synchronized_pool_resource): Guard behind
	__cpp_lib_memory_resource >= 201603L.
	(polymorphic_allocator): Guard behind
	__cpp_lib_polymorphic_allocator.
	* include/std/memory: Switch to bits/version.h for
	__cpp_lib_{parallel_algorithm,atomic_value_initialization}.
	* include/std/list: Switch to bits/version.h for
	__cpp_lib_erase_if.
	(erase, erase_if): Guard behind __cpp_lib_erase_if.
	* include/std/latch: Switch to bits/version.h for __cpp_lib_latch.
	Guard header behind that FTM.
	* include/std/iterator: Switch to bits/version.h for
	__cpp_lib_null_iterators.
	* include/std/iomanip: Switch to bits/version.h for
	__cpp_lib_quoted_string_io.
	(quoted): Guard behind __cpp_lib_quoted_string_io.
	* include/std/functional: Switch to bits/version.h for
	__cpp_lib_{invoke{,_r},constexpr_functional,bind_front} and
	__cpp_lib_{not_fn,booyer_moore_searcher}.
	(invoke): Guard behind __cpp_lib_invoke.
	(invoke_r): Guard behind __cpp_lib_invoke_r.
	(bind_front): Guard behind __cpp_lib_bind_front.
	(not_fn): Guard behind __cpp_lib_not_fn.
	(boyer_moore_searcher, boyer_moore_horspool_searcher): Guard
	definition behind __cpp_lib_boyer_moore_searcher.
	* include/std/forward_list: Switch to bits/version.h for
	__cpp_lib_erase_if.
	(erase, erase_if): Guard behind __cpp_lib_erase_if.
	* include/std/format: Switch to bits/version.h for
	__cpp_lib_format.  Guard header behind that FTM.
	* include/std/filesystem: Switch to bits/version.h for
	__cpp_lib_filesystem.  Guard header behind that FTM.
	* include/std/expected: Switch to bits/version.h for
	__cpp_lib_expected.  Guard header behind it.
	* include/std/execution: Switch to bits/version.h for
	__cpp_lib_{execution,parallel_algorithm}.  Guard header behind
	either.
	* include/std/deque: Switch to bits/version.h for
	__cpp_lib_erase_if.
	(erase, erase_if): Guard behind __cpp_lib_erase_if.
	* include/std/coroutine: Switch to bits/version.h for
	__cpp_lib_coroutine.  Guard header behind that FTM.
	* include/std/concepts: Switch to bits/version.h for
	__cpp_lib_concepts.  Guard header behind that FTM.
	* include/std/complex: Switch to bits/version.h for
	__cpp_lib_{complex_udls,constexpr_complex}.
	(operator""if, operator""i, operator""il): Guard behind
	__cpp_lib_complex_udls.
	* include/std/charconv: Swtich to bits/version.h for
	__cpp_lib_{to_chars,constexpr_charconv}.
	* include/std/bitset: Switch to bits/version.h for
	__cpp_lib_constexpr_bitset.
	* include/std/bit: Switch to bits/version.h for
	__cpp_lib_{bit_cast,byteswap,bitops,int_pow2,endian}.
	(bit_cast): Guard behind __cpp_lib_bit_cast.
	(byteswap): Guard behind __cpp_lib_byteswap.
	(rotl, rotr, countl_zero, countl_one, countr_zero, countr_one)
	(popcount): Guard behind __cpp_lib_bitops.
	(has_single_bit, bit_ceil, bit_floor, bit_width): Guard behind
	__cpp_lib_int_pow2.
	(endian): Guard behind __cpp_lib_endian.
	* include/std/barrier: Switch to bits/version.h for
	__cpp_lib_barrier.  Guard header behind that FTM.
	* include/std/atomic: Switch to bits/version.h for
	__cpp_lib_atomic_{is_always_lock_free,float,ref}
	and __cpp_lib_lock_free_type_aliases.
	(*::is_always_lock_free): Guard behind
	__cpp_lib_atomic_is_always_lock_free.
	(atomic<float>): Guard behind __cpp_lib_atomic_float.
	(atomic_ref): Guard behind __cpp_lib_atomic_ref.
	(atomic_signed_lock_free, atomic_unsigned_lock_free): Guard behind
	__cpp_lib_atomic_lock_free_type_aliases.
	* include/std/array: Switch to bits/version.h for
	__cpp_lib_to_array.
	(to_array): Guard behind __cpp_lib_to_array.
	* include/std/any: Switch to bits/version.h for __cpp_lib_any.
	Guard header behind that FTM.
	* include/std/algorithm: Switch to bits/version.h for
	__cpp_lib_parallel_algorithm.
	* include/c_global/cstddef: Switch to bits/version.h for
	__cpp_lib_byte.
	(byte): Guard behind __cpp_lib_byte.
	* include/c_global/cmath: Switch to bits/version.h for
	__cpp_lib_{hypot,interpolate}.
	(hypot3): Guard behind __cpp_lib_hypot.
	(lerp): Guard behind __cpp_lib_interpolate.
	* include/c_compatibility/stdatomic.h: Switch to
	bits/stl_version.h for __cpp_lib_atomic.  Guard header behind that
	FTM.
	* include/bits/utility.h: Switch to bits/version.h for
	__cpp_lib_{tuple_element_t,integer_sequence,ranges_zip}.
	(tuple_element_t): Guard behind __cpp_lib_tuple_element_t.
	(integer_sequence et al): Guard behind __cpp_lib_integer_sequence.
	* include/bits/uses_allocator_args.h: Switch to bits/version.h for
	__cpp_lib_make_obj_using_allocator.  Guard header behind that FTM.
	* include/bits/unordered_map.h: Switch to bits/version.h for
	__cpp_lib_unordered_map_try_emplace.
	(try_emplace): Guard behind __cpp_lib_unordered_map_try_emplace.
	* include/bits/unique_ptr.h: Switch to bits/version.h for
	__cpp_lib_{constexpr_memory,make_unique}.
	(make_unique): Guard behind __cpp_lib_make_unique.
	* include/bits/stl_vector.h: Switch to bits/version.h for
	__cpp_lib_constexpr_vector.
	* include/bits/stl_uninitialized.h: Switch to bits/version.h for
	__cpp_lib_raw_memory_algorithms.
	(uninitialized_default_construct)
	(uninitialized_default_construct_n, uninitialized_move)
	(uninitialized_move_n, uninitialized_value_construct)
	(uninitialized_value_construct_n): Guard behind
	__cpp_lib_raw_memory_algorithms.
	* include/bits/stl_tree.h: Switch to bits/version.h for
	__cpp_lib_generic_associative_lookup.
	* include/bits/stl_stack.h: Switch to bits/version.h for
	__cpp_lib_adaptor_iterator_pair_constructor.
	(stack): Guard iterator-pair constructor behind
	__cpp_lib_adaptor_iterator_pair_constructor.
	* include/bits/stl_queue.h: Switch to bits/version.h for
	__cpp_lib_adaptor_iterator_pair_constructor.
	(queue): Guard iterator-pair constructor behind
	__cpp_lib_adaptor_iterator_pair_constructor.
	* include/bits/stl_pair.h: Switch to bits/version.h for
	__cpp_lib_{concepts,tuples_by_type}.
	(get): Guard type-getting overloads behind
	__cpp_lib_tuples_by_type.
	* include/bits/stl_map.h: Switch to bits/version.h for
	__cpp_lib_map_try_emplace.
	(map<>::try_emplace): Guard behind __cpp_lib_map_try_emplace.
	* include/bits/stl_list.h: Switch to bits/version.h for
	__cpp_lib_list_remove_return_type.
	(__remove_return_type, _GLIBCXX_LIST_REMOVE_RETURN_TYPE_TAG)
	[C++20]: guard behind __cpp_lib_list_remove_return_type instead.
	* include/bits/stl_iterator.h: Switch to bits/version.h for
	__cpp_lib_{constexpr_iterator,array_constexpr} and
	__cpp_lib_{make_reverse_iterator,move_iterator_concept}.
	(make_reverse_iterator): Guard behind
	__cpp_lib_make_reverse_iterator.
	(iterator_concept et al): Guard __cpp_lib_move_iterator_concept
	changes behind that FTM.
	* include/bits/stl_function.h: Switch to bits/version.h for
	__cpp_lib_transparent_operators.
	(equal_to, not_equal_to, greater, less, greater_equal)
	(less_equal, bit_and, bit_or, bit_xor, bit_not, logical_and)
	(logical_or, logical_not, plus, minus, multiplies, divides)
	(modulus, negate): Guard '= void' fwdecls behind
	__cpp_lib_transparent_operators.
	(plus<void>, minus<void>, multiplies<void>, divides<void>)
	(modulus<void>, negate<void>, logical_and<void>, logical_or<void>)
	(logical_not<void>, bit_and<void>, bit_or<void>, bit_xor<void>)
	(equal_to<void>, not_equal_to<void>, greater<void>, less<void>)
	(greater_equal<void>, less_equal<void>, bit_not<void>)
	(__has_is_transparent): Guard behind
	__cpp_lib_transparent_operators.
	* include/bits/stl_algobase.h: Switch to bits/version.h for
	__cpp_lib_robust_nonmodifying_seq_ops.
	(robust equal, mismatch): Guard behind
	__cpp_lib_nonmember_container_access.
	* include/bits/stl_algo.h: Swtich to bits/version.h for
	__cpp_lib_{clamp,sample}.
	(clamp): Guard behind __cpp_lib_clamp.
	(sample): Guard behind __cpp_lib_sample.
	* include/bits/specfun.h: Switch to bits/version.h for
	__cpp_lib_math_special_functions and __STDCPP_MATH_SPEC_FUNCS__.
	* include/bits/shared_ptr_base.h: Switch to bits/version.h for
	__cpp_lib_{smart_ptr_for_overwrite,shared_ptr_arrays}.
	(_Sp_overwrite_tag): Guard behind
	__cpp_lib_smart_ptr_for_overwrite.
	* include/bits/shared_ptr_atomic.h: Switch to bits/version.h for
	__cpp_lib_atomic_shared_ptr.
	* include/bits/shared_ptr.h: Switch to bits/version.h for
	__cpp_lib_{enable_shared_from_this,shared_ptr_weak_type}.
	(shared_ptr<T>::weak_type): Guard behind
	__cpp_lib_shared_ptr_weak_type.
	(enable_shared_from_this<T>::weak_from_this): Guard behind
	__cpp_lib_enable_shared_from_this.
	* include/bits/ranges_cmp.h: Switch to bits/version.h for
	__cpp_lib_ranges.
	* include/bits/ranges_algo.h: Switch to bits/version.h for
	__cpp_lib_{shift,ranges_{contains,find_last,fold,iota}}.
	* include/bits/range_access.h: Switch to bits/version.h for
	__cpp_lib_nonmember_container_access
	(size, empty, data): Guard behind
	__cpp_lib_nonmember_container_access.
	(ssize): Guard behind __cpp_lib_ssize.
	* include/bits/ptr_traits.h: Switch to bits/version.h. for
	__cpp_lib_{constexpr_memory,to_address}.
	(to_address): Guard behind __cpp_lib_to_address.
	* include/bits/node_handle.h: Switch to bits/version.h for
	__cpp_lib_node_extract.  Guard header behind that FTM.
	* include/bits/move_only_function.h: Switch to bits/version.h for
	__cpp_lib_move_only_function.  Guard header behind that FTM.
	* include/bits/move.h: Switch to bits/version.h for
	__cpp_lib_addressof_constexpr.
	* include/bits/ios_base.h: Switch to bits/version.h for
	__cpp_lib_ios_noreplace.
	(noreplace): Guard with __cpp_lib_ios_noreplace.
	* include/bits/hashtable.h: Switch to bits/version.h for
	__cpp_lib_generic_unordered_lookup.
	(_M_equal_range_tr, _M_count_tr, _M_find_tr): Guard behind
	__cpp_lib_generic_unordered_lookup.
	* include/bits/forward_list.h: Switch to bits/version.h for
	__cpp_lib_list_remove_return_type.
	(__remove_return_type): Guard behind
	__cpp_lib_list_remove_return_type.
	* include/bits/erase_if.h: Switch to bits/version.h for
	__cpp_lib_erase_if.
	* include/bits/cow_string.h: Switch to bits/version.h for
	__cpp_lib_constexpr_string.
	* include/bits/chrono.h: Swtich to bits/version.h for
	__cpp_lib_chrono{,_udls}.
	(ceil): Guard behind __cpp_lib_chrono.
	(operator""ns et al): Guard behind __cpp_lib_chrono_udls.
	* include/bits/char_traits.h: Switch to bits/version.h for
	__cpp_lib_constexpr_char_traits.
	* include/bits/basic_string.h: Switch to bits/version.h for
	__cpp_lib_{constexpr_string,string_{resize_and_overwrite,udls}}.
	(resize_and_overwrite): Guard behind
	__cpp_lib_string_resize_and_overwrite.
	(operator""s): Guard behind __cpp_lib_string_udls.
	* include/bits/atomic_wait.h: Switch to bits/version.h for
	__cpp_lib_atomic_wait.  Guard header behind that FTM.
	* include/bits/atomic_base.h: Switch to bits/version.h for
	__cpp_lib_atomic_value_initialization and
	__cpp_lib_atomic_flag_test.
	(atomic_flag::test): Guard behind __cpp_lib_atomic_flag_test,
	rather than C++20.
	* include/bits/allocator.h: Switch to bits/version.h for
	__cpp_lib_incomplete_container_elements.
	* include/bits/alloc_traits.h: Switch to using bits/version.h for
	__cpp_lib_constexpr_dynamic_alloc and
	__cpp_lib_allocator_traits_is_always_equal.
	* include/bits/align.h: Switch to bits/version.h for defining
	__cpp_lib_assume_aligned.
	(assume_aligned): Guard with __cpp_lib_assume_aligned.
	* include/bits/algorithmfwd.h: Switch to bits/version.h for
	defining __cpp_lib_constexpr_algorithms.
	* include/std/stacktrace: Switch to bits/version.h for
	__cpp_lib_stacktrace.  Guard header behind that FTM.
	* testsuite/23_containers/array/tuple_interface/get_neg.cc:
	Update line numbers.
2023-08-16 15:16:25 +02:00
Jan Hubicka
45c53768b6 Add cold attribute to throw wrappers and terminate
PR middle-end/109849
	* include/bits/c++config (std::__terminate): Mark cold.
	* include/bits/functexcept.h: Mark everything as cold.
	* libsupc++/exception: Mark terminate and unexpected as cold.
2023-06-28 11:47:11 +02:00
Jason Merrill
2415024e0f c++: use __cxa_call_terminate for MUST_NOT_THROW [PR97720]
[except.handle]/7 says that when we enter std::terminate due to a throw,
that is considered an active handler.  We already implemented that properly
for the case of not finding a handler (__cxa_throw calls __cxa_begin_catch
before std::terminate) and the case of finding a callsite with no landing
pad (the personality function calls __cxa_call_terminate which calls
__cxa_begin_catch), but for the case of a throw in a try/catch in a noexcept
function, we were emitting a cleanup that calls std::terminate directly
without ever calling __cxa_begin_catch to handle the exception.

A straightforward way to fix this seems to be calling __cxa_call_terminate
instead.  However, that requires exporting it from libstdc++, which we have
not previously done.  Despite the name, it isn't actually part of the ABI
standard.  Nor is __cxa_call_unexpected, as far as I can tell, but that one
is also used by clang.  For this case they use __clang_call_terminate; it
seems reasonable to me for us to stick with __cxa_call_terminate.

I also change __cxa_call_terminate to take void* for simplicity in the front
end (and consistency with __cxa_call_unexpected) but that isn't necessary if
it's undesirable for some reason.

This patch does not fix the issue that representing the noexcept as a
cleanup is wrong, and confuses the handler search; since it looks like a
cleanup in the EH tables, the unwinder keeps looking until it finds the
catch in main(), which it should never have gotten to.  Without the
try/catch in main, the unwinder would reach the end of the stack and say no
handler was found.  The noexcept is a handler, and should be treated as one,
as it is when the landing pad is omitted.

The best fix for that issue seems to me to be to represent an
ERT_MUST_NOT_THROW after an ERT_TRY in an action list as though it were an
ERT_ALLOWED_EXCEPTIONS (since indeed it is an exception-specification).  The
actual code generation shouldn't need to change (apart from the change made
by this patch), only the action table entry.

	PR c++/97720

gcc/cp/ChangeLog:

	* cp-tree.h (enum cp_tree_index): Add CPTI_CALL_TERMINATE_FN.
	(call_terminate_fn): New macro.
	* cp-gimplify.cc (gimplify_must_not_throw_expr): Use it.
	* except.cc (init_exception_processing): Set it.
	(cp_protect_cleanup_actions): Return it.

gcc/ChangeLog:

	* tree-eh.cc (lower_resx): Pass the exception pointer to the
	failure_decl.
	* except.h: Tweak comment.

libstdc++-v3/ChangeLog:

	* libsupc++/eh_call.cc (__cxa_call_terminate): Take void*.
	* config/abi/pre/gnu.ver: Add it.

gcc/testsuite/ChangeLog:

	* g++.dg/eh/terminate2.C: New test.
2023-06-03 21:49:00 -04:00
Jason Merrill
5d9c911907 libstdc++: optimize EH phase 2
In the ABI's two-phase EH model, first we walk the stack looking for a
handler, then we walk the stack running cleanups until we reach that
handler.  In the cleanup phase, we shouldn't redundantly check the handlers
along the way, e.g. when walking through g():

  void f() { throw 42; }
  void g() { try { f(); } catch (void *) { } }
  int main() { try { g(); } catch (int) { } }

libstdc++-v3/ChangeLog:

	* libsupc++/eh_personality.cc (PERSONALITY_FUNCTION): Don't check
	handlers in the cleanup phase.
2023-06-01 08:49:20 -04:00
Jonathan Wakely
b153f4e4ca libstdc++: Adjust uses of null pointer constants in docs
libstdc++-v3/ChangeLog:

	* doc/xml/manual/extensions.xml: Fix example to declare and
	qualify std::free, and use NULL instead of 0.
	* doc/html/manual/ext_demangling.html: Regenerate.
	* libsupc++/cxxabi.h: Adjust doxygen comments.
2023-04-19 00:13:02 +01:00
Jonathan Wakely
291c130ef0 libstdc++: Fix comment typo in eh_personality.cc
libstdc++-v3/ChangeLog:

	* libsupc++/eh_personality.cc: Fix spelling in comment.
2023-03-07 17:33:28 +00:00
Jonathan Wakely
dc79eba72b libstdc++: Fix uses of non-reserved names in headers
The non-reserved names 'val' and 'dest' were being used in our headers
but haven't been added to the 17_intro/names.cc test. That's because
they are used by <asm-generic/posix_types.h> and <netinet/tcp.h>
respecitvely on glibc-based systems.

libstdc++-v3/ChangeLog:

	* include/bits/fs_ops.h (create_directory): Use reserved name
	for parameter.
	* include/bits/ranges_algo.h (__contains_subrange_fn):
	Likewise.
	* include/bits/regex_automaton.h (_State_base::_M_print):
	Likewise.
	* include/bits/regex_automaton.tcc(_State_base::_M_print):
	Likewise.
	* include/bits/regex_scanner.tcc(_Scanner::_M_print): Likewise.
	* include/experimental/bits/fs_ops.h (create_directory):
	Likewise.
	* include/std/mutex (timed_mutex::_M_clocklock): Likewise.
	(recursive_timed_mutex:_M_clocklock): Likewise.
	* include/std/tuple (basic_common_reference): Likewise.
	* libsupc++/cxxabi_init_exception.h
	(__cxa_init_primary_exception): Likewise.
	* testsuite/17_intro/names.cc: Add checks.
2023-02-16 10:24:45 +00:00
Jakub Jelinek
83ffe9cde7 Update copyright years. 2023-01-16 11:52:17 +01:00
Jonathan Wakely
7b79fa9309 libstdc++: Fix _Hash_bytes for I16LP32 targets [PR107885]
For H8/300 size_t is 32 bits wide, but (unsigned char)buf[2] << 16
promotes to int which is only 16 bits wide. The shift is then undefined.
This fixes it by converting to size_t before shifting.

libstdc++-v3/ChangeLog:

	PR libstdc++/107885
	* libsupc++/hash_bytes.cc (_Hash_bytes): Convert to size_t
	instead of implicit integer promotion to 16 bits.
2022-11-28 16:57:35 +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
Jakob Hasse
b83f01d005 libstdc++: fix pointer type exception catch (no RTTI) [PR105387]
__pbase_type_info::__do_catch(), used to catch pointer type exceptions,
did not check if the type info object to compare against is a pointer
type info object before doing a static down-cast to a pointer type info
object. If RTTI is disabled, this leads to the following situation:
Since a pointer type info object has additional fields, they would
end up being undefined if the actual type info object was not a pointer
type info object.

A simple check has been added before the down-cast happens.

Note that a consequence of this check is that exceptions of type
pointer-to-member cannot be caught anymore.

In case RTTI is enabled, this does not seem to be a problem because
RTTI-based checks would run before and prevent running into the bad
down-cast. Hence, the fix is disabled if RTTI is enabled and exceptions
of type pointer-to-member can still be caught.

libstdc++-v3/ChangeLog:

	PR libstdc++/105387
	* libsupc++/pbase_type_info.cc (__do_catch) [!__cpp_rtti]: Add
	check that the thrown type is actually a pointer.
	* testsuite/18_support/105387.cc: New test.
	* testsuite/18_support/105387_memptr.cc: New test.

Signed-off-by: Jakob Hasse <jakob.hasse@espressif.com>
2022-11-05 14:03:08 +00:00
Jonathan Wakely
418999fe38 libstdc++: Simplify lifetime of eh_globals variable [PR107500]
Since this is a trivial type, we probably don't need to do anything to
ensure it's still accessible after other static dtors.

libstdc++-v3/ChangeLog:

	PR libstdc++/107500
	* libsupc++/eh_globals.cc (eh_globals): Remove immortalizing
	wrapper.
	(__cxxabiv1::__cxa_get_globals_fast): Adjust.
	(__cxxabiv1::__cxa_get_globals): Adjust.
2022-11-04 14:04:53 +00:00
Jonathan Wakely
f505f37a8e libstdc++: Define _GNU_SOURCE for secure_getenv on Cygwin [PR107511]
As in r12-6867-ge20486d508afdf we need to define _GNU_SOURCE explicitly
for Cygwin, because configure finds it in libc but it isn't declared
unless we request it.

libstdc++-v3/ChangeLog:

	PR libstdc++/107511
	* libsupc++/eh_alloc.cc (_GNU_SOURCE): Define.
2022-11-04 14:04:53 +00:00
Jonathan Wakely
41602c85ac libstdc++: Remove more redundant union members
We don't need these 'unused' members because they're never used, and a
union with a single variant member is fine.

libstdc++-v3/ChangeLog:

	* libsupc++/eh_globals.cc (constant_init::unused): Remove.
	* src/c++11/system_error.cc (constant_init::unused): Remove.
	* src/c++17/memory_resource.cc (constant_init::unused): Remove.
2022-11-02 20:33:03 +00:00
Jakub Jelinek
0c86a66748 libstdc++: _Bfloat16 for <compare>
Jon pointed out that we have TODO: _Bfloat16 in <compare>.
Right now _S_fp_fmt() returns _Binary16 for _Float16, __fp16 as well
as __bf16 and it actually works because we don't have a special handling
of _Binary16.  So, either we could just document that, but I'm a little bit
afraid if HPPA or MIPS don't start supporting _Float16 and/or __bf16.
If they do, we have the
 #if defined __hppa__ || (defined __mips__ && !defined __mips_nan2008)
                  // IEEE 754-1985 allowed the meaning of the quiet/signaling
                  // bit to be reversed. Flip that to give desired ordering.
                  if (__builtin_isnan(__x) && __builtin_isnan(__y))
                    {
                      using _Int = decltype(__ix);

                      constexpr int __nantype = __fmt == _Binary32  ?  22
                                              : __fmt == _Binary64  ?  51
                                              : __fmt == _Binary128 ? 111
                                              : -1;
                      constexpr _Int __bit = _Int(1) << __nantype;
                      __ix ^= __bit;
                      __iy ^= __bit;
                    }
 #endif
code, the only one where we actually care whether something is
_Binary{32,64,128} (elsewhere we just care about the x86 and m68k 80bits
or double double or just floating point type's sizeof) and we'd need
to handle there _Binary16 and/or _Bfloat16.

So this patch uses different enum for it even when it isn't needed right
now, after all _Binary16 isn't needed either and we could just use
_Binary32...

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

	* libsupc++/compare (_Strong_order::_Fp_fmt): Add _Bfloat16.
	(_Strong_order::_Bfloat16): New static data member.
	(_Strong_order::_S_fp_fmt): Return _Bfloat16 for std::bfloat16_t.
2022-11-02 13:35:53 +01:00
Arsen Arsenović
655271e47f libstdc++: Don't use gstdint.h anymore
libstdc++-v3/ChangeLog:

	* configure.ac: Stop generating gstdint.h.
	* src/c++11/compatibility-atomic-c++0x.cc: Stop using gstdint.h.
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* doc/Makefile.in: Regenerate.
	* include/Makefile.in: Regenerate.
	* libsupc++/Makefile.in: Regenerate.
	* po/Makefile.in: Regenerate.
	* python/Makefile.in: Regenerate.
	* src/Makefile.in: Regenerate.
	* src/c++11/Makefile.in: Regenerate.
	* src/c++17/Makefile.in: Regenerate.
	* src/c++20/Makefile.in: Regenerate.
	* src/c++98/Makefile.in: Regenerate.
	* src/filesystem/Makefile.in: Regenerate.
	* src/libbacktrace/Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.
2022-10-29 00:55:42 +01:00
LIU Hao
f036d759ec gcc: Add 'mcf' thread model support from mcfgthread
This patch adds the new thread model `mcf`, which implements mutexes
and condition variables with the mcfgthread library.

Source code for mcfgthread is available at <https://github.com/lhmouse/mcfgthread>.

config/ChangeLog:
	* gthr.m4 (GCC_AC_THREAD_HEADER): Add new case for `mcf` thread
	model

gcc/ChangeLog:
	* config/i386/mingw-mcfgthread.h: New file
	* config/i386/mingw32.h: Add builtin macro and default libraries
	for mcfgthread when thread model is `mcf`
	* config.gcc: Include 'i386/mingw-mcfgthread.h' when thread model
	is `mcf`
	* configure.ac: Recognize `mcf` as a valid thread model
	* config.in: Regenerate
	* configure: Regenerate

libatomic/ChangeLog:
	* configure.tgt: Add new case for `mcf` thread model

libgcc/ChangeLog:
	* config.host: Add new cases for `mcf` thread model
	* config/i386/gthr-mcf.h: New file
	* config/i386/t-mingw-mcfgthread: New file
	* config/i386/t-slibgcc-cygming: Add mcfgthread for libgcc DLL
	* configure: Regenerate

libstdc++-v3/ChangeLog:
	* libsupc++/atexit_thread.cc (__cxa_thread_atexit): Use
	implementation from mcfgthread if available
	* libsupc++/guard.cc (__cxa_guard_acquire, __cxa_guard_release,
	__cxa_guard_abort): Use implementations from mcfgthread if
	available
	* configure: Regenerate
2022-10-19 13:52:37 +00:00
Jonathan Wakely
0dd9dd1fdf libstdc++: Disable all emergency EH pool code if obj-count == 0
For a zero-sized static pool we can completely elide all code for the EH
pool.

We no longer need to adjust the static buffer size to ensure at least
one free_entry can be created in it, because we no longer use a static
buffer at all if obj_count == 0. If the buffer exists, obj_count >= 1
and the buffer will be much larger than sizeof(free_entry).

libstdc++-v3/ChangeLog:

	* libsupc++/eh_alloc.cc [USE_POOL]: New macro.
	[!USE_POOL] (__gnu_cxx::__freeres, pool): Do not define.
	[_GLIBCXX_EH_POOL_STATIC] (pool::arena): Do not use std::max.
	(__cxxabiv1::__cxa_allocate_exception) [!USE_POOL]: Do not use
	pool.
	(__cxxabiv1::__cxa_free_exception) [!USE_POOL]: Likewise.
	(__cxxabiv1::__cxa_allocate_dependent_exception) [!USE_POOL]:
	Likewise.
	(__cxxabiv1::__cxa_free_dependent_exception) [!USE_POOL]:
	Likewise.
2022-10-14 15:35:41 +01:00
Jonathan Wakely
23c3cbaed3 libstdc++: Fix bootstrap for --disable-threads build [PR107221]
The __scoped_lock type should be used unqualified so that we always
refer to pool::__scoped_lock, which might be the dummy fallback
implementation.

The __mutex and __scoped_lock types in <ext/concurrence.h> already work
fine without __GTHREADS being defined, but that header isn't included at
all unless _GLIBCXX_HOSTED != 0. The fallback implementation should be
used for ! _GLIBCXX_HOSTED instead of for !defined __GTHREADS.

libstdc++-v3/ChangeLog:

	PR bootstrap/107221
	* libsupc++/eh_alloc.cc (pool): Change preprocessor condition
	for using __mutex from __GTHREADS to _GLIBCXX_HOSTED.
	(pool::allocate): Remove namespace qualification to use
	pool::__scoped_lock instead of __gnu_cxx::__scoped_lock.
2022-10-11 20:36:09 +01:00
Jonathan Wakely
637e3668fd libstdc++: Allow emergency EH alloc pool size to be tuned [PR68606]
Implement a long-standing request to support tuning the size of the
emergency buffer for allocating exceptions after malloc fails, or to
disable that buffer entirely.

It's now possible to disable the dynamic allocation of the buffer and
use a fixed-size static buffer, via --enable-libstdcxx-static-eh-pool.
This is a built-time choice that is baked into libstdc++ and so affects
all code linked against that build of libstdc++.

The size of the pool can be set by --with-libstdcxx-eh-pool-obj-count=N
which is measured in units of sizeof(void*) not bytes. A given exception
type such as std::system_error depends on the target, so giving a size
in bytes wouldn't be portable across 16/32/64-bit targets.

When libstdc++ is configured to use a dynamic buffer, the size of that
buffer can now be tuned at runtime by setting the GLIBCXX_TUNABLES
environment variable (c.f. PR libstdc++/88264). The number of exceptions
to reserve space for is controlled by the "glibcxx.eh_pool.obj_count"
and "glibcxx.eh_pool.obj_size" tunables. The pool will be sized to be
able to allocate obj_count exceptions of size obj_size*sizeof(void*) and
obj_count "dependent" exceptions rethrown by std::rethrow_exception.

With the ability to tune the buffer size, we can reduce the default pool
size on 32-bit and 16-bit targets. Most users never need to throw 1kB
exceptions in parallel from hundreds of threads after malloc is OOM. The
users who do need that can use the tunables to select larger sizes.

The old defaults can be chosen at runtime by setting GLIBCXX_TUNABLES
to:
64-bit: glibcxx.eh_pool.obj_count=64:glibcxx.eh_pool.obj_size=112
32-bit: glibcxx.eh_pool.obj_count=32:glibcxx.eh_pool.obj_size=104

Or approximated by configuring with:
64-bit: --with-libstdcxx-eh-pool-obj-count=252
32-bit: --with-libstdcxx-eh-pool-obj-count=94

libstdc++-v3/ChangeLog:

	PR libstdc++/68606
	* Makefile.in: Regenerate.
	* acinclude.m4 (GLIBCXX_EMERGENCY_EH_ALLOC): New macro.
	* configure: Regenerate.
	* configure.ac: Use GLIBCXX_EMERGENCY_EH_ALLOC.
	* crossconfig.m4: Check for secure_getenv.
	* doc/Makefile.in: Regenerate.
	* doc/xml/manual/configure.xml: Document new configure options.
	* doc/xml/manual/evolution.xml: Document addition of tunables.
	* doc/xml/manual/using_exceptions.xml: Document emergency
	buffer and tunables.
	* doc/html/*: Regenerate.
	* include/Makefile.in: Regenerate.
	* libsupc++/Makefile.am: Use EH_POOL_FLAGS.
	* libsupc++/Makefile.in: Regenerate.
	* libsupc++/eh_alloc.cc (EMERGENCY_OBJ_SIZE): Define in units
	of sizeof(void*) not including the ABI's exception header.
	(EMERGENCY_OBJ_COUNT): Define as target-independent calculation
	based on word size.
	(MAX_OBJ_COUNT): Define macro for upper limit on pool size.
	(pool) [_GLIBCXX_EH_POOL_STATIC]: Use fixed-size buffer.
	(pool::buffer_size_in_bytes): New static member function.
	(pool::pool): Parse GLIBCXX_TUNABLES environment variable to set
	pool size at runtime.
	(pool::in_pool): Use std::less<void*> for total order.
	(__freeres) [_GLIBCXX_EH_POOL_STATIC]: Do nothing.
	(__cxa_free_exception, __cxa_free_dependent_exception): Add
	[[unlikely]] attributes.
	* po/Makefile.in: Regenerate.
	* python/Makefile.in: Regenerate.
	* src/Makefile.in: Regenerate.
	* src/c++11/Makefile.in: Regenerate.
	* src/c++17/Makefile.in: Regenerate.
	* src/c++20/Makefile.in: Regenerate.
	* src/c++98/Makefile.in: Regenerate.
	* src/filesystem/Makefile.in: Regenerate.
	* src/libbacktrace/Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.
2022-10-11 16:21:48 +01:00
Jason Merrill
873d395c29 libstdc++: small dynamic_cast optimization
This change speeds up the simple benchmark below by about 40%.

struct A { virtual ~A() {} };
struct B: A { } b;
A* ap = &b;
void *sink;
int main()
{
  for (long i = 0; i < 4000000000L; ++i)
    sink = dynamic_cast<B*>(ap);
}

libstdc++-v3/ChangeLog:

	* libsupc++/dyncast.cc (__dynamic_cast): Avoid virtual function
	call in simple success case.
2022-09-07 10:11:54 -04:00
Keef Aragon
5bc2042df4 Fix bug in emergency cxa pool free
This probably has never actually affected anyone in practice. The normal
ABI implementation just uses malloc and only falls back to the pool on
malloc failure. But if that happens a bunch of times the freelist gets out
of order which violates some of the invariants of the freelist (as well as
the comments that follow the bug). The bug is just a comparison reversal
when traversing the freelist in the case where the pointer being returned
to the pool is after the existing freelist.

libstdc++-v3/
	* libsupc++/eh_alloc.cc (pool::free): Inverse comparison.
2022-08-17 10:40:01 +02:00
Alexandre Oliva
a33dda016e libstdc++: eh_globals: gthreads: reset _S_init before deleting key
Clear __eh_globals_init's _S_init in the dtor before deleting the
gthread key.

This ensures that, in case any code involved in deleting the key
interacts with eh_globals, the key that is being deleted won't be
used, and the non-thread-specific eh_globals fallback will.


for  libstdc++-v3/ChangeLog

	* libsupc++/eh_globals.cc [!_GLIBCXX_HAVE_TLS]
	(__eh_globals_init::~__eh_globals_init): Clear _S_init first.
2022-06-21 23:11:02 -03: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
c829b04bc3 libstdc++: Allow std::swap to find overload for std::exception_ptr
The non-member swap for std::exception_ptr is in a nested namespace and
so can only be found by ADL currently. Add a using-declaration so that
qualified std::swap calls will use the std::exception_ptr::swap member,
instead of the generic std::swap.

There's no new test for this, because the generic std::swap works, it
just does more work than is necessary.

Also tell Doxygen to replace the __exception_ptr namespace with
"__unspecified__" in the generate docs, so the real name is not
documented.

libstdc++-v3/ChangeLog:

	* doc/doxygen/user.cfg.in (PREDEFINED): Replace __exception_ptr
	with "__unspecified__".
	* libsupc++/exception_ptr.h: Improve doxygen docs.
	(__exception_ptr::swap): Also declare in namespace std.
2022-05-13 20:40:04 +01:00
Jonathan Wakely
c470f3ea86 libstdc++: Make std::rethrow_if_nested work without RTTI
This allows std::rethrow_if_nested to work with -fno-rtti by not
attempting the dynamic_cast if it requires RTTI, since that's ill-formed
with -fno-rtti. The cast will still work if a static upcast to
std::nested_exception is allowed.

Also use if-constexpr to avoid the compile-time overload resolution (and
SFINAE) and run-time dispatching for std::rethrow_if_nested and
std::throw_with_nested.

Also add better doxygen comments throughout the file.

libstdc++-v3/ChangeLog:

	* libsupc++/nested_exception.h (throw_with_nested) [C++17]: Use
	if-constexpr instead of tag dispatching.
	(rethrow_if_nested) [C++17]: Likewise.
	(rethrow_if_nested) [!__cpp_rtti]: Do not use dynamic_cast if it
	would require RTTI.
	* testsuite/18_support/nested_exception/rethrow_if_nested-term.cc:
	New test.
2022-05-13 20:39:59 +01:00
Jonathan Wakely
a0080f0285 libstdc++: Remove whitespace before preprocessor directives
These are harmless, but also unnecessary and inconsistent (and their
removal was requested by PR libstdc++/17632).

libstdc++-v3/ChangeLog:

	* config/locale/dragonfly/numeric_members.cc: Remove whitespace.
	* config/locale/gnu/numeric_members.cc: Likewise.
	* include/bits/locale_facets_nonio.h: Likewise.
	* libsupc++/typeinfo: Likewise.
2022-05-12 18:04:01 +01:00
Jonathan Wakely
488d268728 libstdc++: Do not use #include inside push visibility scope [PR99871]
libstdc++-v3/ChangeLog:

	PR libstdc++/99871
	* include/bits/specfun.h: Use visibility attribute on namespace,
	instead of pragma push/pop.
	* libsupc++/compare: Likewise.
	* libsupc++/exception: Likewise.
	* libsupc++/exception.h: Likewise.
	* libsupc++/exception_ptr.h: Likewise.
	* libsupc++/initializer_list: Likewise.
	* libsupc++/nested_exception.h: Likewise.
2022-05-06 14:43:39 +01:00
Jonathan Wakely
7f016919fc libstdc++: Add comment about memalign requirements
The memalign man page on Solaris and QNX lists an additional requirement
for the alignment value that is not present in all implementation of
that non-standard function. For both those targets we should actually be
using posix_memalign anyway, so it doesn't matter. This just adds a
comment making note of that fact.

libstdc++-v3/ChangeLog:

	* libsupc++/new_opa.cc (aligned_alloc): Add comment.
2022-03-31 16:18:00 +01:00
Jonathan Wakely
8bbeffc102 libstdc++: Workaround for missing 'using enum' in Clang 12
Once we no longer care about older compilers without this feature, we
can drop these static data members, so the names don't have to be
visible at class scope.

libstdc++-v3/ChangeLog:

	* libsupc++/compare (_Strong_order) [!__cpp_using_enum]: Add
	static data members for _Fp_fmt enumerators.
2022-03-29 10:06:33 +01:00
Jonathan Wakely
b78e0ce28b libstdc++: Define std::expected for C++23 (P0323R12)
Because this adds a new class template called std::unexpected, we have
to stop declaring the std::unexpected() function (which was deprecated
in C++11 and removed in C++17).

libstdc++-v3/ChangeLog:

	* doc/doxygen/user.cfg.in: Add new header.
	* include/Makefile.am: Likewise.
	* include/Makefile.in: Regenerate.
	* include/precompiled/stdc++.h: Add new header.
	* include/std/version (__cpp_lib_expected): Define.
	* libsupc++/exception [__cplusplus > 202002] (unexpected)
	(unexpected_handler, set_unexpected): Do not declare for C++23.
	* include/std/expected: New file.
	* testsuite/20_util/expected/assign.cc: New test.
	* testsuite/20_util/expected/cons.cc: New test.
	* testsuite/20_util/expected/illformed_neg.cc: New test.
	* testsuite/20_util/expected/observers.cc: New test.
	* testsuite/20_util/expected/requirements.cc: New test.
	* testsuite/20_util/expected/swap.cc: New test.
	* testsuite/20_util/expected/synopsis.cc: New test.
	* testsuite/20_util/expected/unexpected.cc: New test.
	* testsuite/20_util/expected/version.cc: New test.
2022-03-27 18:50:31 +01:00
Jonathan Wakely
73f3b8a53e libstdc++: Fix std::strong_order to handle NaN on VAX
I mistakenly believed that VAX floats do not support NaN, but with GCC
__builtin_isnan(__builtin_nan("")) is true. That means my previous
change to <compare> is wrong, because it fails to handle NaN.

When std::numeric_limits<floating-point-type>::is_iec559 is false, as on
VAX, the standard only requires an ordering that is consistent with the
ordering observed by comparison operators. With this change the ordering
is -NaN < numbers < +NaN, and there is no support for different NaN bit
patterns (as I'm not even sure if GCC supports any for VAX).

libstdc++-v3/ChangeLog:

	* libsupc++/compare (_Strong_order::_S_fp_cmp) [__vax__]:
	Handle NaN.
2022-03-10 14:25:46 +00:00
Jonathan Wakely
cfaa2fac42 libstdc++: Support VAX floats in std::strong_order
The VAX float and double format does not support NaN, so the
std::partial_ordering returned by <=> will never be 'unordered'. We can
just use the partial_ordering value as the strong_ordering.

libstdc++-v3/ChangeLog:

	* libsupc++/compare (_Strong_ordering::_S_fp_cmp) [__vax__]: Use
	<=> comparison.
2022-03-10 11:49:00 +00:00
Jonathan Wakely
289f65d643 libstdc++: Fix -Wunused-local-typedefs warning in <compare>
libstdc++-v3/ChangeLog:

	* libsupc++/compare (strong_order::_S_fp_cmp): Move typedef
	inside #if condition.
2022-03-04 10:43:29 +00:00
Jonathan Wakely
9805965e35 libstdc++: Implement std::strong_order for floating-point types [PR96526]
This removes a FIXME in <compare>, defining the total order for
floating-point types. I originally opened PR96526 to request a new
compiler built-in to implement this, but now that we have std::bit_cast
it can be done entirely in the library.

The implementation is based on the glibc definitions of totalorder,
totalorderf, totalorderl etc.

I think this works for all the types that satisfy std::floating_point
today, and should also work for the types expected to be added by P1467
except for std::bfloat16_t. It also supports some additional types that
don't currently satisfy std::floating_point, such as __float80, but we
probably do want that to satisfy the concept for non-strict modes.

libstdc++-v3/ChangeLog:

	PR libstdc++/96526
	* libsupc++/compare (strong_order): Add missing support for
	floating-point types.
	* testsuite/18_support/comparisons/algorithms/strong_order_floats.cc:
	New test.
2022-03-03 22:24:45 +00:00
Jonathan Wakely
27ba40559c libstdc++: Add suggestion to std::uncaught_exception() warning
We should use the SUGGEST macro for std::uncaught_exception()
deprecation warnings.

libstdc++-v3/ChangeLog:

	* include/bits/allocator.h: Qualify std::allocator_traits in
	deprecated warnings.
	* libsupc++/exception (uncaught_exception): Add suggestion to
	deprecated warning.
2022-02-04 15:26:59 +00:00
Jonathan Wakely
b8806796ec libstdc++: Ensure all feature test macros have type long [PR87193]
This defines all the __cpp_lib_xxx macros as type long, as required by
the standard. We had an inconsistent mix of int and long, sometimes even
for the same macro name.

The __cpp_lib_experimental_xxx macros are left as type int, because
that's what it says in the relevant TS specs.

libstdc++-v3/ChangeLog:

	PR libstdc++/87193
	PR libstdc++/104019
	* include/bits/alloc_traits.h (__cpp_lib_allocator_traits_is_always_equal):
	Define as type long.
	* include/bits/allocator.h (__cpp_lib_incomplete_container_elements):
	Likewise.
	* include/bits/basic_string.h (__cpp_lib_string_udls): Likewise.
	* include/bits/chrono.h (__cpp_lib_chrono): Likewise.
	(__cpp_lib_chrono_udls): Likewise.
	* include/bits/move.h (__cpp_lib_addressof_constexpr): Likewise.
	* include/bits/node_handle.h (__cpp_lib_node_extract): Likewise.
	* include/bits/range_access.h (__cpp_lib_nonmember_container_access):
	Likewise.
	* include/bits/shared_ptr.h (__cpp_lib_enable_shared_from_this):
	Likewise.
	* include/bits/stl_algo.h (__cpp_lib_clamp): Likewise.
	(__cpp_lib_sample): Likewise.
	* include/bits/stl_algobase.h (__cpp_lib_robust_nonmodifying_seq_ops):
	Likewise.
	* include/bits/stl_function.h (__cpp_lib_transparent_operators):
	Likewise.
	* include/bits/stl_iterator.h (__cpp_lib_make_reverse_iterator):
	Likewise.
	* include/bits/stl_map.h (__cpp_lib_map_try_emplace):
	Likewise.
	* include/bits/stl_tree.h (__cpp_lib_generic_associative_lookup):
	Likewise.
	* include/bits/unique_ptr.h (__cpp_lib_make_unique):
	Likewise.
	* include/bits/unordered_map.h (__cpp_lib_unordered_map_try_emplace):
	Likewise.
	* include/c_global/cmath (__cpp_lib_hypot): Likewise.
	* include/c_global/cstddef (__cpp_lib_byte): Likewise.
	* include/std/atomic (__cpp_lib_atomic_is_always_lock_free):
	Likewise.
	* include/std/complex (__cpp_lib_complex_udls): Likewise.
	* include/std/filesystem (__cpp_lib_filesystem): Likewise.
	* include/std/functional (__cpp_lib_not_fn): Likewise.
	(__cpp_lib_boyer_moore_searcher): Likewise.
	* include/std/iomanip (__cpp_lib_quoted_string_io): Likewise.
	* include/std/mutex (__cpp_lib_scoped_lock): Likewise.
	* include/std/numeric (__cpp_lib_gcd_lcm): Likewise.
	(__cpp_lib_gcd, __cpp_lib_lcm): Likewise.
	* include/std/tuple (__cpp_lib_apply): Likewise.
	(__cpp_lib_make_from_tuple): Likewise.
	* include/std/type_traits (__cpp_lib_integral_constant_callable)
	(__cpp_lib_bool_constant, __cpp_lib_logical_traits)
	(__cpp_lib_is_null_pointer, __cpp_lib_transformation_trait_aliases)
	(__cpp_lib_result_of_sfinae, __cpp_lib_void_t)
	(__cpp_lib_is_swappable, __cpp_lib_is_invocable)
	(__cpp_lib_has_unique_object_representations)
	(__cpp_lib_is_aggregate): Likewise.
	* include/std/version: Likewise.
	* libsupc++/new (__cpp_lib_launder): Likewise.
2022-01-21 16:07:34 +00:00
Jonathan Wakely
3acb929cc0 libstdc++: Define <stacktrace> header for C++23
Add the <stacktrace> header and a new libstdc++_libbacktrace.a library
that provides the implementation. For now, the new library is only built
if --enable-libstdcxx-backtrace=yes is used. As with the Filesystem TS,
the new library is only provided as a static archive.

libstdc++-v3/ChangeLog:

	* acinclude.m4 (GLIBCXX_ENABLE_BACKTRACE): New macro.
	* configure.ac: Use GLIBCXX_ENABLE_BACKTRACE.
	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/std/stacktrace: New header.
	* include/std/version (__cpp_lib_stacktrace): Define.
	* Makefile.in: Regenerate.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* doc/Makefile.in: Regenerate.
	* libsupc++/Makefile.in: Regenerate.
	* po/Makefile.in: Regenerate.
	* python/Makefile.in: Regenerate.
	* src/Makefile.am: Regenerate.
	* src/Makefile.in: Regenerate.
	* src/c++11/Makefile.in: Regenerate.
	* src/c++17/Makefile.in: Regenerate.
	* src/c++20/Makefile.in: Regenerate.
	* src/c++98/Makefile.in: Regenerate.
	* src/filesystem/Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.
	* src/libbacktrace/Makefile.am: New file.
	* src/libbacktrace/Makefile.in: New file.
	* src/libbacktrace/backtrace-rename.h: New file.
	* src/libbacktrace/backtrace-supported.h.in: New file.
	* src/libbacktrace/config.h.in: New file.
	* testsuite/lib/libstdc++.exp (check_effective_target_stacktrace):
	New proc.
	* testsuite/20_util/stacktrace/entry.cc: New test.
	* testsuite/20_util/stacktrace/synopsis.cc: New test.
	* testsuite/20_util/stacktrace/version.cc: New test.
2022-01-17 12:13:02 +00:00
Jonathan Wakely
68c2e9e923 libstdc++: Fix and simplify freestanding configuration [PR103866]
This fixes the --disable-hosted-libstdcxx build so that it works with
--without-headers. Currently you need to also use --with-newlib, which
is confusing for users who aren't actually using newlib.

The AM_PROG_LIBTOOL checks are currently skipped for --with-newlib and
--with-avrlibc builds, with this change they are also skipped when using
--without-headers.  It would be nice if using --disable-hosted-libstdcxx
automatically skipped those checks, but GLIBCXX_ENABLE_HOSTED comes too
late to make the AM_PROG_LIBTOOL checks depend on $is_hosted.

The checks for EOF, SEEK_CUR etc. cause the build to fail if there is no
<stdio.h> available.  Unlike most headers, which get a HAVE_FOO_H macro,
<stdio.h> is in autoconf's default includes, so every check tries to
include it unconditionally. This change skips those checks for
freestanding builds.

Similarly, the checks for <stdint.h> types done by GCC_HEADER_STDINT try
to include <stdio.h> and fail for --without-headers builds. This change
skips the use of GCC_HEADER_STDINT for freestanding. We can probably
stop using GCC_HEADER_STDINT entirely, since only one file uses the
gstdint.h header that is generated, and that could easily be changed to
use <stdint.h> instead. That can wait for stage 1.

We also need to skip the GLIBCXX_CROSSCONFIG stage if --without-headers
was used, since we don't have any of the functions it deals with.

The end result of the changes above is that it should not be necessary
for a --disable-hosted-libstdcxx --without-headers build to also use
--with-newlib.

Finally, compile libsupc++ with -ffreestanding when --without-headers is
used, so that <stdint.h> will use <gcc-stdint.h> instead of expecting it
to come from libc.

libstdc++-v3/ChangeLog:

	PR libstdc++/103866
	* acinclude.m4 (GLIBCXX_COMPUTE_STDIO_INTEGER_CONSTANTS): Do
	nothing for freestanding builds.
	(GLIBCXX_ENABLE_HOSTED): Define FREESTANDING_FLAGS.
	* configure.ac: Do not use AC_LIBTOOL_DLOPEN when configured
	with --without-headers.  Do not use GCC_HEADER_STDINT for
	freestanding builds.
	* libsupc++/Makefile.am (HOSTED_CXXFLAGS): Use -ffreestanding
	for freestanding builds.
	* configure: Regenerate.
	* Makefile.in: Regenerate.
	* doc/Makefile.in: Regenerate.
	* include/Makefile.in: Regenerate.
	* libsupc++/Makefile.in: Regenerate.
	* po/Makefile.in: Regenerate.
	* python/Makefile.in: Regenerate.
	* src/Makefile.in: Regenerate.
	* src/c++11/Makefile.in: Regenerate.
	* src/c++17/Makefile.in: Regenerate.
	* src/c++20/Makefile.in: Regenerate.
	* src/c++98/Makefile.in: Regenerate.
	* src/filesystem/Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.
2022-01-10 12:18:14 +00:00
Jonathan Wakely
3633cc5428 libstdc++: Implement P1328 "Making std::type_info::operator== constexpr"
This feature is present in the C++23 draft.

With Jakub's recent front-end changes we can implement constexpr
equality by comparing the addresses of std::type_info objects. We do not
need string comparisons, because for constant evaluation cases we know
we aren't dealing with std::type_info objects defined in other
translation units.

The ARM EABI requires that the type_info::operator== function can be
defined out-of-line (and suggests that should be the default), but to be
a constexpr function it must be defined inline (at least for C++23
mode). To meet these conflicting requirements we make the inline version
of operator== call a new __equal function when called at runtime. That
is an alias for the non-inline definition of operator== defined in
libsupc++.

libstdc++-v3/ChangeLog:

	* config/abi/pre/gnu.ver (GLIBCXX_3.4.30): Export new symbol for
	ARM EABI.
	* include/bits/c++config (_GLIBCXX23_CONSTEXPR): Define.
	* include/std/version (__cpp_lib_constexpr_typeinfo): Define.
	* libsupc++/tinfo.cc: Add #error to ensure non-inline definition
	is emitted.
	(type_info::__equal): Define alias symbol.
	* libsupc++/typeinfo (type_info::before): Combine different
	implementations into one.
	(type_info::operator==): Likewise. Use address equality for
	constant evaluation. Call __equal for targets that require the
	definition to be non-inline.
	* testsuite/18_support/type_info/constexpr.cc: New test.
2022-01-05 14:43:01 +00:00
Jakub Jelinek
7adcbafe45 Update copyright years. 2022-01-03 10:42:10 +01:00
Jonathan Wakely
a8e02a00a0 libstdc++: Make std::make_exception_ptr work with -fno-exceptions [PR85813]
This allows std::make_exception_ptr to be used in a translation unit
compiled with -fno-exceptions. This works because the new implementation
added for PR 68297 doesn't need to throw or catch anything. The catch is
there to handle exceptions from the constructor of the exception object,
which we can assume won't happen in a -fno-exceptions TU and so use the
__catch macro instead. If the constructor does throw (because it's
defined in a different TU which was compiled with exceptions enabled)
then that exception will propagate to the make_exception_ptr caller.
That seems acceptable for a program that is trying to mix & match TUs
compiled with and without exceptions, and using types that throw when
constructed. That should be rare, and can't reasonably be expected to
have sensible behaviour.

This also enables the new implementation for targets that use a
non-standard calling convention for the exceptionDestructor callback
(specifically, mingw, which uses __thiscall). All we need to do is mark
the __dest_thunk function template with the right calling convention.

Finally, the useless no-op definition of make_exception_ptr (which is
only used if both RTTI and exceptions are disabled) is marked
always_inline, to ensure that the linker won't keep that definition and
discard the functional ones when both definitions of the function are
present in the link. An alternative would be to add the abi_tag
attribute to the useless definition, but making it always_inline should
work, and it's small enough to always be inlined reliably.

libstdc++-v3/ChangeLog:

	PR libstdc++/85813
	* libsupc++/exception_ptr.h (__dest_thunk): Add macro for
	destructor calling convention.
	(make_exception_ptr): Enable non-throwing implementation for
	-fno-exceptions and for non-standard calling conventions. Use
	always_inline attribute on the useless no-rtti no-exceptions
	definition.
	* testsuite/18_support/exception_ptr/64241.cc: Add -fno-rtti so
	the no-op implementation is still used.
2021-12-09 23:12:20 +00:00
Jonathan Wakely
a1ca039fc0 libstdc++: Fix std::exception_ptr regressions [PR103630]
This restores support for std::make_exception_ptr<E&> and for using
std::exception_ptr in C++98.

Because the new non-throwing implementation needs to use std::decay to
handle references the original throwing implementation is used for
C++98.

We also need to change the typeid expression so it doesn't yield the
dynamic type when the function parameter is a reference to a polymorphic
type. Otherwise the new exception object could be caught by any handler
matching the dynamic type, even though the actual exception object is
only a copy of the base class, sliced to the static type.

libstdc++-v3/ChangeLog:

	PR libstdc++/103630
	* libsupc++/exception_ptr.h (exception_ptr): Fix exception
	specifications on inline definitions.
	(make_exception_ptr): Decay the template parameter. Use typeid
	of the static type.
	* testsuite/18_support/exception_ptr/103630.cc: New test.
2021-12-09 23:02:37 +00:00
Jonathan Wakely
74d14778e7 libstdc++: Define std::__is_constant_evaluated() for internal use
This adds std::__is_constant_evaluated() as a C++11 wrapper for
__builtin_is_constant_evaluated, but just returning false if the
built-in isn't supported by the compiler. This allows us to use it
throughout the library without checking __has_builtin every time.

Some uses in std::vector and std::string can only be constexpr when the
std::is_constant_evaluated() function actually works, so we might as
well guard them with a relevant macro and call that function directly,
rather than the built-in or std::__is_constant_evaluated().

The remaining checks of the __cpp_lib_is_constant_evaluated macro could
now be replaced by checking __cplusplus >= 202002 instead, but there's
no practical difference. We still need some kind of preprocessor check
there anyway.

libstdc++-v3/ChangeLog:

	* doc/doxygen/user.cfg.in (PREDEFINED): Change macro name.
	* include/bits/allocator.h (allocate, deallocate): Use
	std::__is_constant_evaluated() unconditionally, instead of
	checking whether std::is_constant_evaluated() (or the built-in)
	can be used.
	* include/bits/basic_string.h: Check new macro. call
	std::is_constant_evaluated() directly in C++20-only code that is
	guarded by a suitable macro.
	* include/bits/basic_string.tcc: Likewise.
	* include/bits/c++config (__is_constant_evaluated): Define.
	(_GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED): Replace with ...
	(_GLIBCXX_HAVE_IS_CONSTANT_EVALUATED): New macro.
	* include/bits/char_traits.h (char_traits): Replace conditional
	calls to std::is_constant_evaluated with unconditional calls to
	std::__is_constant_evaluated.
	* include/bits/cow_string.h: Use new macro.
	* include/bits/ranges_algobase.h (__copy_or_move): Replace
	conditional calls to std::is_constant_evaluated with unconditional
	calls to std::__is_constant_evaluated.
	(__copy_or_move_backward, __fill_n_fn): Likewise.
	* include/bits/ranges_cmp.h (ranges::less): Likewise.
	* include/bits/stl_algobase.h (lexicographical_compare_three_way):
	Likewise.
	* include/bits/stl_bvector.h: Call std::is_constant_evaluated
	directly in C++20-only code that is guarded by a suitable macro.
	* include/bits/stl_construct.h (_Construct, _Destroy, _Destroy_n):
	Replace is_constant_evaluated with __is_constant_evaluated.
	* include/bits/stl_function.h (greater, less, greater_equal)
	(less_equal): Replace __builtin_is_constant_evaluated and
	__builtin_constant_p with __is_constant_evaluated.
	* include/bits/stl_vector.h: Call std::is_constant_evaluated()
	in C++20-only code.
	* include/debug/helper_functions.h (__check_singular): Use
	__is_constant_evaluated instead of built-in, or remove check
	entirely.
	* include/std/array (operator<=>): Use __is_constant_evaluated
	unconditionally.
	* include/std/bit (__bit_ceil): Likewise.
	* include/std/type_traits (is_constant_evaluated): Define using
	'if consteval' if possible.
	* include/std/version: Use new macro.
	* libsupc++/compare: Use __is_constant_evaluated instead of
	__builtin_is_constant_evaluated.
	* testsuite/23_containers/array/tuple_interface/get_neg.cc:
	Adjust dg-error lines.
2021-12-01 15:00:33 +00:00
Jonathan Wakely
054bf99841 libstdc++: Fix std::type_info::before for ARM [PR103240]
The r179236 fix for std::type_info::operator== should also have been
applied to std::type_info::before. Otherwise two distinct types can
compare equivalent due to using a string comparison, when they should do
a pointer comparison.

libstdc++-v3/ChangeLog:

	PR libstdc++/103240
	* libsupc++/tinfo2.cc (type_info::before): Use unadjusted name
	to check for the '*' prefix.
	* testsuite/util/testsuite_shared.cc: Add type_info object for
	use in new test.
	* testsuite/18_support/type_info/103240.cc: New test.
2021-11-17 17:21:24 +00:00
Jonathan Wakely
f4130a3eb5 libstdc++: Deprecate std::unexpected and handler functions
These functions have been deprecated since C++11, and were removed in
C++17. The proposal P0323 wants to reuse the name std::unexpected for a
class template, so we will need to stop defining the current function
for C++23 anyway.

This marks them as deprecated for C++11 and up, to warn users they won't
continue to be available. It disables them for C++17 and up, unless the
_GLIBCXX_USE_DEPRECATED macro is defined.

The <unwind-cxx.h> header uses std::unexpected_handler in the public
API, but since that type is the same as std::terminate_handler we can
just use that instead, to avoid warnings about it being deprecated.

libstdc++-v3/ChangeLog:

	* doc/xml/manual/evolution.xml: Document deprecations.
	* doc/html/*: Regenerate.
	* libsupc++/exception (unexpected_handler, unexpected)
	(get_unexpected, set_unexpected): Add deprecated attribute.
	Do not define without _GLIBCXX_USE_DEPRECATED for C++17 and up.
	* libsupc++/eh_personality.cc (PERSONALITY_FUNCTION): Disable
	deprecated warnings.
	* libsupc++/eh_ptr.cc (std::rethrow_exception): Likewise.
	* libsupc++/eh_terminate.cc: Likewise.
	* libsupc++/eh_throw.cc (__cxa_init_primary_exception):
	Likewise.
	* libsupc++/unwind-cxx.h (struct __cxa_exception): Use
	terminate_handler instead of unexpected_handler.
	(struct __cxa_dependent_exception): Likewise.
	(__unexpected): Likewise.
	* testsuite/18_support/headers/exception/synopsis.cc: Add
	dg-warning for deprecated warning.
	* testsuite/18_support/exception_ptr/60612-unexpected.cc:
	Disable deprecated warnings.
	* testsuite/18_support/set_unexpected.cc: Likewise.
	* testsuite/18_support/unexpected_handler.cc: Likewise.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/lambda/lambda-eh2.C: Add dg-warning for new
	deprecation warnings.
	* g++.dg/cpp0x/noexcept06.C: Likewise.
	* g++.dg/cpp0x/noexcept07.C: Likewise.
	* g++.dg/eh/forced3.C: Likewise.
	* g++.dg/eh/unexpected1.C: Likewise.
	* g++.old-deja/g++.eh/spec1.C: Likewise.
	* g++.old-deja/g++.eh/spec2.C: Likewise.
	* g++.old-deja/g++.eh/spec3.C: Likewise.
	* g++.old-deja/g++.eh/spec4.C: Likewise.
	* g++.old-deja/g++.mike/eh33.C: Likewise.
	* g++.old-deja/g++.mike/eh34.C: Likewise.
	* g++.old-deja/g++.mike/eh50.C: Likewise.
	* g++.old-deja/g++.mike/eh51.C: Likewise.
2021-11-04 20:53:29 +00:00
Jonathan Wakely
250ddf4c0b libstdc++: Add wrapper for internal uses of std::terminate
This adds an inline wrapper for std::terminate that doesn't add the
declaration of std::terminate to namespace std. This allows the
library to terminate without including all of <exception>.

libstdc++-v3/ChangeLog:

	* include/bits/atomic_timed_wait.h: Remove unused header.
	* include/bits/c++config (std:__terminate): Define.
	* include/bits/semaphore_base.h: Remove <exception> and use
	__terminate instead of terminate.
	* include/bits/std_thread.h: Likewise.
	* libsupc++/eh_terminate.cc (std::terminate): Use qualified-id
	to call __cxxabiv1::__terminate.
2021-10-11 20:35:51 +01:00