]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Elide the copy in extended returns for nonlimited by-reference types
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 11 Jul 2023 08:59:17 +0000 (10:59 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Fri, 28 Jul 2023 07:28:16 +0000 (09:28 +0200)
gcc/ada/

* gcc-interface/trans.cc (gnat_to_gnu): Restrict previous change to
the case where the simple return statement has got no storage pool.

gcc/ada/gcc-interface/trans.cc

index fd85facaf70fb3cf43ecd0ce006aed721413b87a..5d93060c6d85e79f3c59f980af5524693ee2691e 100644 (file)
@@ -8451,8 +8451,8 @@ gnat_to_gnu (Node_Id gnat_node)
 
        5. If this is a reference to an unconstrained array which is used either
          as the prefix of an attribute reference that requires an lvalue or in
-         a return statement, then return the result unmodified because we want
-         to return the original bounds.
+         a return statement without storage pool, return the result unmodified
+         because we want to return the original bounds.
 
        6. Finally, if the type of the result is already correct.  */
 
@@ -8518,7 +8518,8 @@ gnat_to_gnu (Node_Id gnat_node)
           && Present (Parent (gnat_node))
           && ((Nkind (Parent (gnat_node)) == N_Attribute_Reference
                && lvalue_required_for_attribute_p (Parent (gnat_node)))
-              || Nkind (Parent (gnat_node)) == N_Simple_Return_Statement))
+              || (Nkind (Parent (gnat_node)) == N_Simple_Return_Statement
+                  && No (Storage_Pool (gnat_node)))))
     ;
 
   else if (TREE_TYPE (gnu_result) != gnu_result_type)