aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2023-07-11 10:59:17 +0200
committerMarc Poulhiès <poulhies@adacore.com>2023-07-28 09:28:16 +0200
commit7a1826d3d1f36033408eaa71c167fbb322523946 (patch)
treebb95cf7138fd1dce0e81a6e9a29d46b4375b75ff /gcc
parent9c70186d84b895340771fcf9df54e3ed6f1a4e48 (diff)
downloadgcc-7a1826d3d1f36033408eaa71c167fbb322523946.zip
gcc-7a1826d3d1f36033408eaa71c167fbb322523946.tar.gz
gcc-7a1826d3d1f36033408eaa71c167fbb322523946.tar.bz2
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/gcc-interface/trans.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc
index fd85fac..5d93060 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)