https://gcc.gnu.org/g:145314b3ef9017bb7d841578bb989dd85b3a12ac

commit r15-6582-g145314b3ef9017bb7d841578bb989dd85b3a12ac
Author: Eric Botcazou <ebotca...@adacore.com>
Date:   Tue Dec 10 17:53:34 2024 +0100

    ada: Plug small loophole in previous change
    
    The initial change only deals with the controlled record case for assignment
    statements, but the controlled array case needs the same treatment.
    
    gcc/ada/ChangeLog:
    
            * exp_ch5.adb (Expand_Assign_Array): Bail out for controlled
            components if the RHS is a function call and the assignment has
            the No_Ctrl_Actions flag set.

Diff:
---
 gcc/ada/exp_ch5.adb | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb
index 39b26e0e9b64..096509b49d56 100644
--- a/gcc/ada/exp_ch5.adb
+++ b/gcc/ada/exp_ch5.adb
@@ -534,9 +534,14 @@ package body Exp_Ch5 is
          Loop_Required := True;
 
       --  Arrays with controlled components are expanded into a loop to force
-      --  calls to Adjust at the component level.
+      --  calls to Adjust at the component level, except for a function call
+      --  that requires no controlling actions (see Expand_Ctrl_Function_Call).
 
       elsif Has_Controlled_Component (L_Type) then
+         if Nkind (Rhs) = N_Function_Call and then No_Ctrl_Actions (N) then
+            return;
+         end if;
+
          Loop_Required := True;
 
       --  If object is full access, we cannot tolerate a loop

Reply via email to