Patchwork Fix canonicalize_constructor_val

login
register
mail settings
Submitter Richard Guenther
Date Nov. 8, 2011, 11:22 a.m.
Message ID <alpine.LNX.2.00.1111081221370.4527@zhemvz.fhfr.qr>
Download mbox | patch
Permalink /patch/124332/
State New
Headers show

Comments

Richard Guenther - Nov. 8, 2011, 11:22 a.m.
This fixes an oversight in canonicalize_constructor_val which
can result in trying to add a referenced var to a function that
doesn't have them computed when folding a statement before
referenced_vars pass has been run.

Committed.

Richard.

2011-11-08  Richard Guenther  <rguenther@suse.de>

	* gimple-fold.c (canonicalize_constructor_val): Make sure
	we have referenced vars setup before adding to them.

Patch

Index: gcc/gimple-fold.c
===================================================================
--- gcc/gimple-fold.c	(revision 181154)
+++ gcc/gimple-fold.c	(working copy)
@@ -137,7 +137,8 @@  canonicalize_constructor_val (tree cval)
 	      || TREE_CODE (base) == FUNCTION_DECL)
 	  && !can_refer_decl_in_current_unit_p (base))
 	return NULL_TREE;
-      if (cfun && base && TREE_CODE (base) == VAR_DECL)
+      if (cfun && gimple_referenced_vars (cfun)
+	  && base && TREE_CODE (base) == VAR_DECL)
 	add_referenced_var (base);
       /* Fixup types in global initializers.  */
       if (TREE_TYPE (TREE_TYPE (cval)) != TREE_TYPE (TREE_OPERAND (cval, 0)))