Commit graph

854 commits

Author SHA1 Message Date
Jonathan Wakely
21c8708ba6 libstdc++: Fix std::to_array for trivial-ish types [PR115522]
Due to PR c++/85723 the std::is_trivial trait is true for types with a
deleted default constructor, so the use of std::is_trivial in
std::to_array is not sufficient to ensure the type can be trivially
default constructed then filled using memcpy.

I also forgot that a type with a deleted assignment operator can still
be trivial, so we also need to check that it's assignable because the
is_constant_evaluated() path can't use memcpy.

Replace the uses of std::is_trivial with std::is_trivially_copyable
(needed for memcpy), std::is_trivially_default_constructible (needed so
that the default construction is valid and does no work) and
std::is_copy_assignable (needed for the constant evaluation case).

libstdc++-v3/ChangeLog:

	PR libstdc++/115522
	* include/std/array (to_array): Workaround the fact that
	std::is_trivial is not sufficient to check that a type is
	trivially default constructible and assignable.
	* testsuite/23_containers/array/creation/115522.cc: New test.

(cherry picked from commit 510ce5eed69ee1bea9c2c696fe3b2301e16d1486)
2024-07-12 11:12:27 +01:00
Jonathan Wakely
217e778a31 libstdc++: Replace stacktrace effective target with feature test
Rmove the dejagnu code for checking whether std::stacktrace is supported
and just use the new dg-require-cpp-feature-test directive to check for
__cpp_lib_stacktrace instead.

libstdc++-v3/ChangeLog:

	* testsuite/19_diagnostics/stacktrace/current.cc: Check for
	__cpp_lib_stacktrace instead of check for stacktrace ET.
	* testsuite/19_diagnostics/stacktrace/entry.cc: Likewise.
	* testsuite/19_diagnostics/stacktrace/hash.cc: Likewise.
	* testsuite/19_diagnostics/stacktrace/output.cc: Likewise.
	* testsuite/19_diagnostics/stacktrace/stacktrace.cc: Likewise.
	* testsuite/19_diagnostics/stacktrace/synopsis.cc: Likewise.
	* testsuite/19_diagnostics/stacktrace/version.cc: Likewise.
	* testsuite/23_containers/vector/debug/assign4_backtrace_neg.cc:
	Likewise.
	* testsuite/lib/libstdc++.exp (check_effective_target_stacktrace):
	Remove.
2024-03-26 11:32:55 +00:00
Jonathan Wakely
c2e28df90a libstdc++: Destroy allocators in re-inserted container nodes [PR114401]
The allocator objects in container node handles were not being destroyed
after the node was re-inserted into a container. They are stored in a
union and so need to be explicitly destroyed when the node becomes
empty. The containers were zeroing the node handle's pointer, which
makes it empty, causing the handle's destructor to think there's nothign
to clean up.

Add a new member function to the node handle which destroys the
allocator and zeros the pointer. Change the containers to call that
instead of just changing the pointer manually.

We can also remove the _M_empty member of the union which is not
necessary.

libstdc++-v3/ChangeLog:

	PR libstdc++/114401
	* include/bits/hashtable.h (_Hashtable::_M_reinsert_node): Call
	release() on node handle instead of just zeroing its pointer.
	(_Hashtable::_M_reinsert_node_multi): Likewise.
	(_Hashtable::_M_merge_unique): Likewise.
	(_Hashtable::_M_merge_multi): Likewise.
	* include/bits/node_handle.h (_Node_handle_common::release()):
	New member function.
	(_Node_handle_common::_Optional_alloc::_M_empty): Remove
	unnecessary union member.
	(_Node_handle_common): Declare _Hashtable as a friend.
	* include/bits/stl_tree.h (_Rb_tree::_M_reinsert_node_unique):
	Call release() on node handle instead of just zeroing its
	pointer.
	(_Rb_tree::_M_reinsert_node_equal): Likewise.
	(_Rb_tree::_M_reinsert_node_hint_unique): Likewise.
	(_Rb_tree::_M_reinsert_node_hint_equal): Likewise.
	* testsuite/23_containers/multiset/modifiers/114401.cc: New test.
	* testsuite/23_containers/set/modifiers/114401.cc: New test.
	* testsuite/23_containers/unordered_multiset/modifiers/114401.cc: New test.
	* testsuite/23_containers/unordered_set/modifiers/114401.cc: New test.
2024-03-22 22:39:06 +00:00
Jonathan Wakely
142cc4c223 libstdc++: Constrain std::vector default constructor [PR113841]
This is needed to avoid errors outside the immediate context when
evaluating is_default_constructible_v<vector<T, A>> when A is not
default constructible.

To avoid diagnostic regressions for 23_containers/vector/48101_neg.cc we
need to make the std::allocator<cv T> partial specializations default
constructible, which they probably should have been anyway.

libstdc++-v3/ChangeLog:

	PR libstdc++/113841
	* include/bits/allocator.h (allocator<cv T>): Add default
	constructor to partial specializations for cv-qualified types.
	* include/bits/stl_vector.h (_Vector_impl::_Vector_impl()):
	Constrain so that it's only present if the allocator is default
	constructible.
	* include/bits/stl_bvector.h (_Bvector_impl::_Bvector_impl()):
	Likewise.
	* testsuite/23_containers/vector/cons/113841.cc: New test.
2024-03-22 22:39:06 +00:00
François Dumont
dda96a9d94 libstdc++: Fix N3344 behavior on _Safe_iterator::_M_can_advance
We shall be able to advance from a 0 offset a value-initialized iterator.

libstdc++-v3/ChangeLog:

	* include/debug/safe_iterator.tcc (_Safe_iterator<>::_M_can_advance):
	Accept 0 offset advance on value-initialized iterator.
	* testsuite/23_containers/vector/debug/n3644.cc: New test case.
2024-03-18 22:30:55 +01:00
François Dumont
5f6e0853c3 libstdc++: Fix _Safe_local_iterator<>::_M_valid_range
Unordered container local_iterator range shall not contain any singular
iterator unless both iterators are both value-initialized.

libstdc++-v3/ChangeLog:

	* include/debug/safe_local_iterator.tcc
	(_Safe_local_iterator::_M_valid_range): Add _M_value_initialized and
	_M_singular checks.
	* testsuite/23_containers/unordered_set/debug/114316.cc: New test case.
2024-03-18 22:25:57 +01:00
François Dumont
07fad7a7fc libstdc++: Implement N3644 on _Safe_iterator<> [PR114316]
Consider range of value-initialized iterators as valid and empty.

libstdc++-v3/ChangeLog:

	PR libstdc++/114316
	* include/debug/safe_iterator.tcc (_Safe_iterator<>::_M_valid_range):
	First check if both iterators are value-initialized before checking if
	singular.
	* testsuite/23_containers/set/debug/114316.cc: New test case.
	* testsuite/23_containers/vector/debug/114316.cc: New test case.
2024-03-17 16:41:37 +01:00
Jonathan Wakely
709d8474bc libstdc++: Replace unnecessary uses of built-ins in testsuite
I don't see why we should rely on __builtin_memset etc. in tests. We can
just include <cstring> and use the public API.

libstdc++-v3/ChangeLog:

	* testsuite/23_containers/deque/allocator/default_init.cc: Use
	std::memset instead of __builtin_memset.
	* testsuite/23_containers/forward_list/allocator/default_init.cc:
	Likewise.
	* testsuite/23_containers/list/allocator/default_init.cc:
	Likewise.
	* testsuite/23_containers/map/allocator/default_init.cc:
	Likewise.
	* testsuite/23_containers/set/allocator/default_init.cc:
	Likewise.
	* testsuite/23_containers/unordered_map/allocator/default_init.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/allocator/default_init.cc:
	Likewise.
	* testsuite/23_containers/vector/allocator/default_init.cc:
	Likewise.
	* testsuite/23_containers/vector/bool/allocator/default_init.cc:
	Likewise.
	* testsuite/29_atomics/atomic/compare_exchange_padding.cc:
	Likewise.
	* testsuite/util/atomic/wait_notify_util.h: Likewise.
2024-03-07 20:55:25 +00:00
Jonathan Wakely
2d8cd712b1 libstdc++: Add more nodiscard uses in <vector>
Add [[nodiscard]] to vector::at and to comparison operators.

libstdc++-v3/ChangeLog:

	* include/bits/stl_bvector.h (vector<bool, A>::at): Add
	nodiscard.
	* include/bits/stl_vector.h (vector<T, A>::at): Likewise.
	(operator==, operator<=>, operator<, operator!=, operator>)
	(operator<=, operator>=): Likewise.
	* include/debug/vector (operator==, operator<=>, operator<)
	(operator!=, operator>, operator<=, operator>=): Likewise.
	* testsuite/23_containers/vector/nodiscard.cc: New test.
2024-02-28 11:27:46 +00:00
Patrick Palka
3d3145e9e1 libstdc++/debug: Fix constexpr _Safe_iterator in C++20 mode [PR109536]
Some _Safe_iterator member functions define a variable of non-literal
type __gnu_cxx::__scoped_lock, which automatically disqualifies them from
being constexpr in C++20 mode even if that code path is never constant
evaluated.  This restriction was lifted by P2242R3 for C++23, but we
need to work around it in C++20 mode.  To that end this patch defines
a pair of macros that encapsulate the lambda-based workaround mentioned
in that paper and uses it to make these functions valid C++20 constexpr
functions.  The augmented std::vector test element_access/constexpr.cc
now successfully compiles in C++20 mode with -D_GLIBCXX_DEBUG (and it
should test all member functions modified by this patch).

	PR libstdc++/109536

libstdc++-v3/ChangeLog:

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

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2024-01-18 10:36:07 -05:00
François Dumont
46afbeb814 libstdc++: [_GLIBCXX_DEBUG] Fix assignment of value-initialized iterator [PR112477]
Now that _M_Detach do not reset iterator _M_version value we need to reset it when
the iterator is attached to a new sequence, even if this sequencer is null when
assigning a value-initialized iterator. In this case _M_version shall be resetted to 0.

libstdc++-v3/ChangeLog:

	PR libstdc++/112477
	* src/c++11/debug.cc
	(_Safe_iterator_base::_M_attach): Reset _M_version to 0 if attaching to null
	sequence.
	(_Safe_iterator_base::_M_attach_single): Likewise.
	(_Safe_local_iterator_base::_M_attach): Likewise.
	(_Safe_local_iterator_base::_M_attach_single): Likewise.
	* testsuite/23_containers/map/debug/112477.cc: New test case.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2024-01-11 19:29:37 +01:00
Jakub Jelinek
a945c346f5 Update copyright years. 2024-01-03 12:19:35 +01:00
Jonathan Wakely
7d00a59229 libstdc++: Make __gnu_debug::vector usable in constant expressions [PR109536]
This makes constexpr std::vector (mostly) work in Debug Mode. All safe
iterator instrumentation and checking is disabled during constant
evaluation, because it requires mutex locks and calls to non-inline
functions defined in libstdc++.so. It should be OK to disable the safety
checks, because most UB should be detected during constant evaluation
anyway.

We could try to enable the full checking in constexpr, but it would mean
wrapping all the non-inline functions like _M_attach with an inline
_M_constexpr_attach that does the iterator housekeeping inline without
mutex locks when called for constant evaluation, and calls the
non-inline function at runtime. That could be done in future if we find
that we've lost safety or useful checking by disabling the safe
iterators.

There are a few test failures in C++20 mode, which I'm unable to
explain. The _Safe_iterator::operator++() member gives errors for using
non-constexpr functions during constant evaluation, even though those
functions are guarded by std::is_constant_evaluated() checks. The same
code works fine for C++23 and up.

libstdc++-v3/ChangeLog:

	PR libstdc++/109536
	* include/bits/c++config (__glibcxx_constexpr_assert): Remove
	macro.
	* include/bits/stl_algobase.h (__niter_base, __copy_move_a)
	(__copy_move_backward_a, __fill_a, __fill_n_a, __equal_aux)
	(__lexicographical_compare_aux): Add constexpr to overloads for
	debug mode iterators.
	* include/debug/helper_functions.h (__unsafe): Add constexpr.
	* include/debug/macros.h (_GLIBCXX_DEBUG_VERIFY_COND_AT): Remove
	macro, folding it into ...
	(_GLIBCXX_DEBUG_VERIFY_AT_F): ... here. Do not use
	__glibcxx_constexpr_assert.
	* include/debug/safe_base.h (_Safe_iterator_base): Add constexpr
	to some member functions. Omit attaching, detaching and checking
	operations during constant evaluation.
	* include/debug/safe_container.h (_Safe_container): Likewise.
	* include/debug/safe_iterator.h (_Safe_iterator): Likewise.
	* include/debug/safe_iterator.tcc (__niter_base, __copy_move_a)
	(__copy_move_backward_a, __fill_a, __fill_n_a, __equal_aux)
	(__lexicographical_compare_aux): Add constexpr.
	* include/debug/vector (_Safe_vector, vector): Add constexpr.
	Omit safe iterator operations during constant evaluation.
	* testsuite/23_containers/vector/bool/capacity/constexpr.cc:
	Remove dg-xfail-if for debug mode.
	* testsuite/23_containers/vector/bool/cmp_c++20.cc: Likewise.
	* testsuite/23_containers/vector/bool/cons/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/bool/element_access/1.cc:
	Likewise.
	* testsuite/23_containers/vector/bool/element_access/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/bool/modifiers/assign/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/bool/modifiers/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/bool/modifiers/swap/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/capacity/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/cmp_c++20.cc: Likewise.
	* testsuite/23_containers/vector/cons/constexpr.cc: Likewise.
	* testsuite/23_containers/vector/data_access/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/element_access/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/modifiers/assign/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/modifiers/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/modifiers/swap/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/cons/destructible_debug_neg.cc:
	Adjust dg-error line number.
2023-12-14 16:07:48 +00:00
Jason Merrill
c1e54c82a9 c++: partial ordering of object parameter [PR53499]
Looks like we implemented option 1 (skip the object parameter) for CWG532
before the issue was resolved, and never updated to the final resolution of
option 2 (model it as a reference).  More recently CWG2445 extended this
handling to static member functions; I think that's wrong, and have
opened CWG2834 to address that and how explicit object member functions
interact with it.

The FIXME comments are to guide how the explicit object member function
support should change the uses of DECL_NONSTATIC_MEMBER_FUNCTION_P.

The library testsuite changes are to make partial ordering work again
between the generic operator- in the testcase and
_Pointer_adapter::operator-.

	DR 532
	PR c++/53499

gcc/cp/ChangeLog:

	* pt.cc (more_specialized_fn): Fix object parameter handling.

gcc/testsuite/ChangeLog:

	* g++.dg/template/partial-order4.C: New test.
	* g++.dg/template/spec26.C: Adjust for CWG532.

libstdc++-v3/ChangeLog:

	* testsuite/23_containers/vector/ext_pointer/types/1.cc
	* testsuite/23_containers/vector/ext_pointer/types/2.cc
	(N::operator-): Make less specialized.
2023-12-06 09:02:01 -05:00
Jonathan Wakely
5e8a30d8b8 libstdc++: Redefine __glibcxx_assert to work in C++23 constexpr
The changes in r14-5979 to support unknown references in constant
expressions caused some test regressions. The way that __glibcxx_assert
is defined for constant evaluation no longer works when
_GLIBCXX_ASSERTIONS is defined.

This change simplifies __glibcxx_assert so that there is only one check,
rather than a constexpr one and a conditionally-enabled runtime one. The
constexpr one does not need to use __builtin_unreachable to cause a
compilation failure, because __glibcxx_assert_fail is not usable in
constant expressions, so that will cause a failure too.

As well as fixing the regressions, this makes the code for the
assertions shorter and simpler, so should be quicker to compile, and
might inline better too.

libstdc++-v3/ChangeLog:

	* include/bits/c++config (__glibcxx_assert_fail): Declare even
	when assertions are not enabled.
	(__glibcxx_constexpr_assert): Remove macro.
	(__glibcxx_assert_impl): Remove macro.
	(_GLIBCXX_ASSERT_FAIL): New macro.
	(_GLIBCXX_DO_ASSERT): New macro.
	(__glibcxx_assert): Simplify to a single definition that works
	at runtime and during constant evaluation.
	* testsuite/21_strings/basic_string_view/element_access/char/back_constexpr_neg.cc:
	Adjust expected errors.
	* testsuite/21_strings/basic_string_view/element_access/char/constexpr_neg.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/char/front_constexpr_neg.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/back_constexpr_neg.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/constexpr_neg.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/element_access/wchar_t/front_constexpr_neg.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/modifiers/remove_prefix/debug.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/modifiers/remove_suffix/debug.cc:
	Likewise.
	* testsuite/23_containers/span/back_neg.cc: Likewise.
	* testsuite/23_containers/span/front_neg.cc: Likewise.
	* testsuite/23_containers/span/index_op_neg.cc: Likewise.
	* testsuite/26_numerics/lcm/105844.cc: Likewise.
2023-12-05 23:33:22 +00:00
Thomas Schwinge
762b428815 Fix '23_containers/span/at.cc' for '-fno-exceptions' configurations
Added in recent commit 1fa85dcf65
"libstdc++: Add std::span::at for C++26 (P2821R5)", the test case already
does use '#if __cpp_exceptions', but failed to correspondingly guard the
'dg-warning' directives, resulting in:

    FAIL: 23_containers/span/at.cc  -std=gnu++26  (test for warnings, line 15)
    FAIL: 23_containers/span/at.cc  -std=gnu++26  (test for warnings, line 26)
    PASS: 23_containers/span/at.cc  -std=gnu++26 (test for excess errors)
    PASS: 23_containers/span/at.cc  -std=gnu++26 execution test

	libstdc++-v3/
	* testsuite/23_containers/span/at.cc: Fix for '-fno-exceptions'
	configurations.
2023-11-29 14:12:56 +01:00
Jonathan Wakely
43626143c9 libstdc++: Add freestanding feature test macros (P2407R5)
This C++26 change makes several classes "partially freestanding", but we
already fully supported them in freestanding mode. All we need to do is
define the new feature test macros and add tests for them.

libstdc++-v3/ChangeLog:

	* include/bits/version.def (freestanding_algorithm)
	(freestanding_array, freestanding_optional)
	(freestanding_string_view, freestanding_variant): Add.
	* include/bits/version.h: Regenerate.
	* include/std/algorithm (__glibcxx_want_freestanding_algorithm):
	Define.
	* include/std/array (__glibcxx_want_freestanding_array):
	Define.
	* include/std/optional (__glibcxx_want_freestanding_optional):
	Define.
	* include/std/string_view
	(__glibcxx_want_freestanding_string_view): Define.
	* include/std/variant (__glibcxx_want_freestanding_variant):
	Define.
	* testsuite/20_util/optional/version.cc: Add checks for
	__cpp_lib_freestanding_optional.
	* testsuite/20_util/variant/version.cc: Add checks for
	__cpp_lib_freestanding_variant.
	* testsuite/23_containers/array/tuple_interface/get_neg.cc:
	Adjust dg-error line numbers.
	* testsuite/21_strings/basic_string_view/requirements/version.cc:
	New test.
	* testsuite/23_containers/array/requirements/version.cc: New
	test.
	* testsuite/25_algorithms/fill_n/requirements/version.cc: New
	test.
	* testsuite/25_algorithms/swap_ranges/requirements/version.cc:
	New test.
2023-11-21 15:58:21 +00:00
Jonathan Wakely
1fa85dcf65 libstdc++: Add std::span::at for C++26 (P2821R5)
Also define the new feature test macros from P2833R2, indicating that
std::span and std::expected are supported for freestanding mode.

libstdc++-v3/ChangeLog:

	* include/bits/version.def (freestanding_expected): New macro.
	(span): Add C++26 value.
	* include/bits/version.h: Regenerate.
	* include/std/expected (__glibcxx_want_freestanding_expected):
	Define.
	* include/std/span (span::at): New member function.
	* testsuite/20_util/expected/version.cc: Add checks for
	__cpp_lib_freestanding_expected.
	* testsuite/23_containers/span/2.cc: Moved to...
	* testsuite/23_containers/span/version.cc: ...here. Add checks
	for __cpp_lib_span in <span> as well as in <version>.
	* testsuite/23_containers/span/1.cc: Removed.
	* testsuite/23_containers/span/at.cc: New test.
2023-11-21 15:58:21 +00:00
Jonathan Wakely
f4ab68469c libstdc++: Test for feature test macros more accurately
Tests which check for feature test macros should use the no_pch option,
so that we're really testing for the definition being in the intended
header, and not just testing that it's present in <bits/stdc++.h> (which
includes all the standard headers and so defines all the macros).

libstdc++-v3/ChangeLog:

	* testsuite/18_support/byte/requirements.cc: Disable PCH.
	* testsuite/18_support/destroying_delete.cc: Likewise.
	* testsuite/18_support/source_location/1.cc: Likewise.
	* testsuite/18_support/source_location/version.cc: Likewise.
	* testsuite/18_support/type_info/constexpr.cc: Likewise.
	* testsuite/18_support/uncaught_exceptions/uncaught_exceptions.cc:
	Likewise.
	* testsuite/19_diagnostics/stacktrace/output.cc: Likewise.
	* testsuite/19_diagnostics/stacktrace/synopsis.cc: Likewise.
	* testsuite/19_diagnostics/stacktrace/version.cc: Likewise.
	* testsuite/20_util/addressof/requirements/constexpr.cc:
	Likewise.
	* testsuite/20_util/allocator_traits/header-2.cc: Likewise.
	* testsuite/20_util/allocator_traits/header.cc: Likewise.
	* testsuite/20_util/as_const/1.cc: Likewise. Likewise.
	* testsuite/20_util/bitset/cons/constexpr_c++23.cc: Likewise.
	* testsuite/20_util/bitset/version.cc: Likewise.
	* testsuite/20_util/duration/arithmetic/constexpr_c++17.cc:
	Likewise.
	* testsuite/20_util/duration_cast/rounding.cc: Likewise.
	* testsuite/20_util/enable_shared_from_this/members/weak_from_this.cc:
	Likewise.
	* testsuite/20_util/exchange/constexpr.cc: Likewise.
	* testsuite/20_util/expected/synopsis.cc: Likewise.
	* testsuite/20_util/expected/version.cc: Likewise.
	* testsuite/20_util/function_objects/bind_front/1.cc: Likewise.
	* testsuite/20_util/function_objects/bind_front/2.cc: Likewise.
	* testsuite/20_util/function_objects/invoke/3.cc: Likewise.
	* testsuite/20_util/function_objects/invoke/4.cc: Likewise.
	* testsuite/20_util/function_objects/invoke/constexpr.cc:
	Likewise.
	* testsuite/20_util/function_objects/invoke/version.cc:
	Likewise.
	* testsuite/20_util/function_objects/searchers.cc: Likewise.
	* testsuite/20_util/integer_comparisons/1.cc: Likewise.
	* testsuite/20_util/integer_comparisons/2.cc: Likewise.
	* testsuite/20_util/is_bounded_array/value.cc: Likewise.
	* testsuite/20_util/is_layout_compatible/value.cc: Likewise.
	* testsuite/20_util/is_layout_compatible/version.cc: Likewise.
	* testsuite/20_util/is_nothrow_swappable/requirements/explicit_instantiation.cc:
	Likewise.
	* testsuite/20_util/is_nothrow_swappable/requirements/typedefs.cc:
	Likewise.
	* testsuite/20_util/is_nothrow_swappable/value.cc: Likewise.
	* testsuite/20_util/is_nothrow_swappable/value.h: Likewise.
	* testsuite/20_util/is_nothrow_swappable_with/requirements/explicit_instantiation.cc:
	Remove redundant checks already tested elsewhere.
	* testsuite/20_util/is_nothrow_swappable_with/requirements/typedefs.cc:
	Likewise.
	* testsuite/20_util/is_nothrow_swappable_with/value.cc: Disable
	PCH.
	* testsuite/20_util/is_pointer_interconvertible/value.cc:
	Likewise.
	* testsuite/20_util/is_pointer_interconvertible/version.cc:
	Likewise.
	* testsuite/20_util/is_scoped_enum/value.cc: Likewise.
	* testsuite/20_util/is_scoped_enum/version.cc: Likewise.
	* testsuite/20_util/is_swappable/requirements/explicit_instantiation.cc:
	Remove redundant checks already tested elsewhere.
	* testsuite/20_util/is_swappable/requirements/typedefs.cc:
	Remove redundant checks already tested elsewhere.
	* testsuite/20_util/is_swappable/value.cc: Disable PCH.
	* testsuite/20_util/is_swappable/value.h: Reorder headers.
	* testsuite/20_util/is_swappable_with/requirements/explicit_instantiation.cc:
	Remove redundant checks already tested elsewhere.
	* testsuite/20_util/is_swappable_with/requirements/typedefs.cc:
	Remove redundant checks already tested elsewhere.
	* testsuite/20_util/is_swappable_with/value.cc: Disable PCH.
	* testsuite/20_util/is_unbounded_array/value.cc: Likewise.
	* testsuite/20_util/move_only_function/cons.cc: Likewise.
	* testsuite/20_util/move_only_function/version.cc: Likewise.
	* testsuite/20_util/optional/monadic/and_then.cc: Likewise.
	* testsuite/20_util/optional/requirements.cc: Likewise.
	* testsuite/20_util/optional/version.cc: Likewise.
	* testsuite/20_util/owner_less/void.cc: Likewise.
	* testsuite/20_util/reference_from_temporary/value.cc: Likewise.
	* testsuite/20_util/reference_from_temporary/version.cc:
	Likewise.
	* testsuite/20_util/shared_ptr/atomic/atomic_shared_ptr.cc:
	Likewise.
	* testsuite/20_util/shared_ptr/creation/array.cc: Likewise.
	* testsuite/20_util/shared_ptr/creation/overwrite.cc: Likewise.
	* testsuite/20_util/shared_ptr/creation/version.cc: Likewise.
	* testsuite/20_util/time_point_cast/rounding.cc: Likewise.
	* testsuite/20_util/to_chars/constexpr.cc: Likewise.
	* testsuite/20_util/to_chars/result.cc: Likewise.
	* testsuite/20_util/to_chars/version.cc: Likewise.
	* testsuite/20_util/to_underlying/1.cc: Likewise.
	* testsuite/20_util/to_underlying/version.cc: Likewise.
	* testsuite/20_util/tuple/apply/1.cc: Likewise.
	* testsuite/20_util/tuple/cons/constexpr_allocator_arg_t.cc:
	Likewise.
	* testsuite/20_util/tuple/make_from_tuple/1.cc: Likewise.
	* testsuite/20_util/tuple/p2321r2.cc: Likewise.
	* testsuite/20_util/tuple/tuple_element_t.cc: Likewise.
	* testsuite/20_util/unique_ptr/cons/constexpr_c++20.cc:
	Likewise.
	* testsuite/20_util/unique_ptr/creation/for_overwrite.cc:
	Likewise.
	* testsuite/20_util/unreachable/1.cc: Likewise.
	* testsuite/20_util/unreachable/version.cc: Likewise.
	* testsuite/20_util/unwrap_reference/1.cc: Likewise.
	* testsuite/20_util/unwrap_reference/3.cc: Likewise.
	* testsuite/20_util/variant/constexpr.cc: Likewise.
	* testsuite/20_util/variant/version.cc: Likewise.
	* testsuite/20_util/variant/visit_inherited.cc: Likewise.
	* testsuite/20_util/void_t/1.cc: Likewise.
	* testsuite/21_strings/basic_string/capacity/char/resize_and_overwrite.cc:
	Likewise.
	* testsuite/21_strings/basic_string/cons/char/constexpr.cc:
	Likewise.
	* testsuite/21_strings/basic_string/cons/wchar_t/constexpr.cc:
	Likewise.
	* testsuite/21_strings/basic_string/erasure.cc: Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/char/to_string_float.cc:
	Likewise.
	* testsuite/21_strings/basic_string/numeric_conversions/version.cc:
	Likewise.
	* testsuite/21_strings/basic_string/version.cc: Likewise.
	* testsuite/21_strings/basic_string_view/operations/contains/char.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/contains/char/2.cc:
	Likewise.
	* testsuite/21_strings/basic_string_view/operations/copy/char/constexpr.cc:
	Likewise.
	* testsuite/21_strings/char_traits/requirements/constexpr_functions_c++17.cc:
	Likewise.
	* testsuite/21_strings/char_traits/requirements/constexpr_functions_c++20.cc:
	Likewise.
	* testsuite/21_strings/char_traits/requirements/version.cc:
	Likewise.
	* testsuite/23_containers/array/comparison_operators/constexpr.cc:
	Likewise.
	* testsuite/23_containers/array/creation/1.cc: Likewise.
	* testsuite/23_containers/array/creation/2.cc: Likewise.
	* testsuite/23_containers/array/element_access/constexpr_c++17.cc:
	Likewise.
	* testsuite/23_containers/array/requirements/constexpr_fill.cc:
	Likewise.
	* testsuite/23_containers/array/requirements/constexpr_iter.cc:
	Likewise.
	* testsuite/23_containers/deque/erasure.cc: Likewise.
	* testsuite/23_containers/forward_list/erasure.cc: Likewise.
	* testsuite/23_containers/list/erasure.cc: Likewise.
	* testsuite/23_containers/map/erasure.cc: Likewise.
	* testsuite/23_containers/queue/cons_from_iters.cc: Likewise.
	* testsuite/23_containers/set/erasure.cc: Likewise.
	* testsuite/23_containers/span/1.cc: Likewise.
	* testsuite/23_containers/span/2.cc: Likewise.
	* testsuite/23_containers/stack/cons_from_iters.cc: Likewise.
	* testsuite/23_containers/unordered_map/erasure.cc: Likewise.
	* testsuite/23_containers/unordered_map/operations/1.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/erasure.cc: Likewise.
	* testsuite/23_containers/unordered_set/operations/1.cc:
	Likewise.
	* testsuite/23_containers/vector/cons/constexpr.cc: Likewise.
	* testsuite/23_containers/vector/erasure.cc: Likewise.
	* testsuite/23_containers/vector/requirements/version.cc:
	Likewise.
	* testsuite/24_iterators/insert_iterator/constexpr.cc: Likewise.
	* testsuite/25_algorithms/clamp/constexpr.cc: Likewise.
	* testsuite/25_algorithms/clamp/requirements/explicit_instantiation/1.cc:
	Remove redundant checks already tested elsewhere.
	* testsuite/25_algorithms/constexpr_macro.cc: Likewise.
	* testsuite/25_algorithms/cpp_lib_constexpr.cc: Likewise.
	* testsuite/25_algorithms/fold_left/1.cc: Likewise.
	* testsuite/25_algorithms/pstl/feature_test-2.cc: Likewise.
	* testsuite/25_algorithms/pstl/feature_test-3.cc: Likewise.
	* testsuite/25_algorithms/pstl/feature_test-4.cc: Likewise.
	* testsuite/25_algorithms/pstl/feature_test-5.cc: Likewise.
	* testsuite/25_algorithms/pstl/feature_test.cc: Likewise.
	* testsuite/26_numerics/bit/bit.byteswap/byteswap.cc: Likewise.
	* testsuite/26_numerics/bit/bit.byteswap/version.cc: Likewise.
	* testsuite/26_numerics/bit/bit.cast/bit_cast.cc: Likewise.
	* testsuite/26_numerics/bit/bit.cast/version.cc: Likewise.
	* testsuite/26_numerics/bit/header-2.cc: Likewise.
	* testsuite/26_numerics/bit/header.cc: Likewise.
	* testsuite/26_numerics/complex/1.cc: Likewise.
	* testsuite/26_numerics/complex/2.cc: Likewise.
	* testsuite/26_numerics/endian/2.cc: Likewise.
	* testsuite/26_numerics/endian/3.cc: Likewise.
	* testsuite/26_numerics/gcd/1.cc: Likewise.
	* testsuite/26_numerics/lcm/1.cc: Likewise.
	* testsuite/26_numerics/lerp/1.cc: Likewise.
	* testsuite/26_numerics/lerp/version.cc: Likewise.
	* testsuite/26_numerics/midpoint/integral.cc: Likewise.
	* testsuite/26_numerics/midpoint/version.cc: Likewise.
	* testsuite/26_numerics/numbers/1.cc: Likewise.
	* testsuite/26_numerics/numbers/2.cc: Likewise.
	* testsuite/27_io/basic_filebuf/native_handle/char/1.cc:
	Likewise.
	* testsuite/27_io/basic_filebuf/native_handle/version.cc:
	Likewise.
	* testsuite/27_io/basic_ofstream/open/char/noreplace.cc:
	Likewise.
	* testsuite/27_io/basic_ofstream/open/wchar_t/noreplace.cc:
	Likewise.
	* testsuite/27_io/basic_syncbuf/1.cc: Likewise.
	* testsuite/27_io/basic_syncbuf/2.cc: Likewise.
	* testsuite/27_io/basic_syncstream/1.cc: Likewise.
	* testsuite/27_io/basic_syncstream/2.cc: Likewise.
	* testsuite/27_io/spanstream/1.cc: Likewise.
	* testsuite/27_io/spanstream/version.cc: Likewise.
	* testsuite/29_atomics/atomic/cons/value_init.cc: Likewise.
	* testsuite/29_atomics/atomic/lock_free_aliases.cc: Likewise.
	* testsuite/29_atomics/atomic/wait_notify/1.cc: Likewise.
	* testsuite/29_atomics/atomic/wait_notify/2.cc: Likewise.
	* testsuite/29_atomics/headers/stdatomic.h/c_compat.cc:
	Likewise.
	* testsuite/29_atomics/headers/stdatomic.h/version.cc: Likewise.
	* testsuite/30_threads/barrier/1.cc: Likewise.
	* testsuite/30_threads/barrier/2.cc: Likewise.
	* testsuite/30_threads/condition_variable_any/stop_token/1.cc:
	Likewise.
	* testsuite/30_threads/condition_variable_any/stop_token/2.cc:
	Likewise.
	* testsuite/30_threads/jthread/1.cc: Likewise.
	* testsuite/30_threads/jthread/version.cc: Likewise.
	* testsuite/30_threads/latch/1.cc: Likewise.
	* testsuite/30_threads/latch/2.cc: Likewise.
	* testsuite/30_threads/scoped_lock/requirements/typedefs.cc:
	Likewise.
	* testsuite/30_threads/semaphore/1.cc: Likewise.
	* testsuite/30_threads/semaphore/2.cc: Likewise.
	* testsuite/30_threads/stop_token/1.cc: Likewise.
	* testsuite/30_threads/stop_token/2.cc: Likewise.
	* testsuite/experimental/feat-char8_t.cc: Likewise.
	* testsuite/experimental/iterator/ostream_joiner.cc: Likewise.
	* testsuite/experimental/numeric/gcd.cc: Likewise.
	* testsuite/experimental/scopeguard/uniqueres.cc: Likewise.
	* testsuite/std/concepts/1.cc: Likewise.
	* testsuite/std/concepts/2.cc: Likewise.
	* testsuite/std/ranges/adaptors/as_const/1.cc: Likewise.
	* testsuite/std/ranges/adaptors/as_rvalue/1.cc: Likewise.
	* testsuite/std/ranges/adaptors/chunk/1.cc: Likewise.
	* testsuite/std/ranges/adaptors/chunk_by/1.cc: Likewise.
	* testsuite/std/ranges/adaptors/enumerate/1.cc: Likewise.
	* testsuite/std/ranges/adaptors/join_with/1.cc: Likewise.
	* testsuite/std/ranges/adaptors/slide/1.cc: Likewise.
	* testsuite/std/ranges/adaptors/stride/1.cc: Likewise.
	* testsuite/std/ranges/cartesian_product/1.cc: Likewise.
	* testsuite/std/ranges/headers/ranges/synopsis.cc: Likewise.
	* testsuite/std/ranges/repeat/1.cc: Likewise.
	* testsuite/std/ranges/version_c++23.cc: Likewise.
	* testsuite/std/ranges/zip/1.cc: Likewise.
	* testsuite/std/time/syn_c++20.cc: Likewise.
	* testsuite/experimental/feat-cxx14.cc: Likewise. Include
	<algorithm> and <iterator>.
	* testsuite/23_containers/array/tuple_interface/get_neg.cc:
	Adjust dg-error line numbers.
2023-11-16 08:06:59 +00:00
Jonathan Wakely
a92a434024 libstdc++: Add [[nodiscard]] to std::span members
All std::span member functions are pure functions that have no side
effects. They are only useful for their return value, so they should all
warn if that value is not used.

libstdc++-v3/ChangeLog:

	* include/std/span (span, as_bytes, as_writable_bytes): Add
	[[nodiscard]] attribute on all non-void functions.
	* testsuite/23_containers/span/back_assert_neg.cc: Suppress
	nodiscard warning.
	* testsuite/23_containers/span/back_neg.cc: Likewise.
	* testsuite/23_containers/span/first_2_assert_neg.cc: Likewise.
	* testsuite/23_containers/span/first_assert_neg.cc: Likewise.
	* testsuite/23_containers/span/first_neg.cc: Likewise.
	* testsuite/23_containers/span/front_assert_neg.cc: Likewise.
	* testsuite/23_containers/span/front_neg.cc: Likewise.
	* testsuite/23_containers/span/index_op_assert_neg.cc: Likewise.
	* testsuite/23_containers/span/index_op_neg.cc: Likewise.
	* testsuite/23_containers/span/last_2_assert_neg.cc: Likewise.
	* testsuite/23_containers/span/last_assert_neg.cc: Likewise.
	* testsuite/23_containers/span/last_neg.cc: Likewise.
	* testsuite/23_containers/span/subspan_2_assert_neg.cc:
	Likewise.
	* testsuite/23_containers/span/subspan_3_assert_neg.cc:
	Likewise.
	* testsuite/23_containers/span/subspan_4_assert_neg.cc:
	Likewise.
	* testsuite/23_containers/span/subspan_5_assert_neg.cc:
	Likewise.
	* testsuite/23_containers/span/subspan_6_assert_neg.cc:
	Likewise.
	* testsuite/23_containers/span/subspan_assert_neg.cc: Likewise.
	* testsuite/23_containers/span/subspan_neg.cc: Likewise.
	* testsuite/23_containers/span/nodiscard.cc: New test.
2023-11-11 00:41:08 +00:00
François Dumont
c714b4d30d libstdc++: [_Hashtable] Do not reuse untrusted cached hash code
On merge, reuse a merged node's possibly cached hash code only if we are on the
same type of hash and this hash is stateless.

Usage of function pointers or std::function as hash functor will prevent reusing
cached hash code.

libstdc++-v3/ChangeLog

	* include/bits/hashtable_policy.h
	(_Hash_code_base::_M_hash_code(const _Hash&, const _Hash_node_value<>&)): Remove.
	(_Hash_code_base::_M_hash_code<_H2>(const _H2&, const _Hash_node_value<>&)): Remove.
	* include/bits/hashtable.h
	(_M_src_hash_code<_H2>(const _H2&, const key_type&, const __node_value_type&)): New.
	(_M_merge_unique<>, _M_merge_multi<>): Use latter.
	* testsuite/23_containers/unordered_map/modifiers/merge.cc
	(test04, test05, test06): New test cases.
2023-10-19 19:06:08 +02:00
Jonathan Wakely
77cf377302 libstdc++: Prevent unwanted ADL in std::to_array [PR111512]
As noted in PR c++/111512, GCC does ADL for __builtin_memcpy if it is
unqualified, which can cause errors for template argument types which
cannot be completed.

Casting the memcpy arguments to void* prevents ADL from considering the
problem type.

libstdc++-v3/ChangeLog:

	PR libstdc++/111511
	PR c++/111512
	* include/std/array (to_array): Cast memcpy arguments to void*.
	* testsuite/23_containers/array/creation/111512.cc: New test.
2023-09-25 09:48:44 +01:00
Jonathan Wakely
b9a2dce8c4 libstdc++: Remove dg-options "-std=gnu++20" from 23_containers tests
The testsuite will automatically select C++20 for these tests now, and
removing the hardcoded -std option allows them to be tested for C++23
and C++26 as well.

libstdc++-v3/ChangeLog:

	* testsuite/23_containers/array/comparison_operators/96851.cc:
	Remove dg-options -std=gnu++2a.
	* testsuite/23_containers/array/comparison_operators/constexpr.cc:
	Likewise.
	* testsuite/23_containers/array/creation/1.cc: Likewise.
	* testsuite/23_containers/array/creation/110167.cc: Likewise.
	* testsuite/23_containers/array/creation/2.cc: Likewise.
	* testsuite/23_containers/array/creation/3_neg.cc: Likewise.
	* testsuite/23_containers/array/requirements/constexpr_fill.cc:
	Likewise.
	* testsuite/23_containers/array/requirements/constexpr_swap.cc:
	Likewise.
	* testsuite/23_containers/deque/48101-3_neg.cc: Likewise.
	* testsuite/23_containers/deque/erasure.cc: Likewise.
	* testsuite/23_containers/deque/modifiers/emplace/92878_92947.cc:
	Likewise.
	* testsuite/23_containers/deque/operators/cmp_c++20.cc:
	Likewise.
	* testsuite/23_containers/forward_list/48101-3_neg.cc: Likewise.
	* testsuite/23_containers/forward_list/cmp_c++20.cc: Likewise.
	* testsuite/23_containers/forward_list/erasure.cc: Likewise.
	* testsuite/23_containers/forward_list/modifiers/92878_92947.cc:
	Likewise.
	* testsuite/23_containers/forward_list/operations/remove_cxx20_return.cc:
	Likewise.
	* testsuite/23_containers/forward_list/operations/unique_cxx20_return.cc:
	Likewise.
	* testsuite/23_containers/list/48101-3_neg.cc: Likewise.
	* testsuite/23_containers/list/cmp_c++20.cc: Likewise.
	* testsuite/23_containers/list/erasure.cc: Likewise.
	* testsuite/23_containers/list/modifiers/emplace/92878_92947.cc:
	Likewise.
	* testsuite/23_containers/list/operations/remove_cxx20_return.cc:
	Likewise.
	* testsuite/23_containers/list/operations/unique_cxx20_return.cc:
	Likewise.
	* testsuite/23_containers/map/48101-3_neg.cc: Likewise.
	* testsuite/23_containers/map/erasure.cc: Likewise.
	* testsuite/23_containers/map/modifiers/emplace/92878_92947.cc:
	Likewise.
	* testsuite/23_containers/map/operations/contains.cc: Likewise.
	* testsuite/23_containers/map/operators/cmp_c++20.cc: Likewise.
	* testsuite/23_containers/multimap/48101-3_neg.cc: Likewise.
	* testsuite/23_containers/multimap/modifiers/emplace/92878_92947.cc:
	Likewise.
	* testsuite/23_containers/multimap/operations/contains.cc:
	Likewise.
	* testsuite/23_containers/multimap/operators/cmp_c++20.cc:
	Likewise.
	* testsuite/23_containers/multiset/48101-3_neg.cc: Likewise.
	* testsuite/23_containers/multiset/modifiers/emplace/92878_92947.cc:
	Likewise.
	* testsuite/23_containers/multiset/operations/contains.cc:
	Likewise.
	* testsuite/23_containers/multiset/operators/cmp_c++20.cc:
	Likewise.
	* testsuite/23_containers/priority_queue/92878_92947.cc:
	Likewise.
	* testsuite/23_containers/queue/92878_92947.cc: Likewise.
	* testsuite/23_containers/queue/cmp_c++20.cc: Likewise.
	* testsuite/23_containers/set/48101-3_neg.cc: Likewise.
	* testsuite/23_containers/set/erasure.cc: Likewise.
	* testsuite/23_containers/set/modifiers/emplace/92878_92947.cc:
	Likewise.
	* testsuite/23_containers/set/operations/contains.cc: Likewise.
	* testsuite/23_containers/set/operators/cmp_c++20.cc: Likewise.
	* testsuite/23_containers/span/1.cc: Likewise.
	* testsuite/23_containers/span/101411.cc: Likewise.
	* testsuite/23_containers/span/2.cc: Likewise.
	* testsuite/23_containers/span/deduction.cc: Likewise.
	* testsuite/23_containers/span/explicit.cc: Likewise.
	* testsuite/23_containers/span/layout_compat.cc: Likewise.
	* testsuite/23_containers/span/lwg3255.cc: Likewise.
	* testsuite/23_containers/span/nothrow_cons.cc: Likewise.
	* testsuite/23_containers/span/trivially_copyable.cc: Likewise.
	* testsuite/23_containers/stack/92878_92947.cc: Likewise.
	* testsuite/23_containers/stack/cmp_c++20.cc: Likewise.
	* testsuite/23_containers/unordered_map/48101-3_neg.cc:
	Likewise.
	* testsuite/23_containers/unordered_map/erasure.cc: Likewise.
	* testsuite/23_containers/unordered_map/modifiers/92878_92947.cc:
	Likewise.
	* testsuite/23_containers/unordered_map/operations/1.cc:
	Likewise.
	* testsuite/23_containers/unordered_map/operations/contains.cc:
	Likewise.
	* testsuite/23_containers/unordered_multimap/48101-3_neg.cc:
	Likewise.
	* testsuite/23_containers/unordered_multimap/modifiers/92878_92947.cc:
	Likewise.
	* testsuite/23_containers/unordered_multimap/operations/1.cc:
	Likewise.
	* testsuite/23_containers/unordered_multimap/operations/contains.cc:
	Likewise.
	* testsuite/23_containers/unordered_multiset/48101-3_neg.cc:
	Likewise.
	* testsuite/23_containers/unordered_multiset/modifiers/92878_92947.cc:
	Likewise.
	* testsuite/23_containers/unordered_multiset/operations/1.cc:
	Likewise.
	* testsuite/23_containers/unordered_multiset/operations/contains.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/48101-3_neg.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/erasure.cc: Likewise.
	* testsuite/23_containers/unordered_set/modifiers/92878_92947.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/operations/1.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/operations/contains.cc:
	Likewise.
	* testsuite/23_containers/vector/48101-3_neg.cc: Likewise.
	* testsuite/23_containers/vector/bool/capacity/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/bool/cmp_c++20.cc: Likewise.
	* testsuite/23_containers/vector/bool/cons/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/bool/element_access/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/bool/iterator_c++20.cc:
	Likewise.
	* testsuite/23_containers/vector/bool/modifiers/assign/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/bool/modifiers/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/bool/modifiers/swap/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/capacity/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/cmp_c++20.cc: Likewise.
	* testsuite/23_containers/vector/cons/constexpr.cc: Likewise.
	* testsuite/23_containers/vector/data_access/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/element_access/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/erasure.cc: Likewise.
	* testsuite/23_containers/vector/modifiers/assign/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/modifiers/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/modifiers/emplace/92878_92947.cc:
	Likewise.
	* testsuite/23_containers/vector/modifiers/swap/constexpr.cc:
	Likewise.
	* testsuite/23_containers/vector/requirements/version.cc:
	Likewise.
2023-09-16 00:10:45 +01:00
Jonathan Wakely
ed8fcd0df5 libstdc++: Remove dg-options "-std=gnu++2a" from XFAIL std::span tests
The testsuite will automatically select C++20 for these tests now, and
removing the hardcoded -std option allows them to be tested for C++23
and C++26 as well.

We can also combine the { dg-require-effective-target c++2a } directive
with the dg-do selector.

We need to add the no_pch options for tests that define
_GLIBCXX_ASSERTIONS in the test, otherwise the PCH is included without
that defined.

libstdc++-v3/ChangeLog:

	* testsuite/23_containers/span/back_assert_neg.cc: Remove
	dg-options and add effective target selector to dg-do. Add
	no_pch.
	* testsuite/23_containers/span/back_neg.cc: Likewise.
	* testsuite/23_containers/span/cons_1_assert_neg.cc: Likewise.
	* testsuite/23_containers/span/cons_2_assert_neg.cc: Likewise.
	* testsuite/23_containers/span/first_2_assert_neg.cc: Likewise.
	* testsuite/23_containers/span/first_assert_neg.cc: Likewise.
	* testsuite/23_containers/span/first_neg.cc: Likewise.
	* testsuite/23_containers/span/front_assert_neg.cc: Likewise.
	* testsuite/23_containers/span/front_neg.cc: Likewise.
	* testsuite/23_containers/span/index_op_assert_neg.cc: Likewise.
	* testsuite/23_containers/span/index_op_neg.cc: Likewise.
	* testsuite/23_containers/span/last_2_assert_neg.cc: Likewise.
	* testsuite/23_containers/span/last_assert_neg.cc: Likewise.
	* testsuite/23_containers/span/last_neg.cc: Likewise.
	* testsuite/23_containers/span/subspan_2_assert_neg.cc:
	Likewise.
	* testsuite/23_containers/span/subspan_3_assert_neg.cc:
	Likewise.
	* testsuite/23_containers/span/subspan_4_assert_neg.cc:
	Likewise.
	* testsuite/23_containers/span/subspan_5_assert_neg.cc:
	Likewise.
	* testsuite/23_containers/span/subspan_6_assert_neg.cc:
	Likewise.
	* testsuite/23_containers/span/subspan_assert_neg.cc: Likewise.
	* testsuite/23_containers/span/subspan_neg.cc: Likewise.
	* testsuite/24_iterators/range_operations/advance_debug_neg.cc:
	Likewise.
2023-09-15 21:57:40 +01:00
Jonathan Wakely
7810fb3a14 libstdc++: Remove dg-options "-std=gnu++23" from remaining tests
The testsuite will automatically select C++23 for these tests now, and
removing the hardcoded -std option allows them to be tested for C++26
as well.

libstdc++-v3/ChangeLog:

	* testsuite/18_support/headers/limits/synopsis_cxx23.cc: Remove
	dg-options.
	* testsuite/18_support/headers/stdfloat/types_std.cc: Likewise.
	* testsuite/18_support/type_info/constexpr.cc: Likewise.
	* testsuite/19_diagnostics/stacktrace/current.cc: Likewise.
	* testsuite/19_diagnostics/stacktrace/entry.cc: Likewise.
	* testsuite/19_diagnostics/stacktrace/stacktrace.cc: Likewise.
	* testsuite/19_diagnostics/stacktrace/synopsis.cc: Likewise.
	* testsuite/19_diagnostics/stacktrace/version.cc: Likewise.
	* testsuite/20_util/aligned_storage/deprecated-2b.cc: Likewise.
	* testsuite/20_util/aligned_union/deprecated-2b.cc: Likewise.
	* testsuite/20_util/bitset/access/constexpr.cc: Likewise.
	* testsuite/20_util/bitset/cons/constexpr_c++23.cc: Likewise.
	* testsuite/20_util/bitset/count/constexpr.cc: Likewise.
	* testsuite/20_util/bitset/ext/constexpr.cc: Likewise.
	* testsuite/20_util/bitset/operations/constexpr_c++23.cc:
	Likewise.
	* testsuite/20_util/bitset/version.cc: Likewise.
	* testsuite/20_util/from_chars/8.cc: Likewise.
	* testsuite/20_util/from_chars/constexpr.cc: Likewise.
	* testsuite/20_util/function/cons/deduction_c++23.cc: Likewise.
	* testsuite/20_util/function_objects/invoke/4.cc: Likewise.
	* testsuite/20_util/function_objects/invoke/dangling_ref.cc:
	Likewise.
	* testsuite/20_util/is_scoped_enum/value.cc: Likewise.
	* testsuite/20_util/is_scoped_enum/version.cc: Likewise.
	* testsuite/20_util/move_only_function/call.cc: Likewise.
	* testsuite/20_util/move_only_function/cons.cc: Likewise.
	* testsuite/20_util/move_only_function/move.cc: Likewise.
	* testsuite/20_util/move_only_function/version.cc: Likewise.
	* testsuite/20_util/optional/monadic/and_then.cc: Likewise.
	* testsuite/20_util/optional/monadic/or_else.cc: Likewise.
	* testsuite/20_util/optional/monadic/or_else_neg.cc: Likewise.
	* testsuite/20_util/optional/monadic/pr109242.cc: Likewise.
	* testsuite/20_util/optional/monadic/transform.cc: Likewise.
	* testsuite/20_util/pair/p2321r2.cc: Likewise.
	* testsuite/20_util/reference_from_temporary/value.cc: Likewise.
	* testsuite/20_util/reference_from_temporary/value2.cc:
	Likewise.
	* testsuite/20_util/reference_from_temporary/version.cc:
	Likewise.
	* testsuite/20_util/to_chars/constexpr.cc: Likewise.
	* testsuite/20_util/to_chars/float128_c++23.cc: Likewise.
	* testsuite/20_util/to_chars/float16_c++23.cc: Likewise.
	* testsuite/20_util/to_chars/version.cc: Likewise.
	* testsuite/20_util/to_underlying/1.cc: Likewise.
	* testsuite/20_util/to_underlying/version.cc: Likewise.
	* testsuite/20_util/tuple/p2321r2.cc: Likewise.
	* testsuite/20_util/unique_ptr/assign/constexpr.cc: Likewise.
	* testsuite/20_util/unique_ptr/comparison/constexpr.cc:
	Likewise.
	* testsuite/20_util/unique_ptr/cons/constexpr_c++20.cc:
	Likewise.
	* testsuite/20_util/unique_ptr/creation/constexpr.cc: Likewise.
	* testsuite/20_util/unique_ptr/modifiers/constexpr.cc: Likewise.
	* testsuite/20_util/unique_ptr/specialized_algorithms/constexpr.cc: Likewise.
	* testsuite/20_util/unreachable/1.cc: Likewise.
	* testsuite/20_util/unreachable/version.cc: Likewise.
	* testsuite/20_util/uses_allocator/lwg3677.cc: Likewise.
	* testsuite/21_strings/basic_string/capacity/char/resize_and_overwrite.cc: Likewise.
	* testsuite/21_strings/basic_string/operations/contains/char.cc:
	Likewise.
	* testsuite/21_strings/basic_string/operations/contains/nonnull.cc: Likewise.
	* testsuite/21_strings/basic_string/operations/contains/wchar_t.cc: Likewise.
	* testsuite/21_strings/basic_string_view/cons/char/range_c++20.cc: Likewise.
	* testsuite/21_strings/basic_string_view/cons/wchar_t/range_c++20.cc: Likewise.
	* testsuite/21_strings/basic_string_view/operations/contains/char.cc: Likewise.
	* testsuite/21_strings/basic_string_view/operations/contains/char/2.cc: Likewise.
	* testsuite/21_strings/basic_string_view/operations/contains/nonnull.cc: Likewise.
	* testsuite/21_strings/basic_string_view/operations/contains/wchar_t.cc: Likewise.
	* testsuite/23_containers/queue/cons_from_iters.cc: Likewise.
	* testsuite/23_containers/stack/cons_from_iters.cc: Likewise.
	* testsuite/23_containers/vector/bool/element_access/1.cc:
	Likewise.
	* testsuite/24_iterators/const_iterator/1.cc: Likewise.
	* testsuite/25_algorithms/contains/1.cc: Likewise.
	* testsuite/25_algorithms/contains_subrange/1.cc: Likewise.
	* testsuite/25_algorithms/find_last/1.cc: Likewise.
	* testsuite/25_algorithms/find_last_if/1.cc: Likewise.
	* testsuite/25_algorithms/find_last_if_not/1.cc: Likewise.
	* testsuite/25_algorithms/fold_left/1.cc: Likewise.
	* testsuite/25_algorithms/fold_right/1.cc: Likewise.
	* testsuite/25_algorithms/iota/1.cc: Likewise.
	* testsuite/26_numerics/bit/bit.byteswap/byteswap.cc: Likewise.
	* testsuite/26_numerics/bit/bit.byteswap/version.cc: Likewise.
	* testsuite/26_numerics/complex/ext_c++23.cc: Likewise.
	* testsuite/26_numerics/headers/cmath/c99_classification_macros_c++23.cc: Likewise.
	* testsuite/26_numerics/headers/cmath/constexpr_std_c++23.cc:
	Likewise.
	* testsuite/26_numerics/headers/cmath/functions_std_c++23.cc:
	Likewise.
	* testsuite/26_numerics/headers/cmath/nextafter_c++23.cc:
	Likewise.
	* testsuite/26_numerics/numbers/4.cc: Likewise.
	* testsuite/27_io/basic_ostream/inserters_other/char/volatile_ptr.cc: Likewise.
	* testsuite/27_io/filesystem/path/native/conv_c++23.cc:
	Likewise.
	* testsuite/27_io/spanstream/1.cc: Likewise.
	* testsuite/27_io/spanstream/2.cc: Likewise.
	* testsuite/27_io/spanstream/version.cc: Likewise.
	* testsuite/29_atomics/atomic_float/requirements_cxx23.cc:
	Likewise.
	* testsuite/29_atomics/headers/stdatomic.h/c_compat.cc:
	Likewise.
	* testsuite/29_atomics/headers/stdatomic.h/version.cc: Likewise.
	* testsuite/30_threads/packaged_task/cons/deduction_c++23.cc:
	Likewise.
	* testsuite/experimental/filesystem/path/native/conv_c++23.cc:
	Likewise.
	* testsuite/std/ranges/adaptors/adjacent/1.cc: Likewise.
	* testsuite/std/ranges/adaptors/adjacent_transform/1.cc:
	Likewise.
	* testsuite/std/ranges/adaptors/as_const/1.cc: Likewise.
	* testsuite/std/ranges/adaptors/as_rvalue/1.cc: Likewise.
	* testsuite/std/ranges/adaptors/chunk/1.cc: Likewise.
	* testsuite/std/ranges/adaptors/chunk_by/1.cc: Likewise.
	* testsuite/std/ranges/adaptors/enumerate/1.cc: Likewise.
	* testsuite/std/ranges/adaptors/join_with/1.cc: Likewise.
	* testsuite/std/ranges/adaptors/lwg3715.cc: Likewise.
	* testsuite/std/ranges/adaptors/slide/1.cc: Likewise.
	* testsuite/std/ranges/adaptors/stride/1.cc: Likewise.
	* testsuite/std/ranges/cartesian_product/1.cc: Likewise.
	* testsuite/std/ranges/range_adaptor_closure.cc: Likewise.
	* testsuite/std/ranges/repeat/1.cc: Likewise.
	* testsuite/std/ranges/version_c++23.cc: Likewise.
	* testsuite/std/ranges/zip/1.cc: Likewise.
	* testsuite/std/ranges/zip_transform/1.cc: Likewise.
2023-09-15 21:57:40 +01:00
Jonathan Wakely
5d066729ff libstdc++: Remove dg-options "-std=c++20" from <span> and <cuchar> tests
The testsuite will automatically select C++20 for these tests now, and
removing the hardcoded -std option allows them to be tested for C++23
and C++26 as well.

There doesn't seem to be any reason they need to use strict -std=c++20
mode, so don't add the { dg-add-options strict_std } directive, just let
them use strict or non-strict modes.

libstdc++-v3/ChangeLog:

	* testsuite/21_strings/headers/cuchar/functions_std_cxx20.cc:
	Remove dg-options.
	* testsuite/23_containers/span/contiguous_range_neg.cc:
	Likewise.
	* testsuite/23_containers/span/everything.cc: Likewise.
2023-09-15 21:57:39 +01:00
Jonathan Wakely
52841fb703 libstdc++: Replace dg-options "-std=c++11" with dg-add-options strict_std
These tests can (and should) also be run for later standards, so replace
the { dg-options "-std=c++11" } with { dg-add-options strict_std } and a
target selector for c++11.

libstdc++-v3/ChangeLog:

	* testsuite/23_containers/deque/48101-2_neg.cc: Replace
	dg-options with target selector.
	* testsuite/23_containers/forward_list/48101-2_neg.cc: Likewise.
	* testsuite/23_containers/list/48101-2_neg.cc: Likewise.
	* testsuite/23_containers/map/48101-2_neg.cc: Likewise.
	* testsuite/23_containers/map/48101_neg.cc: Likewise.
	* testsuite/23_containers/multimap/48101-2_neg.cc: Likewise.
	* testsuite/23_containers/multimap/48101_neg.cc: Likewise.
	* testsuite/23_containers/multiset/48101-2_neg.cc: Likewise.
	* testsuite/23_containers/set/48101-2_neg.cc: Likewise.
	* testsuite/23_containers/unordered_map/48101-2_neg.cc:
	Likewise.
	* testsuite/23_containers/unordered_multimap/48101-2_neg.cc:
	Likewise.
	* testsuite/23_containers/unordered_multiset/48101-2_neg.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/48101-2_neg.cc:
	Likewise.
	* testsuite/23_containers/vector/48101-2_neg.cc: Likewise.
2023-09-15 21:57:38 +01:00
Jonathan Wakely
b96b554592 libstdc++: Add Filesystem TS and std::stacktrace symbols to libstdc++exp.a
This consolidates the three static archives for extensions into one, so
that -lstdc++exp can be used to provide the definitions of all unstable
library features.

The libstdc++_libbacktrace.a archive is now just a "noinst" convenience
library that is only used during the build, not installed. Its contents
are added to libstdc++exp.a, along with the new non-inline definitions
of std::stacktrace symbols.

The libstdc++fs.a archive is still installed, but its contents are
duplicated in libstdc++exp.a now. This means -lstdc++exp can be used
instead of -lstdc++fs. For targets using the GNU linker we should
consider replacing libstdc++fs.a with a linker script that does
INPUT(libstdc++exp.a).

The tests for <experimental/filesystem> could be changed to use
-lstdc++exp instead of -lstdc++fs, which would allow removing
src/filesystem/.libs from the LDFLAGS in scripts/testsuite_flags.in,
but that can be done at a later date.

libstdc++-v3/ChangeLog:

	* acinclude.m4 (GLIBCXX_CONFIGURE): Add c++23 directory.
	* configure: Regenerate.
	* doc/html/manual/*: Regenerate.
	* doc/xml/manual/using.xml: Update documentation on linking.
	* include/std/stacktrace: Remove declarations of libbacktrace
	APIs.
	(stacktrace_entry::_S_err_handler, stacktrace_entry::_S_init):
	Remove.
	(stacktrace_entry::_Info): New class.
	(stacktrace_entry::_M_get_info): Use _Info.
	(__stacktrace_impl): New class.
	(basic_stacktrace): Derive from __stacktrace_impl.
	(basic_stacktrace::current): Use __stacktrace_impl::_S_current.
	* scripts/testsuite_flags.in: Adjust LDFLAGS to find
	libstdc++exp instead of libstdc++_libbacktrace.
	* src/Makefile.am (SUBDIRS): Add c++23 directory.
	* src/Makefile.in: Regenerate.
	* src/c++20/Makefile.am: Fix comment.
	* src/c++20/Makefile.in: Regenerate.
	* src/c++23/Makefile.am: New file.
	* src/c++23/Makefile.in: New file.
	* src/c++23/stacktrace.cc: New file with definitions of
	stacktrace_entry::_Info and __stacktrace_impl members.
	* src/experimental/Makefile.am: Use LIBADD to include other
	libraries.
	* src/experimental/Makefile.in: Regenerate.
	* src/libbacktrace/Makefile.am: Use noinst_LTLIBRARIES.
	* src/libbacktrace/Makefile.in: Regenerate.
	* testsuite/19_diagnostics/stacktrace/current.cc: Adjust
	dg-options to use -lstdc++exp.
	* testsuite/19_diagnostics/stacktrace/entry.cc: Likewise.
	* testsuite/19_diagnostics/stacktrace/stacktrace.cc: Likewise.
	* testsuite/23_containers/vector/debug/assign4_backtrace_neg.cc:
	Likewise.
2023-09-08 18:04:12 +01:00
Jonathan Wakely
b1ca841b89 libstdc++: Fix missing/misplaced { dg-options "-std=gnu++20" } in tests
These tests do not run by default, because the c++20 effective target
selector isn't matched.

libstdc++-v3/ChangeLog:

	* testsuite/23_containers/unordered_map/operations/1.cc: Add
	dg-options for C++20 mode.
	* testsuite/23_containers/unordered_multimap/operations/1.cc:
	Likewise.
	* testsuite/23_containers/unordered_multiset/operations/1.cc:
	Likewise.
	* testsuite/23_containers/unordered_set/operations/1.cc:
	Likewise.
	* testsuite/std/time/parse.cc: Move dg-options before dg-do.
2023-09-07 08:10:53 +01:00
Jonathan Wakely
affbb7b432 libstdc++: Fix filenames and comments in tests [PR26142]
These tests have transposed digits in the filenames and comments.

libstdc++-v3/ChangeLog:

	PR libstdc++/26142
	* testsuite/23_containers/vector/26412-1.cc: Moved to...
	* testsuite/23_containers/vector/26142-1.cc: ...here.
	* testsuite/23_containers/vector/26412-2.cc: Moved to...
	* testsuite/23_containers/vector/26142-2.cc: ...here.
2023-09-04 16:24:35 +01:00
Jonathan Wakely
0eb35092de libstdc++: Add explicit -std=gnu++98 to tests that use { target c++98_only }
libstdc++-v3/ChangeLog:

	* testsuite/23_containers/deque/requirements/explicit_instantiation/2.cc:
	Add dg-options to restrict the test to C++98 mode.
	* testsuite/23_containers/list/requirements/explicit_instantiation/2.cc:
	Likewise.
2023-09-04 16:04:26 +01:00
François Dumont
2aa8ebc0a6 libstdc++: Fix tests relying on operator new/delete overload
Fix tests that are checking for an expected allocation plan. They are failing if
an allocation is taking place outside the test main.

libstdc++-v3/ChangeLog

	* testsuite/util/replacement_memory_operators.h
	(counter::scope): New, capture and reset counter count at construction and
	restore it at destruction.
	(counter::check_new): Add scope instantiation.
	* testsuite/23_containers/unordered_map/96088.cc (main):
	Add counter::scope instantiation.
	* testsuite/23_containers/unordered_multimap/96088.cc (main): Likewise.
	* testsuite/23_containers/unordered_multiset/96088.cc (main): Likewise.
	* testsuite/23_containers/unordered_set/96088.cc (main): Likewise.
	* testsuite/ext/malloc_allocator/deallocate_local.cc (main): Likewise.
	* testsuite/ext/new_allocator/deallocate_local.cc (main): Likewise.
	* testsuite/ext/throw_allocator/deallocate_local.cc (main): Likewise.
	* testsuite/ext/pool_allocator/allocate_chunk.cc (started): New global.
	(operator new(size_t)): Check started.
	(main): Set/Unset started.
	* testsuite/17_intro/no_library_allocation.cc: New test case.
2023-08-23 06:35:24 +02: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
Jonathan Wakely
f30e62b0ee libstdc++: Require C++11 for 23_containers/vector/bool/110807.cc [PR110807]
This new test uses uniform initialization syntax, so requires C++11 or
later.

libstdc++-v3/ChangeLog:

	PR libstdc++/110807
	* testsuite/23_containers/vector/bool/110807.cc: Require c++11.
2023-07-26 19:10:11 +01:00
Jonathan Wakely
7931a1de9e libstdc++: Avoid bogus overflow warnings in std::vector<bool> [PR110807]
GCC thinks the allocation can alter the object being copied if it's
globally reachable, so doesn't realize that [x.begin(), x.end()) after
the allocation is the same as x.size() before it.

This causes a testsuite failure when testing with -D_GLIBCXX_DEBUG:
FAIL: 23_containers/vector/bool/swap.cc (test for excess errors)
A fix is to move the calls to x.begin() and x.end() to before the
allocation.

A similar problem exists in vector<bool>::_M_insert_range where *this is
globally reachable, as reported in PR libstdc++/110807. That can also be
fixed by moving calls to begin() and end() before the allocation.

libstdc++-v3/ChangeLog:

	PR libstdc++/110807
	* include/bits/stl_bvector.h (vector(const vector&)): Access
	iterators before allocating.
	* include/bits/vector.tcc (vector<bool>::_M_insert_range):
	Likewise.
	* testsuite/23_containers/vector/bool/110807.cc: New test.
2023-07-26 17:02:46 +01:00
Jonathan Wakely
cd9964b7e2 libstdc++: Disable std::forward_list tests for C++98 mode
These tests fail with -std=gnu++98/-D_GLIBCXX_DEBUG in the runtest
flags. They should require the c++11 effective target.

libstdc++-v3/ChangeLog:

	* testsuite/23_containers/forward_list/debug/iterator1_neg.cc:
	Skip as UNSUPPORTED for C++98 mode.
	* testsuite/23_containers/forward_list/debug/iterator3_neg.cc:
	Likewise.
2023-07-05 07:39:04 +01:00
Jonathan Wakely
33245d6b87 libstdc++: Qualify calls to std::_Destroy and _Destroy_aux
These calls should be qualified to prevent ADL, which can cause errors
for incomplete types that are associated classes.

libstdc++-v3/ChangeLog:

	* include/bits/alloc_traits.h (_Destroy): Qualify call.
	* include/bits/stl_construct.h (_Destroy, _Destroy_n): Likewise.
	* testsuite/23_containers/vector/cons/destroy-adl.cc: New test.
2023-07-04 00:05:53 +01:00
Jonathan Wakely
960de5dd88 libstdc++: Optimize std::to_array for trivial types [PR110167]
As reported in PR libstdc++/110167, std::to_array compiles extremely
slowly for very large arrays. It needs to instantiate a very large
specialization of std::index_sequence<N...> and then create a very large
aggregate initializer from the pack expansion. For trivial types we can
simply default-initialize the std::array and then use memcpy to copy the
values. For non-trivial types we need to use the existing
implementation, despite the compilation cost.

As also noted in the PR, using a generic lambda instead of the
__to_array helper compiles faster since gcc-13. It also produces
slightly smaller code at -O1, due to additional inlining. The code at
-Os, -O2 and -O3 seems to be the same. This new implementation requires
__cpp_generic_lambdas >= 201707L (i.e. P0428R2) but that is supported
since Clang 10 and since Intel icc 2021.5.0 (and since GCC 10.1).

libstdc++-v3/ChangeLog:

	PR libstdc++/110167
	* include/std/array (to_array): Initialize arrays of trivial
	types using memcpy. For non-trivial types, use lambda
	expressions instead of a separate helper function.
	(__to_array): Remove.
	* testsuite/23_containers/array/creation/110167.cc: New test.
2023-06-09 13:08:25 +01:00
Jonathan Wakely
3ec1d76a35 libstdc++: Improve tests for emplace member of sequence containers
Our existing tests for std::deque::emplace, std::list::emplace and
std::vector::emplace are poor. We only have compile tests for PR 52799
and the equivalent for a const_iterator as the insertion point. This
fails to check that the value is actually inserted correctly and the
right iterator is returned.

Add new tests that cover the existing 52799.cc and const_iterator.cc
compile-only tests, as well as verifying the effects are correct.

libstdc++-v3/ChangeLog:

	* testsuite/23_containers/deque/modifiers/emplace/52799.cc:
	Removed.
	* testsuite/23_containers/deque/modifiers/emplace/const_iterator.cc:
	Removed.
	* testsuite/23_containers/list/modifiers/emplace/52799.cc:
	Removed.
	* testsuite/23_containers/list/modifiers/emplace/const_iterator.cc:
	Removed.
	* testsuite/23_containers/vector/modifiers/emplace/52799.cc:
	Removed.
	* testsuite/23_containers/vector/modifiers/emplace/const_iterator.cc:
	Removed.
	* testsuite/23_containers/deque/modifiers/emplace/1.cc: New
	test.
	* testsuite/23_containers/list/modifiers/emplace/1.cc: New
	test.
	* testsuite/23_containers/vector/modifiers/emplace/1.cc: New
	test.
2023-06-09 09:55:42 +01:00
Jonathan Wakely
fa8b4468e0 libstdc++: Fix some tests that fail with -fno-exceptions
libstdc++-v3/ChangeLog:

	* testsuite/18_support/nested_exception/rethrow_if_nested-term.cc:
	Require effective target exceptions_enabled instead of using
	dg-skip-if.
	* testsuite/23_containers/vector/capacity/constexpr.cc: Expect
	shrink_to_fit() to be a no-op without exceptions enabled.
	* testsuite/23_containers/vector/capacity/shrink_to_fit.cc:
	Likewise.
	* testsuite/ext/bitmap_allocator/check_allocate_max_size.cc:
	Require effective target exceptions_enabled.
	* testsuite/ext/malloc_allocator/check_allocate_max_size.cc:
	Likewise.
	* testsuite/ext/mt_allocator/check_allocate_max_size.cc:
	Likewise.
	* testsuite/ext/new_allocator/check_allocate_max_size.cc:
	Likewise.
	* testsuite/ext/pool_allocator/check_allocate_max_size.cc:
	Likewise.
	* testsuite/ext/throw_allocator/check_allocate_max_size.cc:
	Likewise.
2023-06-07 16:51:59 +01:00
Jonathan Wakely
56001fad4e libstdc++: Fix ambiguous expression in std::array<T, 0>::front() [PR110139]
For 32-bit targets using -pedantic (or using Clang) makes the expression
_M_elems[0] ambiguous.  The overloaded operator[] that we want to call
has a size_t parameter, but 0 is type ptrdiff_t for many ILP32 targets,
so using the implicit conversion from _M_elems to T* and then
subscripting that is also viable.

Change the 0 to (size_type)0 and also make the conversion to T*
explicit, so that's it's not viable here. The latter change requires a
static_cast in data() where we really do want to convert _M_elems to a
pointer.

libstdc++-v3/ChangeLog:

	PR libstdc++/110139
	* include/std/array (__array_traits<T, 0>::operator T*()): Make
	conversion operator explicit.
	(array::front): Use size_type as subscript operand.
	(array::data): Use static_cast to make conversion explicit.
	* testsuite/23_containers/array/element_access/110139.cc: New
	test.
2023-06-06 12:43:47 +01:00
Jonathan Wakely
b7b255e77a libstdc++: Fix code size regressions in std::vector [PR110060]
My r14-1452-gfb409a15d9babc change to add optimization hints to
std::vector causes regressions because it makes std::vector::size() and
std::vector::capacity() too big to inline. That's the opposite of what
I wanted, so revert the changes to those functions.

To achieve the original aim of optimizing vec.assign(vec.size(), x) we
can add a local optimization hint to _M_fill_assign, so that it doesn't
affect all other uses of size() and capacity().

Additionally, add the same hint to the _M_assign_aux overload for
forward iterators and add that to the testcase.

It would be nice to similarly optimize:
  if (vec1.size() == vec2.size()) vec1 = vec2;
but adding hints to operator=(const vector&) doesn't help. Presumably
the relationships between the two sizes and two capacities are too
complex to track effectively.

libstdc++-v3/ChangeLog:

	PR libstdc++/110060
	* include/bits/stl_vector.h (_Vector_base::_M_invariant):
	Remove.
	(vector::size, vector::capacity): Remove calls to _M_invariant.
	* include/bits/vector.tcc (vector::_M_fill_assign): Add
	optimization hint to reallocating path.
	(vector::_M_assign_aux(FwdIter, FwdIter, forward_iterator_tag)):
	Likewise.
	* testsuite/23_containers/vector/capacity/invariant.cc: Moved
	to...
	* testsuite/23_containers/vector/modifiers/assign/no_realloc.cc:
	...here. Check assign(FwdIter, FwdIter) too.
	* testsuite/23_containers/vector/types/1.cc: Revert addition
	of -Wno-stringop-overread option.
2023-06-01 16:06:15 +01:00
Jonathan Wakely
fb409a15d9 libstdc++: Express std::vector's size() <= capacity() invariant in code
This adds optimizer hints so that GCC knows that size() <= capacity() is
always true. This allows the compiler to optimize away re-allocating
paths when assigning new values to the vector without resizing it, e.g.,
vec.assign(vec.size(), new_val).

libstdc++-v3/ChangeLog:

	* include/bits/stl_vector.h (_Vector_base::_M_invariant()): New
	function.
	(vector::size(), vector::capacity()): Call _M_invariant().
	* testsuite/23_containers/vector/capacity/invariant.cc: New test.
	* testsuite/23_containers/vector/types/1.cc: Add suppression for
	false positive warning (PR110060).
2023-05-31 21:01:15 +01:00
Jonathan Wakely
25264f6b3a libstdc++: Fix some AIX test failures
AIX <sys/thread.h> defines struct tstate with non-reserved names, so
adjust the 17_intro/names.cc test. It also defines struct user, which
conflicts with namespace user in some tests.

Replacing the global operator new doesn't work on AIX the same way as it
does for ELF, so skip some tests that depend on replacing it.

Add missing DG directives to synchronized_value test so it doesn't run
for the single-threaded AIX multilib.

libstdc++-v3/ChangeLog:

	* testsuite/17_intro/names.cc [_AIX]: Do not define policy.
	* testsuite/19_diagnostics/error_code/cons/lwg3629.cc: Rename
	namespace to avoid clashing with libc struct.
	* testsuite/19_diagnostics/error_condition/cons/lwg3629.cc:
	Likewise.
	* testsuite/23_containers/unordered_map/96088.cc: Skip on AIX.
	* testsuite/23_containers/unordered_multimap/96088.cc: Likewise.
	* testsuite/23_containers/unordered_multiset/96088.cc: Likewise.
	* testsuite/23_containers/unordered_set/96088.cc: Likewise.
	* testsuite/experimental/synchronized_value.cc: Require gthreads
	and add missing option for pthreads targets.
2023-04-12 23:25:17 +01:00
Marek Polacek
a226590fef c++: explicit ctor and list-initialization [PR109159]
When I implemented explicit(bool) in r9-3735, I added this code to
add_template_candidate_real:
+  /* Now the explicit specifier might have been deduced; check if this
+     declaration is explicit.  If it is and we're ignoring non-converting
+     constructors, don't add this function to the set of candidates.  */
+  if ((flags & LOOKUP_ONLYCONVERTING) && DECL_NONCONVERTING_P (fn))
+    return NULL;
but as this test demonstrates, that's incorrect when we're initializing
from a {}: for list-initialization we consider explicit constructors and
complain if one is chosen.

	PR c++/109159

gcc/cp/ChangeLog:

	* call.cc (add_template_candidate_real): Add explicit decls to the
	set of candidates when the initializer is a braced-init-list.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/pair/cons/explicit_construct.cc: Adjust dg-error.
	* testsuite/20_util/tuple/cons/explicit_construct.cc: Likewise.
	* testsuite/23_containers/span/explicit.cc: Likewise.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/explicit16.C: New test.
2023-03-20 16:54:11 -04:00
Jonathan Wakely
3adf6dd508 libstdc++: Use dg-bogus in new test [PR108554]
libstdc++-v3/ChangeLog:

	PR libstdc++/108554
	* testsuite/23_containers/map/modifiers/108554.cc: Use dg-bogus.
2023-01-27 15:33:00 +00:00
Jonathan Wakely
3376467ce0 libstdc++: Add returns_nonnull to non-inline std::map detail [PR108554]
std::map uses a non-inline function to rebalance its tree and the
compiler can't see that it always returns a valid pointer (assuming
valid inputs, which is a precondition anyway). This can result in
-Wnull-derefernce warnings for valid code, because the compiler thinks
there is a path where the function returns null.

Adding the returns_nonnull attribute tells the compiler that is can't
happen. While we're doing that, we might as well also add a nonnull
attribute to the rebalancing functions too.

libstdc++-v3/ChangeLog:

	PR libstdc++/108554
	* include/bits/stl_tree.h (_Rb_tree_insert_and_rebalance): Add
	nonnull attribute.
	(_Rb_tree_rebalance_for_erase): Add nonnull and returns_nonnull
	attributes.
	* testsuite/23_containers/map/modifiers/108554.cc: New test.
2023-01-26 13:38:22 +00:00
Jakub Jelinek
83ffe9cde7 Update copyright years. 2023-01-16 11:52:17 +01:00
François Dumont
5c9833d878 libstdc++: [_GLIBCXX_DEBUG] Complete deadlock fix on safe iterators [PR108288]
Complete fix on all _Safe_iterator post-increment and post-decrement implementations
and on _Safe_local_iterator.

libstdc++-v3/ChangeLog:

	PR libstdc++/108288
	* include/debug/safe_iterator.h (_Safe_iterator<>::operator++(int)): Extend deadlock
	fix to other iterator category.
	(_Safe_iterator<>::operator--(int)): Likewise.
	* include/debug/safe_local_iterator.h (_Safe_local_iterator<>::operator++(int)):
	Fix deadlock.
	* testsuite/util/debug/unordered_checks.h (invalid_local_iterator_pre_increment): New.
	(invalid_local_iterator_post_increment): New.
	* testsuite/23_containers/unordered_map/debug/invalid_local_iterator_post_increment_neg.cc:
	New test.
	* testsuite/23_containers/unordered_map/debug/invalid_local_iterator_pre_increment_neg.cc:
	New test.
2023-01-15 17:05:00 +01:00
Jonathan Wakely
1530a9b1f4 libstdc++: Fix std::array<T, 0>::data() to be a constant expression [PR108258]
When I refactored the __array_traits helper I broke this.

libstdc++-v3/ChangeLog:

	PR libstdc++/108258
	* include/std/array (__array_traits<T, 0>::operator T*()): Add
	constexpr.
	* testsuite/23_containers/array/element_access/constexpr_c++17.cc: Check
	std::array<T, 0>::data().
2023-01-04 11:53:49 +00:00