diff options
author | Mark Mitchell <mark@codesourcery.com> | 2000-01-03 21:32:58 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2000-01-03 21:32:58 +0000 |
commit | 4b3b53287de4c2ff7d8105b4045157a8b886737b (patch) | |
tree | 4a521c0b3f24972f16458e5d56629150b4d8c037 /gcc | |
parent | f540ec244888cce9614dd91eff8a013897f01f9b (diff) | |
download | gcc-4b3b53287de4c2ff7d8105b4045157a8b886737b.zip gcc-4b3b53287de4c2ff7d8105b4045157a8b886737b.tar.gz gcc-4b3b53287de4c2ff7d8105b4045157a8b886737b.tar.bz2 |
cp-tree.h (CLASSTYPE_VBASECLASSES): Improve documentation.
* cp-tree.h (CLASSTYPE_VBASECLASSES): Improve documentation.
* class.c (layout_basetypes): Don't set BINFO_INHERITANCE_CHAIN
or unshare_base_binfos for virtual bases here.
* search.c (dfs_get_vbase_types): Do it here.
(get_vbase_types): Adjust.
From-SVN: r31184
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cp/class.c | 2 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 15 | ||||
-rw-r--r-- | gcc/cp/search.c | 15 |
4 files changed, 29 insertions, 11 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6dc8394..6c6179f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2000-01-03 Mark Mitchell <mark@codesourcery.com> + + * cp-tree.h (CLASSTYPE_VBASECLASSES): Improve documentation. + * class.c (layout_basetypes): Don't set BINFO_INHERITANCE_CHAIN + or unshare_base_binfos for virtual bases here. + * search.c (dfs_get_vbase_types): Do it here. + (get_vbase_types): Adjust. + 2000-01-02 Mark Mitchell <mark@codesourcery.com> * cp-tree.h (CLASSTYPE_VFIELDS): Move definition. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 0a8fbf7..86cb926 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -4379,8 +4379,6 @@ layout_basetypes (rec) for (vbase_types = CLASSTYPE_VBASECLASSES (rec); vbase_types; vbase_types = TREE_CHAIN (vbase_types)) { - BINFO_INHERITANCE_CHAIN (vbase_types) = TYPE_BINFO (rec); - unshare_base_binfos (vbase_types); propagate_binfo_offsets (vbase_types, BINFO_OFFSET (vbase_types)); if (extra_warnings) diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index e5daa86..a172ec1 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -1408,7 +1408,20 @@ struct lang_type #define CLASSTYPE_VSIZE(NODE) (TYPE_LANG_SPECIFIC(NODE)->vsize) /* A chain of BINFOs for the direct and indirect virtual base classes - that this type uses in depth-first left-to-right order. */ + that this type uses in depth-first left-to-right order. These + BINFOs are distinct from those in the TYPE_BINFO hierarchy. So, + given: + + struct A {}; + struct B : public A {}; + struct C : virtual public B {}; + struct D : virtual public B {}; + struct E : public C, public D {}; + + there will be two copies of `A' and `B' in the TYPE_BINFO hierarchy + for `E'. On the CLASSTYPE_VBASECLASSES list, there will be just + one copy of `A' (distinct from the other two) with its own copy of `B' + (also distinct from the copies in the TYPE_BINFO hierarchy.) */ #define CLASSTYPE_VBASECLASSES(NODE) (TYPE_LANG_SPECIFIC(NODE)->vbases) /* The BINFO (if any) for the virtual baseclass T of the class C. */ diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 130f9bf..28ef1a1 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -2907,33 +2907,32 @@ dfs_get_vbase_types (binfo, data) tree binfo; void *data; { - tree *vbase_types = (tree *) data; + tree type = (tree) data; if (TREE_VIA_VIRTUAL (binfo) && ! BINFO_VBASE_MARKED (binfo)) { tree new_vbase = make_binfo (integer_zero_node, binfo, BINFO_VTABLE (binfo), BINFO_VIRTUALS (binfo)); - TREE_CHAIN (new_vbase) = *vbase_types; + unshare_base_binfos (new_vbase); TREE_VIA_VIRTUAL (new_vbase) = 1; - *vbase_types = new_vbase; + BINFO_INHERITANCE_CHAIN (new_vbase) = TYPE_BINFO (type); + TREE_CHAIN (new_vbase) = CLASSTYPE_VBASECLASSES (type); + CLASSTYPE_VBASECLASSES (type) = new_vbase; SET_BINFO_VBASE_MARKED (binfo); } SET_BINFO_MARKED (binfo); return NULL_TREE; } -/* Return a list of binfos for the virtual base classes for TYPE, in - depth-first search order. The list is freshly allocated, so - no modification is made to the current binfo hierarchy. */ +/* Set CLASSTYPE_VBASECLASSES for TYPE. */ void get_vbase_types (type) tree type; { CLASSTYPE_VBASECLASSES (type) = NULL_TREE; - dfs_walk (TYPE_BINFO (type), dfs_get_vbase_types, unmarkedp, - &CLASSTYPE_VBASECLASSES (type)); + dfs_walk (TYPE_BINFO (type), dfs_get_vbase_types, unmarkedp, type); /* Rely upon the reverse dfs ordering from dfs_get_vbase_types, and now reverse it so that we get normal dfs ordering. */ CLASSTYPE_VBASECLASSES (type) = nreverse (CLASSTYPE_VBASECLASSES (type)); |