[PATCH][C++] Fix PR40834

Richard Guenther rguenther@suse.de
Fri Jul 24 22:49:00 GMT 2009


This fixes an issue with my last patch to genericization.  Walking
BIND_EXPRs need to include BIND_EXPR_VARs in the same way as walk_tree
would do it.  Fixed by calling walk_tree again on the BIND_EXPR after
recording it on the stack.

Bootstrapped and tested on x86_64-unknown-linux-gnu, ok for trunk?

Thanks,
Richard.

2009-07-24  Richard Guenther  <rguenther@suse.de>

	PR c++/40834
	* cp-gimplify.c (cp_genericize_r): Properly walk the BIND_EXPR
	vars.

Index: gcc/cp/cp-gimplify.c
===================================================================
--- gcc/cp/cp-gimplify.c	(revision 150041)
+++ gcc/cp/cp-gimplify.c	(working copy)
@@ -804,10 +804,14 @@ cp_genericize_r (tree *stmt_p, int *walk
 	}
     }
 
-  else if (TREE_CODE (stmt) == BIND_EXPR)
+  else if (TREE_CODE (stmt) == BIND_EXPR
+	   /* We walk this twice, once to keep track of the BIND_EXPR
+	      stack and once to properly walk the BIND_EXPR vars.  */
+	   && (VEC_empty (tree, wtd->bind_expr_stack)
+	       || VEC_last (tree, wtd->bind_expr_stack) != stmt))
     {
       VEC_safe_push (tree, heap, wtd->bind_expr_stack, stmt);
-      cp_walk_tree (&BIND_EXPR_BODY (stmt),
+      cp_walk_tree (stmt_p,
 		    cp_genericize_r, data, NULL);
       VEC_pop (tree, wtd->bind_expr_stack);
       *walk_subtrees = 0;



More information about the Gcc-patches mailing list