]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Use-before-definition of a component of discriminated aggregate's itype.
authorSteve Baird <baird@adacore.com>
Fri, 11 Jul 2025 21:40:59 +0000 (14:40 -0700)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 24 Jul 2025 08:52:37 +0000 (10:52 +0200)
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.

gcc/ada/exp_aggr.adb

index 9458bdea66330fcf44efba879280e56707f1c6b9..cd98369a91890781b458e2c1d2154251369d79e6 100644 (file)
@@ -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));