PR c++/14429
authorlerdsuwa <lerdsuwa@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 27 Jul 2004 15:47:10 +0000 (15:47 +0000)
committerlerdsuwa <lerdsuwa@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 27 Jul 2004 15:47:10 +0000 (15:47 +0000)
* pt.c (coerce_template_template_parms) <PARM_DECL case>: Only check
when the type of ARG is not dependent.

* g++.dg/template/ttp11.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@85222 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/ttp11.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/ttp12.C [new file with mode: 0644]

index 329b12e..3a270bc 100644 (file)
@@ -1,3 +1,9 @@
+2004-07-27  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       PR c++/14429
+       * pt.c (coerce_template_template_parms) <PARM_DECL case>: Only check
+       when the type of ARG is not dependent.
+
 2004-07-26  Geoffrey Keating  <geoffk@apple.com>
 
        * g++spec.c (LIBSTDCXX_PROFILE): Default to LIBSTDCXX.
index ca84b39..7ae18f8 100644 (file)
@@ -3639,11 +3639,16 @@ coerce_template_template_parms (tree parm_parms,
 
        case PARM_DECL:
          /* The tsubst call is used to handle cases such as
-              template <class T, template <T> class TT> class D;  
+
+              template <int> class C {};
+              template <class T, template <T> class TT> class D {};
+              D<int, C> d;
+
             i.e. the parameter list of TT depends on earlier parameters.  */
-         if (!same_type_p
-             (tsubst (TREE_TYPE (parm), outer_args, complain, in_decl),
-              TREE_TYPE (arg)))
+         if (!dependent_type_p (TREE_TYPE (arg))
+             && !same_type_p
+                   (tsubst (TREE_TYPE (parm), outer_args, complain, in_decl),
+                            TREE_TYPE (arg)))
            return 0;
          break;
          
index bf23710..bc4bea2 100644 (file)
@@ -1,3 +1,8 @@
+2004-07-27  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       PR c++/14429
+       * g++.dg/template/ttp11.C: New test.
+
 2004-07-27  Diego Novillo  <dnovillo@redhat.com>
 
        * gcc.c-torture/compile/20040727-1.c: New test.
diff --git a/gcc/testsuite/g++.dg/template/ttp11.C b/gcc/testsuite/g++.dg/template/ttp11.C
new file mode 100644 (file)
index 0000000..84867e1
--- /dev/null
@@ -0,0 +1,14 @@
+// { dg-do compile }
+
+// Origin: heinlein@informatik.uni-ulm.de
+
+// PR c++/14429: Matching of template template parameter containing
+// non-type parameter with type that depends on earlier parameter.
+
+template <template <typename U, U* p> class T>
+struct X {};
+
+template <template <typename U, U* p> class T>
+struct Y {
+    X<T> x;
+};
diff --git a/gcc/testsuite/g++.dg/template/ttp12.C b/gcc/testsuite/g++.dg/template/ttp12.C
new file mode 100644 (file)
index 0000000..554738b
--- /dev/null
@@ -0,0 +1,19 @@
+// Copyright (C) 2004 Free Software Foundation
+// Contributed by Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
+// { dg-do compile }
+
+// Check the type of non-type parameter in template template parameter
+// only if it is dependent.
+
+template <template <int* p> class T>
+struct X {};
+
+template <typename U, template <U* p> class T>
+struct Y {
+    X<T> x;
+};
+
+template <int* p> struct Z {};
+
+Y<int, Z> y1;
+Y<char, Z> y2;         // { dg-error "mismatch|expected|invalid" }