* pt.c (lookup_template_class): Build complete template arguments
authorlerdsuwa <lerdsuwa@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 13 Oct 2001 15:00:44 +0000 (15:00 +0000)
committerlerdsuwa <lerdsuwa@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 13 Oct 2001 15:00:44 +0000 (15:00 +0000)
for BOUND_TEMPLATE_TEMPLATE_PARM.

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

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

index 2b1b453..92907b8 100644 (file)
@@ -1,3 +1,8 @@
+2001-10-13  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       * pt.c (lookup_template_class): Build complete template arguments
+       for BOUND_TEMPLATE_TEMPLATE_PARM.
+
 2001-10-12  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
 
        * cp-tree.h (TYPE_BINFO): Update comment.
index cd68629..e2904b5 100644 (file)
@@ -3913,6 +3913,19 @@ lookup_template_class (d1, arglist, in_decl, context, entering_scope, complain)
 
       parmlist = DECL_INNERMOST_TEMPLATE_PARMS (template);
 
+      /* Consider an example where a template template parameter declared as
+
+          template <class T, class U = std::allocator<T> > class TT
+
+        The template parameter level of T and U are one level larger than 
+        of TT.  To proper process the default argument of U, say when an 
+        instantiation `TT<int>' is seen, we need to build the full
+        arguments containing {int} as the innermost level.  Outer levels
+        can be obtained from `current_template_args ()'.  */
+
+      if (processing_template_decl)
+       arglist = add_to_template_args (current_template_args (), arglist);
+
       arglist2 = coerce_template_parms (parmlist, arglist, template,
                                         complain, /*require_all_args=*/1);
       if (arglist2 == error_mark_node)
diff --git a/gcc/testsuite/g++.dg/template/ttp2.C b/gcc/testsuite/g++.dg/template/ttp2.C
new file mode 100644 (file)
index 0000000..45d9abd
--- /dev/null
@@ -0,0 +1,17 @@
+// Copyright (C) 2001 Free Software Foundation
+// Contributed by Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
+// { dg-do compile }
+
+template <class U> struct Alloc {};
+
+template <class T, class U = Alloc<T> > struct Vector {};
+
+template <template <class T, class U = Alloc<T> > class TT>
+struct C {
+       TT<int> tt;
+};
+
+int main()
+{
+       C<Vector> c;
+}