search.c (is_subobject_of_p): Make sure we're looking at the right baseclasses.
authorMark Mitchell <mark@codesourcery.com>
Tue, 27 Apr 1999 00:02:52 +0000 (00:02 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Tue, 27 Apr 1999 00:02:52 +0000 (00:02 +0000)
* search.c (is_subobject_of_p): Make sure we're looking at the
right baseclasses.

From-SVN: r26669

gcc/cp/ChangeLog
gcc/cp/search.c
gcc/testsuite/g++.old-deja/g++.other/lookup15.C [new file with mode: 0644]

index 4c8b67fbc2ce519ba57d82c5154b44f017b66288..3124a49a6dcda39b3b4cda77fb31e7ec0ebcc684 100644 (file)
@@ -1,3 +1,8 @@
+1999-04-26  Mark Mitchell  <mark@codesourcery.com>
+
+       * search.c (is_subobject_of_p): Make sure we're looking at the
+       right baseclasses.
+
 1999-04-26  Marc Espie  <espie@cvs.openbsd.org>
 
        * Make-lang.in (cplib2.ready): Don't depend on phony targets.
index 7ce65e63f8edcf4f7c4e7cccbad3b18c0a8eb745..ca98daaac4af0be55939b383d3646689974e87dc 100644 (file)
@@ -1065,13 +1065,17 @@ is_subobject_of_p (parent, binfo)
   tree binfos;
   int i, n_baselinks;
 
+  /* We want to canonicalize for comparison purposes.  But, when we
+     iterate through basetypes later, we want the binfos from the
+     original hierarchy.  That's why we have to calculate BINFOS
+     first, and then canonicalize.  */
+  binfos = BINFO_BASETYPES (binfo);
   parent = canonical_binfo (parent);
   binfo = canonical_binfo (binfo);
 
   if (parent == binfo)
     return 1;
 
-  binfos = BINFO_BASETYPES (binfo);
   n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0;
 
   /* Process and/or queue base types.  */
diff --git a/gcc/testsuite/g++.old-deja/g++.other/lookup15.C b/gcc/testsuite/g++.old-deja/g++.other/lookup15.C
new file mode 100644 (file)
index 0000000..be9096a
--- /dev/null
@@ -0,0 +1,37 @@
+// Build don't link:
+// Origin: Benjamin Kosnik <bkoz@cygnus.com>
+
+class b
+{
+  int j;
+public:
+  b(int a = 6): j(a) {}
+  void imbue(int a) {++j;}
+};
+
+class d: public b
+{
+  int k;
+public:
+  d(int a = 7): b(a), k(a) {}
+  void imbue(int a) {++k;}
+};
+  
+//virtual public kills, public ok
+class mostd: virtual public d
+{
+  int l;
+public:
+  mostd(int a = 9): d(a), l(a) {}
+};
+
+int main() {
+
+  d dobj;
+  dobj.imbue(5);
+
+  mostd mobj;
+  mobj.imbue(5);
+  
+  return 0;
+}