https://gcc.gnu.org/g:f92d4b5fd84a2b37f62639188df7104da67e755e

commit r15-2615-gf92d4b5fd84a2b37f62639188df7104da67e755e
Author: Gary Dismukes <dismu...@adacore.com>
Date:   Wed Jun 26 22:00:49 2024 +0000

    ada: Missing adjust of controlled component initialized from container 
aggregate
    
    In the case of controlled components initialized by a container aggregate,
    the compiler was suppressing the call to the needed Adjust operation,
    because it was suppressed for all aggregates. But container aggregates
    aren't built in place, so target adjustment should still be done in that
    case.
    
    gcc/ada/
    
            * exp_ch3.adb (Build_Record_Init_Proc.Build_Assignment): Do the
            component adjustment in the case of initialization by a container
            aggregate.

Diff:
---
 gcc/ada/exp_ch3.adb | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb
index 1eea062210ab..6fee2b41bac6 100644
--- a/gcc/ada/exp_ch3.adb
+++ b/gcc/ada/exp_ch3.adb
@@ -2700,10 +2700,12 @@ package body Exp_Ch3 is
          end if;
 
          --  Adjust the component if controlled except if it is an aggregate
-         --  that will be expanded inline.
+         --  that will be expanded inline (but note that the case of container
+         --  aggregates does require component adjustment).
 
          if Needs_Finalization (Typ)
-           and then Nkind (Exp_Q) not in N_Aggregate | N_Extension_Aggregate
+           and then (Nkind (Exp_Q) not in N_Aggregate | N_Extension_Aggregate
+                      or else Is_Container_Aggregate (Exp_Q))
            and then not Is_Build_In_Place_Function_Call (Exp)
          then
             Adj_Call :=

Reply via email to