aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2004-05-18 15:53:21 -0400
committerJason Merrill <jason@gcc.gnu.org>2004-05-18 15:53:21 -0400
commitd7981fd95fde4396a5d774be8db49708ef68b86d (patch)
tree3d225bf185c5ce4a94b6386d6e62e88b33cf3578 /gcc
parentc9e66eda1aa76b77d9a56bf0d1b19a1576c37a62 (diff)
downloadgcc-d7981fd95fde4396a5d774be8db49708ef68b86d.zip
gcc-d7981fd95fde4396a5d774be8db49708ef68b86d.tar.gz
gcc-d7981fd95fde4396a5d774be8db49708ef68b86d.tar.bz2
* class.c (build_base_path): Tidy a bit.
From-SVN: r82004
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/class.c18
2 files changed, 15 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index f1c24c1..ec73835 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,7 @@
+2004-05-18 Jason Merrill <jason@redhat.com>
+
+ * class.c (build_base_path): Tidy a bit.
+
2004-05-14 Geoffrey Keating <geoffk@apple.com>
* name-lookup.c (struct scope_binding): New.
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 6d2fef5..33cbdb6 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -255,6 +255,7 @@ build_base_path (enum tree_code code,
int fixed_type_p;
int want_pointer = TREE_CODE (TREE_TYPE (expr)) == POINTER_TYPE;
bool has_empty = false;
+ bool virtual_access;
if (expr == error_mark_node || binfo == error_mark_node || !binfo)
return error_mark_node;
@@ -296,21 +297,24 @@ build_base_path (enum tree_code code,
offset = BINFO_OFFSET (binfo);
fixed_type_p = resolves_to_fixed_type_p (expr, &nonnull);
- if (want_pointer && !nonnull
- && (!integer_zerop (offset) || (v_binfo && fixed_type_p <= 0)))
+ /* Do we need to look in the vtable for the real offset? */
+ virtual_access = (v_binfo && fixed_type_p <= 0);
+
+ /* Do we need to check for a null pointer? */
+ if (want_pointer && !nonnull && (virtual_access || !integer_zerop (offset)))
null_test = error_mark_node;
- if (TREE_SIDE_EFFECTS (expr)
- && (null_test || (v_binfo && fixed_type_p <= 0)))
+ /* Protect against multiple evaluation if necessary. */
+ if (TREE_SIDE_EFFECTS (expr) && (null_test || virtual_access))
expr = save_expr (expr);
+ /* Now that we've saved expr, build the real null test. */
if (null_test)
null_test = fold (build2 (NE_EXPR, boolean_type_node,
expr, integer_zero_node));
/* If this is a simple base reference, express it as a COMPONENT_REF. */
- if (code == PLUS_EXPR
- && (v_binfo == NULL_TREE || fixed_type_p > 0)
+ if (code == PLUS_EXPR && !virtual_access
/* We don't build base fields for empty bases, and they aren't very
interesting to the optimizers anyway. */
&& !has_empty)
@@ -323,7 +327,7 @@ build_base_path (enum tree_code code,
goto out;
}
- if (v_binfo && fixed_type_p <= 0)
+ if (virtual_access)
{
/* Going via virtual base V_BINFO. We need the static offset
from V_BINFO to BINFO, and the dynamic offset from D_BINFO to