From 89ea02fbac98156915e26567a21668dd816b4e3a Mon Sep 17 00:00:00 2001
From: Jason Merrill <jason@redhat.com>
Date: Tue, 17 Dec 2002 16:29:29 -0500
Subject: [PATCH] calls.c (expand_call): Handle CALL_EXPR_HAS_RETURN_SLOT_ADDR
 with special struct-return ABIs.

        * calls.c (expand_call): Handle CALL_EXPR_HAS_RETURN_SLOT_ADDR
        with special struct-return ABIs.

cp/
        * semantics.c (simplify_aggr_init_exprs_r): Don't change the type
        of the CALL_EXPR.

From-SVN: r60223
---
 gcc/calls.c        | 16 ++++++++++++++--
 gcc/cp/ChangeLog   |  3 +++
 gcc/cp/semantics.c | 11 +++--------
 3 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/gcc/calls.c b/gcc/calls.c
index 4d6cdd78aebc..09398e87e1ce 100644
--- a/gcc/calls.c
+++ b/gcc/calls.c
@@ -2248,8 +2248,20 @@ expand_call (exp, target, ignore)
 	struct_value_size = int_size_in_bytes (TREE_TYPE (exp));
 
 	if (CALL_EXPR_HAS_RETURN_SLOT_ADDR (exp))
-	  /* The structure value address arg is already in actparms.  */
-	  structure_value_addr_parm = 1;
+	  {
+	    /* The structure value address arg is already in actparms.  */
+	    if (struct_value_rtx == 0)
+	      /* We want to pass it as a normal argument, so leave it.  */
+	      structure_value_addr_parm = 1;
+	    else
+	      {
+		/* We want to pass it in a special location.  */
+		tree return_arg = TREE_VALUE (actparms);
+		actparms = TREE_CHAIN (actparms);
+		structure_value_addr = expand_expr (return_arg, struct_value_rtx,
+						    VOIDmode, EXPAND_NORMAL);
+	      }
+	  }
 	else if (target && GET_CODE (target) == MEM)
 	  structure_value_addr = XEXP (target, 0);
 	else
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a1b5038ff6a3..1e50ff96905a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,8 @@
 2002-12-16  Jason Merrill  <jason@redhat.com>
 
+	* semantics.c (simplify_aggr_init_exprs_r): Don't change the type
+	of the CALL_EXPR.
+
 	* semantics.c (do_pushlevel): Call pushlevel after adding the
 	SCOPE_STMT.
 	(do_poplevel): Call poplevel before adding the SCOPE_STMT.
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 763916acbac3..e402a72f8947 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -2250,14 +2250,9 @@ simplify_aggr_init_exprs_r (tp, walk_subtrees, data)
   TREE_SIDE_EFFECTS (call_expr) = 1;
 
   if (style == arg)
-    {
-      /* Tell the backend that we've added our return slot to the argument
-	 list.  */
-      CALL_EXPR_HAS_RETURN_SLOT_ADDR (call_expr) = 1;
-      /* And don't let anyone use the value of the call directly in a
-	 larger expression.  */
-      TREE_TYPE (call_expr) = void_type_node;
-    }
+    /* Tell the backend that we've added our return slot to the argument
+       list.  */
+    CALL_EXPR_HAS_RETURN_SLOT_ADDR (call_expr) = 1;
   else if (style == pcc)
     {
       /* If we're using the non-reentrant PCC calling convention, then we
-- 
GitLab