Commit 9965d119 by Nathan Sidwell Committed by Nathan Sidwell

invoke.texi (-fdump-class-layout): Document.

gcc:
	* invoke.texi (-fdump-class-layout): Document.
	(-fdump-translation-unit): Use `=' as filename separator.
cp:
	Fix specification and implementation bugs in V3 ABI
	construction vtables.
	* cp-tree.h (flag_dump_class_layout): New flag.
	(BINFO_OVERRIDE_ALONG_VIRTUAL_PATH_P): Remove.
	(BINFO_LOST_PRIMARY_P): New flag.
	(SET_BINFO_NEW_VTABLE_MARKED): Adjust asserts.
	(BINFO_PRIMARY_MARKED_P): Rename to ...
	(BINFO_PRIMARY_P): ... here.
	(binfo_via_virtual): New prototype.
	* decl2.c (flag_dump_class_layout): New flag.
	(cxx_decode_option): Set it. Adjust -fdump-translation-unit to
	use `=' as a file name separator.
	* init.c (dfs_initialize_vtbl_ptrs): Walk into virtual primary
	bases.
	(build_vtbl_address): If this is a virtual primary base, then
	get the vtbl of what it is ultimately primary for.
	* search.c (dfs_skip_nonprimary_vbases_unmarkedp): Adjust
	for BINFO_PRIMARY_P.
	(dfs_skip_nonprimary_vbases_markedp): Likewise.
	(get_shared_vbase_if_not_primary): Likewise.
	(dfs_get_pure_virtuals): Likewise.
	(expand_upcast_fixups): Likewise.
	(fixup_virtual_upcast_offsets): Likewise.
	(dfs_find_vbase_instance): Likewise.
	(find_vbase_instance): Likewise.
	(binfo_from_vbase): Adjust comment to reflect reality.
	(binfo_via_virtual): New function.
	* class.c (VTT_TOP_LEVEL_P, VTT_MARKED_BINFO_P): New macros
	for binfo walking during VTT construction.
	(dfs_mark_primary_bases): Remove.
	(force_canonical_binfo_r): New function.
	(force_canonical_binfo): New function.
	(mark_primary_virtual_base): New function.
	(mark_primary_bases): Walk in inheritance graph order, use
	mark_primary_virtual_base.
	(determine_primary_base): Use some more intermediate variables.
	(dfs_find_final_overrider): Don't check for overriding along a
	virtual path.
	(dfs_modify_vtables): Walk into primary virtual bases too.
	(walk_subobject_offsets): Adjust for BINFO_PRIMARY_P.
	(build_base_fields): Likewise.
	(dfs_set_offset_for_unshared_vbases): Likewise.
	(layout_virtual_bases): Likewise.
	(end_of_class): Likewise.
	(finish_struct_1): Call dump_class_hierarchy, if requested.
	(dfs_get_primary_binfo): Use BINFO_TYPE for binfos.
	(dump_class_hierarchy_r): Add stream parameter. Emit more information.
	(dump_class_hierarchy): Add file parameter. Append to file, if
	required.
	(finish_vtbls): Adjust accumulate_vtbl_inits call.
	Use canonical base for virtual bases.
	(build_vtt): Add more comments. Adjust build_vtt_inits call.
	(build_vtt_inits): Remove VIRTUAL_VTTS_P parm.
	Only set BINFO_VPTR_INDEX on top level. Use VTT_TOP_LEVEL_P,
	VTT_MARKED_BINFO_P for binfo walking. Use canonical vbase for
	virtual VTTs.
	(dfs_build_secondary_vptr_vtt_inits): Extract VTT_TOP_LEVEL_P
	from DATA.  We want virtual primary bases and all bases via virtual.
	Only set BINFO_VPTR_INDEX for top level. Look up from a primary
	virtual base when not a construction vtable.
	(dfs_ctor_vtable_bases_queue_p): New DFS predicate.
	(build_ctor_vtbl_group): Adjust accumulate_vtbl_inits call.
	Use canonical bases when processing virtual bases.
	(accumulate_vtbl_inits): We're interested in any base via a
	virtual path.
	(dfs_accumulate_vtbl_inits): If this is a primary virtual base
	within a construction vtable, determine what is being overridden.
	(build_vtbl_initializer): Add more comments
	(add_vcall_offset_vtbl_entries_1): Adjust comment.
	(build_rtti_vtbl_entries): Check if the base has lost its
	primary.
testsuite:
	* g++.old-deja/g++.abi/primary2.C: New test.
	* g++.old-deja/g++.abi/primary3.C: New test.
	* g++.old-deja/g++.abi/primary4.C: New test.
	* g++.old-deja/g++.abi/primary5.C: New test.
	* g++.old-deja/g++.abi/vtable3.h: New test.
	* g++.old-deja/g++.abi/vtable3a.C: New test.
	* g++.old-deja/g++.abi/vtable3b.C: New test.
	* g++.old-deja/g++.abi/vtable3c.C: New test.
	* g++.old-deja/g++.abi/vtable3d.C: New test.
	* g++.old-deja/g++.abi/vtable3e.C: New test.
	* g++.old-deja/g++.abi/vtable3f.C: New test.
	* g++.old-deja/g++.abi/vtable3g.C: New test.
	* g++.old-deja/g++.abi/vtable3h.C: New test.
	* g++.old-deja/g++.abi/vtable3i.C: New test.
	* g++.old-deja/g++.abi/vtable3j.C: New test.
	* g++.old-deja/g++.oliva/thunk1.C: Remove XFAIL.

From-SVN: r39455
parent 36ca672c
2001-02-05 Nathan Sidwell <nathan@codesourcery.com>
* invoke.texi (-fdump-class-layout): Document.
(-fdump-translation-unit): Use `=' as filename separator.
2001-02-05 Mark Mitchell <mark@codesourcery.com> 2001-02-05 Mark Mitchell <mark@codesourcery.com>
* Makefile.in (s-mlib): Don't build multilibs if * Makefile.in (s-mlib): Don't build multilibs if
......
2001-02-05 Nathan Sidwell <nathan@codesourcery.com>
Fix specification and implementation bugs in V3 ABI
construction vtables.
* cp-tree.h (flag_dump_class_layout): New flag.
(BINFO_OVERRIDE_ALONG_VIRTUAL_PATH_P): Remove.
(BINFO_LOST_PRIMARY_P): New flag.
(SET_BINFO_NEW_VTABLE_MARKED): Adjust asserts.
(BINFO_PRIMARY_MARKED_P): Rename to ...
(BINFO_PRIMARY_P): ... here.
(binfo_via_virtual): New prototype.
* decl2.c (flag_dump_class_layout): New flag.
(cxx_decode_option): Set it. Adjust -fdump-translation-unit to
use `=' as a file name separator.
* init.c (dfs_initialize_vtbl_ptrs): Walk into virtual primary
bases.
(build_vtbl_address): If this is a virtual primary base, then
get the vtbl of what it is ultimately primary for.
* search.c (dfs_skip_nonprimary_vbases_unmarkedp): Adjust
for BINFO_PRIMARY_P.
(dfs_skip_nonprimary_vbases_markedp): Likewise.
(get_shared_vbase_if_not_primary): Likewise.
(dfs_get_pure_virtuals): Likewise.
(expand_upcast_fixups): Likewise.
(fixup_virtual_upcast_offsets): Likewise.
(dfs_find_vbase_instance): Likewise.
(find_vbase_instance): Likewise.
(binfo_from_vbase): Adjust comment to reflect reality.
(binfo_via_virtual): New function.
* class.c (VTT_TOP_LEVEL_P, VTT_MARKED_BINFO_P): New macros
for binfo walking during VTT construction.
(dfs_mark_primary_bases): Remove.
(force_canonical_binfo_r): New function.
(force_canonical_binfo): New function.
(mark_primary_virtual_base): New function.
(mark_primary_bases): Walk in inheritance graph order, use
mark_primary_virtual_base.
(determine_primary_base): Use some more intermediate variables.
(dfs_find_final_overrider): Don't check for overriding along a
virtual path.
(dfs_modify_vtables): Walk into primary virtual bases too.
(walk_subobject_offsets): Adjust for BINFO_PRIMARY_P.
(build_base_fields): Likewise.
(dfs_set_offset_for_unshared_vbases): Likewise.
(layout_virtual_bases): Likewise.
(end_of_class): Likewise.
(finish_struct_1): Call dump_class_hierarchy, if requested.
(dfs_get_primary_binfo): Use BINFO_TYPE for binfos.
(dump_class_hierarchy_r): Add stream parameter. Emit more information.
(dump_class_hierarchy): Add file parameter. Append to file, if
required.
(finish_vtbls): Adjust accumulate_vtbl_inits call.
Use canonical base for virtual bases.
(build_vtt): Add more comments. Adjust build_vtt_inits call.
(build_vtt_inits): Remove VIRTUAL_VTTS_P parm.
Only set BINFO_VPTR_INDEX on top level. Use VTT_TOP_LEVEL_P,
VTT_MARKED_BINFO_P for binfo walking. Use canonical vbase for
virtual VTTs.
(dfs_build_secondary_vptr_vtt_inits): Extract VTT_TOP_LEVEL_P
from DATA. We want virtual primary bases and all bases via virtual.
Only set BINFO_VPTR_INDEX for top level. Look up from a primary
virtual base when not a construction vtable.
(dfs_ctor_vtable_bases_queue_p): New DFS predicate.
(build_ctor_vtbl_group): Adjust accumulate_vtbl_inits call.
Use canonical bases when processing virtual bases.
(accumulate_vtbl_inits): We're interested in any base via a
virtual path.
(dfs_accumulate_vtbl_inits): If this is a primary virtual base
within a construction vtable, determine what is being overridden.
(build_vtbl_initializer): Add more comments
(add_vcall_offset_vtbl_entries_1): Adjust comment.
(build_rtti_vtbl_entries): Check if the base has lost its
primary.
2001-02-05 Mark Mitchell <mark@codesourcery.com> 2001-02-05 Mark Mitchell <mark@codesourcery.com>
* Makefile.in (g++spec.o): Adjust use of DRIVER_DEFINES. * Makefile.in (g++spec.o): Adjust use of DRIVER_DEFINES.
......
...@@ -60,7 +60,7 @@ Boston, MA 02111-1307, USA. */ ...@@ -60,7 +60,7 @@ Boston, MA 02111-1307, USA. */
TYPE_POLYMORHPIC_P (in _TYPE) TYPE_POLYMORHPIC_P (in _TYPE)
ICS_THIS_FLAG (in _CONV) ICS_THIS_FLAG (in _CONV)
BINDING_HAS_LEVEL_P (in CPLUS_BINDING) BINDING_HAS_LEVEL_P (in CPLUS_BINDING)
BINFO_OVERRIDE_ALONG_VIRTUAL_PATH_P (in BINFO) BINFO_LOST_PRIMARY_P (in BINFO)
TREE_PARMLIST (in TREE_LIST) TREE_PARMLIST (in TREE_LIST)
3: TYPE_USES_VIRTUAL_BASECLASSES (in a class TYPE). 3: TYPE_USES_VIRTUAL_BASECLASSES (in a class TYPE).
BINFO_VTABLE_PATH_MARKED. BINFO_VTABLE_PATH_MARKED.
...@@ -1158,6 +1158,10 @@ extern int flag_access_control; ...@@ -1158,6 +1158,10 @@ extern int flag_access_control;
extern int flag_check_new; extern int flag_check_new;
/* Nonnull if we want to dump class heirarchies. */
extern const char *flag_dump_class_layout;
/* C++ language-specific tree codes. */ /* C++ language-specific tree codes. */
#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) SYM, #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) SYM,
...@@ -1672,11 +1676,11 @@ struct lang_type ...@@ -1672,11 +1676,11 @@ struct lang_type
(TREE_LANG_FLAG_4 (CANONICAL_BINFO (B, C))) (TREE_LANG_FLAG_4 (CANONICAL_BINFO (B, C)))
/* Any subobject that needs a new vtable must have a vptr and must not /* Any subobject that needs a new vtable must have a vptr and must not
be a primary base (since it would then use the vtable from a be a non-virtual primary base (since it would then use the vtable from a
derived class.) */ derived class and never become non-primary.) */
#define SET_BINFO_NEW_VTABLE_MARKED(B, C) \ #define SET_BINFO_NEW_VTABLE_MARKED(B, C) \
(BINFO_NEW_VTABLE_MARKED (B, C) = 1, \ (BINFO_NEW_VTABLE_MARKED (B, C) = 1, \
my_friendly_assert (!BINFO_PRIMARY_MARKED_P (B), 20000517), \ my_friendly_assert (!BINFO_PRIMARY_P (B) || TREE_VIA_VIRTUAL (B), 20000517), \
my_friendly_assert (CLASSTYPE_VFIELDS (BINFO_TYPE (B)) != NULL_TREE, \ my_friendly_assert (CLASSTYPE_VFIELDS (BINFO_TYPE (B)) != NULL_TREE, \
20000517)) 20000517))
...@@ -1691,7 +1695,7 @@ struct lang_type ...@@ -1691,7 +1695,7 @@ struct lang_type
class of a non-primary virtual base. This flag is only valid for class of a non-primary virtual base. This flag is only valid for
paths (given by BINFO_INHERITANCE_CHAIN) that really exist in the paths (given by BINFO_INHERITANCE_CHAIN) that really exist in the
final object. */ final object. */
#define BINFO_PRIMARY_MARKED_P(NODE) \ #define BINFO_PRIMARY_P(NODE) \
(BINFO_PRIMARY_BASE_OF (NODE) != NULL_TREE) (BINFO_PRIMARY_BASE_OF (NODE) != NULL_TREE)
/* The index in the VTT where this subobject's sub-VTT can be found. /* The index in the VTT where this subobject's sub-VTT can be found.
...@@ -1708,9 +1712,10 @@ struct lang_type ...@@ -1708,9 +1712,10 @@ struct lang_type
immediate base.) */ immediate base.) */
#define BINFO_PRIMARY_BASE_OF(NODE) TREE_VEC_ELT ((NODE), 10) #define BINFO_PRIMARY_BASE_OF(NODE) TREE_VEC_ELT ((NODE), 10)
/* Nonzero if this binfo declares a virtual function which is /* Nonzero if this binfo has lost its primary base binfo (because that
overridden along a virtual path. */ is a nearly-empty virtual base that has been taken by some other
#define BINFO_OVERRIDE_ALONG_VIRTUAL_PATH_P(NODE) TREE_LANG_FLAG_2 (NODE) base in the complete heirarchy. */
#define BINFO_LOST_PRIMARY_P(NODE) TREE_LANG_FLAG_2 (NODE)
/* Nonzero if this binfo is an indirect primary base, i.e. a virtual /* Nonzero if this binfo is an indirect primary base, i.e. a virtual
base that is a primary base of some of other class in the base that is a primary base of some of other class in the
...@@ -4248,6 +4253,7 @@ extern tree unmarked_vtable_pathp PARAMS ((tree, void *)); ...@@ -4248,6 +4253,7 @@ extern tree unmarked_vtable_pathp PARAMS ((tree, void *));
extern tree convert_pointer_to_vbase PARAMS ((tree, tree)); extern tree convert_pointer_to_vbase PARAMS ((tree, tree));
extern tree find_vbase_instance PARAMS ((tree, tree)); extern tree find_vbase_instance PARAMS ((tree, tree));
extern tree binfo_for_vbase PARAMS ((tree, tree)); extern tree binfo_for_vbase PARAMS ((tree, tree));
extern tree binfo_via_virtual PARAMS ((tree, tree));
extern void fixup_all_virtual_upcast_offsets PARAMS ((tree)); extern void fixup_all_virtual_upcast_offsets PARAMS ((tree));
/* in semantics.c */ /* in semantics.c */
......
...@@ -403,6 +403,10 @@ int flag_operator_names = 1; ...@@ -403,6 +403,10 @@ int flag_operator_names = 1;
int flag_check_new; int flag_check_new;
/* Nonnull if we want to dump class heirarchies. */
const char *flag_dump_class_layout;
/* Nonzero if we want the new ISO rules for pushing a new scope for `for' /* Nonzero if we want the new ISO rules for pushing a new scope for `for'
initialization variables. initialization variables.
0: Old rules, set by -fno-for-scope. 0: Old rules, set by -fno-for-scope.
...@@ -647,13 +651,23 @@ cxx_decode_option (argc, argv) ...@@ -647,13 +651,23 @@ cxx_decode_option (argc, argv)
name_mangling_version name_mangling_version
= read_integral_parameter (option_value, p - 2, name_mangling_version); = read_integral_parameter (option_value, p - 2, name_mangling_version);
else if ((option_value else if ((option_value
= skip_leading_substring (p, "dump-translation-unit-"))) = skip_leading_substring (p, "dump-translation-unit=")))
{ {
if (p[22] == '\0') if (!*option_value)
error ("no file specified with -fdump-translation-unit"); error ("no file specified with -fdump-translation-unit");
else else
flag_dump_translation_unit = option_value; flag_dump_translation_unit = option_value;
} }
else if ((option_value
= skip_leading_substring (p, "dump-class-layout=")))
{
if (!*option_value)
error ("no file specified with -fdump-class-layout");
else
flag_dump_class_layout = option_value;
}
else if (!strcmp (p, "dump-class-layout"))
flag_dump_class_layout = ""; /* empty string for stderr */
else else
{ {
int found = 0; int found = 0;
......
...@@ -137,7 +137,7 @@ dfs_initialize_vtbl_ptrs (binfo, data) ...@@ -137,7 +137,7 @@ dfs_initialize_vtbl_ptrs (binfo, data)
tree binfo; tree binfo;
void *data; void *data;
{ {
if (!BINFO_PRIMARY_MARKED_P (binfo) if ((!BINFO_PRIMARY_P (binfo) || TREE_VIA_VIRTUAL (binfo))
&& CLASSTYPE_VFIELDS (BINFO_TYPE (binfo))) && CLASSTYPE_VFIELDS (BINFO_TYPE (binfo)))
{ {
tree base_ptr = TREE_VALUE ((tree) data); tree base_ptr = TREE_VALUE ((tree) data);
...@@ -802,16 +802,27 @@ static tree ...@@ -802,16 +802,27 @@ static tree
build_vtbl_address (binfo) build_vtbl_address (binfo)
tree binfo; tree binfo;
{ {
tree binfo_for = binfo;
tree vtbl; tree vtbl;
if (BINFO_VPTR_INDEX (binfo) && TREE_VIA_VIRTUAL (binfo)
&& BINFO_PRIMARY_P (binfo))
/* If this is a virtual primary base, then the vtable we want to store
is that for the base this is being used as the primary base of. We
can't simply skip the initialization, because we may be expanding the
inits of a subobject constructor where the virtual base layout
can be different. */
while (BINFO_PRIMARY_BASE_OF (binfo_for))
binfo_for = BINFO_PRIMARY_BASE_OF (binfo_for);
/* Figure out what vtable BINFO's vtable is based on, and mark it as /* Figure out what vtable BINFO's vtable is based on, and mark it as
used. */ used. */
vtbl = get_vtbl_decl_for_binfo (binfo); vtbl = get_vtbl_decl_for_binfo (binfo_for);
assemble_external (vtbl); assemble_external (vtbl);
TREE_USED (vtbl) = 1; TREE_USED (vtbl) = 1;
/* Now compute the address to use when initializing the vptr. */ /* Now compute the address to use when initializing the vptr. */
vtbl = BINFO_VTABLE (binfo); vtbl = BINFO_VTABLE (binfo_for);
if (TREE_CODE (vtbl) == VAR_DECL) if (TREE_CODE (vtbl) == VAR_DECL)
{ {
vtbl = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (vtbl)), vtbl); vtbl = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (vtbl)), vtbl);
......
...@@ -2045,7 +2045,7 @@ dfs_skip_nonprimary_vbases_unmarkedp (binfo, data) ...@@ -2045,7 +2045,7 @@ dfs_skip_nonprimary_vbases_unmarkedp (binfo, data)
tree binfo; tree binfo;
void *data ATTRIBUTE_UNUSED; void *data ATTRIBUTE_UNUSED;
{ {
if (TREE_VIA_VIRTUAL (binfo) && !BINFO_PRIMARY_MARKED_P (binfo)) if (TREE_VIA_VIRTUAL (binfo) && !BINFO_PRIMARY_P (binfo))
/* This is a non-primary virtual base. Skip it. */ /* This is a non-primary virtual base. Skip it. */
return NULL_TREE; return NULL_TREE;
...@@ -2060,7 +2060,7 @@ dfs_skip_nonprimary_vbases_markedp (binfo, data) ...@@ -2060,7 +2060,7 @@ dfs_skip_nonprimary_vbases_markedp (binfo, data)
tree binfo; tree binfo;
void *data ATTRIBUTE_UNUSED; void *data ATTRIBUTE_UNUSED;
{ {
if (TREE_VIA_VIRTUAL (binfo) && !BINFO_PRIMARY_MARKED_P (binfo)) if (TREE_VIA_VIRTUAL (binfo) && !BINFO_PRIMARY_P (binfo))
/* This is a non-primary virtual base. Skip it. */ /* This is a non-primary virtual base. Skip it. */
return NULL_TREE; return NULL_TREE;
...@@ -2078,7 +2078,7 @@ get_shared_vbase_if_not_primary (binfo, data) ...@@ -2078,7 +2078,7 @@ get_shared_vbase_if_not_primary (binfo, data)
tree binfo; tree binfo;
void *data; void *data;
{ {
if (TREE_VIA_VIRTUAL (binfo) && !BINFO_PRIMARY_MARKED_P (binfo)) if (TREE_VIA_VIRTUAL (binfo) && !BINFO_PRIMARY_P (binfo))
{ {
tree type = (tree) data; tree type = (tree) data;
...@@ -2088,7 +2088,7 @@ get_shared_vbase_if_not_primary (binfo, data) ...@@ -2088,7 +2088,7 @@ get_shared_vbase_if_not_primary (binfo, data)
/* This is a non-primary virtual base. If there is no primary /* This is a non-primary virtual base. If there is no primary
version, get the shared version. */ version, get the shared version. */
binfo = binfo_for_vbase (BINFO_TYPE (binfo), type); binfo = binfo_for_vbase (BINFO_TYPE (binfo), type);
if (BINFO_PRIMARY_MARKED_P (binfo)) if (BINFO_PRIMARY_P (binfo))
return NULL_TREE; return NULL_TREE;
} }
...@@ -2152,7 +2152,7 @@ dfs_get_pure_virtuals (binfo, data) ...@@ -2152,7 +2152,7 @@ dfs_get_pure_virtuals (binfo, data)
/* We're not interested in primary base classes; the derived class /* We're not interested in primary base classes; the derived class
of which they are a primary base will contain the information we of which they are a primary base will contain the information we
need. */ need. */
if (!BINFO_PRIMARY_MARKED_P (binfo)) if (!BINFO_PRIMARY_P (binfo))
{ {
tree virtuals; tree virtuals;
...@@ -2455,7 +2455,7 @@ expand_upcast_fixups (binfo, addr, orig_addr, vbase, vbase_addr, t, ...@@ -2455,7 +2455,7 @@ expand_upcast_fixups (binfo, addr, orig_addr, vbase, vbase_addr, t,
tree delta; tree delta;
HOST_WIDE_INT n; HOST_WIDE_INT n;
while (BINFO_PRIMARY_MARKED_P (binfo)) while (BINFO_PRIMARY_P (binfo))
{ {
binfo = BINFO_INHERITANCE_CHAIN (binfo); binfo = BINFO_INHERITANCE_CHAIN (binfo);
if (TREE_VIA_VIRTUAL (binfo)) if (TREE_VIA_VIRTUAL (binfo))
...@@ -2593,7 +2593,7 @@ fixup_virtual_upcast_offsets (real_binfo, binfo, init_self, can_elide, addr, ori ...@@ -2593,7 +2593,7 @@ fixup_virtual_upcast_offsets (real_binfo, binfo, init_self, can_elide, addr, ori
tree real_base_binfo = TREE_VEC_ELT (real_binfos, i); tree real_base_binfo = TREE_VEC_ELT (real_binfos, i);
tree base_binfo = TREE_VEC_ELT (binfos, i); tree base_binfo = TREE_VEC_ELT (binfos, i);
int is_not_base_vtable int is_not_base_vtable
= !BINFO_PRIMARY_MARKED_P (real_base_binfo); = !BINFO_PRIMARY_P (real_base_binfo);
if (! TREE_VIA_VIRTUAL (real_base_binfo)) if (! TREE_VIA_VIRTUAL (real_base_binfo))
fixup_virtual_upcast_offsets (real_base_binfo, base_binfo, fixup_virtual_upcast_offsets (real_base_binfo, base_binfo,
is_not_base_vtable, can_elide, addr, is_not_base_vtable, can_elide, addr,
...@@ -2737,7 +2737,7 @@ dfs_find_vbase_instance (binfo, data) ...@@ -2737,7 +2737,7 @@ dfs_find_vbase_instance (binfo, data)
{ {
tree base = TREE_VALUE ((tree) data); tree base = TREE_VALUE ((tree) data);
if (BINFO_PRIMARY_MARKED_P (binfo) if (BINFO_PRIMARY_P (binfo)
&& same_type_p (BINFO_TYPE (binfo), base)) && same_type_p (BINFO_TYPE (binfo), base))
return binfo; return binfo;
...@@ -2755,7 +2755,7 @@ find_vbase_instance (base, type) ...@@ -2755,7 +2755,7 @@ find_vbase_instance (base, type)
tree instance; tree instance;
instance = binfo_for_vbase (base, type); instance = binfo_for_vbase (base, type);
if (!BINFO_PRIMARY_MARKED_P (instance)) if (!BINFO_PRIMARY_P (instance))
return instance; return instance;
return dfs_walk (TYPE_BINFO (type), return dfs_walk (TYPE_BINFO (type),
...@@ -3249,8 +3249,8 @@ binfo_for_vtable (var) ...@@ -3249,8 +3249,8 @@ binfo_for_vtable (var)
return main_binfo; return main_binfo;
} }
/* Returns the binfo of the first direct or indirect virtual base from /* Returns the binfo of the first direct or indirect virtual base derived
which BINFO is derived, or NULL if binfo is not via virtual. */ from BINFO, or NULL if binfo is not via virtual. */
tree tree
binfo_from_vbase (binfo) binfo_from_vbase (binfo)
...@@ -3264,6 +3264,24 @@ binfo_from_vbase (binfo) ...@@ -3264,6 +3264,24 @@ binfo_from_vbase (binfo)
return NULL_TREE; return NULL_TREE;
} }
/* Returns the binfo of the first direct or indirect virtual base derived
from BINFO up to the TREE_TYPE, LIMIT, or NULL if binfo is not
via virtual. */
tree
binfo_via_virtual (binfo, limit)
tree binfo;
tree limit;
{
for (; binfo && (!limit || !same_type_p (BINFO_TYPE (binfo), limit));
binfo = BINFO_INHERITANCE_CHAIN (binfo))
{
if (TREE_VIA_VIRTUAL (binfo))
return binfo;
}
return NULL_TREE;
}
/* Returns the BINFO (if any) for the virtual baseclass T of the class /* Returns the BINFO (if any) for the virtual baseclass T of the class
C from the CLASSTYPE_VBASECLASSES list. */ C from the CLASSTYPE_VBASECLASSES list. */
......
...@@ -223,8 +223,8 @@ in the following sections. ...@@ -223,8 +223,8 @@ in the following sections.
@item Debugging Options @item Debugging Options
@xref{Debugging Options,,Options for Debugging Your Program or GCC}. @xref{Debugging Options,,Options for Debugging Your Program or GCC}.
@gccoptlist{ @gccoptlist{
-a -ax -d@var{letters} -fdump-unnumbered -fdump-translation-unit-@var{file} @gol -a -ax -d@var{letters} -fdump-unnumbered -fdump-translation-unit=@var{file} @gol
-fpretend-float -fprofile-arcs -ftest-coverage @gol -fdump-class-layout=@var{file} -fpretend-float -fprofile-arcs -ftest-coverage @gol
-g -g@var{level} -gcoff -gdwarf -gdwarf-1 -gdwarf-1+ -gdwarf-2 @gol -g -g@var{level} -gcoff -gdwarf -gdwarf-1 -gdwarf-1+ -gdwarf-2 @gol
-ggdb -gstabs -gstabs+ -gxcoff -gxcoff+ @gol -ggdb -gstabs -gstabs+ -gxcoff -gxcoff+ @gol
-p -pg -print-file-name=@var{library} -print-libgcc-file-name @gol -p -pg -print-file-name=@var{library} -print-libgcc-file-name @gol
...@@ -2679,10 +2679,15 @@ numbers and line number note output. This makes it more feasible to ...@@ -2679,10 +2679,15 @@ numbers and line number note output. This makes it more feasible to
use diff on debugging dumps for compiler invocations with different use diff on debugging dumps for compiler invocations with different
options, in particular with and without -g. options, in particular with and without -g.
@item -fdump-translation-unit-@var{file} (C and C++ only) @item -fdump-translation-unit=@var{file} (C and C++ only)
Dump a representation of the tree structure for the entire translation Dump a representation of the tree structure for the entire translation
unit to @var{file}. unit to @var{file}.
@item -fdump-class_layout=@var{file} (C++ only)
@item -fdump-class_layout (C++ only)
Dump a representation of each class's heirarchy to @var{file}, or
@code{stderr} if not specified.
@item -fpretend-float @item -fpretend-float
When running a cross-compiler, pretend that the target machine uses the When running a cross-compiler, pretend that the target machine uses the
same floating point format as the host machine. This causes incorrect same floating point format as the host machine. This causes incorrect
......
2001-02-05 Nathan Sidwell <nathan@codesourcery.com>
* g++.old-deja/g++.abi/primary2.C: New test.
* g++.old-deja/g++.abi/primary3.C: New test.
* g++.old-deja/g++.abi/primary4.C: New test.
* g++.old-deja/g++.abi/primary5.C: New test.
* g++.old-deja/g++.abi/vtable3.h: New test.
* g++.old-deja/g++.abi/vtable3a.C: New test.
* g++.old-deja/g++.abi/vtable3b.C: New test.
* g++.old-deja/g++.abi/vtable3c.C: New test.
* g++.old-deja/g++.abi/vtable3d.C: New test.
* g++.old-deja/g++.abi/vtable3e.C: New test.
* g++.old-deja/g++.abi/vtable3f.C: New test.
* g++.old-deja/g++.abi/vtable3g.C: New test.
* g++.old-deja/g++.abi/vtable3h.C: New test.
* g++.old-deja/g++.abi/vtable3i.C: New test.
* g++.old-deja/g++.abi/vtable3j.C: New test.
* g++.old-deja/g++.oliva/thunk1.C: Remove XFAIL.
2001-02-03 Jakub Jelinek <jakub@redhat.com> 2001-02-03 Jakub Jelinek <jakub@redhat.com>
* g++.old-deja/g++.other/anon6.C: New test. * g++.old-deja/g++.other/anon6.C: New test.
......
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com>
// Check primary bases are chosen correctly.
struct A {virtual void Foo () {}};
struct B : virtual A {};
struct C : virtual B {};
struct D : virtual B, virtual C {};
int main ()
{
D d;
#if __GXX_ABI_VERSION >= 100
if (sizeof (D) != sizeof (A))
return 1;
#endif
return 0;
}
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com>
// Check primary bases are chosen correctly.
struct A {virtual void Foo () {}};
struct B1 : virtual A {};
struct B2 : virtual A {};
struct C : virtual B1, B2 {};
struct D : virtual C {};
int main ()
{
C c;
D d;
A *apc = &c;
B1 *b1pc = &c;
B2 *b2pc = &c;
A *apd = &d;
B1 *b1pd = &d;
B2 *b2pd = &d;
#if __GXX_ABI_VERSION >= 100
if (static_cast <void *> (apc) != static_cast <void *> (b1pc))
return 1;
if (static_cast <void *> (apd) != static_cast <void *> (b1pd))
return 2;
if (static_cast <void *> (apd) != static_cast <void *> (&d))
return 3;
#endif
return 0;
}
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com>
// Check primary bases are chosen correctly.
struct A { virtual void Foo () {}};
struct B1 : virtual A {};
struct B2 : virtual A {};
struct C : virtual B1 {};
struct D : virtual B1, B2, C {};
int main ()
{
D d;
A *ap = &d;
C *cp = &d;
#if __GXX_ABI_VERSION >= 100
if (static_cast <void *> (ap) != static_cast <void *> (cp))
return 1;
#endif
return 0;
}
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com>
// Check primary bases are chosen correctly.
struct A1
{
virtual void Foo () {};
};
struct A : A1
{
};
struct B : A
{
};
struct C : virtual B
{
};
struct D : virtual B, virtual C
{
};
int main()
{
D d;
#if __GXX_ABI_VERSION >= 100
if (sizeof (D) != sizeof (A))
return 1;
#endif
return 0;
}
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com>
// Check constructor vtables work. This is included from numerous test
// files, which set the #defines necessary to specify the heirarchy.
#include <typeinfo>
#include <stdio.h>
// XXX. vcall offsets are still broken, remove this define to re-enable
// testing when fixed.
#define NO_VCALL_TEST
int fail;
template <typename BASE, typename DERIVED>
int Test (DERIVED *d, int expect)
{
BASE *b = static_cast <BASE *> (d);
void *full_b = dynamic_cast <void *> (b);
void *full_d = dynamic_cast <void *> (d);
if (full_b != full_d)
{
fail++;
fprintf (stderr, "base %s and derived %s have different full objects\n",
typeid (BASE).name (), typeid (DERIVED).name ());
return 1;
}
DERIVED *dynamic_d = dynamic_cast <DERIVED *> (b);
if (dynamic_d != d)
{
fail++;
fprintf (stderr, "dynamic_cast from %s to %s failed\n",
typeid (BASE).name (), typeid (DERIVED).name ());
return 1;
}
#ifndef NO_VCALL_TEST
b->Baz (static_cast <void *> (b));
int res = b->Foo (static_cast <void *> (d));
if (res != expect)
{
fail++;
fprintf (stderr, "%s::Foo returned %d, expected %d\n",
typeid (BASE).name (), res, expect);
return 1;
}
#endif
return 0;
}
template <typename T>
int Test (T *self, void *expected, int result)
{
if (self != expected)
{
fail++;
fprintf (stderr, "%s::Foo wrong this pointer\n", typeid (T).name ());
}
return result;
}
struct A {
#ifndef A_EMPTY
int a_m;
#endif
virtual int Foo (void *p) {return Test (this, p, 1);}
virtual int Baz (void *p) {return Test (this, p, 1);}
A ();
~A ();
};
struct B1: virtual A {
#ifndef B1_EMPTY
int b1_m;
#endif
virtual int Foo (void *p) {return Test (this, p, 2);}
B1();
~B1();
};
struct B2: virtual A {
#ifndef B2_EMPTY
int b2_m;
#endif
virtual int Foo (void *p) {return Test (this, p, 3);}
B2();
~B2();
};
struct Empty {};
struct C : C_PARENTS {
#ifndef C_EMPTY
int c_m;
#endif
virtual int Foo (void *p) {return Test (this, p, 4);}
C();
~C();
};
A::A ()
{
fprintf (stderr, "%s\n", __PRETTY_FUNCTION__);
Test <A> (this, 1);
}
A::~A ()
{
fprintf (stderr, "%s\n", __PRETTY_FUNCTION__);
Test <A> (this, 1);
}
B1::B1()
{
fprintf (stderr, "%s\n", __PRETTY_FUNCTION__);
Test <A> (this, 2);
Test <B1> (this, 2);
}
B1::~B1()
{
fprintf (stderr, "%s\n", __PRETTY_FUNCTION__);
Test <A> (this, 2);
Test <B1> (this, 2);
}
B2::B2()
{
fprintf (stderr, "%s\n", __PRETTY_FUNCTION__);
Test <A> (this, 3);
Test <B2> (this, 3);
}
B2::~B2()
{
fprintf (stderr, "%s\n", __PRETTY_FUNCTION__);
Test <A> (this, 3);
Test <B2> (this, 3);
}
C::C()
{
fprintf (stderr, "%s\n", __PRETTY_FUNCTION__);
Test <A> (this, 4);
Test <C> (this, 4);
}
C::~C()
{
fprintf (stderr, "%s\n", __PRETTY_FUNCTION__);
Test <A> (this, 4);
Test <C> (this, 4);
}
struct D : C {};
struct D1 : virtual C {};
struct D2 : virtual A, virtual C {};
int main()
{
{
fprintf (stderr, "C\n");
C c;
}
{
fprintf (stderr, "D\n");
D d;
}
{
fprintf (stderr, "D1\n");
D1 d1;
}
{
fprintf (stderr, "D2\n");
D2 d2;
}
if (fail)
fprintf (stderr, "There are %d failings\n", fail);
else
fprintf (stderr, "Passed\n");
return fail ? 1 : 0;
}
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com>
// Check constructor vtables work.
#define A_EMPTY
#define B1_EMPTY
#define B2_EMPTY
#define C_EMPTY
#define C_PARENTS B1, B2
#include "vtable3.h"
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com>
// Check constructor vtables work.
#define B1_EMPTY
#define B2_EMPTY
#define C_EMPTY
#define C_PARENTS B1, B2
#include "vtable3.h"
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com>
// Check constructor vtables work.
#define A_EMPTY
#define B2_EMPTY
#define C_EMPTY
#define C_PARENTS B1, B2
#include "vtable3.h"
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com>
// Check constructor vtables work.
#define A_EMPTY
#define B1_EMPTY
#define C_EMPTY
#define C_PARENTS B1, B2
#include "vtable3.h"
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com>
// Check constructor vtables work.
#define A_EMPTY
#define B1_EMPTY
#define B2_EMPTY
#define C_PARENTS B1, B2
#include "vtable3.h"
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com>
// Check constructor vtables work.
#define A_EMPTY
#define B1_EMPTY
#define B2_EMPTY
#define C_EMPTY
#define C_PARENTS B1, virtual B2
#include "vtable3.h"
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com>
// Check constructor vtables work.
#define A_EMPTY
#define B1_EMPTY
#define B2_EMPTY
#define C_EMPTY
#define C_PARENTS virtual B1, B2
#include "vtable3.h"
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com>
// Check constructor vtables work.
#define A_EMPTY
#define B1_EMPTY
#define B2_EMPTY
#define C_EMPTY
#define C_PARENTS virtual B1, virtual B2
#include "vtable3.h"
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com>
// Check constructor vtables work.
#define B1_EMPTY
#define B2_EMPTY
#define C_EMPTY
#define C_PARENTS virtual B1, B2
#include "vtable3.h"
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 4 February 2001 <nathan@codesourcery.com>
// Check constructor vtables work.
#define B1_EMPTY
#define B2_EMPTY
#define C_EMPTY
#define C_PARENTS virtual B1, virtual B2
#include "vtable3.h"
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
// based on bug report by Fredrik Öhrström <d92-foh@nada.kth.se> // based on bug report by Fredrik Öhrström <d92-foh@nada.kth.se>
// Special g++ Options: -fvtable-thunks // Special g++ Options: -fvtable-thunks
// execution test - XFAIL *-*-*
#include <cstdlib> #include <cstdlib>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment