* 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
+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.
{
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);
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)
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;
}
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;
}
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;
// 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.
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);
}
// 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.
{
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 *