public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [COMMITTED] ada: Fix internal error on aggregate within container aggregate
@ 2023-06-20  7:46 Marc Poulhiès
  2023-07-07  8:51 ` Eric Botcazou
  0 siblings, 1 reply; 2+ messages in thread
From: Marc Poulhiès @ 2023-06-20  7:46 UTC (permalink / raw)
  To: gcc-patches; +Cc: Eric Botcazou

From: Eric Botcazou <ebotcazou@adacore.com>

This just applies the same fix to Expand_Array_Aggregate as the one that was
recently applied to Convert_To_Assignments.

gcc/ada/

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

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/exp_aggr.adb | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb
index fb5f404922f..5e22fefbc1d 100644
--- a/gcc/ada/exp_aggr.adb
+++ b/gcc/ada/exp_aggr.adb
@@ -4244,9 +4244,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
@@ -6108,7 +6108,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);
@@ -6118,9 +6119,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 Is_Special_Return_Object
-- 
2.40.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [COMMITTED] ada: Fix internal error on aggregate within container aggregate
  2023-06-20  7:46 [COMMITTED] ada: Fix internal error on aggregate within container aggregate Marc Poulhiès
@ 2023-07-07  8:51 ` Eric Botcazou
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Botcazou @ 2023-07-07  8:51 UTC (permalink / raw)
  To: Marc Poulhiès; +Cc: gcc-patches

> This just applies the same fix to Expand_Array_Aggregate as the one that was
> recently applied to Convert_To_Assignments.
> 
> gcc/ada/
> 
> 	* exp_aggr.adb (Convert_To_Assignments): Tweak comment.
> 	(Expand_Array_Aggregate): Do not delay the expansion if the parent
> 	node is a container aggregate.

This is not a regression but the problem is quite visible in Ada 2022 so I 
backported the fix onto the 13 branch.

-- 
Eric Botcazou



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-07-07  8:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-20  7:46 [COMMITTED] ada: Fix internal error on aggregate within container aggregate Marc Poulhiès
2023-07-07  8:51 ` Eric Botcazou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).