* [COMMITTED] ada: Adjust recent change for returns involving function calls
@ 2022-11-21 10:14 Marc Poulhiès
0 siblings, 0 replies; only message in thread
From: Marc Poulhiès @ 2022-11-21 10:14 UTC (permalink / raw)
To: gcc-patches; +Cc: Eric Botcazou
From: Eric Botcazou <ebotcazou@adacore.com>
gcc/ada/
* gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Constant>: Revert
latest change.
* gcc-interface/trans.cc (gnat_to_gnu) <N_Object_Declaration>:
Tweak latest change.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/gcc-interface/decl.cc | 11 -----------
gcc/ada/gcc-interface/trans.cc | 11 ++++++++---
2 files changed, 8 insertions(+), 14 deletions(-)
diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc
index e25ce498f2c..c383f9b218a 100644
--- a/gcc/ada/gcc-interface/decl.cc
+++ b/gcc/ada/gcc-interface/decl.cc
@@ -637,17 +637,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition)
break;
case E_Constant:
- /* If this is a constant related to a return in a function returning by
- invisible reference without expression, get the return object. */
- if (Is_Related_To_Func_Return (gnat_entity)
- && current_function_decl
- && TREE_ADDRESSABLE (TREE_TYPE (current_function_decl))
- && !gnu_expr)
- {
- gnu_decl = DECL_RESULT (current_function_decl);
- break;
- }
-
/* Ignore constant definitions already marked with the error node. See
the N_Object_Declaration case of gnat_to_gnu for the rationale. */
if (definition
diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc
index d0ff741585e..1cd621a9377 100644
--- a/gcc/ada/gcc-interface/trans.cc
+++ b/gcc/ada/gcc-interface/trans.cc
@@ -6482,9 +6482,10 @@ gnat_to_gnu (Node_Id gnat_node)
then elide the temporary by forwarding the return object to Func:
+ result_type *Rnn = (result_type *) <retval>;
*<retval> = Func (); [return slot optimization]
[...]
- return <retval>;
+ return Rnn;
That's necessary if the result type needs finalization because the
temporary would never be adjusted as Expand_Simple_Function_Return
@@ -6496,8 +6497,12 @@ gnat_to_gnu (Node_Id gnat_node)
&& current_function_decl
&& TREE_ADDRESSABLE (TREE_TYPE (current_function_decl)))
{
- gnu_result = gnat_to_gnu_entity (gnat_temp, NULL_TREE, true);
- gnu_result = build_unary_op (INDIRECT_REF, NULL_TREE, gnu_result);
+ gnat_to_gnu_entity (gnat_temp,
+ DECL_RESULT (current_function_decl),
+ true);
+ gnu_result
+ = build_unary_op (INDIRECT_REF, NULL_TREE,
+ DECL_RESULT (current_function_decl));
gnu_result
= Call_to_gnu (Prefix (Expression (gnat_node)),
&gnu_result_type, gnu_result,
--
2.34.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-11-21 10:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-21 10:14 [COMMITTED] ada: Adjust recent change for returns involving function calls Marc Poulhiès
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).