This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH for template crash
- To: egcs-patches at egcs dot cygnus dot com
- Subject: C++ PATCH for template crash
- From: Mark Mitchell <mark at codesourcery dot com>
- Date: Fri, 23 Apr 1999 09:59:26 -0700
- Reply-to: mark at codesourcery dot com
Here's a patch for a recently reported buglet.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
1999-04-23 Mark Mitchell <mark@codesourcery.com>
* search.c (is_subobject_of_p): Handle TEMPLATE_TYPE_PARMs and
such as base classes.
Index: testsuite/g++.old-deja/g++.pt/crash40.C
===================================================================
RCS file: crash40.C
diff -N crash40.C
--- /dev/null Sat Dec 5 20:30:03 1998
+++ crash40.C Fri Apr 23 09:38:29 1999
@@ -0,0 +1,19 @@
+// Build don't link:
+// Origin: rch@larissa.sd.bi.ruhr-uni-bochum.de
+
+template< class X >
+struct VB: public virtual X
+{};
+
+template< class MOPTerm1, class MOPTerm2 >
+struct MOPTermUnify
+{
+ struct MO:
+ public VB<MOPTerm1>,
+ public VB<MOPTerm2>
+ {
+ void fix()
+ {
+ }
+ };
+};
Index: cp/search.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/search.c,v
retrieving revision 1.98
diff -u -p -r1.98 search.c
--- search.c 1999/04/20 21:48:51 1.98
+++ search.c 1999/04/23 16:39:15
@@ -1062,21 +1062,27 @@ static int
is_subobject_of_p (parent, binfo)
tree parent, binfo;
{
- tree binfos = BINFO_BASETYPES (binfo);
- int i, n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0;
+ tree binfos;
+ int i, n_baselinks;
- if (TREE_VIA_VIRTUAL (parent))
- parent = TYPE_BINFO (TREE_TYPE (parent));
- if (TREE_VIA_VIRTUAL (binfo))
- binfo = TYPE_BINFO (TREE_TYPE (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. */
for (i = 0; i < n_baselinks; i++)
{
- tree base_binfo = canonical_binfo (TREE_VEC_ELT (binfos, i));
+ tree base_binfo = TREE_VEC_ELT (binfos, i);
+ if (!CLASS_TYPE_P (TREE_TYPE (base_binfo)))
+ /* If we see a TEMPLATE_TYPE_PARM, or some such, as a base
+ class there's no way to descend into it. */
+ continue;
+
if (is_subobject_of_p (parent, base_binfo))
return 1;
}