On Wed, Apr 03, 2013 at 09:43:01AM -0400, Jason Merrill wrote:
> We should be able to just copy NON_DEFAULT_TEMPLATE_ARGS_COUNT over
> rather than mess with looking into and building an INTEGER_CST.

So is this ok instead?

2013-04-03  Jakub Jelinek  <ja...@redhat.com>

        PR debug/56819
        * tree.c (strip_typedefs): Copy NON_DEFAULT_TEMPLATE_ARGS_COUNT
        from args to new_args.
        (strip_typedefs_expr): Copy NON_DEFAULT_TEMPLATE_ARGS_COUNT from t to
        r instead of doing {S,G}ET_NON_DEFAULT_TEMPLATE_ARGS_COUNT.

        * g++.dg/debug/pr56819.C: New test.

--- gcc/cp/tree.c.jj    2013-04-03 11:15:39.412081151 +0200
+++ gcc/cp/tree.c       2013-04-03 15:49:54.885694171 +0200
@@ -1255,8 +1255,13 @@ strip_typedefs (tree t)
                  changed = true;
              }
            if (changed)
-             fullname = lookup_template_function (TREE_OPERAND (fullname, 0),
-                                                  new_args);
+             {
+               NON_DEFAULT_TEMPLATE_ARGS_COUNT (new_args)
+                 = NON_DEFAULT_TEMPLATE_ARGS_COUNT (args);
+               fullname
+                 = lookup_template_function (TREE_OPERAND (fullname, 0),
+                                             new_args);
+             }
            else
              ggc_free (new_args);
          }
@@ -1389,8 +1394,8 @@ strip_typedefs_expr (tree t)
            r = copy_node (t);
            for (i = 0; i < n; ++i)
              TREE_VEC_ELT (r, i) = (*vec)[i];
-           SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT
-             (r, GET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (t));
+           NON_DEFAULT_TEMPLATE_ARGS_COUNT (r)
+             = NON_DEFAULT_TEMPLATE_ARGS_COUNT (t);
          }
        else
          r = t;
--- gcc/testsuite/g++.dg/debug/pr56819.C.jj     2013-04-03 15:49:05.384965717 
+0200
+++ gcc/testsuite/g++.dg/debug/pr56819.C        2013-04-03 15:49:05.384965717 
+0200
@@ -0,0 +1,27 @@
+// PR debug/56819
+// { dg-do compile }
+// { dg-options "-fcompare-debug" }
+
+template <typename>
+struct A
+{
+  template <typename>
+  struct B;
+};
+
+template <typename>
+struct C
+{
+  typedef int I;
+};
+
+template <typename T>
+class D
+{
+  typedef A <void> E;
+  typedef typename T::template B <E> F;
+  typedef typename C <F>::I I;
+  A <I> foo () { return A<I> (); }
+};
+
+template class D <A <void> >;


        Jakub

Reply via email to