summaryrefslogtreecommitdiff
path: root/gcc/gimple-fold.c
diff options
context:
space:
mode:
authormatz <matz@138bc75d-0d04-0410-961f-82ee72b054a4>2011-04-03 11:13:09 +0000
committermatz <matz@138bc75d-0d04-0410-961f-82ee72b054a4>2011-04-03 11:13:09 +0000
commitbb903e9c84ce730268cc488d5d3b71821e2c13a2 (patch)
treecffddfa016b791b26c7af434581e9984b8129eea /gcc/gimple-fold.c
parente7e718d0e3388209a0ddc92dc0e91baf547dd262 (diff)
downloadgcc-bb903e9c84ce730268cc488d5d3b71821e2c13a2.tar.gz
* cgraphbuild.c (record_reference): Canonicalize constructor
values. * gimple-fold.c (canonicalize_constructor_val): Accept being called without function context. * cgraphunit.c (cgraph_finalize_compilation_unit): Clear current_function_decl and cfun. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@171903 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gimple-fold.c')
-rw-r--r--gcc/gimple-fold.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index 367e40e3029..f1eb98e329f 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -106,7 +106,7 @@ can_refer_decl_in_current_unit_p (tree decl)
return true;
}
-/* CVAL is value taken from DECL_INITIAL of variable. Try to transorm it into
+/* CVAL is value taken from DECL_INITIAL of variable. Try to transform it into
acceptable form for is_gimple_min_invariant. */
tree
@@ -131,10 +131,9 @@ canonicalize_constructor_val (tree cval)
|| TREE_CODE (base) == FUNCTION_DECL)
&& !can_refer_decl_in_current_unit_p (base))
return NULL_TREE;
- if (base && TREE_CODE (base) == VAR_DECL)
+ if (cfun && base && TREE_CODE (base) == VAR_DECL)
add_referenced_var (base);
- /* We never have the chance to fixup types in global initializers
- during gimplification. Do so here. */
+ /* Fixup types in global initializers. */
if (TREE_TYPE (TREE_TYPE (cval)) != TREE_TYPE (TREE_OPERAND (cval, 0)))
cval = build_fold_addr_expr (TREE_OPERAND (cval, 0));
}