diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-03-15 09:35:56 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-03-15 09:35:56 +0000 |
commit | e8844fc36936140eb1c9f659a16b401980733b49 (patch) | |
tree | 604287ecd222a7298e95b6799dafc8e1b6467250 /gcc/gimple-fold.c | |
parent | 5ce2a6ec8443c9fcf3c4f96383246efa8f5b3d6a (diff) | |
download | gcc-e8844fc36936140eb1c9f659a16b401980733b49.tar.gz |
2012-03-15 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 185416 using svnmerge
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@185423 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gimple-fold.c')
-rw-r--r-- | gcc/gimple-fold.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index 5ba7178b0da..d4028398079 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -131,18 +131,26 @@ canonicalize_constructor_val (tree cval) if (TREE_CODE (cval) == ADDR_EXPR) { tree base = get_base_address (TREE_OPERAND (cval, 0)); + if (!base) + return NULL_TREE; - if (base - && (TREE_CODE (base) == VAR_DECL - || TREE_CODE (base) == FUNCTION_DECL) + if ((TREE_CODE (base) == VAR_DECL + || TREE_CODE (base) == FUNCTION_DECL) && !can_refer_decl_in_current_unit_p (base)) return NULL_TREE; - if (base && TREE_CODE (base) == VAR_DECL) + if (TREE_CODE (base) == VAR_DECL) { TREE_ADDRESSABLE (base) = 1; if (cfun && gimple_referenced_vars (cfun)) add_referenced_var (base); } + else if (TREE_CODE (base) == FUNCTION_DECL) + { + /* Make sure we create a cgraph node for functions we'll reference. + They can be non-existent if the reference comes from an entry + of an external vtable for example. */ + cgraph_get_create_node (base); + } /* 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)); @@ -3115,6 +3123,11 @@ gimple_get_virt_method_for_binfo (HOST_WIDE_INT token, tree known_binfo) if (!can_refer_decl_in_current_unit_p (fn)) return NULL_TREE; + /* Make sure we create a cgraph node for functions we'll reference. + They can be non-existent if the reference comes from an entry + of an external vtable for example. */ + cgraph_get_create_node (fn); + return fn; } |