This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH to clean up some binfo stuff
- To: egcs-patches at cygnus dot com
- Subject: PATCH to clean up some binfo stuff
- From: Mark Mitchell <mark at markmitchell dot com>
- Date: Thu, 27 Aug 1998 10:20:20 -0700
- Cc: Jason Merrill <jason at cygnus dot com>
- Reply-to: mark at markmitchell dot com
Jason --
You beat me to the punch (by a matter of hours) on fixing the
unshared-ness of binfos. I decided that my preliminary cleanups were
still worth putting in; all these patches do is remove some unused
parameters, add some documentation, and such: no substantive changes.
--
Mark Mitchell mark@markmitchell.com
Mark Mitchell Consulting http://www.markmitchell.com
1998-08-27 Mark Mitchell <mark@markmitchell.com>
* class.c (build_vbase_path): Use reverse_path.
(finish_base_struct): Move warnings for inaccessible bases to
layout_basetypes.
(modify_one_vtable): Remove check of TREE_USED (binfo).
(fixup_vtable_deltas1): Likewise.
* cp-tree.h (BINFO_INHERITANCE_CHAIN): Document here.
(xref_tag): Remove binfos parameter.
(make_binfo): Remove chain parameter.
(reverse_path): Add copy parameter.
* decl.c (init_decl_processing): Change calls to xref_tag.
(xref_tag): Remove binfos parameter.
(xref_basetypes): Change calls to make_binfo.
* decl2.c (grok_x_components): Change calls to xref_tag.
(handle_class_head): Likewise.
* friend.c (do_friend): Likewise.
* lex.c (make_lang_type): Change calls to make_binfo.
* parse.y (structsp): Change calls to xref_tag.
(named_complex_class_head_sans_basetype): Likewise.
(named_class_head): Likewise.
* rtti.c (init_rtti_processing): Likewise.
* search.c (compute_access): Change calls to reverse_path.
(dfs_get_vbase_types): Change calls to make_binfo.
(get_vbase_types): Remove dead code.
* tree.c (unshare_base_binfos): Change calls to make_binfo.
(layout_basetypes): Warn here about inaccessible bases.
(make_binfo): Remove chain parameter.
(reverse_path): Add copy parameter.
Index: testsuite/g++.old-deja/g++.other/lookup2.C
===================================================================
RCS file: lookup2.C
diff -N lookup2.C
*** /dev/null Mon Dec 31 20:00:00 1979
--- lookup2.C Thu Aug 27 09:54:50 1998
***************
*** 0 ****
--- 1,13 ----
+ // Build don't link:
+
+ struct B {
+ int i;
+ };
+
+ struct D: virtual public B {
+ int i;
+ };
+
+ struct D2 : public D {
+ void f() { i = 3; }
+ };
Index: testsuite/g++.old-deja/g++.pt/lookup5.C
===================================================================
RCS file: lookup5.C
diff -N lookup5.C
*** /dev/null Mon Dec 31 20:00:00 1979
--- lookup5.C Thu Aug 27 09:54:50 1998
***************
*** 0 ****
--- 1,14 ----
+ // Build don't link:
+
+ struct B {
+ int i;
+ };
+
+ struct D: public B {
+ int i;
+ };
+
+ template <class T>
+ struct D2 : public D {
+ void f() { i = 3; }
+ };
Index: cp/class.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/class.c,v
retrieving revision 1.72
diff -c -p -r1.72 class.c
*** class.c 1998/08/27 02:04:24 1.72
--- class.c 1998/08/27 16:55:06
*************** build_vbase_path (code, type, expr, path
*** 266,282 ****
if (BINFO_INHERITANCE_CHAIN (path))
{
- tree reverse_path = NULL_TREE;
-
push_expression_obstack ();
! while (path)
! {
! tree r = copy_node (path);
! BINFO_INHERITANCE_CHAIN (r) = reverse_path;
! reverse_path = r;
! path = BINFO_INHERITANCE_CHAIN (path);
! }
! path = reverse_path;
pop_obstacks ();
}
--- 266,273 ----
if (BINFO_INHERITANCE_CHAIN (path))
{
push_expression_obstack ();
! path = reverse_path (path, /*copy=*/1);
pop_obstacks ();
}
*************** finish_base_struct (t, b)
*** 1758,1792 ****
}
}
- /* This comment said "Must come after offsets are fixed for all bases."
- Well, now this happens before the offsets are fixed, but it seems to
- work fine. Guess we'll see... */
- for (i = 0; i < n_baseclasses; i++)
- {
- tree base_binfo = TREE_VEC_ELT (binfos, i);
- tree basetype = BINFO_TYPE (base_binfo);
-
- if (get_base_distance (basetype, t, 0, (tree*)0) == -2)
- {
- cp_warning ("direct base `%T' inaccessible in `%T' due to ambiguity",
- basetype, t);
- }
- }
- {
- tree v = get_vbase_types (t);
-
- for (; v; v = TREE_CHAIN (v))
- {
- tree basetype = BINFO_TYPE (v);
- if (get_base_distance (basetype, t, 0, (tree*)0) == -2)
- {
- if (extra_warnings)
- cp_warning ("virtual base `%T' inaccessible in `%T' due to ambiguity",
- basetype, t);
- }
- }
- }
-
{
tree vfields;
/* Find the base class with the largest number of virtual functions. */
--- 1749,1754 ----
*************** modify_one_vtable (binfo, t, fndecl, pfn
*** 2413,2422 ****
BINFO_OFFSET (binfo));
this_offset = ssize_binop (MINUS_EXPR, offset, base_offset);
- /* Make sure we can modify the derived association with immunity. */
- if (TREE_USED (binfo))
- my_friendly_assert (0, 999);
-
if (binfo == TYPE_BINFO (t))
{
/* In this case, it is *type*'s vtable we are modifying.
--- 2375,2380 ----
*************** fixup_vtable_deltas1 (binfo, t)
*** 2516,2524 ****
if (! tree_int_cst_equal (this_offset, delta))
{
/* Make sure we can modify the derived association with immunity. */
- if (TREE_USED (binfo))
- my_friendly_assert (0, 999);
-
if (binfo == TYPE_BINFO (t))
{
/* In this case, it is *type*'s vtable we are modifying.
--- 2474,2479 ----
Index: cp/cp-tree.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/cp-tree.h,v
retrieving revision 1.119
diff -c -p -r1.119 cp-tree.h
*** cp-tree.h 1998/08/27 01:41:15 1.119
--- cp-tree.h 1998/08/27 16:55:18
*************** struct lang_type
*** 966,971 ****
--- 966,981 ----
/* Additional macros for inheritance information. */
+ /* The BINFO_INHERITANCE_CHAIN is used opposite to the description in
+ gcc/tree.h. In particular if D is derived from B then the BINFO
+ for B (in D) will have a BINFO_INHERITANCE_CHAIN pointing to
+ D. In tree.h, this pointer is described as pointing in other
+ direction.
+
+ After a call to get_vbase_types, the vbases are chained together in
+ depth-first order via TREE_CHAIN. Other than that, TREE_CHAIN is
+ unused. */
+
#ifdef MI_MATRIX
/* When building a matrix to determine by a single lookup
whether one class is derived from another or not,
*************** extern int parmlist_is_exprlist PROTO(
*** 2548,2554 ****
extern int copy_args_p PROTO((tree));
extern int grok_ctor_properties PROTO((tree, tree));
extern void grok_op_properties PROTO((tree, int, int));
! extern tree xref_tag PROTO((tree, tree, tree, int));
extern tree xref_tag_from_type PROTO((tree, tree, int));
extern void xref_basetypes PROTO((tree, tree, tree, tree));
extern tree start_enum PROTO((tree));
--- 2558,2564 ----
extern int copy_args_p PROTO((tree));
extern int grok_ctor_properties PROTO((tree, tree));
extern void grok_op_properties PROTO((tree, int, int));
! extern tree xref_tag PROTO((tree, tree, int));
extern tree xref_tag_from_type PROTO((tree, tree, int));
extern void xref_basetypes PROTO((tree, tree, tree, tree));
extern tree start_enum PROTO((tree));
*************** extern tree hash_tree_cons PROTO((int,
*** 3005,3013 ****
extern tree hash_tree_chain PROTO((tree, tree));
extern tree hash_chainon PROTO((tree, tree));
extern tree get_decl_list PROTO((tree));
! extern tree make_binfo PROTO((tree, tree, tree, tree, tree));
extern tree binfo_value PROTO((tree, tree));
! extern tree reverse_path PROTO((tree));
extern int count_functions PROTO((tree));
extern int is_overloaded_fn PROTO((tree));
extern tree get_first_fn PROTO((tree));
--- 3015,3023 ----
extern tree hash_tree_chain PROTO((tree, tree));
extern tree hash_chainon PROTO((tree, tree));
extern tree get_decl_list PROTO((tree));
! extern tree make_binfo PROTO((tree, tree, tree, tree));
extern tree binfo_value PROTO((tree, tree));
! extern tree reverse_path PROTO((tree, int));
extern int count_functions PROTO((tree));
extern int is_overloaded_fn PROTO((tree));
extern tree get_first_fn PROTO((tree));
Index: cp/decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.194
diff -c -p -r1.194 decl.c
*** decl.c 1998/08/27 00:14:27 1.194
--- decl.c 1998/08/27 16:55:59
*************** init_decl_processing ()
*** 6166,6172 ****
if (flag_honor_std)
push_namespace (get_identifier ("std"));
bad_alloc_type_node = xref_tag
! (class_type_node, get_identifier ("bad_alloc"), NULL_TREE, 1);
if (flag_honor_std)
pop_namespace ();
newtype = build_exception_variant
--- 6166,6172 ----
if (flag_honor_std)
push_namespace (get_identifier ("std"));
bad_alloc_type_node = xref_tag
! (class_type_node, get_identifier ("bad_alloc"), 1);
if (flag_honor_std)
pop_namespace ();
newtype = build_exception_variant
*************** grok_op_properties (decl, virtualp, frie
*** 11415,11423 ****
scope.) */
tree
! xref_tag (code_type_node, name, binfo, globalize)
tree code_type_node;
! tree name, binfo;
int globalize;
{
enum tag_types tag_code;
--- 11415,11423 ----
scope.) */
tree
! xref_tag (code_type_node, name, globalize)
tree code_type_node;
! tree name;
int globalize;
{
enum tag_types tag_code;
*************** xref_tag (code_type_node, name, binfo, g
*** 11623,11631 ****
redeclare_class_template (ref, current_template_parms);
}
- if (binfo)
- xref_basetypes (code_type_node, name, ref, binfo);
-
/* Until the type is defined, tentatively accept whatever
structure tag the user hands us. */
if (TYPE_SIZE (ref) == NULL_TREE
--- 11623,11628 ----
*************** xref_tag_from_type (old, id, globalize)
*** 11662,11668 ****
if (id == NULL_TREE)
id = TYPE_IDENTIFIER (old);
! return xref_tag (code_type_node, id, NULL_TREE, globalize);
}
void
--- 11659,11665 ----
if (id == NULL_TREE)
id = TYPE_IDENTIFIER (old);
! return xref_tag (code_type_node, id, globalize);
}
void
*************** xref_basetypes (code_type_node, name, re
*** 11759,11765 ****
base_binfo = make_binfo (integer_zero_node, basetype,
TYPE_BINFO_VTABLE (basetype),
! TYPE_BINFO_VIRTUALS (basetype), NULL_TREE);
TREE_VEC_ELT (binfos, i) = base_binfo;
TREE_VIA_PUBLIC (base_binfo) = via_public;
--- 11756,11762 ----
base_binfo = make_binfo (integer_zero_node, basetype,
TYPE_BINFO_VTABLE (basetype),
! TYPE_BINFO_VIRTUALS (basetype));
TREE_VEC_ELT (binfos, i) = base_binfo;
TREE_VIA_PUBLIC (base_binfo) = via_public;
Index: cp/decl2.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl2.c,v
retrieving revision 1.119
diff -c -p -r1.119 decl2.c
*** decl2.c 1998/08/24 11:57:09 1.119
--- decl2.c 1998/08/27 16:56:16
*************** grok_x_components (specs, components)
*** 945,951 ****
x = DECL_NAME (CLASSTYPE_TI_TEMPLATE (t));
else
x = TYPE_IDENTIFIER (t);
! t = xref_tag (tcode, x, NULL_TREE, 0);
}
if (ANON_UNION_TYPE_P (t))
--- 945,951 ----
x = DECL_NAME (CLASSTYPE_TI_TEMPLATE (t));
else
x = TYPE_IDENTIFIER (t);
! t = xref_tag (tcode, x, 0);
}
if (ANON_UNION_TYPE_P (t))
*************** grok_x_components (specs, components)
*** 989,995 ****
case ENUMERAL_TYPE:
tcode = enum_type_node;
! t = xref_tag (tcode, TYPE_IDENTIFIER (t), NULL_TREE, 0);
x = grok_enum_decls (NULL_TREE);
return x;
break;
--- 989,995 ----
case ENUMERAL_TYPE:
tcode = enum_type_node;
! t = xref_tag (tcode, TYPE_IDENTIFIER (t), 0);
x = grok_enum_decls (NULL_TREE);
return x;
break;
*************** handle_class_head (aggr, scope, id)
*** 4943,4948 ****
cp_error ("no file-scope type named `%D'", id);
id = xref_tag
! (aggr, make_anon_name (), NULL_TREE, 1);
return TYPE_MAIN_DECL (id);
}
--- 4943,4948 ----
cp_error ("no file-scope type named `%D'", id);
id = xref_tag
! (aggr, make_anon_name (), 1);
return TYPE_MAIN_DECL (id);
}
Index: cp/friend.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/friend.c,v
retrieving revision 1.25
diff -c -p -r1.25 friend.c
*** friend.c 1998/08/23 12:47:04 1.25
--- friend.c 1998/08/27 16:56:18
*************** do_friend (ctype, declarator, decl, parm
*** 476,482 ****
if (decl == NULL_TREE)
{
cp_warning ("implicitly declaring `%T' as struct", declarator);
! decl = xref_tag (record_type_node, declarator, NULL_TREE, 1);
decl = TYPE_MAIN_DECL (decl);
}
--- 476,482 ----
if (decl == NULL_TREE)
{
cp_warning ("implicitly declaring `%T' as struct", declarator);
! decl = xref_tag (record_type_node, declarator, 1);
decl = TYPE_MAIN_DECL (decl);
}
Index: cp/lex.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/lex.c,v
retrieving revision 1.66
diff -c -p -r1.66 lex.c
*** lex.c 1998/08/26 12:45:13 1.66
--- lex.c 1998/08/27 16:56:32
*************** make_lang_type (code)
*** 4623,4630 ****
CLASSTYPE_AS_LIST (t) = build_expr_list (NULL_TREE, t);
SET_CLASSTYPE_INTERFACE_UNKNOWN_X (t, interface_unknown);
CLASSTYPE_INTERFACE_ONLY (t) = interface_only;
! TYPE_BINFO (t) = make_binfo (integer_zero_node, t, NULL_TREE, NULL_TREE,
! NULL_TREE);
CLASSTYPE_BINFO_AS_LIST (t) = build_tree_list (NULL_TREE, TYPE_BINFO (t));
/* Make sure this is laid out, for ease of use later.
--- 4623,4629 ----
CLASSTYPE_AS_LIST (t) = build_expr_list (NULL_TREE, t);
SET_CLASSTYPE_INTERFACE_UNKNOWN_X (t, interface_unknown);
CLASSTYPE_INTERFACE_ONLY (t) = interface_only;
! TYPE_BINFO (t) = make_binfo (integer_zero_node, t, NULL_TREE, NULL_TREE);
CLASSTYPE_BINFO_AS_LIST (t) = build_tree_list (NULL_TREE, TYPE_BINFO (t));
/* Make sure this is laid out, for ease of use later.
Index: cp/parse.y
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/parse.y,v
retrieving revision 1.83
diff -c -p -r1.83 parse.y
*** parse.y 1998/08/26 13:55:44 1.83
--- parse.y 1998/08/27 16:57:08
*************** structsp:
*** 2083,2092 ****
$$.new_type_flag = 1;
check_for_missing_semicolon ($$.t); }
| ENUM identifier
! { $$.t = xref_tag (enum_type_node, $2, NULL_TREE, 1);
$$.new_type_flag = 0; }
| ENUM complex_type_name
! { $$.t = xref_tag (enum_type_node, $2, NULL_TREE, 1);
$$.new_type_flag = 0; }
| TYPENAME_KEYWORD typename_sub
{ $$.t = $2;
--- 2083,2092 ----
$$.new_type_flag = 1;
check_for_missing_semicolon ($$.t); }
| ENUM identifier
! { $$.t = xref_tag (enum_type_node, $2, 1);
$$.new_type_flag = 0; }
| ENUM complex_type_name
! { $$.t = xref_tag (enum_type_node, $2, 1);
$$.new_type_flag = 0; }
| TYPENAME_KEYWORD typename_sub
{ $$.t = $2;
*************** named_complex_class_head_sans_basetype:
*** 2193,2204 ****
do_xref_defn:
/* empty */ %prec EMPTY
! { $<ttype>$ = xref_tag (current_aggr, $<ttype>0, NULL_TREE, 0); }
;
named_class_head:
named_class_head_sans_basetype %prec EMPTY
! { $$ = xref_tag (current_aggr, $1, NULL_TREE, 1); }
| named_class_head_sans_basetype_defn do_xref_defn
maybe_base_class_list %prec EMPTY
{
--- 2193,2204 ----
do_xref_defn:
/* empty */ %prec EMPTY
! { $<ttype>$ = xref_tag (current_aggr, $<ttype>0, 0); }
;
named_class_head:
named_class_head_sans_basetype %prec EMPTY
! { $$ = xref_tag (current_aggr, $1, 1); }
| named_class_head_sans_basetype_defn do_xref_defn
maybe_base_class_list %prec EMPTY
{
*************** named_class_head:
*** 2225,2231 ****
unnamed_class_head:
aggr '{'
! { $$ = xref_tag ($$, make_anon_name (), NULL_TREE, 0);
yyungetc ('{', 1); }
;
--- 2225,2231 ----
unnamed_class_head:
aggr '{'
! { $$ = xref_tag ($$, make_anon_name (), 0);
yyungetc ('{', 1); }
;
Index: cp/rtti.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/rtti.c,v
retrieving revision 1.15
diff -c -p -r1.15 rtti.c
*** rtti.c 1998/08/17 16:29:17 1.15
--- rtti.c 1998/08/27 16:57:11
*************** init_rtti_processing ()
*** 60,66 ****
if (flag_honor_std)
push_namespace (get_identifier ("std"));
type_info_type_node = xref_tag
! (class_type_node, get_identifier ("type_info"), NULL_TREE, 1);
if (flag_honor_std)
pop_namespace ();
tinfo_fn_id = get_identifier ("__tf");
--- 60,66 ----
if (flag_honor_std)
push_namespace (get_identifier ("std"));
type_info_type_node = xref_tag
! (class_type_node, get_identifier ("type_info"), 1);
if (flag_honor_std)
pop_namespace ();
tinfo_fn_id = get_identifier ("__tf");
Index: cp/search.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/search.c,v
retrieving revision 1.43
diff -c -p -r1.43 search.c
*** search.c 1998/08/27 01:41:16 1.43
--- search.c 1998/08/27 16:57:23
*************** compute_access (basetype_path, field)
*** 1003,1009 ****
}
/* must reverse more than one element */
! basetype_path = reverse_path (basetype_path);
types = basetype_path;
via_protected = 0;
access = access_default_node;
--- 1003,1009 ----
}
/* must reverse more than one element */
! basetype_path = reverse_path (basetype_path, /*copy=*/0);
types = basetype_path;
via_protected = 0;
access = access_default_node;
*************** compute_access (basetype_path, field)
*** 1049,1055 ****
else
break;
}
! reverse_path (basetype_path);
/* No special visibilities apply. Use normal rules. */
--- 1049,1055 ----
else
break;
}
! reverse_path (basetype_path, /*copy=*/0);
/* No special visibilities apply. Use normal rules. */
*************** dfs_get_vbase_types (binfo)
*** 3196,3205 ****
{
if (TREE_VIA_VIRTUAL (binfo) && ! BINFO_VBASE_MARKED (binfo))
{
! vbase_types = make_binfo (integer_zero_node, binfo,
! BINFO_VTABLE (binfo),
! BINFO_VIRTUALS (binfo), vbase_types);
! TREE_VIA_VIRTUAL (vbase_types) = 1;
SET_BINFO_VBASE_MARKED (binfo);
}
SET_BINFO_MARKED (binfo);
--- 3196,3207 ----
{
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;
! TREE_VIA_VIRTUAL (new_vbase) = 1;
! vbase_types = new_vbase;
SET_BINFO_VBASE_MARKED (binfo);
}
SET_BINFO_MARKED (binfo);
*************** get_vbase_types (type)
*** 3214,3224 ****
tree vbases;
tree binfo;
! if (TREE_CODE (type) == TREE_VEC)
! binfo = type;
! else
! binfo = TYPE_BINFO (type);
!
vbase_types = NULL_TREE;
dfs_walk (binfo, dfs_get_vbase_types, unmarkedp);
dfs_walk (binfo, dfs_unmark, markedp);
--- 3216,3222 ----
tree vbases;
tree binfo;
! binfo = TYPE_BINFO (type);
vbase_types = NULL_TREE;
dfs_walk (binfo, dfs_get_vbase_types, unmarkedp);
dfs_walk (binfo, dfs_unmark, markedp);
Index: cp/tree.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/tree.c,v
retrieving revision 1.61
diff -c -p -r1.61 tree.c
*** tree.c 1998/08/27 01:41:17 1.61
--- tree.c 1998/08/27 16:57:29
*************** unshare_base_binfos (base_binfo)
*** 646,653 ****
= 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);
--- 646,652 ----
= 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);
TREE_VIA_PUBLIC (chain) = TREE_VIA_PUBLIC (base_base_binfo);
TREE_VIA_PROTECTED (chain) = TREE_VIA_PROTECTED (base_base_binfo);
*************** layout_basetypes (rec, max)
*** 677,685 ****
tree binfos = TYPE_BINFO_BASETYPES (rec);
int i, n_baseclasses = binfos ? TREE_VEC_LENGTH (binfos) : 0;
! /* Get all the virtual base types that this type uses.
! The TREE_VALUE slot holds the virtual baseclass type. */
! tree vbase_types = get_vbase_types (rec);
unsigned int record_align = MAX (BITS_PER_UNIT, TYPE_ALIGN (rec));
unsigned int desired_align;
--- 676,682 ----
tree binfos = TYPE_BINFO_BASETYPES (rec);
int i, n_baseclasses = binfos ? TREE_VEC_LENGTH (binfos) : 0;
! tree vbase_types;
unsigned int record_align = MAX (BITS_PER_UNIT, TYPE_ALIGN (rec));
unsigned int desired_align;
*************** layout_basetypes (rec, max)
*** 694,700 ****
record_align = MAX (record_align, STRUCTURE_SIZE_BOUNDARY);
#endif
! CLASSTYPE_VBASECLASSES (rec) = vbase_types;
my_friendly_assert (TREE_CODE (TYPE_SIZE (rec)) == INTEGER_CST, 19970302);
const_size = TREE_INT_CST_LOW (TYPE_SIZE (rec));
--- 691,701 ----
record_align = MAX (record_align, STRUCTURE_SIZE_BOUNDARY);
#endif
! /* Get all the virtual base types that this type uses. The
! TREE_VALUE slot holds the virtual baseclass type. Note that
! get_vbase_types makes copies of the virtual base BINFOs, so that
! the vbase_types are unshared. */
! CLASSTYPE_VBASECLASSES (rec) = vbase_types = get_vbase_types (rec);
my_friendly_assert (TREE_CODE (TYPE_SIZE (rec)) == INTEGER_CST, 19970302);
const_size = TREE_INT_CST_LOW (TYPE_SIZE (rec));
*************** layout_basetypes (rec, max)
*** 761,766 ****
--- 762,772 ----
else
{
my_friendly_assert (TREE_TYPE (field) == basetype, 23897);
+
+ if (get_base_distance (basetype, rec, 0, (tree*)0) == -2)
+ cp_warning ("direct base `%T' inaccessible in `%T' due to ambiguity",
+ basetype, rec);
+
BINFO_OFFSET (base_binfo)
= size_int (CEIL (TREE_INT_CST_LOW (DECL_FIELD_BITPOS (field)),
BITS_PER_UNIT));
*************** layout_basetypes (rec, max)
*** 774,779 ****
--- 780,793 ----
{
BINFO_INHERITANCE_CHAIN (vbase_types) = TYPE_BINFO (rec);
unshare_base_binfos (vbase_types);
+
+ if (extra_warnings)
+ {
+ tree basetype = BINFO_TYPE (vbase_types);
+ if (get_base_distance (basetype, rec, 0, (tree*)0) == -2)
+ cp_warning ("virtual base `%T' inaccessible in `%T' due to ambiguity",
+ basetype, rec);
+ }
}
return max;
*************** get_decl_list (value)
*** 1198,1212 ****
VTABLE is the virtual function table with which to initialize
sub-objects of type TYPE.
! VIRTUALS are the virtual functions sitting in VTABLE.
- CHAIN are more associations we must retain. */
-
tree
! make_binfo (offset, binfo, vtable, virtuals, chain)
tree offset, binfo;
tree vtable, virtuals;
- tree chain;
{
tree new_binfo = make_tree_vec (7);
tree type;
--- 1212,1223 ----
VTABLE is the virtual function table with which to initialize
sub-objects of type TYPE.
! VIRTUALS are the virtual functions sitting in VTABLE. */
tree
! make_binfo (offset, binfo, vtable, virtuals)
tree offset, binfo;
tree vtable, virtuals;
{
tree new_binfo = make_tree_vec (7);
tree type;
*************** make_binfo (offset, binfo, vtable, virtu
*** 1219,1228 ****
binfo = TYPE_BINFO (binfo);
}
- TREE_CHAIN (new_binfo) = chain;
- if (chain)
- TREE_USED (new_binfo) = TREE_USED (chain);
-
TREE_TYPE (new_binfo) = TYPE_MAIN_VARIANT (type);
BINFO_OFFSET (new_binfo) = offset;
BINFO_VTABLE (new_binfo) = vtable;
--- 1230,1235 ----
*************** binfo_value (elem, type)
*** 1251,1263 ****
return get_binfo (elem, type, 0);
}
tree
! reverse_path (path)
tree path;
{
register tree prev = 0, tmp, next;
for (tmp = path; tmp; tmp = next)
{
next = BINFO_INHERITANCE_CHAIN (tmp);
BINFO_INHERITANCE_CHAIN (tmp) = prev;
prev = tmp;
--- 1258,1279 ----
return get_binfo (elem, type, 0);
}
+ /* Reverse the BINFO-chain given by PATH. (If the
+ BINFO_INHERITANCE_CHAIN points from base classes to derived
+ classes, it will instead point from derived classes to base
+ classes.) Returns the first node in the reversed chain. If COPY
+ is non-zero, the nodes are copied as the chain is traversed. */
+
tree
! reverse_path (path, copy)
tree path;
+ int copy;
{
register tree prev = 0, tmp, next;
for (tmp = path; tmp; tmp = next)
{
+ if (copy)
+ tmp = copy_node (tmp);
next = BINFO_INHERITANCE_CHAIN (tmp);
BINFO_INHERITANCE_CHAIN (tmp) = prev;
prev = tmp;