+2012-03-14 Richard Guenther <rguenther@suse.de>
+
+ PR middle-end/52582
+ * gimple-fold.c (canonicalize_constructor_val): Make sure
+ we have a cgraph node for a FUNCTION_DECL that comes from
+ a constructor.
+ (gimple_get_virt_method_for_binfo): Likewise.
+
2012-03-14 Richard Guenther <rguenther@suse.de>
PR tree-optimization/52571
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));
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;
}