pt.c (unify): Handle when both ARG and PARM are BOUND_TEMPLATE_TEMPLATE_PARM.
authorKriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
Sat, 16 Dec 2000 07:57:21 +0000 (07:57 +0000)
committerKriang Lerdsuwanakij <lerdsuwa@gcc.gnu.org>
Sat, 16 Dec 2000 07:57:21 +0000 (07:57 +0000)
* pt.c (unify): Handle when both ARG and PARM are
BOUND_TEMPLATE_TEMPLATE_PARM.

* g++.old-deja/g++.pt/ttp65.C: New test.

From-SVN: r38301

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

index 7437490bc31cad539e1b3637554132121152d75a..f94fdc1ad9d1ae8c707f4eb5c5650c636021b3f3 100644 (file)
@@ -1,3 +1,8 @@
+2000-12-15  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       * pt.c (unify): Handle when both ARG and PARM are
+       BOUND_TEMPLATE_TEMPLATE_PARM.
+
 2000-12-15  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
 
        * pt.c (reduce_template_parm_level): Set DECL_ARTIFICIAL and
index ac6fc165d51e9f2fa189150dd0b2887d25e480fd..3a0096e503c85c8837b9a7bb4dba517bfcb692ef 100644 (file)
@@ -8417,16 +8417,18 @@ unify (tparms, targs, parm, arg, strict)
 
       if (TREE_CODE (parm) == BOUND_TEMPLATE_TEMPLATE_PARM)
        {
-         /* ARG must be constructed from a template class.  */
-         if (TREE_CODE (arg) != RECORD_TYPE || !CLASSTYPE_TEMPLATE_INFO (arg))
+         /* ARG must be constructed from a template class or a template
+            template parameter.  */
+         if (TREE_CODE (arg) != BOUND_TEMPLATE_TEMPLATE_PARM
+             && (TREE_CODE (arg) != RECORD_TYPE || !CLASSTYPE_TEMPLATE_INFO (arg)))
            return 1;
 
          {
            tree parmtmpl = TYPE_TI_TEMPLATE (parm);
            tree parmvec = TYPE_TI_ARGS (parm);
-           tree argvec = CLASSTYPE_TI_ARGS (arg);
+           tree argvec = TYPE_TI_ARGS (arg);
            tree argtmplvec
-             = DECL_INNERMOST_TEMPLATE_PARMS (CLASSTYPE_TI_TEMPLATE (arg));
+             = DECL_INNERMOST_TEMPLATE_PARMS (TYPE_TI_TEMPLATE (arg));
            int i;
 
            /* The parameter and argument roles have to be switched here 
@@ -8455,7 +8457,7 @@ unify (tparms, targs, parm, arg, strict)
                  return 1;
              }
          }
-         arg = CLASSTYPE_TI_TEMPLATE (arg);
+         arg = TYPE_TI_TEMPLATE (arg);
 
          /* Fall through to deduce template name.  */
        }
index b43a4628473a51c969b35bda5b4a3f3f8f51b6a6..3b8b153c2b9a1f1bd8f42f1f04b629e83be85ae3 100644 (file)
@@ -1,3 +1,7 @@
+2000-12-15  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       * g++.old-deja/g++.pt/ttp65.C: New test.
+
 2000-12-15  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
 
        * g++.old-deja/g++.pt/ttp64.C: New test.
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/ttp65.C b/gcc/testsuite/g++.old-deja/g++.pt/ttp65.C
new file mode 100644 (file)
index 0000000..9f4507a
--- /dev/null
@@ -0,0 +1,38 @@
+// Build don't link:
+
+// Copyright (C) 2000 Free Software Foundation
+// Contributed by Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
+
+// Bug: We used reject template unification of two bound template template
+// parameters.
+
+template <class T, class U=int> class C
+{
+};
+
+template <class T, class U> void f(C<T,U> c)
+{
+}
+
+template <class T> void f(C<T> c)
+{
+}
+
+template <template<class,class=int> class C, class T, class U>
+void g(C<T,U> c)
+{
+}
+
+template <template<class,class=int> class C, class T> void g(C<T> c)
+{
+}
+
+int main()
+{
+  C<int,char> c1;
+  f(c1);
+  g(c1);
+  C<int,int> c2;
+  f(c2);
+  g(c2);
+}