Commit 88f19756 by Richard Henderson Committed by Richard Henderson

fold-const.c (tree_expr_nonzero_p): Use get_base_address before assuming an ADDR_EXPR is non-null.

        * fold-const.c (tree_expr_nonzero_p): Use get_base_address before
        assuming an ADDR_EXPR is non-null.
cp/
        * class.c (fixed_type_or_null): Use get_base_address before
        assuming an ADDR_EXPR is non-null.

From-SVN: r86788
parent b6e9851a
2004-08-30 Richard Henderson <rth@redhat.com>
* fold-const.c (tree_expr_nonzero_p): Use get_base_address before
assuming an ADDR_EXPR is non-null.
2004-08-30 Jason Merrill <jason@redhat.com> 2004-08-30 Jason Merrill <jason@redhat.com>
* gthr-posix.h, gthr-dce.h: Add #pragma weaks. * gthr-posix.h, gthr-dce.h: Add #pragma weaks.
......
2004-08-30 Richard Henderson <rth@redhat.com>
* class.c (fixed_type_or_null): Use get_base_address before
assuming an ADDR_EXPR is non-null.
2004-08-30 Nathan Sidwell <nathan@codesourcery.com> 2004-08-30 Nathan Sidwell <nathan@codesourcery.com>
* name-lookup.c (pop_binding, pushdecl, * name-lookup.c (pop_binding, pushdecl,
......
...@@ -5238,9 +5238,17 @@ fixed_type_or_null (tree instance, int* nonnull, int* cdtorp) ...@@ -5238,9 +5238,17 @@ fixed_type_or_null (tree instance, int* nonnull, int* cdtorp)
return fixed_type_or_null (TREE_OPERAND (instance, 0), nonnull, cdtorp); return fixed_type_or_null (TREE_OPERAND (instance, 0), nonnull, cdtorp);
case ADDR_EXPR: case ADDR_EXPR:
instance = TREE_OPERAND (instance, 0);
if (nonnull) if (nonnull)
*nonnull = 1; {
return fixed_type_or_null (TREE_OPERAND (instance, 0), nonnull, cdtorp); /* Just because we see an ADDR_EXPR doesn't mean we're dealing
with a real object -- given &p->f, p can still be null. */
tree t = get_base_address (instance);
/* ??? Probably should check DECL_WEAK here. */
if (t && DECL_P (t))
*nonnull = 1;
}
return fixed_type_or_null (instance, nonnull, cdtorp);
case COMPONENT_REF: case COMPONENT_REF:
/* If this component is really a base class reference, then the field /* If this component is really a base class reference, then the field
......
...@@ -9582,11 +9582,22 @@ tree_expr_nonzero_p (tree t) ...@@ -9582,11 +9582,22 @@ tree_expr_nonzero_p (tree t)
break; break;
case ADDR_EXPR: case ADDR_EXPR:
/* Weak declarations may link to NULL. */ {
if (DECL_P (TREE_OPERAND (t, 0))) tree base = get_base_address (TREE_OPERAND (t, 0));
return !DECL_WEAK (TREE_OPERAND (t, 0));
/* Constants and all other cases are never weak. */ if (!base)
return true; return false;
/* Weak declarations may link to NULL. */
if (DECL_P (base))
return !DECL_WEAK (base);
/* Constants are never weak. */
if (TREE_CODE_CLASS (TREE_CODE (base)) == 'c')
return true;
return false;
}
case COND_EXPR: case COND_EXPR:
return (tree_expr_nonzero_p (TREE_OPERAND (t, 1)) return (tree_expr_nonzero_p (TREE_OPERAND (t, 1))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment