This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ PATCH] Fix 3986
- To: gcc-patches at gcc dot gnu dot org
- Subject: [C++ PATCH] Fix 3986
- From: Nathan Sidwell <nathan at codesourcery dot com>
- Date: Thu, 06 Sep 2001 09:50:03 +0100
- Organization: Codesourcery LLC
[and this one was blocked too.]
Mark,
this patch fixes 2.95 regression 3986 which is another bug caused by
our unshared binfos. I'd forgotten about indirect primary bases when
forcing the canonical binfo. Also I've moved setting the
LOST_PRIMARY_BINFO_P flag into mark_primary_bases, which I think it better
belongs.
booted & tested on i686-pc-linux-gnu, ok for mainline & branch?
nathan
--
Dr Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2001-09-05 Nathan Sidwell <nathan@codesourcery.com>
* class.c (force_canonical_binfo_r): Check & move an indirect
primary base first.
(force_canonical_binfo): Check that it's not already
canonical.
(mark_primary_virtual_base): Remove BINFO parameter.
(mark_primary_bases): Adjust, set BINFO_LOST_PRIMARY_P here.
Index: cp/class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/class.c,v
retrieving revision 1.406
diff -c -3 -p -r1.406 class.c
*** class.c 2001/08/30 12:44:22 1.406
--- class.c 2001/09/05 17:33:54
*************** force_canonical_binfo_r (to, from, type,
*** 1437,1443 ****
tree mappings;
{
int i, n_baseclasses = BINFO_N_BASETYPES (from);
!
BINFO_INDIRECT_PRIMARY_P (to)
= BINFO_INDIRECT_PRIMARY_P (from);
BINFO_INDIRECT_PRIMARY_P (from) = 0;
--- 1437,1444 ----
tree mappings;
{
int i, n_baseclasses = BINFO_N_BASETYPES (from);
!
! my_friendly_assert (to != from, 20010905);
BINFO_INDIRECT_PRIMARY_P (to)
= BINFO_INDIRECT_PRIMARY_P (from);
BINFO_INDIRECT_PRIMARY_P (from) = 0;
*************** force_canonical_binfo_r (to, from, type,
*** 1461,1471 ****
my_friendly_assert (same_type_p (BINFO_TYPE (to), BINFO_TYPE (from)),
20010104);
mappings = tree_cons (from, to, mappings);
for (i = 0; i != n_baseclasses; i++)
{
tree from_binfo = BINFO_BASETYPE (from, i);
tree to_binfo = BINFO_BASETYPE (to, i);
!
if (TREE_VIA_VIRTUAL (from_binfo))
{
if (BINFO_PRIMARY_P (from_binfo) &&
--- 1462,1483 ----
my_friendly_assert (same_type_p (BINFO_TYPE (to), BINFO_TYPE (from)),
20010104);
mappings = tree_cons (from, to, mappings);
+
+ if (CLASSTYPE_HAS_PRIMARY_BASE_P (BINFO_TYPE (from))
+ && TREE_VIA_VIRTUAL (CLASSTYPE_PRIMARY_BINFO (BINFO_TYPE (from))))
+ {
+ tree from_primary = get_primary_binfo (from);
+
+ if (BINFO_PRIMARY_BASE_OF (from_primary) == from)
+ force_canonical_binfo (get_primary_binfo (to), from_primary,
+ type, mappings);
+ }
+
for (i = 0; i != n_baseclasses; i++)
{
tree from_binfo = BINFO_BASETYPE (from, i);
tree to_binfo = BINFO_BASETYPE (to, i);
!
if (TREE_VIA_VIRTUAL (from_binfo))
{
if (BINFO_PRIMARY_P (from_binfo) &&
*************** force_canonical_binfo (to, from, type, m
*** 1498,1514 ****
{
tree assoc = purpose_member (BINFO_TYPE (to),
CLASSTYPE_VBASECLASSES (type));
! TREE_VALUE (assoc) = to;
! force_canonical_binfo_r (to, from, type, mappings);
}
! /* Make BASE_BINFO the primary virtual base of BINFO within the hierarchy
! dominated by TYPE. Returns BASE_BINFO, if it can be made so, NULL
otherwise (because something else has already made it primary). */
static tree
! mark_primary_virtual_base (binfo, base_binfo, type)
! tree binfo;
tree base_binfo;
tree type;
{
--- 1510,1528 ----
{
tree assoc = purpose_member (BINFO_TYPE (to),
CLASSTYPE_VBASECLASSES (type));
! if (TREE_VALUE (assoc) != to)
! {
! TREE_VALUE (assoc) = to;
! force_canonical_binfo_r (to, from, type, mappings);
! }
}
! /* Make BASE_BINFO the a primary virtual base within the hierarchy
! dominated by TYPE. Returns BASE_BINFO, if it is not already one, NULL
otherwise (because something else has already made it primary). */
static tree
! mark_primary_virtual_base (base_binfo, type)
tree base_binfo;
tree type;
{
*************** mark_primary_virtual_base (binfo, base_b
*** 1519,1526 ****
/* It's already allocated in the hierarchy. BINFO won't have a
primary base in this hierachy, even though the complete object
BINFO is for, would do. */
- BINFO_LOST_PRIMARY_P (binfo) = 1;
-
return NULL_TREE;
}
--- 1533,1538 ----
*************** mark_primary_bases (type)
*** 1608,1617 ****
base_binfo = get_primary_binfo (binfo);
if (TREE_VIA_VIRTUAL (base_binfo))
! base_binfo = mark_primary_virtual_base (binfo, base_binfo, type);
if (base_binfo)
BINFO_PRIMARY_BASE_OF (base_binfo) = binfo;
BINFO_UNSHARED_MARKED (binfo) = 1;
}
--- 1620,1631 ----
base_binfo = get_primary_binfo (binfo);
if (TREE_VIA_VIRTUAL (base_binfo))
! base_binfo = mark_primary_virtual_base (base_binfo, type);
if (base_binfo)
BINFO_PRIMARY_BASE_OF (base_binfo) = binfo;
+ else
+ BINFO_LOST_PRIMARY_P (binfo) = 1;
BINFO_UNSHARED_MARKED (binfo) = 1;
}
// { dg-do compile }
// Copyright (C) 2001 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 5 Sept 2001 <nathan@codesourcery.com>
// Bug 3986. Another indirect primary base problem.
struct Consts
{
};
struct MathLib :
virtual Consts
{
};
struct Parallel :
virtual Consts
{
};
struct Particles :
virtual MathLib,
virtual Parallel
{
};
struct Ring :
virtual Particles
{
};
struct Injection :
virtual Particles,
virtual Ring
{
};
struct LSpaceCharge :
virtual Ring,
virtual Injection
{
};
struct Bump :
virtual Consts
{
};
struct Output :
virtual Injection,
virtual Bump
{
};
struct Plots :
virtual LSpaceCharge,
virtual Output
{
};