]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
4 weeks agoc++/reflection: Support members_of and imported namespace-scope names [PR124200]
Nathaniel Shead [Sun, 22 Feb 2026 15:20:38 +0000 (02:20 +1100)] 
c++/reflection: Support members_of and imported namespace-scope names [PR124200]

namespace_members_of needs to iterate over all VECTOR_BINDINGs
for the given namespace, and handle deduplication.

PR c++/124200

gcc/cp/ChangeLog:

* name-lookup.h (walk_namespace_bindings): Declare.
* name-lookup.cc (walk_namespace_bindings): New function.
* reflect.cc (namespace_members_of): Use it.

gcc/testsuite/ChangeLog:

* g++.dg/modules/reflect-2_a.H: New test.
* g++.dg/modules/reflect-2_b.C: New test.
* g++.dg/modules/reflect-2_c.C: New test.
* g++.dg/modules/reflect-3_a.H: New test.
* g++.dg/modules/reflect-3_b.C: New test.
* g++.dg/modules/reflect-3_c.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Co-authored-by: Thomas Berger <loki+gcc@loki.codes>
Reviewed-by: Jason Merrill <jason@redhat.com>
Reviewed-by: Marek Polacek <polacek@redhat.com>
4 weeks agoc++/modules: Reparent linemaps for partition direct loads [PR124309]
Nathaniel Shead [Sun, 8 Mar 2026 14:10:02 +0000 (01:10 +1100)] 
c++/modules: Reparent linemaps for partition direct loads [PR124309]

The attached testcase failed because when part-11_d.C sees the import
of X through Z:part, the module's location is maintained as the indirect
(imported) location through Y that came first, but it is still promoted
to a direct import.

When part-11_e.C reads the module then it sees a direct import of X
through Z, but there is no valid source location for X in Z (because we
only kept the imported location) and so we report a bad CMI.

This fixes the issue by updating a module seen as direct for the first
time via a partition to reparent the module's location to where the
partition imported it from, so we properly process it as a direct
location that we need to write out, similarly to what we do when we
reimport an indirect module within the module purview.

PR c++/124309

gcc/cp/ChangeLog:

* module.cc (enum module_directness): Fix inconsistent
capitalisation.
(module_state::read_imports): Reparent module locations newly
seen as direct via partition.

gcc/testsuite/ChangeLog:

* g++.dg/modules/part-11_a.C: New test.
* g++.dg/modules/part-11_b.C: New test.
* g++.dg/modules/part-11_c.C: New test.
* g++.dg/modules/part-11_d.C: New test.
* g++.dg/modules/part-11_e.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
4 weeks agoUpdate gcc sv.po
Joseph Myers [Thu, 12 Mar 2026 22:39:15 +0000 (22:39 +0000)] 
Update gcc sv.po

* sv.po: Update.

4 weeks agosimplify-rtx: Fix the case where subreg of a vec_concat could fail [PR123822]
Andrew Pinski [Wed, 11 Mar 2026 20:01:08 +0000 (13:01 -0700)] 
simplify-rtx: Fix the case where subreg of a vec_concat could fail [PR123822]

So combine (rightfully) produces:
(subreg:DD (vec_concat:V2DI (const_int -1 [0xffffffffffffffff])
        (reg:DI 145 [ _22 ])) 0)

And then calls simplify_subreg on it.
simplify_subreg then sees it can remove the vec_concat as this is
the lower part and try to do `(subreg:DD (const_int -1 [0xffffffffffffffff]))`
but that is an invalid constant for DF64 so simplify_subreg rejects
that and returns NULL but there is code in simplify_subreg to create
a SUBREG then if the subreg validates. The problem is we are using DImode
for the inner mode and that validates but when gen_rtx_SUBREG is called
the inner mode of DImode is not there; only VOIDmode.
So the fix is to check for VOIDmode before the call to validate_subreg.

Bootstrapped and tested on x86_64-linux-gnu. And lightly tested for aarch64-linux-gnu.

PR rtl-optimization/123822

gcc/ChangeLog:

* simplify-rtx.cc (simplify_context::simplify_subreg): Check the
mode of the part to be non-VOIDmode before calling gen_rtx_SUBREG.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr123822-1.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
4 weeks ago[PR124452, LRA]: Move point of skipping postponed insn
Vladimir N. Makarov [Thu, 12 Mar 2026 20:47:16 +0000 (16:47 -0400)] 
[PR124452, LRA]: Move point of skipping postponed insn

Patch for PR115042 skipped processing postponed insns after possible
generation of address reloads for the postponed insns.  The reload
insns were lost in the code and this resulted in wrong code generation.

To fix this the patch moves skipping the postponed insn before any
reload generation.

gcc/ChangeLog:

PR rtl-optimization/124452
* lra-constraints.cc (curr_insn_transform): Move return on the
postponed insn before any reload generation.

4 weeks agotestsuite/c++: Fix lifetime of lambda in pr103953.C [PR119930]
Andrew Pinski [Sat, 7 Mar 2026 19:24:14 +0000 (11:24 -0800)] 
testsuite/c++: Fix lifetime of lambda in pr103953.C [PR119930]

So in the end the problem with pr103953.C is the lifetime
of a lambda object is not extended past the statement.
With sane operator new we are able to delete stores using
that object as it is dead afterwards.

So the fix to the testcase is to make the lambda its own
object and then call it.

I also went back to check to make sure the original issue was
reproducible with this version too.

Tested on x86_64-linux-gnu and the testcase failure is gone.

PR testsuite/119930

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/torture/pr103953.C: Store the second
lambda into its own object to extend its lifeime.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
4 weeks agoRevert "build: Properly set gas_flag/gnu_ld_flag"
Rainer Orth [Thu, 12 Mar 2026 20:09:39 +0000 (21:09 +0100)] 
Revert "build: Properly set gas_flag/gnu_ld_flag"

As reported in

https://gcc.gnu.org/pipermail/gcc-patches/2026-March/709850.html

this patch

commit fdd1d058f289eda39b6eb1386a0dabef3478d298
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date:   Fri Feb 6 20:31:27 2026 +0100

    build: Properly set gas_flag/gnu_ld_flag

still causes testsuite regressions in some scenarious (a cross to
arm-none-eabi in this case).

Comparing gcc/auto-host.h before and after that patch shows that
HAVE_GNU_AS and HAVE_GNU_LD are mis-detected again:

@@ -1640 +1616 @@
-#define HAVE_GNU_AS 1
+#define HAVE_GNU_AS 0
@@ -1652 +1628 @@
-#define HAVE_GNU_LD 1
+#define HAVE_GNU_LD 0

Since

commit c807ac4d96dbb2e612fa2e8ebf7485b2fc3db117
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date:   Sun Mar 1 18:04:03 2026 +0100

    Switch to HAVE_SOLARIS_AS

and

commit 96f3b4dfe16984299d65d7a071a5586dafcbd046
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date:   Sun Mar 1 18:32:26 2026 +0100

    Switch to HAVE_SOLARIS_LD

this patch is no longer needed to avoid the HAVE_GNU_AS/HAVE_GNU_LD
misdetections on Solaris.  In fact, the few remaining uses of those
macros are expected to be removed in GCC 17 stage 1.

For the moment, I'd like to revert the patch above.

Bootstrapped without regressions no i386-pc-solaris2.11,
sparc-sun-solaris2.11, x86_64-pc-linux-gnu, and by comparing auto-host.h
in make configure-gcc for a cross to arm-none-eabi.

This reverts commit fdd1d058f289eda39b6eb1386a0dabef3478d298.

4 weeks agoFortran: [PR121743] ICE in build_function_decl.
Jerry DeLisle [Thu, 12 Mar 2026 17:23:47 +0000 (10:23 -0700)] 
Fortran: [PR121743] ICE in build_function_decl.

PR fortran/121743

gcc/fortran/ChangeLog:

* trans-decl.cc (build_function_decl): Adjust the
gcc_assert condition to avoid the ICE.

gcc/testsuite/ChangeLog:

* gfortran.dg/pr121743.f90: New test.

Co-Authored-By: Gilles Gouaillardet <gilles.gouaillardet@gmail.com>
4 weeks agotestsuite: Remove xfails in gcc.dg/attr-alloc_size-11.c [PR80006]
Rainer Orth [Thu, 12 Mar 2026 19:57:21 +0000 (20:57 +0100)] 
testsuite: Remove xfails in gcc.dg/attr-alloc_size-11.c [PR80006]

As described in PR middle-end/80006, the gcc.dg/attr-alloc_size-11.c
test XPASSes on many targets:

XPASS: gcc.dg/attr-alloc_size-11.c missing range info for short (test for warnings, line 51)
XPASS: gcc.dg/attr-alloc_size-11.c missing range info for signed char (test for warnings, line 50)

Therefore, this patch removes the xfails.

Tested on i386-pc-solaris2.11, sparc-sun-solaris2.11, and
x86_64-pc-linux-gnu.

2026-03-02  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc/testsuite:
PR tree-optimization/80006
* gcc.dg/attr-alloc_size-11.c (dg-warning): Remove xfails.

4 weeks agotestsuite: Fix gcc.dg/plugin/must-tail-call-2.c on SPARC [PR121159]
Rainer Orth [Thu, 12 Mar 2026 19:53:50 +0000 (20:53 +0100)] 
testsuite: Fix gcc.dg/plugin/must-tail-call-2.c on SPARC [PR121159]

The gcc.dg/plugin/must-tail-call-2.c test FAILs on 32 and 64-bit SPARC:

FAIL: gcc.dg/plugin/must-tail-call-2.c -fplugin=./must_tail_call_plugin.so (test for excess errors)

Excess errors:
gcc.dg/plugin/must-tail-call-2.c:58:3: error: cannot tail-call: target is not able to optimize the call into a sibling call

As discussed in the PR, this can be avoided by compiling with
-fdelayed-branch on SPARC.

Tested on sparc-sun-solaris2.11, sparc64-unknown-linux-gnu, and
x86_64-pc-linux-gnu.

2026-03-09  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc/testsuite:
PR middle-end/121159
* gcc.dg/plugin/must-tail-call-2.c (dg-additional-options): Add
-fdelayed-branch on SPARC.

4 weeks agolibphobos: Implement IeeeFlags on SPARC [PR123202]
Rainer Orth [Thu, 12 Mar 2026 19:51:02 +0000 (20:51 +0100)] 
libphobos: Implement IeeeFlags on SPARC [PR123202]

The libphobos.phobos/std_math_hardware.d test FAILs on SPARC:

FAIL: libphobos.phobos/std_math_hardware.d (test for excess errors)
UNRESOLVED: libphobos.phobos/std_math_hardware.d compilation failed to produce executable

Excess errors:
libphobos.phobos/std_math_hardware.d:7: error: undefined identifier 'FloatingPointControl'

There's currently no support for IeeeFlags on SPARC.

One part of an implementation has already been committed to upstream phobos

commit aa963e98c55b36b5d608f9443d96c66b63d16d8f
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date:   Thu Feb 19 12:47:58 2026 +0100

    std/math/hardware.d: Partial IeeeFlags implementation on SPARC (#10958)

but the actual implementation is specific to a GDC-specific part of
hardware.d which isn't upstream yet.  This patch provides that part.

Tested on sparc-sun-solaris2.11 and sparc64-unknown-linux-gnu.

2025-12-19  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

libphobos:
PR d/123202
* src/std/math/hardware.d (getIeeeFlags) [GNU && SPARC_Any]: Implement.
(resetIeeeFlags) [GNU && SPARC_Any]: Likewise.
(hasExceptionTraps) [SPARC_Any]: Return true.
(getControlState) [GNU && SPARC_Any]: Implement.
(setControlState) [GNU && SPARC_Any]: Likewise.

4 weeks agolibstdc++: Increase timeout for 23_containers/mdspan/submdspan tests [PR124290]
Rainer Orth [Thu, 12 Mar 2026 19:46:22 +0000 (20:46 +0100)] 
libstdc++: Increase timeout for 23_containers/mdspan/submdspan tests [PR124290]

The 23_containers/mdspan/submdspan/selections tests often time out on
Solaris/SPARC:

WARNING: 23_containers/mdspan/submdspan/selections/left_padded.cc  -std=gnu++26 (test for excess errors) program timed out.
FAIL: 23_containers/mdspan/submdspan/selections/left_padded.cc  -std=gnu++26 (test for excess errors)

Even on an unloaded system, compilation takes ca. 4 minutes, close to
the default DejaGnu timeout of 5 minutes.  Setting/increasing the
timeout factor to 2 was not enough, so this patch raises it to 4 for all
5 tests.

Tested on sparc-sun-solaris2.11 and x86_64-pc-linux-gnu.

2026-03-06  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

libstdc++-v3:
PR libstdc++/124290
* testsuite/23_containers/mdspan/submdspan/selections/left_padded.cc:
Use dg-timeout-factor 4.
* testsuite/23_containers/mdspan/submdspan/selections/left.cc:
* testsuite/23_containers/mdspan/submdspan/selections/right_padded.cc:
* testsuite/23_containers/mdspan/submdspan/selections/right.cc:
Likewise.
* testsuite/23_containers/mdspan/submdspan/selections/stride.cc:
Likewise.

4 weeks agoc++/reflection: add fixed test
Marek Polacek [Thu, 12 Mar 2026 19:27:54 +0000 (15:27 -0400)] 
c++/reflection: add fixed test

This test I got today was just fixed by r16-8027 earlier today.

gcc/testsuite/ChangeLog:

* g++.dg/reflect/define_static_array5.C: New test.

4 weeks agoc++/reflection: class member access with [: T::BASELINK :] [PR124440]
Marek Polacek [Wed, 11 Mar 2026 17:28:30 +0000 (13:28 -0400)] 
c++/reflection: class member access with [: T::BASELINK :] [PR124440]

Let

  struct B { consteval virtual int fn() const { return 1; } };
  struct D : B { consteval int fn() const override { return 2; } };

and consider

  d.[:^^B::fn:]()  // #1
  d.[:^^B:]::fn()  // #2

then #1 should yield 2 and #2 should yield 1: #1 doesn't count as
qualified name lookup and so should be treated as "d.fn()" where
lookup_vfn_in_binfo in build_over_call finds D::fn.  But #2 is like
"d.B::fn()" which should prevent a virtual function call and we
should be calling B::fn.

We already handle this correctly outside of templates: finish_call_expr
only checks IDK to see if it should disallow_virtual, but in tsubst_expr
it looks at BASELINK_QUALIFIED_P, which is wrongly set for #1.

BASELINK_QUALIFIED_P is always set by adjust_result_of_q_name_lookup,
so cp_parser_postfix_dot_deref_expression should clear it for case #1.
With this patch, we only set BASELINK_QUALIFIED_P if qualifying_scope
was not null.

Unfortunately we can't avoid the adjust_result_ call because then
lookup_vfn_in_binfo gets a binfo that isn't BINFO_PRIMARY_P and it won't
find D::fn.  It seems it is necessary to have that adjust_result_ ->
lookup_base adjustment.

And then tsubst_expr has to do the same thing for when we have

  d.[:^^T::fn:]()

where T is a tparm that is substituted with B.

PR c++/124440

gcc/cp/ChangeLog:

* parser.cc (cp_parser_postfix_dot_deref_expression): Pass
parser->scope to adjust_result_of_qualified_name_lookup even
when splice_p.  Assign the result of
adjust_result_of_qualified_name_lookup to name.
* pt.cc (tsubst_expr): Call adjust_result_of_qualified_name_lookup
for BASELINKs in splice-expressions.
* search.cc (adjust_result_of_qualified_name_lookup): Return early
if decl is not a BASELINK.  If qualifying_scope is null, use decl's
binfo.  Set BASELINK_QUALIFIED_P only if qualifying_scope wasn't
null.

gcc/testsuite/ChangeLog:

* g++.dg/reflect/member21.C: Uncomment the commented out asserts.

Reviewed-by: Jason Merrill <jason@redhat.com>
4 weeks agoFortran: Add missing deferred type PDT errors in allocate [PR115316]
Paul Thomas [Thu, 12 Mar 2026 17:50:55 +0000 (17:50 +0000)] 
Fortran: Add missing deferred type PDT errors in allocate [PR115316]

2026-03-12  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/115316
* match.cc (spec_list_type): A version of gfc_spec_list_type,
which returns true if any of the LEN parameters are deferred.
(gfc_match_allocate): Use it to set saw_deferred if any of the
parameters of the allocate object are deferred.

gcc/testsuite/
PR fortran/115316
* gfortran.dg/pdt_87.f03: New test.

4 weeks agoFortran: gfortran PDT component access [PR122696]
Paul Thomas [Thu, 12 Mar 2026 17:35:51 +0000 (17:35 +0000)] 
Fortran: gfortran PDT component access [PR122696]

2026-03-12  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/122696
* resolve.cc (resolve_assoc_var): A generic function selector
must be resolved to a specific function before doing anything
more with the associate name.

gcc/testsuite/
PR fortran/122696
* gfortran.dg/pdt_89.f03: New test.

4 weeks agoAda: Fix Program_Error raised in a Bounded_Indefinite_Holders instance
Steve Baird [Thu, 12 Mar 2026 17:18:36 +0000 (18:18 +0100)] 
Ada: Fix Program_Error raised in a Bounded_Indefinite_Holders instance

If Ada.Containers.Bounded_Indefinite_Holders is instantiated with an
Element_Type that requires finalization, the declaration of a Holder
object with an explicit initial value may incorrectly raise Program_Error
during its elaboration.

gcc/ada/
PR ada/124016
* libgnat/a-cbinho.adb (Create_Subpool): Handle the case where
the type Holder_Subpool has nontrivial finalization. Declare the
local variable Subpool with its Import aspect specified (to avoid
unwanted finalization), and make corresponding changes in order to
initialize that variable.
* libgnat/s-stposu.ads (_Adjust_Clone): New procedure.
* libgnat/s-stposu.adb (_Adjust_Clone): New body.

4 weeks agoAda: Fix missing error for dangling pointer from access discriminant
Eric Botcazou [Thu, 12 Mar 2026 17:11:34 +0000 (18:11 +0100)] 
Ada: Fix missing error for dangling pointer from access discriminant

This restores the original computation of the scope depth of the innermost
enclosing master of a given node and performs a couple of other cleanups.

Note that this has uncovered an issue in the ACATS c3a0025 test and the
change contains the modification that has been submitted to the ACAA.

gcc/ada/
PR ada/124369
* accessibility.adb (Accessibility_Message): Give an error instead
of a warning in an instance when No_Dynamic_Accessibility_Checks is
in effect.
(Innermost_Master_Scope_Depth): Restore the original computation of
the nearest enclosing dynamic scope.
* sem_attr.adb (Resolve_Attribute) <Attribute_Access>: Call the
Accessibility_Message routine in all cases to give accessibility
errors and do not return.  Call the Static_Accessibility_Level
function in all cases to compute static accessibility levels.
Add guard before calling Prefix_With_Safe_Accessibility_Level.

gcc/testsuite/
* ada/acats-3/tests/c3/c3a0025.a: Tweak.
* ada/acats-4/tests/c3/c3a0025.a: Likewise.
* gnat.dg/access12.adb: New test.

4 weeks agoAda: Fix missing accessibility check in assignment for aliased parameter
Eric Botcazou [Thu, 12 Mar 2026 16:58:41 +0000 (17:58 +0100)] 
Ada: Fix missing accessibility check in assignment for aliased parameter

This plugs a loophole related to static accessibility checks in assignment
for aliased parameters.

gcc/ada/
PR ada/124376
* sem_res.adb (Resolve_Actuals.Check_Aliased_Parameter): Deal with
assignment statements.

gcc/testsuite/
* gnat.dg/aliased3.adb: New test.

4 weeks agoAda: Complete implementation of AI12-0402
Eric Botcazou [Thu, 12 Mar 2026 16:52:08 +0000 (17:52 +0100)] 
Ada: Complete implementation of AI12-0402

This implements AI12-0402 in the function computing the accessibility level
of function calls in the general case, as opposed to the more specific case
of the RM 6.4.1(6.4) legality rule.  This also removes a ??? note attached
to the handling of N_Assignment_Statement nodes in this function.

gcc/ada/
PR ada/124376
* accessibility.adb (Accessibility_Level): Minor formatting tweaks.
(Accessibility_Level.Function_Call_Or_Allocator_Level): Implement
AI12-0402.  Reimplement the loop climbing up the parent chain to
find an object being initialized.  Restrict the specific handling
of N_Assignment_Statement nodes to the anonymous access type case.
* doc/gnat_rm/implementation_of_ada_2022_features.rst: Adjust the
entries of AI12-0277, AI12-0345 & AI12-0372, add one for AI12-0402.
* gnat_rm.texi: Regenerate.

4 weeks agoc++: require C++26 for -freflection [PR124447]
Marek Polacek [Wed, 11 Mar 2026 20:10:12 +0000 (16:10 -0400)] 
c++: require C++26 for -freflection [PR124447]

-freflection is unusable without C++26 so let's not allow it.

PR c++/124447

gcc/c-family/ChangeLog:

* c-opts.cc (c_common_post_options): Error if -freflection is used
without -std=c++26 or -std=gnu++26.

Reviewed-by: Jason Merrill <jason@redhat.com>
4 weeks agoipa-prop: Skip analysis od static constructor entries with no index (PR124260)
Martin Jambor [Thu, 12 Mar 2026 15:59:34 +0000 (16:59 +0100)] 
ipa-prop: Skip analysis od static constructor entries with no index (PR124260)

PR 124260 is about dereferencing a NULL "index" tree when traversing
static constructors of global variables.  As discussed in the bug, it
is unclear whether that is allowed but ObjC compiler creates these at
least on 32bit hosts.  Ian plans to fix this in the FE in the next
stage1 but for this stage4, such entries can be easily skipped in
ipa-prop (too).  The collected information is used for speculative
"devirtualization" ony and so if we miss a relevant entry, it may only
result in a "bad" decision whether to do that or not.

gcc/ChangeLog:

2026-03-11  Martin Jambor  <mjambor@suse.cz>

PR objc/124260
* ipa-prop.cc (ipa_analyze_var_static_initializer): Skip a constructor
entry if its index is NULL.

4 weeks agoc++/modules: Support diagnostic classification changes in macros [PR124459]
Nathaniel Shead [Thu, 12 Mar 2026 13:47:36 +0000 (00:47 +1100)] 
c++/modules: Support diagnostic classification changes in macros [PR124459]

Diagnostic classification changes via _Pragma can occur in macros, but
weren't taking effect in imported modules.  The issue is that we were
reading the diagnostic classification map before we processed the macro
maps, which meant that all locations in macros were just falling back
to the abstract location of the module itself.  Fixed by moving the
processing after we've read the macro maps.

PR c++/124459

gcc/cp/ChangeLog:

* module.cc (module_state::read_initial): Move
read_diagnostic_classification after read_macro_maps.

gcc/testsuite/ChangeLog:

* g++.dg/modules/warn-spec-4_a.C: New test.
* g++.dg/modules/warn-spec-4_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
4 weeks agoc++/modules: Merge synthesized definitions of defaulted members [PR124311]
Nathaniel Shead [Mon, 2 Mar 2026 14:24:06 +0000 (01:24 +1100)] 
c++/modules: Merge synthesized definitions of defaulted members [PR124311]

When a TU synthesizes a definition of a defaulted member function we
mark the TU that did this as the originating module, and so export it
from there.  If this TU is imported into a module that already has a
declaration of this entity the declarations should be merged.

This patch fixes an issue where this merging was not occurring for
explicitly defaulted member functions, by checking DECL_DEFAULTED_FN
instead of just DECL_ARTIFICIAL.

PR c++/124311

gcc/cp/ChangeLog:

* module.cc (trees_in::key_mergeable): Check DECL_DEFAULTED_FN
instead of DECL_ARTIFICIAL.

gcc/testsuite/ChangeLog:

* g++.dg/modules/imp-member-5_a.C: New test.
* g++.dg/modules/imp-member-5_b.C: New test.
* g++.dg/modules/imp-member-5_c.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
4 weeks agoc++/modules: Check for redeclarations of members in wrong module
Nathaniel Shead [Sat, 7 Mar 2026 06:14:55 +0000 (17:14 +1100)] 
c++/modules: Check for redeclarations of members in wrong module

We had missed checking whether we were doing an (outside class)
declaration of a member attached to the wrong module.  This patch adds
those checks.

Within duplicate_decls/maybe_module_redeclare there's not a nice way to
do this because the attachment of a member is always calculated based on
the attachment of its owning type, which defeats the purpose here.
Instead I added the checks to start_decl and grokfndecl where we do
other various checks for if a redeclaration of a class member is legal.

gcc/cp/ChangeLog:

* decl.cc (start_decl): Check module_may_redeclare for members.
(grokfndecl): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/modules/class-12_a.C: New test.
* g++.dg/modules/class-12_b.C: New test.
* g++.dg/modules/class-12_c.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
4 weeks agotestsuite: Add testcase for bug fixed on trunk but not in 15/14 [PR124154]
Jakub Jelinek [Thu, 12 Mar 2026 14:23:48 +0000 (15:23 +0100)] 
testsuite: Add testcase for bug fixed on trunk but not in 15/14 [PR124154]

This testcase used to be rejected before r16-970, but is accepted since
then.  It used to be rejected in 15.1 and 14.2 too, but PR120123
r15-9757 and r14-11823 backports started to ICE on it instead.
In 13/12 it is still rejected, so not a regression there.

2026-03-12  Jakub Jelinek  <jakub@redhat.com>

PR c++/124154
* g++.dg/cpp23/explicit-obj-lambda21.C: New test.

4 weeks agoc++/modules: Fix ICE in xref_basetypes on class redefinition
Nathaniel Shead [Sat, 7 Mar 2026 13:13:28 +0000 (00:13 +1100)] 
c++/modules: Fix ICE in xref_basetypes on class redefinition

In a modules scenario, when we bail out of begin_class_definition due to
an error in module_may_redeclare, we return error_mark_node but had
already started building the class definition.  When we re-enter
cp_parser_class_head we then successfully reach xref_basetypes, where we
then crash because the binfo slot is non-null.

This fixes the issue by moving the module_may_redeclare check earlier,
to before we call xref_basetypes, so that we don't start building the
definition if we were going to bail anyway.  As a side effect this also
moves the check to before we update the DECL_SOURCE_LOCATION of the type
to the start of the class head, so that when we complain about
mismatched attachment we can point to the imported declaration rather
than referring to ourselves again.

gcc/cp/ChangeLog:

* semantics.cc (begin_class_definition): Move
module_may_redeclare check to...
* parser.cc (cp_parser_class_head): ...here.

gcc/testsuite/ChangeLog:

* g++.dg/modules/class-13_a.C: New test.
* g++.dg/modules/class-13_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
4 weeks agoc++/modules: Don't create bindings for hidden friends [PR124390]
Nathaniel Shead [Sat, 7 Mar 2026 15:48:10 +0000 (02:48 +1100)] 
c++/modules: Don't create bindings for hidden friends [PR124390]

In r16-6343-gc368ea51b3bae27e3007b9bd89f6162c4c80259f we stopped walking
attached decls for a DECL_MODULE_KEYED_DECLS_P entity during dependency
gathering so that we didn't unnecessarily expose them if they weren't
going to be emitted anyway, and relied on walking the definition to
properly setup dependencies.

But the linked PR shows that if those attached decls instantiate a
template that pushes a hidden friend, they might be found anyway even if
we don't find them via the function definition, because we see the
hidden decls during add_binding_entity.

Apart from causing this crash, walking these hidden decls is both
pointless (hidden friends, if needed, will always be walked by their
owning class type, and ADL does not need namespace-scope bindings to
call them) and expensive, because this can cause a large swathe of other
otherwise discarded GMF entities to be marked as reachable.

This patch fixes the issue by not creating bindings for hidden friends.
Perhaps no hidden entities should have bindings at all, but doing this
causes make_dependency to break on the underlying alias decl for a
purview DECL_LOCAL_DECL_P when considering additional bindings that need
to be created, and I think we might need this to stay around so that we
can properly merge these decls anyway (though I haven't investigated
this yet).  So this patch goes for a more minimal fix for now.

PR c++/124390

gcc/cp/ChangeLog:

* module.cc (depset::hash::add_binding_entity): Don't create
bindings for hidden friends.

gcc/testsuite/ChangeLog:

* g++.dg/modules/friend-13.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
4 weeks agoc++: Fix up ICE check_out_of_consteval_use_r on some OpenMP clauses
Jakub Jelinek [Thu, 12 Mar 2026 14:13:54 +0000 (15:13 +0100)] 
c++: Fix up ICE check_out_of_consteval_use_r on some OpenMP clauses

When testing make check in libgomp with
RUNTESTFLAGS='--target_board=unix/-std=gnu++26/-freflection'
there are several ICEs.  One is what I've just committed a fix for,
another one is on OpenMP clauses with iterators, where we use
TREE_VEC with 6 arguments as a temporary hack created by
cp_parser_omp_iterator, the first operand of that is an artificial
VAR_DECL for a variable that should be later on temporarily in scope
when handling the iterator during gimplification, then a few
expressions for low/high bound/step and finally the last one can
be a BLOCK covering the expression in the clause argument.  Unfortunately
check_out_of_consteval_use_r just ICEs on it, BLOCK doesn't have TREE_TYPE.
While this could be handled specially for
OMP_CLAUSE with OMP_CLAUSE_{DEPEND,AFFINITY,TO,FROM,MAP} only and only for
TREE_VECs in TREE_LIST of their argument, just punting on BLOCK like the
patch below seems to be far easier.

Note, with these 2 changes no ICEs in libgomp make check left.

2026-03-12  Jakub Jelinek  <jakub@redhat.com>

* reflect.cc (check_out_of_consteval_use_r): Don't walk BLOCK
subtrees.

* g++.dg/reflect/omp_depend1.C: New test.

4 weeks agobootstrap/124406 - fix lean LTO profiledboostrap
Richard Biener [Thu, 12 Mar 2026 12:03:02 +0000 (13:03 +0100)] 
bootstrap/124406 - fix lean LTO profiledboostrap

On s390x we are seeing CFG divergence when using the boostrap-lto-lean
config with profiledbootstrap which uses a non-LTO build for
stageprofile and a LTO build for stagefeedback.  This is caused by
local IPA pure-const skipping some analysis only when not doing LTO.

The following removes this divergence.  Proposed by Honza in the PR,
profilebootstrapped with bootstrap-lto-lean on s390x-linux-gnu.

PR bootstrap/124406
* ipa-pure-const.cc (skip_function_for_local_pure_const):
Do not analyze interposable functions when LTO is enabled.

4 weeks agosh: Remove TARGET_PROMOTE_PROTOTYPES
H.J. Lu [Wed, 11 Mar 2026 15:43:01 +0000 (08:43 -0700)] 
sh: Remove TARGET_PROMOTE_PROTOTYPES

TARGET_PROMOTE_PROTOTYPES is an optimization, not an ABI requirement.
TARGET_PROMOTE_FUNCTION_MODE should be used for ABI requirement, which
is properly defined for sh.  Remove TARGET_PROMOTE_PROTOTYPES from sh.

gcc/

PR target/122925
PR target/119979
* config/sh/sh.cc (TARGET_PROMOTE_PROTOTYPES): Removed.

gcc/testsuite/

PR target/122925
PR target/119979
* gcc.dg/pr122925.c: New test.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
4 weeks agofortran: Fix UB in transfer_expr [PR124450]
Jakub Jelinek [Thu, 12 Mar 2026 11:39:43 +0000 (12:39 +0100)] 
fortran: Fix UB in transfer_expr [PR124450]

trans-io.cc (transfer_array_component) calls transfer_expr with
NULL code:
  transfer_expr (&se, &cm->ts, tmp, NULL, NULL_TREE);
I'm surprised it doesn't ICE in other spots that dereference
code->whatever but each one is guarded with some condition
that perhaps don't trigger in that case for some reason.
Anyway, the &code->loc case does trigger, it doesn't ICE, but
it is undefined behavior in the compiler when code is NULL,
and we'd crash if the where argument of 3*sizeof(void*) is
dereferenced.  Code I've checked can handle NULL where though.

2026-03-12  Jakub Jelinek  <jakub@redhat.com>

PR fortran/124450
* trans-io.cc (transfer_expr): If code is NULL, call
transfer_array_component with NULL where argument rather than
&code->loc.

* gfortran.dg/pr124450.f90: New test.

4 weeks agoFortran: gfortran PDT component access [PR97818]
Paul Thomas [Thu, 12 Mar 2026 11:21:23 +0000 (11:21 +0000)] 
Fortran: gfortran PDT component access [PR97818]

2026-03-12  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/97818
* trans-decl.cc (gfc_trans_deferred_vars): Make sure that the
result symbol is referenced before allocating parameterized
components.

gcc/testsuite/
PR fortran/97818
* gfortran.dg/pdt_88.f03: New test.

4 weeks agofold-mem-offsets: Clarify why do_analysis pre-marks the memory insn
Philipp Tomsich [Mon, 23 Feb 2026 19:22:03 +0000 (20:22 +0100)] 
fold-mem-offsets: Clarify why do_analysis pre-marks the memory insn

The bitmap_set_bit call before fold_offsets in do_analysis is
intentional: fold_offsets requires all uses of a definition to already
be in can_fold_insns before it will mark the definition as foldable.
Pre-marking the memory instruction (which is the root use) is necessary
for its address definitions to pass this check during the DFS.

Replace the generic comment with one that explains this dependency.

gcc/ChangeLog:

* fold-mem-offsets.cc (do_analysis): Revise comment.

4 weeks agolibstdc++: Fix mingw-w64 build due to __max macro
Jonathan Wakely [Wed, 11 Mar 2026 21:22:12 +0000 (21:22 +0000)] 
libstdc++: Fix mingw-w64 build due to __max macro

The stdlib.h header on mingw defines a function-like macro called __max,
which causes an error here:

include/format:3785:55: error: macro '__max' requires 2 arguments, but only 1 given
 3785 |               iter_difference_t<_OutIter> __max(_M_max);

We have lots of existing variables called __max, but this is the only
case that uses direct-initialization and so interferes with the
function-like macro in stdlib.h

The fix applied here is just to rename the variable. We can't use
direct-list-initialization because the conversion from size_t to the
difference type would be narrowing. We prefer not to use
copy-initialization so that conversion to the difference type is
explicit not implicit.

libstdc++-v3/ChangeLog:

* include/std/format (__format::_Ptr_sink::_M_finish): Rename
__max variable to __m.
* testsuite/17_intro/names.cc (__max): Define function-like
macro.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 weeks agosymtab: Fix init and fini priority to reset to default [PR120030]
Andrew Pinski [Wed, 11 Mar 2026 21:41:31 +0000 (14:41 -0700)] 
symtab: Fix init and fini priority to reset to default [PR120030]

Right now if try to reset the priority of a constructor to the
default (65535), there is an ICE.
To fix this the assert is wrong and intead we should check
if the priority is already the default if not then we should
just update it.

Bootstrapped and tested on x86_64-linux-gnu.

PR middle-end/120030

gcc/ChangeLog:

* symtab.cc (symtab_node::set_init_priority): Better
handle the case of setting the priority back to default.
(cgraph_node::set_fini_priority): Likewise.

gcc/testsuite/ChangeLog:

* gcc.dg/constructor-2.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
4 weeks agodoc/extend: Document constructor/destructor attribute applying
Andrew Pinski [Wed, 11 Mar 2026 21:35:06 +0000 (14:35 -0700)] 
doc/extend: Document constructor/destructor attribute applying

Again while looking into PR 120030, there was no documentation
of what it means to have multiple constructor/destructor attributes
on the same function. Basically the last priority wins.

gcc/ChangeLog:

* doc/extend.texi (constructor/destructor): Add documentation
about multiple attributes here.

4 weeks agodoc/extend: Document constructor/destructor priority when none is supplied
Andrew Pinski [Wed, 11 Mar 2026 21:29:20 +0000 (14:29 -0700)] 
doc/extend: Document constructor/destructor priority when none is supplied

Noticed while working on PR 120030, the priority/order of constructor/destructor
without an argument is not documented.
This adds that the default priority is 65535 (last in order).

gcc/ChangeLog:

* doc/extend.texi (constructor/destructor): Document
the priority when none is supplied.

4 weeks agoopenmp, c++: Fix up TREE_TYPE of OMP_TASK
Jakub Jelinek [Thu, 12 Mar 2026 08:09:42 +0000 (09:09 +0100)] 
openmp, c++: Fix up TREE_TYPE of OMP_TASK

I've made a typo a few years ago and used void_node instead of void_type_node
as TREE_TYPE of OMP_TASK in the taskwait depend case.  This got later
on copied also for dispatch.
With reflection this leads to ICEs (but guess except for the testcase
we should also backport it to release branches).

2026-03-12  Jakub Jelinek  <jakub@redhat.com>

* parser.cc (cp_parser_omp_taskwait): Set TREE_TYPE of OMP_TASK
to void_type_node rather than void_node.
(cp_parser_omp_dispatch): Likewise.

* g++.dg/reflect/omp_taskwait1.C: New test.

4 weeks agolibstdc++: Use CTAD for span in std::define_static_object [PR124443]
Jakub Jelinek [Thu, 12 Mar 2026 07:50:35 +0000 (08:50 +0100)] 
libstdc++: Use CTAD for span in std::define_static_object [PR124443]

The standard in https://eel.is/c++draft/meta.reflection#meta.define.static-17
uses CTAD for span but we were avoiding that and using span<const _Up>
instead.

2026-03-12  Jakub Jelinek  <jakub@redhat.com>

PR libstdc++/124443
* include/std/meta (std::define_static_object): Use CTAD for span.

4 weeks agoc++: Support proxy iterators in reflection get_range_elts [PR124425]
Jakub Jelinek [Thu, 12 Mar 2026 07:48:47 +0000 (08:48 +0100)] 
c++: Support proxy iterators in reflection get_range_elts [PR124425]

I've punted up on proxy iterators because I didn't know how to construct
a test for those.

The following patch adds support for thosse.  Besides converting those
to valuet if needed and for classes making sure they live in a TARGET_EXPR
where they can be subsequently destructed, the patch adds
CLEANUP_POINT_EXPRs around the deref and inc expressions such that the
TARGET_EXPRs in those expressions are immediately destructed after returning
what we need.
cmp doesn't need that because
  cmp = condition_conversion (cmp);
already adds that.
Without the CLEANUP_POINT_EXPRs stuff is destructed (and marked as if out of
lifetime) only in some CLEANUP_POINT_EXPR surrounding the metafn call, which
is certainly too late for stuff that is reentered and left again in every
iteration.
I wrongly thought I'd need to duplicate the first part of CLEANUP_POINT_EXPR
handling in reflect.cc (which is complicated because struct constexpr_ctx
is only defined in constexpr.cc), then cxx_eval_constant_expression
e.g. deref and then duplicate the second part of CLEANUP_POINT_EXPR
handling, but it seems that the CLEANUP_POINT_EXPR evaluation just returns
what was returned from the recursive call on its operand, which is I think
exactly what we need.

This change broke 2 testcases, reflect_constant_array4.C and
define_static_array4.C, but IMHO correctly so, apparently what I had
there was creating std::pair<const int &, const int &> with references
to something that should have been immediately destructed in each iteration.
So, the patch fixes those tests to use std::pair<int, int> instead.

2026-03-12  Jakub Jelinek  <jakub@redhat.com>

PR c++/124425
* reflect.cc (get_range_elts): Handle proxy iterators.  Call
fold_build_cleanup_point_expr on both deref and inc.

* g++.dg/reflect/define_static_array4.C: Enable commented out
static_asserts and fix up the first one.
(as_pair): Make sure to return std::pair <int, int>.
* g++.dg/reflect/reflect_constant_array4.C: Enable commented out
static_asserts and fix up the first one.
(as_pair): Make sure to return std::pair <int, int>.
* g++.dg/reflect/reflect_constant_array7.C: New test.
* g++.dg/reflect/reflect_constant_array8.C: New test.

4 weeks agoFortran: Add testcase [PR102333]
Christopher Albert [Tue, 10 Mar 2026 23:24:41 +0000 (00:24 +0100)] 
Fortran: Add testcase [PR102333]

The reproducer from the bug report compiles cleanly on current
trunk.  Add a testcase to prevent future regressions.

PR fortran/102333

gcc/testsuite/ChangeLog:

PR fortran/102333
* gfortran.dg/pr102333.f90: New test.

Signed-off-by: Christopher Albert <albert@tugraz.at>
4 weeks agoFortran: Add testcase [PR103139]
Christopher Albert [Tue, 10 Mar 2026 23:25:24 +0000 (00:25 +0100)] 
Fortran: Add testcase [PR103139]

The reproducer from the bug report compiles cleanly on current
trunk.  Add a testcase to prevent future regressions.

PR fortran/103139

gcc/testsuite/ChangeLog:

PR fortran/103139
* gfortran.dg/pr103139.f90: New test.

Signed-off-by: Christopher Albert <albert@tugraz.at>
4 weeks agoc++/modules: Allow merging members of instantiations attached to named modules [PR124431]
Nathaniel Shead [Wed, 11 Mar 2026 12:21:02 +0000 (23:21 +1100)] 
c++/modules: Allow merging members of instantiations attached to named modules [PR124431]

The crash in the linked PR occurs because we treat all entities attached
to a (different) named module as being unmergeable, and so end up with
two different FIELD_DECLs for the member of a type.

But templates can be instantiated or specialised in any module, not just
the module they originated from, but are still considered attached to
that named module.  It seems that we already handle class-scope
VAR_DECL, FUNCTION_DECL, TYPE_DECL, and TEMPLATE_DECL correctly by using
a MK_decl_spec or MK_type_spec merge kind, but FIELD_DECLs and
CONST_DECLs are not depended upon separately and so never get
MK_template_mask specs.

For these cases I think we can always rely on the container being
accurate and having its fields already setup, so this patch fixes the
issue by allowing non-unique merge kind for decls with a template
specialisation container of code TYPE_DECL.

PR c++/124431

gcc/cp/ChangeLog:

* module.cc (trees_in::key_mergeable): Allow merging members of
template specialisations.

gcc/testsuite/ChangeLog:

* g++.dg/modules/merge-21_a.C: New test.
* g++.dg/modules/merge-21_b.C: New test.
* g++.dg/modules/merge-21_c.C: New test.
* g++.dg/modules/merge-21_d.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
4 weeks agoFortran: Fix ICE after rejected CHARACTER duplicate declaration [PR82721]
Christopher Albert [Tue, 10 Mar 2026 17:17:32 +0000 (18:17 +0100)] 
Fortran: Fix ICE after rejected CHARACTER duplicate declaration [PR82721]

When a CHARACTER declaration is rejected because the symbol already has
a different basic type, declaration parsing may already have created a
fresh gfc_charlen node for the rejected entity.  reject_statement()
undoes symbol-table changes, but it does not roll back the namespace
charlen list, so the stale len(...) expression can survive and later be
resolved through dangling symtree pointers, causing corrupted
diagnostics or an ICE.

Fix this in build_sym by discarding only the unattached gfc_charlen
node created for the rejected declaration before it is ever attached to
any surviving symbol.  Keep shared charlen nodes intact so other
invalid-code diagnostics still see the state they expect.  Also add a
regression test that uses MALLOC_PERTURB_ to make the old crash
reproducible.

gcc/fortran/ChangeLog:

PR fortran/82721
* decl.cc (discard_pending_charlen): New helper.
(build_sym): Discard unattached CHARACTER length nodes when
gfc_add_type rejects the declaration.

gcc/testsuite/ChangeLog:

PR fortran/82721
* gfortran.dg/pr82721.f90: New test.

Signed-off-by: Christopher Albert <albert@tugraz.at>
4 weeks agoriscv/docs: Increment the required binutils to 2.40 [PR124409]
Andrew Pinski [Wed, 11 Mar 2026 05:28:43 +0000 (22:28 -0700)] 
riscv/docs: Increment the required binutils to 2.40 [PR124409]

GCC has not able to build with binutils 2.30 due to the requirement
of needing zmull support. This changes the documentation to tbe
first binutils release that supported zmull.

PR target/124409

gcc/ChangeLog:

* doc/install.texi: Increment the required binutils for
riscv to 2.40.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
4 weeks agoFortran: Fix ICE on invalid CLASS component in derived type [PR106946]
Christopher Albert [Tue, 10 Mar 2026 16:32:32 +0000 (17:32 +0100)] 
Fortran: Fix ICE on invalid CLASS component in derived type [PR106946]

When a CLASS component declaration inside a derived type has a syntax
error (for example, a missing comma), gfc_build_class_symbol creates a
CLASS container symbol outside the undo mechanism.  Error recovery then
frees the referenced type but leaves the CLASS container orphaned with
dangling pointers, leading to an ICE during later resolution.

Fix this by removing CLASS components created during a failed data
declaration from the derived type component chain, deleting their
namespace symtree entries only when they are still present, releasing
the CLASS container symbol, and freeing the component itself.  Also
expand the regression coverage to exercise allocatable and pointer CLASS
declarations, including a valid component followed by a bad one.

gcc/fortran/ChangeLog:

PR fortran/106946
* decl.cc (gfc_match_data_decl): Remove CLASS components added by a
failed declaration in a derived type, and guard symtree deletion.
* gfortran.h (gfc_free_component, gfc_delete_symtree): Declare.
* symbol.cc (gfc_free_component): New function.
(free_components): Use it.
(gfc_delete_symtree): Make non-static.

gcc/testsuite/ChangeLog:

PR fortran/106946
* gfortran.dg/pr106946.f90: Cover allocatable and pointer CLASS
declarations, including a valid component followed by a bad one.

Signed-off-by: Christopher Albert <albert@tugraz.at>
4 weeks agoanalyzer: fix false +ves when testing <stdbool.h>/_Bool values [PR124451]
David Malcolm [Thu, 12 Mar 2026 00:45:29 +0000 (20:45 -0400)] 
analyzer: fix false +ves when testing <stdbool.h>/_Bool values [PR124451]

PR analyzer/124451 reports false positives from -Wanalyzer-malloc-leak
when using inverted "bool" values to track whether an allocation
happened.

The root cause is that with _Bool, the inversion is a bitwise not,
and this leads to the test of the condition against 0 to not be
recognized by malloc_state_machine::on_condition.  Hence on_condition
fails to transition the state machine for the pointer from "unchecked"
to "null" or "nonnull", leaving it in the "unchecked" state.

This patch generalizes the folding logic in the analyzer that folds
  "!(x CMP y)" => "x !CMP y"
so that it also folds
  "~(x CMP y)" => "x !CMP y"
when the bitwise not is on a boolean type, fixing the false positives.

gcc/analyzer/ChangeLog:
PR analyzer/124451
* region-model-manager.cc
(region_model_manager::maybe_invert_comparison_in_unaryop): New,
adapted from...
(region_model_manager::maybe_fold_unaryop): ...here, splitting out
the comparison inversion case for TRUTH_NOT_EXPR.  Add a case for
BIT_NOT_EXPR, reusing the inversion logic when dealing with
boolean types.
* region-model-manager.h
(region_model_manager::maybe_invert_comparison_in_unaryop): New decl.

gcc/testsuite/ChangeLog:
PR analyzer/124451
* gcc.dg/analyzer/conditionals-pr124451-_Bool.c: New test.
* gcc.dg/analyzer/conditionals-pr124451-enum.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 weeks agoanalyzer: fix ICE on computed goto [PR124375]
David Malcolm [Thu, 12 Mar 2026 00:45:29 +0000 (20:45 -0400)] 
analyzer: fix ICE on computed goto [PR124375]

gcc/analyzer/ChangeLog:
PR analyzer/124375
* ops.cc (ggoto_edge_op::apply_constraints): Ensure that we write
back a rejected_constraint if the edge is infeasible.
* region-model.cc (region_model::add_constraint): Convert
rejected_op_constraint from tree to const svalue *.
(rejected_op_constraint::dump_to_pp): Likewise.
* region-model.h (class rejected_op_constraint): Likewise.

gcc/testsuite/ChangeLog:
PR analyzer/124375
* gcc.dg/analyzer/ice-pr124375-1.c: New test.
* gcc.dg/analyzer/ice-pr124375-2.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 weeks agoanalyzer: fix ICE on effective modulo by zero [PR124433]
David Malcolm [Thu, 12 Mar 2026 00:45:29 +0000 (20:45 -0400)] 
analyzer: fix ICE on effective modulo by zero [PR124433]

gcc/analyzer/ChangeLog:
PR analyzer/124433
* region-model-manager.cc
(region_model_manager::maybe_fold_binop): When checking for
division by zero, use the value range of the divisor, rather
than merely checking for constant 0.
* region-model.cc (region_model::get_gassign_result): Likewise.

gcc/testsuite/ChangeLog:
PR analyzer/124433
* gcc.dg/analyzer/divide-by-zero-ice-pr124433.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
4 weeks agoFortran: Fix class dummy-array assignment deep copy [PR110877]
Christopher Albert [Tue, 10 Mar 2026 21:39:54 +0000 (22:39 +0100)] 
Fortran: Fix class dummy-array assignment deep copy [PR110877]

Recover the class vptr for scalarized elements of nonpointer
dummy arrays so polymorphic assignment uses the deep-copy path.

PR fortran/110877

gcc/fortran/ChangeLog:

* trans-expr.cc (gfc_trans_assignment_1): Recover the class
vptr for scalarized elements of nonpointer dummy arrays.

gcc/testsuite/ChangeLog:

* gfortran.dg/pr110877.f90: New test.

Signed-off-by: Christopher Albert <albert@tugraz.at>
4 weeks agoDaily bump.
GCC Administrator [Thu, 12 Mar 2026 00:16:31 +0000 (00:16 +0000)] 
Daily bump.

4 weeks agoc++: error routines re-entered with uneval lambda [PR124397]
Marek Polacek [Sun, 8 Mar 2026 16:34:30 +0000 (12:34 -0400)] 
c++: error routines re-entered with uneval lambda [PR124397]

As discussed in
<https://gcc.gnu.org/pipermail/gcc-patches/2026-March/710075.html>
we shouldn't override complain with tf_warning_or_error when we are
emitting cp_printer diagnostics.  We had no way to check that so
this patch adds emitting_diagnostic_p.

PR c++/124397

gcc/cp/ChangeLog:

* pt.cc (tsubst_lambda_expr): Don't override complain when emitting
diagnostics.

gcc/ChangeLog:

* diagnostic.h (emitting_diagnostic_p): New.
* diagnostics/context.h (context::emitting_diagnostic_p): New.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/lambda-uneval30.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
Reviewed-by: David Malcolm <dmalcolm@redhat.com>
4 weeks agofortran: Fix mixed ENTRY union ABI under -ff2c [PR95338]
Christopher Albert [Tue, 10 Mar 2026 18:44:29 +0000 (19:44 +0100)] 
fortran: Fix mixed ENTRY union ABI under -ff2c [PR95338]

Mixed ENTRY masters store each result in a shared union.  Under -ff2c,
default REAL entries use the C double ABI even though their Fortran result
symbols remain default REAL.  Building the union directly from the Fortran
result symbols therefore gives the entry wrapper a real(kind=8) return type
but leaves the master union field at real(kind=4), which later trips the
GIMPLE verifier with a non-trivial conversion in COMPONENT_REF.

Build the mixed ENTRY union fields from the ABI return type instead, so
default REAL entries under -ff2c contribute a real(kind=8) field.  Add a
regression test for the original mixed INTEGER/REAL ENTRY reproducer.

gcc/fortran/ChangeLog:

PR fortran/95338
* trans-types.cc (gfc_get_entry_result_type): New helper to use the
ABI return type for mixed ENTRY union fields.
(gfc_get_mixed_entry_union): Use it for each entry result field.

gcc/testsuite/ChangeLog:

PR fortran/95338
* gfortran.dg/pr95338.f90: New test.

Signed-off-by: Christopher Albert <albert@tugraz.at>
4 weeks agoUpdate gcc sv.po
Joseph Myers [Wed, 11 Mar 2026 21:46:49 +0000 (21:46 +0000)] 
Update gcc sv.po

* sv.po: Update.

4 weeks agoc++: ICE with structured bindings and arrays [PR120285]
Marek Polacek [Mon, 9 Mar 2026 15:40:54 +0000 (11:40 -0400)] 
c++: ICE with structured bindings and arrays [PR120285]

In r15-3933 I started using a CONSTRUCTOR to signal direct-init
to build_vec_init rather than a TREE_LIST.  That broke

  struct S {
    int a = 1;
  };
  void foo() {
    S arr[2];
    auto [x, y](arr);
  }

because we pass that new CONSTRUCTOR not to build_vec_init but to
build_aggr_init which then crashes in digest_init_r because the
new CONSTRUCTOR wasn't reshaped.  It should work to reshape it if
its type is CP_AGGREGATE_TYPE_P but it might be safer to resort
back to building up a list if we're not going to go to build_vec_init.

PR c++/120285

gcc/cp/ChangeLog:

* init.cc (build_vec_init): Only build up a CONSTRUCTOR for
arrays, otherwise use a TREE_LIST like prior to r15-3933.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1z/decomp68.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
4 weeks agogenautomata: Support INSN_UIDs up to INT_MAX-1 [PR124436]
Jakub Jelinek [Wed, 11 Mar 2026 16:28:58 +0000 (17:28 +0100)] 
genautomata: Support INSN_UIDs up to INT_MAX-1 [PR124436]

With --param=min-nondebug-insn-uid= parameter one can force really large
INSN_UIDs even in moderately large functions.
Obviously the compiler will break badly if INSN_UID (which is host int)
wraps around, but in dfa_insn_code_enlarge it actually breaks already
when INSN_UID reaches INT_MAX / 2 + 1, because it tries to resize
vector to twice the max INSN_UID and overflows (UB on the compiler side
and then trying to allocate 0xfffffffe00000001-ish bytes).

The following patch fixes it by making sure not to overflow and cap
the allocation size at INT_MAX (that means even maximum INSN_UID INT_MAX
will not work properly, but just reaching that is highly undesirable
anyway).  Alternatively dfa_insn_codes_length could be e.g. HOST_WIDE_INT
and we could just use HOST_WIDE_INT_C (2) * uid, but then we'd allocate
parts of vector for something that we really won't use anyway.

Of course, it is really bad idea to use
--param=min-nondebug-insn-uid=1073741824
or even huge numbers several times smaller than that, because the compiler
often allocates arrays sized by maximum INSN_UID, so e.g. compiling empty
function on cross to mips64-linux with that argument needed around 38GiB
of RAM.

2026-03-11  Jakub Jelinek  <jakub@redhat.com>

PR target/124436
* genautomata.cc (output_dfa_insn_code_func): Use
MIN (INT_MAX, 2U * uid) instead of 2 * uid in dfa_insn_code_enlarge.

4 weeks agoaarch64: mingw: Add more tests for variadic hva
Saurabh Jha [Wed, 11 Mar 2026 10:30:04 +0000 (10:30 +0000)] 
aarch64: mingw: Add more tests for variadic hva

The test gcc.target/aarch64/mingw/variadic_hva.c started failing after
this commit:
b67918fddab42c434c10bedff6c210c55ed907a0

This commit adds three variants of this test case with options that
introduce more predictability to code generation. This will make it less
probable that these tests will break with any other future change. The
options used are:
1. -fno-section-anchors
2. -mcmodel=tiny
3. -mcmodel=small.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/mingw/variadic_hva.c: Deleted and created
three variants.
* gcc.target/aarch64/mingw/variadic_hva1.c: Derived from
variadic_hva.c and compiled with option -fno-section-anchors.
* gcc.target/aarch64/mingw/variadic_hva2.c: Derived from
variadic_hva.c and compiled with option -mcmodel=tiny.
* gcc.target/aarch64/mingw/variadic_hva3.c: Derived from
variadic_hva.c and compiled with option -mcmodel=small.

4 weeks agoc++/reflection: fix for substituting ^^T::mem [PR124331]
Marek Polacek [Mon, 9 Mar 2026 21:30:26 +0000 (17:30 -0400)] 
c++/reflection: fix for substituting ^^T::mem [PR124331]

In compare11.C, the static_assert was wrongly failing because
compare_reflections got a FIELD_DECL and COMPONENT_REF for ^^S::mem.
We shouldn't have created the COMPONENT_REF.  So this patch avoids
creating the COMPONENT_REF by avoiding the finish_qualified_id_expr
call in tsubst_qualified_id when processing a REFLECT_EXPR.

Happily, it fixed some other issues too.

Unfortunately, I found another issue (PR124440) while trying to test
this patch more extensively.  I plan to fix that separately next.

PR c++/124331

gcc/cp/ChangeLog:

* pt.cc (tsubst_qualified_id): New name_lookup_p parameter.  Don't
call adjust_result_of_qualified_name_lookup and
finish_qualified_id_expr if name_lookup_p is false.
(tsubst_expr) <case REFLECT_EXPR>: Handle SCOPE_REF specially by
calling tsubst_qualified_id with name_lookup_p=false.

gcc/testsuite/ChangeLog:

* g++.dg/reflect/expr13.C: Uncomment the commented out assert.
* g++.dg/reflect/serialize2.C: Replace #if 0 with #ifdef.
* g++.dg/reflect/compare11.C: New test.
* g++.dg/reflect/member21.C: New test.
* g++.dg/reflect/serialize3.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
4 weeks agox86: Handle non-int load with integer constant
H.J. Lu [Mon, 9 Mar 2026 13:16:24 +0000 (06:16 -0700)] 
x86: Handle non-int load with integer constant

1. For non-int load with zero integer constant, generate:

(set (reg/v:SF 126 [ f ])
     (const_double:SF 0.0 [0x0.0p+0]))

instead of

(set (reg/v:SF 126 [ f ])
     (const_int 0 [0]))

2. For non-int load with non-zero integer constant, generate:

(set (subreg:SI (reg/v:SF 105 [ f ]) 0)
     (const_int 1313486336 [0x4e4a3600]))

instead of

(set (reg/v:SF 105 [ f ])
     (const_int 1313486336 [0x4e4a3600]))

gcc/

PR target/124407
* config/i386/i386-features.cc (ix86_place_single_vector_set):
Handle non-int load with integer constant.
(ix86_broadcast_inner): Convert const0_rtx to non-int mode.

gcc/testsuite/

PR target/124407
* gcc.target/i386/pr124407-1.c: New test.
* gcc.target/i386/pr124407-2.c: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
4 weeks agoexpand: Fix GET_MODE_SIZE/GET_MODE_BITSIZE typo [PR124435]
Richard Sandiford [Wed, 11 Mar 2026 14:48:04 +0000 (14:48 +0000)] 
expand: Fix GET_MODE_SIZE/GET_MODE_BITSIZE typo [PR124435]

When splitting out store_field_updates_msb_p, r16-7265-ga9e48eca3a6eef
accidentally replaced GET_MODE_BITSIZE with GET_MODE_SIZE.

A matching rename of to_size to to_bitsize would have overflowed a line,
so it seemed worth breaking the endian cases apart.

gcc/
PR middle-end/124435
* expr.cc (store_field_updates_msb_p): Use GET_MODE_BITSIZE
instead of GET_MODE_SIZE.  Handle the two endiannesses separately.

gcc/testsuite/
PR middle-end/124435
* gcc.dg/torture/pr124435.c: New test.

4 weeks agoRevert "[1/n][PR tree-optimization/90036] All refinement of entries in DOM hash table"
Jeff Law [Wed, 11 Mar 2026 14:38:41 +0000 (08:38 -0600)] 
Revert "[1/n][PR tree-optimization/90036] All refinement of entries in DOM hash table"

This reverts commit 55c6baeb86b10912e98f4cf6b0a432d7c896d81e.

4 weeks agoRevert "[PR tree-optimization/90036] Backpropagate more equivalences in DOM"
Jeff Law [Wed, 11 Mar 2026 14:38:27 +0000 (08:38 -0600)] 
Revert "[PR tree-optimization/90036] Backpropagate more equivalences in DOM"

This reverts commit f23a339a686ed6cc6a4838459bc220e48ba901cb.

4 weeks agoc++: add fixed test [PR124389]
Patrick Palka [Wed, 11 Mar 2026 14:00:57 +0000 (10:00 -0400)] 
c++: add fixed test [PR124389]

This one is also fixed by r16-7055.  The testcases from that commit
utilize the concepts satisfaction cache, whereas this one utilizes
the constexpr call cache.

PR c++/124389
PR c++/122494

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/static_assert18.C: New test.

4 weeks agoarm: Fix trapping arithmetic [PR123271]
Richard Earnshaw [Wed, 11 Mar 2026 11:14:47 +0000 (11:14 +0000)] 
arm: Fix trapping arithmetic [PR123271]

Patch r10-3995 accidentally defined insn patterns that overrode the
default behaviour of overflow-trapping arithmetic; this broke the
implementation of -ftrapv.  Fixed by renaming the internal patterns.
For consistency I've renamed more than is strictly necessary.

gcc/ChangeLog:

PR target/123271
* config/arm/arm.md (subvsi3_intmin): Renamed to ...
(sub_cmpVsi3_intmin): ... this.
(subvsi3): Renamed to ...
(sub_cmpVsi3): ... this.
(subvsi3_imm1): Renamed to ...
(sub_cmpVsi3_imm1): ... this.
(usubvsi3_borrow): Renamed to ...
(usub_cmpVsi3_borrow): ... this.
(usubvsi3_borrow_imm): Renamed to ...
(usub_cmpVsi3_borrow_imm): ... this.
(subvsi3_borrow): Renamed to ...
(sub_cmpVsi3_borrow): ... this.
(subvsi3_borrow_imm): Renamed to ...
(sub_cmpVsi3_borrow_imm): ... this.

gcc/testsuite/ChangeLog:

PR target/123271
* gcc.target/arm/pr123271.c: New test.

4 weeks agogcc/gcn: Use 'shared_base' register for LDS<->flat conversion
Arsen Arsenović [Tue, 24 Feb 2026 10:24:09 +0000 (10:24 +0000)] 
gcc/gcn: Use 'shared_base' register for LDS<->flat conversion

This speeds up address space conversions by about 8x in
micro-benchmarks.  Those may be slightly unrepresentative, because the
RTL optimizer is free to do whatever it wants with the two registers
address space conversion uses (a temporary register and shared_base).

gcc/ChangeLog:

* config/gcn/gcn.cc (gcn_addr_space_convert): Use
SHARED_BASE_REG to find flat address space base of LDS.

gcc/testsuite/ChangeLog:

* gcc.target/gcn/addr-space-convert-1.c: New test.
* gcc.target/gcn/addr-space-convert-2.c: New test.

4 weeks agogcc/gcn: fix address space conversion between __flat and default [PR124044]
Arsen Arsenović [Tue, 24 Feb 2026 10:11:27 +0000 (10:11 +0000)] 
gcc/gcn: fix address space conversion between __flat and default [PR124044]

The default address space in the GCN backend is distinct from the
flat/global address space that it normally coincides with so that it can
be changed.  But, as a result, address space conversion must be aware of
this difference and handle the default address space explicitly.

Currently, it fails to do so, and so it reaches a gcc_unreachable.

This patch fixes that by resolving the default address space into
whatever address space it effectively is.

gcc/ChangeLog:

PR target/124044
* config/gcn/gcn.cc (gcn_addr_space_resolve_default): New
function.  Converts from ADDR_SPACE_DEFAULT to
DEFAULT_ADDR_SPACE.
(gcn_addr_space_convert): Resolve from_type and to_type address
spaces.

gcc/testsuite/ChangeLog:

* gcc.target/gcn/pr124044.c: New test.

4 weeks agogcc/gcn: add memory aperture register definitions
Arsen Arsenović [Thu, 19 Feb 2026 13:58:01 +0000 (13:58 +0000)] 
gcc/gcn: add memory aperture register definitions

Memory aperture registers on GCN are special read-only registers that
hold the 64-bit (i.e. pointer-sized) values.  These registers are
accessible as the full value or by their lower half (but not upper
half!), and are also aligned to 2^32 (so the lower half is useless..).

They come in two pairs: shared_base/shared_limit and
private_base/private_limit.  The base registers contain the address at
which the LDS and scratch spaces are mapped to, respectively, in the
flat memory space, an the limit registers contain the size of these
mappings.

In a subsequent patch, this will allow us to use a pair of moves to do
conversions from LDS to the flat address space, saving us a few
expensive reads at runtime.

gcc/ChangeLog:

* config/gcn/gcn.cc (gcn_regno_reg_class): Handle
MEMORY_APERTURE_REGS.
(gcn_hard_regno_rename_ok): Return false for memory aperture
regs.
(gcn_memory_move_cost): Handle memory aperture regs the same as
general registers.
(gcn_hard_regno_nregs): Handle MEMORY_APERTURE_REGS.
* config/gcn/gcn.h (SHARED_BASE_REG): Define.
(SHARED_LIMT_REG): Ditto.
(PRIVATE_BASE_REG): Ditto.
(PRIVATE_LIMT_REG): Ditto.
(MEMORY_APERTURE_REG_P): New macro.  Evaluates to non-zero if
parameter is one of the above registers.
(SSRC_REGNO_P): Also evaluate to non-zero for aperture regs, as
they can be sources to scalar instructions.
(enum reg_class): New class: MEMORY_APERTURE_REGS.
(REG_CLASS_NAMES): Provide name for that class.
(MEMORY_APERTURE_REGS_MASK): New helper macro.  Value of
NAMED_REG_MASK2 for each of the memory aperture regs.
(REG_CLASS_CONTENTS): Add the above registers to
MEMORY_APERTURE_REGS, SGPR_VOP_SRC_REGS, and SGPR_SRC_REGS.

4 weeks agofold-mem-offsets: Fix wrong mode in memory_address_addr_space_p
Philipp Tomsich [Mon, 23 Feb 2026 16:22:47 +0000 (17:22 +0100)] 
fold-mem-offsets: Fix wrong mode in memory_address_addr_space_p

The validity check in do_check_validity was passing the address mode
(GET_MODE of the address RTX, e.g. DImode) to memory_address_addr_space_p
instead of the memory access mode (GET_MODE of the MEM RTX, e.g. SImode).
The first argument to memory_address_addr_space_p is the mode of the
memory access, not the address mode.

On targets where address validity depends on the access width (e.g.
alignment-sensitive modes, vector modes), this could accept an illegal
offset or reject a valid one.

Rename the variable to 'addr_mode' for address construction and add a
separate 'mem_mode' for the validity check.

gcc/ChangeLog:

* fold-mem-offsets.cc (do_check_validity): fix wrong mode
and rename arguments to avoid future confusion

4 weeks agotestsuite: Fix up g++.dg/reflect/eh8.C for Solaris iconv [PR124118]
Jakub Jelinek [Wed, 11 Mar 2026 10:55:56 +0000 (11:55 +0100)] 
testsuite: Fix up g++.dg/reflect/eh8.C for Solaris iconv [PR124118]

I forgot about PR112652 and added a test that relies on iconv actually
failing when converting from UTF-8 with some emojis to a character set
without those characters.
Seems Solaris iconv just transcodes such characters as ? instead of
reporting an error.

The following patch splits the test into two halves, so that the first one
is tested on Solaris, and uses dg-skip-if for Solaris like in r16-6209
in the second half (rather than expecting no diagnostics for Solaris,
because one can use GNU libiconv on Solaris too).

2026-03-11  Jakub Jelinek  <jakub@redhat.com>

PR c++/124118
* g++.dg/reflect/eh8.C (bar, c): Move second part of tests to ...
* g++.dg/reflect/eh10.C: ... here, new test.  Add dg-skip-if for
solaris.

4 weeks agolibstdc++: Use __builtin_constexpr_diag instead of __asm__("") in <meta> if possible
Jakub Jelinek [Wed, 11 Mar 2026 06:55:58 +0000 (07:55 +0100)] 
libstdc++: Use __builtin_constexpr_diag instead of __asm__("") in <meta> if possible

Your asm -> __asm__ patch made me think that these are perfect
candidates for __builtin_constexpr_diag, the asms were there just
to make it provably non-constant expression (guess *(char*)nullptr = 0;
would do as well).  But with __builtin_constexpr_diag we can tell
the user the details.

Additionally, when testing it I've found that the
https://eel.is/c++draft/meta.reflection#access.context-13
Throws: meta::exception unless cls is either the null reflection
or a reflection of a complete class type.
part of via's description was implemented wierdly, it did throw
an exception, but not by telling user that via has been called with
something that is not a null reflection nor reflection of a complete
class type, but that is_class_type has been called on a reflection
of something other than a type.

2026-03-11  Jakub Jelinek  <jakub@redhat.com>

* include/std/meta (std::meta::exception::what()): Use
__builtin_constexpr_diag instead of __asm__("") if supported.
(std::meta::access_context::via(info)): Don't call is_class_type
if __cls is not a type.  Use __builtin_constexpr_diag instead of
__asm__("") if supported for -fno-exceptions.

* g++.dg/reflect/eh8.C: Expect different diagnostics.
* g++.dg/reflect/no-exceptions2.C: New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
4 weeks agoc++: Emit error if not quiet and set *non_constant_p for -fno-exceptions metafn error...
Jakub Jelinek [Wed, 11 Mar 2026 06:54:36 +0000 (07:54 +0100)] 
c++: Emit error if not quiet and set *non_constant_p for -fno-exceptions metafn error cases [PR124417]

For -fno-exceptions, we reject throw statements in the source, and a lot
of code in the header has #ifdef __cpp_exceptions guarded stuff and the
FE for !flag_exceptions doesn't emit some parts of the IL needed for
exceptions.  For the errors in metafns, we had just a todo to handle it
in the source but no actual implementation, so we allowed throwing
an exception and sometimes it worked to some extent and sometimes
it didn't.

The following patch fixes it by not throwing an exception if user
asked for -fno-exceptions - instead we just emit an error including
the planned what () (unless ctx->quiet) and make the evaluation
non-constant.

2026-03-11  Jakub Jelinek  <jakub@redhat.com>

PR c++/124417
* reflect.cc (get_meta_exception_object): Add CTX argument.  For
!flag_exceptions emit error unless ctx->quiet, set *non_constant_p
to true and return NULL_TREE instead of throwing an exception.
(throw_exception): Adjust get_meta_exception_object caller.

* g++.dg/reflect/no-exceptions1.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
4 weeks agoc++: Fix up __builtin_constexpr_diag for std::string operands [PR124404]
Jakub Jelinek [Wed, 11 Mar 2026 06:50:22 +0000 (07:50 +0100)] 
c++: Fix up __builtin_constexpr_diag for std::string operands [PR124404]

__builtin_constexpr_diag works fine with string literals or class arguments
like std::{,u8}string_view or string view like classes, but as the following
testcase shows doesn't work with std::string argument.
I believe the important difference is that std::string has non-trivial
destructor and so needs to be passed by invisible reference while
std::string_view doesn't.

Anyway, the following patch makes it work even with std::string.

2026-03-11  Jakub Jelinek  <jakub@redhat.com>

PR c++/124404
* constexpr.cc (cxx_eval_constexpr_diag): Call convert_from_reference
on arguments.

* g++.dg/ext/constexpr-diag7.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
4 weeks agoUpdate gcc de.po, sv.po
Joseph Myers [Wed, 11 Mar 2026 00:23:47 +0000 (00:23 +0000)] 
Update gcc de.po, sv.po

* de.po, sv.po: Update.

4 weeks agoDaily bump.
GCC Administrator [Wed, 11 Mar 2026 00:16:30 +0000 (00:16 +0000)] 
Daily bump.

4 weeks agoc++: For reflection comparison of annotations compare TREE_VALUE [PR124399]
Jakub Jelinek [Tue, 10 Mar 2026 20:27:10 +0000 (21:27 +0100)] 
c++: For reflection comparison of annotations compare TREE_VALUE [PR124399]

https://eel.is/c++draft/meta.reflection#annotation-4
testcase also contains
[[=1]] int x, y;
static_assert(annotations_of(^^x)[0] == annotations_of(^^y)[0]);
so in case of an annotation shared by multiple declarations we need
to compare the TREE_VALUE of the attributes (which is shared in that
case) rather than the TREE_LIST with that TREE_VALUE and TREE_PURPOSE
being "internal ":"annotation ".
For mangling we already handle it right:
  if (eval_is_annotation (h, kind) == boolean_true_node)
    {
      strcpy (prefix, "an");
      if (TREE_PURPOSE (TREE_VALUE (h)) == NULL_TREE)
        TREE_PURPOSE (TREE_VALUE (h))
          = build_int_cst (integer_type_node, annotation_idx++);
      return TREE_PURPOSE (TREE_VALUE (h));
    }
so the annotation index is stored on TREE_PURPOSE of the TREE_VALUE,
so in shared annotation like the above it will have the same index
in both cases.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

When I was adding further tests for this, I've noticed that we don't
handle correctly
[[=1]] int x [[=2]], y [[=3]];
because the attributes list which is shared is clearly added as a shared
tail of the other attributes.  For now this is commented out in the
test, will try to deal with it somehow incrementally.

2026-03-10  Jakub Jelinek  <jakub@redhat.com>

PR c++/124399
* reflect.cc (compare_reflections): For REFLECT_ANNOTATION, compare
TREE_VALUE of lhs and rhs instead of lhs and rhs.

* g++.dg/reflect/annotations12.C: Add further tests.

4 weeks agoc++: Use complete_type on first annotations_of argument if it is a type [PR124399]
Jakub Jelinek [Tue, 10 Mar 2026 20:24:33 +0000 (21:24 +0100)] 
c++: Use complete_type on first annotations_of argument if it is a type [PR124399]

The following testcases FAIL (annotations12.C is directly from
https://eel.is/c++draft/meta.reflection#annotation-4 ) because it is
called on a reflection of class template instantiation which has been
just looked up but not yet completed, and in that case it doesn't
have any attributes instantiated.
Only complete_type instantiates those.  Unlike the second argument
of annotations_of_with_type where the standard requires is_complete_type,
in this case it doesn't, so it is fine if one uses
struct S;
static_assert (annotations_of (^^S).size () == 0);
but I'm afraid we need to instantiate the argument to get the annotations.

2026-03-10  Jakub Jelinek  <jakub@redhat.com>

PR c++/124399
* reflect.cc (eval_annotations_of): Call complete_type on r if it
is a type.

* g++.dg/reflect/annotations3.C: Uncomment 3 test lines.
* g++.dg/reflect/annotations12.C: New test.
* g++.dg/reflect/constant_of5.C: Enable some commented out
or #if 0ed out tests.
* g++.dg/reflect/constant_of6.C: Remove dg-error directive.
* g++.dg/reflect/extract6.C: Remove 2 dg-error directives.

4 weeks agoc++/testsuite: -fimplicit-constexpr adjustments
Jason Merrill [Tue, 10 Mar 2026 19:44:53 +0000 (15:44 -0400)] 
c++/testsuite: -fimplicit-constexpr adjustments

Various tests were failing because they rely on non-constexpr functions
staying that way.  The constexpr-diag tests are easier to just skip if
impcx; the reflection tests can be adjusted.

gcc/testsuite/ChangeLog:

* g++.dg/ext/constexpr-diag3.C: Skip if -fimplicit-constexpr.
* g++.dg/ext/constexpr-diag6.C: Likewise.
* g++.dg/reflect/annotations2.C: Handle -fimplicit-constexpr.
* g++.dg/reflect/p2996-21.C: Likewise.
* g++.dg/reflect/parm4.C: Likewise.

4 weeks agolibstdc++: Add comment to chrono::hh_mm_ss constructor for LWG 4274
Jonathan Wakely [Tue, 10 Mar 2026 15:44:48 +0000 (15:44 +0000)] 
libstdc++: Add comment to chrono::hh_mm_ss constructor for LWG 4274

LWG 4274 was approved in Kona 2025 but I implemented the resolution back
in 2023 for PR libstdc++/108265. This just adds a comment noting that we
implement the resolution.

libstdc++-v3/ChangeLog:

* include/std/chrono (hh_mm_ss): Add comment about LWG 4274.

4 weeks agolibstdc++: Do not use projection for ranges::replace default args (LWG 4444)
Jonathan Wakely [Tue, 10 Mar 2026 17:18:59 +0000 (17:18 +0000)] 
libstdc++: Do not use projection for ranges::replace default args (LWG 4444)

Implement the resolution of LWG 444, accepted in Kona 2025.

The new value to be assigned to the matching elements should default to
the value type of the range, not the type returned by the projection.
The type returned by the projection is only used to find the matching
elements, and might not be assignable to the value type at all.

libstdc++-v3/ChangeLog:

* include/bits/ranges_algo.h (__replace_fn, __replace_if_fn):
Change default template argument for type of new value, as per
LWG 4444.
* testsuite/25_algorithms/replace/lwg4444.cc: New test.
* testsuite/25_algorithms/replace_if/lwg4444.cc: New test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 weeks agolibstdc++: Constrain std::as_bytes to disallow span<volatile T>
Jonathan Wakely [Tue, 10 Mar 2026 16:00:40 +0000 (16:00 +0000)] 
libstdc++: Constrain std::as_bytes to disallow span<volatile T>

Implement the accepted resolution of LWG 4243, approved in Kona 2025.

libstdc++-v3/ChangeLog:

* include/std/span (as_bytes, as_writable_bytes): Add
constraints to disallow volatile elements, as per LWG 4243.
* testsuite/23_containers/span/lwg4243.cc: New test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 weeks agolibstdc++: Add allocate_at_least (P0401) [PR118030]
Nathan Myers [Thu, 5 Mar 2026 13:54:09 +0000 (08:54 -0500)] 
libstdc++: Add allocate_at_least (P0401) [PR118030]

Implement proposals adopted for C++23:
P0401R6, "Providing size feedback in the Allocator interface"
P2652R2, "Disallow User Specialization of allocator_traits".

This is the minimal conforming implementation, i.e. without the
useful parts. Useful parts, to come in future patches, would
include giving access to any extra storage reserved, and use of
it in vector, string, and other contiguous containers.

libstdc++-v3/ChangeLog:
PR libstdc++/118030
* include/bits/alloc_traits.h (allocate_at_least (2x)): Define.
* include/bits/allocator.h (allocate_at_least): Define.
* include/std/memory (__glibcxx_want_allocate_at_least): Define.
* include/bits/memoryfwd.h (allocation_result): Define, #include
<bits/version.h> first so that will work.
* include/bits/version.def (allocate_at_least): Add.
* include/bits/version.h: Regenerate.
* testsuite/20_util/allocator/allocate_at_least.cc: New test.
* testsuite/20_util/allocator/allocate_at_least_neg.cc: New test.

4 weeks agoarm: testsuite: Yet another typo in pr45701-2.c
Richard Earnshaw [Tue, 10 Mar 2026 14:58:01 +0000 (14:58 +0000)] 
arm: testsuite: Yet another typo in pr45701-2.c

Yet another fix to a fix.

gcc/testsuite/ChangeLog:

* gcc.target/arm/pr45701-2.c: Fix typo in last commit.

4 weeks agoarm: testsuite: properly escape '[]' in pr45701-2.c
Richard Earnshaw [Tue, 10 Mar 2026 13:37:46 +0000 (13:37 +0000)] 
arm: testsuite: properly escape '[]' in pr45701-2.c

I missed the escaping of [] in the previous change for this file.

gcc/testsuite/ChangeLog:

* gcc.target/arm/pr45701-2.c: Escape '[]' in scan-assembler.

4 weeks ago[PATCH] RISC-V: Fix TARGET_CHECK_TARGET_CLONE_VERSION implementation
Yangyu Chen [Tue, 10 Mar 2026 14:00:10 +0000 (08:00 -0600)] 
[PATCH] RISC-V: Fix TARGET_CHECK_TARGET_CLONE_VERSION implementation

Currently, the implementation of TARGET_CHECK_TARGET_CLONE_VERSION for
RISC-V is incomplete and will emit an error for invalid target_clones
versions. This can be problematic during transitions to new extensions,
as it may break builds that have not yet updated their target_clones
versions.

This commit implements TARGET_CHECK_TARGET_CLONE_VERSION for RISC-V, by
using the riscv_process_target_version_str with loc set to NULL to
prevent emitting errors for invalid versions. This allows for a smoother
transition to new extensions, while still providing a mechanism for
checking target_clones versions when needed.

Signed-off-by: Yangyu Chen <cyy@cyyself.name>
---
Note: I think it should be safe to push to GCC-16 with the new test, to align
FMV with aarch64 for invalid version string. Future ISA extensions may cause
build breakage if the version string is not updated, and this test can help
catch such issues early.

Aarch64 in GCC-16 already merged this new feature. X86 [1] may also merge this
feature in GCC-16, but it is not yet clear. If X86 also merges this feature in
GCC-16, then it would be more consistent to also merge the RISC-V
implementation in GCC-16.

[1] https://patchwork.sourceware.org/project/gcc/patch/tencent_E83AEE534C5D8845A3371FAAA091B6832306@qq.com/

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_check_target_clone_version):
Fix TARGET_CHECK_TARGET_CLONE_VERSION implementation.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/mvc-warning1.c: New test.

4 weeks agoAdd and fix comments in tree-vect-loop.cc
Richard Biener [Tue, 10 Mar 2026 12:27:38 +0000 (13:27 +0100)] 
Add and fix comments in tree-vect-loop.cc

The following fixes a comment and adds a function level comment.
Noticed when reviewing this code.

* tree-vect-loop.cc (vect_get_datarefs_in_loop): Add function
level comment.
(vect_analyze_loop_2): Fix comment.

4 weeks agoarm: testsuite: avoid pr45701 matching asm across newlines
Richard Earnshaw [Tue, 10 Mar 2026 13:03:16 +0000 (13:03 +0000)] 
arm: testsuite: avoid pr45701 matching asm across newlines

The tests I added yesterday used '.*' in a scan-assembler-not pattern,
but that can match across multiple lines leading to some false matches
in the not variant.  Avoid that by scanning for [^\n]*.

gcc/testsuite/ChangeLog:

* gcc.target/arm/pr45701-1.c: Don't match across lines.
* gcc.target/arm/pr45701-2.c: Likewise.
* gcc.target/arm/pr45701-3.c: Likewise.

4 weeks agotestsuite: Fix up gcc.dg/plugin/analyzer_cpython_plugin.cc [PR112520]
Jakub Jelinek [Tue, 10 Mar 2026 12:26:09 +0000 (13:26 +0100)] 
testsuite: Fix up gcc.dg/plugin/analyzer_cpython_plugin.cc [PR112520]

The recent r16-7938 PR112520 fix hasn't changed much in the testsuite
results for me:
@@ -154,41 +151,34 @@ FAIL: gcc.dg/plugin/cpython-plugin-test-
 FAIL: gcc.dg/plugin/cpython-plugin-test-PyList_Append.c -fplugin=./analyzer_cpython_plugin.so  (test for warnings, line 42)
 FAIL: gcc.dg/plugin/cpython-plugin-test-PyList_Append.c -fplugin=./analyzer_cpython_plugin.so  at line 18 (test for warnings, line 17)
 FAIL: gcc.dg/plugin/cpython-plugin-test-PyList_Append.c -fplugin=./analyzer_cpython_plugin.so  at line 43 (test for warnings, line 42)
-FAIL: gcc.dg/plugin/cpython-plugin-test-PyList_Append.c -fplugin=./analyzer_cpython_plugin.so (internal compiler error: Segmentation fault)
+FAIL: gcc.dg/plugin/cpython-plugin-test-PyList_Append.c -fplugin=./analyzer_cpython_plugin.so (internal compiler error: tree check: expected record_type or union_type or qual_union_type, have integer_type in get_field_by_name, at /home/jakub/src/gcc/gcc/testsuite/gcc.dg/plugin/analyzer_cpython_plugin.cc:62)
 FAIL: gcc.dg/plugin/cpython-plugin-test-PyList_Append.c -fplugin=./analyzer_cpython_plugin.so (test for excess errors)
 FAIL: gcc.dg/plugin/cpython-plugin-test-PyList_New.c -fplugin=./analyzer_cpython_plugin.so  (test for warnings, line 17)
 FAIL: gcc.dg/plugin/cpython-plugin-test-PyList_New.c -fplugin=./analyzer_cpython_plugin.so  (test for warnings, line 18)
 FAIL: gcc.dg/plugin/cpython-plugin-test-PyList_New.c -fplugin=./analyzer_cpython_plugin.so  (test for warnings, line 21)
 FAIL: gcc.dg/plugin/cpython-plugin-test-PyList_New.c -fplugin=./analyzer_cpython_plugin.so  (test for warnings, line 29)
 FAIL: gcc.dg/plugin/cpython-plugin-test-PyList_New.c -fplugin=./analyzer_cpython_plugin.so  at line 37 (test for warnings, line 36)
-FAIL: gcc.dg/plugin/cpython-plugin-test-PyList_New.c -fplugin=./analyzer_cpython_plugin.so (internal compiler error: Segmentation fault)
+FAIL: gcc.dg/plugin/cpython-plugin-test-PyList_New.c -fplugin=./analyzer_cpython_plugin.so (internal compiler error: tree check: expected record_type or union_type or qual_union_type, have integer_type in get_field_by_name, at /home/jakub/src/gcc/gcc/testsuite/gcc.dg/plugin/analyzer_cpython_plugin.cc:62)
 FAIL: gcc.dg/plugin/cpython-plugin-test-PyList_New.c -fplugin=./analyzer_cpython_plugin.so (test for excess errors)
 FAIL: gcc.dg/plugin/cpython-plugin-test-PyLong_FromLong.c -fplugin=./analyzer_cpython_plugin.so  (test for warnings, line 17)
 FAIL: gcc.dg/plugin/cpython-plugin-test-PyLong_FromLong.c -fplugin=./analyzer_cpython_plugin.so  (test for warnings, line 18)
 FAIL: gcc.dg/plugin/cpython-plugin-test-PyLong_FromLong.c -fplugin=./analyzer_cpython_plugin.so  (test for warnings, line 21)
 FAIL: gcc.dg/plugin/cpython-plugin-test-PyLong_FromLong.c -fplugin=./analyzer_cpython_plugin.so  (test for warnings, line 29)
 FAIL: gcc.dg/plugin/cpython-plugin-test-PyLong_FromLong.c -fplugin=./analyzer_cpython_plugin.so  at line 37 (test for warnings, line 36)
-FAIL: gcc.dg/plugin/cpython-plugin-test-PyLong_FromLong.c -fplugin=./analyzer_cpython_plugin.so (internal compiler error: Segmentation fault)
+FAIL: gcc.dg/plugin/cpython-plugin-test-PyLong_FromLong.c -fplugin=./analyzer_cpython_plugin.so (internal compiler error: tree check: expected record_type or union_type or qual_union_type, have integer_type in get_field_by_name, at /home/jakub/src/gcc/gcc/testsuite/gcc.dg/plugin/analyzer_cpython_plugin.cc:62)
 FAIL: gcc.dg/plugin/cpython-plugin-test-PyLong_FromLong.c -fplugin=./analyzer_cpython_plugin.so (test for excess errors)
...

The problem is that get_field_by_name now recurses on TREE_TYPE of
everything in TYPE_FIELDS (which can be FIELD_DECL but many other
things (though primarily for C++ and other languages)).  More importantly,
it recurses even for FIELD_DECLs with scalar (e.g. INTEGER_TYPE) types
and using TYPE_FIELDS on such types results in checking ICE.

The following patch fixes that by only recursing on anonymous struct/union
FIELD_DECLs.  For C those have NULL DECL_NAME, for C++ they would have
IDENTIFIER_ANON_P IDENTIFIER_NODE as DECL_NAME (but it seems this plugin
is only used for C).

No FAILs from plugin.exp now:
Running /usr/src/gcc/gcc/testsuite/gcc.dg/plugin/plugin.exp ...

                === gcc Summary ===

2026-03-10  Jakub Jelinek  <jakub@redhat.com>

PR testsuite/112520
* gcc.dg/plugin/analyzer_cpython_plugin.cc (get_field_by_name):
If name is "ob_refcnt", recurse only for types of FIELD_DECLs
with no DECL_NAME and record or union type.

4 weeks agotestsuite: Remove -O options from some mips.exp tests
Richard Sandiford [Tue, 10 Mar 2026 12:05:56 +0000 (12:05 +0000)] 
testsuite: Remove -O options from some mips.exp tests

Running mips.exp generated several errors like:

ERROR: gcc.target/mips/pr118608-1.c   -O0 : Unrecognised option: -O2 for " dg-options 2 "-mabi=64 -O2" "

mips.exp overrides dg-options with some logic to (try to) enable
the transitive closure of features that would be needed to make the
dg-options valid for the current test run, downgrading from run to
assemble to compile as neecessary.  In order to make sure that
every relevant option has been considered, this version of dg-options
errors out for things that it doesn't recognise.

-O options aren't in the list because mips.exp cycles through the usual
optimisation options.  Instead, dg-skips are used if the test doesn't
make sense for a particular -O* option.

Removing the -O options makes pr118608-2.c identical to pr118608-1.c
and pr118608-4.c identical to pr118608-3.c.

gcc/testsuite/
* gcc.target/mips/pr118608-2.c: Delete.
* gcc.target/mips/pr118608-4.c: Likewise.
* gcc.target/mips/pr123833.c: Remove -O* option.
* gcc.target/mips/pr118608-1.c: Likewise.
* gcc.target/mips/pr118608-3.c: Likewise, and rename to pr118608-2.c.

4 weeks agolibstdc++: Use specific feature test macro for #if in <string>
Jonathan Wakely [Sat, 7 Mar 2026 12:14:27 +0000 (12:14 +0000)] 
libstdc++: Use specific feature test macro for #if in <string>

libstdc++-v3/ChangeLog:

* include/bits/basic_string.h: Check __glibcxx_to_string instead
of __cplusplus.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 weeks agotestsuite/aarch64: Add testcase for already fixed bug [PR123094]
Andrew Pinski [Tue, 10 Mar 2026 09:46:56 +0000 (02:46 -0700)] 
testsuite/aarch64: Add testcase for already fixed bug [PR123094]

This bug was fixed by r16-7941-g2a155ceffe6639. The testcase is
different as this is an ICE rather than wrong code. So it seems
like a good idea to add a testcase for it.

Pushed as obvious after testing to make sure the new testcase
works for aarch64-linux-gnu.

PR rtl-optimization/123094

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/pr123094-1.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
4 weeks agotestsuite: Remove check_cached_effective_target_indexed [PR124066]
Richard Sandiford [Tue, 10 Mar 2026 09:43:30 +0000 (09:43 +0000)] 
testsuite: Remove check_cached_effective_target_indexed [PR124066]

Now that check_cached_effective_target_indexed is a simple wrapper
around check_cached_effective_target, we can replace all uses of
the former with the latter.

gcc/testsuite/
PR testsuite/124066
* lib/target-supports.exp (check_cached_effective_target_indexed):
Remove.  Replace all uses with check_cached_effective_target.

4 weeks agotestsuite: Add EFFECTIVE_TARGETS info to cache keys [PR124066]
Richard Sandiford [Tue, 10 Mar 2026 09:43:30 +0000 (09:43 +0000)] 
testsuite: Add EFFECTIVE_TARGETS info to cache keys [PR124066]

MIPS now uses an "effective target" mechanism to run the vectoriser
testsuite for multiple vector ISAs.  This mechanism defines a couple
of wrapper procedures:

- et-dg-runtest wraps dg-runtest and invokes it for each effective
  target.  The procedure uses two global variables:

  - EFFECTIVE_TARGETS gives the list of targets to test.  This is
    supplied by the test harness.

  - et_index is the index of the current target in EFFECTIVE_TARGETS.
    This is set by et-dg-runtest itself.

- et-is-effective-target wraps is-effective-target.  When the effective
  target mechanism is in use, et-is-effective-target tests whether the
  supplied target matches index $et_index of $EFFECTIVE_TARGETS.

check_effective_target_* procedures that use et-is-effective-target
can therefore vary from one effective target to another.  It seems
that all such procedures are expected to cache their results using
check_cached_effective_target_indexed instead of the standard
check_cached_effective_target.

check_cached_effective_target_indexed distinguishes effective targets by
adding $et_index to the cache key.  One theoretical problem with this is
that it implicitly assumes that EFFECTIVE_TARGETS will always be set to
the same value (if it's set at all).

But the more immediate problem is that et_index is default-
initialised to 0 when the effective target mechanism is not in use.
This means that the same cached values are used for the default
target and for the first effective target.  Also, et-dg-runtest
did not reset et_index after iterating through the targets,
leaving a stale value for later check_effective_target_*s.

As Richi points out in PR124066, a downside of the current
mechanism is that only et-is-effective-target tests are sensitive
to the current effective target.  Automatic tests, like those that
use check_no_compiler_messages, do not use the flags for the current
effective target.

To cope with a future fix for PR124066, it seems better to add
the current effective target to all cache keys, rather than keep
the current distinction between check_cached_effective_target
and check_cached_effective_target_indexed.  It should also be
less error prone.

Also, rather than expect et_index to be default-initialised,
it seems better to ensure that et_index is only defined while
running an effective target variant.  Other procedures can then
key off whether et_index exists.

Doing this fixes some spurious failures on a plain mips64-linux-gnu
test run.

To make the patch easier to review and bisect, the mechanical
replacement of check_cached_effective_target_indexed is left
to a follow-on patch.

gcc/testsuite/
PR testsuite/124066
* lib/target-supports.exp (check_cached_effective_target): If
et_index is defined, add the associated EFFECTIVE_TARGETS element
to the cache key.
(check_cached_effective_target_indexed): Turn into a simple wrapper
around check_cached_effective_target.
(is-effective-target): Remove default-initialization of et_index.
(et-dg-runtest): Likewise.  Unset et_index after each
EFFECTIVE_TARGETS run.
(et-is-effective-target): Key off the existence of et_index rather
than EFFECTIVE_TARGETS.

4 weeks agotestsuite: Tweak caching of MIPS vector tests
Richard Sandiford [Tue, 10 Mar 2026 09:43:29 +0000 (09:43 +0000)] 
testsuite: Tweak caching of MIPS vector tests

Some of the parallel MIPS tests that I ran recently seemed to be
nondeterministic.  Some tests were skipped and others were duplicated.

This turned out to be because some MIPS check_effective_target
procedures accept optional command-line flags.  Sometimes the
procedures are called as normal, without flags, and sometimes
they are passed an explicit -m option.

The problem is that both invocations use the same cache identifier.
This means that the result of the first invocation (with or without
flags) is used for all subsequent invocations (with or without flags).
And the first invocation depends on which tests are being run by a
particular parallel thread.

As a result, the parallel threads did not agree on which tests
needed to be run, and so got out of sync.

The flags passed to the procedures all seem to be valid filenames,
so this patch simply adds the flags to the cache identifier.
It's a bit of a hack, and I'm not sure that this pattern should
be followed for future tests.

Doing that made check_effective_target_mpaired_single always succeed
when no flags were passed, since it simply tests an empty function.
Since there is no predefined macro (AFAICT), the patch tests for support
using the same asm as check_mpaired_single_hw_available (but with an
assemble test rather than with a run test).

Also, check_mpaired_single_hw_available did not pass -mpaired-single
to the hardware test, unlike the loongson_mmi and mma equivalents.

gcc/testsuite/
* lib/target-supports.exp (check_effective_target_mips_loongson_mmi)
(check_effective_target_mips_msa): Add the arguments to the cache
identifier.
(check_effective_target_mpaired_single): Likewise.  Use an asm
to test whether -mpaired-single is supported.
(check_mpaired_single_hw_available): Add -mpaired-single.

4 weeks agoc: Fix ICE after an error: typedef and old style prototypes for nested functions...
Andrew Pinski [Mon, 9 Mar 2026 22:38:33 +0000 (15:38 -0700)] 
c: Fix ICE after an error: typedef and old style prototypes for nested functions [PR123461]

This started to ICE after r16-3747-gafa74d37e8170d which added
a call to mark_decl_used. You can't call mark_decl_used with a
typedef which is an error mark as you get an ICE.
There is a check right after the newly added call for error mark,
so let's move the call to inside that block instead.

Bootstrapped and tested on x86_64-linux-gnu.

PR c/123461

gcc/c/ChangeLog:

* c-decl.cc (declspecs_add_type): Move mark_decl_used
call after the check for error mark node.

gcc/testsuite/ChangeLog:

* gcc.dg/pr123461-1.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
4 weeks agolibstdc++: Whitespace fixes for include/std/format.
Tomasz Kamiński [Tue, 10 Mar 2026 07:54:31 +0000 (08:54 +0100)] 
libstdc++: Whitespace fixes for include/std/format.

libstdc++-v3/ChangeLog:

* include/std/format (__format::_Ptr_sink, __format::__format_padded)
(std::enable_nonlocking_formatter_optimization<pair<_Fp, _Sp>>):
Replaced 8 spaces with tabs.

4 weeks agolibstdc++: Introduce __format::_Ptr_sink for contiguous iterators.
Tomasz Kamiński [Tue, 24 Feb 2026 15:17:30 +0000 (16:17 +0100)] 
libstdc++: Introduce __format::_Ptr_sink for contiguous iterators.

This patch replaces the _Iter_sink specialization for contiguous
iterators of _CharT, with separate _Ptr_sink. This allow further
reduce the number of instantiations as single _Ptr_sink<_CharT>
specialization is used for all such iterators.

To make _Ptr_sink independent of iterator type, we no longer store
value of the iterator as _M_first member (the address pointed to is
still stored inside span). To produce the actual iterator position,
_Ptr_sink::_M_finish requires original pointer to be passed. As any
contiguous iterator is copyable, there is no issue in passing them
to both _Ptr_sink constructor and _M_finish method.

The __do_vformat_to method is reworked, to use _Ptr_sink when possible
(__contiguous_char_iterator is true). The implementation approach is
also changed to split the function into three constexpr branches:
_Sink_iter, contiguous char iterator, other iterators. The latter two
wrap iterators in _Ptr_sink and _Iter_sink respectively and forward
to _Sink_iter specialization.

To reduce the duplication, we introduce __do_format_to_n helper function,
that also handles wrapping iterator into _Ptr_sink and _Iter_sink as
appropriate.

libstdc++-v3/ChangeLog:

* include/std/format (__format::_Ptr_sink): Reworked
from _Iter_sink specialization below.
(__format::_Iter_sink<_CharT, contiguous_iterator _OutIter>):
Renamed and reworked to _Ptr_sink.
(__format::__contiguous_char_iter, __format::__do_vformat_to_n):
Define.
(__format::__do_vformat_to): Use _Ptr_sink when appropriate,
and delegate to _Sink_iter specialization.
(std::format_to_n): Delegate to __do_vformat_to_n.
(__format::_Counting_sink): Use _Ptr_sink as base class.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 weeks agolibstdc+: Eliminate usage of alloca for non-localized formatting
Tomasz Kamiński [Thu, 5 Mar 2026 14:00:31 +0000 (15:00 +0100)] 
libstdc+: Eliminate usage of alloca for non-localized formatting

This patch eliminate the use of __builtin_alloca for non-localized formatting
of integers and pointers.

For integers, the transcoding to _CharT moved from _M_format_int function
to format. This makes the maximum size (that depends on sizeof(_Int)) of the
buffer known (__buf_size) and allows use local array of _CharT (__wbuf) for
the storage. The _M_format_int is modified to accept the string of _CharT.

For pointers, r16-7844-gbfc2b87f8244a1 modified _Pres_p and _Pres_P to have
same value as _Pres_x and _Pres_X, so format specifiers are subset of one
allowed for integers. In consequence we simply delegate to format method
of __formatter_int, reducing the code duplication. The set of allowed
specifiers is still limited per C++ standard by __formatter_ptr::parse.

This patch fix issue in __formatter_ptr::parse, where for 'p' and 'P' the value
of _M_alt was negated for _M_spec (result of previous parse) instead of __spec
(result of current parse), and adjust the __formatter_ptr default constructor
to set _M_spec._M_type and _M_spec._M_alt appropriately.

libstdc++-v3/ChangeLog:

* include/std/format (__formatter_int::format): Handle transcoding
to _CharT before calling _M_format_int.
(__formatter_int::_M_format_int): Accept basic_string_view<_CharT>
and remove transcoding.
(__formatter_ptr::__formatter_ptr): Configure _M_spec member.
(__formatter_ptr::parse): Negate _M_alt for __spec and not _M_spec.
(__formatter_ptr::format): Delegate to __formatter_int.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 weeks agolibstdc++: [_GLIBCXX_DEBUG] Constrain basic_string iterator constructor
François Dumont [Mon, 9 Mar 2026 20:58:45 +0000 (21:58 +0100)] 
libstdc++: [_GLIBCXX_DEBUG] Constrain basic_string iterator constructor

Constrain __gnu_debug::basic_string(_Ite, _Ite, const _Alloc&) _Ite template
parameter so that it is an iterator type.

libstdc++-v3/ChangeLog:

* include/debug/string
[__cplusplus >= 201103L](basic_string(_Ite, _Ite, const _Alloc&)): Add
std::_RequireInputIter<_Ite> template parameter.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
4 weeks agoFix merging of flags in ipa_merge_modref_summary_after_inlining
Jan Hubicka [Tue, 10 Mar 2026 06:56:23 +0000 (07:56 +0100)] 
Fix merging of flags in ipa_merge_modref_summary_after_inlining

When merging the modref summary after inlining, we merge all of the flags
of the outer functions that was inlined into. But things go wrong as
now the flags includes both ECF_NORETURN and ECF_NOTHROW. This happens
because the function which was being inlined had ECF_NOTHROW while caller
had ECF_NORETURN. When both of these are set, ignore_stores_p and
ignore_nondeterminism_p return true. But in this case the inner function is
still just nothrow and not noreturn.

Originally the code was written to only merge ECF_PURE and ECF_CONST where
this logic is correct. This fixes merigng of ignore_stores and
ECF_LOOPING_CONST_OR_PURE flags.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/120987

gcc/ChangeLog:

* ipa-modref.cc (ipa_merge_modref_summary_after_inlining): Mask
off non const/pure/novops related flags when combining of outer
functions.

gcc/testsuite/ChangeLog:

* g++.dg/torture/pr120987-1.C: New test.

Co-authored-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>