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]

Re: [PATCH] PR c++/17554, ice in create_tmp_var, cleanup_expr



On Oct 7, 2004, at 1:18 AM, Jason Merrill wrote:


I think I'd prefer to make the void version the new entry point, to clarify
that it's used in statement context.

I found one more place where needed the type not be void and I implemented
your suggestion.


OK?

Thanks,
Andrew Pinski

ChangeLog:
	* cp/semantics.c (maybe_cleanup_point_expr_void): New function.
	(add_decl_expr): Use maybe_cleanup_point_expr_void instead of
	maybe_cleanup_point_expr.
	(finish_expr_stmt): Likewise.
	(finish_return_stmt): Likewise.
	(finish_for_expr): Likewise.
	(finish_asm_stmt): Likewise.

Patch:
Index: cp/semantics.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/semantics.c,v
retrieving revision 1.442
diff -u -p -r1.442 semantics.c
--- cp/semantics.c	6 Oct 2004 22:09:22 -0000	1.442
+++ cp/semantics.c	7 Oct 2004 13:53:54 -0000
@@ -362,6 +362,19 @@ maybe_cleanup_point_expr (tree expr)
   return expr;
 }

+/* Like maybe_cleanup_point_expr except have the type of void as this is
+ statement and an expression which returns a type. */
+
+static tree
+maybe_cleanup_point_expr_void (tree expr)
+{
+ if (!processing_template_decl && stmts_are_full_exprs_p ())
+ expr = build1 (CLEANUP_POINT_EXPR, void_type_node, expr);
+ return expr;
+}
+
+
+
/* Create a declaration statement for the declaration given by the DECL. */


 void
@@ -369,7 +382,7 @@ add_decl_expr (tree decl)
 {
   tree r = build_stmt (DECL_EXPR, decl);
   if (DECL_INITIAL (decl))
-    r = maybe_cleanup_point_expr (r);
+    r = maybe_cleanup_point_expr_void (r);
   add_stmt (r);
 }

@@ -555,7 +568,7 @@ finish_expr_stmt (tree expr)
 	{
 	  if (TREE_CODE (expr) != EXPR_STMT)
 	    expr = build_stmt (EXPR_STMT, expr);
-	  expr = maybe_cleanup_point_expr (expr);
+	  expr = maybe_cleanup_point_expr_void (expr);
 	}

       r = add_stmt (expr);
@@ -718,7 +731,7 @@ finish_return_stmt (tree expr)
     }

   r = build_stmt (RETURN_EXPR, expr);
-  r = maybe_cleanup_point_expr (r);
+  r = maybe_cleanup_point_expr_void (r);
   r = add_stmt (r);
   finish_stmt ();

@@ -782,7 +795,7 @@ finish_for_expr (tree expr, tree for_stm
       cxx_incomplete_type_error (expr, TREE_TYPE (expr));
       expr = error_mark_node;
     }
-  expr = maybe_cleanup_point_expr (expr);
+  expr = maybe_cleanup_point_expr_void (expr);
   FOR_EXPR (for_stmt) = expr;
 }

@@ -1178,7 +1191,7 @@ finish_asm_stmt (int volatile_p, tree st
 		  output_operands, input_operands,
 		  clobbers);
   ASM_VOLATILE_P (r) = volatile_p;
-  r = maybe_cleanup_point_expr (r);
+  r = maybe_cleanup_point_expr_void (r);
   return add_stmt (r);
 }





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