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 <rguent...@suse.de> * gimple-fold.c (canonicalize_constructor_val): Make sure we have referenced vars setup before adding to them. 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)))