]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix internal error on aggregate within container aggregate
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 25 May 2023 22:09:14 +0000 (00:09 +0200)
committerEric Botcazou <ebotcazou@adacore.com>
Sun, 5 Jan 2025 11:18:51 +0000 (12:18 +0100)
This just applies the same fix to Expand_Array_Aggregate as the one that was
recently applied to Convert_To_Assignments.

gcc/ada/
PR ada/118234
* exp_aggr.adb (Convert_To_Assignments): Tweak comment.
(Expand_Array_Aggregate): Do not delay the expansion if the parent
node is a container aggregate.

gcc/ada/exp_aggr.adb

index a97882dba73a3b381c497f426e2fa0855d2038d6..cda5e66943ec6c87861e75ec745eadbff391b41c 100644 (file)
@@ -4929,9 +4929,9 @@ package body Exp_Aggr is
       --  done top down from above.
 
       if
-         --  Internal aggregate (transformed when expanding the parent)
-         --  excluding the Container aggregate as these are transformed to
-         --  procedure call later.
+         --  Internal aggregates (transformed when expanding the parent),
+         --  excluding container aggregates as these are transformed into
+         --  subprogram calls later.
 
          (Parent_Kind in
             N_Component_Association | N_Aggregate | N_Extension_Aggregate
@@ -6788,7 +6788,8 @@ package body Exp_Aggr is
       --  STEP 3
 
       --  Delay expansion for nested aggregates: it will be taken care of when
-      --  the parent aggregate is expanded.
+      --  the parent aggregate is expanded, excluding container aggregates as
+      --  these are transformed into subprogram calls later.
 
       Parent_Node := Parent (N);
       Parent_Kind := Nkind (Parent_Node);
@@ -6798,9 +6799,10 @@ package body Exp_Aggr is
          Parent_Kind := Nkind (Parent_Node);
       end if;
 
-      if Parent_Kind = N_Aggregate
-        or else Parent_Kind = N_Extension_Aggregate
-        or else Parent_Kind = N_Component_Association
+      if ((Parent_Kind = N_Component_Association
+            or else Parent_Kind = N_Aggregate
+            or else Parent_Kind = N_Extension_Aggregate)
+           and then not Is_Container_Aggregate (Parent_Node))
         or else (Parent_Kind = N_Object_Declaration
                   and then Needs_Finalization (Typ))
         or else (Parent_Kind = N_Assignment_Statement