aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2004-08-30 11:16:31 -0700
committerRichard Henderson <rth@gcc.gnu.org>2004-08-30 11:16:31 -0700
commit88f1975682abfbb86e5e2807ef7225fe6ce177fc (patch)
treeb7a95305df70ea17c17b95c7ffb5076a545bbf16 /gcc/cp
parentb6e9851af8002d984ae10a8ff8c36d7a113f0a51 (diff)
downloadgcc-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/cp')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/class.c12
2 files changed, 15 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index c589b34..83e38c9 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+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>
* name-lookup.c (pop_binding, pushdecl,
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 22781e3..9ef15dcc 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -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);
case ADDR_EXPR:
+ instance = TREE_OPERAND (instance, 0);
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:
/* If this component is really a base class reference, then the field