]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
2 weeks 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.

2 weeks 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.

2 weeks 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.

2 weeks 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.

2 weeks 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.

2 weeks 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.

2 weeks 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.

2 weeks 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.

2 weeks 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.

2 weeks 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.

2 weeks 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.

2 weeks 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.

2 weeks 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.

2 weeks 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.

2 weeks 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.

2 weeks 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.

2 weeks 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.

2 weeks 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.

2 weeks 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.

2 weeks 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.

2 weeks 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.

2 weeks agoada: Document inline assembler limitations in GNAT LLVM
Sebastian Poeplau [Fri, 17 Apr 2026 10:46:28 +0000 (12:46 +0200)] 
ada: Document inline assembler limitations in GNAT LLVM

gcc/ada/ChangeLog:

* doc/gnat_ugn/building_executable_programs_with_gnat.rst: Mention
inline assembler limitations.
* gnat_ugn.texi: Regenerate.

2 weeks agoada: Simplify interfacing with gmtime wrapper
Piotr Trojanek [Mon, 13 Apr 2026 22:14:54 +0000 (00:14 +0200)] 
ada: Simplify interfacing with gmtime wrapper

Interface from Ada to C for calling gmtime was over-complicated. Now we just
rely on the Ada RM and what it guarantees when interfacing for parameters of
elementary types depending on their IN/OUT mode.

gcc/ada/ChangeLog:

* adaint.c, adaint.h (__gnat_to_gm_time): Adapt C side, while keeping
the explicit conversion to time_t, if this ever needs to be debugged.
* libgnat/s-os_lib.adb (To_GM_Time): Adapt Ada side.

2 weeks agoada: Simplify interfacing with localtime wrappers
Piotr Trojanek [Wed, 8 Apr 2026 10:29:37 +0000 (12:29 +0200)] 
ada: Simplify interfacing with localtime wrappers

Interface from Ada to C for calling localtime was over-complicated, including
access types, aliased variables and suppressed CodePeer messages. None of this
is necessary if we just rely on the Ada RM and what it guarantees when
interfacing for parameters of elementary types depending on their IN/OUT mode.

gcc/ada/ChangeLog:

* libgnat/a-calend.adb (localtime_tzoff): Simplify interface.
* sysdep.c (__gnat_localtime_tzoff): Remove duplicated specs; pass
"in" parameters via copy and "out" parameters via pointers.

2 weeks agoada: Fix problematic call to function returning task in anonymous context
Eric Botcazou [Fri, 10 Apr 2026 10:44:47 +0000 (12:44 +0200)] 
ada: Fix problematic call to function returning task in anonymous context

The problem is that the task returned by the call to the function is never
activated.  This is fixed by creating a transient scope around the call, as
is done for controlled types, after making transient scopes compatible with
task types.

gcc/ada/ChangeLog:

PR ada/42413
* exp_ch4.adb (Process_Transients_In_Expression): Deal with a task
activation chain present in the statement list.
* exp_ch6.adb (Make_Build_In_Place_Call_In_Anonymous_Context): Also
establish a transient scope if the result type has tasks.
* exp_ch7.adb (Make_Transient_Block): Deal with Has_Master_Entity
and Has_Activation_Chain_Entity set on the transient scope.
* exp_ch9.ads (Make_Task_Activation_Call): New declaration from...
* exp_ch9.adb (Make_Task_Activation_Call): ...here.
(Build_Activation_Chain_Entity): Deal with transient scopes.
(Build_Master_Entity): Likewise.
(Find_Enclosing_Context): Likewise.
* sem_elab.adb (Activation_Processor.Process_Activation): Deal with
N_Expression_With_Actions nodes.
* sem_util.adb (Current_Entity_In_Scope): Prevent transient scopes
from being transparent for _Chain and _Master entities.

2 weeks agoada: Small tweaks in task activation support code
Eric Botcazou [Fri, 10 Apr 2026 10:35:21 +0000 (12:35 +0200)] 
ada: Small tweaks in task activation support code

This streamlines Build_Activation_Chain_Entity, factors out common code in
Exp_Ch9, and changes the category of the Is_Task_Allocation_Block flag.

No functional changes.

gcc/ada/ChangeLog:

PR ada/42413
* exp_aggr.adb (Build_Record_Aggr_Code): Minor tweak.
* exp_ch9.adb (Make_Task_Activation_Call): New helper function.
(Build_Activation_Chain_Entity): Streamline.
(Build_Master_Entity): Rename local variable.
(Build_Task_Activation_Call): Call Make_Task_Activation_Call.
(Build_Task_Allocate_Block): Likewise.  Set Is_Task_Allocation_Block
separately after having created the block.
* gen_il-gen-gen_nodes.adb (N_Block_Statement): Change the category
of Is_Task_Allocation_Block flag from syntactic to semantic.

2 weeks agoada: Replace Activation_Chain_Entity field by Has_Activation_Chain_Entity flag
Eric Botcazou [Wed, 8 Apr 2026 21:51:18 +0000 (23:51 +0200)] 
ada: Replace Activation_Chain_Entity field by Has_Activation_Chain_Entity flag

The former lives on selected nodes while the latter lives on scope entities.
This is more consistent because 1) activation chains are entities attached
to a scope and 2) master entities already use the Has_Master_Entity flag.

The ultimate goal is to make transient scopes compatible with task types.

No functional changes.

gcc/ada/ChangeLog:

PR ada/42413
* gen_il-fields.ads (Opt_Field_Enum): Remove Activation_Chain_Entity
and add Has_Activation_Chain_Entity.
* gen_il-gen-gen_entities.adb (Entity_Kind): Add new semantic flag
Has_Activation_Chain_Entity.
* gen_il-gen-gen_nodes.adb (N_Subprogram_Body): Remove
Activation_Chain_Entity field.
(N_Task_Body): Likewise.
(N_Package_Declaration): Likewise.
(N_Block_Statement): Likewise.
(N_Extended_Return_Statement): Likewise.
(N_Entry_Body): Likewise.
* einfo.ads (Has_Activation_Chain_Entity): Document new flag.
* sinfo.ads (Activation_Chain_Entity): Delete documentation.
* exp_ch9.adb (Build_Activation_Chain_Entity): Replace uses of
Activation_Chain_Entity by Has_Activation_Chain_Entity.
(Build_Task_Activation_Call): Retrieve the activation chain entity
by means of new helper function Activation_Chain_Entity.
(Build_Task_Allocate_Block): Set Has_Activation_Chain_Entity in
lieu of Activation_Chain_Entity.
(Expand_N_Task_Body): Likewise.
(Find_Enclosing_Context): Fix handling of N_Entry_Body.
* sem_ch7.adb (May_Need_Implicit_Body): Replace test on
Activation_Chain_Entity by Has_Activation_Chain_Entity.

2 weeks agoada: Avoid referencing ignored ghost nodes in finalizer
Viljar Indus [Tue, 14 Apr 2026 13:38:13 +0000 (16:38 +0300)] 
ada: Avoid referencing ignored ghost nodes in finalizer

gcc/ada/ChangeLog:

* exp_ch7.adb (Processing_Actions): Avoid processing
ignored ghost declarations.

2 weeks agoada: Fix missing dispatching for default implementation of S'Class'{Read,Write}
Eric Botcazou [Tue, 14 Apr 2026 18:52:00 +0000 (20:52 +0200)] 
ada: Fix missing dispatching for default implementation of S'Class'{Read,Write}

Note that 'Output and 'Put_Image are also affected since they share a common
implementation with the others.

gcc/ada/ChangeLog:

PR ada/18205
* exp_attr.adb (Rewrite_Attribute_Proc_Call): Skip the conversion to
the formal type only if the actual is of a class-wide type. Generate
a dispatching call when both the prefix is a class-wide type and the
subprogram is a dispatching operation.
(Expand_N_Attribute_Reference) <Input>: Use U_Type consistently and
remove an useless invocation of Root_Type.
<Put_Image>: Minor comment tweak.
<Read>: Likewise.
<Write>: Likewise.

2 weeks agoada: Minor cleanup in macro test
Marc Poulhiès [Fri, 27 Mar 2026 15:55:07 +0000 (16:55 +0100)] 
ada: Minor cleanup in macro test

The majority of the macros checked have already been checked a few line
above. Only difference is __CYGWIN32__, so check for its absence instead
of the presence of the others.

gcc/ada/ChangeLog:

* sysdep.c (getc_immediate_common): Cleanup macro test.

2 weeks agoada: Tweak predicate name and documentation comment
Ronan Desplanques [Mon, 13 Apr 2026 15:59:04 +0000 (17:59 +0200)] 
ada: Tweak predicate name and documentation comment

The old name was wrong because a type is not a subcomponent of itself.
In other words, "is a subcomponent of" is not a reflexive relation. Also,
the old comment implied that the Ekind of the return value was
E_Component; it's actually a type.

gcc/ada/ChangeLog:

* sem_util.ads (Partially_Visible_Subcomponent): Rename into ...
(Partially_Visible_Part): ...this. Improve documentation.
* sem_util.adb: Likewise.
* sem_ch3.adb (Analyze_Component_Declaration,
Array_Type_Declaration): Adapt to renaming.
* sem_ch7.adb (Install_Composite_Operations): Likewise.

2 weeks agoada: Remove doc for long gone field
Ronan Desplanques [Fri, 10 Apr 2026 13:57:41 +0000 (15:57 +0200)] 
ada: Remove doc for long gone field

The field Contains_Ignored_Ghost_Code was removed by the transition to
Gen_IL but its einfo.ads documentation stayed around. This patch removes
this documentation.

gcc/ada/ChangeLog:

* einfo.ads (Contains_Ignored_Ghost_Code): Remove documentation.

2 weeks agoada: Refactor Has_Assertion_Level_Argument for consistency
Mathias Aparicio [Thu, 9 Apr 2026 12:32:51 +0000 (14:32 +0200)] 
ada: Refactor Has_Assertion_Level_Argument for consistency

First branches of `Has_Assertion_Level_Argument` test an equality and if
met return False.

This patch apply this logic for the two other if that returned False
after the if.

gcc/ada/ChangeLog:

* sem_util.adb (Has_Assertion_Level_Argument): Invert the final
check in aspect branch and the check in pragma branch to use
early returns for consistency.

2 weeks agoada: Fix indentation checks with "finally"
Ronan Desplanques [Thu, 9 Apr 2026 12:51:33 +0000 (14:51 +0200)] 
ada: Fix indentation checks with "finally"

When the parser encounters the word "finally", it first considers it an
identifier and then looks ahead and possibly recategorizes it as a
keyword. The expected level of indentation depends on the final verdict,
but indentation checks were performed right away. This patch fixes the
issue by delaying the checks appropriately.

gcc/ada/ChangeLog:

* par.adb, par-util.adb (Check_Bad_Layout_At): New procedure.
* par-ch3.adb (P_Declarative_Item): Use new procedure.
* par-ch5.adb (P_Sequence_Of_Statements): Likewise.

2 weeks agoada: Fix crash in Has_Assertion_Level_Argument
Viljar Indus [Thu, 9 Apr 2026 08:22:05 +0000 (11:22 +0300)] 
ada: Fix crash in Has_Assertion_Level_Argument

This method would crash if the association was not a
N_Component_Association. As it could be something else like an
N_Iterated_Component_Association that does not have the choices
attribute.

gcc/ada/ChangeLog:

* sem_util.adb (Has_Assertion_Level_Argument): Check for
the correct type of association.

2 weeks agoada: Support qualified error names from Standard
Viljar Indus [Wed, 8 Apr 2026 11:32:40 +0000 (14:32 +0300)] 
ada: Support qualified error names from Standard

Typically nodes from Standard were not printed without the
fully qualified prefix names even when Error_Msg_Qual_Level was set.
However in some cases it makes sense to emphasize that the variable
is coming from Standard.

Add a new variable called Error_Msg_Qual_For_Standard to enable
qualified names for entities coming from Standard.

gcc/ada/ChangeLog:

* err_vars.ads (Error_Msg_Qual_For_Standard): New Variable.
* errout.ads (Error_Msg_Qual_For_Standard): Likewise.
* errout.adb (Set_Qualification): Print all qualified names
when Error_Msg_Qual_For_Standard is set.
* sem_util.adb (Normalize_Actuals): Improve error message.

2 weeks agoada: Improve error message for incorrect call arguments
Viljar Indus [Wed, 8 Apr 2026 10:02:06 +0000 (13:02 +0300)] 
ada: Improve error message for incorrect call arguments

Enumeration literals are considered as zero argument functions.
This is not obvious for most users and can create confusing error
messages when an enumeration literal is referred to as a call. For
example if there are indices applied to it.

Instead create a dedicated error message for this scenario.

gcc/ada/ChangeLog:

* sem_util.adb (Normalize_Actuals): Improve error message.

2 weeks agoada: Fix memory leak in __gnat_setenv
Mathias Aparicio [Thu, 26 Mar 2026 15:54:09 +0000 (16:54 +0100)] 
ada: Fix memory leak in __gnat_setenv

Before this patch, the code executed on Linux used `putenv`, which
requires a memory allocation. However, the memory was explicitly freed
only for Windows (`__MINGW32__`) and older VxWorks targets. Because
Linux fell into the allocation block but not the free block, there
was a memory leak.

To fix the leak, `__gnat_setenv` now calls `setenv` for Linux, doing
the same thing we were already doing for macOS.

Note that putting Linux in the Windows block is not a solution because,
on Linux, `putenv` uses the pointer directly and does not copy the
string. Therefore, if the memory were freed right away, there would be
a use-after-free.

To be careful, we do not use `setenv` everywhere else (except for old
VxWorks targets and Windows), because there might be problems with other
configurations if we do so.

gcc/ada/ChangeLog:

* env.c (__gnat_setenv): Add __linux__ preprocessor macro
directive to the setenv block.

2 weeks agoada: Fix SPARK RM 6.9(23) check for limited private types
Viljar Indus [Wed, 1 Apr 2026 07:36:46 +0000 (10:36 +0300)] 
ada: Fix SPARK RM 6.9(23) check for limited private types

The Check_Ghost_Equality_Op predicate was checking the type directly
instead of its underlying type, so a limited private type whose full
view is a non-limited record was incorrectly bypassing the check.
Additionally, the check was never deferred to Process_Full_View, so
equality operators declared in the visible part of a package were
not re-checked once the full view became available.

gcc/ada/ChangeLog:

* ghost.adb (Check_Ghost_Equality_Op): Use Underlying_Type to
look through the private view before checking Is_Record_Type and
Is_Limited_Record.
* sem_ch3.adb (Process_Full_View): After completing the full view,
re-check any primitive equality operators on the private type
against SPARK RM 6.9(23) via Check_Ghost_Equality_Op.

2 weeks agoada: Further streamlining work
Eric Botcazou [Tue, 7 Apr 2026 16:29:17 +0000 (18:29 +0200)] 
ada: Further streamlining work

This streamlines Build_Task_Allocate_Block from Exp_Ch9 by making it return
the block statement only, changes Add_Task_Actuals_To_Build_In_Place_Call to
deal with the master and activation chain actuals more consistently, as well
as flattens an inner block in Make_Build_In_Place_Call_In_Allocator.

No functional changes.

gcc/ada/ChangeLog:

* exp_ch9.ads (Build_Task_Allocate_Block): Change return type.
* exp_ch9.adb (Build_Task_Allocate_Block): Likewise.  Build an
internal block entity instead of declaring an implicit label.
* exp_aggr.adb (Convert_Aggr_In_Allocator): Adjust to above change.
* exp_ch4.adb (Expand_N_Allocator): Likewise.
* exp_ch6.adb (Add_Task_Actuals_To_Build_In_Place_Call): Add default
value for Master_Actual parameter, change name of 4th parameter to
Chain_Actual and deal with them consistently.
(Make_Build_In_Place_Call_In_Allocator): Flatten block statement.
Adjust call to Add_Task_Actuals_To_Build_In_Place_Call.
(Make_Build_In_Place_Call_In_Anonymous_Context): Likewise.
(Make_Build_In_Place_Call_In_Assignment): Likewise.
(Make_Build_In_Place_Call_In_Object_Declaration): Likewise.
* exp_ch7.adb (Build_Cleanup_Statements): Minor tweak.

2 weeks agoada: Add note about Sem_Aux being in binder closure
Ronan Desplanques [Tue, 7 Apr 2026 12:03:00 +0000 (14:03 +0200)] 
ada: Add note about Sem_Aux being in binder closure

I recently realized that Sem_Aux is in the binder's closure, unlike
Sem_Util. This patch makes it explicit in a comment since it can be
useful when choosing where to put a helper subprogram.

gcc/ada/ChangeLog:

* sem_aux.ads: Add note.

2 weeks agoada: Improve layout of record types from Sem
Eric Botcazou [Fri, 3 Apr 2026 09:40:27 +0000 (11:40 +0200)] 
ada: Improve layout of record types from Sem

Compiling the unit with -gnatRh shows unused bits in the record types from
the Sem unit.  This change saves two 32-bit words for Scope_Stack_Entry.

gcc/ada/ChangeLog:

* sem.ads (Suppress_Stack_Entry): Move down Suppress component.
(Scope_Stack_Entry): Reorder components to eliminate holes.

2 weeks agoada: Update gnat-llvm debugging documentation
Tom Tromey [Fri, 3 Apr 2026 18:31:04 +0000 (12:31 -0600)] 
ada: Update gnat-llvm debugging documentation

With the latest patches to LLVM and gnat-llvm, I believe that types
are represented correctly.  This patch updates the documentation
accordingly.

gcc/ada/ChangeLog:

* doc/gnat_ugn/building_executable_programs_with_gnat.rst
(GNATLLVM): Update debugging documentation.
* gnat_ugn.texi: Regenerate.

2 weeks agoada: Cleanup aspect specifications (Ins_Node)
Bob Duff [Sun, 5 Apr 2026 12:42:21 +0000 (08:42 -0400)] 
ada: Cleanup aspect specifications (Ins_Node)

Get rid of the Ins_Node parameters and variable. We still treat
pragma Annotate specially, but at least the special case is more
localized now. (It is quadratic in the number of pragmas Annotate,
which is acceptable.) We should eventually remove this special case.

In the compilation unit case, insert at the end of Pragmas_After,
rather than the beginning. This is not necessary, but seems more
uniform with the non-compilation-unit cases. Remove ??? marks.

gcc/ada/ChangeLog:

* sem_ch13.adb
(Insert_Aitem): Remove Ins_Node formal parameter.
(Analyze_One_Aspect): Likewise.
(Analyze_Aspect_Specifications): Remove Ins_Node local variable.
(Insert_After_Place): New function containing the
special case for Annotate.

2 weeks agoada: Add missing documentation for attribute Ref
Piotr Trojanek [Wed, 1 Apr 2026 15:16:23 +0000 (17:16 +0200)] 
ada: Add missing documentation for attribute Ref

Attribute Ref was implemented for compatibility with other compilers, but never
documented.

gcc/ada/ChangeLog:

* doc/gnat_rm/implementation_defined_attributes.rst (Attribute_Ref):
New section based on comment in sem_attr.ads.
* gnat_rm.texi: Regenerate.

2 weeks agoada: Restore alphabetical ordering in Sem_Util
Ronan Desplanques [Wed, 1 Apr 2026 08:15:46 +0000 (10:15 +0200)] 
ada: Restore alphabetical ordering in Sem_Util

gcc/ada/ChangeLog:

* sem_util.adb, sem_util.ads (Partially_Visible_Subcomponent): Move
to right spot.

2 weeks agoada: Small consistency fixes
Eric Botcazou [Wed, 1 Apr 2026 15:47:56 +0000 (17:47 +0200)] 
ada: Small consistency fixes

Build_Activation_Chain_Entity and Build_Master_Entity from Exp_Ch9 are very
similar but the former takes a Node while the latter takes an Entity.  This
aligns the latter with the former.  No functional changes.

gcc/ada/ChangeLog:

* exp_aggr.adb (Build_Array_Aggr_Code): Adjust actual parameter in
the call to Build_Master_Entity.
* exp_ch3.adb (Expand_N_Full_Type_Declaration): Likewise.
(Expand_N_Object_Declaration): Likewise.
(Expand_Previous_Access_Type): Likewise.
* exp_ch6.adb (Make_Build_In_Place_Call_In_Anonymous_Context):
Likewise.
(Make_Build_In_Place_Iface_Call_In_Allocator): Likewise.
(Make_Build_In_Place_Iface_Call_In_Anonymous_Context): Likewise.
* sem_ch3.adb (Access_Definition): Likewise.
(Access_Type_Declaration): Likewise.
* exp_ch9.ads (Build_Activation_Chain_Entity): Tweak description.
(Build_Master_Entity): Change parameter and tweak description.
* exp_ch9.adb (Build_Master_Entity): Change parameter and adjust.

2 weeks agoada: Implement AI12-0331 Binding Interpretation
Eric Botcazou [Tue, 31 Mar 2026 09:48:11 +0000 (11:48 +0200)] 
ada: Implement AI12-0331 Binding Interpretation

The Binding Interpretation defines the order of the four steps that occur
during the finalization of subpools. The order was previously unspecified
but the AI mentions that there was no real leeway, i.e. that there was a
unique possible order; however it turns out that GNAT implements another
order, which therefore needs to be changed.

Moreover GNAT's implementation is unnecessarily convoluted: 1) it uses a
circular doubly-linked list with a fake head to implement the subpools,
but the subpools have a pointer to the owner of the list, so a simple
doubly-linked list is sufficient and 2) it allocates special nodes on
the heap to chain the subpools onto the list, which is a bit awkward.

gcc/ada/ChangeLog:

PR ada/124143
* libgnat/s-spsufi.ads (Finalize_And_Deallocate): Adjust comment.
* libgnat/s-spsufi.adb: Remove clause for Ada.Unchecked_Deallocation
(Finalize_And_Deallocate): Adjust and implement AI12-0331.
* libgnat/s-stposu.ads (Allocate_From_Subpool): Remove ??? comment.
(Deallocate_Subpool): Likewise.
(SP_Node): Delete.
(SP_Node_Ptr): Likewise.
(Root_Storage_Pool_With_Subpools): Adjust type of Subpools component
(Root_Subpool): Remove Node, add Prev and Next components.
(Detach): Adjust signature.
(Initialize): Delete.
(Initialize_Pool): Likewise.
* libgnat/s-stposu.adb (Allocate_Any_Controlled): Adjust.
(Attach): Reimplement.
(Detach): Likewise.
(Finalize_Pool): Loop over a simple doubly linked list.
(Initialize): Delete.
(Initialize_Pool): Likewise.
(Print_Pool): Adjust.
(Print_Subpool): Likewise.
(Set_Pool_Of_Subpool): Remove obsolete code.

2 weeks agoada: Rename Has_Private_Component function
Ronan Desplanques [Tue, 31 Mar 2026 08:50:44 +0000 (10:50 +0200)] 
ada: Rename Has_Private_Component function

The expression "private component" is best reserved for components of
protected objects' private sections. This renames a function from
"Has_Private_Component" to a more explicit name because that function is
not about the protected object component case.

gcc/ada/ChangeLog:

* sem_util.ads (Has_Private_Component): Rename into...
(Is_Incompletely_Defined): ...this.
* sem_util.adb (Has_Private_Component): Rename into...
(Is_Incompletely_Defined): ...this.
(Check_Fully_Declared): Adapt to above renaming.
* exp_ch3.adb (Freeze_Type): Likewise.
* freeze.adb (Check_And_Freeze_Type): Likewise.
* sem_aggr.adb (Array_Aggr_Subtype): Likewise.
* sem_ch12.adb (Instantiate_Type): Likewise.
* sem_ch13.adb (Rep_Item_Too_Early): Likewise.
* sem_ch3.adb (Access_Definition, Analyze_Full_Type_Declaration,
Analyze_Subtype_Declaration, Build_Derived_Access_Type,
Copy_And_Build, Complete_Private_Subtype, Constrain_Access,
Constrain_Array, Build_Constrained_Access_Type, Constrain_Concurrent,
Constrain_Corresponding_Record, Copy_Array_Subtype_Attributes,
Derived_Type_Declaration): Likewise.
* sem_ch6.adb (Create_Extra_Formals): Likewise.
* sem_res.adb (Make_Call_Into_Operator): Likewise.

2 weeks agoada: Restrict Is_Limited_Composite field to (sub)types
Ronan Desplanques [Tue, 31 Mar 2026 10:27:57 +0000 (12:27 +0200)] 
ada: Restrict Is_Limited_Composite field to (sub)types

Is_Limited_Composite was set on all entities during the migration to
Gen_IL, but it's only used on types and subtypes. This moves the field
to the appropriate entity kind.

gcc/ada/ChangeLog:

* gen_il-gen-gen_entities.adb (Gen_Entities): Move
Is_Limited_Composite.
* einfo.ads (Is_Limited_Composite): Update documentation.

2 weeks agoada: Avoid giving multiple errors on ghost argument
Viljar Indus [Tue, 31 Mar 2026 09:04:37 +0000 (12:04 +0300)] 
ada: Avoid giving multiple errors on ghost argument

Avoid marking multiple errors on the same line if the ghost
expression is both non-static and also would evaluate to False.

gcc/ada/ChangeLog:

* sem_prag.adb (Analyze_Abstract_State): make error checks
exclusive.

2 weeks agoada: Rename Private_Component function
Ronan Desplanques [Mon, 30 Mar 2026 10:36:02 +0000 (12:36 +0200)] 
ada: Rename Private_Component function

The expression "private component" is best reserved for components of
protected objects' private sections. This renames a function from
"Private_Component" to a more explicit name because that function is not
about the protected object component case.

gcc/ada/ChangeLog:

* sem_util.ads, sem_util.adb (Private_Component): Rename into...
(Partially_Visible_Subcomponent): ...this.
* sem_ch3.adb (Analyze_Component_Declaration, Array_Type_Declaration):
Adapt to above renaming.
* sem_ch7.adb (Install_Composite_Operations): Likewise.

2 weeks agoSwitch g++ to default Solaris 11.4 compilation environment
Rainer Orth [Tue, 2 Jun 2026 08:31:47 +0000 (10:31 +0200)] 
Switch g++ to default Solaris 11.4 compilation environment

g++ has predefined _XOPEN_SOURCE=600 since

[fixincludes, v3] Enable full ISO C99 support for C++ on Solaris 10+
http://gcc.gnu.org/ml/gcc-patches/2010-05/msg01308.html

While Solaris 10 introduced XPG6/POSIX.1-2001 support, the default
compilation environment remained XPG3 until Solaris 11.3.  However,
libstdc++ uses many XPG6 interfaces, so g++ needed to explicitly enable
that.

Only Solaris 11.4 implemented XPG7/POSIX.1-2008 support, at the same
time changing the default to XPG7.

Therefore, g++ can remove the explicit enablement of XPG6, using the
11.4 default just like gcc has done all the time.

__EXTENSIONS__ needs to remain, however: a considerable part of
libstdc++ depends on that.

Bootstrapped on i386-pc-solaris2.11, amd64-pc-solaris2.11,
sparc-sun-solaris2.11, and sparcv9-sun-solaris2.11.  There were no
changed to any config.h file.

2026-05-15  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

gcc:
* config/sol2.h (TARGET_OS_CPP_BUILTINS): Don't define
_XOPEN_SOURCE=600 for C++.

2 weeks agolibsanitizer: Fix sanitizer_platform_limits_solaris.cpp compilation
Rainer Orth [Tue, 2 Jun 2026 08:26:16 +0000 (10:26 +0200)] 
libsanitizer: Fix sanitizer_platform_limits_solaris.cpp  compilation

As described in

[sanitizer_common] Fix sanitizer_platform_limits_solaris.cpp compilation (#198158)
https://github.com/llvm/llvm-project/pull/198158

sanitizer_platform_limits_solaris.cpp fails to compile when g++ is
switched to the default Solaris 11.4 compilation environment, XPG7 +
extensions.

This patch, cherry-picked from upstream, fixes this.

Bootstrapped without regressions on i386-pc-solaris2.11 and
sparc-sun-solaris2.11.

2026-05-15  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

libsanitizer:
* sanitizer_common/sanitizer_platform_limits_solaris.cpp:
Cherry-pick llvm-project revision
0e92b557a78eddc7493ade4cfc0a3b6b93ee61cf.

2 weeks agotree-optimization/120702 - avoid folding loads to STRING_CSTs
Richard Biener [Wed, 29 Apr 2026 07:19:43 +0000 (09:19 +0200)] 
tree-optimization/120702 - avoid folding loads to STRING_CSTs

The following avoids (large) string duplication which can happen
when folding aggregate reads to STRING_CSTs.  There's unlikely
to be followup optimization opportunities.

PR tree-optimization/120702
* gimple-fold.cc (maybe_fold_reference): Only fold
register type reads.

* gcc.dg/tree-ssa/pr120702.c: New testcase.

2 weeks agolibstdc++: Support limited escaped formatting for non-Unicode literals.
Tomasz Kamiński [Fri, 15 May 2026 09:07:03 +0000 (11:07 +0200)] 
libstdc++: Support limited escaped formatting for non-Unicode literals.

This restores limited support debug (escaped) output for string when literal
encoding is non-Unicode, by allowing strings that contains only printable
ASCII characters and standard defined escapes (expanded with nul (\0)).
This covers common use-cases, while still preserving flexibility to provide
proper handling for escaping of encoding-specific characters.

libstdc++-v3/ChangeLog:

* include/std/format (__format::__write_escaped_ascii): Mark as
_GLIBCXX_CONSTEXPR_FORMAT and at compile time, reject strings
containing characters other than printable ASCII and standard
escapes.
* testsuite/std/format/debug.cc: Test basic_escapes and \0
at compile-time.
* testsuite/std/format/debug_nonunicode_neg.cc: New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 weeks agolibstdc++: implement constexpr std::format
Ivan Lazaric [Fri, 15 May 2026 09:06:54 +0000 (11:06 +0200)] 
libstdc++: implement constexpr std::format

This patch implements constexpr formatting from P3391R2,
and introduces the constexpr_format feature-test macro.
Since pre-cxx11 cow_string is not constexpr-enabled,
only exposing the feature-test macro under cxx11 ABI.

Add `__format::__toupper_numeric` function that work in constexpr.
It is not fully general, but `<format>` doesn't need all uppercasing.

The `__write_escaped_ascii` is not marked constexpr, to enable
futhure improvement for non-unicode literal encodings (for example
using `iconv`).

Update `__check_dynamic_spec` to check if `__args` is run, to
accomodate for dynamic_format or vformat invoked at compile time.

Mark `basic_format_string` consteval constructor noexcept,
since exceptions are now constexpr, and the standard mandates
failure to parse to be non-catchable ill-formed.
https://eel.is/c++draft/format#fmt.string-3
> Remarks: A call to this function is not a core constant expression
> ([expr.const]) unless there exist args of types Args such that
> str is a format string for args.

Update some formatting tests to test constexpr as well,
and introduce a dedicated smoke test for constexpr formatting.

libstdc++-v3/ChangeLog:

* include/bits/version.def (constexpr_exceptions): Move before
format.
(constexpr_format): Define.
* include/bits/version.h: Regenerate.
* include/std/format (_GLIBCXX_CONSTEXPR_FORMAT): Define and
apply to all of functions except __write_escaped_ascii and
__formatter_fp members.
(_GLIBCXX_CONSTEXPR_FORMAT_ERROR): Replace with
_GLIBCXX_CONSTEXPR_FORMAT.
(basic_format_string::basic_format_string(const _Tp&)):
Mark as noexcept.
(__format::__toupper_numeric): Define.
(__formatter_int::format): Use __format::__toupper_numeric
and replace __builtin_memcpy with ranges::copy.
(__formatter_fp::format): Use __format::__toupper_numeric.
(__formatter_ptr::format): Avoid reinterpret_cast for
null-pointer value to support std::nullptr_t formatting.
(__format::__do_vformat_to): Replace __builtin_memcpy with
ranges::copy.
(basic_format_parse_context::__check_dynamic_spec):
Skip checks if __args pointer is null.
* testsuite/std/format/arguments/args_neg.cc: Diagnostics change.
* testsuite/std/format/constexpr.cc: New test.
* testsuite/std/format/debug.cc: Test at compile-time in C++26
and update iteration limit for paddding tests.
* testsuite/std/format/tuple.cc: Likewise.
* testsuite/std/format/functions/format.cc: Test at compile-time
in C++26.
* testsuite/std/format/dynamic_format.cc: Likewise.
* testsuite/std/format/functions/format_to.cc: Likewise.
* testsuite/std/format/functions/size.cc: Likewise.
* testsuite/std/format/ranges/format_kind.cc: Likewise.
* testsuite/std/format/ranges/formatter.cc: Likewise.
* testsuite/std/format/ranges/sequence.cc: Likewise.
* testsuite/std/format/string.cc: Likewise.
* testsuite/std/time/format/data_not_present_neg.cc: Diagnostics
change.

Co-authored-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Ivan Lazaric <ivan.lazaric1@gmail.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 weeks agowide-int: Fix up wi::bitreverse_large [PR125517]
Jakub Jelinek [Tue, 2 Jun 2026 06:52:44 +0000 (08:52 +0200)] 
wide-int: Fix up wi::bitreverse_large [PR125517]

The following testcase shows wi::bitreverse_large is buggy.  In particular,
it uses the len argument (i.e. number of limbs the xval wide_int has)
to decide how much to clear, but it should be using BLOCKS_NEEDED
(precision) for that and for canonize argument similarly to wi::bswap_large,
because it behaves similarly to that.  If xval is say len 1 but precision
512, we want to clear all 512 bits in the result limbs and the loop then
sets the most significant one in there and canonize with len (512 + 63) /
64, not initialize just the least significant limb, set various bits in the
uninitialized ones and then only care about the least significant 64 bits
anyway.

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

PR middle-end/125517
* wide-int.cc (wi::bitreverse_large): Rename LEN argument to XLEN and
use it as safe_uhwi argument.  Add LEN automatic variable set to
BLOCKS_NEEDED (precision).  Replace loop clearing val with memset.
Remove I automatic variable.

* gcc.dg/builtin-bitreverse-9.c: New test.

Reviewed-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 weeks agolibstdc++: mark integer std::to_(w)string constexpr
Ivan Lazaric [Fri, 15 May 2026 09:06:46 +0000 (11:06 +0200)] 
libstdc++: mark integer std::to_(w)string constexpr

In C++26 paper P3391, "constexpr formatting", has been adopted,
part of which marks std::to_string & std::to_wstring for integers
as constexpr. The __cpp_lib_constexpr_string FTM value is updated
per resolution of LWG4531, "Should there be a feature-test macro
update for constexpr std::to_(w)string?".

Since pre-cxx11 copy-on-write string is not constexpr-enabled,
restricting this constexpr-ification to cxx11 ABI strings.

libstdc++-v3/ChangeLog:

* include/bits/version.def (constexpr_string): Bump to 202511.
* include/bits/version.h: Regenerate.
* include/bits/basic_string.h (std::to_string, std::to_wstring)
[__glibcxx_constexpr_string >= 202511L]: Mark as constexpr.
* testsuite/21_strings/basic_string/numeric_conversions/char/to_string_constexpr.cc:
New test.
* testsuite/21_strings/basic_string/numeric_conversions/wchar_t/to_wstring_constexpr.cc:
New test.
* testsuite/21_strings/basic_string/cons/char/constexpr.cc: Update
__cpp_lib_constexpr_string check.
* testsuite/21_strings/basic_string/cons/wchar_t/constexpr.cc: Likewise.
* testsuite/21_strings/basic_string/version.cc: Add check for value of
__cpp_lib_constexpr_string in C++26.

Co-authored-by: Tomasz Kamiński <tkaminsk@redhat.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Reviewed-by: Nathan Myers <ncm@cantrip.org>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
2 weeks agoFix up gfortran.dg/gomp/allocate-*.f90
Jakub Jelinek [Tue, 2 Jun 2026 06:36:32 +0000 (08:36 +0200)] 
Fix up gfortran.dg/gomp/allocate-*.f90

The r17-1009 change (in particular gfc_match_omp_variable_list hunk
of it) fixed spelling of one diagnostic message, but has not adjusted
corresponding testsuite, so these tests now fail.

Fixed thusly.

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

* gfortran.dg/gomp/allocate-6.f90: Adjust dg-error wording after
recent spelling fixes.
* gfortran.dg/gomp/allocate-7.f90: Likewise.
* gfortran.dg/gomp/allocate-14.f90: Likewise.
* gcc.target/sparc/struct-ret-check-1.c: Fix comment spelling,
specificed -> specified.

2 weeks agoFortran: Fix submodule access to private symbols in parent module [PR88632,104630]
Paul Thomas [Mon, 1 Jun 2026 11:40:53 +0000 (12:40 +0100)] 
Fortran: Fix submodule access to private symbols in parent module [PR88632,104630]

PRs 88632 and 104630 both suffered link a problem, where a private procedure
in a parent module was not visible in a descendent submodule if they were
compiled separately.

The fix is to not filter out private symbols when writing the .smod file.
Submodules are descendants of their ancestor module and access private symbols
in the module's contains section via host association (F2018 14.2.2).

The testcase here is that of PR104630. However, it is functionally identical
to that of PR88632.

2026-06-02  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/88632
PR fortran/104630
* module.cc (write_symtree): Do not filter out private symbols
when writing a submodule interface file (.smod).  Submodules are
descendants of their ancestor module and access private symbols
in the module's contains section via host association per
Fortran 2018 section 14.2.2.

gcc/testsuite/
PR fortran/88632
PR fortran/104630
* gfortran.dg/submodule_35.f90: New test.
* gfortran.dg/submodule_35_aux.f90: Submodule and program for
for the new test.

Assisted by: Claude Sonnet 4.6

2 weeks agoRISC-V: Fix typos in comments and a misspelled variable
Jin Ma [Sat, 30 May 2026 13:32:07 +0000 (21:32 +0800)] 
RISC-V: Fix typos in comments and a misspelled variable

Fix comment typos, grammatical errors and GNU two-space sentence
spacing across the RISC-V backend.  Also rename the misspelled local
variable additioanl_bytes in riscv_zcmp_valid_stack_adj_bytes_p to
additional_bytes.

The change is limited to comments and a local variable name, so this
is a non-functional change.  No test case is added as no behaviour
changes.

gcc/ChangeLog:

* common/config/riscv/riscv-common.cc: Fix typos in comments.
* config/riscv/andes-25-series.md: Likewise.
* config/riscv/autovec-opt.md: Likewise.
* config/riscv/autovec.md: Likewise.
* config/riscv/bitmanip.md: Likewise.
* config/riscv/constraints.md: Likewise.
* config/riscv/gen-riscv-ext-opt.cc: Likewise.
* config/riscv/gen-riscv-mcpu-texi.cc: Likewise.
* config/riscv/generic-vector-ooo.md: Likewise.
* config/riscv/multilib-generator: Likewise.
* config/riscv/riscv-avlprop.cc: Likewise.
* config/riscv/riscv-ext.def: Likewise.
* config/riscv/riscv-ext.opt: Likewise.
* config/riscv/riscv-modes.def: Likewise.
* config/riscv/riscv-opt-popretz.cc: Likewise.
* config/riscv/riscv-profiles.def: Likewise.
* config/riscv/riscv-protos.h: Likewise.
* config/riscv/riscv-selftests.cc: Likewise.
* config/riscv/riscv-sr.cc: Likewise.
* config/riscv/riscv-string.cc: Likewise.
* config/riscv/riscv-subset.h: Likewise.
* config/riscv/riscv-target-attr.cc: Likewise.
* config/riscv/riscv-v.cc: Likewise.
* config/riscv/riscv-vect-permconst.cc: Likewise.
* config/riscv/riscv-vector-builtins-bases.cc: Likewise.
* config/riscv/riscv-vector-builtins-functions.def: Likewise.
* config/riscv/riscv-vector-builtins-shapes.cc: Likewise.
* config/riscv/riscv-vector-builtins-types.def: Likewise.
* config/riscv/riscv-vector-builtins.cc: Likewise.
* config/riscv/riscv-vector-builtins.def: Likewise.
* config/riscv/riscv-vector-builtins.h: Likewise.
* config/riscv/riscv-vector-costs.cc: Likewise.
* config/riscv/riscv-vector-costs.h: Likewise.
* config/riscv/riscv-vsetvl.cc: Likewise.
* config/riscv/riscv-vsetvl.def: Likewise.
* config/riscv/riscv-zicfilp.cc: Likewise.
* config/riscv/riscv.cc: Likewise.
(riscv_zcmp_valid_stack_adj_bytes_p): Rename misspelled
variable additioanl_bytes to additional_bytes.
* config/riscv/riscv.h: Likewise.
* config/riscv/riscv.md: Likewise.
* config/riscv/sifive-vector-builtins-functions.def: Likewise.
* config/riscv/sifive_vector.h: Likewise.
* config/riscv/spacemit-x60.md: Likewise.
* config/riscv/thead.cc: Likewise.
* config/riscv/tt-ascalon-d8.md: Likewise.
* config/riscv/vector-crypto.md: Likewise.
* config/riscv/vector-iterators.md: Likewise.
* config/riscv/vector.md: Likewise.
* config/riscv/zicond.md: Likewise.
* doc/riscv-mcpu.texi: Regenerate.

2 weeks agoRISC-V: Clean up redundant code and fix GNU coding style issues
Jin Ma [Sat, 30 May 2026 14:46:05 +0000 (22:46 +0800)] 
RISC-V: Clean up redundant code and fix GNU coding style issues

Tidy up a few non-functional issues in the RISC-V backend.
genrvv-type-indexer.cc includes <assert.h> but uses no assert, and
riscv-v.cc includes "targhooks.h" twice; remove both.  In addition,
riscv_output_move and riscv_save_libcall_count call abort () where
gcc_unreachable () is the preferred idiom for unreachable points.

The remaining changes fix GNU coding style: add the missing space before
the open parenthesis of function calls and casts, fix brace placement,
remove a stray double semicolon and re-wrap a few over-long lines.

All of the above is redundant code, an idiom change or formatting, so
this is a cleanup with no functional change.  No test case is added as
no behaviour changes.

gcc/ChangeLog:

* common/config/riscv/riscv-common.cc: Fix formatting.
* config/riscv/gen-riscv-mcpu-texi.cc: Likewise.
* config/riscv/gen-riscv-mtune-texi.cc: Likewise.
* config/riscv/genrvv-type-indexer.cc: Remove unused <assert.h>
include.
* config/riscv/riscv-string.cc: Fix formatting.
* config/riscv/riscv-target-attr.cc: Likewise.
* config/riscv/riscv-v.cc: Remove duplicate "targhooks.h" include.
Fix formatting.
* config/riscv/riscv-v.h: Fix formatting.
* config/riscv/riscv-vsetvl.cc: Likewise.
* config/riscv/riscv.cc (riscv_pass_by_reference): Remove stray
double semicolon.  Fix formatting elsewhere.
(riscv_output_move): Use gcc_unreachable () instead of abort ().
(riscv_save_libcall_count): Use gcc_unreachable () instead of
abort ().
* config/riscv/riscv.h: Fix formatting.
* config/riscv/thead.cc: Likewise.

2 weeks agolibbacktrace: support compressed block with no sequences
Ian Lance Taylor [Tue, 2 Jun 2026 04:34:27 +0000 (21:34 -0700)] 
libbacktrace: support compressed block with no sequences

* elf.c (elf_zstd_decompress_frame): Support a compressed block
with no sequences, only literals.

2 weeks agocobol: Improve execution speed of FUNCTION TRIM.
Robert Dubner [Tue, 2 Jun 2026 02:50:28 +0000 (22:50 -0400)] 
cobol: Improve execution speed of FUNCTION TRIM.

By breaking out specific code for FUNCTION TRIM when the string is
single-byte-coded ASCII or EBCDIC, and by creating a matching
__gg__trim_1 routine using std::find_if(), the function operates about
fifteen to 25 times faster than it did.

gcc/cobol/ChangeLog:

* compare.cc (cobol_compare_relop): Rename the cobol_compare_relop
function.
(cobol_compare): Likewise.
* compare.h (cobol_compare_relop): Likewise.
(cobol_compare): Likewise.
* genapi.cc (parser_display): Refine the use of SYSPUNCH_e for
inserting debugging comments into the assembly language.
(parser_relop): Use "cobol_compare".
(handle_gg_trim): Break out SBC TRIM logic.
(parser_intrinsic_call_2): Likewise.
(parser_bsearch_when): Use "cobol_compare"
* genutil.cc (refer_is_super_clean): FldLiteralN is always "super
clean".
(is_pure_integer): Make binary_from_FldNumericBin5 "static bool".
(binary_from_FldLiteralN): New function.
(get_binary_value): Use the new function.

libgcobol/ChangeLog:

* intrinsic.cc (__gg__trim): Eliminate useless comment.
(__gg__trim_1): New function.

2 weeks agoc/c++: Declare stack protection guard in file scope
H.J. Lu [Wed, 6 May 2026 12:58:47 +0000 (20:58 +0800)] 
c/c++: Declare stack protection guard in file scope

When stack protection guard is declared in c_common_nodes_and_builtins,
it is put in the externals scope outside file scope which triggers
-Wnested-externs warning in C:

cc1: warning: nested extern declaration of '__stack_chk_guard' [-Wnested-externs]

Declare stack protection guard in file scope instead.

gcc/c-family/

PR c/121911
* c-common.cc (c_common_nodes_and_builtins): Don't declare stack
protection guard here.

gcc/c/

PR c/121911
* c-decl.cc (push_file_scope): Add stack protection guard to
visible_builtins.

gcc/cp/

PR c/121911
* decl.cc (cxx_init_decl_processing ): Declare stack protection
guard after calling c_common_nodes_and_builtins.

gcc/testsuite/

PR c/121911
* gcc.dg/Wnested-externs-1.c: Add -mstack-protector-guard=global
for x86.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2 weeks agoi386: Add avx512_avoid_vec_perm tune for c86-4g-m7
Tianle Shi [Tue, 2 Jun 2026 01:05:02 +0000 (01:05 +0000)] 
i386: Add avx512_avoid_vec_perm tune for c86-4g-m7

This implements the AVX512 avoid-vec-perm cost model for c86-4g-m7
following the existing AVX256 support r15-4234-g9eaecce3d8c1d9.

Extend the vectorizer cost model to treat 512-bit cross-lane vec_perm
as unprofitable when this tune is enabled, since c86-4g-m7 implements
AVX512 as two 256-bit halves and cross-lane reorder is slower than
staying in AVX256.

Factor out the cross-lane permutation classification into a helper so
the AVX256 and AVX512 cost handling can share the same logic without
duplicating it.

gcc/ChangeLog:

* config/i386/i386.cc (ix86_vector_costs): Add
m_num_avx512_vec_perm.
(ix86_vector_costs::ix86_vector_costs): Initialize it.
(ix86_count_cross_lane_perm_p): New helper to classify
cross-lane vec_perm for AVX256 and AVX512 handling.
(ix86_vector_costs::add_stmt_cost): Use the helper for
vec_perm accounting, record 256-bit and 512-bit counts,
and print detected width as avx%u.
(ix86_vector_costs::finish_cost): Reject AVX512 costs
when TARGET_AVX512_AVOID_VEC_PERM is set and 512-bit
cross-lane vec_perm is present.
* config/i386/i386.h (TARGET_AVX512_AVOID_VEC_PERM):
New macro.
* config/i386/x86-tune.def (X86_TUNE_AVX512_AVOID_VEC_PERM):
New tune for c86-4g-m7.

gcc/testsuite/ChangeLog:

* gcc.target/i386/avx512_avoid_vec_perm-1.c: New test.
* gcc.target/i386/avx512_avoid_vec_perm-2.c: New test.
* gcc.target/i386/avx512_avoid_vec_perm-3.c: New test.

Signed-off-by: Tianle Shi <shitianle@hygon.cn>
2 weeks agoFinish cleanup/removing -Wstrict-overflow= support [PR125558]
Andrew Pinski [Mon, 1 Jun 2026 20:39:36 +0000 (13:39 -0700)] 
Finish cleanup/removing -Wstrict-overflow= support [PR125558]

This finishes removing the support for -Wstrict-overflow that seemly was
missed before. It also marks the option as being ignored and fixes
the -Wstrict-overflow= case where it was rejecting -Wstrict-overflow=1 now.

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

PR middle-end/125558

gcc/ChangeLog:

* common.opt (Wstrict-overflow): Mark as Ignore.
(Wstrict-overflow=): Fix up and mark as igore.
* gcc-diagnostic-spec.cc (nowarn_spec_t::nowarn_spec_t):
Remove OPT_Wstrict_overflow.
* opts.cc (common_handle_option): Likewise.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 weeks agoc++: Improve -fdump-lang-class output
Peter Damianov [Tue, 28 Apr 2026 16:54:50 +0000 (17:54 +0100)] 
c++: Improve -fdump-lang-class output

When I was researching to write my blogpost about vtables:
https://peter0x44.github.io/posts/vtables-itanium-abi/

I noticed a few improvements I could make to -fdump-lang-class's output

-fdump-lang-class prepended "0x" to HOST_WIDE_INT_PRINT_HEX outputs, but the
macro already includes that prefix, producing "0x0x..." in dumps.

Some vtable entries hold signed values e.g. vcall offsets, vbase offsets,
 offset-to-top.  When expr_as_string prints those INTEGER_CSTs,
negative offsets appear as large (unsigned) values.  Print integer vtable
entries as signed values, and keep expr_as_string for all other entries.

gcc/cp/ChangeLog:

* class.cc (dump_vtable_entry): New function.
(dump_array): Use it.
(dump_class_hierarchy_r): Drop redundant literal 0x from
HOST_WIDE_INT_PRINT_HEX formatting.
(dump_vtable): Likewise.

Signed-off-by: Peter Damianov <peter0x44@disroot.org>
2 weeks agoDaily bump.
GCC Administrator [Tue, 2 Jun 2026 00:16:46 +0000 (00:16 +0000)] 
Daily bump.

2 weeks agofortran: submodule cannot access internal subprograms of ancestor module via host...
Jerry DeLisle [Mon, 25 May 2026 16:29:33 +0000 (09:29 -0700)] 
fortran: submodule cannot access internal subprograms of ancestor module via host association

A submodule could not access internal subprograms of its ancestor module
via host association.  References to such procedures were rejected with
"has no IMPLICIT type".  Fortran 2018 §14.6.1.3 requires submodules to
host-associate the specification part and the module subprogram part of
their ancestor module; Intel Fortran and NAG Fortran accept this usage.

Root cause: when parse_module processes a submodule, gfc_current_ns->parent
is left NULL, so the host-association walk cannot reach the ancestor
module's namespace and its internal procedures.

Fix (parse.cc, parse_module): after use_modules() and gfc_traverse_ns(),
strip the child suffix from the submodule's dotted name (e.g. "m.s" -> "m"),
search gfc_global_ns_list for the matching ancestor namespace, and set
gfc_current_ns->parent to it.

Fix (parse.cc, clean_up_modules): before calling gfc_done_2(), reset
gfc_current_ns->parent to NULL to prevent gfc_symbol_done_2 from walking up
to and double-freeing the ancestor module namespace during teardown.

The new parent link also required boundary guards in three places that walk
up the namespace chain:

Fix (class.cc, gfc_find_derived_vtab): the vtab lookup walks up ns->parent
to find the top-level namespace.  Stop at module/submodule boundaries
(FL_MODULE flavor) so that vtables for types defined in a submodule are not
incorrectly placed in the ancestor module namespace.

Fix (openmp.cc, gfc_omp_requires_add_clause, gfc_match_omp_requires,
gfc_match_omp_atomic): three OpenMP helpers walk ns->parent to find the
enclosing program unit.  Each acquired the same boundary guard so the
submodule is treated as its own program unit for OMP REQUIRES purposes.

PR fortran/125527

Assisted by: Claude Sonnet 4.6

gcc/fortran/ChangeLog:

PR fortran/125527
* class.cc (gfc_find_derived_vtab): Stop the top-level namespace
walk at module/submodule boundaries to avoid escaping a submodule
into its ancestor module namespace.
* openmp.cc (gfc_omp_requires_add_clause): Likewise; treat the
submodule as its own program unit for OMP REQUIRES.
(gfc_match_omp_requires): Likewise; allow OMP REQUIRES in a submodule
spec part even when gfc_current_ns->parent is now non-NULL.
(gfc_match_omp_atomic): Likewise.
* parse.cc (parse_module): After processing USE statements and
host-association traversal, link the submodule namespace to its
ancestor module namespace so internal subprograms are visible via
host association (Fortran 2018, 14.6.1.3).
(clean_up_modules): Reset gfc_current_ns->parent before gfc_done_2
to prevent double-free of the ancestor module namespace.

gcc/testsuite/ChangeLog:

PR fortran/125527
* gfortran.dg/submodule_host_assoc_1.f90: New test.
* gfortran.dg/submodule_host_assoc_1_aux.f90: New test.

2 weeks agoc++: Fix spurious -Wduplicated-branches for new (nothrow) T[n] [PR125422]
Joe Natter [Thu, 21 May 2026 18:20:16 +0000 (20:20 +0200)] 
c++: Fix spurious -Wduplicated-branches for new (nothrow) T[n] [PR125422]

When allocating an array of a trivial type with new (nothrow),
build_new_1() may emit a compiler-generated COND_EXPR of the form

  (alloc_node != nullptr) ? rval : alloc_node

For trivial arrays without constructors, destructors, or array cookies,
rval remains equal to data_addr and is therefore equivalent to
alloc_node.  This causes both branches of the generated COND_EXPR to be
identical, triggering -Wduplicated-branches on user code.

Avoid building the null-check COND_EXPR when rval == data_addr.

gcc/cp/ChangeLog:
PR c++/125422
* init.cc (build_new_1): Avoid building a null-check
COND_EXPR when rval == data_addr.

gcc/testsuite/ChangeLog:
PR c++/125422
* g++.dg/warn/Wduplicated-branches10.C: New test.

Signed-off-by: Joe Natter <johannes.natter@outlook.at>
Reviewed-by: Jason Merrill <jason@redhat.com>
2 weeks agoc: fix false positive for -Wvla-parameter [PR98539]
Martin Uecker [Sat, 30 May 2026 14:30:50 +0000 (16:30 +0200)] 
c: fix false positive for -Wvla-parameter [PR98539]

In case of VLAs that are multi-dimensional arrays with unspecified sizes,
the test in the warning code did not work correctly.  Fix this by
explicitely checking that there are specified or unspecified size
expressions to determine the presence of a VLA.

PR c/98539

gcc/c-family/ChangeLog:
* c-warn.cc (warn_parm_array_mismatch): Check number of size
expressions.

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

2 weeks agotestsuite: xfail shrink-wrapping-vector-1.C until PR125400 is fixed
Andrew Pinski [Mon, 1 Jun 2026 19:50:50 +0000 (12:50 -0700)] 
testsuite: xfail shrink-wrapping-vector-1.C until PR125400 is fixed

After r17-603-gacfdad706d8acc, shrink-wrapping-vector-1.C started to
fail because of a missed optimization. So let's mark it as xfail
for the C++ versions where it fails (that is c++17 and down).

Pushed as obvious after testing to see if the testcase xfails correctly.

gcc/testsuite/ChangeLog:

* g++.dg/opt/shrink-wrapping-vector-1.C: xfail for C++17down.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
2 weeks agofortran: wrong generic resolution when actual argument is a procedure pointer
Jerry DeLisle [Tue, 26 May 2026 19:00:33 +0000 (12:00 -0700)] 
fortran: wrong generic resolution when actual argument is a procedure pointer

When a generic interface has two specific procedures -- one with a
procedure-pointer dummy and one with a data-object (e.g. REAL) dummy --
gfortran incorrectly resolved calls where the actual argument was a
procedure pointer to the data-object specific, resulting in the pointer
address being interpreted as a numeric value (wrong code).

The root cause was a missing check in gfc_compare_actual_formal: the
two existing checks guard the case where the formal is a proc_pointer
or FL_PROCEDURE but the actual is not; however the reverse direction
(actual is a proc_pointer but formal is a plain data object) was not
checked.  F23:15.5.2.5, para 2 forbids this pairing.

Assisted by: Claude Sonnet 4.6

gcc/fortran/ChangeLog:

PR fortran/125481
* interface.cc (gfc_compare_actual_formal): Add missing check that
rejects a procedure-pointer actual argument corresponding to a
data-object dummy argument (F23:15.5.2.5, para 2).  Restrict to
EXPR_VARIABLE to avoid false positives on calls through procedure
pointer components.

gcc/testsuite/ChangeLog:

PR fortran/125481
* gfortran.dg/generic_37.f90: New test.
* gfortran.dg/generic_38.f90: New test.

2 weeks agoPR target/122827: aarch64: Treat SVE modes as full-Z for callee-save accounting
Kyrylo Tkachov [Wed, 27 May 2026 20:47:48 +0000 (13:47 -0700)] 
PR target/122827: aarch64: Treat SVE modes as full-Z for callee-save accounting

PR122827 is a miscompile of 526.blender_r in SPEC2017 with
-Ofast -flto=auto -mcpu=neoverse-v2 -msve-vector-bits=128 --param aarch64-autovec-preference=sve-only.
Bisection landed on g:b191e8bdecf (the IRA cost-model rework for PR117477), and the
miscompile disappears with -mearly-ra=none, -fno-caller-saves, or
-fno-early-ra, all of which steer register allocation away from V8-V15.

The bug is in shade_material_loop in shadeinput.c, where a broadcast of
a float scalar to a VNx2SF value is held in V14 across a call:

    mov     z14.s, s15            ; broadcast s15 -> all 4 .s lanes of z14
    ...
    bl      shade_lamp_loop       ; clobbers V14[127:64]
    ...
    fmla    z20.s, p7/m, z14.s, z21.s   ; reads all 4 .s lanes of z14

Under AAPCS64 only the low 64 bits of V8-V15 (D8-D15) are callee-saved.
The prologue dutifully saves d14/d15, but the broadcast and FMA both
touch the full Z register, and the upper half of v14 gets corrupted by
the call -- producing wrong floating-point results.

VNx2SF has GET_MODE_SIZE == 8, so the previous part-clobber check
treated V14 as fully preserved for that mode.  The mode size is
correct for the *data* (two 32-bit lanes), but the underlying SVE
instructions are not packed -- the two .s lanes live at byte offsets
0-3 and 8-11 of the Z register (the .d-strided layout used for partial
SVE modes), so byte 8 onwards is outside the AAPCS64-preserved range.
Any SVE mode in V8-V15 across a call is therefore partially clobbered,
regardless of GET_MODE_SIZE.

The change in g:b191e8bdecf made the cost of allocating a callee-saved
register low enough that IRA started picking V14 for these pseudos,
exposing the latent miscompile.

Two places need fixing:

  * aarch64_hard_regno_call_part_clobbered uses GET_MODE_SIZE to decide
    whether the callee-preserved low 64 bits are enough for the value.
    For SVE modes, compare against BYTES_PER_SVE_VECTOR instead: any
    SVE mode physically uses the full Z register.

  * early-RA classifies allocno groups into FPR_D/FPR_Q/FPR_Z by mode
    bit size, and partial_fpr_clobbers then maps FPR_D to V8QImode for
    the ABI check.  That synthetic V8QImode hides the fact that the
    pseudo is actually an SVE mode, so V8-V15 are not excluded from the
    candidate set.  Classify any SVE mode as FPR_Z so that
    partial_fpr_clobbers uses VNx16QImode and correctly removes V8-V15.

A new test is added in gcc.target/aarch64/sve/pr122827.c
Before the fix the execution test aborts (V14 is allocated to the broadcast
across the call, and the explicit clobber inside the callee corrupts its upper
lanes). after the fix it passes.

Explicitly clobbering V14 with inline assembly in the test may be a bit fragile
as it depends on RA picking V14 for the pre-call broadcast to trigger the bug
but I couldn't find a good way of generalising it without perturbing RA in ways
that made the bug not trigger.

With this patch blender passes again and no regressions on
aarch64-none-linux-gnu bootstrap.

Signed-off-by: Kyrylo Tkachov <ktkachov@nvidia.com>
gcc/ChangeLog:

PR target/122827
* config/aarch64/aarch64.cc (aarch64_hard_regno_call_part_clobbered):
For SVE modes use BYTES_PER_SVE_VECTOR for the per-register size
rather than GET_MODE_SIZE.
* config/aarch64/aarch64-early-ra.cc (early_ra::get_allocno_subgroup):
Classify any SVE mode as FPR_Z.

gcc/testsuite/ChangeLog:

PR target/122827
* gcc.target/aarch64/sve/pr122827.c: New test.

2 weeks agoc++/modules: Add reflection in module dialect.
yxj-github-437 [Sat, 30 May 2026 08:41:01 +0000 (16:41 +0800)] 
c++/modules: Add reflection in module dialect.

Some ICE will occur when reflection codes compile without
-freflection but the std module built with -freflection.
So the module dialect should include reflection.

gcc/cp/ChangeLog:
* module.cc (module_state_config::get_dialect): Add reflection
dialect.

Reviewed-by: Jason Merrill <jason@redhat.com>
2 weeks agoc++: > in requires in template argument [PR125317]
Eczbek [Fri, 22 May 2026 16:57:09 +0000 (12:57 -0400)] 
c++: > in requires in template argument [PR125317]

PR c++/125317

gcc/cp/ChangeLog:

* parser.cc (cp_parser_requirement_body): Set
parser->greater_than_is_operator_p.

gcc/testsuite/ChangeLog:

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

Reviewed-by: Jason Merrill <jason@redhat.com>
2 weeks agoaarch64: Adjust vectorizer loads+store issue info for Olympus
Kyrylo Tkachov [Mon, 1 Jun 2026 16:00:48 +0000 (09:00 -0700)] 
aarch64: Adjust vectorizer loads+store issue info for Olympus

After some more experimentation and evaluation I'm adjusting the
Olympus issue numbers. This unlocks more vector unrolling that's
beneficial for that core.

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

Signed-off-by: Kyrylo Tkachov <ktkachov@nvidia.com>
* config/aarch64/tuning_models/olympus.h (olympus_scalar_issue_info,
olympus_advsimd_issue_info, olympus_sve_issue_info): Set
loads_stores_per_cycle to 6.

2 weeks agoaarch64: Adjust alignment tunings for Olympus
Kyrylo Tkachov [Sun, 31 May 2026 09:05:56 +0000 (02:05 -0700)] 
aarch64: Adjust alignment tunings for Olympus

After some more benchmarking and evaluation I'd like to increase the alignments
needed for -mcpu=olympus.  All three of loop_align, function_align and
jump_align are needed to get a good mix of improvements.  I've added skip
amounts to keep the code size bloat down.  There is some, but the performance
benefit on -mcpu=olympus binaries is worth it (cpython from SPEC2026 in
particular benefits consistently).

As an aside, I do think we'll want a more fine-grained description of alignment
in our CPU tuning structs for -O3 binaries.  -O3 may be willing to pay the
extra padding cost for speed-tuned functions and loops and may want to avoid
the skip amount if the CPU is good enough at skipping past them.
But the -O2 settings may still want to use skip amount to avoid excessive
distro binary bloat.

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

Signed-off-by: Kyrylo Tkachov <ktkachov@nvidia.com>
gcc/ChangeLog

* config/aarch64/tuning_models/olympus.h (olympus_tunings):
Adjust loop_align, function_align, jump_align.

2 weeks agoRegenerate c.opt.urls
Mark Wielaard [Mon, 1 Jun 2026 16:22:20 +0000 (18:22 +0200)] 
Regenerate c.opt.urls

Regenerate opt.urls for deprecation (and removal) of -Wstrict-overflow.

Fixes: b31a43560e88 ("gcc: finalize deprecation of -Wstrict-overflow")
gcc/c-family/ChangeLog:

* c.opt.urls: Regenerate.

2 weeks agoRe-flow lines made longer than 80 characters by typo fixes
Dhruv Chawla [Wed, 27 May 2026 12:28:38 +0000 (12:28 +0000)] 
Re-flow lines made longer than 80 characters by typo fixes

Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com>
gcc/ChangeLog:

* config/arm/arm-mve-builtins-shapes.cc (struct viddup_def):
Re-flow comment.
(struct vidwdup_def): Likewise.
* config/arm/arm.cc (arm_mve_check_reg_origin_is_num_elems): Likewise.
* config/loongarch/sync.md: Likewise.
* config/microblaze/microblaze.cc (compute_frame_size): Likewise.
* config/rs6000/rs6000-call.cc (rs6000_gimplify_va_arg): Likewise.

2 weeks agolibstdc++: Fix typos in os/vxworks/os_defines.h
Dhruv Chawla [Thu, 21 May 2026 12:29:54 +0000 (12:29 +0000)] 
libstdc++: Fix typos in os/vxworks/os_defines.h

Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com>
libstdc++-v3/ChangeLog:

* config/os/vxworks/os_defines.h: Fix typos.

2 weeks agolibitm: Fix typo in config/linux/futex_bits.h
Dhruv Chawla [Thu, 21 May 2026 12:29:05 +0000 (12:29 +0000)] 
libitm: Fix typo in config/linux/futex_bits.h

Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com>
libitm/ChangeLog:

* config/linux/futex_bits.h: Fix typo.

2 weeks agolibgomp: Fix typos in various files
Dhruv Chawla [Thu, 21 May 2026 12:28:26 +0000 (12:28 +0000)] 
libgomp: Fix typos in various files

Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com>
libgomp/ChangeLog:

* config/gcn/simple-bar.h: Fix typos.
* config/linux/futex.h: Likewise.
* config/nvptx/bar.c (gomp_team_barrier_cancel): Likewise.
* config/nvptx/bar.h (gomp_team_barrier_wake): Likewise.
* config/nvptx/simple-bar.h: Likewise.
* config/posix/sem.c: Likewise.
* config/posix/sem.h: Likewise.
* config/posix/simple-bar.h: Likewise.

2 weeks agolibatomic: Fix typos in various files
Dhruv Chawla [Thu, 21 May 2026 11:48:48 +0000 (11:48 +0000)] 
libatomic: Fix typos in various files

Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com>
libatomic/ChangeLog:

* config/mingw/lock.c: Fix typos.
* config/posix/lock.c: Likewise.

2 weeks agogcc/config: Fix typos in various files
Dhruv Chawla [Thu, 21 May 2026 11:48:10 +0000 (11:48 +0000)] 
gcc/config: Fix typos in various files

Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com>
gcc/ChangeLog:

* config/darwin-c.cc (find_subframework_header): Fix typos.
* config/darwin-driver.cc (darwin_find_version_from_kernel): Likewise.
* config/darwin.cc (darwin_label_is_anonymous_local_objc_name): Likewise.
(fprintf): Likewise.
* config/sol2-stubs.cc: Likewise.
* config/sol2.cc (solaris_elf_asm_comdat_section): Likewise.
* config/sol2.h: Likewise.
* config/vx-common.h: Likewise.
* config/vxworks.h (vxworks_asm_out_destructor): Likewise.

2 weeks agoxtensa: Fix typo in xtensa.cc
Dhruv Chawla [Thu, 21 May 2026 11:46:41 +0000 (11:46 +0000)] 
xtensa: Fix typo in xtensa.cc

Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com>
gcc/ChangeLog:

* config/xtensa/xtensa.cc (xtensa_legitimize_address): Fix typos.

2 weeks agovms: Fix typos in various files
Dhruv Chawla [Thu, 21 May 2026 11:46:13 +0000 (11:46 +0000)] 
vms: Fix typos in various files

Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com>
gcc/ChangeLog:

* config/vms/vms-c.cc (enum extern_model_kind): Fix typos.
(vms_pragma_message): Likewise.
(vms_c_register_includes): Likewise.
* config/vms/vms.cc (vms_function_section): Likewise.

2 weeks agovisium: Fix typos in visium.h
Dhruv Chawla [Thu, 21 May 2026 11:45:24 +0000 (11:45 +0000)] 
visium: Fix typos in visium.h

Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com>
gcc/ChangeLog:

* config/visium/visium.h (CASE_VECTOR_PC_RELATIVE): Fix typos.

2 weeks agovax: Fix typos in various files
Dhruv Chawla [Thu, 21 May 2026 11:44:47 +0000 (11:44 +0000)] 
vax: Fix typos in various files

Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com>
gcc/ChangeLog:

* config/vax/vax.cc (vax_expand_addsub_di_operands): Fix typos.
* config/vax/vax.h (PRINT_OPERAND_ADDRESS): Likewise.

2 weeks agosparc: Fix typos in various files
Dhruv Chawla [Thu, 21 May 2026 11:44:03 +0000 (11:44 +0000)] 
sparc: Fix typos in various files

Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com>
gcc/ChangeLog:

* config/sparc/freebsd.h: Fix typos.
* config/sparc/sparc.cc (emit_scc_insn): Likewise.
(sparc_emit_membar_for_model): Likewise.

2 weeks agosh: Fix typos in various files
Dhruv Chawla [Wed, 20 May 2026 13:01:51 +0000 (13:01 +0000)] 
sh: Fix typos in various files

Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com>
gcc/ChangeLog:

* config/sh/sh-mem.cc (sh_expand_cmpstr): Fix typos.
* config/sh/sh.cc (sh_option_override): Likewise.
(sh_rtx_costs): Likewise.
(fixup_addr_diff_vecs): Likewise.
(sh_expand_epilogue): Likewise.
(sh_legitimize_address_displacement): Likewise.
(sh_can_use_simple_return_p): Likewise.
(sh_find_equiv_gbr_addr): Likewise.
(sh_check_add_incdec_notes): Likewise.
* config/sh/sh.md: Likewise.
* config/sh/sh4-300.md: Likewise.
* config/sh/sh_treg_combine.cc (sh_treg_combine::try_combine_comparisons): Likewise.
(sh_treg_combine::try_eliminate_cstores): Likewise.
* config/sh/sync.md: Likewise.

2 weeks agorx: Fix typos in rx.cc and rx.md
Dhruv Chawla [Wed, 20 May 2026 12:16:11 +0000 (12:16 +0000)] 
rx: Fix typos in rx.cc and rx.md

Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com>
gcc/ChangeLog:

* config/rx/rx.cc (rx_print_operand): Fix typos.
(rx_expand_epilogue): Likewise.
* config/rx/rx.md: Likewise.

2 weeks agos390: Fix typos in various files
Dhruv Chawla [Wed, 20 May 2026 12:14:09 +0000 (12:14 +0000)] 
s390: Fix typos in various files

Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com>
gcc/ChangeLog:

* config/s390/2817.md: Fix typos.
* config/s390/s390.cc (s390_contiguous_bitmask_nowrap_p): Likewise.
(s390_contiguous_bitmask_p): Likewise.
(s390_short_displacement): Likewise.
(s390_expand_cmpmem): Likewise.
(s390_expand_vec_movstr): Likewise.
(s390_expand_cstoreti4): Likewise.
(s390_expand_int_spaceship): Likewise.
(s390_z10_optimize_cmp): Likewise.
(s390_support_vector_misalignment): Likewise.
* config/s390/s390.h (NO_FUNCTION_CSE): Likewise.
* config/s390/s390.md: Likewise.
* config/s390/subst.md: Likewise.
* config/s390/vx-builtins.md: Likewise.

libgcc/ChangeLog:

* config/s390/tpf-unwind.h (s390_fallback_frame_state): Likewise.

2 weeks agors6000: Fix typos in various files
Dhruv Chawla [Wed, 20 May 2026 12:11:37 +0000 (12:11 +0000)] 
rs6000: Fix typos in various files

Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com>
gcc/ChangeLog:

* config/rs6000/aix.h: Fix typos.
* config/rs6000/cell.md: Likewise.
* config/rs6000/darwin.h: Likewise.
* config/rs6000/mmintrin.h: Likewise.
* config/rs6000/rs6000-call.cc (rs6000_gimplify_va_arg): Likewise.
* config/rs6000/rs6000-internal.h: Likewise.
* config/rs6000/rs6000-logue.cc (is_altivec_return_reg): Likewise.
(rs6000_output_function_prologue): Likewise.
* config/rs6000/rs6000-p8swap.cc (quad_aligned_store_p): Likewise.
(const_load_sequence_p): Likewise.
(replace_swapped_aligned_store): Likewise.
* config/rs6000/rs6000-passes.def: Likewise.
* config/rs6000/rs6000-string.cc (expand_cmp_vec_sequence): Likewise.
(expand_compare_loop): Likewise.
* config/rs6000/rs6000.cc (rs6000_debug_addr_mask): Likewise.
(rs6000_setup_reg_addr_masks): Likewise.
(darwin_rs6000_override_options): Likewise.
(rs6000_option_override_internal): Likewise.
(rs6000_cost_data::determine_suggested_unroll_factor): Likewise.
(rs6000_cannot_force_const_mem): Likewise.
(rs6000_emit_le_vsx_move): Likewise.
(rs6000_secondary_reload_memory): Likewise.
(rs6000_reverse_condition): Likewise.
(rs6000_expand_float128_convert): Likewise.
(rs6000_adjust_atomic_subword): Likewise.
(rs6000_expand_atomic_op): Likewise.
(rs6000_xcoff_declare_object_name): Likewise.
(output_pcrel_opt_reloc): Likewise.
(rs6000_set_up_by_prologue): Likewise.
(rs6000_split_logical_inner): Likewise.
(rs6000_split_multireg_move): Likewise.
* config/rs6000/rs6000.h: Likewise.
* config/rs6000/rs6000.md: Likewise.
* config/rs6000/sync.md: Likewise.
* config/rs6000/vector.md: Likewise.
* config/rs6000/vsx.md: Likewise.
* config/rs6000/vxworks.h: Likewise.

2 weeks agorl78: Fix typos in various files
Dhruv Chawla [Wed, 20 May 2026 12:07:05 +0000 (12:07 +0000)] 
rl78: Fix typos in various files

Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com>
gcc/ChangeLog:

* config/rl78/rl78.cc (rl78_alloc_physical_registers): Fix typos.
(set_origin): Likewise.
(rl78_remove_unused_sets): Likewise.

2 weeks agopdp11: Fix typo in pdp11.cc
Dhruv Chawla [Wed, 20 May 2026 12:06:21 +0000 (12:06 +0000)] 
pdp11: Fix typo in pdp11.cc

Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com>
gcc/ChangeLog:

* config/pdp11/pdp11.cc (pdp11_insn_cost): Fix typo.

2 weeks agoriscv: Fix typos in various files
Dhruv Chawla [Wed, 20 May 2026 12:05:56 +0000 (12:05 +0000)] 
riscv: Fix typos in various files

Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com>
gcc/ChangeLog:

* common/config/riscv/riscv-common.cc (riscv_subset_list::add): Fix
typos.
(riscv_subset_list::parse_single_multiletter_ext): Likewise.
(riscv_subset_list::set_loc): Likewise.
(riscv_arch_str): Likewise.
* config/riscv/riscv-avlprop.cc: Likewise.
* config/riscv/riscv-bclr-lowest-set-bit.cc (find_later_ctz): Likewise.
* config/riscv/riscv-ext-andes.def: Likewise.
* config/riscv/riscv-ext.def: Likewise.
* config/riscv/riscv-profiles.def: Likewise.
* config/riscv/riscv-selftests.cc (run_const_vector_selftests): Likewise.
(run_broadcast_selftests): Likewise.
(riscv_run_selftests): Likewise.
* config/riscv/riscv-string.cc (riscv_expand_strcmp): Likewise.
* config/riscv/riscv-v.cc (shuffle_decompress_patterns): Likewise.
(vls_mode_valid_p): Likewise.
* config/riscv/riscv-vect-permconst.cc (vector_permconst::process_bb): Likewise.
* config/riscv/riscv-vector-builtins.cc (riscv_pragma_intrinsic_flags_pollute): Likewise.
* config/riscv/riscv-vsetvl.cc: Likewise.
* config/riscv/riscv-zicfilp.cc: Likewise.
* config/riscv/riscv.cc (riscv_expand_mult_with_const_int): Likewise.
(riscv_rtx_costs): Likewise.
(riscv_address_cost): Likewise.
(riscv_vls_cc_function_abi): Likewise.
(riscv_frm_mode_needed): Likewise.
(dispatch_function_versions): Likewise.
* config/riscv/riscv.h (DWARF_REG_TO_UNWIND_COLUMN): Likewise.
* config/riscv/riscv.md: Likewise.

2 weeks agopa: Fix typos in pa.cc
Dhruv Chawla [Wed, 20 May 2026 11:59:15 +0000 (11:59 +0000)] 
pa: Fix typos in pa.cc

Signed-off-by: Dhruv Chawla <dhruvc@nvidia.com>
gcc/ChangeLog:

* config/pa/pa.cc (pa_assemble_integer): Fix typos.
(pa_can_change_mode_class): Likewise.

libgcc/ChangeLog:

* config/pa/linux-atomic.c: Fix typos.
* config/pa/sync-libfuncs.c: Likewise.