[COMMITTED] ada: Fix memory leak in multi-dimensional array aggregate of Vector

Message ID 20230529082931.2410398-1-poulhies@adacore.com
State Accepted
Headers
Series [COMMITTED] ada: Fix memory leak in multi-dimensional array aggregate of Vector |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Marc Poulhiès May 29, 2023, 8:29 a.m. UTC
  From: Eric Botcazou <ebotcazou@adacore.com>

It comes from a superfluous adjustment for subarray components.

gcc/ada/

	* exp_aggr.adb (Initialize_Array_Component): Fix condition detecting
	the nested case that requires an adjustment.

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

---
 gcc/ada/exp_aggr.adb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Patch

diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb
index 75e5e1402df..c4a016ed3d4 100644
--- a/gcc/ada/exp_aggr.adb
+++ b/gcc/ada/exp_aggr.adb
@@ -1459,7 +1459,7 @@  package body Exp_Aggr is
               and then not Is_Build_In_Place_Function_Call (Init_Expr)
               and then not
                 (Is_Array_Type (Comp_Typ)
-                  and then Is_Controlled (Component_Type (Comp_Typ))
+                  and then Needs_Finalization (Component_Type (Comp_Typ))
                   and then Nkind (Expr) = N_Aggregate)
             then
                Adj_Call :=