From: Eric Botcazou Date: Tue, 11 Jul 2023 08:59:17 +0000 (+0200) Subject: ada: Elide the copy in extended returns for nonlimited by-reference types X-Git-Tag: basepoints/gcc-15~7290 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a1826d3d1f36033408eaa71c167fbb322523946;p=thirdparty%2Fgcc.git ada: Elide the copy in extended returns for nonlimited by-reference types 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. --- diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc index fd85facaf70f..5d93060c6d85 100644 --- a/gcc/ada/gcc-interface/trans.cc +++ b/gcc/ada/gcc-interface/trans.cc @@ -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)