Patchwork C++ PATCH for c++/52685 (ICE with dependent/non-dependent bases)

login
register
mail settings
Submitter Jason Merrill
Date March 29, 2012, 3:50 p.m.
Message ID <4F7484DE.6050804@redhat.com>
Download mbox | patch
Permalink /patch/149424/
State New
Headers show

Comments

Jason Merrill - March 29, 2012, 3:50 p.m.
In this testcase, C has a base B<U> which is a non-dependent scope 
because it is the current instantiation.  But B<U> has a dependent base 
A<B<U>>, so we need to be able to handle a non-dependent base that 
itself has a dependent base.

Tested x86_64-pc-linux-gnu, applying to trunk and 4.7.

Patch

commit f44bf02aa21ddfd33505c067f3c26893d432a186
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Mar 29 11:08:11 2012 -0400

    	PR c++/52685
    	* tree.c (copy_binfo): Handle BINFO_DEPENDENT_BASE_P.

diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 87e9be8..30ad5e1 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -1237,12 +1237,11 @@  copy_binfo (tree binfo, tree type, tree t, tree *igo_prev, int virt)
   TREE_CHAIN (*igo_prev) = new_binfo;
   *igo_prev = new_binfo;
 
-  if (binfo)
+  if (binfo && !BINFO_DEPENDENT_BASE_P (binfo))
     {
       int ix;
       tree base_binfo;
 
-      gcc_assert (!BINFO_DEPENDENT_BASE_P (binfo));
       gcc_assert (SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), type));
 
       BINFO_OFFSET (new_binfo) = BINFO_OFFSET (binfo);
@@ -1255,8 +1254,6 @@  copy_binfo (tree binfo, tree type, tree t, tree *igo_prev, int virt)
       for (ix = 0; BINFO_BASE_ITERATE (binfo, ix, base_binfo); ix++)
 	{
 	  tree new_base_binfo;
-
-	  gcc_assert (!BINFO_DEPENDENT_BASE_P (base_binfo));
 	  new_base_binfo = copy_binfo (base_binfo, BINFO_TYPE (base_binfo),
 				       t, igo_prev,
 				       BINFO_VIRTUAL_P (base_binfo));
diff --git a/gcc/testsuite/g++.dg/template/inherit8.C b/gcc/testsuite/g++.dg/template/inherit8.C
new file mode 100644
index 0000000..a9b2bdb
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/inherit8.C
@@ -0,0 +1,13 @@ 
+// PR c++/52685
+
+template <typename T>
+struct A
+{
+  template <typename U>
+  struct B : public A <B<U> >
+  {
+    struct C : public B<U>
+    {
+    };
+  };
+};