]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Remove obsolete trick in Analyze_Function_Return
authorEric Botcazou <ebotcazou@adacore.com>
Sat, 21 Mar 2026 11:24:35 +0000 (12:24 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Fri, 29 May 2026 08:49:49 +0000 (10:49 +0200)
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.

gcc/ada/sem_ch6.adb

index b5a949d2a0e6279702ff674164ad6ae7454d7e7b..67d92626c16dc26f1fea674ca93e72a88c4b56dd 100644 (file)
@@ -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