https://gcc.gnu.org/g:1409e64e870a32eedce096d4e800e7a4a2f7ab79
commit r16-2465-g1409e64e870a32eedce096d4e800e7a4a2f7ab79 Author: Steve Baird <ba...@adacore.com> Date: Fri Jul 11 14:40:59 2025 -0700 ada: Use-before-definition of a component of discriminated aggregate's itype. In some cases involving assigning an aggregate to a formal parameter of an unconstrained discriminated subtype that has a Dynamic_Predicate, and where the discriminated type also has a component of an unconstrained discriminated subtype, the front end generates a malformed tree which causes a compilation failure when the backend fails a consistency check. gcc/ada/ChangeLog: * exp_aggr.adb (Convert_To_Assignments): Add calls to Ensure_Defined before generating assignments to components that could be associated with a not-yet-defined itype. Diff: --- gcc/ada/exp_aggr.adb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 9458bdea6633..cd98369a9189 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -4349,6 +4349,7 @@ package body Exp_Aggr is and then Is_Limited_Type (Typ) then Target_Expr := New_Copy_Tree (Name (Parent_Node)); + Ensure_Defined (Typ, Parent_Node); Insert_Actions (Parent_Node, Build_Record_Aggr_Code (N, Typ, Target_Expr)); Rewrite (Parent_Node, Make_Null_Statement (Loc)); @@ -4374,6 +4375,7 @@ package body Exp_Aggr is if Nkind (N) in N_Aggregate | N_Extension_Aggregate then Target_Expr := New_Copy_Tree (Lhs); + Ensure_Defined (Typ, Parent_Node); Insert_Actions (Parent_Node, Build_Record_Aggr_Code (N, Typ, Target_Expr)); Rewrite (Parent_Node, Make_Null_Statement (Loc));