From patchwork Tue Nov 8 11:22:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Fix canonicalize_constructor_val Date: Tue, 08 Nov 2011 01:22:34 -0000 From: Richard Guenther X-Patchwork-Id: 124332 Message-Id: To: gcc-patches@gcc.gnu.org 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 * 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)))