diff options
author | Richard Henderson <rth@redhat.com> | 2004-08-30 11:16:31 -0700 |
---|---|---|
committer | Richard Henderson <rth@gcc.gnu.org> | 2004-08-30 11:16:31 -0700 |
commit | 88f1975682abfbb86e5e2807ef7225fe6ce177fc (patch) | |
tree | b7a95305df70ea17c17b95c7ffb5076a545bbf16 /gcc/fold-const.c | |
parent | b6e9851af8002d984ae10a8ff8c36d7a113f0a51 (diff) | |
download | gcc-88f1975682abfbb86e5e2807ef7225fe6ce177fc.zip gcc-88f1975682abfbb86e5e2807ef7225fe6ce177fc.tar.gz gcc-88f1975682abfbb86e5e2807ef7225fe6ce177fc.tar.bz2 |
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
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index f728db6..3ee2bc7 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -9582,11 +9582,22 @@ tree_expr_nonzero_p (tree t) break; case ADDR_EXPR: - /* Weak declarations may link to NULL. */ - if (DECL_P (TREE_OPERAND (t, 0))) - return !DECL_WEAK (TREE_OPERAND (t, 0)); - /* Constants and all other cases are never weak. */ - return true; + { + tree base = get_base_address (TREE_OPERAND (t, 0)); + + if (!base) + 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: return (tree_expr_nonzero_p (TREE_OPERAND (t, 1)) |