This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[3.4] C++ PATCH for 15461 and 16851


The patch for 15461 is a backport of part of my patch for 11269 on the old
tree-ssa branch.  The patch for 16851 will also go on the trunk, once I've
tested it there.

Tested i686-pc-linux-gnu, applied to 3.4 branch.  I'll add tests tomorrow.

2004-08-24  Jason Merrill  <jason@redhat.com>

	PR c++/16851
	* tree.c (stabilize_init): See through a COMPOUND_EXPR.

	PR c++/15461
	* semantics.c (nullify_returns_r): Replace a DECL_STMT
	for the NRV with an INIT_EXPR.

*** semantics.c.~1~	2004-08-24 09:54:13.000000000 -0400
--- semantics.c	2004-08-24 14:34:51.113724638 -0400
*************** nullify_returns_r (tree* tp, int* walk_s
*** 3025,3030 ****
--- 3025,3051 ----
    else if (TREE_CODE (*tp) == CLEANUP_STMT
  	   && CLEANUP_DECL (*tp) == nrv)
      CLEANUP_EH_ONLY (*tp) = 1;
+   /* Replace the DECL_STMT for the NRV with an initialization of the
+      RESULT_DECL, if needed.  */
+   else if (TREE_CODE (*tp) == DECL_STMT
+ 	   && DECL_STMT_DECL (*tp) == nrv)
+     {
+       tree init;
+       if (DECL_INITIAL (nrv)
+ 	  && DECL_INITIAL (nrv) != error_mark_node)
+ 	{
+ 	  init = build (INIT_EXPR, void_type_node,
+ 			DECL_RESULT (current_function_decl),
+ 			DECL_INITIAL (nrv));
+ 	  DECL_INITIAL (nrv) = error_mark_node;
+ 	}
+       else
+ 	init = NULL_TREE;
+       init = build_stmt (EXPR_STMT, init);
+       TREE_CHAIN (init) = TREE_CHAIN (*tp);
+       STMT_LINENO (init) = STMT_LINENO (*tp);
+       *tp = init;
+     }
  
    /* Keep iterating.  */
    return NULL_TREE;
*** tree.c.~1~	2004-08-24 09:54:14.000000000 -0400
--- tree.c	2004-08-24 17:53:48.971616072 -0400
*************** stabilize_init (tree init, tree *initp)
*** 2496,2501 ****
--- 2496,2503 ----
  	t = TREE_OPERAND (t, 1);
        if (TREE_CODE (t) == TARGET_EXPR)
  	t = TARGET_EXPR_INITIAL (t);
+       if (TREE_CODE (t) == COMPOUND_EXPR)
+ 	t = expr_last (t);
        if (TREE_CODE (t) == CONSTRUCTOR
  	  && CONSTRUCTOR_ELTS (t) == NULL_TREE)
  	{

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]