Remap dynamic cast hint values to be consistent across ABIs.

* search.c (dynamic_cast_base_recurse): Remap generated value.
	(get_dynamic_cast_base_type): Adjust documentation.
	* tinfo.h (__user_type_info::dyncast): Likewise.
	(__user_type_info::find_public_subobj): Remap BOFF meaning.
	* tinfo.cc (__si_type_info::do_dyncast): Remap BOFF meaning.
	(__class_type_info::do_dyncast): Likewise.
	(__class_type_info::do_find_public_subobj): Likewise.
	* tinfo2.cc (__dynamic_cast): Remap BOFF parameter.

From-SVN: r31538
This commit is contained in:
Nathan Sidwell 2000-01-20 11:05:19 +00:00 committed by Nathan Sidwell
parent f621dedc05
commit f08dda39ed
5 changed files with 37 additions and 23 deletions

View File

@ -1,3 +1,15 @@
2000-01-20 Nathan Sidwell <sidwell@codesourcery.com>
Remap dynamic cast hint values to be consistent across ABIs.
* search.c (dynamic_cast_base_recurse): Remap generated value.
(get_dynamic_cast_base_type): Adjust documentation.
* tinfo.h (__user_type_info::dyncast): Likewise.
(__user_type_info::find_public_subobj): Remap BOFF meaning.
* tinfo.cc (__si_type_info::do_dyncast): Remap BOFF meaning.
(__class_type_info::do_dyncast): Likewise.
(__class_type_info::do_find_public_subobj): Likewise.
* tinfo2.cc (__dynamic_cast): Remap BOFF parameter.
2000-01-19 Gabriel Dos Reis <gdr@codesourcery.coom>
* typeck.c (build_unary_op): Use cp_pedwarn, not pedwarn.

View File

@ -503,12 +503,12 @@ dynamic_cast_base_recurse (subtype, binfo, via_virtual, offset_ptr)
{
tree binfos;
int i, n_baselinks;
int worst = -3;
int worst = -2;
if (BINFO_TYPE (binfo) == subtype)
{
if (via_virtual)
return -2;
return -1;
else
{
*offset_ptr = BINFO_OFFSET (binfo);
@ -528,26 +528,28 @@ dynamic_cast_base_recurse (subtype, binfo, via_virtual, offset_ptr)
rval = dynamic_cast_base_recurse
(subtype, base_binfo,
via_virtual || TREE_VIA_VIRTUAL (base_binfo), offset_ptr);
if (worst == -3)
if (worst == -2)
worst = rval;
else if (rval >= 0)
worst = worst >= 0 ? -1 : worst;
else if (rval > -3)
worst = worst < rval ? worst : rval;
worst = worst >= 0 ? -3 : worst;
else if (rval == -1)
worst = -1;
else if (rval == -3 && worst != -1)
worst = -3;
}
return worst;
}
/* The dynamic cast runtime needs a hint about how the static SUBTYPE type started
from is related to the required TARGET type, in order to optimize the
inheritance graph search. This information is independant of the
/* The dynamic cast runtime needs a hint about how the static SUBTYPE type
started from is related to the required TARGET type, in order to optimize
the inheritance graph search. This information is independant of the
current context, and ignores private paths, hence get_base_distance is
inappropriate. Return a TREE specifying the base offset, BOFF.
BOFF >= 0, there is only one public non-virtual SUBTYPE base at offset BOFF,
and there are no public virtual SUBTYPE bases.
BOFF == -1, SUBTYPE occurs as multiple public non-virtual bases.
BOFF == -2, SUBTYPE occurs as multiple public virtual or non-virtual bases.
BOFF == -3, SUBTYPE is not a public base. */
BOFF == -1, SUBTYPE occurs as multiple public virtual or non-virtual bases.
BOFF == -2, SUBTYPE is not a public base.
BOFF == -3, SUBTYPE occurs as multiple public non-virtual bases. */
tree
get_dynamic_cast_base_type (subtype, target)

View File

@ -243,7 +243,7 @@ do_dyncast (int boff, sub_kind access_path,
if (boff >= 0)
result.target2sub = ((char *)subptr - (char *)objptr) == boff
? contained_public : not_contained;
else if (boff == -3)
else if (boff == -2)
result.target2sub = not_contained;
return false;
}
@ -361,7 +361,7 @@ do_dyncast (int boff, sub_kind access_path,
if (boff >= 0)
result.target2sub = ((char *)subptr - (char *)objptr) == boff
? contained_public : not_contained;
else if (boff == -3)
else if (boff == -2)
result.target2sub = not_contained;
return false;
}
@ -519,7 +519,7 @@ do_find_public_subobj (int boff, const type_info &subtype, void *objptr, void *s
continue; // Not public, can't be here.
void *p;
if (base_list[i].is_virtual && boff == -1)
if (base_list[i].is_virtual && boff == -3)
// Not a virtual base, so can't be here.
continue;

View File

@ -24,12 +24,12 @@ struct __user_type_info : public std::type_info {
// BOFF >= 0, there is only one public non-virtual SUBTYPE base at offset
// BOFF, and there are no public virtual SUBTYPE bases.
// Therefore check if SUBOBJ is at offset BOFF when we find a target
// BOFF == -1, SUBTYPE occurs as multiple public non-virtual bases.
// Lazily search the non-virtual bases of TARGET.
// BOFF == -2, SUBTYPE occurs as multiple public virtual or non-virtual bases.
// BOFF == -1, SUBTYPE occurs as multiple public virtual or non-virtual bases.
// Lazily search all the bases of TARGET.
// BOFF == -3, SUBTYPE is not a public base.
// For backwards compatibility set BOFF to -2, that is the safe `don't know'
// BOFF == -2, SUBTYPE is not a public base.
// BOFF == -3, SUBTYPE occurs as multiple public non-virtual bases.
// Lazily search the non-virtual bases of TARGET.
// For backwards compatibility set BOFF to -1, that is the safe `don't know'
// value. We don't care about SUBTYPES as private bases of TARGET, as they
// can never succeed as downcasts, only as crosscasts -- and then only if
// they are virtual. This is more complicated that it might seem.
@ -131,7 +131,7 @@ struct __user_type_info : public std::type_info {
if (boff >= 0)
return ((char *)subptr - (char *)objptr) == boff
? contained_public : not_contained;
if (boff == -3)
if (boff == -2)
return not_contained;
return do_find_public_subobj (boff, subtype, objptr, subptr);
}

View File

@ -1,5 +1,5 @@
// Methods for type_info for -*- C++ -*- Run Time Type Identification.
// Copyright (C) 1994, 96-97, 1998, 1999 Free Software Foundation
// Copyright (C) 1994, 96-97, 1998, 1999, 2000 Free Software Foundation
// This file is part of GNU CC.
@ -274,7 +274,7 @@ __dynamic_cast (const type_info& (*from)(void), const type_info& (*to)(void),
{
if (!require_public) abort();
return static_cast <__user_type_info const &> (from ()).dyncast
(/*boff=*/-2, to (), address, sub (), subptr);
(/*boff=*/-1, to (), address, sub (), subptr);
}
extern "C" void *