From: Steve Baird Date: Fri, 11 Jul 2025 21:40:59 +0000 (-0700) Subject: ada: Use-before-definition of a component of discriminated aggregate's itype. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1409e64e870a32eedce096d4e800e7a4a2f7ab79;p=thirdparty%2Fgcc.git 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 --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 9458bdea663..cd98369a918 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));