This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Change base class access representation
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: mark at codesourcery dot com
- Cc: gcc-patches at gcc dot gnu dot org, per at bothner dot com
- Date: Fri, 31 Jan 2003 15:52:08 +0000
- Subject: [patch] Change base class access representation
- Organization: Codesourcery LLC
Hi,
g++ currently represents virtual bases with separate 'unshared' binfos
for each access path to the virtual base. This leads to exponential
memory requirement, not to mention confusion.
This patch changes they way a base binfo's access is represented. Instead
of using bit in the base binfo, it uses a vector of access nodes in the
more derived binfo.
I did consider having a single vector containing base binfo/access pairs,
but that looked more error prone - lots of pieces of code assume a set
of binfo pointers is a TREE_VEC.
This patch, on its own, increases the memory requirements. I will be
working on regaining that by not unsharing the virtual base binfos for C++.
Java will have a permenant increase. Though, as I think the java base
accesses are always public, we could default to public bases in the common
code, and simply not allocate the vector in java. Per?
booted and tested on i686-pc-linux-gnu, ok?
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
The voices in my head said this was stupid too
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2003-01-31 Nathan Sidwell <nathan@codesourcery.com>
Change base class access representation.
* tree.h (TREE_VIA_PUBLIC, TREE_VIA_PROTECTED,
TREE_VIA_PRIVATE): Remove.
(BINFO_BASEACCESSES): New binfo elt.
(BINFO_BASEACCESS): New accessor.
(BINFO_ELTS): Increase.
(TI_ACCESS_PUBLIC, TI_ACCESS_PROTECTED, TI_ACCESS_PRIVATE): New.
(access_public_node, access_protected_node,
access_private_node): New global nodes.
* tree.c (build_common_tree_nodes_2): Initialize access nodes.
* dbxout.c (dbxout_type): Adjust.
* dwarf2out.c (gen_inheritance_die): Add access parameter.
(gen_member_die): Adjust.
* dwarfout.c (output_inheritance_die): ARG is array of two trees.
(output_type): Adjust.
* tree-dump.c (dequeue_and_dump): Adjust binfo dumping.
Change base class access representation.
* cp/cp-tree.h (CPTI_ACCESS_*): Remove.
(access_*_node): Remove.
(dfs_walk, dfs_walk_real): Add access arg to queue function.
(markedp, unmarkedp, dfs_unmarked_real_bases_queue_p,
dfs_marked_real_bases_queue_p): Add access arg.
(finish_base_specifier): Add virtual_p arg.
* cp/tree.c (unshare_base_binfos): Adjust.
(make_binfo): Set access vector too.
* cp/class.c (dfs_ctor_vtable_bases_queue_p): Add access arg.
(maybe_warn_about_overly_private_class): Adjust.
(init_class_processing): Don't init access nodes.
* cp/decl.c (xref_basetypes): Adjust.
* cp/parser.c (cp_parser_base_specifier): Adjust.
* cp/pt.c (instantiate_class_template): Adjust.
* cp/rtti.c (get_pseudo_ti_init): Adjust.
(get_pseudo_ti_desc): Adjust.
* cp/search.c (dfs_no_overlap_yet): Add access arg.
(marked_pushdecls_p, unmarked_pushdecls_p): Likewise.
(dfs_debug_unmarkedp): Likewise.
(bfs_walk): Add access arg to queue function.
(lookup_field_queue_p): Add access arg.
(shared_marked_p, shared_unmarked_p): Likewise.
(dfs_accessible_queue_p): Likewise. Adjust.
(dfs_canonical_queue): Likewise.
(lookup_base_r): Adjust.
(dynamic_cast_base_recurse): Adjust.
(dfs_access_in_type): Adjust.
(dfs_walk, dfs_walk_real): Add access arg to queue fn.
(dfs_unmarked_real_bases_queue_p): Adjust.
(dfs_marked_real_bases_queue_p): Adjust.
(markedp, unmarkedp): Add access arg.
* cp/semantics.c (finish_base_specifier): Add virtual arg, adjust.
Change base class access representation.
* java/class.c (set_super_info): Adjust.
(add_interface_do): Adjust.
(maybe_add_interface): Adjust.
(add_interface): Adjust.
* java/parse.y (patch_anonymous_class): Extend access vector too.
Index: dbxout.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dbxout.c,v
retrieving revision 1.133
diff -c -3 -p -r1.133 dbxout.c
*** dbxout.c 16 Jan 2003 15:37:53 -0000 1.133
--- dbxout.c 31 Jan 2003 15:06:19 -0000
*************** dbxout_type (type, full)
*** 1577,1589 ****
}
for (i = 0; i < n_baseclasses; i++)
{
! tree child = TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (type)), i);
!
if (use_gnu_debug_info_extensions)
{
have_used_extensions = 1;
putc (TREE_VIA_VIRTUAL (child) ? '1' : '0', asmfile);
! putc (TREE_VIA_PUBLIC (child) ? '2' : '0', asmfile);
CHARS (2);
if (TREE_VIA_VIRTUAL (child) && strcmp (lang_hooks.name, "GNU C++") == 0)
/* For a virtual base, print the (negative) offset within
--- 1577,1591 ----
}
for (i = 0; i < n_baseclasses; i++)
{
! tree binfo = TYPE_BINFO (type);
! tree child = BINFO_BASETYPE (binfo, i);
! tree access = BINFO_BASEACCESS (binfo, i);
!
if (use_gnu_debug_info_extensions)
{
have_used_extensions = 1;
putc (TREE_VIA_VIRTUAL (child) ? '1' : '0', asmfile);
! putc (access == access_public_node ? '2' : '0', asmfile);
CHARS (2);
if (TREE_VIA_VIRTUAL (child) && strcmp (lang_hooks.name, "GNU C++") == 0)
/* For a virtual base, print the (negative) offset within
Index: dwarf2out.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dwarf2out.c,v
retrieving revision 1.397
diff -c -3 -p -r1.397 dwarf2out.c
*** dwarf2out.c 22 Jan 2003 01:02:47 -0000 1.397
--- dwarf2out.c 31 Jan 2003 15:06:44 -0000
*************** static void gen_field_die PARAMS ((tree
*** 3818,3824 ****
static void gen_ptr_to_mbr_type_die PARAMS ((tree, dw_die_ref));
static dw_die_ref gen_compile_unit_die PARAMS ((const char *));
static void gen_string_type_die PARAMS ((tree, dw_die_ref));
! static void gen_inheritance_die PARAMS ((tree, dw_die_ref));
static void gen_member_die PARAMS ((tree, dw_die_ref));
static void gen_struct_or_union_type_die PARAMS ((tree, dw_die_ref));
static void gen_subroutine_type_die PARAMS ((tree, dw_die_ref));
--- 3818,3824 ----
static void gen_ptr_to_mbr_type_die PARAMS ((tree, dw_die_ref));
static dw_die_ref gen_compile_unit_die PARAMS ((const char *));
static void gen_string_type_die PARAMS ((tree, dw_die_ref));
! static void gen_inheritance_die PARAMS ((tree, tree, dw_die_ref));
static void gen_member_die PARAMS ((tree, dw_die_ref));
static void gen_struct_or_union_type_die PARAMS ((tree, dw_die_ref));
static void gen_subroutine_type_die PARAMS ((tree, dw_die_ref));
*************** gen_string_type_die (type, context_die)
*** 11369,11376 ****
/* Generate the DIE for a base class. */
static void
! gen_inheritance_die (binfo, context_die)
! tree binfo;
dw_die_ref context_die;
{
dw_die_ref die = new_die (DW_TAG_inheritance, context_die, binfo);
--- 11369,11376 ----
/* Generate the DIE for a base class. */
static void
! gen_inheritance_die (binfo, access, context_die)
! tree binfo, access;
dw_die_ref context_die;
{
dw_die_ref die = new_die (DW_TAG_inheritance, context_die, binfo);
*************** gen_inheritance_die (binfo, context_die)
*** 11381,11389 ****
if (TREE_VIA_VIRTUAL (binfo))
add_AT_unsigned (die, DW_AT_virtuality, DW_VIRTUALITY_virtual);
! if (TREE_VIA_PUBLIC (binfo))
add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_public);
! else if (TREE_VIA_PROTECTED (binfo))
add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_protected);
}
--- 11381,11389 ----
if (TREE_VIA_VIRTUAL (binfo))
add_AT_unsigned (die, DW_AT_virtuality, DW_VIRTUALITY_virtual);
! if (access == access_public_node)
add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_public);
! else if (access == access_protected_node)
add_AT_unsigned (die, DW_AT_accessibility, DW_ACCESS_protected);
}
*************** gen_member_die (type, context_die)
*** 11395,11400 ****
--- 11395,11401 ----
dw_die_ref context_die;
{
tree member;
+ tree binfo = TYPE_BINFO (type);
dw_die_ref child;
/* If this is not an incomplete type, output descriptions of each of its
*************** gen_member_die (type, context_die)
*** 11410,11423 ****
the TREE node representing the appropriate (containing) type. */
/* First output info about the base classes. */
! if (TYPE_BINFO (type) && TYPE_BINFO_BASETYPES (type))
{
! tree bases = TYPE_BINFO_BASETYPES (type);
int n_bases = TREE_VEC_LENGTH (bases);
int i;
for (i = 0; i < n_bases; i++)
! gen_inheritance_die (TREE_VEC_ELT (bases, i), context_die);
}
/* Now output info about the data members and type members. */
--- 11411,11426 ----
the TREE node representing the appropriate (containing) type. */
/* First output info about the base classes. */
! if (binfo && BINFO_BASETYPES (binfo))
{
! tree bases = BINFO_BASETYPES (binfo);
! tree accesses = BINFO_BASEACCESSES (binfo);
int n_bases = TREE_VEC_LENGTH (bases);
int i;
for (i = 0; i < n_bases; i++)
! gen_inheritance_die (TREE_VEC_ELT (bases, i),
! TREE_VEC_ELT (accesses, i), context_die);
}
/* Now output info about the data members and type members. */
Index: dwarfout.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dwarfout.c,v
retrieving revision 1.119
diff -c -3 -p -r1.119 dwarfout.c
*** dwarfout.c 16 Dec 2002 18:19:23 -0000 1.119
--- dwarfout.c 31 Jan 2003 15:07:00 -0000
*************** static void
*** 4180,4186 ****
output_inheritance_die (arg)
void *arg;
{
! tree binfo = arg;
ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_inheritance);
sibling_attribute ();
--- 4180,4187 ----
output_inheritance_die (arg)
void *arg;
{
! tree binfo = ((tree *)arg)[0];
! tree access = ((tree *)arg)[1];
ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_inheritance);
sibling_attribute ();
*************** output_inheritance_die (arg)
*** 4191,4202 ****
ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_virtual);
ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
}
! if (TREE_VIA_PUBLIC (binfo))
{
ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_public);
ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
}
! else if (TREE_VIA_PROTECTED (binfo))
{
ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_protected);
ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
--- 4192,4203 ----
ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_virtual);
ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
}
! if (access == access_public_node)
{
ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_public);
ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
}
! else if (access == access_protected_node)
{
ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_protected);
ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
*************** output_type (type, containing_scope)
*** 4897,4914 ****
if (COMPLETE_TYPE_P (type))
{
/* First output info about the base classes. */
! if (TYPE_BINFO (type) && TYPE_BINFO_BASETYPES (type))
{
! register tree bases = TYPE_BINFO_BASETYPES (type);
! register int n_bases = TREE_VEC_LENGTH (bases);
register int i;
for (i = 0; i < n_bases; i++)
{
! tree binfo = TREE_VEC_ELT (bases, i);
output_type (BINFO_TYPE (binfo), containing_scope);
! output_die (output_inheritance_die, binfo);
}
}
--- 4898,4921 ----
if (COMPLETE_TYPE_P (type))
{
+ tree binfo = TYPE_BINFO (type);
+
/* First output info about the base classes. */
! if (binfo)
{
! tree bases = BINFO_BASETYPES (binfo);
! tree accesses = BINFO_BASEACCESSES (binfo);
! register int n_bases = BINFO_N_BASETYPES (binfo);
register int i;
for (i = 0; i < n_bases; i++)
{
! tree arg[2];
!
! arg[0] = TREE_VEC_ELT (bases, i);
! arg[1] = TREE_VEC_ELT (accesses, i);
output_type (BINFO_TYPE (binfo), containing_scope);
! output_die (output_inheritance_die, arg);
}
}
Index: tree-dump.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-dump.c,v
retrieving revision 1.9
diff -c -3 -p -r1.9 tree-dump.c
*** tree-dump.c 16 Dec 2002 18:20:00 -0000 1.9
--- tree-dump.c 31 Jan 2003 15:07:08 -0000
*************** dequeue_and_dump (di)
*** 273,290 ****
more informative. */
if (dni->binfo_p)
{
! if (TREE_VIA_PUBLIC (t))
! dump_string (di, "pub");
! else if (TREE_VIA_PROTECTED (t))
! dump_string (di, "prot");
! else if (TREE_VIA_PRIVATE (t))
! dump_string (di, "priv");
if (TREE_VIA_VIRTUAL (t))
dump_string (di, "virt");
! dump_child ("type", BINFO_TYPE (t));
! dump_child ("base", BINFO_BASETYPES (t));
goto done;
}
--- 273,301 ----
more informative. */
if (dni->binfo_p)
{
! unsigned ix;
! tree bases = BINFO_BASETYPES (t);
! unsigned n_bases = bases ? TREE_VEC_LENGTH (bases): 0;
!
! dump_child ("type", BINFO_TYPE (t));
!
if (TREE_VIA_VIRTUAL (t))
dump_string (di, "virt");
! dump_int (di, "bases", n_bases);
! for (ix = 0; ix != n_bases; ix++)
! {
! static const char *const accesses[] =
! {
! NULL, "pub", "prot", "priv"
! };
! tree base = TREE_VEC_ELT (bases, ix);
! tree access = TREE_VEC_ELT (BINFO_BASEACCESSES (t), ix);
+ dump_string (di, accesses[TREE_INT_CST_LOW (access)]);
+ queue_and_dump_index (di, "binf", base, DUMP_BINFO);
+ }
+
goto done;
}
Index: tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.c,v
retrieving revision 1.288
diff -c -3 -p -r1.288 tree.c
*** tree.c 10 Jan 2003 02:22:04 -0000 1.288
--- tree.c 31 Jan 2003 15:07:16 -0000
*************** build_common_tree_nodes_2 (short_double)
*** 4685,4690 ****
--- 4685,4694 ----
bitsize_one_node = bitsize_int (1);
bitsize_unit_node = bitsize_int (BITS_PER_UNIT);
+ access_public_node = build_int_2 (1, 0);
+ access_protected_node = build_int_2 (2, 0);
+ access_private_node = build_int_2 (3, 0);
+
void_type_node = make_node (VOID_TYPE);
layout_type (void_type_node);
Index: tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.379
diff -c -3 -p -r1.379 tree.h
*** tree.h 31 Jan 2003 14:46:47 -0000 1.379
--- tree.h 31 Jan 2003 15:07:24 -0000
*************** struct tree_common GTY(())
*** 192,206 ****
INTEGER_CST, REAL_CST, COMPLEX_CST, VECTOR_CST
TREE_PUBLIC in
VAR_DECL or FUNCTION_DECL or IDENTIFIER_NODE
- TREE_VIA_PUBLIC in
- TREE_LIST or TREE_VEC
EXPR_WFL_EMIT_LINE_NOTE in
EXPR_WITH_FILE_LOCATION
private_flag:
- TREE_VIA_PRIVATE in
- TREE_LIST or TREE_VEC
TREE_PRIVATE in
..._DECL
CALL_EXPR_HAS_RETURN_SLOT_ADDR in
--- 192,202 ----
*************** struct tree_common GTY(())
*** 208,216 ****
protected_flag:
- TREE_VIA_PROTECTED in
- TREE_LIST
- TREE_VEC
TREE_PROTECTED in
BLOCK
..._DECL
--- 204,209 ----
*************** extern void tree_vec_elt_check_failed PA
*** 565,584 ****
for this name in an inner scope. */
#define TREE_PUBLIC(NODE) ((NODE)->common.public_flag)
- /* Nonzero for TREE_LIST or TREE_VEC node means that the path to the
- base class is via a `public' declaration, which preserves public
- fields from the base class as public. */
- #define TREE_VIA_PUBLIC(NODE) ((NODE)->common.public_flag)
-
- /* Ditto, for `private' declarations. */
- #define TREE_VIA_PRIVATE(NODE) ((NODE)->common.private_flag)
-
- /* Nonzero for TREE_LIST or TREE_VEC node means that the path to the
- base class is via a `protected' declaration, which preserves
- protected fields from the base class as protected.
- OVERLOADED. */
- #define TREE_VIA_PROTECTED(NODE) ((NODE)->common.protected_flag)
-
/* In any expression, nonzero means it has side effects or reevaluation
of the whole expression could produce a different value.
This is set if any subexpression is a function call, a side effect
--- 558,563 ----
*************** struct tree_type GTY(())
*** 1362,1368 ****
vtable where the offset to the virtual base can be found. */
#define BINFO_VPTR_FIELD(NODE) TREE_VEC_ELT (NODE, 5)
! #define BINFO_ELTS 6
/* Slot used to build a chain that represents a use of inheritance.
For example, if X is derived from Y, and Y is derived from Z,
--- 1341,1355 ----
vtable where the offset to the virtual base can be found. */
#define BINFO_VPTR_FIELD(NODE) TREE_VEC_ELT (NODE, 5)
! /* Indicates the accesses this binfo has to its bases. The values are
! access_public_node, access_protected_node or access_private_node. */
! #define BINFO_BASEACCESSES(NODE) TREE_VEC_ELT ((NODE), 6)
! #define BINFO_BASEACCESS(NODE,N) TREE_VEC_ELT (BINFO_BASEACCESSES(NODE), (N))
!
! /* Number of language independent elements in a binfo. Languages may
! add additional trailing elements. */
!
! #define BINFO_ELTS 7
/* Slot used to build a chain that represents a use of inheritance.
For example, if X is derived from Y, and Y is derived from Z,
*************** enum tree_index
*** 1959,1964 ****
--- 1946,1955 ----
TI_BITSIZE_ONE,
TI_BITSIZE_UNIT,
+ TI_ACCESS_PUBLIC,
+ TI_ACCESS_PROTECTED,
+ TI_ACCESS_PRIVATE,
+
TI_COMPLEX_INTEGER_TYPE,
TI_COMPLEX_FLOAT_TYPE,
TI_COMPLEX_DOUBLE_TYPE,
*************** extern GTY(()) tree global_trees[TI_MAX]
*** 2032,2037 ****
--- 2023,2033 ----
#define bitsize_zero_node global_trees[TI_BITSIZE_ZERO]
#define bitsize_one_node global_trees[TI_BITSIZE_ONE]
#define bitsize_unit_node global_trees[TI_BITSIZE_UNIT]
+
+ /* Base access nodes. These are shared int_cst nodes, starting at one. */
+ #define access_public_node global_trees[TI_ACCESS_PUBLIC]
+ #define access_protected_node global_trees[TI_ACCESS_PROTECTED]
+ #define access_private_node global_trees[TI_ACCESS_PRIVATE]
#define null_pointer_node global_trees[TI_NULL_POINTER]
Index: cp/class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/class.c,v
retrieving revision 1.518
diff -c -3 -p -r1.518 class.c
*** cp/class.c 30 Jan 2003 16:02:54 -0000 1.518
--- cp/class.c 31 Jan 2003 15:08:31 -0000
*************** static void build_vtt (tree);
*** 197,203 ****
static tree binfo_ctor_vtable (tree);
static tree *build_vtt_inits (tree, tree, tree *, tree *);
static tree dfs_build_secondary_vptr_vtt_inits (tree, void *);
! static tree dfs_ctor_vtable_bases_queue_p (tree, void *data);
static tree dfs_fixup_binfo_vtbls (tree, void *);
static tree get_original_base (tree, tree);
static tree dfs_get_primary_binfo (tree, void*);
--- 197,203 ----
static tree binfo_ctor_vtable (tree);
static tree *build_vtt_inits (tree, tree, tree *, tree *);
static tree dfs_build_secondary_vptr_vtt_inits (tree, void *);
! static tree dfs_ctor_vtable_bases_queue_p (tree, tree, void *data);
static tree dfs_fixup_binfo_vtbls (tree, void *);
static tree get_original_base (tree, tree);
static tree dfs_get_primary_binfo (tree, void*);
*************** maybe_warn_about_overly_private_class (t
*** 1802,1811 ****
issues error messages specifically referring to
constructors/destructors.) */
int i;
! tree binfos = BINFO_BASETYPES (TYPE_BINFO (t));
! for (i = 0; i < CLASSTYPE_N_BASECLASSES (t); i++)
! if (TREE_VIA_PUBLIC (TREE_VEC_ELT (binfos, i))
! || TREE_VIA_PROTECTED (TREE_VEC_ELT (binfos, i)))
{
has_nonprivate_method = 1;
break;
--- 1802,1811 ----
issues error messages specifically referring to
constructors/destructors.) */
int i;
! tree binfo = TYPE_BINFO (t);
!
! for (i = 0; i < BINFO_N_BASETYPES (binfo); i++)
! if (BINFO_BASEACCESS (binfo, i) != access_private_node)
{
has_nonprivate_method = 1;
break;
*************** init_class_processing (void)
*** 5716,5730 ****
* sizeof (struct class_stack_node));
VARRAY_TREE_INIT (local_classes, 8, "local_classes");
- access_default_node = build_int_2 (0, 0);
- access_public_node = build_int_2 (ak_public, 0);
- access_protected_node = build_int_2 (ak_protected, 0);
- access_private_node = build_int_2 (ak_private, 0);
- access_default_virtual_node = build_int_2 (4, 0);
- access_public_virtual_node = build_int_2 (4 | ak_public, 0);
- access_protected_virtual_node = build_int_2 (4 | ak_protected, 0);
- access_private_virtual_node = build_int_2 (4 | ak_private, 0);
-
ridpointers[(int) RID_PUBLIC] = access_public_node;
ridpointers[(int) RID_PRIVATE] = access_private_node;
ridpointers[(int) RID_PROTECTED] = access_protected_node;
--- 5716,5721 ----
*************** dfs_build_secondary_vptr_vtt_inits (tree
*** 7414,7420 ****
hierarchy. */
static tree
! dfs_ctor_vtable_bases_queue_p (tree binfo, void* data)
{
if (TREE_VIA_VIRTUAL (binfo))
/* Get the shared version. */
--- 7405,7412 ----
hierarchy. */
static tree
! dfs_ctor_vtable_bases_queue_p (tree binfo, tree access ATTRIBUTE_UNUSED,
! void* data)
{
if (TREE_VIA_VIRTUAL (binfo))
/* Get the shared version. */
Index: cp/cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.809
diff -c -3 -p -r1.809 cp-tree.h
*** cp/cp-tree.h 31 Jan 2003 14:46:52 -0000 1.809
--- cp/cp-tree.h 31 Jan 2003 15:08:44 -0000
*************** enum cp_tree_index
*** 595,609 ****
CPTI_GLOBAL_DELETE_FNDECL,
CPTI_AGGR_TAG,
- CPTI_ACCESS_DEFAULT,
- CPTI_ACCESS_PUBLIC,
- CPTI_ACCESS_PROTECTED,
- CPTI_ACCESS_PRIVATE,
- CPTI_ACCESS_DEFAULT_VIRTUAL,
- CPTI_ACCESS_PUBLIC_VIRTUAL,
- CPTI_ACCESS_PROTECTED_VIRTUAL,
- CPTI_ACCESS_PRIVATE_VIRTUAL,
-
CPTI_CTOR_IDENTIFIER,
CPTI_COMPLETE_CTOR_IDENTIFIER,
CPTI_BASE_CTOR_IDENTIFIER,
--- 595,600 ----
*************** extern GTY(()) tree cp_global_trees[CPTI
*** 685,703 ****
#define global_delete_fndecl cp_global_trees[CPTI_GLOBAL_DELETE_FNDECL]
#define current_aggr cp_global_trees[CPTI_AGGR_TAG]
- /* Define the sets of attributes that member functions and baseclasses
- can have. These are sensible combinations of {public,private,protected}
- cross {virtual,non-virtual}. */
-
- #define access_default_node cp_global_trees[CPTI_ACCESS_DEFAULT]
- #define access_public_node cp_global_trees[CPTI_ACCESS_PUBLIC]
- #define access_protected_node cp_global_trees[CPTI_ACCESS_PROTECTED]
- #define access_private_node cp_global_trees[CPTI_ACCESS_PRIVATE]
- #define access_default_virtual_node cp_global_trees[CPTI_ACCESS_DEFAULT_VIRTUAL]
- #define access_public_virtual_node cp_global_trees[CPTI_ACCESS_PUBLIC_VIRTUAL]
- #define access_protected_virtual_node cp_global_trees[CPTI_ACCESS_PROTECTED_VIRTUAL]
- #define access_private_virtual_node cp_global_trees[CPTI_ACCESS_PRIVATE_VIRTUAL]
-
/* We cache these tree nodes so as to call get_identifier less
frequently. */
--- 676,681 ----
*************** typedef enum tmpl_spec_kind {
*** 3080,3086 ****
/* The various kinds of access. BINFO_ACCESS depends on these being
two bit quantities. The numerical values are important; they are
used to initialize RTTI data structures, so changing them changes
! the ABI. */
typedef enum access_kind {
ak_none = 0, /* Inaccessible. */
ak_public = 1, /* Accessible, as a `public' thing. */
--- 3058,3065 ----
/* The various kinds of access. BINFO_ACCESS depends on these being
two bit quantities. The numerical values are important; they are
used to initialize RTTI data structures, so changing them changes
! the ABI. These do not have to match the values of the
! access_*_nodes in tree.h, but they may as well do so. */
typedef enum access_kind {
ak_none = 0, /* Inaccessible. */
ak_public = 1, /* Accessible, as a `public' thing. */
*************** extern tree binfo_from_vbase (tree);
*** 4146,4164 ****
extern tree look_for_overrides_here (tree, tree);
extern int check_final_overrider (tree, tree);
extern tree dfs_walk (tree,
! tree (*) (tree, void *),
! tree (*) (tree, void *),
! void *);
extern tree dfs_walk_real (tree,
! tree (*) (tree, void *),
! tree (*) (tree, void *),
! tree (*) (tree, void *),
! void *);
extern tree dfs_unmark (tree, void *);
! extern tree markedp (tree, void *);
! extern tree unmarkedp (tree, void *);
! extern tree dfs_unmarked_real_bases_queue_p (tree, void *);
! extern tree dfs_marked_real_bases_queue_p (tree, void *);
extern tree dfs_skip_vbases (tree, void *);
extern tree marked_vtable_pathp (tree, void *);
extern tree unmarked_vtable_pathp (tree, void *);
--- 4125,4143 ----
extern tree look_for_overrides_here (tree, tree);
extern int check_final_overrider (tree, tree);
extern tree dfs_walk (tree,
! tree (*) (tree, void *),
! tree (*) (tree, tree, void *),
! void *);
extern tree dfs_walk_real (tree,
! tree (*) (tree, void *),
! tree (*) (tree, void *),
! tree (*) (tree, tree, void *),
! void *);
extern tree dfs_unmark (tree, void *);
! extern tree markedp (tree, tree, void *);
! extern tree unmarkedp (tree, tree, void *);
! extern tree dfs_unmarked_real_bases_queue_p (tree, tree, void *);
! extern tree dfs_marked_real_bases_queue_p (tree, tree, void *);
extern tree dfs_skip_vbases (tree, void *);
extern tree marked_vtable_pathp (tree, void *);
extern tree unmarked_vtable_pathp (tree, void *);
*************** extern void finish_default_args
*** 4249,4255 ****
extern tree finish_member_class_template (tree);
extern void finish_template_decl (tree);
extern tree finish_template_type (tree, tree, int);
! extern tree finish_base_specifier (tree, tree);
extern void finish_member_declaration (tree);
extern void check_multiple_declarators (void);
extern tree finish_typeof (tree);
--- 4228,4234 ----
extern tree finish_member_class_template (tree);
extern void finish_template_decl (tree);
extern tree finish_template_type (tree, tree, int);
! extern tree finish_base_specifier (tree, tree, bool);
extern void finish_member_declaration (tree);
extern void check_multiple_declarators (void);
extern tree finish_typeof (tree);
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.993
diff -c -3 -p -r1.993 decl.c
*** cp/decl.c 30 Jan 2003 16:02:56 -0000 1.993
--- cp/decl.c 31 Jan 2003 15:09:14 -0000
*************** xref_tag_from_type (tree old, tree id, i
*** 12785,12801 ****
}
/* REF is a type (named NAME), for which we have just seen some
! baseclasses. BINFO is a list of those baseclasses; the
TREE_PURPOSE is an access_* node, and the TREE_VALUE is the type of
! the base-class. CODE_TYPE_NODE indicates whether REF is a class,
struct, or union. */
void
! xref_basetypes (tree ref, tree binfo)
{
/* In the declaration `A : X, Y, ... Z' we mark all the types
(A, X, Y, ..., Z) so we can check for duplicates. */
! tree binfos;
tree *basep;
int i;
--- 12785,12803 ----
}
/* REF is a type (named NAME), for which we have just seen some
! baseclasses. BASE_LIST is a list of those baseclasses; the
TREE_PURPOSE is an access_* node, and the TREE_VALUE is the type of
! the base-class. TREE_VIA_VIRTUAL indicates virtual
! inheritance. CODE_TYPE_NODE indicates whether REF is a class,
struct, or union. */
void
! xref_basetypes (tree ref, tree base_list)
{
/* In the declaration `A : X, Y, ... Z' we mark all the types
(A, X, Y, ..., Z) so we can check for duplicates. */
! tree binfos, accesses;
! tree binfo;
tree *basep;
int i;
*************** xref_basetypes (tree ref, tree binfo)
*** 12813,12819 ****
instantiated. This ensures that if we call ourselves recursively
we do not get confused about which classes are marked and which
are not. */
! basep = &binfo;
while (*basep)
{
tree basetype = TREE_VALUE (*basep);
--- 12815,12821 ----
instantiated. This ensures that if we call ourselves recursively
we do not get confused about which classes are marked and which
are not. */
! basep = &base_list;
while (*basep)
{
tree basetype = TREE_VALUE (*basep);
*************** xref_basetypes (tree ref, tree binfo)
*** 12826,12854 ****
}
SET_CLASSTYPE_MARKED (ref);
! BINFO_BASETYPES (TYPE_BINFO (ref)) = binfos
! = make_tree_vec (list_length (binfo));
!
! for (i = 0; binfo; binfo = TREE_CHAIN (binfo))
{
/* The base of a derived struct is public by default. */
! int via_public
! = (TREE_PURPOSE (binfo) == access_public_node
! || TREE_PURPOSE (binfo) == access_public_virtual_node
! || (tag_code != class_type
! && (TREE_PURPOSE (binfo) == access_default_node
! || TREE_PURPOSE (binfo) == access_default_virtual_node)));
! int via_protected
! = (TREE_PURPOSE (binfo) == access_protected_node
! || TREE_PURPOSE (binfo) == access_protected_virtual_node);
! int via_virtual
! = (TREE_PURPOSE (binfo) == access_private_virtual_node
! || TREE_PURPOSE (binfo) == access_protected_virtual_node
! || TREE_PURPOSE (binfo) == access_public_virtual_node
! || TREE_PURPOSE (binfo) == access_default_virtual_node);
! tree basetype = TREE_VALUE (binfo);
tree base_binfo;
if (basetype && TREE_CODE (basetype) == TYPE_DECL)
basetype = TREE_TYPE (basetype);
if (!basetype
--- 12828,12853 ----
}
SET_CLASSTYPE_MARKED (ref);
! i = list_length (base_list);
! binfo = TYPE_BINFO (ref);
! if (i)
! {
! BINFO_BASETYPES (binfo) = binfos = make_tree_vec (i);
! BINFO_BASEACCESSES (binfo) = accesses = make_tree_vec (i);
! }
!
! for (i = 0; base_list; base_list = TREE_CHAIN (base_list))
{
/* The base of a derived struct is public by default. */
! tree access = TREE_PURPOSE (base_list);
! int via_virtual = TREE_VIA_VIRTUAL (base_list);
! tree basetype = TREE_VALUE (base_list);
tree base_binfo;
+ if (!access)
+ access = (tag_code == class_type
+ ? access_private_node : access_public_node);
+
if (basetype && TREE_CODE (basetype) == TYPE_DECL)
basetype = TREE_TYPE (basetype);
if (!basetype
*************** xref_basetypes (tree ref, tree binfo)
*** 12858,12864 ****
&& TREE_CODE (basetype) != BOUND_TEMPLATE_TEMPLATE_PARM))
{
error ("base type `%T' fails to be a struct or class type",
! TREE_VALUE (binfo));
continue;
}
--- 12857,12863 ----
&& TREE_CODE (basetype) != BOUND_TEMPLATE_TEMPLATE_PARM))
{
error ("base type `%T' fails to be a struct or class type",
! basetype);
continue;
}
*************** xref_basetypes (tree ref, tree binfo)
*** 12891,12898 ****
? TYPE_BINFO_VIRTUALS (basetype) : NULL_TREE);
TREE_VEC_ELT (binfos, i) = base_binfo;
! TREE_VIA_PUBLIC (base_binfo) = via_public;
! TREE_VIA_PROTECTED (base_binfo) = via_protected;
TREE_VIA_VIRTUAL (base_binfo) = via_virtual;
BINFO_INHERITANCE_CHAIN (base_binfo) = TYPE_BINFO (ref);
--- 12890,12896 ----
? TYPE_BINFO_VIRTUALS (basetype) : NULL_TREE);
TREE_VEC_ELT (binfos, i) = base_binfo;
! TREE_VEC_ELT (accesses, i) = access;
TREE_VIA_VIRTUAL (base_binfo) = via_virtual;
BINFO_INHERITANCE_CHAIN (base_binfo) = TYPE_BINFO (ref);
*************** xref_basetypes (tree ref, tree binfo)
*** 12932,12940 ****
i += 1;
}
if (i)
! TREE_VEC_LENGTH (binfos) = i;
else
! BINFO_BASETYPES (TYPE_BINFO (ref)) = NULL_TREE;
if (i > 1)
{
--- 12930,12938 ----
i += 1;
}
if (i)
! TREE_VEC_LENGTH (accesses) = TREE_VEC_LENGTH (binfos) = i;
else
! BINFO_BASEACCESSES (binfo) = BINFO_BASETYPES (binfo) = NULL_TREE;
if (i > 1)
{
Index: cp/parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.42
diff -c -3 -p -r1.42 parser.c
*** cp/parser.c 30 Jan 2003 07:23:59 -0000 1.42
--- cp/parser.c 31 Jan 2003 15:09:46 -0000
*************** cp_parser_base_clause (cp_parser* parser
*** 12413,12434 ****
static tree
cp_parser_base_specifier (cp_parser* parser)
{
- static const tree *const access_nodes[][2] =
- {
- /* This ordering must match the access_kind enumeration. */
- {&access_default_node, &access_default_virtual_node},
- {&access_public_node, &access_public_virtual_node},
- {&access_protected_node, &access_protected_virtual_node},
- {&access_private_node, &access_private_virtual_node}
- };
cp_token *token;
bool done = false;
bool virtual_p = false;
bool duplicate_virtual_error_issued_p = false;
bool duplicate_access_error_issued_p = false;
bool class_scope_p, template_p;
! access_kind access = ak_none;
! tree access_node;
tree type;
/* Process the optional `virtual' and `access-specifier'. */
--- 12413,12425 ----
static tree
cp_parser_base_specifier (cp_parser* parser)
{
cp_token *token;
bool done = false;
bool virtual_p = false;
bool duplicate_virtual_error_issued_p = false;
bool duplicate_access_error_issued_p = false;
bool class_scope_p, template_p;
! tree access = NULL_TREE;
tree type;
/* Process the optional `virtual' and `access-specifier'. */
*************** cp_parser_base_specifier (cp_parser* par
*** 12460,12475 ****
case RID_PRIVATE:
/* If more than one access specifier appears, issue an
error. */
! if (access != ak_none && !duplicate_access_error_issued_p)
{
cp_parser_error (parser,
"more than one access specifier in base-specified");
duplicate_access_error_issued_p = true;
}
! access = ((access_kind)
! tree_low_cst (ridpointers[(int) token->keyword],
! /*pos=*/1));
/* Consume the access-specifier. */
cp_lexer_consume_token (parser->lexer);
--- 12451,12464 ----
case RID_PRIVATE:
/* If more than one access specifier appears, issue an
error. */
! if (access && !duplicate_access_error_issued_p)
{
cp_parser_error (parser,
"more than one access specifier in base-specified");
duplicate_access_error_issued_p = true;
}
! access = ridpointers[(int) token->keyword];
/* Consume the access-specifier. */
cp_lexer_consume_token (parser->lexer);
*************** cp_parser_base_specifier (cp_parser* par
*** 12482,12490 ****
}
}
- /* Map `virtual_p' and `access' onto one of the access tree-nodes. */
- access_node = *access_nodes[access][virtual_p];
-
/* Look for the optional `::' operator. */
cp_parser_global_scope_opt (parser, /*current_scope_valid_p=*/false);
/* Look for the nested-name-specifier. The simplest way to
--- 12471,12476 ----
*************** cp_parser_base_specifier (cp_parser* par
*** 12520,12526 ****
if (type == error_mark_node)
return error_mark_node;
! return finish_base_specifier (access_node, TREE_TYPE (type));
}
/* Exception handling [gram.exception] */
--- 12506,12512 ----
if (type == error_mark_node)
return error_mark_node;
! return finish_base_specifier (TREE_TYPE (type), access, virtual_p);
}
/* Exception handling [gram.exception] */
Index: cp/pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.657
diff -c -3 -p -r1.657 pt.c
*** cp/pt.c 30 Jan 2003 16:02:56 -0000 1.657
--- cp/pt.c 31 Jan 2003 15:10:09 -0000
*************** instantiate_class_template (type)
*** 5144,5150 ****
{
tree template, args, pattern, t, member;
tree typedecl;
!
if (type == error_mark_node)
return error_mark_node;
--- 5144,5151 ----
{
tree template, args, pattern, t, member;
tree typedecl;
! tree pbinfo;
!
if (type == error_mark_node)
return error_mark_node;
*************** instantiate_class_template (type)
*** 5275,5284 ****
if (ANON_AGGR_TYPE_P (pattern))
SET_ANON_AGGR_TYPE_P (type);
! if (TYPE_BINFO_BASETYPES (pattern))
{
tree base_list = NULL_TREE;
! tree pbases = TYPE_BINFO_BASETYPES (pattern);
int i;
/* Substitute into each of the bases to determine the actual
--- 5276,5288 ----
if (ANON_AGGR_TYPE_P (pattern))
SET_ANON_AGGR_TYPE_P (type);
! pbinfo = TYPE_BINFO (pattern);
!
! if (BINFO_BASETYPES (pbinfo))
{
tree base_list = NULL_TREE;
! tree pbases = BINFO_BASETYPES (pbinfo);
! tree paccesses = BINFO_BASEACCESSES (pbinfo);
int i;
/* Substitute into each of the bases to determine the actual
*************** instantiate_class_template (type)
*** 5290,5322 ****
tree pbase;
pbase = TREE_VEC_ELT (pbases, i);
/* Substitute to figure out the base class. */
base = tsubst (BINFO_TYPE (pbase), args, tf_error, NULL_TREE);
if (base == error_mark_node)
continue;
!
! /* Calculate the correct access node. */
! if (TREE_VIA_VIRTUAL (pbase))
! {
! if (TREE_VIA_PUBLIC (pbase))
! access = access_public_virtual_node;
! else if (TREE_VIA_PROTECTED (pbase))
! access = access_protected_virtual_node;
! else
! access = access_private_virtual_node;
! }
! else
! {
! if (TREE_VIA_PUBLIC (pbase))
! access = access_public_node;
! else if (TREE_VIA_PROTECTED (pbase))
! access = access_protected_node;
! else
! access = access_private_node;
! }
!
base_list = tree_cons (access, base, base_list);
}
/* The list is now in reverse order; correct that. */
--- 5294,5308 ----
tree pbase;
pbase = TREE_VEC_ELT (pbases, i);
+ access = TREE_VEC_ELT (paccesses, i);
/* Substitute to figure out the base class. */
base = tsubst (BINFO_TYPE (pbase), args, tf_error, NULL_TREE);
if (base == error_mark_node)
continue;
!
base_list = tree_cons (access, base, base_list);
+ TREE_VIA_VIRTUAL (base_list) = TREE_VIA_VIRTUAL (pbase);
}
/* The list is now in reverse order; correct that. */
Index: cp/rtti.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/rtti.c,v
retrieving revision 1.154
diff -c -3 -p -r1.154 rtti.c
*** cp/rtti.c 17 Jan 2003 20:14:44 -0000 1.154
--- cp/rtti.c 31 Jan 2003 15:10:12 -0000
*************** get_pseudo_ti_init (tree type, tree var_
*** 1039,1044 ****
--- 1039,1045 ----
tree binfo = TYPE_BINFO (type);
int nbases = BINFO_N_BASETYPES (binfo);
tree base_binfos = BINFO_BASETYPES (binfo);
+ tree base_accesses = BINFO_BASEACCESSES (binfo);
tree base_inits = NULL_TREE;
int ix;
*************** get_pseudo_ti_init (tree type, tree var_
*** 1051,1057 ****
tree tinfo;
tree offset;
! if (TREE_PUBLIC (base_binfo))
flags |= 2;
tinfo = get_tinfo_ptr (BINFO_TYPE (base_binfo));
if (TREE_VIA_VIRTUAL (base_binfo))
--- 1052,1058 ----
tree tinfo;
tree offset;
! if (TREE_VEC_ELT (base_accesses, ix) == access_public_node)
flags |= 2;
tinfo = get_tinfo_ptr (BINFO_TYPE (base_binfo));
if (TREE_VIA_VIRTUAL (base_binfo))
*************** get_pseudo_ti_desc (tree type)
*** 1187,1198 ****
return class_desc_type_node;
else
{
! tree base_binfo =
! TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (type)), 0);
! int num_bases = BINFO_N_BASETYPES (TYPE_BINFO (type));
if (num_bases == 1
! && TREE_PUBLIC (base_binfo)
&& !TREE_VIA_VIRTUAL (base_binfo)
&& integer_zerop (BINFO_OFFSET (base_binfo)))
/* single non-virtual public. */
--- 1188,1201 ----
return class_desc_type_node;
else
{
! tree binfo = TYPE_BINFO (type);
! tree base_binfos = BINFO_BASETYPES (binfo);
! tree base_accesses = BINFO_BASEACCESSES (binfo);
! tree base_binfo = TREE_VEC_ELT (base_binfos, 0);
! int num_bases = TREE_VEC_LENGTH (base_binfos);
if (num_bases == 1
! && TREE_VEC_ELT (base_accesses, 0) == access_public_node
&& !TREE_VIA_VIRTUAL (base_binfo)
&& integer_zerop (BINFO_OFFSET (base_binfo)))
/* single non-virtual public. */
Index: cp/search.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/search.c,v
retrieving revision 1.251
diff -c -3 -p -r1.251 search.c
*** cp/search.c 30 Jan 2003 16:02:57 -0000 1.251
--- cp/search.c 31 Jan 2003 15:10:18 -0000
*************** static tree lookup_field_1 PARAMS ((tree
*** 85,97 ****
static int is_subobject_of_p PARAMS ((tree, tree, tree));
static int is_subobject_of_p_1 PARAMS ((tree, tree, tree));
static tree dfs_check_overlap PARAMS ((tree, void *));
! static tree dfs_no_overlap_yet PARAMS ((tree, void *));
static base_kind lookup_base_r
PARAMS ((tree, tree, base_access, int, int, int, tree *));
static int dynamic_cast_base_recurse PARAMS ((tree, tree, int, tree *));
! static tree marked_pushdecls_p PARAMS ((tree, void *));
! static tree unmarked_pushdecls_p PARAMS ((tree, void *));
! static tree dfs_debug_unmarkedp PARAMS ((tree, void *));
static tree dfs_debug_mark PARAMS ((tree, void *));
static tree dfs_get_vbase_types PARAMS ((tree, void *));
static tree dfs_push_type_decls PARAMS ((tree, void *));
--- 85,97 ----
static int is_subobject_of_p PARAMS ((tree, tree, tree));
static int is_subobject_of_p_1 PARAMS ((tree, tree, tree));
static tree dfs_check_overlap PARAMS ((tree, void *));
! static tree dfs_no_overlap_yet PARAMS ((tree, tree, void *));
static base_kind lookup_base_r
PARAMS ((tree, tree, base_access, int, int, int, tree *));
static int dynamic_cast_base_recurse PARAMS ((tree, tree, int, tree *));
! static tree marked_pushdecls_p PARAMS ((tree, tree, void *));
! static tree unmarked_pushdecls_p PARAMS ((tree, tree, void *));
! static tree dfs_debug_unmarkedp PARAMS ((tree, tree, void *));
static tree dfs_debug_mark PARAMS ((tree, void *));
static tree dfs_get_vbase_types PARAMS ((tree, void *));
static tree dfs_push_type_decls PARAMS ((tree, void *));
*************** static struct search_level *push_search_
*** 104,123 ****
static struct search_level *pop_search_level
PARAMS ((struct stack_level *));
static tree bfs_walk
! PARAMS ((tree, tree (*) (tree, void *), tree (*) (tree, void *),
void *));
! static tree lookup_field_queue_p PARAMS ((tree, void *));
static int shared_member_p PARAMS ((tree));
static tree lookup_field_r PARAMS ((tree, void *));
static tree canonical_binfo PARAMS ((tree));
! static tree shared_marked_p PARAMS ((tree, void *));
! static tree shared_unmarked_p PARAMS ((tree, void *));
static int dependent_base_p PARAMS ((tree));
! static tree dfs_accessible_queue_p PARAMS ((tree, void *));
static tree dfs_accessible_p PARAMS ((tree, void *));
static tree dfs_access_in_type PARAMS ((tree, void *));
static access_kind access_in_type PARAMS ((tree, tree));
! static tree dfs_canonical_queue PARAMS ((tree, void *));
static tree dfs_assert_unmarked_p PARAMS ((tree, void *));
static void assert_canonical_unmarked PARAMS ((tree));
static int protected_accessible_p PARAMS ((tree, tree, tree));
--- 104,123 ----
static struct search_level *pop_search_level
PARAMS ((struct stack_level *));
static tree bfs_walk
! PARAMS ((tree, tree (*) (tree, void *), tree (*) (tree, tree, void *),
void *));
! static tree lookup_field_queue_p PARAMS ((tree, tree, void *));
static int shared_member_p PARAMS ((tree));
static tree lookup_field_r PARAMS ((tree, void *));
static tree canonical_binfo PARAMS ((tree));
! static tree shared_marked_p PARAMS ((tree, tree, void *));
! static tree shared_unmarked_p PARAMS ((tree, tree, void *));
static int dependent_base_p PARAMS ((tree));
! static tree dfs_accessible_queue_p PARAMS ((tree, tree, void *));
static tree dfs_accessible_p PARAMS ((tree, void *));
static tree dfs_access_in_type PARAMS ((tree, void *));
static access_kind access_in_type PARAMS ((tree, tree));
! static tree dfs_canonical_queue PARAMS ((tree, tree, void *));
static tree dfs_assert_unmarked_p PARAMS ((tree, void *));
static void assert_canonical_unmarked PARAMS ((tree));
static int protected_accessible_p PARAMS ((tree, tree, tree));
*************** lookup_base_r (binfo, base, access, with
*** 190,196 ****
tree *binfo_ptr;
{
int i;
! tree bases;
base_kind found = bk_not_base;
if (access == ba_check
--- 190,196 ----
tree *binfo_ptr;
{
int i;
! tree bases, accesses;
base_kind found = bk_not_base;
if (access == ba_check
*************** lookup_base_r (binfo, base, access, with
*** 229,251 ****
}
bases = BINFO_BASETYPES (binfo);
if (!bases)
return bk_not_base;
for (i = TREE_VEC_LENGTH (bases); i--;)
{
tree base_binfo = TREE_VEC_ELT (bases, i);
int this_non_public = is_non_public;
int this_virtual = is_virtual;
base_kind bk;
if (access <= ba_ignore)
; /* no change */
! else if (TREE_VIA_PUBLIC (base_binfo))
; /* no change */
else if (access == ba_not_special)
this_non_public = 1;
! else if (TREE_VIA_PROTECTED (base_binfo) && within_current_scope)
; /* no change */
else if (is_friend (BINFO_TYPE (binfo), current_scope ()))
; /* no change */
--- 229,254 ----
}
bases = BINFO_BASETYPES (binfo);
+ accesses = BINFO_BASEACCESSES (binfo);
if (!bases)
return bk_not_base;
for (i = TREE_VEC_LENGTH (bases); i--;)
{
tree base_binfo = TREE_VEC_ELT (bases, i);
+ tree base_access = TREE_VEC_ELT (accesses, i);
+
int this_non_public = is_non_public;
int this_virtual = is_virtual;
base_kind bk;
if (access <= ba_ignore)
; /* no change */
! else if (base_access == access_public_node)
; /* no change */
else if (access == ba_not_special)
this_non_public = 1;
! else if (base_access == access_protected_node && within_current_scope)
; /* no change */
else if (is_friend (BINFO_TYPE (binfo), current_scope ()))
; /* no change */
*************** dynamic_cast_base_recurse (subtype, binf
*** 378,384 ****
int via_virtual;
tree *offset_ptr;
{
! tree binfos;
int i, n_baselinks;
int worst = -2;
--- 381,387 ----
int via_virtual;
tree *offset_ptr;
{
! tree binfos, accesses;
int i, n_baselinks;
int worst = -2;
*************** dynamic_cast_base_recurse (subtype, binf
*** 394,406 ****
}
binfos = BINFO_BASETYPES (binfo);
n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0;
for (i = 0; i < n_baselinks; i++)
{
tree base_binfo = TREE_VEC_ELT (binfos, i);
int rval;
! if (!TREE_VIA_PUBLIC (base_binfo))
continue;
rval = dynamic_cast_base_recurse
(subtype, base_binfo,
--- 397,411 ----
}
binfos = BINFO_BASETYPES (binfo);
+ accesses = BINFO_BASEACCESSES (binfo);
n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0;
for (i = 0; i < n_baselinks; i++)
{
tree base_binfo = TREE_VEC_ELT (binfos, i);
+ tree base_access = TREE_VEC_ELT (accesses, i);
int rval;
! if (base_access != access_public_node)
continue;
rval = dynamic_cast_base_recurse
(subtype, base_binfo,
*************** canonical_binfo (binfo)
*** 635,642 ****
canonical versions of virtual bases. */
static tree
! dfs_canonical_queue (binfo, data)
tree binfo;
void *data ATTRIBUTE_UNUSED;
{
return canonical_binfo (binfo);
--- 639,647 ----
canonical versions of virtual bases. */
static tree
! dfs_canonical_queue (binfo, access, data)
tree binfo;
+ tree access ATTRIBUTE_UNUSED;
void *data ATTRIBUTE_UNUSED;
{
return canonical_binfo (binfo);
*************** assert_canonical_unmarked (binfo)
*** 667,690 ****
Otherwise, return NULL_TREE. */
static tree
! shared_marked_p (binfo, data)
tree binfo;
void *data;
{
binfo = canonical_binfo (binfo);
! return markedp (binfo, data);
}
/* If BINFO is not marked, return a canonical version of BINFO.
Otherwise, return NULL_TREE. */
static tree
! shared_unmarked_p (binfo, data)
tree binfo;
void *data;
{
binfo = canonical_binfo (binfo);
! return unmarkedp (binfo, data);
}
/* The accessibility routines use BINFO_ACCESS for scratch space
--- 672,697 ----
Otherwise, return NULL_TREE. */
static tree
! shared_marked_p (binfo, access, data)
tree binfo;
+ tree access;
void *data;
{
binfo = canonical_binfo (binfo);
! return markedp (binfo, access, data);
}
/* If BINFO is not marked, return a canonical version of BINFO.
Otherwise, return NULL_TREE. */
static tree
! shared_unmarked_p (binfo, access, data)
tree binfo;
+ tree access;
void *data;
{
binfo = canonical_binfo (binfo);
! return unmarkedp (binfo, access, data);
}
/* The accessibility routines use BINFO_ACCESS for scratch space
*************** dfs_access_in_type (binfo, data)
*** 740,781 ****
{
int i;
int n_baselinks;
! tree binfos;
/* Otherwise, scan our baseclasses, and pick the most favorable
access. */
binfos = BINFO_BASETYPES (binfo);
n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0;
for (i = 0; i < n_baselinks; ++i)
{
tree base_binfo = TREE_VEC_ELT (binfos, i);
! access_kind base_access
= BINFO_ACCESS (canonical_binfo (base_binfo));
! if (base_access == ak_none || base_access == ak_private)
/* If it was not accessible in the base, or only
accessible as a private member, we can't access it
all. */
! base_access = ak_none;
! else if (TREE_VIA_PROTECTED (base_binfo))
! /* Public and protected members in the base are
protected here. */
! base_access = ak_protected;
! else if (!TREE_VIA_PUBLIC (base_binfo))
! /* Public and protected members in the base are
private here. */
! base_access = ak_private;
/* See if the new access, via this base, gives more
access than our previous best access. */
! if (base_access != ak_none
! && (base_access == ak_public
! || (base_access == ak_protected
! && access != ak_public)
! || (base_access == ak_private
! && access == ak_none)))
{
! access = base_access;
/* If the new access is public, we can't do better. */
if (access == ak_public)
--- 747,786 ----
{
int i;
int n_baselinks;
! tree binfos, accesses;
/* Otherwise, scan our baseclasses, and pick the most favorable
access. */
binfos = BINFO_BASETYPES (binfo);
+ accesses = BINFO_BASEACCESSES (binfo);
n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0;
for (i = 0; i < n_baselinks; ++i)
{
tree base_binfo = TREE_VEC_ELT (binfos, i);
! tree base_access = TREE_VEC_ELT (accesses, i);
! access_kind base_access_now
= BINFO_ACCESS (canonical_binfo (base_binfo));
! if (base_access_now == ak_none || base_access_now == ak_private)
/* If it was not accessible in the base, or only
accessible as a private member, we can't access it
all. */
! base_access_now = ak_none;
! else if (base_access == access_protected_node)
! /* Public and protected members in the base become
protected here. */
! base_access_now = ak_protected;
! else if (base_access == access_private_node)
! /* Public and protected members in the base become
private here. */
! base_access_now = ak_private;
/* See if the new access, via this base, gives more
access than our previous best access. */
! if (base_access_now != ak_none
! && (access == ak_none || base_access_now < access))
{
! access = base_access_now;
/* If the new access is public, we can't do better. */
if (access == ak_public)
*************** access_in_type (type, decl)
*** 825,832 ****
/* Called from dfs_accessible_p via dfs_walk. */
static tree
! dfs_accessible_queue_p (binfo, data)
tree binfo;
void *data ATTRIBUTE_UNUSED;
{
if (BINFO_MARKED (binfo))
--- 830,838 ----
/* Called from dfs_accessible_p via dfs_walk. */
static tree
! dfs_accessible_queue_p (binfo, access, data)
tree binfo;
+ tree access;
void *data ATTRIBUTE_UNUSED;
{
if (BINFO_MARKED (binfo))
*************** dfs_accessible_queue_p (binfo, data)
*** 834,840 ****
/* If this class is inherited via private or protected inheritance,
then we can't see it, unless we are a friend of the subclass. */
! if (!TREE_VIA_PUBLIC (binfo)
&& !is_friend (BINFO_TYPE (BINFO_INHERITANCE_CHAIN (binfo)),
current_scope ()))
return NULL_TREE;
--- 840,846 ----
/* If this class is inherited via private or protected inheritance,
then we can't see it, unless we are a friend of the subclass. */
! if (access != access_public_node
&& !is_friend (BINFO_TYPE (BINFO_INHERITANCE_CHAIN (binfo)),
current_scope ()))
return NULL_TREE;
*************** struct lookup_field_info {
*** 1155,1162 ****
lookup_field via breadth_first_search. */
static tree
! lookup_field_queue_p (binfo, data)
tree binfo;
void *data;
{
struct lookup_field_info *lfi = (struct lookup_field_info *) data;
--- 1161,1169 ----
lookup_field via breadth_first_search. */
static tree
! lookup_field_queue_p (binfo, access, data)
tree binfo;
+ tree access ATTRIBUTE_UNUSED;
void *data;
{
struct lookup_field_info *lfi = (struct lookup_field_info *) data;
*************** static tree
*** 1695,1701 ****
bfs_walk (binfo, fn, qfn, data)
tree binfo;
tree (*fn) PARAMS ((tree, void *));
! tree (*qfn) PARAMS ((tree, void *));
void *data;
{
size_t head;
--- 1702,1708 ----
bfs_walk (binfo, fn, qfn, data)
tree binfo;
tree (*fn) PARAMS ((tree, void *));
! tree (*qfn) PARAMS ((tree, tree, void *));
void *data;
{
size_t head;
*************** bfs_walk (binfo, fn, qfn, data)
*** 1717,1723 ****
{
int i;
int n_baselinks;
! tree binfos;
/* Pull the next type out of the queue. */
binfo = VARRAY_TREE (bfs_bases, head);
--- 1724,1730 ----
{
int i;
int n_baselinks;
! tree binfos, accesses;
/* Pull the next type out of the queue. */
binfo = VARRAY_TREE (bfs_bases, head);
*************** bfs_walk (binfo, fn, qfn, data)
*** 1729,1741 ****
/* Queue up the base types. */
binfos = BINFO_BASETYPES (binfo);
n_baselinks = binfos ? TREE_VEC_LENGTH (binfos): 0;
for (i = 0; i < n_baselinks; i++)
{
tree base_binfo = TREE_VEC_ELT (binfos, i);
if (qfn)
! base_binfo = (*qfn) (base_binfo, data);
if (base_binfo)
{
--- 1736,1749 ----
/* Queue up the base types. */
binfos = BINFO_BASETYPES (binfo);
+ accesses = BINFO_BASEACCESSES (binfo);
n_baselinks = binfos ? TREE_VEC_LENGTH (binfos): 0;
for (i = 0; i < n_baselinks; i++)
{
tree base_binfo = TREE_VEC_ELT (binfos, i);
if (qfn)
! base_binfo = (*qfn) (base_binfo, TREE_VEC_ELT (accesses, i), data);
if (base_binfo)
{
*************** dfs_walk_real (binfo, prefn, postfn, qfn
*** 1759,1770 ****
tree binfo;
tree (*prefn) PARAMS ((tree, void *));
tree (*postfn) PARAMS ((tree, void *));
! tree (*qfn) PARAMS ((tree, void *));
void *data;
{
int i;
int n_baselinks;
! tree binfos;
tree rval = NULL_TREE;
/* Call the pre-order walking function. */
--- 1767,1778 ----
tree binfo;
tree (*prefn) PARAMS ((tree, void *));
tree (*postfn) PARAMS ((tree, void *));
! tree (*qfn) PARAMS ((tree, tree, void *));
void *data;
{
int i;
int n_baselinks;
! tree binfos, accesses;
tree rval = NULL_TREE;
/* Call the pre-order walking function. */
*************** dfs_walk_real (binfo, prefn, postfn, qfn
*** 1777,1789 ****
/* Process the basetypes. */
binfos = BINFO_BASETYPES (binfo);
n_baselinks = BINFO_N_BASETYPES (binfo);
for (i = 0; i < n_baselinks; i++)
{
tree base_binfo = TREE_VEC_ELT (binfos, i);
if (qfn)
! base_binfo = (*qfn) (base_binfo, data);
if (base_binfo)
{
--- 1785,1798 ----
/* Process the basetypes. */
binfos = BINFO_BASETYPES (binfo);
+ accesses = BINFO_BASEACCESSES (binfo);
n_baselinks = BINFO_N_BASETYPES (binfo);
for (i = 0; i < n_baselinks; i++)
{
tree base_binfo = TREE_VEC_ELT (binfos, i);
if (qfn)
! base_binfo = (*qfn) (base_binfo, TREE_VEC_ELT (accesses, i), data);
if (base_binfo)
{
*************** tree
*** 1807,1813 ****
dfs_walk (binfo, fn, qfn, data)
tree binfo;
tree (*fn) PARAMS ((tree, void *));
! tree (*qfn) PARAMS ((tree, void *));
void *data;
{
return dfs_walk_real (binfo, 0, fn, qfn, data);
--- 1816,1822 ----
dfs_walk (binfo, fn, qfn, data)
tree binfo;
tree (*fn) PARAMS ((tree, void *));
! tree (*qfn) PARAMS ((tree, tree, void *));
void *data;
{
return dfs_walk_real (binfo, 0, fn, qfn, data);
*************** look_for_overrides_r (type, fndecl)
*** 2025,2032 ****
once. */
tree
! dfs_unmarked_real_bases_queue_p (binfo, data)
tree binfo;
void *data;
{
if (TREE_VIA_VIRTUAL (binfo))
--- 2034,2042 ----
once. */
tree
! dfs_unmarked_real_bases_queue_p (binfo, access, data)
tree binfo;
+ tree access;
void *data;
{
if (TREE_VIA_VIRTUAL (binfo))
*************** dfs_unmarked_real_bases_queue_p (binfo,
*** 2037,2051 ****
type = TREE_PURPOSE (type);
binfo = binfo_for_vbase (BINFO_TYPE (binfo), type);
}
! return unmarkedp (binfo, NULL);
}
/* Like dfs_unmarked_real_bases_queue_p but walks only into things
that are marked, rather than unmarked. */
tree
! dfs_marked_real_bases_queue_p (binfo, data)
tree binfo;
void *data;
{
if (TREE_VIA_VIRTUAL (binfo))
--- 2047,2062 ----
type = TREE_PURPOSE (type);
binfo = binfo_for_vbase (BINFO_TYPE (binfo), type);
}
! return unmarkedp (binfo, access, NULL);
}
/* Like dfs_unmarked_real_bases_queue_p but walks only into things
that are marked, rather than unmarked. */
tree
! dfs_marked_real_bases_queue_p (binfo, access, data)
tree binfo;
+ tree access;
void *data;
{
if (TREE_VIA_VIRTUAL (binfo))
*************** dfs_marked_real_bases_queue_p (binfo, da
*** 2056,2062 ****
type = TREE_PURPOSE (type);
binfo = binfo_for_vbase (BINFO_TYPE (binfo), type);
}
! return markedp (binfo, NULL);
}
/* A queue function that skips all virtual bases (and their
--- 2067,2073 ----
type = TREE_PURPOSE (type);
binfo = binfo_for_vbase (BINFO_TYPE (binfo), type);
}
! return markedp (binfo, access, NULL);
}
/* A queue function that skips all virtual bases (and their
*************** get_pure_virtuals (type)
*** 2148,2163 ****
/* DEPTH-FIRST SEARCH ROUTINES. */
tree
! markedp (binfo, data)
tree binfo;
void *data ATTRIBUTE_UNUSED;
{
return BINFO_MARKED (binfo) ? binfo : NULL_TREE;
}
tree
! unmarkedp (binfo, data)
tree binfo;
void *data ATTRIBUTE_UNUSED;
{
return !BINFO_MARKED (binfo) ? binfo : NULL_TREE;
--- 2159,2176 ----
/* DEPTH-FIRST SEARCH ROUTINES. */
tree
! markedp (binfo, access, data)
tree binfo;
+ tree access ATTRIBUTE_UNUSED;
void *data ATTRIBUTE_UNUSED;
{
return BINFO_MARKED (binfo) ? binfo : NULL_TREE;
}
tree
! unmarkedp (binfo, access, data)
tree binfo;
+ tree access ATTRIBUTE_UNUSED;
void *data ATTRIBUTE_UNUSED;
{
return !BINFO_MARKED (binfo) ? binfo : NULL_TREE;
*************** unmarked_vtable_pathp (binfo, data)
*** 2180,2187 ****
}
static tree
! marked_pushdecls_p (binfo, data)
tree binfo;
void *data ATTRIBUTE_UNUSED;
{
return (CLASS_TYPE_P (BINFO_TYPE (binfo))
--- 2193,2201 ----
}
static tree
! marked_pushdecls_p (binfo, access, data)
tree binfo;
+ tree access ATTRIBUTE_UNUSED;
void *data ATTRIBUTE_UNUSED;
{
return (CLASS_TYPE_P (BINFO_TYPE (binfo))
*************** marked_pushdecls_p (binfo, data)
*** 2190,2197 ****
}
static tree
! unmarked_pushdecls_p (binfo, data)
tree binfo;
void *data ATTRIBUTE_UNUSED;
{
return (CLASS_TYPE_P (BINFO_TYPE (binfo))
--- 2204,2212 ----
}
static tree
! unmarked_pushdecls_p (binfo, access, data)
tree binfo;
+ tree access ATTRIBUTE_UNUSED;
void *data ATTRIBUTE_UNUSED;
{
return (CLASS_TYPE_P (BINFO_TYPE (binfo))
*************** dfs_debug_mark (binfo, data)
*** 2376,2383 ****
info for this base class. */
static tree
! dfs_debug_unmarkedp (binfo, data)
tree binfo;
void *data ATTRIBUTE_UNUSED;
{
return (!CLASSTYPE_DEBUG_REQUESTED (BINFO_TYPE (binfo))
--- 2391,2399 ----
info for this base class. */
static tree
! dfs_debug_unmarkedp (binfo, access, data)
tree binfo;
+ tree access ATTRIBUTE_UNUSED;
void *data ATTRIBUTE_UNUSED;
{
return (!CLASSTYPE_DEBUG_REQUESTED (BINFO_TYPE (binfo))
*************** dfs_check_overlap (empty_binfo, data)
*** 2741,2748 ****
/* Trivial function to stop base traversal when we find something. */
static tree
! dfs_no_overlap_yet (binfo, data)
tree binfo;
void *data;
{
struct overlap_info *oi = (struct overlap_info *) data;
--- 2757,2765 ----
/* Trivial function to stop base traversal when we find something. */
static tree
! dfs_no_overlap_yet (binfo, access, data)
tree binfo;
+ tree access ATTRIBUTE_UNUSED;
void *data;
{
struct overlap_info *oi = (struct overlap_info *) data;
Index: cp/semantics.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/semantics.c,v
retrieving revision 1.297
diff -c -3 -p -r1.297 semantics.c
*** cp/semantics.c 30 Jan 2003 07:23:59 -0000 1.297
--- cp/semantics.c 31 Jan 2003 15:10:24 -0000
*************** finish_template_type (name, args, enteri
*** 2038,2064 ****
access_{default,public,protected_private}[_virtual]_node.*/
tree
! finish_base_specifier (access_specifier, base_class)
! tree access_specifier;
! tree base_class;
{
tree result;
! if (base_class == error_mark_node)
{
error ("invalid base-class specification");
result = NULL_TREE;
}
! else if (! is_aggr_type (base_class, 1))
result = NULL_TREE;
else
{
! if (cp_type_quals (base_class) != 0)
{
! error ("base class `%T' has cv qualifiers", base_class);
! base_class = TYPE_MAIN_VARIANT (base_class);
}
! result = build_tree_list (access_specifier, base_class);
}
return result;
--- 2038,2063 ----
access_{default,public,protected_private}[_virtual]_node.*/
tree
! finish_base_specifier (tree base, tree access, bool virtual_p)
{
tree result;
! if (base == error_mark_node)
{
error ("invalid base-class specification");
result = NULL_TREE;
}
! else if (! is_aggr_type (base, 1))
result = NULL_TREE;
else
{
! if (cp_type_quals (base) != 0)
{
! error ("base class `%T' has cv qualifiers", base);
! base = TYPE_MAIN_VARIANT (base);
}
! result = build_tree_list (access, base);
! TREE_VIA_VIRTUAL (result) = virtual_p;
}
return result;
Index: cp/tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/tree.c,v
retrieving revision 1.317
diff -c -3 -p -r1.317 tree.c
*** cp/tree.c 31 Jan 2003 14:46:53 -0000 1.317
--- cp/tree.c 31 Jan 2003 15:10:28 -0000
*************** unshare_base_binfos (binfo)
*** 738,745 ****
base_binfo,
BINFO_VTABLE (base_binfo),
BINFO_VIRTUALS (base_binfo));
- TREE_VIA_PUBLIC (new_binfo) = TREE_VIA_PUBLIC (base_binfo);
- TREE_VIA_PROTECTED (new_binfo) = TREE_VIA_PROTECTED (base_binfo);
TREE_VIA_VIRTUAL (new_binfo) = TREE_VIA_VIRTUAL (base_binfo);
BINFO_INHERITANCE_CHAIN (new_binfo) = binfo;
BINFO_PRIMARY_BASE_OF (new_binfo) = NULL_TREE;
--- 738,743 ----
*************** make_binfo (offset, binfo, vtable, virtu
*** 910,916 ****
BINFO_VIRTUALS (new_binfo) = virtuals;
if (binfo && BINFO_BASETYPES (binfo) != NULL_TREE)
! BINFO_BASETYPES (new_binfo) = copy_node (BINFO_BASETYPES (binfo));
return new_binfo;
}
--- 908,918 ----
BINFO_VIRTUALS (new_binfo) = virtuals;
if (binfo && BINFO_BASETYPES (binfo) != NULL_TREE)
! {
! BINFO_BASETYPES (new_binfo) = copy_node (BINFO_BASETYPES (binfo));
! /* We do not need to copy the accesses, as they are read only. */
! BINFO_BASEACCESSES (new_binfo) = BINFO_BASEACCESSES (binfo);
! }
return new_binfo;
}
Index: java/class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/class.c,v
retrieving revision 1.152
diff -c -3 -p -r1.152 class.c
*** java/class.c 31 Jan 2003 14:46:54 -0000 1.152
--- java/class.c 31 Jan 2003 15:11:14 -0000
*************** set_super_info (int access_flags, tree t
*** 354,371 ****
{
int total_supers = interfaces_count;
tree class_decl = TYPE_NAME (this_class);
if (super_class)
total_supers++;
! TYPE_BINFO_BASETYPES (this_class) = make_tree_vec (total_supers);
if (super_class)
{
tree super_binfo = make_tree_vec (BINFO_ELTS);
BINFO_TYPE (super_binfo) = super_class;
BINFO_OFFSET (super_binfo) = integer_zero_node;
! TREE_VIA_PUBLIC (super_binfo) = 1;
! TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (this_class)), 0)
! = super_binfo;
CLASS_HAS_SUPER (this_class) = 1;
}
--- 354,373 ----
{
int total_supers = interfaces_count;
tree class_decl = TYPE_NAME (this_class);
+ tree binfo = TYPE_BINFO (this_class);
+
if (super_class)
total_supers++;
! BINFO_BASETYPES (binfo) = make_tree_vec (total_supers);
! BINFO_BASEACCESSES (binfo) = make_tree_vec (total_supers);
if (super_class)
{
tree super_binfo = make_tree_vec (BINFO_ELTS);
BINFO_TYPE (super_binfo) = super_class;
BINFO_OFFSET (super_binfo) = integer_zero_node;
! TREE_VEC_ELT (BINFO_BASETYPES (binfo), 0) = super_binfo;
! TREE_VEC_ELT (BINFO_BASEACCESSES (binfo), 0) = access_public_node;
CLASS_HAS_SUPER (this_class) = 1;
}
*************** int common_enclosing_context_p (tree typ
*** 490,504 ****
}
static void
! add_interface_do (tree basetype_vec, tree interface_class, int i)
{
tree interface_binfo = make_tree_vec (BINFO_ELTS);
BINFO_TYPE (interface_binfo) = interface_class;
BINFO_OFFSET (interface_binfo) = integer_zero_node;
BINFO_VPTR_FIELD (interface_binfo) = integer_zero_node;
TREE_VIA_VIRTUAL (interface_binfo) = 1;
! TREE_VIA_PUBLIC (interface_binfo) = 1;
! TREE_VEC_ELT (basetype_vec, i) = interface_binfo;
}
/* Add INTERFACE_CLASS to THIS_CLASS iff INTERFACE_CLASS can't be
--- 492,506 ----
}
static void
! add_interface_do (tree binfo, tree interface_class, int i)
{
tree interface_binfo = make_tree_vec (BINFO_ELTS);
BINFO_TYPE (interface_binfo) = interface_class;
BINFO_OFFSET (interface_binfo) = integer_zero_node;
BINFO_VPTR_FIELD (interface_binfo) = integer_zero_node;
TREE_VIA_VIRTUAL (interface_binfo) = 1;
! BINFO_BASETYPE (binfo, i) = interface_binfo;
! BINFO_BASEACCESS (binfo, i) = access_public_node;
}
/* Add INTERFACE_CLASS to THIS_CLASS iff INTERFACE_CLASS can't be
*************** add_interface_do (tree basetype_vec, tre
*** 508,516 ****
tree
maybe_add_interface (tree this_class, tree interface_class)
{
! tree basetype_vec = TYPE_BINFO_BASETYPES (this_class);
int i;
! int n = TREE_VEC_LENGTH (basetype_vec);
for (i = 0; ; i++)
{
if (i >= n)
--- 510,518 ----
tree
maybe_add_interface (tree this_class, tree interface_class)
{
! tree binfo = TYPE_BINFO (this_class);
int i;
! int n = BINFO_N_BASETYPES (binfo);
for (i = 0; ; i++)
{
if (i >= n)
*************** maybe_add_interface (tree this_class, tr
*** 518,529 ****
error ("internal error - too many interface type");
return NULL_TREE;
}
! else if (TREE_VEC_ELT (basetype_vec, i) == NULL_TREE)
break;
! else if (BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i)) == interface_class)
return interface_class;
}
! add_interface_do (basetype_vec, interface_class, i);
return NULL_TREE;
}
--- 520,531 ----
error ("internal error - too many interface type");
return NULL_TREE;
}
! else if (BINFO_BASETYPE (binfo, i) == NULL_TREE)
break;
! else if (BINFO_TYPE (BINFO_BASETYPE (binfo, i)) == interface_class)
return interface_class;
}
! add_interface_do (binfo, interface_class, i);
return NULL_TREE;
}
*************** maybe_add_interface (tree this_class, tr
*** 532,540 ****
void
add_interface (tree this_class, tree interface_class)
{
! tree basetype_vec = TYPE_BINFO_BASETYPES (this_class);
int i;
! int n = TREE_VEC_LENGTH (basetype_vec);
for (i = 0; ; i++)
{
if (i >= n)
--- 534,542 ----
void
add_interface (tree this_class, tree interface_class)
{
! tree binfo = TYPE_BINFO (this_class);
int i;
! int n = BINFO_N_BASETYPES (binfo);
for (i = 0; ; i++)
{
if (i >= n)
*************** add_interface (tree this_class, tree int
*** 542,551 ****
error ("internal error - too many interface type");
return;
}
! else if (TREE_VEC_ELT (basetype_vec, i) == NULL_TREE)
break;
}
! add_interface_do (basetype_vec, interface_class, i);
}
#if 0
--- 544,553 ----
error ("internal error - too many interface type");
return;
}
! else if (BINFO_BASETYPE (binfo, i) == NULL_TREE)
break;
}
! add_interface_do (binfo, interface_class, i);
}
#if 0
Index: java/parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
retrieving revision 1.420
diff -c -3 -p -r1.420 parse.y
*** java/parse.y 29 Jan 2003 18:48:41 -0000 1.420
--- java/parse.y 31 Jan 2003 15:11:49 -0000
*************** patch_anonymous_class (tree type_decl, t
*** 3840,3855 ****
/* If it's an interface, implement it */
if (CLASS_INTERFACE (type_decl))
{
! tree s_binfo;
int length;
if (parser_check_super_interface (type_decl, class_decl, wfl))
return;
! s_binfo = TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (class)), 0);
! length = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (class))+1;
! TYPE_BINFO_BASETYPES (class) = make_tree_vec (length);
! TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (class)), 0) = s_binfo;
/* And add the interface */
parser_add_interface (class_decl, type_decl, wfl);
}
--- 3840,3858 ----
/* If it's an interface, implement it */
if (CLASS_INTERFACE (type_decl))
{
! tree s_binfo, s_access;
int length;
if (parser_check_super_interface (type_decl, class_decl, wfl))
return;
! s_binfo = BINFO_BASETYPE (binfo, 0);
! s_access = BINFO_BASEACCESS (binfo, 0);
! length = TREE_VEC_LENGTH (BINFO_BASETYPES (binfo)) + 1;
! BINFO_BASETYPES (binfo) = make_tree_vec (length);
! BINFO_BASEACCESSES (binfo) = make_tree_vec (length);
! BINFO_BASETYPE (binfo, 0) = s_binfo;
! BINFO_BASEACCESS (binfo, 0) = s_access;
/* And add the interface */
parser_add_interface (class_decl, type_decl, wfl);
}
*************** patch_anonymous_class (tree type_decl, t
*** 3858,3864 ****
{
if (parser_check_super (type_decl, class_decl, wfl))
return;
! BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (binfo), 0)) = type;
}
}
--- 3861,3867 ----
{
if (parser_check_super (type_decl, class_decl, wfl))
return;
! BINFO_TYPE (BINFO_BASETYPE (binfo, 0)) = type;
}
}