Commit Graph

15233 Commits

Author SHA1 Message Date
GCC Administrator
e20ea6bcf8 Daily bump. 2024-07-19 00:18:20 +00:00
Patrick Palka
313afcfdab c++: diagnose failed qualified lookup into current inst
When the scope of a qualified name is the current instantiation, and
qualified lookup finds nothing at template definition time, then we
know it'll find nothing at instantiation time (unless the current
instantiation has dependent bases).  So such qualified name lookup
failure can be diagnosed ahead of time as per [temp.res.general]/6.

This patch implements that, for qualified names of the form (where
the current instantiation is A<T>):

  this->non_existent
  a.non_existent
  A::non_existent
  typename A::non_existent

It turns out we already optimistically attempt qualified lookup of
seemingly every qualified name, even when it's dependently scoped, and
then suppress issuing a lookup failure diagnostic after the fact.
So implementing this is mostly a matter of restricting the diagnostic
suppression to "dependentish" scopes (i.e. dependent scopes or the
current instantiation with dependent bases), rather than suppressing
for any dependently-typed scope as we currently do.

The cp_parser_conversion_function_id change is needed to avoid regressing
lookup/using8.C:

  using A<T>::operator typename A<T>::Nested*;

When looking up A<T>::Nested we consider it not dependently scoped since
we entered A<T> from cp_parser_conversion_function_id earlier.   But this
A<T> is the implicit instantiation A<T> not the primary template type A<T>,
and so the lookup fails which we now diagnose.  This patch works around
this by not entering the template scope of a qualified conversion
function-id in this case, i.e. if we're in an expression vs declaration
context, by seeing if the type already went through finish_template_type
with entering_scope=true.

gcc/cp/ChangeLog:

	* decl.cc (make_typename_type): Restrict name lookup failure
	punting to dependentish_scope_p instead of dependent_type_p.
	* error.cc (qualified_name_lookup_error): Improve diagnostic
	when the scope is the current instantiation.
	* parser.cc (cp_parser_diagnose_invalid_type_name): Likewise.
	(cp_parser_conversion_function_id): Don't call push_scope on
	a template scope unless we're in a declaration context.
	(cp_parser_lookup_name): Restrict name lookup failure
	punting to dependentish_scope_p instead of depedent_type_p.
	* semantics.cc (finish_id_expression_1): Likewise.
	* typeck.cc (finish_class_member_access_expr): Likewise.

libstdc++-v3/ChangeLog:

	* include/experimental/socket
	(basic_socket_iostream::basic_socket_iostream): Fix typo.
	* include/tr2/dynamic_bitset
	(__dynamic_bitset_base::_M_is_proper_subset_of): Likewise.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp0x/alignas18.C: Expect name lookup error for U::X.
	* g++.dg/cpp0x/forw_enum13.C: Expect name lookup error for
	D3::A and D4<T>::A.
	* g++.dg/parse/access13.C: Declare A::E::V to avoid name lookup
	failure and preserve intent of the test.
	* g++.dg/parse/enum11.C: Expect extra errors, matching the
	non-template case.
	* g++.dg/template/crash123.C: Avoid name lookup failure to
	preserve intent of the test.
	* g++.dg/template/crash124.C: Likewise.
	* g++.dg/template/crash7.C: Adjust expected diagnostics.
	* g++.dg/template/dtor6.C: Declare A::~A() to avoid name lookup
	failure and preserve intent of the test.
	* g++.dg/template/error22.C: Adjust expected diagnostics.
	* g++.dg/template/static30.C: Avoid name lookup failure to
	preserve intent of the test.
	* g++.old-deja/g++.other/decl5.C: Adjust expected diagnostics.
	* g++.dg/template/non-dependent34.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
2024-07-17 20:54:14 -04:00
GCC Administrator
2ee5b58be6 Daily bump. 2024-07-13 00:17:42 +00:00
Alexandre Oliva
26dfb3f2d3 [libstdc++] [testsuite] require dfprt on some tests
On a target that doesn't enable decimal float components in libgcc
(because the libc doens't define all required FE_* macros), but whose
compiler supports _Decimal* types, the effective target requirement
dfp passes, but several tests won't link because the runtime support
they depend on is missing.  State their dfprt requirement.


for  libstdc++-v3/ChangeLog

	* testsuite/decimal/binary-arith.cc: Require dfprt.
	* testsuite/decimal/comparison.cc: Likewise.
	* testsuite/decimal/compound-assignment.cc: Likewise.
	* testsuite/decimal/compound-assignment-memfunc.cc: Likewise.
	* testsuite/decimal/make-decimal.cc: Likewise.
	* testsuite/decimal/pr54036-1.cc: Likewise.
	* testsuite/decimal/pr54036-2.cc: Likewise.
	* testsuite/decimal/pr54036-3.cc: Likewise.
	* testsuite/decimal/unary-arith.cc: Likewise.
2024-07-12 05:42:19 -03:00
GCC Administrator
88ff0504ab Daily bump. 2024-07-12 00:17:52 +00:00
Jonathan Wakely
43763bd75f
libstdc++: Test that std::atomic_ref<bool> uses the primary template
The previous commit changed atomic_ref<bool> to not use the integral
specialization. This adds a test to verify that change. We can't
directly test that the primary template is used, but we can check that
the member functions of the integral specializations are not present.

libstdc++-v3/ChangeLog:

	* testsuite/29_atomics/atomic_ref/bool.cc: New test.
2024-07-12 00:08:16 +01:00
Damien Lebrun-Grandie
79d3f17b07
libstdc++: the specialization atomic_ref<bool> should use the primary template
Per [atomics.ref.int] `bool` is excluded from the list of integral types
for which there is a specialization of the `atomic_ref` class template
and [Note 1] clearly states that `atomic_ref<bool>` "uses the primary
template" instead.

libstdc++-v3/ChangeLog:

	* include/bits/atomic_base.h (__atomic_ref): Do not use integral
	specialization for bool.

Signed-off-by: Damien Lebrun-Grandie <dalg24@gmail.com>
2024-07-12 00:08:15 +01:00
Gerald Pfeifer
26c9b095ed libstdc++: Switch gcc.gnu.org links to https
libstdc++-v3:
	* doc/xml/manual/using.xml: Switch gcc.gnu.org links to https.
	* doc/html/manual/using_concurrency.html: Regenerate.
	* doc/html/manual/using_dynamic_or_shared.html: Ditto.
	* doc/html/manual/using_headers.html: Ditto.
	* doc/html/manual/using_namespaces.html: Ditto.
2024-07-12 00:03:18 +02:00
Jonathan Wakely
8dbc02ba43
libstdc++: Disable expensive test for debug mode [PR108636]
This test uses -fkeep-inline-functions and with debug mode enabled that
compiles much slower and times out if the system is under heavy load.

The original problem being tested is independent of debug mode, so just
require normal mode for the test.

libstdc++-v3/ChangeLog:

	PR libstdc++/108636
	* testsuite/27_io/filesystem/path/108636.cc: Require normal
	mode.
2024-07-11 16:18:49 +01:00
GCC Administrator
f777ab31e5 Daily bump. 2024-07-11 00:17:33 +00:00
Jonathan Wakely
d8cd852118
libstdc++: Make std::basic_format_context non-copyable [PR114387]
Users are not supposed to create objects of this type, and there's no
reason it needs to be copyable. LWG 4061 makes it non-copyable and
non-default constructible.

libstdc++-v3/ChangeLog:

	PR libstdc++/114387
	* include/std/format (basic_format_context): Define copy
	operations as deleted, as per LWG 4061.
	* testsuite/std/format/context.cc: New test.
2024-07-10 22:05:22 +01:00
Jonathan Wakely
9f758953eb
libstdc++: Minor optimization for std::locale::encoding()
For the C locale we know the encoding is ASCII, so we can avoid using
newlocale and nl_langinfo_l. Similarly, for an unnamed locale, we aren't
going to get a useful answer, so we can just use a default-constrcuted
std::text_encoding representing an unknown encoding.

libstdc++-v3/ChangeLog:

	* src/c++26/text_encoding.cc (__locale_encoding): Add to unnamed
	namespace.
	(std::locale::encoding): Optimize for "C" and "*" names.
2024-07-10 22:05:22 +01:00
Jonathan Wakely
c5efc6eca8
libstdc++: Use direct-initialization for std::vector<bool>'s allocator [PR115854]
The consensus in the standard committee is that this change shouldn't be
necessary, and the Allocator requirements should require conversions
between rebound allocators to be implicit. But we can make it work for
now anyway.

libstdc++-v3/ChangeLog:

	PR libstdc++/115854
	* include/bits/stl_bvector.h (_Bvector_base): Convert allocator
	to rebound type explicitly.
	* testsuite/23_containers/vector/allocator/115854.cc: New test.
	* testsuite/23_containers/vector/bool/allocator/115854.cc: New test.
2024-07-10 22:05:22 +01:00
Jonathan Wakely
cda469a59e
libstdc++: ranges::find needs explicit conversion to size_t [PR115799]
For an integer-class type we need to use an explicit conversion to size_t.

libstdc++-v3/ChangeLog:

	PR libstdc++/115799
	* include/bits/ranges_util.h (__find_fn): Make conversion
	from difference type ti size_t explicit.
	* testsuite/25_algorithms/find/bytes.cc: Check ranges::find with
	__gnu_test::test_contiguous_range.
	* testsuite/std/ranges/range.cc: Adjust expected difference_type
	for __gnu_test::test_contiguous_range.
	* testsuite/util/testsuite_iterators.h (contiguous_iterator_wrapper):
	Use __max_diff_type as difference type.
	(test_range::sentinel, test_sized_range_sized_sent::sentinel):
	Ensure that operator- returns difference_type.
2024-07-10 22:05:21 +01:00
Marek Polacek
f0fb6b6acd c++: remove Concepts TS code
In GCC 14 we deprecated Concepts TS and discussed removing the code
in GCC 15.  This patch removes Concepts TS code from the front end,
including support for template-introductions, as in:

  template<typename T>
  concept C = true;

  C{T} void foo (T); // write template<C T> void foo (T);

The biggest part of this patch is adjusting the testsuite.  We don't
want to lose coverage so I've converted most of -fconcepts-ts tests
to C++20.  That means they no longer have to be c++17_only.  Mostly
this meant turning "concept bool" into "concept" and turning function
concepts into C++20 concepts.  I've added missing "auto"s where
required, but "auto"s in template-argument-lists are not supported
anymore so I've removed some of the tests; some of them are still
present to verify we don't crash on such autos.  I've also added ()
around "requires" expressions.

I plan to add a porting_to.html entry with a few hints.

I've rebased and tested the patch after the recent r15-1103.

gcc/c-family/ChangeLog:

	* c-cppbuiltin.cc (c_cpp_builtins): Remove flag_concepts_ts code.
	* c-opts.cc (c_common_post_options): Likewise.
	* c.opt: Remove -fconcepts-ts.
	* c.opt.urls: Regenerate.

gcc/cp/ChangeLog:

	* constraint.cc (deduce_concept_introduction, get_deduced_wildcard,
	get_introduction_prototype, introduce_type_template_parameter,
	introduce_template_template_parameter,
	introduce_nontype_template_parameter,
	build_introduced_template_parameter, introduce_template_parameter,
	introduce_template_parameter_pack, introduce_template_parameter,
	introduce_template_parameters, process_introduction_parms,
	check_introduction_list, finish_template_introduction): Remove.
	(finish_shorthand_constraint): Remove a Concepts TS comment.
	* cp-tree.h (check_auto_in_tmpl_args, finish_template_introduction):
	Remove.
	* decl.cc (function_requirements_equivalent_p): Remove pre-C++20 code.
	(grokfndecl): Don't check flag_concepts_ts.
	(grokvardecl): Don't check that concept have type bool.
	* parser.cc (cp_parser_decl_specifier_seq): Don't check
	flag_concepts_ts.
	(cp_parser_introduction_list): Remove.
	(cp_parser_template_id): Remove dead code.
	(cp_parser_simple_type_specifier): Don't check flag_concepts_ts.
	(cp_parser_placeholder_type_specifier): Require require auto or
	decltype(auto) even pre-C++20.  Don't check flag_concepts_ts.
	(cp_parser_type_id_1): Don't check flag_concepts_ts.
	(cp_parser_template_type_arg): Likewise.
	(cp_parser_requires_clause_opt): Remove flag_concepts_ts code.
	(cp_parser_compound_requirement): Don't check flag_concepts_ts.
	(cp_parser_template_introduction): Remove.
	(cp_parser_template_declaration_after_export): Don't call
	cp_parser_template_introduction.
	* pt.cc (template_heads_equivalent_p): Remove pre-C++20 code.
	(find_parameter_pack_data): Remove type_pack_expansion_p.
	(find_parameter_packs_r): Remove flag_concepts_ts code.  Remove
	type_pack_expansion_p code.
	(uses_parameter_packs): Remove type_pack_expansion_p code.
	(make_pack_expansion): Likewise.
	(check_for_bare_parameter_packs): Likewise.
	(fixed_parameter_pack_p): Likewise.
	(tsubst_qualified_id): Remove dead code.
	(extract_autos_r): Remove.
	(extract_autos): Remove.
	(do_auto_deduction): Remove flag_concepts_ts code.
	(type_uses_auto): Likewise.
	(check_auto_in_tmpl_args): Remove.

gcc/ChangeLog:

	* doc/invoke.texi: Mention that -fconcepts-ts was removed.

libstdc++-v3/ChangeLog:

	* testsuite/std/ranges/access/101782.cc: Don't compile with
	-fconcepts-ts.

gcc/testsuite/ChangeLog:

	* g++.dg/concepts/auto3.C: Compile with -fconcepts.  Run in C++17 and
	up.  Add dg-error.
	* g++.dg/concepts/auto5.C: Likewise.
	* g++.dg/concepts/auto7.C: Compile with -fconcepts.  Add dg-error.
	* g++.dg/concepts/auto8a.C: Compile with -fconcepts.
	* g++.dg/concepts/class-deduction1.C: Compile with -fconcepts.  Run in
	C++17 and up.  Convert to C++20.
	* g++.dg/concepts/class5.C: Likewise.
	* g++.dg/concepts/class6.C: Likewise.
	* g++.dg/concepts/debug1.C: Likewise.
	* g++.dg/concepts/decl-diagnose.C: Compile with -fconcepts.  Run in
	C++17 and up.  Add dg-error.
	* g++.dg/concepts/deduction-constraint1.C: Compile with -fconcepts.
	Run in C++17 and up.  Convert to C++20.
	* g++.dg/concepts/diagnostic1.C: Likewise.
	* g++.dg/concepts/dr1430.C: Likewise.
	* g++.dg/concepts/equiv.C: Likewise.
	* g++.dg/concepts/equiv2.C: Likewise.
	* g++.dg/concepts/expression.C: Likewise.
	* g++.dg/concepts/expression2.C: Likewise.
	* g++.dg/concepts/expression3.C: Likewise.
	* g++.dg/concepts/fn-concept2.C: Compile with -fconcepts.  Run in
	C++17 and up.  Remove code.  Add dg-prune-output.
	* g++.dg/concepts/fn-concept3.C: Compile with -fconcepts.  Run in
	C++17 and up.  Convert to C++20.
	* g++.dg/concepts/fn1.C: Likewise.
	* g++.dg/concepts/fn10.C: Likewise.
	* g++.dg/concepts/fn2.C: Likewise.
	* g++.dg/concepts/fn3.C: Likewise.
	* g++.dg/concepts/fn4.C: Likewise.
	* g++.dg/concepts/fn5.C: Likewise.
	* g++.dg/concepts/fn6.C: Likewise.
	* g++.dg/concepts/fn7.C: Compile with -fconcepts.  Add dg-error.
	* g++.dg/concepts/fn8.C: Compile with -fconcepts.  Run in C++17 and up.
	Convert to C++20.
	* g++.dg/concepts/fn9.C: Likewise.
	* g++.dg/concepts/generic-fn-err.C: Likewise.
	* g++.dg/concepts/generic-fn.C: Likewise.
	* g++.dg/concepts/inherit-ctor1.C: Likewise.
	* g++.dg/concepts/inherit-ctor3.C: Likewise.
	* g++.dg/concepts/intro1.C: Likewise.
	* g++.dg/concepts/locations1.C: Compile with -fconcepts.  Run in C++17
	and up.  Add dg-prune-output.
	* g++.dg/concepts/partial-concept-id1.C: Compile with -fconcepts.
	Run in C++17 and up.  Convert to C++20.
	* g++.dg/concepts/partial-concept-id2.C: Likewise.
	* g++.dg/concepts/partial-spec5.C: Likewise.
	* g++.dg/concepts/placeholder2.C: Likewise.
	* g++.dg/concepts/placeholder3.C: Likewise.
	* g++.dg/concepts/placeholder4.C: Likewise.
	* g++.dg/concepts/placeholder5.C: Likewise.
	* g++.dg/concepts/placeholder6.C: Likewise.
	* g++.dg/concepts/pr65634.C: Likewise.
	* g++.dg/concepts/pr65636.C: Likewise.
	* g++.dg/concepts/pr65681.C: Likewise.
	* g++.dg/concepts/pr65848.C: Likewise.
	* g++.dg/concepts/pr67249.C: Likewise.
	* g++.dg/concepts/pr67595.C: Likewise.
	* g++.dg/concepts/pr68434.C: Likewise.
	* g++.dg/concepts/pr71127.C: Likewise.
	* g++.dg/concepts/pr71128.C: Compile with -fconcepts.  Run in C++17
	and up.  Add dg-error.
	* g++.dg/concepts/pr71131.C: Compile with -fconcepts.  Run in C++17
	and up.  Convert to C++20.
	* g++.dg/concepts/pr71385.C: Likewise.
	* g++.dg/concepts/pr85065.C: Likewise.
	* g++.dg/concepts/pr92804-2.C: Compile with -fconcepts.  Convert to
	C++20.
	* g++.dg/concepts/template-parm11.C: Compile with -fconcepts.  Run in
	C++17 and up.  Convert to C++20.
	* g++.dg/concepts/template-parm12.C: Likewise.
	* g++.dg/concepts/template-parm2.C: Likewise.
	* g++.dg/concepts/template-parm3.C: Likewise.
	* g++.dg/concepts/template-parm4.C: Likewise.
	* g++.dg/concepts/template-template-parm1.C: Likewise.
	* g++.dg/concepts/var-concept1.C: Likewise.
	* g++.dg/concepts/var-concept2.C: Likewise.
	* g++.dg/concepts/var-concept3.C: Likewise.
	* g++.dg/concepts/var-concept4.C: Likewise.
	* g++.dg/concepts/var-concept5.C: Likewise.
	* g++.dg/concepts/var-concept6.C: Likewise.
	* g++.dg/concepts/var-concept7.C: Likewise.
	* g++.dg/concepts/var-templ1.C: Run in C++17 and up.
	* g++.dg/concepts/var-templ2.C: Compile with -fconcepts.  Run in C++17
	and up.  Convert to C++20.
	* g++.dg/concepts/var-templ3.C: Likewise.
	* g++.dg/concepts/variadic1.C: Likewise.
	* g++.dg/concepts/variadic2.C: Likewise.
	* g++.dg/concepts/variadic3.C: Likewise.
	* g++.dg/concepts/variadic4.C: Likewise.
	* g++.dg/cpp2a/concepts-pr65575.C: Likewise.
	* g++.dg/cpp2a/concepts-pr66091.C: Likewise.
	* g++.dg/cpp2a/concepts-pr67148.C: Compile with -fconcepts.  Convert
	to C++20.
	* g++.dg/cpp2a/concepts-pr67225-1.C: Likewise.
	* g++.dg/cpp2a/concepts-pr67225-2.C: Likewise.
	* g++.dg/cpp2a/concepts-pr67225-3.C: Likewise.
	* g++.dg/cpp2a/concepts-pr67225-4.C: Likewise.
	* g++.dg/cpp2a/concepts-pr67225-5.C: Likewise.
	* g++.dg/cpp2a/concepts-pr67319.C: Likewise.
	* g++.dg/cpp2a/concepts-pr67427.C: Likewise.
	* g++.dg/cpp2a/concepts-pr67654.C: Likewise.
	* g++.dg/cpp2a/concepts-pr67658.C: Likewise.
	* g++.dg/cpp2a/concepts-pr67684.C: Likewise.
	* g++.dg/cpp2a/concepts-pr67697.C: Likewise.
	* g++.dg/cpp2a/concepts-pr67719.C: Likewise.
	* g++.dg/cpp2a/concepts-pr67774.C: Likewise.
	* g++.dg/cpp2a/concepts-pr67825.C: Likewise.
	* g++.dg/cpp2a/concepts-pr67860.C: Likewise.
	* g++.dg/cpp2a/concepts-pr67862.C: Likewise.
	* g++.dg/cpp2a/concepts-pr67969.C: Likewise.
	* g++.dg/cpp2a/concepts-pr68093-2.C: Likewise.
	* g++.dg/cpp2a/concepts-pr68372.C: Likewise.
	* g++.dg/cpp2a/concepts-pr68812.C: Likewise.
	* g++.dg/cpp2a/concepts-pr69235.C: Likewise.
	* g++.dg/cpp2a/concepts-pr78752-2.C: Likewise.
	* g++.dg/cpp2a/concepts-pr78752.C: Likewise.
	* g++.dg/cpp2a/concepts-pr79759.C: Likewise.
	* g++.dg/cpp2a/concepts-pr80746.C: Likewise.
	* g++.dg/cpp2a/concepts-pr80773.C: Likewise.
	* g++.dg/cpp2a/concepts-pr82507.C: Likewise.
	* g++.dg/cpp2a/concepts-pr82740.C: Likewise.
	* g++.dg/cpp2a/concepts-pr84980.C: Compile with -fconcepts.  Run in
	C++17 and up.  Convert to C++20.
	* g++.dg/cpp2a/concepts-pr85265.C: Likewise.
	* g++.dg/cpp2a/concepts-pr85808.C: Compile with -fconcepts.  Convert
	to C++20.
	* g++.dg/cpp2a/concepts-pr86269.C: Likewise.
	* g++.dg/cpp2a/concepts-pr87441.C: Likewise.
	* g++.dg/cpp2a/concepts-requires5.C: Compile with -fconcepts.
	Adjust dg-error.  Add same_as.
	* g++.dg/cpp2a/nontype-class50a.C: Compile with -fconcepts.
	* g++.dg/concepts/auto1.C: Removed.
	* g++.dg/concepts/auto4.C: Removed.
	* g++.dg/concepts/auto6.C: Removed.
	* g++.dg/concepts/fn-concept1.C: Removed.
	* g++.dg/concepts/intro2.C: Removed.
	* g++.dg/concepts/intro3.C: Removed.
	* g++.dg/concepts/intro4.C: Removed.
	* g++.dg/concepts/intro5.C: Removed.
	* g++.dg/concepts/intro6.C: Removed.
	* g++.dg/concepts/intro7.C: Removed.
	* g++.dg/cpp2a/concepts-ts1.C: Removed.
	* g++.dg/cpp2a/concepts-ts2.C: Removed.
	* g++.dg/cpp2a/concepts-ts3.C: Removed.
	* g++.dg/cpp2a/concepts-ts4.C: Removed.
	* g++.dg/cpp2a/concepts-ts5.C: Removed.
	* g++.dg/cpp2a/concepts-ts6.C: Removed.
2024-07-10 15:38:48 -04:00
GCC Administrator
ceb944ad4c Daily bump. 2024-07-09 00:17:28 +00:00
Jonathan Wakely
40d234dd64
libstdc++: Fix _Atomic(T) macro in <stdatomic.h> [PR115807]
The definition of the _Atomic(T) macro needs to refer to ::std::atomic,
not some other std::atomic relative to the current namespace.

libstdc++-v3/ChangeLog:

	PR libstdc++/115807
	* include/c_compatibility/stdatomic.h (_Atomic): Ensure it
	refers to std::atomic in the global namespace.
	* testsuite/29_atomics/headers/stdatomic.h/115807.cc: New test.
2024-07-08 20:40:35 +01:00
GCC Administrator
53eef7915a Daily bump. 2024-07-08 00:17:01 +00:00
Gerald Pfeifer
6fa4802eee libstdc++: Tweak two links in configuration docs
libstdc++-v3:
	* doc/xml/manual/configure.xml: Update Autobook 14 link.
	Update GCC installation instructions link.
	* doc/html/manual/configure.html: Regenerate.
2024-07-07 23:18:11 +02:00
Jonathan Wakely
ce34fcc572
libstdc++: Fix std::find for non-contiguous iterators [PR115799]
The r15-1857 change didn't correctly restrict the new optimization to
contiguous iterators.

libstdc++-v3/ChangeLog:

	PR libstdc++/115799
	* include/bits/stl_algo.h (find): Use 'if constexpr' so that
	memchr optimization is a discarded statement for non-contiguous
	iterators.
	* testsuite/25_algorithms/find/bytes.cc: Check with input
	iterators.
2024-07-07 12:26:09 +01:00
Jonathan Wakely
762ee55d36
libstdc++: Fix memchr path in std::ranges::find for non-common range [PR115799]
The memchr optimization introduced in r15-1857 needs to advance the
start iterator instead of returning the sentinel.

libstdc++-v3/ChangeLog:

	PR libstdc++/115799
	* include/bits/ranges_util.h (__find_fn): Return iterator
	instead of sentinel.
	* testsuite/25_algorithms/find/constrained.cc: Check non-common
	contiguous sized range of char.
2024-07-07 12:26:08 +01:00
GCC Administrator
e78c5d0ae4 Daily bump. 2024-07-07 00:16:44 +00:00
Jonathan Wakely
3fc913104d
libstdc++: Remove redundant 17_intro/headers tests
We have several nearly identical tests under 17_intro/headers which only
differ in a -std option set using dg-options. Since the testsuite now
supports running tests with multiple -std options (and I test that
regularly) we don't need these duplicated tests. We can remove most of
them and let the testsuite decide which -std option to use.

In the all_attributes.cc case the content of the tests is slightly
different, but they can be combined into one test that defines macros
conditionally based on __cplusplus checks.

The stdc++.cc tests could also be combined this way, but for now I've
just kept one version for c++98 and one for all later standards.

For stdc++_multiple_inclusion.cc we can remove the body of the files and
just include stdc++.cc twice. This means we don't need to add includes
to both stdc++.cc and stdc++_multiple_inclusion.cc, we only need to
update one place.

libstdc++-v3/ChangeLog:

	* testsuite/17_intro/headers/c++1998/all_attributes.cc: Add
	attribute names from later standards and remove dg-options.
	* testsuite/17_intro/headers/c++1998/stdc++.cc: Add c++98_only
	target selector.
	* testsuite/17_intro/headers/c++1998/stdc++_multiple_inclusion.cc:
	Remove content and include stdc++.cc twice instead.
	* testsuite/17_intro/headers/c++2011/stdc++.cc: Replace
	dg-options with c++11 target selector.
	* testsuite/17_intro/headers/c++2011/stdc++_multiple_inclusion.cc:
	Remove content and include stdc++.cc twice instead.
	* testsuite/17_intro/headers/c++2011/all_attributes.cc: Removed.
	* testsuite/17_intro/headers/c++2011/all_no_exceptions.cc: Removed.
	* testsuite/17_intro/headers/c++2011/all_no_rtti.cc: Removed.
	* testsuite/17_intro/headers/c++2011/all_pedantic_errors.cc: Removed.
	* testsuite/17_intro/headers/c++2011/charset.cc: Removed.
	* testsuite/17_intro/headers/c++2011/operator_names.cc: Removed.
	* testsuite/17_intro/headers/c++2014/all_attributes.cc: Removed.
	* testsuite/17_intro/headers/c++2014/all_no_exceptions.cc: Removed.
	* testsuite/17_intro/headers/c++2014/all_no_rtti.cc: Removed.
	* testsuite/17_intro/headers/c++2014/all_pedantic_errors.cc: Removed.
	* testsuite/17_intro/headers/c++2014/charset.cc: Removed.
	* testsuite/17_intro/headers/c++2014/operator_names.cc: Removed.
	* testsuite/17_intro/headers/c++2014/stdc++.cc: Removed.
	* testsuite/17_intro/headers/c++2014/stdc++_multiple_inclusion.cc: Removed.
	* testsuite/17_intro/headers/c++2017/all_attributes.cc: Removed.
	* testsuite/17_intro/headers/c++2017/all_no_exceptions.cc: Removed.
	* testsuite/17_intro/headers/c++2017/all_no_rtti.cc: Removed.
	* testsuite/17_intro/headers/c++2017/all_pedantic_errors.cc: Removed.
	* testsuite/17_intro/headers/c++2017/charset.cc: Removed.
	* testsuite/17_intro/headers/c++2017/operator_names.cc: Removed.
	* testsuite/17_intro/headers/c++2017/stdc++.cc: Removed.
	* testsuite/17_intro/headers/c++2017/stdc++_multiple_inclusion.cc: Removed.
	* testsuite/17_intro/headers/c++2020/all_attributes.cc: Removed.
	* testsuite/17_intro/headers/c++2020/all_no_exceptions.cc: Removed.
	* testsuite/17_intro/headers/c++2020/all_no_rtti.cc: Removed.
	* testsuite/17_intro/headers/c++2020/all_pedantic_errors.cc: Removed.
	* testsuite/17_intro/headers/c++2020/charset.cc: Removed.
	* testsuite/17_intro/headers/c++2020/operator_names.cc: Removed.
	* testsuite/17_intro/headers/c++2020/stdc++.cc: Removed.
	* testsuite/17_intro/headers/c++2020/stdc++_multiple_inclusion.cc: Removed.
2024-07-06 21:16:53 +01:00
Jonathan Wakely
9f1cd51766
libstdc++: Use reserved form of [[__likely__]] in <variant>
We should not use [[unlikely]] before C++20, so use [[__unlikely__]]
instead.

libstdc++-v3/ChangeLog:

	* include/std/variant (_Variant_storage::_M_reset): Use
	__unlikely__ form of attribute instead of unlikely.
2024-07-06 21:16:53 +01:00
Jonathan Wakely
dcc735aaea
libstdc++: Restore support for including <name.h> in extern "C" [PR115797]
The r15-1857 change means that <type_traits> is included by <cmath> for
C++17 and up, which breaks code including <math.h> inside an extern "C"
block. Although doing that is not allowed by the C++ standard, there's
lots of existing code which incorrectly thinks it's a good idea and so
we try to support it.

libstdc++-v3/ChangeLog:

	PR libstdc++/115797
	* include/std/type_traits: Ensure "C++" language linkage.
	* testsuite/17_intro/headers/c++2011/linkage.cc: Replace
	dg-options with c++11 target selector.
2024-07-06 21:15:25 +01:00
GCC Administrator
92e4d73dd9 Daily bump. 2024-07-06 00:18:02 +00:00
Jonathan Wakely
f63896ff5a
libstdc++: Add dg-error for new -Wdelete-incomplete diagnostics [PR115747]
Since r15-1794-gbeb7a418aaef2e the -Wdelete-incomplete diagnostic is a
permerror instead of a (suppressed in system headers) warning. Add
dg-error directives.

libstdc++-v3/ChangeLog:

	PR c++/115747
	* testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc:
	Add dg-error for new C++26 diagnostics.
2024-07-05 12:18:34 +01:00
Jonathan Wakely
6025256d47
libstdc++: Use RAII in <bits/stl_uninitialized.h>
This adds an _UninitDestroyGuard class template, similar to
ranges::_DestroyGuard used in <bits/ranges_uninitialized.h>. This allows
us to remove all the try-catch blocks and rethrows, because any required
cleanup gets done in the guard destructor.

libstdc++-v3/ChangeLog:

	* include/bits/stl_uninitialized.h (_UninitDestroyGuard): New
	class template and partial specialization.
	(__do_uninit_copy, __do_uninit_fill, __do_uninit_fill_n)
	(__uninitialized_copy_a, __uninitialized_fill_a)
	(__uninitialized_fill_n_a, __uninitialized_copy_move)
	(__uninitialized_move_copy, __uninitialized_fill_move)
	(__uninitialized_move_fill, __uninitialized_default_1)
	(__uninitialized_default_n_a, __uninitialized_default_novalue_1)
	(__uninitialized_default_novalue_n_1, __uninitialized_copy_n)
	(__uninitialized_copy_n_pair): Use it.
2024-07-05 12:18:34 +01:00
Jonathan Wakely
de19b516ed
libstdc++: Use memchr to optimize std::find [PR88545]
This optimizes std::find to use memchr when searching for an integer in
a range of bytes.

libstdc++-v3/ChangeLog:

	PR libstdc++/88545
	PR libstdc++/115040
	* include/bits/cpp_type_traits.h (__can_use_memchr_for_find):
	New variable template.
	* include/bits/ranges_util.h (__find_fn): Use memchr when
	possible.
	* include/bits/stl_algo.h (find): Likewise.
	* testsuite/25_algorithms/find/bytes.cc: New test.
2024-07-05 12:18:34 +01:00
GCC Administrator
304b6464e0 Daily bump. 2024-07-05 00:17:25 +00:00
John David Anglin
46ffda9bf1 Skip 30_threads/future/members/poll.cc on hppa*-*-linux*
hppa*-*-linux* lacks high resolution timer support. Timer resolution
ranges from 1 to 10ms. As a result, a large number of iterations are
needed for the wait_for_0 and ready loops. This causes the
wait_until_sys_epoch and wait_until_steady_epoch loops to timeout.
There the loop wait time is determined by the timer resolution.

2024-07-04  John David Anglin  <danglin@gcc.gnu.org>

libstdc++-v3/ChangeLog:
	PR libstdc++/98678
	* testsuite/30_threads/future/members/poll.cc: Skip on hppa*-*-linux*.
2024-07-04 09:16:18 -04:00
GCC Administrator
614fd0fb30 Daily bump. 2024-06-29 00:17:22 +00:00
Jonathan Wakely
52370c839e
libstdc++: Define __glibcxx_assert_fail for non-verbose build [PR115585]
When the library is configured with --disable-libstdcxx-verbose the
assertions just abort instead of calling __glibcxx_assert_fail, and so I
didn't export that function for the non-verbose build. However, that
option is documented to not change the library ABI, so we still need to
export the symbol from the library. It could be needed by programs
compiled against the headers from a verbose build.

The non-verbose definition can just call abort so that it doesn't pull
in I/O symbols, which are unwanted in a non-verbose build.

libstdc++-v3/ChangeLog:

	PR libstdc++/115585
	* src/c++11/assert_fail.cc (__glibcxx_assert_fail): Add
	definition for non-verbose builds.
2024-06-28 20:19:02 +01:00
Jonathan Wakely
fab60eaa94
libstdc++: Extend std::equal memcmp optimization to std::byte [PR101485]
We optimize std::equal to memcmp for integers and pointers, which means
that std::byte comparisons generate bigger code than char comparisons.

We can't use memcmp for arbitrary enum types, because they could have an
overloaded operator== that has custom semantics, but we know that
std::byte doesn't do that.

libstdc++-v3/ChangeLog:

	PR libstdc++/101485
	* include/bits/stl_algobase.h (__equal_aux1): Check for
	std::byte as well.
	* testsuite/25_algorithms/equal/101485.cc: New test.
2024-06-28 20:19:02 +01:00
Jonathan Wakely
03d3aeb0e0
libstdc++: Do not use C++11 alignof in C++98 mode [PR104395]
When -faligned-new (or Clang's -faligned-allocation) is used our
allocators try to support extended alignments, gated on the
__cpp_aligned_new macro. However, because they use alignof(_Tp) which is
not a keyword in C++98 mode, using -std=c++98 -faligned-new results in
errors from <memory> and other headers.

We could change them to use __alignof__ instead of alignof, but that
would potentially alter the result of the conditions, because e.g.
alignof(long long) != __alignof__(long long) on some targets. That's
probably not an issue for any types with extended alignment, so maybe it
would be a safe change.

For now, it seems acceptable to just disable the extended alignment
support in C++98 mode, so that -faligned-new enables std::align_val_t
and the corresponding operator new overloads, but doesn't affect
std::allocator, __gnu_cxx::__bitmap_allocator etc.

libstdc++-v3/ChangeLog:

	PR libstdc++/104395
	* include/bits/new_allocator.h: Disable extended alignment
	support in C++98 mode.
	* include/bits/stl_tempbuf.h: Likewise.
	* include/ext/bitmap_allocator.h: Likewise.
	* include/ext/malloc_allocator.h: Likewise.
	* include/ext/mt_allocator.h: Likewise.
	* include/ext/pool_allocator.h: Likewise.
	* testsuite/ext/104395.cc: New test.
2024-06-28 20:19:02 +01:00
Jonathan Wakely
ac8c61b62e
libstdc++: Simplify <ext/aligned_buffer.h> class templates
As noted in a comment, the __gnu_cxx::__aligned_membuf class template
can be simplified, because alignof(T) and alignas(T) use the correct
alignment for a data member. That's true since GCC 8 and Clang 8. The
EDG front end (as used by Intel icc, aka "Intel C++ Compiler Classic")
does not implement the PR c++/69560 change, so keep using the old
implementation when __EDG__ is defined, to avoid an ABI change for icc.

For __gnu_cxx::__aligned_buffer<T> all supported compilers agree on the
value of __alignof__(T), but we can still simplify it by removing the
dependency on std::aligned_storage<sizeof(T), __alignof__(T)>.

Add a test that checks that the aligned buffer types have the expected
alignment, so that we can tell if changes like this affect their ABI
properties.

libstdc++-v3/ChangeLog:

	* include/ext/aligned_buffer.h (__aligned_membuf): Use
	alignas(T) directly instead of defining a struct and using 9its
	alignment.
	(__aligned_buffer): Remove use of std::aligned_storage.
	* testsuite/abi/aligned_buffers.cc: New test.
2024-06-28 20:19:02 +01:00
GCC Administrator
4fda39e7cc Daily bump. 2024-06-28 00:18:04 +00:00
Jonathan Wakely
73ad57c244
libstdc++: Fix std::codecvt<wchar_t, char, mbstate_t> for empty dest [PR37475]
For the GNU locale model, codecvt::do_out and codecvt::do_in incorrectly
return 'ok' when the destination range is empty. That happens because
detecting incomplete output is done in the loop body, and the loop is
never even entered if to == to_end.

By restructuring the loop condition so that we check the output range
separately, we can ensure that for a non-empty source range, we always
enter the loop at least once, and detect if the destination range is too
small.

The loops also seem easier to reason about if we return immediately on
any error, instead of checking the result twice on every iteration. We
can use an RAII type to restore the locale before returning, which also
simplifies all the other member functions.

libstdc++-v3/ChangeLog:

	PR libstdc++/37475
	* config/locale/gnu/codecvt_members.cc (Guard): New RAII type.
	(do_out, do_in): Return partial if the destination is empty but
	the source is not. Use Guard to restore locale on scope exit.
	Return immediately on any conversion error.
	(do_encoding, do_max_length, do_length): Use Guard.
	* testsuite/22_locale/codecvt/in/char/37475.cc: New test.
	* testsuite/22_locale/codecvt/in/wchar_t/37475.cc: New test.
	* testsuite/22_locale/codecvt/out/char/37475.cc: New test.
	* testsuite/22_locale/codecvt/out/wchar_t/37475.cc: New test.
2024-06-27 12:02:17 +01:00
Alexandre Oliva
95faa1bea7 [libstdc++] [testsuite] defer to check_vect_support* [PR115454]
The newly-added testcase overrides the default dg-do action set by
check_vect_support_and_set_flags (in libstdc++-dg/conformance.exp), so
it attempts to run the test even if runtime vector support is not
available.

Remove the explicit dg-do directive, so that the default is honored,
and the test is run if vector support is found, and only compiled
otherwise.


for  libstdc++-v3/ChangeLog

	PR libstdc++/115454
	* testsuite/experimental/simd/pr115454_find_last_set.cc: Defer
	to check_vect_support_and_set_flags's default dg-do action.
2024-06-27 07:22:48 -03:00
Jonathan Wakely
dafa750c8a
libstdc++: Fix std::format for chrono::duration with unsigned rep [PR115668]
Using std::chrono::abs is only valid if numeric_limits<rep>::is_signed
is true, so using it unconditionally made it ill-formed to format a
duration with an unsigned rep.

The duration formatter might as negate the duration itself instead of
using chrono::abs, because it already needs to check for a negative
value.

libstdc++-v3/ChangeLog:

	PR libstdc++/115668
	* include/bits/chrono_io.h (formatter<duration<R,P, C>::format):
	Do not use chrono::abs.
	* testsuite/20_util/duration/io.cc: Check formatting a duration
	with unsigned rep.
2024-06-27 09:39:41 +01:00
Jonathan Wakely
8fd84bc009
libstdc++: Add debug assertions to std::vector<bool> [PR103191]
This adds debug assertions for std::vector<bool> element access.

libstdc++-v3/ChangeLog:

	PR libstdc++/103191
	* include/bits/stl_bvector.h (vector<bool>::operator[])
	(vector<bool>::front, vector<bool>::back): Add debug assertions.
	* testsuite/23_containers/vector/bool/element_access/constexpr.cc:
	Remove dg-error that no longer triggers.
2024-06-27 09:39:41 +01:00
Jonathan Wakely
cfc9fa3bdd
libstdc++: Enable more debug assertions during constant evaluation [PR111250]
Some of our debug assertions expand to nothing unless
_GLIBCXX_ASSERTIONS is defined, which means they are not checked during
constant evaluation. By making them unconditionally expand to a
__glibcxx_assert expression they will be checked during constant
evaluation. This allows us to diagnose more instances of undefined
behaviour at compile-time, such as accessing a vector past-the-end.

libstdc++-v3/ChangeLog:

	PR libstdc++/111250
	* include/debug/assertions.h (__glibcxx_requires_non_empty_range)
	(__glibcxx_requires_nonempty, __glibcxx_requires_subscript):
	Define to __glibcxx_assert expressions or to debug mode
	__glibcxx_check_xxx expressions.
	* testsuite/23_containers/array/element_access/constexpr_c++17.cc:
	Add checks for out-of-bounds accesses in constant expressions.
	* testsuite/23_containers/vector/element_access/constexpr.cc:
	Likewise.
2024-06-27 09:39:40 +01:00
GCC Administrator
9c56dc7f52 Daily bump. 2024-06-27 00:17:31 +00:00
Jonathan Wakely
0731985920
libstdc++: Add script to update docs for a new release branch
This should be run on a release branch after branching from trunk.
Various links and references to trunk in the docs will be updated to
refer to the new release branch.

libstdc++-v3/ChangeLog:

	* scripts/update_release_branch.sh: New file.
2024-06-26 21:15:14 +01:00
Jonathan Wakely
6eff23314a
libstdc++: Remove duplicate test
We currently have 808590.cc which only runs for C++98 mode, and
808590-cxx11.cc which only runs for C++11 and later, but have almost
identical content (except for a defaulted special member in the C++11
one, to suppress a -Wdeprecated-copy warning).

This was done originally to ensure that the test ran for both C++98 mode
and C++11 mode, because the logic being tested was different enough to
need both to be tested. But it's trivial to run all tests in multiple
-std modes now, using GLIBCXX_TESTSUITE_STDS, so we don't need two
separate tests. We can remove one of the tests and allow the other one
to run in any -std mode.

libstdc++-v3/ChangeLog:

	* testsuite/20_util/specialized_algorithms/uninitialized_copy/808590.cc:
	Copy defaulted assignment operator from 808590-cxx11.cc to
	suppress a warning.
	* testsuite/20_util/specialized_algorithms/uninitialized_copy/808590-cxx11.cc:
	Removed.
2024-06-26 21:15:14 +01:00
Jonathan Wakely
e65b6627a3
libstdc++: Increase timeouts for PSTL tests in debug mode [PR90276]
These tests compile very slowly in debug mode.

libstdc++-v3/ChangeLog:

	PR libstdc++/90276
	* testsuite/25_algorithms/pstl/alg_modifying_operations/rotate_copy.cc:
	Increase timeout for debug mode.
	* testsuite/25_algorithms/pstl/alg_modifying_operations/transform_binary.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/mismatch.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_sorting/lexicographical_compare.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_sorting/minmax_element.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_sorting/set_symmetric_difference.cc:
	Likewise.
2024-06-26 21:14:22 +01:00
Jonathan Wakely
003ce8a6c4
libstdc++: Work around some PSTL test failures for debug mode [PR90276]
This addresses one known failure due to a bug in the upstream tests, and
a number of timeouts due to the algorithms running much more slowly with
debug mode checks enabled.

libstdc++-v3/ChangeLog:

	PR libstdc++/90276
	* testsuite/25_algorithms/pstl/alg_sorting/partial_sort.cc
	[_GLIBCXX_DEBUG]: Add xfail-run-if for debug mode.
	* testsuite/25_algorithms/pstl/alg_nonmodifying/nth_element.cc
	[_GLIBCXX_DEBUG]: Reduce size of test data.
	* testsuite/25_algorithms/pstl/alg_sorting/includes.cc:
	Likewise.
	* testsuite/25_algorithms/pstl/alg_sorting/set_util.h:
	Likewise.
2024-06-26 21:14:14 +01:00
Jonathan Wakely
0ca8d56f20
libstdc++: Fix std::chrono::tzdb to work with vanguard format
I found some issues in the std::chrono::tzdb parser by testing the
tzdata "vanguard" format, which uses new features that aren't enabled in
the "main" and "rearguard" data formats.

Since 2024a the keyword "minimum" is no longer valid for the FROM and TO
fields in a Rule line, which means that "m" is now a valid abbreviation
for "maximum". Previously we expected either "mi" or "ma". For backwards
compatibility, a FROM field beginning with "mi" is still supported and
is treated as 1900. The "maximum" keyword is only allowed in TO now,
because it makes no sense in FROM. To support these changes the
minmax_year and minmax_year2 classes for parsing FROM and TO are
replaced with a single years_from_to class that reads both fields.

The vanguard format makes use of %z in Zone FORMAT fields, which caused
an exception to be thrown from ZoneInfo::set_abbrev because no % or /
characters were expected when a Zone doesn't use a named Rule. The
ZoneInfo::to(sys_info&) function now uses format_abbrev_str to replace
any %z with the current offset. Although format_abbrev_str also checks
for %s and STD/DST formats, those only make sense when a named Rule is
in effect, so won't occur when ZoneInfo::to(sys_info&) is used.

This change also implements a feature that has always been missing from
time_zone::_M_get_sys_info: finding the Rule that is active before the
specified time point, so that we can correctly handle %s in the FORMAT
for the first new sys_info that gets created. This requires implementing
a poorly documented feature of zic, to get the LETTERS field from a
later transition, as described at
https://mm.icann.org/pipermail/tz/2024-April/058891.html
In order for this to work we need to be able to distinguish an empty
letters field (as used by CE%sT where the variable part is either empty
or "S") from "the letters field is not known for this transition". The
tzdata file uses "-" for an empty letters field, which libstdc++ was
previously replacing with "" when the Rule was parsed. Instead, we now
preserve the "-" in the Rule object, so that "" can be used for the case
where we don't know the letters (and so need to decide it).

libstdc++-v3/ChangeLog:

	* src/c++20/tzdb.cc (minmax_year, minmax_year2): Remove.
	(years_from_to): New class replacing minmax_year and
	minmax_year2.
	(format_abbrev_str, select_std_or_dst_abbrev): Move earlier in
	the file. Handle "-" for letters.
	(ZoneInfo::to): Use format_abbrev_str to expand %z.
	(ZoneInfo::set_abbrev): Remove exception. Change parameter from
	reference to value.
	(operator>>(istream&, Rule&)): Do not clear letters when it
	contains "-".
	(time_zone::_M_get_sys_info): Add missing logic to find the Rule
	in effect before the time point.
	* testsuite/std/time/tzdb/1.cc: Adjust for vanguard format using
	"GMT" as the Zone name, not as a Link to "Etc/GMT".
	* testsuite/std/time/time_zone/sys_info_abbrev.cc: New test.
2024-06-26 21:04:18 +01:00
Alexandre Oliva
eed2027843 [libstdc++] [testsuite] no libatomic for vxworks
libatomic hasn't been ported to vxworks.  Most of the stdatomic.h and
<atomic> underlying requirements are provided by builtins and libgcc,
and the vxworks libc already provides remaining __atomic symbols, so
porting libatomic doesn't seem to make sense.

However, some of the target arch-only tests in
add_options_for_libatomic cover vxworks targets, so we end up
attempting to link libatomic in, even though it's not there.
Preempt those too-broad tests.


Co-Authored-By: Marc Poulhiès <poulhies@adacore.com>

for  libstdc++-v3/ChangeLog

	* testsuite/lib/dg-options.exp (add_options_for_libatomic):
	None for *-*-vxworks*.
2024-06-26 02:08:27 -03:00
GCC Administrator
9fe669ced1 Daily bump. 2024-06-26 00:17:38 +00:00