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

commit r17-949-gee2e8e17067e08f65ae832f266f3d158c4fd4485
Author: Eric Botcazou <[email protected]>
Date:   Sat Mar 21 12:24:35 2026 +0100

    ada: Remove obsolete trick in Analyze_Function_Return
    
    The compiler no longer creates a temporary for controlled aggregate returns.
    
    gcc/ada/ChangeLog:
    
            * sem_ch6.adb (Analyze_Function_Return): Remove obsolete code that
            wraps the return in a block when the expression is an aggregate.

Diff:
---
 gcc/ada/sem_ch6.adb | 21 ---------------------
 1 file changed, 21 deletions(-)

diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
index b5a949d2a0e6..67d92626c16d 100644
--- a/gcc/ada/sem_ch6.adb
+++ b/gcc/ada/sem_ch6.adb
@@ -875,27 +875,6 @@ package body Sem_Ch6 is
             return;
 
          else
-            --  The resolution of a controlled [extension] aggregate associated
-            --  with a return statement creates a temporary which needs to be
-            --  finalized on function exit. Wrap the return statement inside a
-            --  block so that the finalization machinery can detect this case.
-            --  This early expansion is done only when the return statement is
-            --  not part of a handled sequence of statements.
-
-            if Nkind (Expr) in N_Aggregate | N_Extension_Aggregate
-              and then Needs_Finalization (R_Type)
-              and then Nkind (Parent (N)) /= N_Handled_Sequence_Of_Statements
-            then
-               Rewrite (N,
-                 Make_Block_Statement (Loc,
-                   Handled_Statement_Sequence =>
-                     Make_Handled_Sequence_Of_Statements (Loc,
-                       Statements => New_List (Relocate_Node (N)))));
-
-               Analyze (N);
-               return;
-            end if;
-
             Analyze (Expr);
 
             --  Ada 2005 (AI-251): If the type of the returned object is

Reply via email to