]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
4 weeks agoada: Update references to Parameter Associations RM 6.4.1
Denis Mazzucato [Tue, 20 Jan 2026 11:54:02 +0000 (12:54 +0100)] 
ada: Update references to Parameter Associations RM 6.4.1

AI12-0095-1 added a paragraph after RM 6.4.1(6.3/3), all the subsequent RM
references within 6.x may be off by one; this patch updates those references.

gcc/ada/ChangeLog:

* sem_util.adb: Fix RM references.
* sem_util.ads: Likewise.
* sem_warn.adb: Likewise.

4 weeks agoada: Set Etype before analysis for conditions generated for 'Old
Martin Clochard [Tue, 20 Jan 2026 16:44:13 +0000 (17:44 +0100)] 
ada: Set Etype before analysis for conditions generated for 'Old

The absence of Etype decoration is problematic for GNATprove, which
cannot use analyze to fill the blanks in the output.

gcc/ada/ChangeLog:

* sem_util.adb (As_Boolean): utility to fill decoration in expressions
(Determining_Condition): set Etype for generated Boolean connectors
(Conditional_Evaluation_Condition): set Etype for generated connectors

4 weeks agoada: Formal function default given by expression rejected with -gnatX
Gary Dismukes [Tue, 20 Jan 2026 22:35:50 +0000 (22:35 +0000)] 
ada: Formal function default given by expression rejected with -gnatX

The compiler should be allowing formal functions to be defaulted by
an expression when the core extensions are enabled, but it was
requiring all extensions to be enabled.

gcc/ada/ChangeLog:

* par-ch12.adb (P_Formal_Subprogram_Declaration): Pass True for
the Is_Core_Extension parameter on call to Error_Msg_GNAT_Extension.

4 weeks agoada: Reject pragma CPU and Priority that duplicate corresponding aspects
Piotr Trojanek [Mon, 19 Jan 2026 22:04:10 +0000 (23:04 +0100)] 
ada: Reject pragma CPU and Priority that duplicate corresponding aspects

When a main subprogram had its CPU or priority specified first by an aspect
specification and then by a corresponding pragma, then the pragma was silently
ignored. Now such a pragma is rejected.

gcc/ada/ChangeLog:

* sem_ch13.adb (Analyze_Aspect_Specifications): Record aspect CPU and
Priority applied to subprogram as a representation item.

4 weeks agoada: Reject exceptional contracts on No_Raise subprograms
Claire Dross [Fri, 16 Jan 2026 16:02:50 +0000 (17:02 +0100)] 
ada: Reject exceptional contracts on No_Raise subprograms

Rejectd the SPARK-specific exceptional contract pragmas Exceptional_Cases and
Exit_Cases when they are not compatible with the No_Raise GNAT-specific aspect.

gcc/ada/ChangeLog:

* sem_prag.adb (Analyze_Exit_Contract): The Exception_Raised exit kind
is not compatible with No_Raise.
(Analyze_Pragma): The Exceptional_Cases pragma is not compatible with
No_Raise.

4 weeks agoada: Fix crash on declare expression in contract on access to subprogram type
Eric Botcazou [Tue, 20 Jan 2026 09:09:23 +0000 (10:09 +0100)] 
ada: Fix crash on declare expression in contract on access to subprogram type

As documented at the end of gen_il-gen-gen_entities.adb, E_Subprogram_Type
is part of Scope_Kind but, unlike what is said, it lacks Scope_Depth_Value.

gcc/ada/ChangeLog:

* gen_il-gen-gen_entities.adb (E_Subprogram_Type): Add the missing
Scope_Depth_Value field.

4 weeks agoada: Fix fallout of recent freezing change for expression functions
Eric Botcazou [Sun, 18 Jan 2026 21:12:25 +0000 (22:12 +0100)] 
ada: Fix fallout of recent freezing change for expression functions

The change unnecessarily prevents the profile of all dispatching operations
from being frozen by their subprogram body, which exposes a weakness in the
implementation of freezing for generic units.  This just reverts that part.

gcc/ada/ChangeLog:

PR ada/93702
* exp_ch3.adb (Make_Controlling_Function_Wrappers): Revert latest
change.
* sem_ch12.adb (Analyze_One_Association): Remove redundant line.
* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Freeze the profile
again for bodies that are not generated from expression functions.

4 weeks agoada: Spurious error on formals with First_Controlling_Parameter type
Javier Miranda [Fri, 16 Jan 2026 17:11:55 +0000 (17:11 +0000)] 
ada: Spurious error on formals with First_Controlling_Parameter type

This patch fixes a spurious error reported by the frontend when
a dispatching primitive of a tagged type has additional formals
with types that have the First_Controlling_Parameter aspect.

gcc/ada/ChangeLog:

* sem_disp.adb (Check_Controlling_Formals): Formals of a type
specifying aspect First_Controlling_Parameter are not candidate
controlling parameters when they are not the first formal of
the dispatching primitive.

4 weeks agoada: Unsupported C++ constructor call in array aggregate
Javier Miranda [Thu, 15 Jan 2026 20:49:28 +0000 (20:49 +0000)] 
ada: Unsupported C++ constructor call in array aggregate

This patch adds support for C++ constructor calls in array aggregates.

gcc/ada/ChangeLog:

* exp_ch5.adb (Expand_N_Assignment_Statement): Handle internally
generated initialization invoking a C++ constructor.

4 weeks agoada: Fix early freezing of tagged type by expression function in nested package
Eric Botcazou [Tue, 13 Jan 2026 19:00:28 +0000 (20:00 +0100)] 
ada: Fix early freezing of tagged type by expression function in nested package

This addresses a long-standing issue in the implementation of expression
functions of Ada 2012, pertaining to their interaction with the freezing
of types that are referenced in their expression: when they are used as
the completion of a function declaration, their expression causes these
types to become frozen, but when they are stand-alone, it does not.

The last rule is problematic for GNAT, because it goes against its freezing
model devised for Ada 95, where types must always be frozen for code to be
generated.  Therefore the current implementation needs to resort to several
kludges in order to implement it, but these are not bullet proof and do not
always work when tagged types are involved.

The new approach is to insert the generated body of stand-alone expression
functions at the next freezing point, instead of at the end of the current
package.  This makes a difference for nested packages, which are precisely
the problematic case.  This requires the analysis and resolution performed
on the body, potentially out of context now, to give identical results as
the preanalysis and resolution performed on the expression in its context,
which is achieved by treating the generated body as an inlined body.

This approach requires a more complete implementation of the special rules
for freezing expression functions, so the change overhauls it and plugs the
most blatant loopholes of the current implementation.

gcc/ada/ChangeLog:

PR ada/93702
* contracts.adb (Analyze_Entry_Or_Subprogram_Contract): Call
Freeze_Expr_Types_Before instead of Freeze_Expr_Types.
(Process_Preconditions_For): Likewise.
* exp_ch3.adb (Make_Controlling_Function_Wrappers): Do not set
Was_Expression_Function flag on the generated bodies.
* exp_ch6.adb (Expand_Call_Helper): Call Original_Node on the
result of the call to Expression_Of_Expression_Function.
* freeze.ads (Freeze_Expr_Types): Delete.
(Freeze_Expr_Types_Before): New procedure declaration.
* freeze.adb (Check_Expression_Function): Delete.
(Freeze_And_Append): Add Do_Freeze_Profile formal parameter and
pass it to Freeze_Entity.  Remove call to Check_Expression_Function.
(Freeze_Entity): Set Test_E consistently and freeze the expression
of expression functions that are primitives of a tagged type.
(Freeze_Profile): Adjust calls to Should_Freeze_Type.
(In_Expanded_Body): Also return true for DIC procedures.
(Freeze_Expression): Remove call to Check_Expression_Function.
Freeze the expression of expression functions.
(Freeze_Expr_Types): Add Result and Before formal parameters.
Make a copy and preanalyze/resolve it only if Typ is present.
(Freeze_Expr_Types.Explain_Error): New procedure.
(Freeze_Expr_Types.Find_Incomplete_Constant): Likewise.
(Freeze_Expr_Types.Check_And_Freeze_Type): Return immediately if
the type is already frozen.  Report errors on N instead of Node.
If Before is False, append the freeze nodes to Result.
(Freeze_Expr_Types.Freeze_Type_Refs): Call Find_Incomplete_Constant.
(Freeze_Expr_Types_Before): New procedure.
(Should_Freeze_Type): Remove formal parameter E and
specific kludge for stand-alone expression functions.
* ghost.ads (Mark_And_Set_Ghost_Body_Of_Expression_Function): New
procedure declaration.
* ghost.adb (Mark_And_Set_Ghost_Body_Of_Expression_Function): New
procedure body.
* rtsfind.adb (RTE): Preserve and reset the In_Inlined_Body flag.
(RTE_Record_Component): Likewise.
* sem_attr.adb (Resolve_Attribute) <Attribute_Access>: Just call
Freeze_Expression to freeze the expression of prefixes that are
expression functions and remove obsolete implementation.
* sem_ch3.adb (Analyze_Declarations): Adjust commentary.
(Check_Completion): Also skip stand-alone expressions functions.
* sem_ch4.adb (Analyze_Case_Expression): Always analyze the choices.
* sem_ch6.adb: Add with and use clauses for Sem_Ch7.
(Analyze_Expression_Function): Call Freeze_Expr_Types_Before instead
of Freeze_Expr_Types for expression functions that are completions.
For stand-alone expression functions, set In_Private_Part on the
entity if it is in the private part, propagate the results of the
resolution of the specification of the the declaration to that of
the body and insert the body at the next freezing point.
(Analyze_Subprogram_Body_Helper): Remove the machinery for masking
and unmasking unfrozen types. For a stand-alone expression function,
call Mark_And_Set_Ghost_Body_Of_Expression_Function, remove obsolete
code dealing with the freezing of the spec, set In_Inlined_Body to
True, make the full view of the private types of its scope visible
if this is not the current scope and it is in the private part, and
avoid making the spec immediately visible.
(Analyze_Subprogram_Specification): Fix typo.
(New_Overloaded_Entity): Set Has_Completion on a [generic] package
that conflicts with the entity to prevent a cascaded error.
* sem_ch7.ads (Is_Private_Base_Type): New function declaration moved
here from...
* sem_ch7.adb (Is_Private_Base_Type): ...here.  Remove.
* sem_ch8.adb (Analyze_Subprogram_Renaming): Call Freeze_Expression
to freeze the expression of expression functions, but only if the
renaming comes from source.
* sem_ch12.adb (Analyze_One_Association): Likewise, and remove the
manual freezing for calls to them.
* sem_res.adb (Resolve): Remove obsolete commentary.
(Resolve_Call): Always freeze the expression of names that are
expression functions.
* sem_util.adb (Check_Fully_Declared): Add commentary and do not
check types with private component declared outside of the current
scope when it is a generic unit.
(Expression_Of_Expression_Function): Return Expression directly.
(Is_Inlinable_Expression_Function): Call Original_Node on the
result of the call to Expression_Of_Expression_Function.

4 weeks agoada: Fix fallout of latest change to Analyze_Subprogram_Renaming
Eric Botcazou [Fri, 16 Jan 2026 18:55:07 +0000 (19:55 +0100)] 
ada: Fix fallout of latest change to Analyze_Subprogram_Renaming

Replacing the original expression by Expression_Of_Expression_Function is
not fully equivalent because Expression_Of_Expression_Function returns the
Original_Node of the expression.

gcc/ada/ChangeLog:

* sem_ch8.adb (Analyze_Subprogram_Renaming): Retrieve again the
expression of the expression function manually.

4 weeks agoada: Small tweak to error message for premature freezing of deferred constant
Eric Botcazou [Thu, 15 Jan 2026 23:31:16 +0000 (00:31 +0100)] 
ada: Small tweak to error message for premature freezing of deferred constant

The tweak is to add the name of the constant to the error message.  That's
a minor improvement in this simple case, but it will help for the same error
in a more complex case.

gcc/ada/ChangeLog:

* sem_res.adb (Resolve_Entity_Name): Add the name of the constant
to the error message for premature freezing of deferred constants.

4 weeks agoada: Missing contract checks for calls to formal subprograms within instances
Gary Dismukes [Thu, 15 Jan 2026 20:40:28 +0000 (20:40 +0000)] 
ada: Missing contract checks for calls to formal subprograms within instances

While working on a visibility bug, it was noticed that preconditions
on formal subprograms are not being checked on calls to the subprograms
within package instantiations.  The wrapper subprogram that is created to
perform the check (and invoke the actual subprogram) was not being used
as the target of calls, and the actual subprogram is being called instead
(bypassing the check).  This was due to the subprogram renaming created
(for the actual-to-formal association) and the wrapper being homographs,
and the loop over interpretations in Collect_Interps happening to resolve
calls to the actual instead of the wrapper.  This wrong resolution is
avoided by removing the homographic subprogram renaming, so that the
resolution can only resolve to the wrapper (which will only include
the precondition check in the case where assertions are enabled).

gcc/ada/ChangeLog:

* sem_ch12.adb (Build_Subprogram_Wrapper): Remove the subprogram
renaming created for the formal-to-actual association from the
list of renamings (only when such a subprogram renaming is present).
Also, change the name from plural to singular, since the procedure
only creates one wrapper, update the spec comment to reflect that,
and clarify the state and use of the Renamings parameter.

4 weeks agoada: Fix Ghost => True/False for Abstract_State
Viljar Indus [Thu, 15 Jan 2026 08:41:59 +0000 (10:41 +0200)] 
ada: Fix Ghost => True/False for Abstract_State

Ensure that an Assertion_Level is assigned when Ghost => True is
used for Abstract_State.

Add an error if Ghost => False is used on an Abstract_State within
a ghost pacakage.

Add an error if the expression used for Ghost is not static.

gcc/ada/ChangeLog:

* sem_prag.adb (Analyze_Abstract_State): Improve handling of
True/False for Abstract_State with Ghost.

4 weeks agoada: Fix Initialize aspect for constructors
Denis Mazzucato [Fri, 9 Jan 2026 15:04:57 +0000 (16:04 +0100)] 
ada: Fix Initialize aspect for constructors

This patch improve the analysis for the Initialize aspect in constructor bodies.
Specifically:
- Assignments based on the Initialize aspect are always placed at the end of the
  constructor prologue, otherwise they could be overwritten depending on the
  original order of components.
- Introduce the "others" default choice for the Initialize aggregate.
- Improve diagnostics when the Initialize aspect is clearly misspelled.
- Flag components that are required to be initialized but are missing from the
  Initialize aspect.
- Check whether aggregate choices refer to ancestors, which is not allowed.

gcc/ada/ChangeLog:

* exp_ch3.adb (Build_Implicit_Parameterless_Constructor): Add Initialize
aspect with default others to trigger Initialize aspect analysis.
* exp_ch6.adb (Prepend_Constructor_Procedure_Prologue): Fix
initialization order.
(Init_From_Initialize_Expression): Retrieve initialization expression or
the default one base on the Initialize aspect.
(Init_From_Default_Or_Constructor):. Retrieve initialization expression
based on the default one in the record initialization list or the init
procedure.
* sem_ch13.adb (Analyze_Aspect_Specifications): Add check for
missing components that require initialization, and add an
expression_with_action node to place ABE during resolution of
aggregates with function calls.
(Check_Constructor_Choices): Helper to check that the aggregate choices
do not refer to ancestors.
(Diagnose_Misplaced_Aspects): Improve diagnostics when it is a clear
misspelling of Initialize aspect.
* sem_ch6.adb (Analyze_Direct_Attribute_Definition): If missing, add a
compiler generated Initialize aspect with default others to trigger
Initialize analysis.

4 weeks agoada: More tweaks to semantic analysis of expression functions
Eric Botcazou [Wed, 14 Jan 2026 17:01:54 +0000 (18:01 +0100)] 
ada: More tweaks to semantic analysis of expression functions

They are exclusively about streamlining the implementation, so there should
be no functional changes.

gcc/ada/ChangeLog:

* contracts.adb (Has_Public_Visibility_Of_Subprogram): Use Subp_Id
throughout and Is_Expression_Function to spot expression functions.
* ghost.adb (Is_OK_Declaration): Likewise.
* sem_ch12.adb (Analyze_One_Association): Likewise.
* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Likewise.
(Analyze_Subprogram_Specification): Fix typo.
(Find_Corresponding_Spec): Call Is_Expression_Function.
* sem_ch8.adb (Analyze_Subprogram_Renaming): Retrieve the expression
by means of Expression_Of_Expression_Function.
* sem_res.adb (Resolve_Allocator): Call Is_Expression_Function.
(Rewrite_Renamed_Operator): Likewise.
* sem_util.adb (Expression_Of_Expression_Function): Streamline the
the implementation.
(Is_Expression_Function): Likewise.

4 weeks agoada: Fix incorrect finalization of renamed function call at library level
Eric Botcazou [Mon, 12 Jan 2026 20:45:44 +0000 (21:45 +0100)] 
ada: Fix incorrect finalization of renamed function call at library level

This is a regression present in recent releases for the peculiar case of the
renaming of a controlled function call done at library level, which causes
the compiler to create a dangling reference to a temporary created on the
stack of the elaboration routine to hold the result of the function call.

gcc/ada/ChangeLog:

* exp_ch6.adb (Expand_Ctrl_Function_Call): Bail out for the name
of an object renaming declaration at library level, if the call
does not return on the secondary stack.
* exp_ch8.adb (Expand_N_Object_Renaming_Declaration): Rewrite the
renaming as a regular object declaration if it is declared at
library level and the name is a controlled function call whose
result is not returned on the secondary stack.
* exp_util.adb (Rewrite_Object_Declaration_As_Renaming): Minor fix.

4 weeks agoada: Handle call to C++ constructor in generic instantiation
Javier Miranda [Mon, 12 Jan 2026 13:48:04 +0000 (13:48 +0000)] 
ada: Handle call to C++ constructor in generic instantiation

Add missing support for C++ constructor call passed as a generic
formal subprogram parameter.

gcc/ada/ChangeLog:

* sem_ch3.adb (Analyze_Subtype_Declaration): Record subtypes
inherit the CPP_Class attribute; required for instantiations.

4 weeks agoada: Visibility bug in instance of generic with precondition on formal subprogram
Gary Dismukes [Wed, 7 Jan 2026 20:23:55 +0000 (20:23 +0000)] 
ada: Visibility bug in instance of generic with precondition on formal subprogram

The compiler may issue an error saying that a global entity referenced in
the precondition of a formal subprogram is not visible when the containing
generic is instantiated at a place where the entity is not directly visible.
This was due to the formal subprogram's contract not having been analyzed
in the generic template.  As a result, the nodes with global references were
not properly captured (by Save_Global_References).

An additional problem was exposed, which was that references within
contract aspect specifications of generic formals to other formals of the
same generic were not being properly analyzed/resolved, due to copying
the aspect specifications of the already-analyzed copy of the generic
formal when building subprogram wrappers for the contracts.  This could
lead to blowups in the back end due to references to the original formals
occurring in the expansion of the instantiation.  This is addressed by
copying the aspect specifications of the unanalyzed formals rather than
those that were analyzed in the copy of the generic template.

gcc/ada/ChangeLog:

* contracts.adb (Analyze_Contracts): Add cases for formal subprogram
Nkinds so that Analyze_Entry_Or_Subprogram_Contract will be called
for them.
* sem_attr.adb (Analyze_Attribute_Old_Result): Account for the cases
of formal subprogram Nkinds, allowing Old attributes for those.
* sem_ch12.adb (Build_Subprogram_Wrappers): Add a formal for passing
the unanalyzed generic formal, and use it for copying any aspect
specifications of the generic formal rather than copying the analyzed
generic formal's aspects.
(Analyze_One_Association): Pass Assoc.Un_Formal as an additional
actual in the call to Build_Subprogram_Wrappers.

4 weeks agoada: Missing dynamic accessibility check assigning conditional expr to saooaaat.
Steve Baird [Thu, 8 Jan 2026 22:31:16 +0000 (14:31 -0800)] 
ada: Missing dynamic accessibility check assigning conditional expr to saooaaat.

When a conditional expression is assigned to a saooaaat (that is, to a
stand-alone object of an anonymous access type), in some cases the
required dynamic accessibility check was not being performed.

gcc/ada/ChangeLog:

* accessibility.adb (Needs_Accessibility_Level_Temp_Or_Check): Conform
to spec changes. Return True for the RHS of an assignment statement.
* accessibility.ads: Change name of Is_Anonymous_Access_Actual
to Needs_Accessibility_Level_Temp_Or_Check; the function now returns
True in cases other than those described by the old name.
Also change name of the formal parameter from N to Conditional_Expr.
* exp_ch4.adb (Expand_N_If_Expression): Update call to a function
whose name changed.

4 weeks agoada: Improve machinery for generating predicate check
Javier Miranda [Wed, 24 Dec 2025 10:46:40 +0000 (10:46 +0000)] 
ada: Improve machinery for generating predicate check

gcc/ada/ChangeLog:

* sem_util.adb (Is_Fully_Initialized_Variant): Moved inside
subprogram Is_Fully_Initialized_Type.
(Is_Fully_Initialized_Constrained_Array): New subprogram that
factorizes code of Is_[Fully|Partially]_Initialized_Type.
(Is_Fully_Initialized_Record_Type): New subprogram; add missing
support for incomplete types.
(Is_Partially_Initialized_Record_Type): New subprogram; add missing
support for incomplete types.
(Is_Partially_Initialized_Type): Add new formal for predicate checks.
* sem_util.ads (Is_Partially_Initialized_Type): Add new formal for
predicate checks.
* sem_warn.adb (Type_OK_For_No_Value_Assigned): Use named parameters
in call to Is_Partially_Initialized_Type.
* sem_ch3.adb (Analyze_Object_Declaration): Add new actual for
predicate checks.

4 weeks agoada: Small tweaks to semantic analysis of expression functions
Eric Botcazou [Sun, 11 Jan 2026 12:00:32 +0000 (13:00 +0100)] 
ada: Small tweaks to semantic analysis of expression functions

They are mostly about streamlining the implementation, but also eliminate
unexpected or duplicate error messages in some specific cases.

gcc/ada/ChangeLog:

* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Introduce new local
boolean constant From_Expression_Function, use it throughout, and
replace an equivalent test by it.  Do not deal with name conflicts
here when it is true.  Do not verify the consistency of overriding
indicators for stand-alone expression functions.
* sem_util.ads (Is_Expression_Function_Or_Completion): Fix improper
wording in description.
* sem_util.adb (Is_Expression_Function_Or_Completion): Streamline
the implementation.

4 weeks agoada: Fix endless loop on Address aspect for object with dynamic address
Eric Botcazou [Thu, 8 Jan 2026 20:58:05 +0000 (21:58 +0100)] 
ada: Fix endless loop on Address aspect for object with dynamic address

The freezing machinery ends up inserting a freeze node into its own Actions
list, which causes Expand_N_Freeze_Entity to enter an endless loop, because
Remove_Init_Call incorrectly returns the initialization call of a different
variable than the one for which it was invoked.

gcc/ada/ChangeLog:

* exp_util.adb (Remove_Init_Call.Find_Init_Call_In_List): Check that
the first actual denotes the expected variable modulo qualification
and conversion.

4 weeks agoada: Handle call to C++ constructor placed in return statement
Javier Miranda [Sun, 4 Jan 2026 10:32:56 +0000 (10:32 +0000)] 
ada: Handle call to C++ constructor placed in return statement

Add missing support for C++ constructor call placed in the return
statement.

gcc/ada/ChangeLog:

* sem_ch3.adb (Analyze_Object_Declaration): Report an error if the
return statement of a function with foreign convention has a call
to a C++ constructor.
* exp_ch3.adb (Expand_N_Object_Declaration): Handle initialization
expression calling a C++ constructor in an extended return statement
of a subprogram with Ada convention.

4 weeks agoada: Small tweak to Analyze_Subprogram_Body_Helper
Eric Botcazou [Thu, 8 Jan 2026 10:40:38 +0000 (11:40 +0100)] 
ada: Small tweak to Analyze_Subprogram_Body_Helper

No functional changes.

gcc/ada/ChangeLog:

* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Pull out the generic
case from the if-statement and put it first.

4 weeks agoada: Enable checks during analysis of expanded dispatching calls
Denis Mazzucato [Tue, 23 Dec 2025 14:25:46 +0000 (15:25 +0100)] 
ada: Enable checks during analysis of expanded dispatching calls

This patch enables the generation of run-time checks during the analysis and
resolution of expanded dispatching calls. They were previously disabled to avoid
reporting spurious warnings under the ZFP run-time, but this is no longer
required.

gcc/ada/ChangeLog:

* exp_disp.adb (Expand_Dispatching_Call): Remove suppression of checks
during analysis of expanded dispatching calls.

4 weeks agoada: Make "finally" a non-reserved keyword
Ronan Desplanques [Wed, 7 Jan 2026 11:43:36 +0000 (12:43 +0100)] 
ada: Make "finally" a non-reserved keyword

This makes it possible to use the word "finally" as an identifier when
GNAT extensions are enabled. This does not make the syntax ambiguous
and the "finally" syntax extension is not affected.

gcc/ada/ChangeLog:

* doc/gnat_rm/gnat_language_extensions.rst: Add that finally is a
non-reserved keyword.
* par-ch5.adb (P_Sequence_Of_Statements): handle "finally" syntax
extension.
* snames.ads-tmpl: Remove the concept of GNAT extension reserved
word.
* snames.adb-tmpl (Is_Keyword_Name): Likewise.
* scans.adb (Initialize_Ada_Keywords): Likewise.
* par-util.adb (Check_Future_Keyword): Likewise.
* gnat_rm.texi: Regenerate.

4 weeks agoada: Crash with pragma Ignore_Pragma in SPARK mode
Bob Duff [Wed, 7 Jan 2026 18:57:52 +0000 (13:57 -0500)] 
ada: Crash with pragma Ignore_Pragma in SPARK mode

This patch fixes a bug in the expansion of protected bodies.

Consolidate the various cases that simply copy the Op_Body,
which is usually a protected subprogram declaration or body.
Remove the "raise Program_Error", because it's not really the
job of this code to enforce the rules about what can appear
in a protected body. Better to remove all the cases that
have accreted over the years, and just assume that anything
not allowed syntactically must be an artifact of expansion.

The specific goal here is to avoid raising Program_Error
when Op_Body is a null statement, which happens when there
is a "SPARK_Mode => Off" aspect (turned into a pragma)
and also a "pragma Ignore_Pragma (SPARK_Mode)" (which turns
the pragma into a null statement). The fix here is more
general and more "DRY".

gcc/ada/ChangeLog:

* exp_ch9.adb (Expand_N_Protected_Body):
Remove "raise Program_Error" and consolidate other
cases.

4 weeks agoada: Extend the runtime GPR files for shared libs
Sebastian Poeplau [Fri, 14 Nov 2025 15:46:21 +0000 (16:46 +0100)] 
ada: Extend the runtime GPR files for shared libs

The GPR files can be used to build the Ada runtime, usually via
libada.gpr as the entry point. This commits extends the GPR project
definitions to make them suitable for shared and static PIC runtime
builds.

When LIBRARY_KIND is "static-pic", the libraries gain a "_pic" suffix,
as expected by the build tools. When it's "dynamic", we configure the
Library_Version attribute in order to set the right SONAME on Unix, as
well as the expected symlinks.

Finally, libgnarl.gpr now depends on libgnat.gpr; the missing dependency
hasn't caused problems so far because static libraries don't resolve
missing symbols at build time, but it's necessary to build shared
libraries.

gcc/ada/ChangeLog:

* libgnarl/libgnarl.gpr: Add dependency on libgnat.gpr.
Set Library_Name and Library_Version depending on Library_Kind.
* libgnat/libgnat.gpr: Likewise.

4 weeks agoada: Support for implicit parameterless constructor
Denis Mazzucato [Tue, 6 Jan 2026 12:38:49 +0000 (13:38 +0100)] 
ada: Support for implicit parameterless constructor

An implicit parameterless constructor is available when no other constructor is
declared for a tagged type that has an ancestor with constructors. The implicit
parameterless constructor calls the parent parameterless constructor through the
Super aspect without arguments.

gcc/ada/ChangeLog:

* aspects.ads (Aspects): Make Super aspect optional to allow for
explicit call to parent parameterless constructor.
* exp_ch3.adb (Build_Implicit_Parameterless_Constructor): Build implicit
parameterless constructor when no other constructors are defined but the
type has an ancestor with constructors.
* exp_ch6.adb
(Init_Expression_If_Any): Pe4rmit implicit calls to parameterless
constructors in initialization expressions if available.
(Make_Parent_Constructor_Call): Super without parameters calls the
parent parameterless constructor.
* sem_ch13.adb (Analyze_Aspect_Specification): Allow Super aspect
without expression.
* sem_ch3.adb (Analyze_Object_Declaration): Delay check for missing
parameterless constructor until the the implicit constructor is built.

4 weeks agoada: New aspects for use in CodePeer's taint analysis.
Steve Baird [Mon, 15 Dec 2025 21:47:35 +0000 (13:47 -0800)] 
ada: New aspects for use in CodePeer's taint analysis.

Add minimal compiler support for three new aspects: Taint_Sanitizer,
Taint_Sink, and Taint_Source. This support consists of accepting (with no
accompanying semantic analysis) aspect specifications for these aspects, using
either aspect_specification syntax or pragmas. Such aspect specifications are
subsequently ignored by the compiler front end. These aspects are intended for
use with CodePeer and are (or will be) documented in CodePeer documentation;
they are not documented in the GNAT RM.

gcc/ada/ChangeLog:

* aspects.ads: Add three new Taint_Xxx aspects to the Aspect_Id
enumeration type and define a corresponding subtype,
Ignored_Aspects.
* exp_prag.adb (Expand_N_Pragma): Don't rewrite a taint-related
pragma as a null statement. We want to leave the (unanalyzed)
pragma in the tree.
* sem_ch13.adb (Analyze_One_Aspect): Leave taint-related aspect
specifications
(and their arguments, if any) unanalyzed.
(Check_Aspect_At_Freeze_Point): Update a case statement to treat
the new aspects as an error case.
* sem_util.adb (Should_Ignore_Pragma_Sem): Return True for an
ignored pragma.
* snames.ads-tmpl: Define names for the three new aspects.

4 weeks agoada: Tech debt: VAST-related cleanup of Save_Scan_State
Bob Duff [Tue, 6 Jan 2026 14:42:09 +0000 (09:42 -0500)] 
ada: Tech debt: VAST-related cleanup of Save_Scan_State

Minor cleanup; follow-on to previous change titled
"clean up miscellaneous VAST issues".

Use an aggregate in Save_Scan_State. This has the usual
advantage of an aggregate over a series of individual
assignments -- full coverage checking.

gcc/ada/ChangeLog:

* scans.adb (Save_Scan_State): Use an aggregate.

4 weeks agoada: Fix spurious range check for out mode scalars in class-wide preconditions
Denis Mazzucato [Mon, 22 Dec 2025 12:44:41 +0000 (13:44 +0100)] 
ada: Fix spurious range check for out mode scalars in class-wide preconditions

This patch fixes a spurious range check that was generated for out mode scalars
after a class-wide precondition call. This issue was not present in static
preconditions, but only in dynamic ones. This patch refactors the two helper
call builders into the same to ensure the same processing of actuals.

gcc/ada/ChangeLog:

* exp_ch6.adb (Build_Helper_Call): Refactor code to handle both static and
dynamic precondition calls in the same way.

4 weeks agoada: Refactor assignments in constructor prologue
Denis Mazzucato [Tue, 16 Dec 2025 10:16:32 +0000 (11:16 +0100)] 
ada: Refactor assignments in constructor prologue

Constructor prologues now call the same routine as initialization procedures to
build component assignments.

gcc/ada/ChangeLog:

* exp_ch3.adb (Build_Record_Init_Proc): Move Build_Assignment to
Build_Component_Assignment in Exp_Util for a more general use.
* exp_ch6.adb (Prepend_Constructor_Procedure_Prologue): refactor using
Build_Component_Assignment.
* exp_util.adb (Build_Component_Assignment): Logic to build component
assignments for initialization procedures and constructor prologues.
* exp_util.ads (Build_Component_Assignment): Likewise.
* sem_ch5.adb (Analyze_Assignment): Revert back changes from previous
attempt to fix assignments of limited types in constructor prologues,
the use of Build_Component_Assignment makes those changes unnecessary.

4 weeks agoada: Minor comment fixes
Eric Botcazou [Mon, 5 Jan 2026 06:56:07 +0000 (07:56 +0100)] 
ada: Minor comment fixes

This comprises a couple of typos and a small rewriting.

gcc/ada/ChangeLog:

* exp_ch3.adb (Expand_N_Object_Declaration): Minor comment fixes.

4 weeks agoada: Fix typo in head comment of Sinput specification
Eric Botcazou [Sat, 3 Jan 2026 08:58:32 +0000 (09:58 +0100)] 
ada: Fix typo in head comment of Sinput specification

As explained later in the commentary of the file, wide characters specified
to be line terminators are considered to be logical instead of physical line
terminators.  The change also aligns the description of the physical line
terminators with the one present later in the commentary.

gcc/ada/ChangeLog:

* sinput.ads: Small tweak to head comment.

4 weeks agoada: Fix propagation of by-constructor indication from composition
Denis Mazzucato [Tue, 23 Dec 2025 10:02:49 +0000 (11:02 +0100)] 
ada: Fix propagation of by-constructor indication from composition

This patch stops the propagation of by-constructor indication from composition.
Only derived tagged types should propagate this indication.

gcc/ada/ChangeLog:

* sem_ch3.adb (Build_Derived_Type): Propagate by-constructor indication
only for derived tagged types, not for composition.

4 weeks agolibstdc++: Add data/member for initializer_list, and remove std overloads
Tomasz Kamiński [Mon, 18 May 2026 11:14:25 +0000 (13:14 +0200)] 
libstdc++: Add data/member for initializer_list, and remove std overloads

This implements changes section 4.6 of P3016R6, and initializer_list related
parts of 4.7 and 4.8. The change makes immediately dangling invocations of
std::begin, std::end, and std::data on braced-init list ill-formed (see
range_access_neg.cc and range_access17_neg.cc):
  auto it = std::begin({1, 2, 3});  // ILL-FORMED, it was dangling
  (it == std::end({1, 2, 3}));      // ILL-FORMED, was unspecified
  auto* ptr = std::data({1, 2, 3}); // ILL-FORMED, ptr was dangling
However, similary problemetic calls for std::rbegin, std::rend remain
well-formed (see range_access14_neg.cc), as initializer_list overloads
are preserved for these functions:
  auto rit = ranges::rbegin({1, 2, 3}); // COMPILES, dangling
  auto rend = ranges::rend({1, 2, 3});  // COMPILES, danging
Note, that non-problematic std::size({1, 2, 3}) and std::empty({1, 2, 3})
use c-array overloads, and remain well-formed.

Per paper, to keep std::data(il) and std::empty(il) well-formed, the data
and empty member are added to initializer_list.

libstdc++-v3/ChangeLog:

* include/bits/version.def (initializer_list): Define with value
202511 for C++26.
* include/bits/version.h: Regenerate.
* libsupc++/initializer_list (initializer_list::data)
(initializer_list::empty) [__glibcxx_initializer_list >= 202511L]:
Define.
(std::begin(initializer_list<_Tp>), std::end(initializer_list<_Tp>)):
Define only if __glibcxx_initializer_list < 202511L (i.e. not defined).
* include/bits/range_access.h (std::empty(initializer_list<_Tp>))
(std::data(initializer_list<_Tp>)): Define only if
__glibcxx_initializer_list < 202511L (i.e. not defined).
* testsuite/18_support/initializer_list/range_access.cc: Move test for
brace-init list to range_access_neg.c. Included <iterator> in C++26 or
later mode.
* testsuite/18_support/initializer_list/data_empty_mem.cc: New test.
* testsuite/18_support/initializer_list/range_access14.cc: New test.
* testsuite/18_support/initializer_list/range_access14_neg.cc: New test.
* testsuite/18_support/initializer_list/range_access17.cc: New test.
* testsuite/18_support/initializer_list/range_access17_neg.cc: New test.
* testsuite/18_support/initializer_list/range_access_neg.cc: New test.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
4 weeks agoRestore original format of -fstack-usage and add new second field
Eric Botcazou [Mon, 25 May 2026 07:42:04 +0000 (09:42 +0200)] 
Restore original format of -fstack-usage and add new second field

This should minimize the backward compatibility breakage.

gcc/
* doc/invoke.texi (fstack-usage): Document new second field.
* toplev.cc (output_stack_usage_1): Revert latest changes and add
the mangled name as the second field.

gcc/testsuite/
* gcc.dg/stack-usage-1.c: Adjust.

4 weeks agobitmap: Fix bitmap_last_set_bit
Richard Sandiford [Mon, 25 May 2026 07:04:11 +0000 (08:04 +0100)] 
bitmap: Fix bitmap_last_set_bit

If the last bit in a bitmap was in elt->bits[0], bitmap_last_set_bit
would not read it and would instead fall through with "word" still set
to elt->bits[1], which is known to be 0.

This patch fixes it to use the same structure as
bitmap_first_set_bit_worker.

As you might expect from this, only the sbitmap version of this
function appears to be used.

gcc/
* bitmap.cc (bitmap_last_set_bit): Fix handling of index 0.

4 weeks agoAdjust stack-usage-realign.c for commit 960895db668
H.J. Lu [Mon, 25 May 2026 04:54:51 +0000 (12:54 +0800)] 
Adjust stack-usage-realign.c for commit 960895db668

Add the user visibility name to scan-stack-usage in stack-usage-realign.c
for

commit 960895db66868a81fafbebe4392bf0f1054fc101
Author: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
Date:   Mon May 18 18:20:14 2026 -0700

    stack_usage: Print out the user visibility name too

* gcc.target/i386/stack-usage-realign.c: Add the user visibility
name to scan-stack-usage.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
4 weeks agoFortran: [PR93727] Fix EX format kind=8 output on ILP32 targets
Jerry DeLisle [Sun, 24 May 2026 18:51:49 +0000 (11:51 -0700)] 
Fortran: [PR93727] Fix EX format kind=8 output on ILP32 targets

On 32-bit targets such as ARM where unsigned long is 32 bits, the
kind=8 case in get_float_hex_string used unsigned long for frac_part.
The kind=8 mantissa requires 52 bits (13 hex digits), so the cast
silently truncated the upper bits, producing wrong hex output.  In
addition, converting a ~4.5e15 double value to a 32-bit unsigned long
is out of range, which raised IEEE_INVALID_FLAG on ARM hardware.

Fix kind=8 by using GFC_UINTEGER_8, which is guaranteed 64 bits on all
targets.  Update kind=10 and kind=16 to use GFC_UINTEGER_8 throughout
for consistency with libgfortran conventions.

PR fortran/93727

libgfortran/ChangeLog:

* io/write_float.def (get_float_hex_string): Fix kind=8 frac_part
from unsigned long to GFC_UINTEGER_8 to correct truncated hex
output and IEEE_INVALID_FLAG on ILP32 targets.  Update kind=10
and kind=16 to use GFC_UINTEGER_8 for consistency.

Assisted by: Claude Sonnet 4.6

4 weeks agomatch.pd: Fold popcount(x ^ (x - 1)) to ctz(x) + 1 [PR124630]
liuhongt [Thu, 14 May 2026 09:06:43 +0000 (02:06 -0700)] 
match.pd: Fold popcount(x ^ (x - 1)) to ctz(x) + 1 [PR124630]

When X is nonzero, X ^ (X - 1) produces a mask of trailing zeros plus
the lowest set bit, so popcount of that expression equals ctz(X) + 1.

gcc/ChangeLog:

PR middle-end/124630
* match.pd (popcount (x ^ (x - 1))): Fold to ctz (x) + 1 when
x is nonzero and CTZ is directly supported.

gcc/testsuite/ChangeLog:

PR middle-end/124630
* gcc.dg/pr124630.c: New test.
* gcc.target/i386/pr124630.c: New test.

4 weeks agoc: fix debris from r17-680
Sam James [Mon, 25 May 2026 00:24:14 +0000 (01:24 +0100)] 
c: fix debris from r17-680

r17-680-g09e74059bdb12c added a debugging pragma and a whitespace change
to a comment. I don't think either were intended.

gcc/c/ChangeLog:

* c-parser.cc: Delete errant optimize pragma.

4 weeks agoDaily bump.
GCC Administrator [Mon, 25 May 2026 00:16:22 +0000 (00:16 +0000)] 
Daily bump.

4 weeks agoalgol68: Open source files in binary mode
Peter Damianov [Sun, 24 May 2026 18:59:46 +0000 (14:59 -0400)] 
algol68: Open source files in binary mode

When building a source file with CRLF newlines on Windows, the CRLFs were
getting converted to LFs, so a86_file_read was returning "short" byte counts
and tripping an assert. Make sure files get opened in binary mode to avoid this.

gcc/algol68/ChangeLog:

* a68-lang.cc (a68_handle_option): Open file in binary mode.
* a68-parser-scanner.cc (read_source_file): Open file in binary mode.
(include_files): Likewise.

4 weeks agomatch: Optimize `(~y & x) ^ y` into (y | x) [PR125104]
Raven Hallsby [Sun, 24 May 2026 02:09:16 +0000 (21:09 -0500)] 
match: Optimize `(~y & x) ^ y` into (y | x) [PR125104]

Despite a similar rule existing earlier in match.pd, this simplify
rule is needed because the front-end (before pass 006.original)
performs trivial constant optimizations, such as ~1 -> -2 on
integers (at least those defined as `int`).

PR tree-optimization/125104

gcc/ChangeLog:

* match.pd (`(~y & x) ^ y`): New Pattern.

gcc/testsuite/ChangeLog:

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

4 weeks agostack_usage: Print out the user visibility name too
Andrew Pinski [Tue, 19 May 2026 01:20:14 +0000 (18:20 -0700)] 
stack_usage: Print out the user visibility name too

Since the output here should be usable via humans, we
should print out the user realable name and not just the
mangled name. For C, that means we print out the same name
twice which is fine. The mangled name is useful to correspond
the assembly with the stack usage too.

For C++ it will something like:
t.c:2:5:_Z5unopti `int unopt(int)` 16 static

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* toplev.cc (output_stack_usage_1): Print out the human readable
name in quotes.

gcc/testsuite/ChangeLog:

* gcc.dg/stack-usage-1.c: Update testcase.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
4 weeks agoifcvt: factor: turn asserts about abnormals to conditional [PR125419]
Andrew Pinski [Fri, 22 May 2026 19:07:28 +0000 (12:07 -0700)] 
ifcvt: factor: turn asserts about abnormals to conditional [PR125419]

I missed that factor_out_operators might look further up when it is doing its
factoring so we end up with a statement that ssa names that are used in abnormal
edges.
This changes the asserts to just reject the factoring instead.

Bootstrapped and tested on x86_64-linx-gnu.

PR tree-optimization/125419

gcc/ChangeLog:

* tree-if-conv.cc (factor_out_operators): Change
asserts about abnormals into a conditional to reject
it.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
4 weeks agoFortran: [PR93727] Implement EX format specifier for WRITE
Jerry DeLisle [Mon, 11 May 2026 01:13:48 +0000 (18:13 -0700)] 
Fortran: [PR93727] Implement EX format specifier for WRITE

These changes implement a portion of the Fortran 2018
EX format specifier for WRITE output. Hexadecimal
floating point formats for KIND=4,8,10, and 16 real
numbers if supported by the configured machine.

Format tokens are added as place holders for future leading
zero specifiers.

Remaining to be completed is proper rounding of truncated
hex float strings and implementing the READ functions. These
will be a followup patches.

PR fortran/93727

gcc/fortran/ChangeLog:

* io.cc (enum format_token): Add FMT_EX, FMT_LPS, FMT_LPZ, FMT_LZ
enums to identify specific tokens.
(format_lex): Add parsing and checking of the EXw.d and EXw.dEe edit
specifiers.

libgfortran/ChangeLog:

* io/format.c (format_lex): Add new FMT_EX token handing.
(parse_format_list): Likewise.
(next_format): Likewise
* io/io.h (write_ex): Add prototype for new function.
(internal_proto): Likewise.
* io/transfer.c (formatted_transfer_scalar_write): Use FMT_EX token.
* io/write.c (write_default_char4): White space fix.
(write_a): White space fix.
(write_boz): White space fix.
(write_decimal): White space fix.
(otoa_big): White space fix.
(write_character): White space fix.
(write_float_0): White space fix.
(write_ex): New function which uses the new helper function
get_float_hex_string() to build the hexadecimal float format for
output.
(write_real): White space fix.
(write_complex): White space fix.
(nml_write_obj): White space fix.
(namelist_write): White space fix.
* io/write_float.def: Add defines to handle the various forms of
KIND=16 floats. These handle the selection of the appropriate versions
of the frexp, fabs, and scalbn used to extract the components of the
floating point values.
(GFC_REAL_16_FREXP): New define.
(GFC_REAL_16_FABS): New define.
(GFC_REAL_16_SCALBN): New define.
(get_float_hex_string): New function which exatracts the bits and builds
the basic hexadecimal format strings into a buffer. The buffer is provided
by the caller write_ex.
(build_float_string): White space fix.
(quadmath_snprintf): White space fix.
(determine_en_precision): White space fix.

gcc/testsuite/ChangeLog:

* gfortran.dg/EXformat_1.F90: New test.
* gfortran.dg/EXformat_2.f90: New test.

Co-Authored-By: Harald Anlauf <anlauf@gcc.gnu.org>
4 weeks agoDaily bump.
GCC Administrator [Sun, 24 May 2026 00:16:26 +0000 (00:16 +0000)] 
Daily bump.

4 weeks agofold-const.cc: remove fold_overflow_warning()
Daniel Barboza [Sat, 17 Jan 2026 19:01:54 +0000 (16:01 -0300)] 
fold-const.cc: remove fold_overflow_warning()

Remove all remaining callers of fold_overflow_warning() in
fold-const.cc, along with all associated logic.

pointer_may_wrap_p is also removed - it was being called twice, both
times to determine whether to call fold_overflow_warning() or not, and
had no other uses after fold_overflow_warning() was removed.

gcc/ChangeLog:

* fold-const.cc (fold_overflow_warning): Removed.
(pointer_may_wrap_p): Removed.
(fold_comparison): Removed fold_overflow_warning and
pointer_may_wrap_up calls.
(fold_binary_loc): Likewise.
* fold-const.h (fold_overflow_warning): Removed.

gcc/testsuite/ChangeLog:

* gcc.dg/Wstrict-overflow-22.c: Removed, given that we do not
generated a warning for the pattern being tested.
* gcc.dg/Wstrict-overflow-5.c: Likewise.

4 weeks agofold-const.cc: overhaul tree_expr_nonnegative_(warn)_p
Daniel Barboza [Sat, 17 Jan 2026 19:01:53 +0000 (16:01 -0300)] 
fold-const.cc: overhaul tree_expr_nonnegative_(warn)_p

We want to eliminate another source of Wstrict-overflow warnings from
tree_expr_nonnegative_warnv_p, via fold_overflow_warn(). At this point
strict_overflow_p is marked as ATTRIBUTE_UNUSED and we can remove it.

By removing it, the function would lost the "warnv" and be renamed to
tree_expr_nonnegative_p. This matches an existing function, that has a
different API. In a closer inspection we verify that
tree_expr_nonnegative_p is a wrapper for tree_expr_nonnegative_warn_p,
that throws a warning and leaves depth = 0 by default. This same
behavior can be achieved by removing strict_overflow_p from
tree_expr_nonnegative_warnv_p, so we'll go ahead with its rename and the
removal of the pre-existing tree_expr_nonnegative_p.

The additional strict_overflow_p local variables we've been adding to
satisfy the RECURSE() macro are all eliminated.

gcc/c-family/ChangeLog:

* c-warn.cc (warn_for_sign_compare): Remove strict_overflow_p
argument from tree_expr_nonnegative_p call.

gcc/c/ChangeLog:

* c-typeck.cc (build_conditional_expr): Likewise.

gcc/ChangeLog:

* fold-const.cc (fold_binary_loc): Likewise.
(tree_expr_nonnegative_warnv_p): Renamed to
tree_expr_nonnegative_p. Argument strict_overflow_p removed.
(tree_expr_nonnegative_p): Removed.
(RECURSE): Removed strict_overflow_p argument.
(tree_unary_nonnegative_p): Local strict_overflow_p variable
added to support the RECURSE() macro was removed.
(tree_binary_nonnegative_p): Likewise.
(tree_single_nonnegative_p): Likewise.
(tree_call_nonnegative_p): Likewise.
(tree_invalid_nonnegative_p): Likewise.
(tree_binary_nonzero_p): Removed sub_strict_overflow_p variable
from tree_expr_nonnegative_p call.
* fold-const.h (tree_expr_nonnegative_p): Removed.
(tree_expr_nonnegative_warnv_p): Renamed to
tree_expr_nonnegative_p, removed strict_overflow_p argument.
* tree-ssa-loop-manip.cc (create_iv): Removed ovf variable from
tree_expr_nonnegative_p call.

4 weeks agofold-const.cc: remove strict_overflow_p from tree_expr_nonnegative helpers
Daniel Barboza [Sat, 17 Jan 2026 19:01:52 +0000 (16:01 -0300)] 
fold-const.cc: remove strict_overflow_p from tree_expr_nonnegative helpers

Before handling the fold_overflow_warn() call from
tree_expr_nonnegative_warnv_p we'll remove all remaining
strict_overflow_p flags from the helpers that are still using it.

An ATTRIBUTE_UNUSED tag was added in the strict_overflow_p argument in
tree_expr_nonnegative_warnv_p because the variable is now unused, but
removing it right now will incur a lot of non-trivial changes that would
be too much for this patch. This tag, and all the extra lines we're
adding to make RECURSE() happy, will be dealt with in the next patch.

gimple-fold.cc functions got impacted by the changes and were changed
accordingly.

gcc/ChangeLog:

* fold-const.cc (tree_call_nonnegative_warnv_p): Renamed to
tree_call_nonnegative_warnv_p.
(tree_call_nonnegative_p): Removed strict_overflow_p flag.
(tree_invalid_nonnegative_warnv_p): Renamed to
tree_invalid_nonnegative_p.
(tree_invalid_nonnegative_p): Removed strict_overflow_p flag.
(tree_expr_nonnegative_warnv_p): Added ATTRIBUTE_UNUSED tag in
the now unused strict_overflow_p argument. Removed
strict_overflow_p call from tree_invalid_nonnegative_p.
* fold-const.h (tree_call_nonnegative_warnv_p): Renamed to
tree_call_nonnegative_p.
(tree_call_nonnegative_p): Removed strict_overflow_p flag.
* gimple-fold.cc (gimple_call_nonnegative_warnv_p): Renamed to
gimple_call_nonnegative_p.
(gimple_call_nonnegative_p): Removed strict_overflow_p flag.
(gimple_stmt_nonnegative_warnv_p): Renamed to
gimple_stmt_nonnegative_p.
(gimple_stmt_nonnegative_p): Removed strict_overflow_p flag.
* gimple-fold.h (gimple_stmt_nonnegative_warnv_p): Renamed to
gimple_stmt_nonnegative_p.
(gimple_stmt_nonnegative_p): Removed strict_overflow_p flag.
* gimple-range-fold.cc (fold_using_range::fold_stmt): Removed
strict_overflow_p flag from gimple_stmt_nonnegative_p.
(fold_using_range::range_of_call): Likewise.

4 weeks agofold-const.cc: remove strict_overflow_p flag from tree_single_nonnegative_p
Daniel Barboza [Sat, 17 Jan 2026 19:01:51 +0000 (16:01 -0300)] 
fold-const.cc: remove strict_overflow_p flag from tree_single_nonnegative_p

Similar to the previous patches: remove the strict_overflow_p flag to
allow us to remove the fold_overflow_warn() from the parent function
tree_single_nonnegative_warnv_p.

The changes done in fold-const.cc caused a ripple effect on
gimple-fold.cc, where we ended up doing similar changes to
gimple_assign_nonnegative_warnv_p and gimple_phi_nonnegative_warnv_p.

gcc/ChangeLog:

* fold-const.cc (tree_single_nonnegative_warnv_p): Renamed to
tree_single_nonnegative_p.
(tree_single_nonnegative_p): Removed strict_overflow_p flag.
(tree_expr_nonnegative_warnv_p): Removed strict_overflow_p flag
from tree_single_nonnegative_p call.
* fold-const.h (tree_single_nonnegative_warnv_p): Renamed to
tree_single_nonnegative_p.
(tree_single_nonnegative_p): Removed strict_overflow_p flag.
* gimple-fold.cc (gimple_assign_nonnegative_warnv_p): Renamed to
gimple_assign_nonnegative_p.
(gimple_assign_nonnegative_p): Removed strict_overflow_p flag.
(gimple_phi_nonnegative_warnv_p): Renamed to
gimple_phi_nonnegative_p.
(gimple_phi_nonnegative_p): Removed strict_overflow_p flag.
(gimple_stmt_nonnegative_warnv_p): Removed strict_overflow_p
flag from gimple_phi_nonnegative_p and gimple_assign_nonnegative_p
calls.

4 weeks agofold-const.cc: remove strict_overflow_p from tree_unary_nonnegative
Daniel Barboza [Sat, 17 Jan 2026 19:01:50 +0000 (16:01 -0300)] 
fold-const.cc: remove strict_overflow_p from tree_unary_nonnegative

Similar to what was done with tree_binary_nonnegative_p in the previous
patch, we want to remove overflow flags from all
tree_unary_nonnegative_warnv_p helpers, and then remove all overflow
flags from the parent helper itself.

gcc/ChangeLog:

* fold-const.cc (tree_unary_nonnegative_warnv_p): Renamed to
tree_unary_nonnegative_p.
(tree_unary_nonnegative_p): Removed strict_overflow_p flag.
(tree_expr_nonnegative_warnv_p): Removed strict_overflow_flag
from tree_unary_nonnegative_p calls.
* fold-const.h (tree_unary_nonnegative_warnv_p): Renamed to
tree_unary_nonnegative_p.
(tree_unary_nonnegative_p): Removed strict_overflow_p flag.
* gimple-fold.cc (gimple_assign_nonnegative_warnv_p): Removed
strict_overflow_flag from tree_unary_nonnegative_p calls.

gcc/testsuite/ChangeLog:

* gcc.dg/Wstrict-overflow-24.c: Removed since the pattern
doesn't throw warnings anymore.
* gcc.dg/Wstrict-overflow-9.c: Likewise.

4 weeks agofold-const.cc: remove strict_overflow_p from tree_binary_nonnegative
Daniel Barboza [Sat, 17 Jan 2026 19:01:49 +0000 (16:01 -0300)] 
fold-const.cc: remove strict_overflow_p from tree_binary_nonnegative

We want to remove a fold_overflow_warn() nested inside
tree_exp_nonnegative_warnv_p. This function uses a lot of helpers, and
some of them do recursive calls for the helper itself.

Let's deal with strict_overflow_p flags for each helper first, starting
with tree_binary_nonnegative_warnv_p, that is now renamed to
tree_binary_nonnegative_p since it doesn't handle warnings anymore.

The RECURSE() macro expects a strict_overflow_p variable to be valid in
its scope, so we can't just remove the flag from the function
parameters. We're adding a temporary block that declares a local
strict_overflow_p variable to make RECURSE() happy. These declarations
will all be removed when we deal with tree_expr_nonnegative_warnv_p.

gcc/ChangeLog:

* fold-const.cc (tree_binary_nonnegative_warnv_p): Renamed to
tree_binary_nonnegative_p.
(tree_binary_nonnegative_p): Removed strict_overflow_p flag. Add
a local variable with the same name for RECURSE() that we'll
remove later.
(tree_expr_nonnegative_warnv_p): Removed strict_overflow_p flag
from tree_binary_nonnegative_p call.
* fold-const.h (tree_binary_nonnegative_warnv_p): Renamed to
tree_binary_nonnegative_p.
(tree_binary_nonnegative_p): Removed strict_overflow_p flag.
* gimple-fold.cc (gimple_assign_nonnegative_warnv_p): Likewise.

gcc/testsuite/ChangeLog:

* gcc.dg/pr56355-1.c: Removed since it's a warning check test
and we do not emit warnings for the code being tested.

4 weeks agofold-const.cc: remove strict_overflow_p from maybe_canonicalize_comparison
Daniel Barboza [Sat, 17 Jan 2026 19:01:48 +0000 (16:01 -0300)] 
fold-const.cc: remove strict_overflow_p from maybe_canonicalize_comparison

Remove the strict overflow flag from maybe_canonicalize_comparison
functions. All related fold_overflow_warning calls are also removed.

gcc/ChangeLog:

* fold-const.cc (maybe_canonicalize_comparison_1): Removed
strict_overflow_p flag.
(maybe_canonicalize_comparison): Removed strict_overflow_p
flag and all fold_overflow_warning calls.

4 weeks agofold-const.cc: remove strict_overflow_p from tree_expr_nonzero_warnv_p
Daniel Barboza [Sat, 17 Jan 2026 19:01:47 +0000 (16:01 -0300)] 
fold-const.cc: remove strict_overflow_p from tree_expr_nonzero_warnv_p

After changing all its internal helpers we're ready to change
tree_expr_nonzero_warnv_p. By removing the strict_overflow_p flag from
it we'll make the existing tree_expr_nonzero_p unneeded. We'll delete it
and rename tree_expr_nonzero_warnv_p to tree_expr_nonzero_p without
changing the API and the behavior for existing callers.

And we'll end up removing a fold_overflow_warn() call, which was our
whole idea in the end.

gcc/ChangeLog:

* fold-const.cc (tree_expr_nonzero_warnv_p): Renamed to
tree_expr_nonzero_p and removed the strict_overflow_p flag.
(tree_expr_nonzero_p): Removed it since it's now redundant with
tree_expr_nonzero_warnv_p.
(tree_unary_nonzero_p): Removed the local sub_strict_overflow_p
flag from the tree_expr_nonzero_p call.
(tree_binary_nonzero_p): Likewise.
(tree_single_nonzero_p): Likewise.

4 weeks agofold-const.cc: remove strict_overflow_p from tree_single_nonzero_warnv_p
Daniel Barboza [Sat, 17 Jan 2026 19:01:46 +0000 (16:01 -0300)] 
fold-const.cc: remove strict_overflow_p from tree_single_nonzero_warnv_p

This helper is called by tree_expr_nonzero_warnv_p(), a helper that is
gating a call to fold_overflow_warning() that we want to eliminate.

The helper is renamed to remove the "warn" from its name since it
doesn't throw or set any overflow warnings anymore.

gcc/c-family/ChangeLog:

* c-ubsan.cc (ubsan_maybe_instrument_reference_or_call): Removed
strict_overflow_p flag.

gcc/ChangeLog:

* fold-const.cc (tree_expr_nonzero_warnv_p): Removed
strict_overflow_p flag.
(tree_single_nonzero_warnv_p): Renamed to tree_single_nonzero_p.
(tree_single_nonzero_p): Removed strict_overflow_p flag.
* fold-const.h (tree_single_nonzero_warnv_p): Renamed to
tree_single_nonzero_p.
(tree_single_nonzero_p): Removed strict_overflow_p flag.
* gimple-range-fold.cc (fold_using_range::range_of_address):
Removed strict_overflow_p flag.
(range_from_readonly_load): Likewise.
* ipa-prop.cc (ipa_compute_jump_functions_for_edge): Likewise.
* tree-ssa-phiopt.cc (absorbing_element_p): Likewise.
* value-query.cc (range_query::get_tree_range): Likewise.

4 weeks agofold-const.cc: remove strict_overflow_p from tree_binary_nonzero_warnv_p
Daniel Barboza [Sat, 17 Jan 2026 19:01:45 +0000 (16:01 -0300)] 
fold-const.cc: remove strict_overflow_p from tree_binary_nonzero_warnv_p

This helper is called by tree_expr_nonzero_warnv_p(), a helper that is
gating a call to fold_overflow_warning() that we want to eliminate.

The helper is renamed to remove the "warn" from its name since it
doesn't throw or set any overflow warnings anymore.

gcc/ChangeLog:

* fold-const.cc (tree_expr_nonzero_warnv_p): Removed
strict_overflow_p flag from tree_binary_nonzero_p call.
(tree_binary_nonzero_warnv_p): Renamed to tree_binary_nonzero_p.
(tree_binary_nonzero_p): Removed strict_overflow_p flag.
* fold-const.h (tree_binary_nonzero_warnv_p): Renamed to
tree_binary_nonzero_p.
(tree_binary_nonzero_p): Removed strict_overflow_p flag.

4 weeks agofold-const.cc: remove strict_overflow_p from tree_unary_nonzero_warnv_p
Daniel Barboza [Sat, 17 Jan 2026 19:01:44 +0000 (16:01 -0300)] 
fold-const.cc: remove strict_overflow_p from tree_unary_nonzero_warnv_p

This helper is called by tree_expr_nonzero_warnv_p(), a helper that is
gating a call to fold_overflow_warning() that we want to eliminate.

For now let's change the comment from tree_expr_nonzero_warnv_p() to
mention that we're throwing overflow warnings just for certain cases,
not all. We'll change that comment again when we get to work on
tree_expr_nonzero_warnv_p().

The helper is renamed to remove the "warn" from its name since it
doesn't throw or set any overflow warnings anymore.

gcc/ChangeLog:

* fold-const.cc (mask_with_tz): Changed comment that describes
tree_expr_nonzero_warnv_p warn on overflow behavior.
(tree_expr_nonzero_warnv_p): Removed strict_overflow_p flag.
(tree_unary_nonzero_warnv_p): Renamed to tree_unary_nonzero_p.
(tree_unary_nonzero_p): Removed strict_overflow_p flag.
* fold-const.h (tree_unary_nonzero_warnv_p): Renamed to
tree_unary_nonzero_p.
(tree_unary_nonzero_p): Removed strict_overflow_p flag.

4 weeks agofold-const.cc: remove strict_overflow_p from extract_muldiv
Daniel Barboza [Sat, 17 Jan 2026 19:01:43 +0000 (16:01 -0300)] 
fold-const.cc: remove strict_overflow_p from extract_muldiv

Continuing the deprecation of -Wstrict-overflow, remove the
strict_overflow flag from extract_muldiv().

gcc/ChangeLog:

* fold-const.cc (extract_muldiv): Removed strict_overflow_p
references, including temporary variables and comments.
(extract_muldiv_1): Likewise.
(fold_binary_loc): Likewise.

gcc/testsuite/ChangeLog:

* gcc.dg/Wstrict-overflow-3.c: Removed. We do not throw warnings
for extract_muldiv patterns anymore.

4 weeks agofold-const.cc: remove strict_overflow flag from make_range helpers
Daniel Barboza [Sat, 17 Jan 2026 19:01:42 +0000 (16:01 -0300)] 
fold-const.cc: remove strict_overflow flag from make_range helpers

This is a first step towards deprecating -Wstrict_overflow. The warning
is rooted in several places throughout the code, fold-const.cc functions
being one of them (via fold_overload_warn()).

These helpers are used in other files as well so the approach taken is to
gradually remove it from fold-const.cc while fixing the existing callers
along the way.

gcc/c-family/ChangeLog:

* c-warn.cc (warn_logical_operator): Removed strict_overflow_p
variable.

gcc/ChangeLog:

* fold-const.cc (make_range_step): Likewise.
(make_range): Likewise.
(fold_range_test): Likewise.
* fold-const.h (make_range): Likewise.
(make_range_step): Likewise.
* tree-ssa-reassoc.cc (init_range_entry): Likewise.

4 weeks ago[RISC-V] Improve slli+zext+andi sequence for RISC-V
Philipp Tomsich [Sat, 23 May 2026 16:31:11 +0000 (10:31 -0600)] 
[RISC-V] Improve slli+zext+andi sequence for RISC-V

So this is another patch mostly from the VRULL team.  Given something like
this:

> #define T int
> typedef long unsigned int size_t;
> extern void *xcalloc (size_t, size_t) ;
> typedef struct sparseset_def
> {
>   unsigned T *dense;
>   unsigned T *sparse;
>   unsigned T members;
>   unsigned T size;
>   unsigned T iter;
>   unsigned char iter_inc;
>   unsigned char iterating;
>   unsigned T elms[2];
> } *sparseset;
> sparseset
> sparseset_alloc (unsigned T n_elms)
> {
>   unsigned T n_bytes = sizeof (struct sparseset_def)
>     + ((n_elms - 1) * 2 * sizeof (unsigned T));
>   sparseset set = (sparseset) xcalloc (1, n_bytes);
>   return set;
> }

It currently compiles into this with rv64gcb:

>         addi    a1,a0,4
>         slli    a1,a1,3
>         zext.w  a1,a1
>         andi    a1,a1,-8
>         li      a0,1
>         tail    xcalloc
But we can do better.  In particular the slli+zext+andi sequence can be
improved into:

>         addi    a1,a0,4
>         slli    a5,a1,35
>         srli    a1,a5,32
>         li      a0,1
>         tail    xcalloc

The new pattern needs to be a define_insn_and_split due to a chain of
define_insn_and_split patterns that start with mvconst_internal 🙁

To avoid regressing zba-shadd.c I had to turn an existing define_split into a
define_insn_and_split 🙁 🙁

This has been regression tested on riscv32-elf and riscv64-elf.  It's been
bootstrapped and regression tested on the K1 design (where is likely triggered
a few times during bootstrap) and on the Pioneer (which doesn't have Zba, so
this pattern should never trigger).  Waiting on pre-commit testing's verdict.

gcc/

* config/riscv/bitmanip.md (slli_slli_uw): New pattern.
(plus+and+ashift splitter): Turn into define_insn_and_split.
(riscv_slli_uw): Renamed from *slliuw.

gcc/testsuite
* gcc.target/riscv/and-shift-1.c: New test.

4 weeks agoFortran: Fix scalar class to derived select type entities. [PR125263]
Paul Thomas [Sat, 23 May 2026 13:58:36 +0000 (14:58 +0100)] 
Fortran: Fix scalar class to derived select type entities. [PR125263]

2026-05-23  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/125263
* trans-expr.cc (gfc_trans_assignment_1): Pass scalar class to
derived type assignment expressions to gfc_trans_scalar_assign.

gcc/testsuite/
PR fortran/125263
* gfortran.dg/pr125263.f90: New test.

4 weeks agoFortran: Fix ICE in allocatable finalization expression [PR125391]
Paul Thomas [Sat, 23 May 2026 13:40:19 +0000 (14:40 +0100)] 
Fortran: Fix ICE in allocatable finalization expression [PR125391]

2026-05-23  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/125391
* trans.cc (gfc_assignment_finalizer_call): For finalization of
allocatable and pointer lhs before assignment, gfc_conv_expr
should be used with se.descriptor_only. This avoids implicit of
set_factored_descriptor_value by gfc_conv_expr_descriptor.

gcc/testsuite/
PR fortran/125391
* gfortran.dg/pr125391.f90: New test.

4 weeks agopru: Transform patterns to use hard register constraints
Dimitar Dimitrov [Wed, 25 Mar 2026 20:44:33 +0000 (22:44 +0200)] 
pru: Transform patterns to use hard register constraints

Refactor patterns to use hard register constraints.  With this, all the
single-register classes currently defined for PRU can be removed.

gcc/ChangeLog:

* config/pru/constraints.md (MULDST_REGS): Remove constraint.
(MULSRC0_REGS): Ditto.
(MULSRC1_REGS): Ditto.
* config/pru/predicates.md (pru_muldst_operand): Compare
register number directly.
(pru_mulsrc0_operand): Ditto.
(pru_mulsrc1_operand): Ditto.
* config/pru/pru.h (enum reg_class): Remove single-reg classes.
(REG_CLASS_NAMES): Ditto.
(REGNO_REG_CLASS): Ditto.
* config/pru/pru.md (mulsi3): Switch to hard register constraints.
(umulsidi3): Ditto.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
4 weeks agopru: Inline muldi3 when optimizing for speed
Dimitar Dimitrov [Wed, 25 Mar 2026 20:34:05 +0000 (22:34 +0200)] 
pru: Inline muldi3 when optimizing for speed

When optimizing for speed, it is faster to inline the 32-bit
multiplication sub-operations, instead of calling a library function.
This saves instruction cycles spent for preparing a call to the multi64
library function, at the expense of duplication in text section.

The inlined muldi3 operation uses only a few temporary registers,
so there should be no negative effects due to increased register
pressure.  Even more, the register pressure may even decrease with
inlining because the number of temporary registers is much lower than
the number of caller-saved registers for PRU.

gcc/ChangeLog:

* config/pru/constraints.md: Prevent allocating r27 as
SImode destination for mulsi3 pattern.
* config/pru/pru.h (enum reg_class): Expand MULDST_REGS
to allow fitting DImode.
* config/pru/pru.md (umulsidi3): New pattern.
(muldi3): Ditto.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
4 weeks agoc++: defaulted ctor vs template ctor [PR125135]
Jason Merrill [Fri, 22 May 2026 16:57:09 +0000 (12:57 -0400)] 
c++: defaulted ctor vs template ctor [PR125135]

Here we were getting into a CWG1092 cycle again through
check_non_deducible_conversions, trying to lazily declare the RE move
constructor, looking for a constructor to move A, considering the
constructor template which takes RE&, and so trying to lazily declare the RE
constructors again.

Let's break the cycle in the same way.

PR c++/125135

gcc/cp/ChangeLog:

* pt.cc (check_non_deducible_conversions): Handle LOOKUP_DEFAULTED.

gcc/testsuite/ChangeLog:

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

4 weeks agoDaily bump.
GCC Administrator [Sat, 23 May 2026 00:16:25 +0000 (00:16 +0000)] 
Daily bump.

4 weeks agoOpenMP: Enable 'declare mapper' mappers for 'target update' directives
Julian Brown [Fri, 22 May 2026 21:55:50 +0000 (23:55 +0200)] 
OpenMP: Enable 'declare mapper' mappers for 'target update' directives

This patch enables use of 'declare mapper' for 'target update' directives,
for C and C++ but not yet for Fortran.

There are some implementation choices here and some
"read-between-the-lines" consequences regarding this functionality,
as follows:

* It is possible to invoke a mapper which contains clauses that
  don't make sense for a given 'target update' operation.  E.g. if a
  mapper definition specifies a "from:" mapping and the user does "target
  update to(...)" which triggers that mapper, the resulting map kind
  (OpenMP 5.2, "Table 5.3: Map-Type Decay of Map Type Combinations")
  is "alloc" (and for the inverse case "release").  For such cases,
  an '-Wopenmp' warning is issued and the map clause in question is
  dropped from the mapper expansion.  (Other choices might be to make
  this an error, or to do the same thing but silently, or warn only
  given some special option.)

gcc/c-family/ChangeLog:

* c-common.h (enum c_omp_region_type): Add C_ORT_UPDATE and
C_ORT_OMP_UPDATE codes.
* c-omp.cc (omp_basic_map_kind_name): New function.
(omp_instantiate_mapper): Add LOC parameter and 'target update'
support.
(c_omp_instantiate_mappers): Add 'target update' support.

gcc/c/ChangeLog:

* c-parser.cc (c_parser_omp_clause_from_to): Add parsing
for mapper modifier.
(c_parser_omp_target_update): Instantiate mappers.

gcc/cp/ChangeLog:

* parser.cc (cp_parser_omp_clause_from_to): Add parsing for
mapper modifier.
(cp_parser_omp_target_update): Instantiate mappers.

gcc/testsuite/ChangeLog:

* c-c++-common/gomp/target-update-iterators-1.c: Update for
dg-error change.
* c-c++-common/gomp/declare-mapper-19.c: New test.

Co-Authored-By: Tobias Burnus <tburnus@baylibre.com>
4 weeks agoFortran: Fix .texi and comment typos
Tobias Burnus [Fri, 22 May 2026 21:43:43 +0000 (23:43 +0200)] 
Fortran: Fix .texi and comment typos

gcc/fortran/ChangeLog:

* dump-parse-tree.cc: Fix comment typo.
* gfortran.texi: Fix typo.
* intrinsic.texi: Likewise.
* invoke.texi: Likewise.

libgfortran/ChangeLog:

* m4/matmul.m4: Fix comment typo.
* generated/matmul_c10.c: Regenerate.
* generated/matmul_c16.c: Regenerate.
* generated/matmul_c17.c: Regenerate.
* generated/matmul_c4.c: Regenerate.
* generated/matmul_c8.c: Regenerate.
* generated/matmul_i1.c: Regenerate.
* generated/matmul_i16.c: Regenerate.
* generated/matmul_i2.c: Regenerate.
* generated/matmul_i4.c: Regenerate.
* generated/matmul_i8.c: Regenerate.
* generated/matmul_r10.c: Regenerate.
* generated/matmul_r16.c: Regenerate.
* generated/matmul_r17.c: Regenerate.
* generated/matmul_r4.c: Regenerate.
* generated/matmul_r8.c: Regenerate.

4 weeks agoaarch64: Add bitreverse expanders [PR50481]
Disservin [Wed, 20 May 2026 18:01:07 +0000 (20:01 +0200)] 
aarch64: Add bitreverse expanders [PR50481]

Add missing AArch64 bitreverse expanders so __builtin_bitreverse*
can lower to existing rbit patterns.

PR target/50481
gcc/testsuite/ChangeLog:
* gcc.target/aarch64/bitreverse.c: New test.

gcc/ChangeLog:
* config/aarch64/aarch64.md (bitreverse<mode>2, bitreverseqi2,
bitreversehi2): New expanders.
* config/aarch64/aarch64-simd.md (bitreverse<mode>2): New expander.

Signed-off-by: Disservin <disservin.social@gmail.com>
4 weeks ago[PATCH v4] RISC-V: Add per-type reduction costs to the vector cost model
Wang Yaduo [Fri, 22 May 2026 17:26:10 +0000 (11:26 -0600)] 
[PATCH v4] RISC-V: Add per-type reduction costs to the vector cost model

Add type-specific reduction costs for integer (i8/i16/i32/i64) and
floating-point (f16/f32/f64) reductions.  Ordered (fold-left) FP
reductions receive separate higher costs.  Use helpers is_reduction()
and get_reduction_cost() for readability.  Adjust affected tests to use
-mmax-vectorization.

Changes in v4:
  - Fix failure in gcc.target/riscv/rvv/autovec/cond/pr111401.c by
    adding -mmax-vectorization.

Tested locally with qemu, all affected tests pass.

gcc/
* config/riscv/riscv-protos.h (common_vector_cost): Add
reduc_i8_cost through reduc_f64_cost and
reduc_f{16,32,64}_ordered_cost.
* config/riscv/riscv.cc: Set costs in rvv_vls_vector_cost and
rvv_vla_vector_cost.
* config/riscv/riscv-vector-costs.cc (is_reduction): New helper.
(get_reduction_cost): New helper.
(costs::adjust_stmt_cost): Use them for vec_to_scalar kind.

gcc/testsuite

* gcc.dg/vect/costmodel/riscv/rvv/reduc_vla_ordered.c: New.
* gcc.dg/vect/costmodel/riscv/rvv/reduc_vla_unordered.c: New.
* gcc.dg/vect/costmodel/riscv/rvv/reduc_vls_ordered.c: New.
* gcc.dg/vect/costmodel/riscv/rvv/reduc_vls_unordered.c: New.
* gcc.target/riscv/rvv/autovec/cond/pr111401.c: Use
-mmax-vectorization.
* gcc.target/riscv/rvv/autovec/vls/reduc-19.c: Use
-mmax-vectorization, adjust scan counts.
* gcc.target/riscv/rvv/autovec/vls/reduc-20.c: Likewise.
* gcc.target/riscv/rvv/autovec/vls/reduc-21.c: Likewise.
* gcc.target/riscv/rvv/autovec/vls/wred-3.c: Likewise.

4 weeks agocfgrtl: Forbid forwarder blocks from having clobbers [PR125375]
Richard Sandiford [Fri, 22 May 2026 15:27:31 +0000 (16:27 +0100)] 
cfgrtl: Forbid forwarder blocks from having clobbers [PR125375]

In this testcase, jump2 was presented with:

 L1:
    set the return register
    do epilogue stuff
    goto L4

 L2:
    do the same epilogue stuff

 L3:
    clobber the return register
    goto L4

The question then is: is the L3 block a forwarder block?  It is a
forwarder block in the sense that a jump to L3 can be replaced with a
jump to L4.  But it isn't a forwarder block in the sense of a jump to L3
being equivalent to a jump to L4.  In particular, a jump to L4 cannot be
merged with a jump or fallthrough to L3 unless we can prove that the
clobber is valid for both paths.

In the testcase, L3 was marked as a forwarder block and so cross-jumping
created:

 L1:
    set the return register

 L2:
    do epilogue stuff

 L3:
    clobber the return register
    goto L4

The set of the return register was then inevitably deleted as dead.

The clobber in this case is of the return register.  But the same
principle/problem would apply to any clobber.  We can't introduce new
clobbers on a path without proving that the clobbered thing is dead.

This question arises due to an old quirk of active_insn_p that predates
CVS history:

  bool
  active_insn_p (const rtx_insn *insn)
  {
    return (CALL_P (insn) || JUMP_P (insn)
    || JUMP_TABLE_DATA_P (insn) /* FIXME */
    || (NONJUMP_INSN_P (insn)
&& (! reload_completed
    || (GET_CODE (PATTERN (insn)) != USE
&& GET_CODE (PATTERN (insn)) != CLOBBER))));
  }

Thus a clobber is "active" before RA but not after it.  This means
that, according to flow_active_insn_p, a block with a clobber is not
a forwarder block before RA, but can be afterwards.

The "most optimal" solution would probably be to split the concept
of forwarder block into two, one that allows clobbers and one that
doesn't.  However, that would be difficult to retrofit at this stage
and isn't likely to be suitable for backporting.  This patch therefore
takes the more conservative approach of making flow_active_insn_p treat
clobbers in the same way after RA as it does before RA.

Some of this infrastructure is probably ripe for updating.  For example,
flow might have required explicit uses of the return register, but DF
should cope well enough without.  We should probably also check
whether the active_insn_p behaviour still makes sense.

gcc/
PR rtl-optimization/125375
* cfgrtl.cc (flow_active_insn_p): Return true for clobbers.

gcc/testsuite/
* gcc.dg/pr125375.c: New test.

4 weeks agoRe: [Linaro-TCWG-CI] gcc-17-577-gbc19036af435: 2 regressions on aarch64
Jeff Law [Fri, 22 May 2026 15:21:31 +0000 (09:21 -0600)] 
Re: [Linaro-TCWG-CI] gcc-17-577-gbc19036af435: 2 regressions on aarch64

>>> Produces 2 regressions:
>>>    |
>>>    | regressions.sum:
>>>    | Running gcc:gcc.target/aarch64/aarch64.exp ...
>>>    | FAIL: gcc.target/aarch64/tbz_1.c check-function-bodies g1
>>>    | FAIL: gcc.target/aarch64/tbz_1.c check-function-bodies g2
>> I've reproduced this locally.  I haven't gotten into the debug cycle
>> yet, but wanted folks to know it's mine AFAICT to avoid duplicating
>> debugging efforts.
>
> I think the fix is just a testcase fix.
> Currently the testcase has:
> **      tbnz    w[0-9]+, #?0, .L([0-9]+)
>
> But that should just can be:
> **      tbnz    [wx][0-9]+, #?0, .L([0-9]+)
>
> to match both x0 and w0 there. But are valid in this case with bit 0.
> For both g1 and g2.
Yea, so I wanted to verify this was behaving per expectation.  It is.  We have
this in g1:

> (insn 2 4 3 2 (set (reg/v:SI 101 [ x ])
>         (zero_extend:SI (reg:QI 0 x0 [ x ]))) "j.c":16:1 149 {*zero_extendqisi2_aarch64}
>      (expr_list:REG_DEAD (reg:QI 0 x0 [ x ])
>         (nil)))
> (note 3 2 6 2 NOTE_INSN_FUNCTION_BEG)
> (insn 6 3 7 2 (set (reg:SI 102)
>         (and:SI (reg/v:SI 101 [ x ])
>             (const_int 1 [0x1]))) "j.c":17:6 discrim 1 551 {andsi3}
>      (expr_list:REG_DEAD (reg/v:SI 101 [ x ])
>         (nil)))

We can trivially see that the zero extension is pointless because the value is
masked with 0x1 immediately thereafter.  So ext-dce replaces the zero_extend
with a subreg which then simplifies the sequence into:

> (insn 2 4 3 2 (set (reg/v:SI 101 [ x ])
>         (reg:SI 0 x0 [ x ])) "j.c":16:1 104 {*movsi_aarch64}
>      (expr_list:REG_DEAD (reg:QI 0 x0 [ x ])
>         (nil)))
> (note 3 2 6 2 NOTE_INSN_FUNCTION_BEG)
> (insn 6 3 7 2 (set (reg:SI 102)
>         (and:SI (reg/v:SI 101 [ x ])
>             (const_int 1 [0x1]))) "j.c":17:6 discrim 1 551 {andsi3}
>      (expr_list:REG_DEAD (reg/v:SI 101 [ x ])
>         (nil)))

Combine then turns it into:

> (insn 28 4 2 2 (set (reg:SI 103 [ x ])
>         (reg:SI 0 x0 [ x ])) "j.c":16:1 -1
>      (expr_list:REG_DEAD (reg:SI 0 x0 [ x ])
>         (nil)))
> (note 2 28 3 2 NOTE_INSN_DELETED)
> (note 3 2 6 2 NOTE_INSN_FUNCTION_BEG)
> (note 6 3 7 2 NOTE_INSN_DELETED)
> (note 7 6 8 2 NOTE_INSN_DELETED)
> (jump_insn 8 7 9 2 (parallel [
>             (set (pc)
>                 (if_then_else (eq (zero_extract:DI (subreg:DI (reg:SI 103 [ x ]) 0)
>                             (const_int 1 [0x1])
>                             (const_int 0 [0]))
>                         (const_int 0 [0]))
>                     (label_ref:DI 14)
>                     (pc)))
>             (clobber (reg:CC 66 cc))
>         ]) "j.c":17:6 discrim 1 76 {aarch64_tbzeqdidi}
>      (expr_list:REG_UNUSED (reg:CC 66 cc)
>         (expr_list:REG_DEAD (reg:SI 103 [ x ])
>             (int_list:REG_BR_PROB 966367641 (nil))))

Without the recent ext-dce improvement we get this out of combine:

> (jump_insn 8 7 9 2 (parallel [
>             (set (pc)
>                 (if_then_else (eq (zero_extract:SI (reg:SI 0 x0 [ x ])
>                             (const_int 1 [0x1])
>                             (const_int 0 [0]))
>                         (const_int 0 [0]))
>                     (label_ref:DI 14)
>                     (pc)))
>             (clobber (reg:CC 66 cc))
>         ]) "k.c":17:6 discrim 1 47 {aarch64_tbeqsisi}
>      (expr_list:REG_UNUSED (reg:CC 66 cc)
>         (expr_list:REG_DEAD (reg:QI 0 x0 [ x ])
>             (int_list:REG_BR_PROB 966367644 (nil))))

Note the difference in zero_extract's mode within the bit-test insn.  DI vs SI.
Hence the w vs x difference in the resulting assembly code.

gcc/testsuite
* gcc.target/aarch64/tbz_1.c: Update expected output.

4 weeks agoFortran: invoke.texi - document -fcoarray=shared [PR125416]
Tobias Burnus [Fri, 22 May 2026 13:51:19 +0000 (15:51 +0200)] 
Fortran: invoke.texi - document -fcoarray=shared [PR125416]

gcc/fortran/ChangeLog:

PR fortran/125416
* invoke.texi (fcoarray): Document 'shared'.

4 weeks agolibstdc++: Fix some test failures due to vector using allocate_at_least
Jonathan Wakely [Fri, 22 May 2026 12:25:57 +0000 (13:25 +0100)] 
libstdc++: Fix some test failures due to vector using allocate_at_least

Some std::vector tests are FAILing for 32-bit targets because
std::vector now rounds up allocations to an alignment boundary,
perturbing the expected capacity of the vectors in the tests.

Tweak the tests so that they don't depend on the precise capacity, which
is unspecified anyway.

The 23_containers/vector/modifiers/insert_vs_emplace.cc test still
FAILs, that needs a different fix.

libstdc++-v3/ChangeLog:

* testsuite/23_containers/vector/modifiers/emplace/self_emplace.cc:
Ensure there is no unused capacity before inserting new element.
* testsuite/23_containers/vector/modifiers/insert/self_insert.cc:
Likewise.

4 weeks agomatch.pd: Handle BUILT_IN_BITREVERSE8 like other BUILT_IN_BITREVERSE* [PR125399]
Jakub Jelinek [Fri, 22 May 2026 09:19:18 +0000 (11:19 +0200)] 
match.pd: Handle BUILT_IN_BITREVERSE8 like other BUILT_IN_BITREVERSE* [PR125399]

I've mistakenly omitted BUILT_IN_BITREVERSE8 in the BITREVERSE
operator list.

The following patch fixes that, plus extends the __builtin_bitreverse32
test with one further check and duplicates the test for the other
builtins, i.e. __builtin_bitreverse{8,16,64,128}.

2026-05-22  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/125399
* match.pd (BITREVERSE): Add BUILT_IN_BITREVERSE8.

* gcc.dg/builtin-bitreverse-4.c (foo9): New function.
* gcc.dg/builtin-bitreverse-5.c: New test.
* gcc.dg/builtin-bitreverse-6.c: New test.
* gcc.dg/builtin-bitreverse-7.c: New test.
* gcc.dg/builtin-bitreverse-8.c: New test.

Reviewed-by: Richard Biener <rguenth@suse.de>
4 weeks agoc++, libstdc++: Implement C++26 P3074R7 and CWG3189 - trivial unions [PR119059]
Jakub Jelinek [Fri, 22 May 2026 08:15:45 +0000 (10:15 +0200)] 
c++, libstdc++: Implement C++26 P3074R7 and CWG3189 - trivial unions [PR119059]

The following patch attempts to implement the C++26
P3074R7 - trivial unions (was std::uninitialized<T>)
paperand proposed resolution of
CWG3189 - Implicitly deleted destructors for union-like classes
with the exception of the
  #define __cpp_lib_constexpr_inplace_vector 2025XXL // also in <inplace_vector>
addition and possibly needed <inplace_vector> changes (will defer that to
Jonathan / Tomasz) and except for the changes in [class.default.ctor]/4 which
were reverted by P3726R2 later on .

There is one change which doesn't affect just C++26 but also older versions
of the standard, https://eel.is/c++draft/class.default.ctor#2.2 or its older
counterparts, e.g. C++11 had in [class.ctor]/5
"any non-variant non-static data member of const-qualified type (or array thereof)
with no brace-or-equal-initializer does not have a user-provided default
constructor"
but we've been ignoring the "non-variant" part thereof and diagnosing it
for variant members too.  Note, this is related to the other unimplemented
rule I've posted a patch earlier for that was dismissed (reject
all variant members const before C++26), so some cases which we've rejected
for a wrong reason will now be accepted when they are still invalid before
C++26.

2026-05-22  Jakub Jelinek  <jakub@redhat.com>

PR c++/119059
gcc/c-family/
* c-cppbuiltin.cc (c_cpp_builtins): For C++26 predefine
__cpp_trivial_union to 202502L.
gcc/cp/
* method.cc: Implement C++26 P3074R7 - trivial unions (was
std::uninitialized<T>) (except the sentence removed again in P3726R2)
and proposed resolution of CWG3189 - Implicitly deleted destructors
for union-like classes.
(walk_field_subobs): Don't do default_init_uninitialized_part checks
for variant members.  Don't check subobject ctor/dtor for variant
members for ctor/inheriting ctor or when subobject doesn't have member
initializer for dtor and it is either the dtor_from_ctor case or
the current class doesn't have user provided ctors.
* class.cc (check_field_decl): Don't or in
TYPE_HAS_NONTRIVIAL_DESTRUCTOR or TYPE_HAS_DEFAULT_CONSTRUCTOR of
variant subobjects for C++26.
gcc/testsuite/
* g++.dg/DRs/dr2581-1.C: Expect warning for __cpp_trivial_union.
* g++.dg/DRs/dr2581-2.C: Expect error for __cpp_trivial_union.
* g++.dg/cpp26/feat-cxx26.C: Add __cpp_trivial_union checking.
* g++.dg/cpp26/trivial-union1.C: New test.
* g++.dg/cpp26/trivial-union2.C: New test.
* g++.dg/reflect/trivial-union1.C: New test.
* g++.dg/reflect/type_trait6.C: Adjust expected result of
one is_destructible_type and two is_nothrow_destructible_type calls.
* g++.dg/reflect/is_constructible_type1.C: Adjust expected result
of one is_constructible_type call.
* g++.dg/init/pr43719.C: Don't expect one error.
* g++.dg/init/pr25811.C: Don't expect 3 diagnostic messages,
instead expect a different one for C++98 only.
* g++.dg/other/anon-union2.C: Only expect one diagnostic for
C++23 and older.
* g++.dg/cpp0x/union1.C: Only expect 6 diagnostic messages for
C++23 and older.
* g++.dg/cpp0x/union4.C: Only expect 3 diagnostic messages for
C++23 and older.
* g++.dg/cpp0x/defaulted2.C: Only expect 2 diagnostic messages for
C++23 and older.

Reviewed-by: Jason Merrill <jason@redhat.com>
4 weeks agors6000: Add MPCCORE to TARGET_NO_LWSYNC
Kishan Parmar [Fri, 22 May 2026 06:55:25 +0000 (12:25 +0530)] 
rs6000: Add MPCCORE to TARGET_NO_LWSYNC

The MPC8xx PowerQUICC family only implements full 'sync', 'lwsync'
is not yet supported. The CPU actually checks that the
should-be-zero bits of the sync instruction are zero, and faults
otherwise - same situation as for E500 cores.

Fix emitting 'lwsync' instructions by adding PROCESSOR_MPCCORE
to the TARGET_NO_LWSYNC define.

Encountered an illegal instruction crash (in libstdc++ atomics) and
verified the fix on actual MPC860 hardware.

Minimal test:

  $ cat test.c
  #include <stdatomic.h>
  atomic_int counter;
  void store_release(int val) {
      atomic_store_explicit(&counter, val, memory_order_release);
  }

  $ powerpc-linux-gnu-gcc -mcpu=860 -O2 -S -o- test.c | grep sync
  lwsync     <-- should be sync

  $ powerpc-linux-gnu-gcc -mcpu=8540 -O2 -S -o- test.c | grep sync
  sync       <-- correct (TARGET_NO_LWSYNC already covers E500/8540)

2026-05-22  Steve Markgraf  <steve@steve-m.de>

gcc/ChangeLog:
* config/rs6000/rs6000.h (TARGET_NO_LWSYNC): Add PROCESSOR_MPCCORE.

gcc/testsuite/ChangeLog:
* gcc.target/powerpc/mpc860_no_lwsync.c: New test.

4 weeks agomatch: Handle X != INT_MIN ? -X : INT_MIN [PR125050]
Avinal Kumar [Thu, 21 May 2026 10:24:12 +0000 (15:54 +0530)] 
match: Handle X != INT_MIN ? -X : INT_MIN [PR125050]

The pattern X != C1 ? -X : C2 currently bails out when C1 is
INT_MIN and the type doesn't wrap, because a signed negation
of INT_MIN is undefined behavior.  But the whole expression is
well-defined: it is equivalent to (signed)(-(unsigned)X).

Handle the wi::only_sign_bit_p case by emitting an unsigned
negate instead of giving up, mirroring what the abs pattern
already does for the same edge case.

PR tree-optimization/125050

gcc/ChangeLog:

* match.pd: (X != C1 ? -X : C2): Handle C1 being INT_MIN
by emitting (signed)(-(unsigned)X) instead of bailing out.

gcc/testsuite/ChangeLog:

* gcc.dg/fold-condneg-2.c: Update expected optimization.
* gcc.dg/pr125050.c: New test.
* gcc.dg/tree-ssa/phi-opt-50.c: New test.
* gcc.dg/tree-ssa/phi-opt-51.c: New test.

Signed-off-by: Avinal Kumar <avinal.xlvii@gmail.com>
4 weeks agoDaily bump.
GCC Administrator [Fri, 22 May 2026 00:16:32 +0000 (00:16 +0000)] 
Daily bump.

4 weeks agolibstdc++: Combine duplicated tests for <atomic>
Jonathan Wakely [Thu, 21 May 2026 22:13:53 +0000 (23:13 +0100)] 
libstdc++: Combine duplicated tests for <atomic>

The types_std_c++0x.cc and types_std_c++20.cc tests are almost
identical, and the latter is redundant now that we can (and do) run all
tests for any -std option, and run with -std=gnu++20 by default.
Likewise for the _neg.cc tests.

Merge the C++20-specific parts into the c++0x tests and remove the c++20
ones.

libstdc++-v3/ChangeLog:

* testsuite/29_atomics/headers/atomic/types_std_c++0x.cc: Check
for C++20 std::memory_order enum. Use feature test macro for
char8_t.
* testsuite/29_atomics/headers/atomic/types_std_c++0x_neg.cc:
Add check for atomic_char8_t.
* testsuite/29_atomics/headers/atomic/types_std_c++20.cc:
Removed.
* testsuite/29_atomics/headers/atomic/types_std_c++20_neg.cc:
Removed.
* testsuite/29_atomics/headers/atomic/types_std_c++2a.cc:
Removed.

4 weeks agoavoid-store-forwarding: Continue BB analysis after complex memory ops
Konstantinos Eleftheriou [Fri, 27 Mar 2026 13:26:48 +0000 (06:26 -0700)] 
avoid-store-forwarding: Continue BB analysis after complex memory ops

The pass aborted analysis of the entire remaining basic block when it
encountered a complex memory operation (non-simple store/load).
Store-forwarding opportunities after the complex operation were silently
missed.

Replace the early return with a flush-and-continue: clear the pending
store candidates and keep scanning.  The two other flush sites
(throwing insns, unknown-size memory) already use this pattern.

gcc/ChangeLog:

* avoid-store-forwarding.cc
(store_forwarding_analyzer::avoid_store_forwarding): Replace
return with flush-and-continue for complex memory operations.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/avoid-store-forwarding-6.c: New test.

4 weeks agoavoid-store-forwarding: Reject bit-inserts that clobber live hard regs
Konstantinos Eleftheriou [Fri, 27 Mar 2026 13:26:37 +0000 (06:26 -0700)] 
avoid-store-forwarding: Reject bit-inserts that clobber live hard regs

The bit-insert sequences generated by store_bit_field can clobber hard
registers (such as the flags register on x86) as a side effect.  If
such a register is live at the insertion point, the transformation
would corrupt it, breaking flag-dependent sequences like carry chains
(see PR119795).

Add a liveness check in process_store_forwarding: after generating the
bit-insert sequences, collect the hard registers they clobber (excluding
the intended destination) and reject the transformation if any of them
is live at the insertion point.  Per-insn live-out hard-register sets
are computed once per BB by simulating it backward with
df_simulate_one_insn_backwards, and cached in store_forwarding_analyzer
so subsequent forwarding candidates in the same BB reuse the result.
The cache is populated lazily on the first candidate that produces
non-empty clobbers, so on targets where bit-inserts have no side-effect
clobbers (such as aarch64 bfi) the BB walk never runs.

gcc/ChangeLog:

* avoid-store-forwarding.cc: Include regs.h.
(record_hard_reg_clobbers): New callback.
(store_forwarding_analyzer::m_bb_live_after): New cache.
(store_forwarding_analyzer::compute_bb_live_after): New helper.
(store_forwarding_analyzer::process_store_forwarding): Add
liveness check for hard registers clobbered by bit-insert
sequences, using the cached per-BB live-out information, and
evict the load_insn entry from the cache before delete_insn
in the load-elim path.
(store_forwarding_analyzer::avoid_store_forwarding): Clear the
per-BB liveness cache on entry.

4 weeks agoavoid-store-forwarding: Remove unnecessary store_exprs_del mechanism
Konstantinos Eleftheriou [Tue, 24 Mar 2026 12:21:38 +0000 (13:21 +0100)] 
avoid-store-forwarding: Remove unnecessary store_exprs_del mechanism

The store_exprs_del vector was introduced in the PR119795 fix as a
conservative safety measure alongside the actual bug fixes (adding
forwardings.truncate(0) on vector mismatch and true_dependence
detection).  It tracks deleted store candidates and blocks forwarding
when a deleted store's range overlaps with the load.

However, this check is not needed for correctness.  In the non-load-
elimination path the load is kept and reads all bytes from memory;
the bit-insert only overwrites forwarded bytes.  Deleted stores remain
in the instruction stream, so their memory effects are visible to the
load.  In the load-elimination path, all bytes must be covered by
forwarded stores (enforced by the bitmap check), so missing stores
cannot cause partial updates.

The vector grows monotonically through the basic block and is scanned
for each forwarding candidate, producing O(n^2) behavior for large
basic blocks.

Remove the mechanism entirely.  This eliminates the O(n^2) scan and
simplifies the code.

gcc/ChangeLog:

* avoid-store-forwarding.cc
(store_forwarding_analyzer::avoid_store_forwarding): Remove
store_exprs_del vector and all associated tracking.  Remove the
same_range_as_removed check from the forwarding loop.  Update
block comment.

4 weeks agolibstdc++: Fix recent std::flat_map test with COW std::string
Patrick Palka [Thu, 21 May 2026 22:35:55 +0000 (18:35 -0400)] 
libstdc++: Fix recent std::flat_map test with COW std::string

... which is not constexpr, so just disable constant evaluation of the
test in this case.

libstdc++-v3/ChangeLog:

* testsuite/23_containers/flat_map/1.cc (test_constexpr):
If std::string isn't constexpr don't run test10.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
4 weeks agolibffi: Update list of local patches
Pietro Monteiro [Thu, 21 May 2026 21:59:57 +0000 (17:59 -0400)] 
libffi: Update list of local patches

Remove all old patches and add the one after the most recent upgrade.

libffi/ChangeLog:

* LOCAL_PATCHES: Update list.

Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
4 weeks agolibffi: Remove debugging output
Pietro Monteiro [Thu, 21 May 2026 21:59:57 +0000 (17:59 -0400)] 
libffi: Remove debugging output

The warning is printed when running tests, making dejagnu mark them as
failed when running 32-bit tests on x86_64.

Forwarded upstream: https://github.com/libffi/libffi/pull/940

libffi/ChangeLog:
PR libffi/117635
* src/x86/ffitarget.h (if defined (X86_64) &&
defined (__i386__)): Remove #warning.

Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
4 weeks agolibffi: Always define `WIN32_LEAN_AND_MEAN` before <windows.h>
Pietro Monteiro [Thu, 21 May 2026 21:59:57 +0000 (17:59 -0400)] 
libffi: Always define `WIN32_LEAN_AND_MEAN` before <windows.h>

From commit:
902c755930326cb4405672aa3ea13c35c653cbff - Always define `WIN32_LEAN_AND_MEAN` before <windows.h>

Forwarded upstream: https://github.com/libffi/libffi/pull/937

libffi/ChangeLog:
PR libffi/117635
* src/aarch64/ffi.c: Define `WIN32_LEAN_AND_MEAN` before
`#include <windows.h>`.

Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
4 weeks agolibffi: Integrate testsuite with GCC testsuite
Pietro Monteiro [Thu, 21 May 2026 21:59:57 +0000 (17:59 -0400)] 
libffi: Integrate testsuite with GCC testsuite

From commits:
4824ed41ba7cd63e60fd9f8769a58b79935a90d1 - libffi: Integrate testsuite with GCC testsuite
a0673ec5f9236dca6ada23f28343c591ccd575e4 - Testsuite: allow non-installed testing on darwin
967d4171b2eb0557e86ba28996423353f0f1b141 - libffi: Consider '--with-build-sysroot=[...]' for target libraries' build-tree testing (instead of build-time 'CC' etc.) [PR109951]

libffi/ChangeLog:
PR libffi/117635
* testsuite/lib/libffi.exp (load_gcc_lib): Load library from GCC
testsuite.
Load target-supports.exp and target-supports-dg.exp.
(libffi-init): Use libraries in GCC build tree.
Pass correct flags on darwin.
(libffi_target_compile): If '--with-build-sysroot=[...]' was
specified, use it for build-tree testing. Link with
-shared-libgcc -lstdc++ for C++ sources.

Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
4 weeks agolibffi: Integrate build with GCC
Pietro Monteiro [Thu, 21 May 2026 21:59:56 +0000 (17:59 -0400)] 
libffi: Integrate build with GCC

>From commits:
5be7b66998127286fada45e4f23bd8a2056d553e - libffi: Integrate build with GCC
333efaea633971912f2208d37b7b62992759d400 - libffi: Add --enable-cet to configure
6a6d3817afa02bbcd2388c8e005da6faf88932f1 - Config,Darwin: Allow for configuring Darwin to use embedded runpath.
967d4171b2eb0557e86ba28996423353f0f1b141 - libffi: Consider '--with-build-sysroot=[...]' for target libraries' build-tree testing (instead of build-time 'CC' etc.) [PR109951]
35b05a02de1e8aee7c754a20f50736977c71caca - build: Derive object names in make_sunver.pl

libffi/ChangeLog:
PR libffi/117635
* Makefile.am (AUTOMAKE_OPTIONS): Add info-in-builddir.
(ACLOCAL_AMFLAGS): Set to -I .. -I ../config.
(SUBDIRS): Don't add doc.
(TEXINFO_TEX): New.
(MAKEINFOFLAGS): Likewise.
(info_TEXINFOS): Likewise.
(STAMP_GENINSRC): Likewise.
(STAMP_BUILD_INFO): Likewise.
(all-local): Likewise.
(stamp-geninsrc): Likewise.
(doc/libffi.info): Likewise.
(stamp-build-info:): Likewise.
(CLEANFILES): Likewise.
(MAINTAINERCLEANFILES): Likewise.
(AM_MAKEFLAGS): Likewise.
(LTLDFLAGS): Replace libtool-ldflags with ../libtool-ldflags.
(AM_CFLAGS): Add -Wall -g -fexceptions $(CET_FLAGS).
(libffi.map-sun): Replace make_sunver.pl with
../contrib/make_sunver.pl. Pass $(libffi_la_OBJECTS),
$(libffi_la_LIBADD) to make_sunver.pl unmodified.
(libffi_la_LDFLAGS): Handle Darwin rpaths.
(AM_CCASFLAGS): Add $(CET_FLAGS).
(all-recursive): New.
(install-recursive): Likewise.
(mostlyclean-recursive): Likewise.
(clean-recursive): Likewise.
(distclean-recursive): Likewise.
(maintainer-clean-recursive): Likewise.
(dist-hook): Removed.
Include $(top_srcdir)/../multilib.am.
* Makefile.in: Regenerate.
* configure: Regenerate.
* configure.ac: Add AM_ENABLE_MULTILIB.
Remove the frv*-elf check.
(AX_ENABLE_BUILDDIR): Removed.
(AM_INIT_AUTOMAKE): Add [no-dist].
Add --enable-generated-files-in-srcdir.
(CET_FLAGS): Add GCC_CET_FLAGS and AC_SUBST.
(AC_CONFIG_MACRO_DIR): Removed.
(AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH])): New.
(AX_COMPILER_VENDOR): Removed.
(AX_CC_MAXOPT): Likewise.
(AX_CFLAGS_WARN_ALL): Likewise.
Remove the GCC check.
(AC_SUBST(SYSROOT_CFLAGS_FOR_TARGET)): New.
<local.exp>: Don't set 'CC_FOR_TARGET', 'CXX_FOR_TARGET',
instead set 'SYSROOT_CFLAGS_FOR_TARGET'.
(m4_warn([obsolete])): Removed.
(LT_SYS_SYMBOL_USCORE): Likewise.
(AX_CHECK_COMPILE_FLAG): Likewise.
Remove --disable-docs.
(ACX_CHECK_PROG_VER): Check makeinfo.
(BUILD_DOCS): Updated.
(exec-static-tramp): Don't enable use of static exec trampolines
by default.
Remove --disable-multi-os-directory.
(GCC_WITH_TOOLEXECLIBDIR): New.
Support cross host.
Support --enable-multilib.
(GCC_BASE_VER): New.
(AC_CONFIG_FILES): Remove doc/Makefile.
(AC_CONFIG_LINKS): New.
* fficonfig.h.in: Regenerate.
* include/Makefile.am (nodist_include_HEADERS): Removed.
(gcc_version): New.
(toollibffidir): Likewise.
(toollibffi_HEADERS): Likewise.
* include/Makefile.in: Regenerate.
* man/Makefile.in: Regenerate.
* testsuite/Makefile.in: Regenerate.

Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
4 weeks agolibffi: Sync with libffi 3.5.2
Pietro Monteiro [Thu, 21 May 2026 21:59:56 +0000 (17:59 -0400)] 
libffi: Sync with libffi 3.5.2

Merged commit: e2eda0cf72a0598b44278cc91860ea402273fa29

Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
4 weeks agoc++: fix bogus error with xobj member function [PR125330]
Marek Polacek [Tue, 19 May 2026 00:51:06 +0000 (20:51 -0400)] 
c++: fix bogus error with xobj member function [PR125330]

In this test since r17-472 we issue a bogus "not declared in this scope"
error when parsing the requires because we failed to pushdecl.  Xobj
parameters reuse the default argument field (in _parameter_declaration)
so we also have to check this_identifier.

PR c++/125330

gcc/cp/ChangeLog:

* parser.cc (cp_parser_parameter_declaration_list): Also
pushdecl when parameter->default_argument is this_identifier.

gcc/testsuite/ChangeLog:

* g++.dg/cpp23/explicit-obj-basic8.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
4 weeks agoinstall: The C++ front end does not use extensions
Gerald Pfeifer [Wed, 20 May 2026 12:04:27 +0000 (14:04 +0200)] 
install: The C++ front end does not use extensions

gcc:
* doc/install.texi (Prerequisites): The C++ front end also does
not use extensions.

4 weeks agoc++: another constexpr empty class tweak
Jason Merrill [Tue, 19 May 2026 09:15:00 +0000 (05:15 -0400)] 
c++: another constexpr empty class tweak

While talking about PR125336, I noticed that we were unnecessarily omitting
a subobject CONSTRUCTOR for non-potentially-overlapping fields of empty
class type.  Let's check is_empty_field instead.

gcc/cp/ChangeLog:

* constexpr.cc (init_subob_ctx): Check is_empty_field.

4 weeks agoc++: this capture in template [PR125384]
Jason Merrill [Thu, 21 May 2026 19:02:21 +0000 (15:02 -0400)] 
c++: this capture in template [PR125384]

The r16-1019 change to special-case 'this' capture handling dropped the
'const' qualifier from the capture proxy, so the call to rvalue in
finish_this_expr no longer built a NOP_EXPR to express dropping that
'const'.

PR c++/125384
PR c++/113563

gcc/cp/ChangeLog:

* lambda.cc (build_capture_proxy): 'this' capture proxy is const.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/lambda/lambda-this23.C: New test.

4 weeks agoAArch64: Add PIC/PIE support to large model [PR 123791]
Wilco Dijkstra [Mon, 9 Feb 2026 19:01:19 +0000 (19:01 +0000)] 
AArch64: Add PIC/PIE support to large model [PR 123791]

Use an indirection via GOT for data accesses that might be out of range of
ADRP.  Using the GOT avoids placing relro symbol references in literal pools
(PR 123791).  It also allows the large model to trivially support PIC/PIE.
Constants and readonly data use ADRP since the maximum text size is 2GB in
the large model [1].  The code quality of -mcmodel=large improves dramatically
as a result: codesize of SPEC2017 reduces by 2.2%.

[1] https://github.com/ARM-software/abi-aa/blob/main/sysvabi64/sysvabi64.rst#code-models

gcc:
PR target/123791
* config/aarch64/aarch64.cc (aarch64_cannot_force_const_mem): Remove
forcing symbol references to const mem.
(aarch64_can_use_per_function_literal_pools_p): Return false for
large model.
(aarch64_use_blocks_for_constant_p): Update comment.
(initialize_aarch64_code_model): Allow PIC/PIE.
(aarch64_classify_symbol): Use SYMBOL_SMALL_ABSOLUTE for constant
references and SYMBOL_SMALL_GOT_4G for writeable data.

gcc/testsuite:
PR target/123791
* gcc.target/aarch64/pr123791.c: Update test.
* gcc.target/aarch64/pr63304_1.c: Likewise.
* gcc.target/aarch64/pr78733.c: Likewise.
* gcc.target/aarch64/pr79041-2.c: Likewise.