This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

C++ PATCH to fix recent regression



Fixes the thinko Benjamin pointed out today.

-- 
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

1999-04-26  Mark Mitchell  <mark@codesourcery.com>

	* search.c (is_subobject_of_p): Make sure we're looking at the
	right baseclasses.

Index: testsuite/g++.old-deja/g++.other/lookup15.C
===================================================================
RCS file: lookup15.C
diff -N lookup15.C
--- /dev/null	Sat Dec  5 20:30:03 1998
+++ lookup15.C	Mon Apr 26 23:59:48 1999
@@ -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;
+}
Index: cp/search.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/search.c,v
retrieving revision 1.99
diff -u -p -r1.99 search.c
--- search.c	1999/04/23 10:16:21	1.99
+++ search.c	1999/04/27 06:59:50
@@ -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.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]