aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@yorick.cygnus.com>1998-08-27 01:41:17 +0000
committerJason Merrill <jason@gcc.gnu.org>1998-08-26 21:41:17 -0400
commit0ec57017569c318060c3a9b0f6fb75979291c6c8 (patch)
tree9aeb96010eb77e1a52847d09d87204cb2f6a7c79
parent1ca7641e55b83022d3374d71a69f27003e52b8c3 (diff)
downloadgcc-0ec57017569c318060c3a9b0f6fb75979291c6c8.zip
gcc-0ec57017569c318060c3a9b0f6fb75979291c6c8.tar.gz
gcc-0ec57017569c318060c3a9b0f6fb75979291c6c8.tar.bz2
Stop sharing binfos for indirect virtual bases.
* tree.c (propagate_binfo_offsets): Unshare vbases, too. (layout_basetypes): Likewise. (unshare_base_binfos): Copy vbases, too. * cp-tree.h (BINFO_VIA_PUBLIC, BINFO_BASEINIT_MARKED, BINFO_VBASE_INIT_MARKED): Remove obsolete macros. (BINFO_PUSHDECLS_MARKED, SET_BINFO_PUSHDECLS_MARKED, CLEAR_BINFO_PUSHDECLS_MARKED): New macros. * search.c (lookup_field, lookup_fnfields, lookup_member): Remove reference to BINFO_VIA_PUBLIC. (marked_pushdecls_p, unmarked_pushdecls_p): New fns. (push_class_decls): Use them. (dfs_pushdecls): Use SET_BINFO_PUSHDECLS_MARKED. (dfs_compress_decls): Use CLEAR_BINFO_PUSHDECLS_MARKED. From-SVN: r22017
-rw-r--r--gcc/cp/ChangeLog17
-rw-r--r--gcc/cp/cp-tree.h24
-rw-r--r--gcc/cp/search.c18
-rw-r--r--gcc/cp/tree.c37
4 files changed, 56 insertions, 40 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 636fc12..0f546a2 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,20 @@
+1998-08-27 Jason Merrill <jason@yorick.cygnus.com>
+
+ Stop sharing binfos for indirect virtual bases.
+ * tree.c (propagate_binfo_offsets): Unshare vbases, too.
+ (layout_basetypes): Likewise.
+ (unshare_base_binfos): Copy vbases, too.
+ * cp-tree.h (BINFO_VIA_PUBLIC, BINFO_BASEINIT_MARKED,
+ BINFO_VBASE_INIT_MARKED): Remove obsolete macros.
+ (BINFO_PUSHDECLS_MARKED, SET_BINFO_PUSHDECLS_MARKED,
+ CLEAR_BINFO_PUSHDECLS_MARKED): New macros.
+ * search.c (lookup_field, lookup_fnfields, lookup_member): Remove
+ reference to BINFO_VIA_PUBLIC.
+ (marked_pushdecls_p, unmarked_pushdecls_p): New fns.
+ (push_class_decls): Use them.
+ (dfs_pushdecls): Use SET_BINFO_PUSHDECLS_MARKED.
+ (dfs_compress_decls): Use CLEAR_BINFO_PUSHDECLS_MARKED.
+
1998-08-27 Mark Mitchell <mark@markmitchell.com>
* decl.c (build_enumerator): Set DECL_CONTEXT for the
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index bf91f83..85d983c 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -42,17 +42,18 @@ Boston, MA 02111-1307, USA. */
TYPE_USES_COMPLEX_INHERITANCE (in _TYPE).
C_DECLARED_LABEL_FLAG.
2: IDENTIFIER_OPNAME_P.
+ BINFO_VBASE_MARKED.
BINFO_FIELDS_MARKED.
TYPE_VIRTUAL_P.
PARM_DECL_EXPR (in SAVE_EXPR).
3: TYPE_USES_VIRTUAL_BASECLASSES (in a class TYPE).
BINFO_VTABLE_PATH_MARKED.
+ BINFO_PUSHDECLS_MARKED.
(TREE_REFERENCE_EXPR) (in NON_LVALUE_EXPR) (commented-out).
4: BINFO_NEW_VTABLE_MARKED.
TREE_HAS_CONSTRUCTOR (in INDIRECT_REF, SAVE_EXPR, CONSTRUCTOR,
or FIELD_DECL).
- 5: BINFO_VIA_PUBLIC.
- BINFO_VBASE_INIT_MARKED.
+ 5: Not used.
6: Not used.
Usage of TYPE_LANG_FLAG_?:
@@ -965,10 +966,6 @@ struct lang_type
/* Additional macros for inheritance information. */
-/* When following an binfo-specific chain, this is the cumulative
- via-public flag. */
-#define BINFO_VIA_PUBLIC(NODE) TREE_LANG_FLAG_5 (NODE)
-
#ifdef MI_MATRIX
/* When building a matrix to determine by a single lookup
whether one class is derived from another or not,
@@ -985,12 +982,6 @@ struct lang_type
#define SET_BINFO_MARKED(NODE) (TREE_VIA_VIRTUAL(NODE)?SET_CLASSTYPE_MARKED(BINFO_TYPE(NODE)):(TREE_LANG_FLAG_0(NODE)=1))
#define CLEAR_BINFO_MARKED(NODE) (TREE_VIA_VIRTUAL(NODE)?CLEAR_CLASSTYPE_MARKED(BINFO_TYPE(NODE)):(TREE_LANG_FLAG_0(NODE)=0))
-/* Nonzero means marked in building initialization list. */
-#define BINFO_BASEINIT_MARKED(NODE) CLASSTYPE_MARKED2 (BINFO_TYPE (NODE))
-/* Modifier macros */
-#define SET_BINFO_BASEINIT_MARKED(NODE) SET_CLASSTYPE_MARKED2 (BINFO_TYPE (NODE))
-#define CLEAR_BINFO_BASEINIT_MARKED(NODE) CLEAR_CLASSTYPE_MARKED2 (BINFO_TYPE (NODE))
-
/* Nonzero means marked in search through virtual inheritance hierarchy. */
#define BINFO_VBASE_MARKED(NODE) CLASSTYPE_MARKED2 (BINFO_TYPE (NODE))
/* Modifier macros */
@@ -1015,11 +1006,10 @@ struct lang_type
#define SET_BINFO_NEW_VTABLE_MARKED(NODE) (TREE_VIA_VIRTUAL(NODE)?SET_CLASSTYPE_MARKED4(BINFO_TYPE(NODE)):(TREE_LANG_FLAG_4(NODE)=1))
#define CLEAR_BINFO_NEW_VTABLE_MARKED(NODE) (TREE_VIA_VIRTUAL(NODE)?CLEAR_CLASSTYPE_MARKED4(BINFO_TYPE(NODE)):(TREE_LANG_FLAG_4(NODE)=0))
-/* Nonzero means this class has initialized its virtual baseclasses. */
-#define BINFO_VBASE_INIT_MARKED(NODE) \
- (TREE_VIA_VIRTUAL(NODE)?CLASSTYPE_MARKED5(BINFO_TYPE(NODE)):TREE_LANG_FLAG_5(NODE))
-#define SET_BINFO_VBASE_INIT_MARKED(NODE) (TREE_VIA_VIRTUAL(NODE)?SET_CLASSTYPE_MARKED5(BINFO_TYPE(NODE)):(TREE_LANG_FLAG_5(NODE)=1))
-#define CLEAR_BINFO_VBASE_INIT_MARKED(NODE) (TREE_VIA_VIRTUAL(NODE)?CLEAR_CLASSTYPE_MARKED5(BINFO_TYPE(NODE)):(TREE_LANG_FLAG_5(NODE)=0))
+/* Nonzero means this class has done dfs_pushdecls. */
+#define BINFO_PUSHDECLS_MARKED(NODE) BINFO_VTABLE_PATH_MARKED (NODE)
+#define SET_BINFO_PUSHDECLS_MARKED(NODE) SET_BINFO_VTABLE_PATH_MARKED (NODE)
+#define CLEAR_BINFO_PUSHDECLS_MARKED(NODE) CLEAR_BINFO_VTABLE_PATH_MARKED (NODE)
/* Accessor macros for the vfield slots in structures. */
diff --git a/gcc/cp/search.c b/gcc/cp/search.c
index 4a1733c..1d0f1c3 100644
--- a/gcc/cp/search.c
+++ b/gcc/cp/search.c
@@ -1223,7 +1223,6 @@ lookup_field (xbasetype, name, protect, want_type)
{
type = xbasetype;
basetype_path = TYPE_BINFO (type);
- BINFO_VIA_PUBLIC (basetype_path) = 1;
BINFO_INHERITANCE_CHAIN (basetype_path) = NULL_TREE;
}
else
@@ -1852,7 +1851,6 @@ lookup_fnfields (basetype_path, name, complain)
{
basetype_chain = CLASSTYPE_BINFO_AS_LIST (type);
TREE_VIA_PUBLIC (basetype_chain) = 1;
- BINFO_VIA_PUBLIC (basetype_path) = 1;
BINFO_INHERITANCE_CHAIN (basetype_path) = NULL_TREE;
}
else
@@ -2018,7 +2016,6 @@ lookup_member (xbasetype, name, protect, want_type)
else if (IS_AGGR_TYPE_CODE (TREE_CODE (xbasetype)))
{
basetype_path = TYPE_BINFO (xbasetype);
- BINFO_VIA_PUBLIC (basetype_path) = 1;
BINFO_INHERITANCE_CHAIN (basetype_path) = NULL_TREE;
}
else
@@ -2652,6 +2649,10 @@ static int marked_new_vtablep (binfo) tree binfo;
{ return BINFO_NEW_VTABLE_MARKED (binfo); }
static int unmarked_new_vtablep (binfo) tree binfo;
{ return BINFO_NEW_VTABLE_MARKED (binfo) == 0; }
+static int marked_pushdecls_p (binfo) tree binfo;
+{ return BINFO_PUSHDECLS_MARKED (binfo); }
+static int unmarked_pushdecls_p (binfo) tree binfo;
+{ return BINFO_PUSHDECLS_MARKED (binfo) == 0; }
#if 0
static int dfs_search_slot_nonempty_p (binfo) tree binfo;
@@ -3611,7 +3612,10 @@ dfs_pushdecls (binfo)
methods++;
}
}
- SET_BINFO_MARKED (binfo);
+
+ /* We can't just use BINFO_MARKED because envelope_add_decl uses
+ DERIVED_FROM_P, which calls get_base_distance. */
+ SET_BINFO_PUSHDECLS_MARKED (binfo);
}
/* Consolidate unique (by name) member functions. */
@@ -3653,7 +3657,7 @@ dfs_compress_decls (binfo)
}
}
}
- CLEAR_BINFO_MARKED (binfo);
+ CLEAR_BINFO_PUSHDECLS_MARKED (binfo);
}
/* When entering the scope of a class, we cache all of the
@@ -3671,11 +3675,11 @@ push_class_decls (type)
search_stack = push_search_level (search_stack, &search_obstack);
/* Push class fields into CLASS_VALUE scope, and mark. */
- dfs_walk (TYPE_BINFO (type), dfs_pushdecls, unmarkedp);
+ dfs_walk (TYPE_BINFO (type), dfs_pushdecls, unmarked_pushdecls_p);
/* Compress fields which have only a single entry
by a given name, and unmark. */
- dfs_walk (TYPE_BINFO (type), dfs_compress_decls, markedp);
+ dfs_walk (TYPE_BINFO (type), dfs_compress_decls, marked_pushdecls_p);
/* Open up all the closed envelopes and push the contained decls into
class scope. */
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index fbd8542..6f33ec8 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -584,7 +584,10 @@ propagate_binfo_offsets (binfo, offset)
tree base_binfo = TREE_VEC_ELT (binfos, i);
if (TREE_VIA_VIRTUAL (base_binfo))
- i += 1;
+ {
+ i += 1;
+ unshare_base_binfos (base_binfo);
+ }
else
{
int j;
@@ -639,16 +642,16 @@ unshare_base_binfos (base_binfo)
j >= 0; j--)
{
tree base_base_binfo = TREE_VEC_ELT (base_binfos, j);
- if (! TREE_VIA_VIRTUAL (base_base_binfo))
- TREE_VEC_ELT (base_binfos, j)
- = make_binfo (BINFO_OFFSET (base_base_binfo),
- base_base_binfo,
- BINFO_VTABLE (base_base_binfo),
- BINFO_VIRTUALS (base_base_binfo),
- chain);
+ TREE_VEC_ELT (base_binfos, j)
+ = make_binfo (BINFO_OFFSET (base_base_binfo),
+ base_base_binfo,
+ BINFO_VTABLE (base_base_binfo),
+ BINFO_VIRTUALS (base_base_binfo),
+ chain);
chain = TREE_VEC_ELT (base_binfos, j);
TREE_VIA_PUBLIC (chain) = TREE_VIA_PUBLIC (base_base_binfo);
TREE_VIA_PROTECTED (chain) = TREE_VIA_PROTECTED (base_base_binfo);
+ TREE_VIA_VIRTUAL (chain) = TREE_VIA_VIRTUAL (base_base_binfo);
BINFO_INHERITANCE_CHAIN (chain) = base_binfo;
}
@@ -754,14 +757,16 @@ layout_basetypes (rec, max)
tree field = TYPE_FIELDS (rec);
if (TREE_VIA_VIRTUAL (base_binfo))
- continue;
-
- my_friendly_assert (TREE_TYPE (field) == basetype, 23897);
- BINFO_OFFSET (base_binfo)
- = size_int (CEIL (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field)),
- BITS_PER_UNIT));
- unshare_base_binfos (base_binfo);
- TYPE_FIELDS (rec) = TREE_CHAIN (field);
+ unshare_base_binfos (base_binfo);
+ else
+ {
+ my_friendly_assert (TREE_TYPE (field) == basetype, 23897);
+ BINFO_OFFSET (base_binfo)
+ = size_int (CEIL (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field)),
+ BITS_PER_UNIT));
+ unshare_base_binfos (base_binfo);
+ TYPE_FIELDS (rec) = TREE_CHAIN (field);
+ }
}
for (vbase_types = CLASSTYPE_VBASECLASSES (rec); vbase_types;