]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
2 days agoada: Fix checking context of Initialized attribute
Viljar Indus [Thu, 7 May 2026 11:40:50 +0000 (14:40 +0300)] 
ada: Fix checking context of Initialized attribute

The initialized attribute is a special attribute that can only
be used in places where ghost code can be used.

However in those cases we have no ghost entity to check. Add
guards for this situation inside Check_Ghost_Context.Is_OK_Statement.

gcc/ada/ChangeLog:

* ghost.adb (Is_OK_Statement): Avoid checking for policies and
levels when checking the context of the Initialized attribute.

2 days agoada: Basic support for a new SPARK attribute At
Piotr Trojanek [Thu, 7 May 2026 14:37:01 +0000 (16:37 +0200)] 
ada: Basic support for a new SPARK attribute At

For now, only basic legality checks are present. Expansion is not ready yet.
This should be enough to start implementing the backend support in GNATprove.

gcc/ada/ChangeLog:

* exp_attr.adb (Expand_N_Attribute_Reference): Do not expand new
attribute.
* par-ch4.adb (Scan_Apostrophe): Parse 'At as an attribute reference;
otherwise, it would be parsed as a keyword.
* sem_attr.adb (Analyze_Attribute): Basic checks for new attribute.
(Eval_Attribute): New attribute will never be evaluated.
* snames.ads-tmpl: (Preset Names): "at" is now also an attribute, not
just a keyword.
(Attribute_Id): New attribute identifier.

2 days agoada: Fix bogus validity check failure for FP component of array with reverse SSO
Eric Botcazou [Wed, 6 May 2026 08:44:28 +0000 (10:44 +0200)] 
ada: Fix bogus validity check failure for FP component of array with reverse SSO

It comes from a thinko in Sem_Util.In_Reverse_Storage_Order_Object: only the
innermost enclosing composite type needs to be considered by the predicate.

gcc/ada/ChangeLog:

* sem_util.ads (In_Reverse_Storage_Order_Object): Adjust.
* sem_util.adb (In_Reverse_Storage_Order_Object): Rewrite.

2 days agoada: Complete removal of obsolete project manager sources
Piotr Trojanek [Tue, 14 Apr 2026 10:49:49 +0000 (12:49 +0200)] 
ada: Complete removal of obsolete project manager sources

Remove a leftover from a no-longer-existing project manager.

gcc/ada/ChangeLog:

* adaint.c (__gnat_prj_add_obj_files): Remove; files that referenced
this variable were removed years ago.

2 days agoada: Improve error message for premature record freezing
Mathias Aparicio [Wed, 1 Apr 2026 13:25:14 +0000 (15:25 +0200)] 
ada: Improve error message for premature record freezing

When a record is frozen it must be completely defined. This requires that
all of its components' types must also be completely defined
ARM 3.11.1 (8).

Before this patch, if a record was frozen while one of its components
was of a private type, the compiler complained that the record had a
private component, although privacy was not the root issue.

Now, the compiler states the actual problem directly: the type is not
completely defined.

gcc/ada/ChangeLog:

* freeze.adb (Check_And_Freeze_Type): Emit a more precise error
message when a component's frozen record is incompletely defined
instead of printing private component error.
* sem_util.ads (Incompletely_Defined): New function that
traverses recursively a type and returns the first incompletely
defined component or itself if it is incompletely defined.
* sem_util.adb (Incompletely_Defined): Likewise.
(Is_Incompletely_Defined): Refactor to a test of the new
Incompletely_Defined function for equality with Empty.

2 days agoada: Fix fallout of latest change to Valid_Scalars attribute
Eric Botcazou [Wed, 6 May 2026 16:52:59 +0000 (18:52 +0200)] 
ada: Fix fallout of latest change to Valid_Scalars attribute

The attribute does not work for all private tagged types, but this was not
detected in the case where the full view alone is tagged.

gcc/ada/ChangeLog:

PR ada/124923
* exp_attr.adb  (Expand_N_Attribute_Reference) <Valid_Scalars>: Also
bail out for a private type whose full view alone is tagged.
* sem_attr.adb (Analyze_Attribute) <Valid_Scalars>: Also warn for a
private type whose only full view alone is tagged.

2 days agoada: Avoid use-before-definition within library unit subprograms.
Steve Baird [Fri, 1 May 2026 20:06:52 +0000 (13:06 -0700)] 
ada: Avoid use-before-definition within library unit subprograms.

When the compiler builds a subprogram for an attribute (either Put_Image
or one of the streaming attributes), it needs to be inserted at a place
in the tree where all callers can refer to it.
In some cases involving library unit subprograms, that insertion point was
chosen incorrectly. Gigi would then fail an assertion while processing
a call to a procedure that had not yet been declared.

gcc/ada/ChangeLog:

* exp_attr.adb
(Expand_N_Attribute_Reference.Build_And_Insert_Type_Attr_Subp):
handle the case of a library unit subprogram body; do not assume
that every subprogram body has an enclosing declaration list.

2 days agoada: Reorder code for pragma Interrupts_System_By_Default
Piotr Trojanek [Thu, 30 Apr 2026 13:36:08 +0000 (15:36 +0200)] 
ada: Reorder code for pragma Interrupts_System_By_Default

Put code for Interrupts_System_By_Default in alphabetic order. Code cleanup.

gcc/ada/ChangeLog:

* par-prag.adb (Prag): Fix order.
* sem_prag.adb (Analyze_Pragma, Sig_Flags): Likewise.
* snames.ads-tmpl (Preset Names, Pragma_Id): Likewise.

2 days agoada: Fix internal error on private tagged types in instance with -gnateV
Eric Botcazou [Sat, 2 May 2026 09:09:18 +0000 (11:09 +0200)] 
ada: Fix internal error on private tagged types in instance with -gnateV

The problem is that the full view of a private tagged type, which is visible
in the generic unit, is not restored when expanding -gnateV in the instance.

The fix uses a two-pronged approach:

  1. the Valid_Scalars attribute, on which -gnateV is piggybacked, is fixed
     to properly handle tagged extensions (only the components declared in
     the root type are currently tested for validity).

  2. the special case for tagged extensions in instance bodies implemented
     by Try_Selected_Component_In_Instance is extended to whole instances.

gcc/ada/ChangeLog:

PR ada/124923
* exp_attr.adb (Build_Record_VS_Func): Rename first parameter, fix
description and implement support for tagged extensions.
(Expand_N_Attribute_Reference) <Attribute_Valid_Scalars>: Also bail
out for the class-wide type of private tagged types and Adjust call
to Build_Record_VS_Func.
* sem_attr.adb (Analyze_Attribute) <Attribute_Valid_Scalars>: Also
warn for the class-wide type of private tagged types.
* sem_ch4.adb (Try_Selected_Component_In_Instance): Extend a special
case from instance bodies to whole instances.
* sem_util.ads (Validated_View): Adjust description.
* sem_util.adb (Validated_View): Do not recurse on the parent type
for tagged extensions.

2 days agoada: Support Constant_Reference in Iterable aspect
Claire Dross [Fri, 17 Apr 2026 15:17:13 +0000 (17:17 +0200)] 
ada: Support Constant_Reference in Iterable aspect

A Constant_Reference function returning an anonymous access-to-constant
type can be supplied instead of the Element primitive to allow
iteration over elements of a container.

gcc/ada/ChangeLog:

* exp_ch5.adb (Expand_Formal_Container_Element_Loop): Use
Constant_Reference instead of Element if necessary.
* sem_ch13.adb (Resolve_Iterable_Operation): Check Constant_Reference.
(Validate_Iterable_Aspect): Handle Constant_Reference if supplied.
* sem_ch5.adb (Analyze_Loop_Parameter_Specification): Iteration over
elements of a container is allowed if Constant_Reference is supplied.
* sem_util.adb (Get_Iterable_Type_Primitive): Fix assertion.
* snames.ads-tmpl (Name_Constant_Reference): New name.

2 days agoada: Allow limited type initialization via constructors
Javier Miranda [Thu, 30 Apr 2026 18:30:42 +0000 (18:30 +0000)] 
ada: Allow limited type initialization via constructors

This patch extends the currrent support for constructors to support the
initialization of limited types.

gcc/ada/ChangeLog:

* errout.adb (Set_Msg_Node): Improve readability of message for
constructors name, replacing the internal compiler name
generated for direct attribute definitions with a nicer name.
* erroutc.ads (Replace_With_Attribute_Definition): Promote from
a nested subprogram declaration to a public package-level
declaration.
* erroutc.adb (Replace_With_Attribute_Definition): Move its
implementation to package level.
* exp_attr.adb (Expand_N_Attribute_Reference [Attribute_Make]):
Code cleanup; handle assignment statement and limited type
object declaration.
* exp_ch3.adb (Build_Implicit_Parameterless_Constructor): Add
comment.
(Build_Default_Simple_Initialization): Add comment.
* exp_ch4.adb (Expand_N_Allocator): Fix No_Initialization for
internally generated allocators of types with constructors.
* exp_ch6.adb (Prepend_Constructor_Procedure_Prologue): Install
formals and refactor its body to be consistent with the GNAT
style.
* sem_ch3.adb (OK_For_Limited_Init_In_05): Accept T'Make since
it is semantically equivalent to a function call.
* sem_ch6.adb (Analyze_Direct_Attribute_Definition): Handle
incomplete and private type declarations.
* sem_ch13.adb (Diagnose_Misplaced_Aspects): Remove misleading
error for aspect 'Initializes.
* sem_res.adb (Resolve_Actuals): Skip check on the first actual
of init-proc and constructors because the constructor may be
invoked to initialize a constant object, which is allowed.

2 days agoada: Revert "Remove unnecessary workaround"
Viljar Indus [Thu, 30 Apr 2026 13:15:28 +0000 (16:15 +0300)] 
ada: Revert "Remove unnecessary workaround"

This reverts commit 5c0785d62ca44b9073e543b2b3dbb04f0aca83af.

2 days agoada: Call back-end even in case of errors
Johannes Kanig [Fri, 10 Apr 2026 00:06:45 +0000 (00:06 +0000)] 
ada: Call back-end even in case of errors

In GNATprove mode, still invoke the back end when frontend compilation
errors are present, so the back-end has a chance to emit error messages
for SARIF report generation.

gcc/ada/ChangeLog:

* gnat1drv.adb (Gnat1drv): In GNATprove mode, call the
back end before exiting on compilation errors.

2 days agoada: Adjust bugbox URL in GNATprove mode
Johannes Kanig [Wed, 29 Apr 2026 01:29:38 +0000 (01:29 +0000)] 
ada: Adjust bugbox URL in GNATprove mode

When an FSF frontend crash happens under GNATprove_Mode, the bugbox
should point users to the SPARK repository instead of the GCC bug
tracker.

Keep the existing GCC bug-report instructions for other FSF tools.

gcc/ada/ChangeLog:

* comperr.adb (Compiler_Abort): Use the SPARK bug-report URL in
GNATprove mode only, and keep the GCC bug-report URL for other
FSF tools.

2 days agoDaily bump.
GCC Administrator [Thu, 4 Jun 2026 08:18:58 +0000 (08:18 +0000)] 
Daily bump.

2 days agoAdd 86ff0e88764bfbff1a4989414ec83c0eaa723107 to ignored_commits
Jakub Jelinek [Thu, 4 Jun 2026 08:16:51 +0000 (10:16 +0200)] 
Add 86ff0e88764bfbff1a4989414ec83c0eaa723107 to ignored_commits

2026-06-04  Jakub Jelinek  <jakub@redhat.com>

* gcc-changelog/git_update_version.py (ignored_commits):
Add 86ff0e88764bfbff1a4989414ec83c0eaa723107.

2 days agors6000: Fix PTImode attribute handling [PR106895]
Jeevitha [Thu, 4 Jun 2026 06:52:08 +0000 (01:52 -0500)] 
rs6000: Fix PTImode attribute handling [PR106895]

PTImode is used to generate even/odd register pairs for 128-bit values.
When PTImode is specified via a type attribute, compilation fails
because no internal type exists to represent this mode.

Introduce signed and unsigned PTImode internal builtin types to handle
PTImode. These __pti_internal types are not documented, as they are not
intended for direct user use.

2026-06-04  Jeevitha Palanisamy  <jeevitha@linux.ibm.com>

gcc/
PR target/106895
* config/rs6000/rs6000.h (enum rs6000_builtin_type_index): Add
RS6000_BTI_INTPTI and RS6000_BTI_UINTPTI.
(intPTI_type_internal_node, uintPTI_type_internal_node): New
PTImode type macros.
* config/rs6000/rs6000-builtin.cc (rs6000_init_builtins): Register
signed and unsigned PTImode internal builtin types.
* config/rs6000/sync.md (trunctipti2): New splitter.
(extendptiti2): Likewise.
(zero_extendptiti2): Likewise.

gcc/testsuite/
PR target/106895
* gcc.target/powerpc/pr106895-1.c: New test.
* gcc.target/powerpc/pr106895-2.c: New test.

2 days agomatch: Disable `if (cond) (A | CST1) : (A & ~CST1)` pattern for non-GIMPLE [PR125588]
Andrew Pinski [Thu, 4 Jun 2026 00:18:56 +0000 (17:18 -0700)] 
match: Disable `if (cond) (A | CST1) : (A & ~CST1)` pattern for non-GIMPLE [PR125588]

r17-265-gf6f33ca83cb6b8 added a new pattern that converts:
cond ? (A | CST1) : (A & ~CST1)
into `(A & ~CST1) | (cond * CST1)` but fold (partly via
fold_binary_op_with_conditional_arg) will turn
that back into `cond ? (A | CST1) : (A & ~CST1)` in some
cases. In those cases we get an infinite loop and a stack overflow crash.

This fixes the problem by enabling this pattern for GIMPLE only.

Pushed as obvious after bootstrap/test on x86_64-linux-gnu.

PR middle-end/125588

gcc/ChangeLog:

* match.pd (`if (cond) (A | CST1) : (A & ~CST1)`): Enable
for GIMPLE only.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 days ago[PATCH v4] Replace certain uses of TEST_HARD_REG_BIT in loops with better alternatives
Kevin Stefanov [Thu, 4 Jun 2026 04:46:02 +0000 (22:46 -0600)] 
[PATCH v4] Replace certain uses of TEST_HARD_REG_BIT in loops with better alternatives

This change takes loops of the form:

  for (int <i> = 0; <i> < FIRST_PSEUDO_REGISTER; <i>++)
    if (TEST_HARD_REG_BIT (<set>, <i>))
      <body that doesn't change i or set>

and carries out the necessary refactoring to rewrite them as:

  hard_reg_set_iterator hrsi; [...]
  EXECUTE_IF_SET_IN_HARD_REG_SET (<set>, 0, <i>, hrsi)
    <body that doesn't change i or set>

in loops where expressing <set> does not involve <i>.

It also replaces the only two call sites of hard_reg_set_size
(which was internally using TEST_HARD_REG_BIT in such a loop)
with a call to hard_reg_set_popcount, as a popcount is all
that it was doing anyway. Thus, the now-unused function
hard_reg_set_size has been removed from the codebase.

Replaced one additional use of TEST_HARD_REG_BIT in such
a loop with a call to hard_reg_set_popcount.

---

Hi all,

I have made the improvements suggested by Jeffrey's review.
Thank you for that.

In v4, I remove the function hard_reg_set_size and
replace its only two call sites with calls to
hard_reg_set_popcount as Jeff suggested. Since this
is slightly different from the one recurring mechanical
refactoring I was doing so far everywhere else, but
still related to replacing TEST_HARD_REG_BIT in
loops with better alternatives, I've changed the
patch title to reflect that. The ChangeLog and commit
message have been updated too.

The formatting issues involving commas have been fixed
and I have dropped the gratuitous unrelated change
that Jeff pointed out in the review.

I also spotted some incorrect function names in my previous ChangeLog.
It was an oversight on my side. The git diff
command output shows the function name where the displayed
change dump begins, not the function being changed.
That became a source of confusion for me when the diff dump
begins at the end of the previous function's body as it appears
in the source file. I've corrected these ChangeLog entries.

Synced with trunk as of June 3rd, no merge conflicts.

Regstrapped on x86_64-pc-linux-gnu with enable-languages=c,c++.

This is my first contribution, so if anybody could push it for
me when it's ready, I'd appreciate it. Thanks.

gcc/
* config/m68k/m68k.cc (m68k_conditional_register_usage): Replace TEST_HARD_REG_BIT
with EXECUTE_IF_SET_IN_HARD_REG_SET in applicable loops.
(m68k_zero_call_used_regs): Likewise.
* config/pdp11/pdp11.cc (pdp11_conditional_register_usage): Likewise.
* ira-color.cc (create_new_allocno_hard_regs_node): Replace call to hard_reg_set_size
with hard_reg_set_popcount.
* ira-int.h (hard_reg_set_size): Remove.
* ira-lives.cc (process_bb_node_lives): Replace TEST_HARD_REG_BIT
with EXECUTE_IF_SET_IN_HARD_REG_SET in applicable loops.
* ira.cc (setup_class_hard_regs): Likewise.
(update_equiv_regs_prescan): Likewise.
(build_insn_chain): Likewise.
(setup_stack_reg_pressure_class): Replace call to hard_reg_set_size
with hard_reg_set_popcount.
* lra-eliminations.cc (spill_pseudos): Replace TEST_HARD_REG_BIT
with EXECUTE_IF_SET_IN_HARD_REG_SET in applicable loops.
* optabs.cc (expand_asm_reg_clobber_mem_blockage): Replace
TEST_HARD_REG_BIT with EXECUTE_IF_SET_IN_HARD_REG_SET in one instance
and with hard_reg_set_popcount in another.
* postreload.cc (reload_combine): Replace TEST_HARD_REG_BIT
with EXECUTE_IF_SET_IN_HARD_REG_SET in applicable loops.
* reginfo.cc (init_reg_sets_1): Likewise.
* regrename.cc (init_rename_info): Likewise.
* reload1.cc (maybe_fix_stack_asms): Likewise.
(update_eliminables_and_spill): Likewise.
* rtl-ssa/insns.cc (function_info::record_call_clobbers): Likewise.
* sched-deps.cc (sched_analyze_insn): Likewise.
* sel-sched-dump.cc (print_hard_reg_set): Likewise.

Signed-off-by: Kevin Stefanov <kevinstefanov15@gmail.com>
2 days agoi386: Extend MOVNTDQ support to cover various packed integer types
Xiaomei Xue [Thu, 4 Jun 2026 02:42:12 +0000 (02:42 +0000)] 
i386: Extend MOVNTDQ support to cover various packed integer types

As the associated mode iterator VI8 shows, MOVNTDQ is only used for
*QI and *DI packed integer modes, this patch extends it to cover *HI
and *SI packed integer modes.

gcc/ChangeLog:

* config/i386/sse.md (define_mode_attr sse2): Add V4SI/V8SI/V16SI/
V8HI/V16HI/V32HI.
(<sse2>_movnt<mode>): Change mode iterator from VI8 to VI_AVX_AVX512F.
(define_mode_iterator STORENT_MODE): Add V4SI/V8SI/V16SI/V8HI/V16HI/
V32HI/V16QI/V32QI/V64QI.

Signed-off-by: Xiaomei Xue <xuexiaomei@hygon.cn>
3 days agoc++: non-dep cmp op rewritten from <=> returning char [PR125378]
Patrick Palka [Wed, 3 Jun 2026 22:04:12 +0000 (18:04 -0400)] 
c++: non-dep cmp op rewritten from <=> returning char [PR125378]

When a user operator<=> returns an integral type smaller than int, the
rewritten form of x @ y contains an integer promotion: (int)(x <=> y) @ 0.

This patch teaches build_min_non_dep_op_overload to look through and
preserve this implicit cast.

PR c++/125378

gcc/cp/ChangeLog:

* tree.cc (build_min_non_dep_op_overload): Handle comparison
operator expressions rewritten from a <=> that contain an
integer promotion.

gcc/testsuite/ChangeLog:

* g++.dg/lookup/operator-8b.C: New test.
* g++.dg/lookup/operator-8c.C: New test.
* g++.dg/lookup/operator-9a.C: New test.
* g++.dg/lookup/operator-9b.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
Reviewed-by: Marek Polacek <polacek@redhat.com>
3 days agoc++: unchecked 'A op B' constraint-expression [PR125490]
Patrick Palka [Wed, 3 Jun 2026 22:03:14 +0000 (18:03 -0400)] 
c++: unchecked 'A op B' constraint-expression [PR125490]

Here the nonsensical constraint-expression f() == 42 isn't getting rejected
ahead of time because when parsing we pass no_toplevel_fold_p=true to
cp_parser_binary_expression, which makes it use build_min instead of
build_x_binary_op, effectively bypassing the actual processing of the
operator expression until satisfaction time.  This flag was introduced
by r145014 to avoid undesirable folding / canonicalization of OpenMP for
loop conditions, and that's still the only other user of the flag today.

But I think cp_parser_constraint_expression doesn't need to use this
flag at all because constraint-expression parsing is always templated
and we (generally) don't fold templated trees.  I think the flag is
intended to be used only by OpenMP parsing routines.

Note that without this patch we'd go on to reject the constraint-expression
at satisfaction time, so this first testcase is effectively IFNDR / QoI.
But this change isn't limited to IFNDR cases, we need to process the
operator expression at parse time for sake of correct unqualified lookup
as in the second testcase.

PR c++/125490

gcc/cp/ChangeLog:

* parser.cc (cp_parser_constraint_expression): Pass
no_toplevel_fold_p=false instead of =true to
cp_parser_binary_expression.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-pr125490.C: New test.
* g++.dg/cpp2a/concepts-pr125490a.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
3 days agoa68: fix list of worthy characters in ga68.texi
Jose E. Marchesi [Wed, 3 Jun 2026 20:29:43 +0000 (22:29 +0200)] 
a68: fix list of worthy characters in ga68.texi

Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
gcc/algol68/ChangeLog

* ga68.texi (Worthy characters): Remove spurious @ entry in the
list of worthy characters.

3 days agofortran: add INLINE and ALWAYS_INLINE attributes
Henri Menke [Fri, 29 May 2026 18:09:05 +0000 (18:09 +0000)] 
fortran: add INLINE and ALWAYS_INLINE attributes

gfortran already understands the !GCC$ ATTRIBUTES NOINLINE directive to
suppress inlining of a procedure, but there was no way to request the
opposite.  This adds two attributes:

    !GCC$ ATTRIBUTES inline :: my_procedure
    !GCC$ ATTRIBUTES always_inline :: my_procedure

INLINE is a plain hint equivalent to the C inline keyword and only sets
DECL_DECLARED_INLINE_P, so the inliner's size limits still apply.
ALWAYS_INLINE corresponds to the C always_inline attribute and
additionally sets DECL_DISREGARD_INLINE_LIMITS.  Since Fortran has no
inline keyword, DECL_DECLARED_INLINE_P is set explicitly.  Setting only
DECL_DISREGARD_INLINE_LIMITS would make the middle-end warn that the
always-inline function might not be inlinable.

INLINE and ALWAYS_INLINE are incompatible with NOINLINE.  In the
middle-end the DECL_UNINLINABLE flag set by NOINLINE always wins, so the
inline request would be silently ignored.  To avoid that surprise the
directive parser warns and drops the inline attribute when both are
applied to the same procedure, whether in one directive or in two.

The new EXT_ATTR_* values are appended at the end of the enum because the
symbol_attribute.ext_attr bitmask is written to module files.  Appending
preserves the existing bit positions and keeps modules written by older
gfortran readable.

Bootstrapped and regtested on x86_64-pc-linux-gnu with
--enable-languages=c,c++,fortran.  All three stages built and the
stage 2 and 3 comparison succeeded.  The gfortran testsuite shows no
regressions (75660 expected passes, 339 expected failures, 0 unexpected
failures) and the four new tests pass.

gcc/fortran/ChangeLog:

* gfortran.h (enum ext_attr_id_t): Add EXT_ATTR_INLINE and
EXT_ATTR_ALWAYS_INLINE at the end.  Document that new attributes
must be appended to preserve module compatibility.
* decl.cc (ext_attr_list): Add "inline" and "always_inline".
(gfc_match_gcc_attributes): Warn about and drop INLINE or
ALWAYS_INLINE when combined with NOINLINE on the same symbol.
* trans-decl.cc (build_function_decl): Handle EXT_ATTR_INLINE and
EXT_ATTR_ALWAYS_INLINE by setting DECL_DECLARED_INLINE_P, and
DECL_DISREGARD_INLINE_LIMITS for ALWAYS_INLINE.
* gfortran.texi (ATTRIBUTES directive): Document INLINE and
ALWAYS_INLINE.

gcc/testsuite/ChangeLog:

* gfortran.dg/always_inline_1.f90: New test.
* gfortran.dg/always_inline_2.f90: New test.
* gfortran.dg/inline_1.f90: New test.
* gfortran.dg/inline_2.f90: New test.

Signed-off-by: Henri Menke <henri@henrimenke.de>
3 days agocselim: Allow middle_bb to have more than one statement [PR124405]
Pengxuan Zheng [Thu, 9 Apr 2026 01:09:48 +0000 (18:09 -0700)] 
cselim: Allow middle_bb to have more than one statement [PR124405]

Currently, cselim requires the middle_bb to have only a single statement. This
patch relaxes this restriction as long as all uses (except the rhs) in the
single stmatement are also available where we insert to.

Bootstrapped and tested on x86_64-linux-gnu and aarch64-linux-gnu.

Changes since v1:
* v2: Revert changes to trailing_store_in_bb and do not call
      trailing_store_in_bb to get split_assign.
      Remove some unnecessary checks in cselim_candidate.
      Pass the result of cselim_candidate which is the candidate store for
      cselim as an argument to cond_store_replacement instead.
* v3: Simplify cselim_candidate by always calling trailing_store_in_bb and
      removing the legality checks.
      Generalize the cond_store_replacement legality checks to account for the
      case when the middle_bb can have more than one statement.

PR tree-optimization/124405

gcc/ChangeLog:

* tree-ssa-phiopt.cc (cond_store_replacement): Make ASSIGN (the
candidate store for cselim) an argument of the function instead. Update
legality check due to relaxing the restriction that middle_bb can have
only a single statement.
(cselim_candidate): New.
(pass_cselim::execute): Call cselim_candidate and pass the result to
cond_store_replacement.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/pr124405.c: New test.

Signed-off-by: Pengxuan Zheng <pengxuan.zheng@oss.qualcomm.com>
3 days agoc23: fix TBAA error for function returning structure [PR125252]
Martin Uecker [Sun, 10 May 2026 18:21:40 +0000 (20:21 +0200)] 
c23: fix TBAA error for function returning structure [PR125252]

To fix PR122572 we globbed pointers to structure or union types nested
within other structure or union types to a void pointer when computing
the TYPE_CANONICAL.  But when doing this for function return types this
then leads to wrong aliasing decisions, because for some reason function
derivation behaves differently than pointer and array derivation.  Instead
of globbing to void, replace the nested structure or union type with an
incomplete type instead.

PR c/125252

gcc/c/ChangeLog:

* c-typeck.cc (ptr_to_tagged_member): Return type of member.
(c_type_canonical): Use incomplete type.

gcc/testsuite/ChangeLog:

* gcc.dg/pr125252.c

3 days agoc++: reference tparm refers to temporary object [PR107124]
Marek Polacek [Wed, 27 May 2026 17:23:49 +0000 (13:23 -0400)] 
c++: reference tparm refers to temporary object [PR107124]

[temp.arg.nontype] tells us that a temporary object is not an acceptable
template-argument when the corresponding template parameter has reference
type.  So

  template<const int& CRI> struct B { };
  B<1> b;

is ill-formed.  In the test below we have a tparm `const int &I` and we
are trying to deduce `I` from `A<0>`.  Since a temporary would be required
for the template argument, this should be a deduction failure.

PR c++/107124

gcc/cp/ChangeLog:

* cp-tree.h: Adjust comments to mention
maybe_build_nontype_implicit_conv instead of
maybe_convert_nontype_argument.
* pt.cc (maybe_convert_nontype_argument): Rename to...
(maybe_build_nontype_implicit_conv): ...this.
(convert_nontype_argument_maybe_dependent): New, factored
out of...
(convert_template_argument): ...here.
(unify) <case TEMPLATE_PARM_INDEX>: Call
convert_nontype_argument_maybe_dependent and return unify_invalid
if it failed.  Don't call strip_typedefs_expr.

gcc/testsuite/ChangeLog:

* g++.dg/template/deduce11.C: New test.
* g++.dg/template/deduce12.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
3 days ago[PATCH v2] RISC-V: Add XuanTie C908 tuning and scheduler model
Milan Tripkovic [Wed, 3 Jun 2026 17:33:20 +0000 (11:33 -0600)] 
[PATCH v2] RISC-V: Add XuanTie C908 tuning and scheduler model

Add tuning definitions for the XuanTie C908 core, including a
scalar scheduler model.

The scheduler model describes the scalar integer, load/store, multiply,
divide, and floating-point pipeline resources. It is based on the
XuanTie C908 R1S0 User Manual.

This patch only models scalar scheduling. Vector scheduling is left for
future work (xt-c908v).

The scheduler model was tested on a CanMV-K230-V1.1 with CoreMark and a set
of instruction throughput tests.

The instruction throughput tests are essentially unrolled loops which
have groups of instructions (a group of adds and a group of fadd instructions
we are measuring for example) which use independent registers. For the
purpose of estimating the efficiency of scheduling such an unrolled loop,
the impact of reducing pipeline stalls on measured cycle counts is noticeable.

Each test uses aligned memory access. Before taking
measurements, the benchmark performs 20 warm-up runs. The measured test
is then executed 200 times.

On a CanMV-K230-V1.1 board, this tuning gives about a 0.8% CoreMark improvement.
The instruction throughput tests show cycle-count improvements of
about 5% to 17%.

Long-latency reservations are clamped to 7 cycles, following the existing
RISC-V scheduler modelling approach introduced by commit 8265192.

gcc/ChangeLog:

* config/riscv/riscv-cores.def (RISCV_TUNE): Changed xt-c908
PIPELINE_MODEL and TUNE_INFO
* config/riscv/riscv-opts.h (enum riscv_microarchitecture_type): Add entry
for xt-c908 design
* config/riscv/riscv.cc: New tune structure
for the xt-c908 design.
* config/riscv/riscv.md: Add xt-c908 .
Include xt-c908.md.
* config/riscv/xt-c908.md: New file.

3 days agoc: fix wrong code with counted_by attribute [PR123569]
Martin Uecker [Mon, 1 Jun 2026 18:57:09 +0000 (20:57 +0200)] 
c: fix wrong code with counted_by attribute [PR123569]

For an access to a member of pointer type with counted_by attribute,
the .ACCESS_WITH_SIZE internal function is inserted at certain places
before reading the pointer.  This leads to wrong code for increment
and decrement operations.  For now, do not instrument these accesses
by using default_array_function_conversion instead of
default_array_function_read_conversion and calling mark_exp_read_
directly.  Code to undo the effect of mark_exp_read can be removed,
and the logic is moved into a helper function mark_exp_read_cond.

PR c/123569

gcc/c/ChangeLog:
* c-parser.cc (mark_exp_read_cond): New function.
(c_parser_unary_expression): Use mark_exp_read_cond.
(c_parser_postfix_expression_after_primary): Likewise.
* c-typeck.cc (build_unary_op): Remove dead code and
add checking assertion.

gcc/testsuite/ChangeLog:
* gcc.dg/pr123569.c: New test.

3 days agotree-scalar-evolution: Fold loop PHIs with known nonzero niter
Abhishek Kaushik [Wed, 27 May 2026 11:09:12 +0000 (11:09 +0000)] 
tree-scalar-evolution: Fold loop PHIs with known nonzero niter

SCEV sometimes fails to compute the final value of a loop PHI when the
entry value does not match the value produced by later iterations.  For
example:

  # y = PHI <y_next, 666>
  i_next = i + 1;
  y_next = i_next * 10;

The PHI value is:

  666, 10, 20, 30, ...

This is not a normal affine recurrence.  But if the latch count is
known to be nonzero, the entry value cannot be the value seen after
the loop.  The final value is the latch argument evaluated at iteration
niter - 1.

Teach SCEV final value replacement to handle this case.

This patch was bootstrapped and regression tested on aarch64-linux-gnu.

gcc/:

* tree-scalar-evolution.cc
(compute_final_value_from_loop_phi_latch): New function.
(final_value_replacement_loop): Use it.

gcc/testsuite/:

* gcc.dg/tree-ssa/sccp-loop-phi.c: New test.
* gcc.dg/tree-ssa/sccp-loop-phi-not-optimized.c: New test.

3 days agopasses: Move early pass_sccopy right after evrp [PR103221]
Andrew Pinski [Tue, 2 Jun 2026 20:21:11 +0000 (13:21 -0700)] 
passes: Move early pass_sccopy right after evrp [PR103221]

EVRP changes some statements into copies but then does
not do copy prop during its handling. This causes in some
cases where phiopt could have optimized the phi not to be
done. So we should move the copy prop pass (sccopy) right
after evrp instead of after phiopt.

Notes on the testsuite changes:
dse-points-to.c needs to disable sccopy1 for the same
reason why it disables all other copyprop passes.
pr45397.c had an xfail for specifically PR 103221.
pr81981.c is about a missing warning, in this case moving
sccopy swaps around which uses is first in the list.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/103221
gcc/ChangeLog:

* passes.def (early_optimizations): Move sccopy
to after evrp.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/dse-points-to.c: Disable sccopy1.
* gcc.dg/tree-ssa/pr45397.c: Remove the xfail.
* gcc.dg/ubsan/pr81981.c: Swap around which one is xfailed.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
3 days agosccopy: Handle ssa info for copies in sccopy
Andrew Pinski [Tue, 2 Jun 2026 21:20:17 +0000 (14:20 -0700)] 
sccopy: Handle ssa info for copies in sccopy

Currently if the ssa info (range or aliasing) is different
between the src and dest of a copy, sccopy will reject it.
This fixes the FIXME and handles it in a similar way as copyprop
handles it.  This is needed to able to move sccopy earlier (before phiopt1)
and to act like a copyprop pass.

Bootstrapped and tested on x86_64-linux-gnu with no regressions.

gcc/ChangeLog:

* gimple-ssa-sccopy.cc (stmt_may_generate_copy): Remove restriction
on the ssa info being different for the "copy".
(scc_copy_prop::replace_scc_by_value): Call maybe_duplicate_ssa_info_at_copy
when copyproping a ssa name.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
3 days agoMAINTAINERS: Add missing account names
Richard Earnshaw [Mon, 1 Jun 2026 12:41:26 +0000 (13:41 +0100)] 
MAINTAINERS: Add missing account names

Add the missing account names to the write-after section.  All
contributors that have ever had an account on the sourceware machine(s)
are now covered.  Only one entry remains that appears never to have had
an account.

ChangeLog:

* MAINTAINERS: Add all known missing account names to
write-after.

3 days agolibstdc++: Define feature test macros for hardened implementation
Jonathan Wakely [Thu, 21 May 2026 15:38:58 +0000 (16:38 +0100)] 
libstdc++: Define feature test macros for hardened implementation

The P3471R4 and P3697R1 proposals adding hardened preconditions also
defined feature test macros that indicate whether the hardened
preconditions are checked. For our implementation, those checks are
enabled by defining _GLIBCXX_ASSERTIONS.

To implement this, I've added all the __cpp_lib_hardened_xxx macros at
the end of bits/version.def, because the simplest way to define many of
them seems to be to make the depend on the macro for the main feature
and additionally depend on defined(_GLIBCXX_ASSERTIONS).

The hardening checks were added to each component as follows:

std::array                  r11-4854-g6db082477ad839
std::bitset                 r16-7919-g1b404c574450a4
std::deque                  r7-1526-gbd2ee798d5a5a3
std::expected               since first commit
std::forward_list           r15-5721-ge7aa614d7372b5
std::inplace_vector         since first commit
std::common_iterator        since first commit
std::counted_iterator       since first commit
std::list                   r15-5721-ge7aa614d7372b5
std::shared_ptr<T[]>        since first commit
std::optional               r8-711-g2c27a627a31034
std::ranges::view_interface since first commit
std::span                   r10-2983-gb5c433ce11a140
std::basic_stacktrace       since first commit
std::basic_string           r6-3197-g2f1e8e7c4730bb
std::basic_string_view      r11-2881-g3eefb302d2bd85
std::valarray               r6-3197-g2f1e8e7c4730bb
std::vector                 r6-3197-g2f1e8e7c4730bb

This commit does not define __cpp_lib_hardened_mdspan, that was added in
r17-1258-g19def756dec1fe earlier today.

This commit does not include the LWG 4577 changes to harden
view_interface::operator[] which will be added later (with a new value
for the __cpp_lib_hardened_view_interface macro).

libstdc++-v3/ChangeLog:

* include/bits/version.def: Define macros for hardened
preconditions.
* include/bits/version.h: Regenerate.
* include/std/array: Define "want" macro for hardened
precondition macro.
* include/std/bitset: Likewise.
* include/std/deque: Likewise.
* include/std/expected: Likewise.
* include/std/forward_list: Likewise.
* include/std/inplace_vector: Likewise.
* include/std/iterator: Likewise.
* include/std/list: Likewise.
* include/std/memory: Likewise.
* include/std/optional: Likewise.
* include/std/ranges: Likewise.
* include/std/span: Likewise.
* include/std/stacktrace: Likewise.
* include/std/string: Likewise.
* include/std/string_view: Likewise.
* include/std/valarray: Likewise.
* include/std/vector: Likewise.
* testsuite/23_containers/array/tuple_interface/get_neg.cc:
Adjust dg-error line numbers.

Reviewed-by: Nathan Myers <nmyers@redhat.com>
Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 days agoa86: add syntax on modes and nests to ga68.vw
Jose E. Marchesi [Wed, 3 Jun 2026 14:45:44 +0000 (16:45 +0200)] 
a86: add syntax on modes and nests to ga68.vw

Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
gcc/algol68/ChangeLog

* ga68.vw (Modes and nests): Incorporate syntax from the RR
chapter 7.

3 days agoRISC-V: Add testcase for unsigned scalar SAT_MUL form 11
Pan Li [Mon, 18 May 2026 09:46:05 +0000 (17:46 +0800)] 
RISC-V: Add testcase for unsigned scalar SAT_MUL form 11

The form 11 of unsigned scalar SAT_MUL has supported from
the previous change.  Thus, add the test cases to make sure
it works well.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/sat/sat_arith.h: Add test helper macros.
* gcc.target/riscv/sat/sat_u_mul-12-u16-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-12-u16-from-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-12-u16-from-u64.rv32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-12-u16-from-u64.rv64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-12-u32-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-12-u32-from-u64.rv32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-12-u32-from-u64.rv64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-12-u64-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-12-u8-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-12-u8-from-u16.c: New test.
* gcc.target/riscv/sat/sat_u_mul-12-u8-from-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-12-u8-from-u64.rv32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-12-u8-from-u64.rv64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-12-u16-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-12-u16-from-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-12-u16-from-u64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-12-u32-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-12-u32-from-u64.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-12-u64-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-12-u8-from-u128.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-12-u8-from-u16.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-12-u8-from-u32.c: New test.
* gcc.target/riscv/sat/sat_u_mul-run-12-u8-from-u64.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
3 days agoMatch: Support unsigned scalar SAT_MUL form 11
Pan Li [Mon, 18 May 2026 09:43:19 +0000 (17:43 +0800)] 
Match: Support unsigned scalar SAT_MUL form 11

This patch would like to try to match the the unsigned
SAT_MUL form 11, aka below

  #define DEF_SAT_U_MUL_FMT_11(NT, WT)             \
  NT __attribute__((noinline))                     \
  sat_u_mul_##NT##_from_##WT##_fmt_11 (NT a, NT b) \
  {                                                \
    WT x = (WT)a * (WT)b;                          \
    NT max = -1;                                   \
    bool overflow_p = x >= (WT)(max);              \
    return -(NT)(overflow_p) | (NT)x;              \
  }

while WT is uint128_t, uint64_t, uint32_t and uint16_t, and
NT is uint64_t, uint32_t, uint16_t or uint8_t.

gcc/ChangeLog:

* match-sat-alu.pd: Add pattern for unsigned scalar
SAT_MUL form 11.

Signed-off-by: Pan Li <pan2.li@intel.com>
3 days agoc++/reflection: template splicing tweak
Jason Merrill [Wed, 3 Jun 2026 12:40:53 +0000 (08:40 -0400)] 
c++/reflection: template splicing tweak

Discussion of the 124794 patch observed that access_path can be null if
object_type isn't derived from scope, which means building a nonsensical
BASELINK with null BASELINK_BINFO.

PR c++/124794

gcc/cp/ChangeLog:

* parser.cc (cp_parser_splice_specifier): Use TYPE_BINFO (scope)
for not-derived case.
* search.cc (build_baselink): Assert that binfos aren't null.

3 days agoc++/reflection: member function template splicing [PR124794]
feedable [Wed, 3 Jun 2026 12:40:53 +0000 (08:40 -0400)] 
c++/reflection: member function template splicing [PR124794]

cp_parser_splice_expression is stripping BASELINKs before resolving the
expr; checks if the result is a BASELINK after that (by which point it never
is).  To fix it, stop stripping the BASELINK, add handling to
check_splice_expr instead.

In cp_parser_splice_specifier, the additional template param parsing fails
to detect that the reflection is a template if it's wrapped in a BASELINKs,
and decides not to parse the splice-specialization-specifier if the
'template' keyword is missing. Grab the data from the reflection instead.

During template instantiation, we blindly substitute the template part of a
TEMPLATE_ID_EXPR, even if it's a SPLICE_EXPR. This, in turn, substitutes the
SPLICE_EXPR as-if it had no template arguments and finishes up the
expression, which interferes with later processing by TEMPLATE_ID_EXPR.  To
fix, we defer such TEMPLATE_ID_EXPRs to tsubst_splice_expr, which itself
performs the substitution of a TEMPLATE_ID_EXPR and finishes up the
expression.

check_splice_expr now also accepts TEMPLATE_ID_EXPRs in tsubst_splice_expr;
this is uniform with cp_parser_splice_expression, and required in order to
handle `template[:dep:]<>` where `dep` does not reflect a template.

PR c++/124794
PR c++/125069

gcc/cp/ChangeLog:

* parser.cc (cp_parser_splice_specifier): Do not strip BASELINKs.
(cp_parser_splice_expression): Add parsing for member function
template specializations without the "template" keyword.
* pt.cc (tsubst_splice_expr): Handle TEMPLATE_ID_EXPR where the
template part is a SPLICE_EXPR.
(tsubst_expr): Defer to tsubst_splice_expr when the template part of
TEMPLATE_ID_EXPR is a SPLICE_EXPR.
* reflect.cc (check_splice_expr): Add handling for BASELINKs.

gcc/testsuite/ChangeLog:

* g++.dg/reflect/member19.C: Enable tests.
* g++.dg/reflect/splice15.C: New test.
* g++.dg/reflect/splice16.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
3 days agolibstdc++: Define hardening FTM and update operator[] for mdspan
Tomasz Kamiński [Wed, 3 Jun 2026 10:04:51 +0000 (12:04 +0200)] 
libstdc++: Define hardening FTM and update operator[] for mdspan

Defines __cpp_lib_hardened_mdspan.

The hardened precondition on the mdspan converting constructor,
is validated by the assert(_S_is_compatible_extents()) in the
_ExtentsStorge. This also covers user-defined mappings, as all
mappings are required to store, and thus construct extents
objects.

The operator[] implemented all required bounds checks, by:
* checking for negative values in __index_type_cast
* checking if value is representable in index_type in
  __index_type_cast
* checking against the bound by calling __is_multi_index lambda
  in operator[]
However, the last check subsumes the representability check
(static extent values are validated at compile time).
To reduce duplicated checks, this patch uses __index_int_t
(introduced in r16-7644-g43f7452026fc05 for mdspan::at), that
preserve negative values of arguments of integral type.

libstdc++-v3/ChangeLog:

* include/bits/version.def (hardened_mdspan): Define.
* include/bits/version.h: Regenerate.
* include/std/mdspan (__cpp_lib_hardened_mdspan): Define.
(mdspan::operator[]): Replace __mdspan::__index_type_cast
with cast to __index_int_t, and inline negative value checks.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 days agoAdd CALL_INSN_ABI_ID
Richard Sandiford [Wed, 3 Jun 2026 12:11:17 +0000 (13:11 +0100)] 
Add CALL_INSN_ABI_ID

function-abi.h was originally added to cope with AArch64's
vector PCS and SVE PCS variants.  One of the key requirements
was that a call insn must say precisely which ABI the callee uses,
regardless of how the call is created.

At the time, I did this by encoding the information as an UNSPEC
in the AArch64 call patterns.  IIRC, there were three reasons for
doing it that way:

(1) To make sure that the information is not accidentally dropped.

(2) To make sure that calls using different ABIs are distinct
    (not rtx_equal_p).

(3) Because it seemed presumptious to add a new CALL_INSN field for
    something that only AArch64 was using.

However, CALL_INSN_FUNCTION_USAGE and SIBLING_CALL_P also require (1)
and at least SIBLING_CALL_P requires (2).  I'm not aware that this
has been a common source of bugs in practice.

As far as (3) goes, RISC-V now uses a similar system, and x86 is
also about to use function_abi more heavily (see HJ's patches).
Any target that wants to run CPython efficiently will probably want
to implement preserve_none, and so adopt the same kind of approach.

If we take the view that having multiple ABIs is now going to be
common for "major" targets, attaching the information to the
CALL_INSN would be both simpler and more compact.

As it stands, targets have to smuggle the ABI information from
init_cumulative_args (which supplies the function type) through
function_arg (which asks the target for the final call operand)
to call/call_value/etc. (which receive the information from
function_arg).  It's all a bit of a mess.

This patch therefore adds a new CALL_INSN_ABI_ID field to CALL_INSN
and removes the now-redundant insn_callee_abi hook.

This makes UNSPEC_CALLEE_CC unnecessary on RISC-V, so the patch
reverts the call patterns to something like their state before
r14-3733-gfdd59c0f73e9e6 (which is in no way a comment against
that patch).  In contrast, AArch64 still uses the ABI "cookie"
for other information, so it needs to be kept.

The patch reflows the CALL_INSN_FUNCTION_USAGE documentation but
otherwise just does s/@code{CALL_INSN_FUNCTION_USAGE}/This field/.

gcc/
* rtl.def (CALL_INSN): Add a new integer field.
* rtl.h (CALL_INSN_ABI_ID): New macro.
* target.def (insn_callee_abi): Delete.
* doc/rtl.texi: Document CALL_INSN_ABI_ID.
* doc/tm.texi.in (TARGET_INSN_CALLEE_ABI): Remove.
* doc/tm.texi: Regenerate.
* calls.cc: Include regs.h and function-abi.h.
(emit_call_1): Initialize CALL_INSN_ABI_ID.
* cfgcleanup.cc (old_insns_match_p): Compare CALL_INSN_ABI_IDs.
* emit-rtl.cc (try_split): Copy the original insn's CALL_INSN_ABI_ID
to the new call.
(emit_copy_of_insn_after): Likewise.
(make_call_insn_raw): Initialise CALL_INSN_ABI_ID.
* function-abi.cc (insn_callee_abi): Remove use of the insn_callee_abi
hook and instead use CALL_INSN_ABI_ID.
* recog.cc (peep2_attempt): Copy the original insn's CALL_INSN_ABI_ID
to the new call.
* config/aarch64/aarch64-protos.h (aarch64_gen_callee_cookie): Remove
arm_pcs parameter.
* config/aarch64/aarch64.cc (aarch64_gen_callee_cookie): Likewise.
(aarch64_callee_abi): Delete.
(aarch64_insn_callee_abi): Likewise.
(aarch64_function_arg): Update call to aarch64_callee_abi.
(aarch64_output_mi_thunk): Likewise.  Set CALL_INSN_ABI_ID instead.
(TARGET_INSN_CALLEE_ABI): Delete.
* config/aarch64/aarch64.md (tlsdesc_small_<mode>): Update call
to aarch64_callee_abi and set CALL_INSN_ABI_ID instead.
* config/i386/i386.cc (ix86_insn_callee_abi): Delete.
(ix86_expand_avx_vzeroupper): Set CALL_INSN_ABI_ID.
(TARGET_INSN_CALLEE_ABI): Delete.
* config/riscv/riscv-sr.cc (riscv_remove_unneeded_save_restore_calls):
Remove coding convention from calls to gen_sibcall_internal and
gen_sibcall_value_internal.  Store the ABI identifier in
CALL_INSN_ABI_ID instead.
* config/riscv/riscv.cc (riscv_output_mi_thunk): Likewise.
(riscv_call_tls_get_addr): Likewise, but calling gen_call_value.
(riscv_function_arg): Return null for the end marker.
(get_riscv_cc, riscv_insn_callee_abi): Delete.
(TARGET_INSN_CALLEE_ABI): Delete.
* config/riscv/riscv.md (UNSPEC_CALLEE_CC): Delete.
(sibcall): Revert to treating operand 2 as a placeholder.
Do not pass it to gen_sibcall_internal.
(sibcall_value): Likewise operand 3 and gen_sibcall_value_internal.
(call): Likewise operand 2 and gen_call_internal.
(call_value): Likewise operand 3 and gen_call_value_internal.
(sibcall_internal, call_internal): Remove operand 2.
(sibcall_value_internal, call_value_internal): Remove operand 3.
(untyped_call): Update call to gen_call.

gcc/testsuite/
* gcc.dg/rtl/x86_64/different-structs.c: Initialize CALL_INSN_ABI_ID.
* selftests/x86_64/call-insn.rtl: Likewise.

3 days agoFortran: Wuse-without-only bogus warning for submodules [PR105594]
Paul Thomas [Wed, 3 Jun 2026 11:02:03 +0000 (12:02 +0100)] 
Fortran: Wuse-without-only bogus warning for submodules [PR105594]

2026-06-03  Steven G. Kargl  <kargl@gcc.gnu.org>

gcc/fortran
PR fortran/105594
* module.cc (gfc_use_module): Suppress bogus warning for a missing
ONLY clause on a submodule.

gcc/testsuite/
PR fortran/105594
* gfortran.dg/pr105594.f90: New test.

3 days agoa68: fix diagnostic in recover_from_error
Jose E. Marchesi [Wed, 3 Jun 2026 10:00:21 +0000 (12:00 +0200)] 
a68: fix diagnostic in recover_from_error

The recover_from_error function calls a68_phrase_to_text in order to
get a descriptive text to emit in diagnostics.  This text, however,
may contain format tags such as %< and %>, so it has to be passed to
a68_error as a format string, therwise the format tags are not
interpreted and get printed verbatim.

Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
gcc/algol68/ChangeLog

* a68-parser-bottom-up.cc (recover_from_error): Use the output of
a68_phrase_to_text as format string so format tags are honored.

3 days agoaarch64: Make Uc[ij] constraints public
Alex Coplan [Thu, 28 May 2026 11:26:02 +0000 (12:26 +0100)] 
aarch64: Make Uc[ij] constraints public

This promotes Uci and Ucj from internal to public constraints.  They are
already both documented publically in LLVM [1] and we've had a request
from kernel folks who would like to make use of Ucj for saving/restoring
ZA contents [2].

[1] : https://llvm.org/docs/LangRef.html#supported-constraint-code-list
[2] : https://lore.kernel.org/linux-arm-kernel/ahW8Eba3SNqfVDdk@J2N7QTR9R3/

gcc/ChangeLog:

* config/aarch64/constraints.md (Uci): Drop @internal, slightly tweak
doc string.
(Ucj): Likewise.
* doc/md.texi (Machine Constraints): Document Uci and Ucj under AArch64
family.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/sme/inline-asm.c: New test.

3 days agodoc: Flesh out documentation for IFN_MASK_LOAD
Alex Coplan [Fri, 15 May 2026 15:48:24 +0000 (16:48 +0100)] 
doc: Flesh out documentation for IFN_MASK_LOAD

Following the discussion here:
https://gcc.gnu.org/pipermail/gcc-patches/2026-May/716769.html
this expands the internal function documentation for IFN_MASK_LOAD to
spell out the signature of the function and explain how it relates to
the optab.

gcc/ChangeLog:

* doc/ifn.texi (Direct Internal Functions): Flesh out
documentation for IFN_MASK_LOAD.
* doc/md.texi (Standard Names): Add anchor for maskloadmn so it
can be cross-referenced.

3 days agobackprop: Avoid double deletions [PR125579]
Richard Sandiford [Wed, 3 Jun 2026 10:04:15 +0000 (11:04 +0100)] 
backprop: Avoid double deletions [PR125579]

In this PR, two values were simplified to the same phi, which in
turn was made redundant by other simplifications.  The pass then
tried to delete the phi twice.

gcc/
PR tree-optimization/125579
* gimple-ssa-backprop.cc (backprop::execute): Avoid double deletions.

gcc/testsuite/
PR tree-optimization/125579
* gcc.dg/pr125579.c: New test.

3 days agoAda: Adjust testcase after latest change
Eric Botcazou [Wed, 3 Jun 2026 09:54:25 +0000 (11:54 +0200)] 
Ada: Adjust testcase after latest change

The size clause of 32 bits requires an alignment clause of 4 for atomicity.

gcc/testsuite/
PR ada/125581
* gnat.dg/atomic9.adb (NVIC_STIR): Add alignment clause.

3 days agovect: gate COMPLEX_MUL on FP_CONTRACT_FAST [PR125431]
Tamar Christina [Wed, 3 Jun 2026 08:42:15 +0000 (09:42 +0100)] 
vect: gate COMPLEX_MUL on FP_CONTRACT_FAST [PR125431]

The checks for FP_CONTRACT_FAST were in the wrong place for complex_mul.

The location it was in would only block FMA but not MUL.  It would also not
really reject the forming of the FMA, it would just create an invalid collection
of nodes which would fail analysis later on.

However complex multiplication is also a contraction, since it's doing

real = a*c - b*d
imag = a*d + b*c

This moves the checks up to earliest possible location and actually just returns
and adds the missing check for FMS.

gcc/ChangeLog:

PR tree-optimization/125431
* tree-vect-slp-patterns.cc (complex_mul_pattern::matches,
complex_fms_pattern::matches): Gate on FP contraction.

gcc/testsuite/ChangeLog:

PR tree-optimization/125431
* gfortran.dg/vect/pr125431.f90: New test.

3 days agovect: fix prologue peeling dominator updates [PR125509]
Tamar Christina [Wed, 3 Jun 2026 08:37:32 +0000 (09:37 +0100)] 
vect: fix prologue peeling dominator updates [PR125509]

In the change to enable vectorization without needing a scalar epilogue I
disabled the dominators update for prolog peeling with the assumption that since
I don't need to go to rewire the exits when we vectorize the main loop we don't
end up with the complicated merge block for which the updates were needed.

And indeed no test failed.  But it turns out we now get a different form so the
updates are still needed.  The merge block is still a mess so determining
manually who is the new dominator of whom is still quite difficult so I couldn't
simplify the updates.

This re-enabled dominator updates after prolog peeling.

gcc/ChangeLog:

PR tree-optimization/125509
* tree-vect-loop-manip.cc (vect_do_peeling): Re-enable dominators
update for prolog peeling.

gcc/testsuite/ChangeLog:

PR tree-optimization/125509
* gcc.dg/vect/pr125509.c: New test.

3 days agotestsuite: Skip g++.dg/modules/pr120458-1 etc. on non-UCN targets
Rainer Orth [Wed, 3 Jun 2026 08:05:10 +0000 (10:05 +0200)] 
testsuite: Skip g++.dg/modules/pr120458-1 etc. on non-UCN targets

Two new tests FAIL on Solaris with the native assembler:

FAIL: g++.dg/modules/pr120458-1 -std=c++17 link
FAIL: g++.dg/modules/pr120458-1 -std=c++20 link
FAIL: g++.dg/modules/pr120458-1 -std=c++26 link
FAIL: g++.dg/modules/pr120458-2 -std=c++17 link
FAIL: g++.dg/modules/pr120458-2 -std=c++20 link
FAIL: g++.dg/modules/pr120458-2 -std=c++26 link

They don't assemble because as lacks UCN support:

Assembler: pr120458-1_a.C
        "pr120458-1_a.s", line 3 : Syntax error
        Near line: "    .globl  _ZW6영혼1fj"
[...]
Too many errors - Goodbye

Fixed by skipping the tests on non-UCN targets.

Tested on i386-pc-solaris2.11, sparc-sun-solaris2.11 (as and gas), and
x86_64-pc-linux-gnu.

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

gcc/testsuite:
* g++.dg/modules/pr120458-1_a.C: Skip on non-UCN targets.
* g++.dg/modules/pr120458-2_a.C: Likewise.

3 days agoPR modula2/125512: Candidate for spell checking missed when using qualified ident
Gaius Mulley [Wed, 3 Jun 2026 08:00:20 +0000 (09:00 +0100)] 
PR modula2/125512: Candidate for spell checking missed when using qualified ident

This bug fix checks the qualified ident processing for spell checking
candidates.

gcc/m2/ChangeLog:

PR modula2/125512
* gm2-compiler/P3Build.bnf (SubDesignator): Rewrite to
include spell checking.

gcc/testsuite/ChangeLog:

PR modula2/125512
* gm2.dg/spell/iso/fail/badmodule.mod: New test.
* gm2.dg/spell/iso/fail/badrecord.mod: New test.
* gm2.dg/spell/iso/fail/color.def: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
3 days agolibstdc++: Add (generic_)display_string and (generic_)native_encoded_string to filesy...
Tomasz Kamiński [Thu, 28 May 2026 06:37:33 +0000 (08:37 +0200)] 
libstdc++: Add (generic_)display_string and (generic_)native_encoded_string to filesystem::path

Furthermore string and generic_string method as marked as deprecated
in C++26 mode.

This implements the P2319R5 "Prevent path presentation problem" paper,
with the rename of system_encoded_string from LWG4512,
"The system_encoded_string() and generic_system_encoded_string() member
functions of std::filesystem::path are misnamed".

The wording defines the display_string and generic_display_string
in terms of call of std::format with format string "{}" and "{:g}"
respectively. This patch inlines the effects of above, by either
returning native() or generic_string<value_type>() directly
(if value_type is char), or string constructed __unicode::_Utf_view
of above (when value_type is wchar_t).

As we currently assume that char encoding is always UTF-8, the outputs
of (generic_)native_encoded string and (generic_)display_string
are equivalent. However, the former may be adjusted in future.

libstdc++-v3/ChangeLog:

* include/bits/fs_path.h (path::string, path::generic_string):
Add deprecated attribute in C++26 via _GLIBCXX26_DEPRECATED_SUGGEST.
(path::display_string, path::native_encoded_string)
(path::generic_display_string, path::generic_native_encoded_string)
[__glibcxx_format_path >= 202506L]: Define.
* include/bits/version.def (format_path): Bump to 202506.
* include/bits/version.h: Regenerate.
* testsuite/util/testsuite_fs.h (__gnu_test::compare_paths):
Ignored deprecated declarations warning.
* testsuite/27_io/filesystem/filesystem_error/cons.cc:
Disable -Wdeprecated-declarations warning with pragmas.
* testsuite/27_io/filesystem/operations/canonical.cc: Likewise.
* testsuite/27_io/filesystem/operations/copy_file.cc: Likewise.
* testsuite/27_io/filesystem/path/concat/strings.cc: Likwise.
* testsuite/27_io/filesystem/path/itr/traversal.cc: Likewise.
* testsuite/27_io/filesystem/operations/temp_directory_path.cc:
Likewise.
* testsuite/27_io/filesystem/path/decompose/root_directory.cc:
Likewise.
* testsuite/27_io/filesystem/path/generic/generic_string.cc:
Likewise.
* testsuite/27_io/print/1.cc: Likewise.
* testsuite/27_io/print/2.cc: Likewise.
* testsuite/27_io/print/3.cc: Likewise.
* testsuite/27_io/filesystem/path/append/source.cc:
Add dg-warning for deprecated functions use.
* testsuite/27_io/filesystem/path/decompose/stem.cc: Likewise.
* testsuite/27_io/filesystem/path/native/string-char8_t.cc:
Likewise.
* testsuite/27_io/filesystem/path/generic/display_native_string.cc:
New test.
* testsuite/27_io/filesystem/path/native/display_native_string.cc:
New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 days agotree-optimization/125477 - verify we can copy it before versioning an outer loop
Richard Biener [Tue, 2 Jun 2026 13:41:07 +0000 (15:41 +0200)] 
tree-optimization/125477 - verify we can copy it before versioning an outer loop

The following fixes a hole in vectorizer loop versioning which tries to
version an outer loop that the versioning condition is invariant in but
fails to verify we can actually copy it.

PR tree-optimization/125477
* tree-vect-loop-manip.cc (vect_loop_versioning): Verify we
can duplicate an outer loop before considering to version it.

* gcc.dg/torture/pr125477.c: New testcase.

3 days agotree-core: Remove ENUM_BITFIELD from tree-core.h [PR125507]
Andrew Pinski [Tue, 2 Jun 2026 20:05:06 +0000 (13:05 -0700)] 
tree-core: Remove ENUM_BITFIELD from tree-core.h [PR125507]

This removes ENUM_BITFIELD from tree-core.h. GCC has been written in C++ for
years now. So enums can be bitfields. There is no reason for the macro.
This removes the macro usage from tree-core.h. The other uses can be removed
by others.

Note gengtype needed to support for tree_code to remove the extra enum that is added
for other others.

Bootstrapped and tested on x86_64-linux-gnu.

PR middle-end/125507

gcc/ChangeLog:

* gengtype.cc (main): Add tree_code.
* tree-core.h (struct tree_base): Remove ENUM_BITFIELD.
(struct tree_type_common): Likewise.
(struct tree_decl_common): Likewise.
(struct tree_decl_with_vis): Likewise.
(struct tree_function_decl): Likewise.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
3 days agoRISC-V: Remove dead code in riscv_sched_reorder
Jin Ma [Tue, 2 Jun 2026 13:38:43 +0000 (21:38 +0800)] 
RISC-V: Remove dead code in riscv_sched_reorder

While investigating vsetvl ping-ponging cases recently, the ready
queue reordering hook riscv_sched_reorder was found to contain an
unconditional return that makes most of the body unreachable:

  if (!last_vconfig.valid || *nreadyp == 1)
    return riscv_issue_rate ();

  return riscv_issue_rate ();    /* dead, kills reordering below.  */
  int nready = *nreadyp;
  ...

The hook was introduced by commit 63632889651 ("[RISC-V] Reorder
ready queue slightly to avoid unnecessary vsetvl instructions").  It
is unclear whether the second return was intentional (e.g. left as a
temporary guard) or a leftover.  Either way, since the surrounding
code is specifically designed to group instructions with the same
vector configuration and reduce vsetvl ping-ponging, the dead return
defeats the hook's stated purpose.

Remove the dead return so the reordering can actually run.

A quick look at the resulting fallout is benign: re-enabling the
reordering changes the vsetvl emission pattern for the zve64f
testcases pr111037-1.c, pr111037-4.c and pr113248.c.  The reorder
now places vle64.v + vadd.vv (both with mode-derived SEW=64) before
vfmv.s.f (SEW=16), so the vsetvl pass emits

  vsetivli zero, 1, e64, m1
  ...
  vsetivli zero, 1, e16, m1

instead of the prior

  vsetivli zero, 1, e16, mf4
  ...
  vsetvli  zero, zero, e64, m1

Both sequences contain two vsetvl insns, so the total switching cost
is unchanged.  Updating the scan-assembler-times patterns to match
the new sequence therefore looks like a reasonable adjustment.

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_sched_reorder): Remove dead
return after the early-return guard.

gcc/testsuite/ChangeLog:

PR target/111037
PR target/113248
* gcc.target/riscv/rvv/vsetvl/pr111037-1.c: Update vsetvl
patterns to match post-reorder asm sequence.
* gcc.target/riscv/rvv/vsetvl/pr111037-4.c: Likewise.
* gcc.target/riscv/rvv/vsetvl/pr113248.c: Likewise.

4 days agobitmap: Fix comment about tree representation
Richard Sandiford [Tue, 2 Jun 2026 19:50:29 +0000 (20:50 +0100)] 
bitmap: Fix comment about tree representation

The bitmap_element comments appear to have the left and right children
the wrong way around: prev is the left (lower index) and next is the
right (higher index).

gcc/
* bitmap.h (bitmap_element): Fix left/right distinction in comments.

4 days agobackprop: Create new SSA names
Richard Sandiford [Tue, 2 Jun 2026 19:50:29 +0000 (20:50 +0100)] 
backprop: Create new SSA names

backprop currently takes the shortcut of reusing SSA names when changing
their value.  The original justification for this was that backprop only
makes changes that are acceptable to all (non-debug) users.  It seemed
pointless to go to the trouble of creating a new SSA name, substituting
into all users, creating new SSA names for dependent statements that also
change value, and so on.  Debug instructions could be dealt with using
insert_debug_temp_for_var_def, which would be needed in any case.
(This patch still uses insert_debug_temp_for_var_def.)

See:

  https://gcc.gnu.org/pipermail/gcc-patches/2015-October/431463.html
  https://gcc.gnu.org/pipermail/gcc-patches/2015-October/431468.html

for the original discussion.

However, Robin's upcoming changes to support backpropagating nonzero
bits information runs into the problem that we also need to update
or invalidate range information.  That update would spread to the
same places that an SSA rename would.  Rather than fight the system
regarding cached information, it seemed better to go with the system
by creating new SSA names.

This is more complicated compared to the status quo, but maybe not
much more so than the status quo plus a flow-sensitive info update.

The change also allows an SSA name to be replaced by any gimple
value.  That isn't often useful for the current pass, although
gcc.dg/tree-ssa/backprop-1.c gives an artificial example involving
phi nodes and gcc.dg/torture/pr116922.c gives an example in which
a division gets folded to 1.  However, allowing general replacements
should be useful for Robin's work, which otherwise has to create new
assignments and leave other passes to propagate them away.

Hopefully the comments in the patch explain the approach.

gcc/
* gimple-ssa-backprop.cc: Update the comment at head of the file.
(var_info::new_value, var_info::seq): New member variables.
(var_info::var_info): Initialize them.
(remove_unused_var): Replace with...
(remove_dead_stmt): ...this new function.
(note_replacement): Delete.
(backprop::prepare_change): Likewise.
(backprop::complete_change): Likewise.
(backprop::set_new_value): New function.
(backprop::subst_operand): Likewise.
(backprop::finish_stmt): Likewise.
(backprop::optimize_builtin_call): Replace the lhs and info parameters
with a var_info parameter.  Create a new statement rather than
changing the existing one.
(backprop::optimize_assign): Likewise.
(backprop::optimize_phi): Likewise.
(backprop::replace_assign_rhs): Likewise, but replace gassign and lhs
parameters.
(backprop::propagate_change): New function.
(backprop::commit_replacement): Likewise.
(backprop::execute): Update phase 3 for the above changes.  Do not
alter the original statements during phase 3.  If one SSA name
is scheduled to be replaced, also require all its users in m_vars
to be replaced.  Add a new phase that performs the scheduled
replacements.

gcc/testsuite/
* gcc.dg/tree-ssa/backprop-7.c: New test.

4 days agobackprop: Use a double worklist when propagating usage info
Richard Sandiford [Tue, 2 Jun 2026 19:50:28 +0000 (20:50 +0100)] 
backprop: Use a double worklist when propagating usage info

backprop does a post-order walk over SSA name definitions, recording
information about all uses.  It makes optimistic assumptions about
backedge uses (i.e. uses that occur later in the post order),
then it iterates until a fixed point is reached.

Since the pass currently keeps single-bit information, this fixed point
should be reached after at most two passes: the initial walk and
(if necessary) a "fix-up" walk.

However, Robin's patch will add cases where more iterations might
be needed.  This patch prepares for that by switching to a double-
worklist algorithm.  Each pass through the worklist follows post order,
so that non-backedge uses are processed before definitions.  Definitions
that occur later in the post order are added to the current worklist
and definitions that occur earlier are added to the next worklist.

To make this easier, the patch switches the worklist bitmaps from using
SSA_NAME_VERSION to using m_vars indices (which in any case should be
slightly denser).  Since m_vars also follows post order, we can use
bitmap_clear_first_bit to pop from the worklist and so don't need a
separate vector.

gcc/
* gimple-ssa-backprop.cc: Remove the claim at the head of the file
that we only need to revisit a statement once.
(backprop::m_worklist, backprop::m_worklist_names): Delete.
(backprop::m_worklist1): New member variable.
(backprop::m_worklist2, backprop::m_this_worklist): Likewise.
(backprop::m_next_worklist, backprop::m_worklist_threshold): Likewise.
(backprop::backprop): Update accordingly.
(backprop::~backprop): Likewise.
(backprop::push_to_worklist): Switch to using bitmap worklists that
use m_vars indices instead of SSA_NAME_VERSIONs.  Decide which
worklist should be used based on m_worklist_threshold.
(backprop::pop_from_worklist): Pop the first bit from m_this_worklist.
Set m_worklist_threshold.
(backprop::execute): Use a double-worklist update in which each
iteration makes a post order walk.

4 days agobackprop: Rework SSA-name-to-info mapping
Richard Sandiford [Tue, 2 Jun 2026 19:50:28 +0000 (20:50 +0100)] 
backprop: Rework SSA-name-to-info mapping

backprop currently has:

- a usage_info structure that records information about all uses
- a pool of usage_infos for allocating longer-term instances
- a hash map from SSA names to usage_info pointers
- a post-order list of {SSA name, usage_info pointer} pairs

Thus the representation of an SSA-name-to-info mapping uses one copy
of the usage_info but two copies of the SSA name, one in the hash map
and one in the list.

The pass iterates from an optimistic assumption "down" to reality,
so it sometimes finds that an SSA name no longer has useful information.
When that happens, the pass removes the entry from the hash map but not
from the list.

This was simple and was relatively convenient for the current approach.
However, for later patches, it would be better to have a single object
that holds all information about an SSA name, so that both the mapping
and the list see updates to it.  This patch therefore switches to:

- a var_info structure that records all information about an SSA name
- a pool of var_infos for allocation purposes
- a hash table of var_info pointers
- a post-order list of var_info pointers

The var_info contains the index of its entry in the list.  It's then
possible to remove redundant var_infos from both the hash table and
the list (by nullifying in the latter case).

This doesn't necessarily make much sense on its own.  It's just
easier to follow later patches if this change is split out.

The comment at the head of the file needs to be updated after this,
but it seemed better to leave that till the final patch, when all
other changes have been made.

gcc/
* gimple-ssa-backprop.cc (var_info): New structure.
(var_info_hasher): Likewise.
(backprop::m_info_pool): Replace with...
(backprop::m_var_pool): ...this new member variable.
(backprop::m_info_map): Replace with...
(backprop::m_var_table): ...this new member variable.
(backprop::m_worklist): Store var_info pointers instead of SSA names.
(backprop::backprop): Update accordingly.
(backprop::~backprop): Likewise.
(backprop::lookup_operand): Return a var_info pointer instead of
a usage_info pointer.
(backprop::push_to_worklist): Take a var_info pointer instead
of an SSA name.
(backprop::pop_from_worklist): Return a var_info pointer instead
of an SSA name.
(backprop::process_builtin_call_use): Update calls accordingly.
(backprop::process_assign_use): Likewise.
(backprop::process_phi_use): Likewise.
(backprop::reprocess_inputs): Likewise.
(backprop::process_var): Take a pointer to the var_info entry
as a second parameter.  Update for the above data structure changes.
(backprop::process_block): Update calls to process_var.
(backprop::execute): Likewise.  Update for the above data structure
changes.

4 days agobackprop: Move opt-out for abnormal edges
Richard Sandiford [Tue, 2 Jun 2026 19:50:27 +0000 (20:50 +0100)] 
backprop: Move opt-out for abnormal edges

r6-6843-ga864ad5ba2501d made sure that optimize_phi wouldn't
optimise phi inputs for abnormal edges.  See:

  https://gcc.gnu.org/pipermail/gcc-patches/2016-February/441902.html

for a description of the symptoms.

That was the best place to put the check at the time, and still is
as things stand.  However, a later patch will rename all statements
that might change value, with no opt-out possible once the process
has started.  If a phi input's value has changed, then it must be
replaced no matter what.

This patch therefore moves the check to the analysis phase.

gcc/
* gimple-ssa-backprop.cc (backprop::process_var): Don't try to
optimize SSA names that occur as a phi input for an abnormal edge,
moving the restriction from...
(backprop::optimize_phi): ...here.

4 days agoRelax gsi_replace requirement
Richard Sandiford [Tue, 2 Jun 2026 19:50:27 +0000 (20:50 +0100)] 
Relax gsi_replace requirement

gsi_replace requires the new statement to have the same lhs as
the old one, if both statements have lhses.  This requirement was
added by r0-96285-g0ca5af51abe63d as part of the DEBUG_EXPR_DECL
work.  And it makes sense in that context.  If gsi_replace nixes
the definition of an SSA name that is still referenced by debug
statements then things are going to go wrong.

But if that's the "only" reason, we should be able to relax the
condition to say that, if the new statement has a different lhs,
the caller must ensure that it has updated all debug uses before
calling gsi_replace.

The patch adds a completely_unused helper to test that.  The helper
has a sharp edge and is not widely useful, so I've kept it local
to gimple-iterators.cc for now.

It's arguable that the old code was too forgiving with its
!gimple_has_lhs (stmt) escape hatch.  A tighter condition would be
the one tested by:

  tree old_lhs = gimple_get_lhs (orig_stmt);
  return (!old_lhs
          || gimple_get_lhs (stmt) == old_lhs
  || completely_unused (old_lhs));

gcc/
* gimple-iterator.cc (completely_unused): New function.
(gsi_replace): Allow changes in lhs if the caller has updated
all uses of the old name, including all debug uses.
* gimple-fold.cc (gsi_replace_with_seq_vops): Likewise.

4 days agobitmap: Add bitmap_clear_last_set_bit
Richard Sandiford [Tue, 2 Jun 2026 19:50:27 +0000 (20:50 +0100)] 
bitmap: Add bitmap_clear_last_set_bit

This patch adds a bitmap_clear_last_set_bit routine, following the
precedent and implementation approach of bitmap_clear_first_set_bit.

gcc/
* bitmap.h: Document the complexity of pop_largest aka
bitmap_clear_last_set_bit.
(bitmap_clear_last_set_bit): Declare.
* bitmap.cc (bitmap_last_set_bit_worker): New function,
split out from...
(bitmap_last_set_bit): ...here.
(bitmap_clear_last_set_bit): New function.

4 days agoRevert "pru: Transform patterns to use hard register constraints"
Dimitar Dimitrov [Tue, 2 Jun 2026 18:19:11 +0000 (21:19 +0300)] 
Revert "pru: Transform patterns to use hard register constraints"

This reverts commit r17-684-gfed7299b89f62b.

The "%" modifier does not work for hard-reg constraints.
See https://gcc.gnu.org/pipermail/gcc-patches/2026-May/718682.html

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
4 days agofortran: also link -lpthread when -fcoarray=shared is used [PR125324]
Jerry DeLisle [Wed, 27 May 2026 16:24:26 +0000 (09:24 -0700)] 
fortran: also link -lpthread when -fcoarray=shared is used [PR125324]

When the driver auto-links -lcaf_shmem for -fcoarray=shared it must also
link -lpthread because the shmem CAF runtime uses POSIX threads internally.

Assisted by: Claude Sonnet 4.6

PR fortran/125324

gcc/fortran/ChangeLog:

* gfortranspec.cc (lang_specific_driver): Also append -lpthread
when need_caf_shmem is set.

(cherry picked from commit 8e2b89e87d195409ba1690e2f732431dc4b7305e)

4 days agolibstdc++: constexpr priority_queue
Yuao Ma [Tue, 2 Jun 2026 15:18:26 +0000 (23:18 +0800)] 
libstdc++: constexpr priority_queue

This patch makes priority_queue constexpr as part of P3372R3.

libstdc++-v3/ChangeLog:

* include/bits/stl_queue.h: Add constexpr.
* testsuite/23_containers/priority_queue/constexpr.cc: New test.

4 days agoa68: improve diagnostics for malformed modes
Jose E. Marchesi [Tue, 2 Jun 2026 16:20:33 +0000 (18:20 +0200)] 
a68: improve diagnostics for malformed modes

An Algol 68 mode can be non well formed for two reasons:

- When the mode denotes values that are infinite in size.
- When the mode is strongly coercible to itself.

The yin-yang algorithm implemented by is_well_formed is currently
just reporting a boolean indicating whether the given mode is well
formed.

This patch changes is_well_formed so it returns also the reason for
the particular mode to not be ok: missing a yin means an infinite
mode, whereas missing a yang means the mode is strongly coercible to
itself.

This allows to improve diagnostics, guiding the user on why the mode
is not well formed.

Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
gcc/algol68/ChangeLog

* a68-parser-modes.cc (WELL): Define.
(NO_YIN): Likewise.
(NO_YANG): Likewise.
(UNWELL): Likewise.
(is_well_formed): Discriminate reason for the given mode to not be
well formed.
(a68_make_moid_list): Emit note explaining why a mode is not well
formed.

gcc/testsuite/ChangeLog

* algol68/compile/malformed-mode-1.a68: New test.
* algol68/compile/malformed-mode-2.a68: Likewise.

4 days agolibgomp: Don't use alloca directly
Rainer Orth [Tue, 2 Jun 2026 15:05:31 +0000 (17:05 +0200)] 
libgomp: Don't use alloca directly

This patch

commit a36f0edbec6f2ef36792eda245fa7e512d032872
Author: Arsen Arsenović <aarsenovic@baylibre.com>
Date:   Thu Apr 23 10:47:38 2026 +0000

    libgomp: let plugins handle allocating the target variable table

broke Solaris bootstrap:

In file included from libgomp/oacc-parallel.c:30:
libgomp/oacc-parallel.c: In function ‘GOACC_parallel_keyed’:
libgomp/oacc-parallel.c:297:45: error: implicit declaration of function ‘alloca’ [-Wimplicit-function-declaration]
  297 |        : gomp_offload_session_new (acc_dev, alloca));
      |                                             ^~~~~~
libgomp/libgomp.h:1510:21: note: in definition of macro ‘gomp_offload_session_new’
 1510 |     void *session = alloc (devicep->session.size);      \
      |                     ^~~~~
libgomp/oacc-parallel.c:297:45: error: incompatible implicit declaration of built-in function ‘alloca’ [-Werror=builtin-declaration-mismatch]
libgomp/libgomp.h:1510:21: note: in definition of macro ‘gomp_offload_session_new’
 1510 |     void *session = alloc (devicep->session.size);      \
      |                     ^~~~~

and similarly in target.c.

alloca is declared in <alloca.h> on Solaris.  Therefore the code should
use gomp_alloca instead, which is just for such cases.

Bootstrapped without regressions on i386-pc-solaris2.11,
sparc-sun-solaris2.11, and x86_64-pc-linux-gnu.

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

libgomp:
* oacc-parallel.c (GOACC_parallel_keyed): Use gomp_alloca instead
of alloca.
* target.c (GOMP_target): Likewise.
(GOMP_target_ext): Likewise.

4 days agolibstdc++: Expand supported operations for __rand_uint128.
Tomasz Kamiński [Thu, 15 Jan 2026 13:45:53 +0000 (14:45 +0100)] 
libstdc++: Expand supported operations for __rand_uint128.

This patch adds following operations to __rand_uint128:
* explicit operator bool
* operator- with __rand_uint128
* operator* with uint64_t for _M_hi != 0
* operator/ with uint64_t
The division is currently stubbed by converting to __rand_uint128.

When __rand_uint128 is used, the platform does not provide native 128bit
integer types, thus random number generators will return at most 64bit
integer. In consequence, __generate_cannonical_any will use these
overloads when multiplying by result of generator invocation.

libstdc++-v3/ChangeLog:

* include/bits/random.h (__rand_uint128::operator bool):
(__rand_uint128::operator-=(const type& __r))
(__rand_uint128::operator-(type __l, const type& __r)):
Implement.
(__rand_uint128::operator/=(uint64_t __r))
(__rand_uint128::operator/(type __l, uint64_t __r)):
Define by converting to type.
(__rand_uint128::operator*=(const type& __r)): Remove
precondition and handle _M_hi != 0.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 days agolibstdc++: Fix comment typo in version.tpl
Jonathan Wakely [Tue, 2 Jun 2026 14:38:05 +0000 (15:38 +0100)] 
libstdc++: Fix comment typo in version.tpl

This typo was fixed by r17-1036-gb1263bca56ea82 but only in the
generated version.h header. This fixes the template that it's generated
from.

libstdc++-v3/ChangeLog:

* include/bits/version.tpl: Fix typo.

4 days agoRevert "x86: fix under-aligned indirect AVX argument/return stack slots on win64...
Jonathan Yong [Tue, 2 Jun 2026 13:55:18 +0000 (13:55 +0000)] 
Revert "x86: fix under-aligned indirect AVX argument/return stack slots on win64 [PR54412]"

This reverts commit 77b2eaf09c77bf2dddcb8c35ee8bc9cc99e2f93c.
Revert due to regressions on ARM:

  | regressions.sum:
  | Running gcc:gcc.target/aarch64/sve/pcs/aarch64-sve-pcs.exp ...
  | FAIL: gcc.target/aarch64/sve/pcs/struct_3_128.c -march=armv8.2-a+sve -fno-stack-protector  check-function-bodies test_pst_uniform4
  | FAIL: gcc.target/aarch64/sve/pcs/struct_3_256.c -march=armv8.2-a+sve -fno-stack-protector  check-function-bodies test_pst_uniform4
  | FAIL: gcc.target/aarch64/sve/pcs/struct_3_512.c -march=armv8.2-a+sve -fno-stack-protector  check-function-bodies test_pst_uniform4

gcc/ChangeLog:

PR target/54412
gcc/calls.cc: Revert.
gcc/config/i386/i386.cc: Ditto.
gcc/doc/tm.texi: Ditto.
gcc/doc/tm.texi.in: Ditto.
gcc/function.cc: Ditto.
gcc/target.def: Ditto.

Signed-off-by: Jonathan Yong <10walls@gmail.com>
4 days agotree-optimization/125545 - reassoc insering after asm goto
Richard Biener [Tue, 2 Jun 2026 12:56:12 +0000 (14:56 +0200)] 
tree-optimization/125545 - reassoc insering after asm goto

There's one case we can handle just fine which is when the asm goto
has a single successor (it's fallthru edge, possibly shared with
an asm goto label).  As we're using dominance based insertion
point discovery we have to handle this case.

PR tree-optimization/125545
* tree-ssa-reassoc.cc (insert_stmt_after): Allow asm goto
with a single successor.

* gcc.dg/torture/pr125545.c: New testcase.

4 days ago[PATCH 1/8] RISC-V: Add zvfofp8min ISA extension support
Lino Hsing-Yu Peng [Tue, 2 Jun 2026 13:37:22 +0000 (07:37 -0600)] 
[PATCH 1/8] RISC-V: Add zvfofp8min ISA extension support

Add initial ISA-level for Zvfofp8min extension.

gcc/ChangeLog:

* common/config/riscv/riscv-common.cc: Add zvfofp8min support.
* config/riscv/riscv-ext.def: Add zvfofp8min entry.
* config/riscv/riscv-ext.opt: Add zvfofp8min option.
* config/riscv/riscv-vector-builtins.cc: Require zvfofp8min.
* config/riscv/riscv-vector-builtins.h: Add zvfofp8min handling.
* doc/riscv-ext.texi: Document the new extension.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/arch-61.c: New test.

4 days agotree-optimization/125553 - ICE with VN trick
Richard Biener [Tue, 2 Jun 2026 12:03:24 +0000 (14:03 +0200)] 
tree-optimization/125553 - ICE with VN trick

The following avoids re-doing an earlier CSE when trying to handle
a BIT_FIELD_REF as memory reference by combining it with a
defining load.  This might (as in this case) result in double-insertion
to the VN hashtables which rightfully ICEs.

PR tree-optimization/125553
* tree-ssa-sccvn.cc (visit_nary_op): Valueize the BIT_FIELD_REF
operand before looking at its definition.

* gcc.dg/torture/pr125553.c: New testcase.

4 days ago[PATCH] RISC-V: Add tuning info and vector cost model for xt-c9501fdvt
Wang Yaduo [Tue, 2 Jun 2026 13:12:54 +0000 (07:12 -0600)] 
[PATCH] RISC-V: Add tuning info and vector cost model for xt-c9501fdvt

Switch the xt-c9501fdvt RISCV_TUNE entry from generic_ooo_tune_info
to a new xt_c9501_tune_info, with its own scalar tuning parameters
and a dedicated cpu_vector_cost table (xt_c9501_vector_cost) covering
VLS / VLA per-type statement, load/store and reduction costs.

gcc/ChangeLog:

* config/riscv/riscv-cores.def: Switch xt-c9501fdvt tune to
xt_c9501_tune_info.
* config/riscv/riscv.cc (xt_c9501_vls_vector_cost): New.
(xt_c9501_vla_vector_cost): New.
(xt_c9501_vector_cost): New.
(xt_c9501_tune_info): New.

gcc/testsuite/ChangeLog:

* gcc.dg/vect/costmodel/riscv/rvv/xt-c9501fdvt-vect-stmt-cost.c:
New test.
* gcc.dg/vect/costmodel/riscv/rvv/xt-c9501fdvt-vect-ldst-cost.c:
New test.
* gcc.dg/vect/costmodel/riscv/rvv/xt-c9501fdvt-reduc-unordered.c:
New test.
* gcc.dg/vect/costmodel/riscv/rvv/xt-c9501fdvt-reduc-ordered.c:
New test.

4 days ago[PATCH] RISC-V: Fix missing return in expand_vec_perm
Jin Ma [Tue, 2 Jun 2026 13:07:00 +0000 (07:07 -0600)] 
[PATCH] RISC-V: Fix missing return in expand_vec_perm

In expand_vec_perm, the branch handling a selector that is a constant
duplicate (all indices identical) emits a VLMAX vrgather and is then
meant to be done.  The missing return let control fall through into the
generic modulo-index handling below, which recomputes and overwrites
the target with another gather sequence.

Add the return so the duplicate path stops after the gather.

No test case is added: without the return the first gather is a dead
store to the target that the generic path immediately overwrites, so it
is removed by later RTL dead-store elimination and the final assembly is
identical with and without the fix.  No test can therefore observe the
change.

gcc/ChangeLog:

* config/riscv/riscv-v.cc (expand_vec_perm): Add missing return
after emit_vlmax_gather_insn.

4 days agotree-optimization/125250 - UB in testcase
Richard Biener [Tue, 2 Jun 2026 12:44:33 +0000 (14:44 +0200)] 
tree-optimization/125250 - UB in testcase

The following avoids accessing a short as _Bool.

PR tree-optimization/125250
* gcc.dg/torture/pr125250.c: Declare g0 as _Bool.

4 days agotree-optimization/125502 - vector load decomposition issue
Richard Biener [Tue, 2 Jun 2026 10:06:23 +0000 (12:06 +0200)] 
tree-optimization/125502 - vector load decomposition issue

When forwprop decomposes a vector load based on BIT_FIELD_REF
uses we have to avoid moving defs of abnormals.

PR tree-optimization/125502
* tree-ssa-forwprop.cc (optimize_vector_load): Do not
move defs of abnormals.

* gcc.dg/torture/pr125502.c: New testcase.

4 days agoPR modula2/125544: ISO reallocate does not call allocate if the address is NIL
Gaius Mulley [Tue, 2 Jun 2026 11:14:51 +0000 (12:14 +0100)] 
PR modula2/125544: ISO reallocate does not call allocate if the address is NIL

This bugfix is for the ISO Storage.REALLOCATE procedure which is a GNU
extension.  It should behave in the same way as the PIM version by
first checking whether the pointer parameter is NIL and then calling
ALLOCATE.

gcc/m2/ChangeLog:

PR modula2/125544
* gm2-libs-iso/Storage.def (REALLOCATE): Updated comment
describing new behavior.
* gm2-libs-iso/Storage.mod (REALLOCATE): Check addr
and call ALLOCATE if NIL else call lowerReallocate.
(lowerReallocate): New procedure.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
4 days agoi386: Rename crotate attribute to inv_rotate
Uros Bizjak [Tue, 2 Jun 2026 09:03:32 +0000 (11:03 +0200)] 
i386: Rename crotate attribute to inv_rotate

The crotate code attribute maps a rotation operation to its
inverse direction (rotate <-> rotatert). Since "counter rotate"
does not accurately describe this relationship, rename the
attribute to inv_rotate.

No functional change intended.

gcc/
* config/i386/i386.md (crotate): Rename to inv_rotate.
Update all uses accordingly.

4 days agoc-family: Prevent optimize attribute from undoing target attribute
Christopher Bazley [Wed, 29 Apr 2026 12:33:05 +0000 (12:33 +0000)] 
c-family: Prevent optimize attribute from undoing target attribute

This patch fixes a bug reported as PR c/125327.

Previously, function attributes such as
__attribute__ ((target ("vsx"), optimize("O2"))) could
be applied wrongly because correct processing of the
optimize attribute relied on at least one of the following to
be true:

1. The function had no function-specific target options, or
2. changing optimization options did not have the side-effect
   of modifying target options, or
3. the target option modified as a side-effect of changing
   optimization options was not saved in the cl_target_option
   struct.

Assumptions 2 and 3 are not generally guaranteed to be true.
The implementation of the handle_optimize_attribute function
already implicitly acknowledged that by rebuilding the target
options after parsing optimization options, and replacing the
current target option node if that rebuilding resulted in
a fresh target option node. However, any target options
already associated with the function being modified were not
applied before parsing optimization options, therefore they
were lost if that function's target option node was replaced.
Moreover, the decision about whether to replace any existing
target option node was flawed because it was based on a
comparison with a fake node built from ambient global state
instead of a comparison with the current target node.

Assumption 3 is true for i386 because the i386 definition of
munroll-only-small-loops does not have the "Save" tag,
therefore its value cannot differ from the ambient global state
and the target node of the function was not replaced.
The rs6000 and s390 definitions of munroll-only-small-loops
(which is likewise implicitly enabled at -O2 and above)
*do* have the "Save" tag but the 'target' attribute is not
supported on s390, therefore the bug can only be reproduced
on rs6000.

For the bug to manifest, the target option node needed to be
replaced. For rs6000, that could happen if the newly-saved
value of munroll-only-small-loops differed from the ambient
global state (which was wrongly used as the baseline for the
comparison) even if the newly-saved value did not differ from
the value previously saved in the target option node of the
function whose 'optimize' attribute was being applied.

gcc/c-family/ChangeLog:

* c-attribs.cc (handle_optimize_attribute):
Save the global target options before modifying
them. If the function with the optimize attribute
already has a target option node then restore those
target options as the global options, so that they
are used as the basis for any new optimization and
target options attached to the function.

gcc/d/ChangeLog:

* d-attribs.cc (d_handle_optimize_attribute):
Save the global target options before modifying
them. If the function with the optimize attribute
already has a target option node then restore those
target options as the global options, so that they
are used as the basis for any new optimization and
target options attached to the function.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr125327.c: New test.

4 days agoada: Reject misalignment of objects with address clause
Eric Botcazou [Thu, 30 Apr 2026 11:08:17 +0000 (13:08 +0200)] 
ada: Reject misalignment of objects with address clause

Misaligned objects are meant to be rejected universally by the compiler.

gcc/ada/ChangeLog:

* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Variable>: Validate
a known alignment on the object even if there is an address clause.

4 days agoada: Avoid definition of unused label for LOOP_STMT
Marc Poulhiès [Thu, 9 Apr 2026 10:28:23 +0000 (12:28 +0200)] 
ada: Avoid definition of unused label for LOOP_STMT

The gimplification of LOOP_STMT has a systematic end label definition,
that may be unused. For example, an endless loop maybe gimplified to:

      <D.5765>:
      # USE = anything
      # CLB = anything
      totoD.5747 ();
      goto <D.5765>;
      <D.5749>:

Later, the gimple_seq_may_fallthru() will decide that this block can
fallthru as the last statement is a single label that may be jumped to
from somewhere else.

Only defining this label if we also emit jumps to it helps the compiler
correctly decide if the block can fallthru or not.

In particular, if a function, with a local object needing finalization
and the No_Return aspect, is an endless loop then the spurious warning
that the function is still returning is not emitted anymore.

gcc/ada/ChangeLog:

* gcc-interface/trans.cc (gnat_to_gnu) <N_Exit_Statement>: Mark
the label tree as used.
(gnat_gimplify_stmt) <LOOP_STMT>: Do not emit end label
definition in unused.

4 days agoada: Add warning for too large return object in extended return statement
Eric Botcazou [Mon, 6 Apr 2026 11:00:50 +0000 (13:00 +0200)] 
ada: Add warning for too large return object in extended return statement

The return object may be allocated directly on the return or secondary stack
by the front-end, in other words be the renaming of an allocator.

gcc/ada/ChangeLog:

* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Variable>: Do not
give the warning about too large a size here but...
* gcc-interface/utils2.cc (build_allocator): ...here instead.

4 days agoada: Skip layout derivation for C-compatible unchecked union types
Eric Botcazou [Wed, 4 Mar 2026 13:27:06 +0000 (14:27 +0100)] 
ada: Skip layout derivation for C-compatible unchecked union types

The machinery that computes the layout of derived types does not support
C-compatible unchecked union types, but their layout is fixed in any case.

gcc/ada/ChangeLog:

* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Record_Type>: Do not
derive the layout of C-compatible unchecked union types.

4 days agoada: Plug loophole in layout derivation machinery
Eric Botcazou [Tue, 3 Mar 2026 22:03:18 +0000 (23:03 +0100)] 
ada: Plug loophole in layout derivation machinery

The machinery that computes the layout of derived types does not deal with
the variant part of unchecked union types that also contain a fixed part,
because this variant part is represented by a (mere) union type instead of
a qualified union type.

gcc/ada/ChangeLog:

* gcc-interface/decl.cc (components_to_record): Tweak comment.
(build_position_list): Deal with unchecked union types.
(build_variant_list): Likewise.
(get_variant_part): Likewise.
(create_variant_part_from): Likewise.
(copy_and_substitute_in_layout): Likewise.

4 days agoada: Adjust translation of non-stored discriminants of tagged subtypes
Eric Botcazou [Mon, 9 Feb 2026 11:23:17 +0000 (12:23 +0100)] 
ada: Adjust translation of non-stored discriminants of tagged subtypes

This changes the translation of non-stored discriminants of tagged subtypes
from the (stored) discriminants of the ultimate ancestor to the (non-stored)
discriminants of the tagged type, for the sake of tagged extensions.

This also contains a code layout tweak to gnat_to_gnu_entity and a minor
improvement to gnat_to_gnu.

gcc/ada/ChangeLog:

* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Record_Subtype>: Do
not repeat conditions in chained tests.
(copy_and_substitute_in_layout): For a tagged subtype, inherit the
non-stored dicriminants from the old type explicitely.
* gcc-interface/trans.cc (gnat_to_gnu): Exclude more contexts for
the transformation of boolean rvalues.

4 days agoada: Adjust RESULT_DECL of functions after updating their profile if needed
Eric Botcazou [Mon, 9 Feb 2026 08:40:18 +0000 (09:40 +0100)] 
ada: Adjust RESULT_DECL of functions after updating their profile if needed

Adjusting the RESULT_DECL of functions is necessary before handing them over
to the middle-end when they return by invisible reference and are defined in
the current translation unit, so that's done in Subprogram_Body_to_gnu.

That's also needed when the functions are generated by the middle-end, like
GNU thunks.  But, in this case, the transformation can only be applied when
the full view of the type is available, which is not guaranteed by the time
maybe_make_gnu_thunk is invoked, so the transformation needs to be delayed
and applied by update_profile when the full view is eventually encountered.

gcc/ada/ChangeLog:

PR ada/89609
* gcc-interface/gigi.h (adjust_result_decl_for_invisible_reference):
New inline function.
* gcc-interface/decl.cc (update_profile): Adjust the RESULT_DECL of
the function if it returns by invisible reference.
* gcc-interface/trans.cc (Subprogram_Body_to_gnu): Replace manual
adjustment by a call to adjust_result_decl_for_invisible_reference.
(maybe_make_gnu_thunk): Likewise.
* gcc-interface/targtyps.cc: Include stor-layout.h header file.

4 days agoada: Fix Scalar_Storage_Order not honored for misaligned wrapped scalar
Eric Botcazou [Fri, 23 Jan 2026 08:28:38 +0000 (09:28 +0100)] 
ada: Fix Scalar_Storage_Order not honored for misaligned wrapped scalar

This occurs when the construct is totally scalarized by the SRA pass.

gcc/ada/ChangeLog:

* gcc-interface/utils.cc (maybe_pad_type): Propagate the flag
TYPE_REVERSE_STORAGE_ORDER from the inner type to the record type
if the former is also an aggregate type.

4 days agoada: Do not generate accessibility checks for specific synthesized return
Eric Botcazou [Sat, 2 May 2026 07:13:20 +0000 (09:13 +0200)] 
ada: Do not generate accessibility checks for specific synthesized return

This is the return synthesized in a function whose body has been wrapped in
a nested _Wrapped_Statements function, since it only propagates the result.

gcc/ada/ChangeLog:

* accessibility.adb (Apply_Accessibility_Check_For_Return): Bail out
for the return synthesized in a function with _Wrapped_Statements.

4 days agoada: Update gnat-llvm debugging documentation for nested functions
Tom Tromey [Thu, 23 Apr 2026 18:26:47 +0000 (12:26 -0600)] 
ada: Update gnat-llvm debugging documentation for nested functions

We recently changed gdb so that it can directly handle gnat-style
unnesting.  This fixes an issue with debugging nested functions with
gnat-llvm.

gcc/ada/ChangeLog:

* doc/gnat_ugn/building_executable_programs_with_gnat.rst
(GNATLLVM): Remove note about nested functions.
* gnat_ugn.texi: Regenerate.

4 days agoada: Adjust expansion disabling for ghost expression functions
Marc Poulhiès [Mon, 27 Apr 2026 08:22:01 +0000 (10:22 +0200)] 
ada: Adjust expansion disabling for ghost expression functions

When analyzing a Ghost expression function, expansion was disabled,
which was an issue when some entities needed to be frozen (which is
often the case as expression function are often the first freezing point
of entities).

The previous change:

 "Warn on unmodified parameters of expression functions"

now triggers the disabling of the expander because it marks the body of
expression function as "coming from source".

This change adjust the disabling condition by excluding body coming from
expression function.

gcc/ada/ChangeLog:

* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Do not disable
expander if body comes from an expression function.

4 days agoada: Remove unnecessary workaround
Viljar Indus [Thu, 16 Apr 2026 11:02:30 +0000 (14:02 +0300)] 
ada: Remove unnecessary workaround

Technically this is no longer necessary as everything will be
removed along with the ignored ghost code removal.

gcc/ada/ChangeLog:

* sem_prag.adb (Analyze_Pragma): Remove overflow supression
workaround.

4 days agoada: Remove implicit WITHs from ignored ghost regions
Viljar Indus [Fri, 10 Apr 2026 10:04:25 +0000 (13:04 +0300)] 
ada: Remove implicit WITHs from ignored ghost regions

Create implicit withs with the same ghost policy as the region
they originate from.

Ensure that the list of Implicit_Withs is consistent after
ignored ghost nodes have been replaced with Null_Statements.

Omit the No_Dependence on ignored implicit WITHs

gcc/ada/ChangeLog:

* rtsfind.adb (Maybe_Add_With): Ensure conistent Implicit_With nodes
traversal after ignored ghost nodes have been removed.
Omit checks on ignored WITH clauses.

4 days agoada: Minor comment fixes
Eric Botcazou [Sun, 26 Apr 2026 22:21:56 +0000 (00:21 +0200)] 
ada: Minor comment fixes

gcc/ada/ChangeLog:

* krunch.ads: Fix a few typos in the description.

4 days agoada: Fix crash on allocator of class-wide interface as actual in subprogram call
Eric Botcazou [Wed, 22 Apr 2026 11:54:17 +0000 (13:54 +0200)] 
ada: Fix crash on allocator of class-wide interface as actual in subprogram call

The crash occurs because the type of the allocator lacks the Master_Id to be
passed to the function initializing the allocator, which is required because
the interface is limited and therefore may be the progenitor of a type that
contains tasks.

It comes from a couple of problems: 1) the special conversion trick used in
Resolve_Actuals to force the displacement of the pointer, which blocks the
proper resolution of the allocator (its E_Allocator_Type is not replaced),
and 2) the lack of Master_Id on the E_Access_Subtype created for the subtype
of the parameter in the subprogram call, which is the not null variant of a
named access type.

The former problem is solved by resolving the allocator explicitly, while
the latter is solved by changing Master_Id to live on root types only (in
accordance with RM 9.3(2), which says that it should designate the master
construct that elaborates the ultimate ancestor of a given access type).

The change contains a couple of additional fixes: 3) the proper resolution
of the allocator causes missing accessibility checks to be generated, which
in turn generates a fair amount of useless access checks and 4) an incorrect
transient scope would be created around the allocator when the type of the
parameter is named, while it's only needed for an anonymous access type.

gcc/ada/ChangeLog:

* gen_il-gen-gen_entities.adb (Access_Kind): Add Root_Type_Only for
the Master_Id field.
* einfo.ads (Master_Id): Document that it lives on root types only.
* accessibility.adb (Apply_Accessibility_Check_For_Allocator): Avoid
generating secondary useless checks.
* exp_ch3.adb (Build_Initialization_Call): Use the Master_Id of the
type of target reference directly.
(Build_Master): Minor tweak.
(Expand_N_Full_Type_Declaration): Do not call Build_Master for a
derived access type declaration.
* exp_ch4.adb (Expand_N_Allocator): Test Master_Id directly on the
access type.
* sem_res.adb (Resolve_Actuals): In the case of an allocator, if the
designated type is a CW interface, call Convert_To_And_Rewrite to
add the special conversion but nevertheless resolve the allocator to
the type of the formal afterward; do not establish a transient scope
if the type is a named access type.

4 days agoada: Simplify host and target suffix queries
Piotr Trojanek [Thu, 16 Apr 2026 10:01:33 +0000 (12:01 +0200)] 
ada: Simplify host and target suffix queries

Code cleanup for host and target suffixes, which are stored in C runtime code.

gcc/ada/ChangeLog:

* libgnat/s-os_lib.adb (Get_Debuggable_Suffix, Get_Executable_Suffix,
Get_Object_Suffix, Get_Target_Debuggable_Suffix,
Get_Target_Executable_Suffix, Get_Target_Object_Suffix): Access strings
like we do in Gnatlink.
* adaint.c (__gnat_object_suffix, __gnat_executable_suffix,
__gnat_debuggable_suffix): Now constants, just like the ones for target
suffixes.

4 days agoada: Fix Expression_Copy field documentation
Marc Poulhiès [Mon, 20 Apr 2026 11:31:22 +0000 (13:31 +0200)] 
ada: Fix Expression_Copy field documentation

The field has been added to N_Aspect_Specification nodes in
 "Implement Aspects as fields under nodes"
 commited in late 2023.

gcc/ada/ChangeLog:

* sinfo.ads <Expression_Copy>: Mention it is present in
N_Aspect_Specification nodes.
<N_Aspect_Specification>: Add Expression_Copy field.

4 days agoada: Expand check for setenv availability with _POSIX_VERSION
Mathias Aparicio [Mon, 13 Apr 2026 14:18:56 +0000 (16:18 +0200)] 
ada: Expand check for setenv availability with _POSIX_VERSION

Before this patch, the check for setenv availability was hard-coded to a
fixed list of platforms. Now expand the OR clause to also accept any system
conforming to ISO POSIX.1-2001, which includes setenv in unistd.h. This
avoids falling back to the putenv-based #else branch on other
POSIX-compliant systems.

gcc/ada/ChangeLog:

* env.c (__gnat_setenv): Add _POSIX_VERSION >= 200112L to setenv
availability check.

4 days agoada: Fix a couple of glitches in GNAT-LLVM section of User's Guide
Eric Botcazou [Mon, 20 Apr 2026 13:09:31 +0000 (15:09 +0200)] 
ada: Fix a couple of glitches in GNAT-LLVM section of User's Guide

gcc/ada/ChangeLog:

* doc/gnat_ugn/building_executable_programs_with_gnat.rst: Fix a
couple of glitches.
* gnat_ugn.texi: Regenerate.

4 days agoada: Linker_Section not inherited by object from unconstrained parent subtype
Gary Dismukes [Fri, 17 Apr 2026 23:15:29 +0000 (23:15 +0000)] 
ada: Linker_Section not inherited by object from unconstrained parent subtype

In the case of an object_declaration with a subtype_indication
whose subtype_mark denotes an unconstrained parent subtype (like
"type Unconstrained_String is new String") that itself specifies
the Linker_Section aspect or pragma, the object is not being inherited
from the type like it should be, and so will not be allocated in
the section specified by the aspect or pragma.

gcc/ada/ChangeLog:

* sem_ch3.adb (Copy_Parent_Attributes): Inherit Linker_Section_Pragma.