OSDN Git Service

PR c++/10552
authorlerdsuwa <lerdsuwa@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 11 May 2003 09:45:30 +0000 (09:45 +0000)
committerlerdsuwa <lerdsuwa@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 11 May 2003 09:45:30 +0000 (09:45 +0000)
* pt.c (tsubst_copy): Handle TEMPLATE_DECL that is a member class
template and has dependent context.

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

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

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

index 77cfaac..9aa822b 100644 (file)
@@ -1,3 +1,9 @@
+2003-05-11  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       PR c++/10552
+       * pt.c (tsubst_copy): Handle TEMPLATE_DECL that is a member class
+       template and has dependent context.
+
 2003-05-10  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
 
        * pt.c (instantiate_decl): Call push/pop_deferring_access_checks.
index b4a9729..efc3774 100644 (file)
@@ -7294,7 +7294,29 @@ tsubst_copy (t, args, complain, in_decl)
                       args, complain, in_decl);
       else if (is_member_template (t))
        return tsubst (t, args, complain, in_decl);
+      else if (DECL_CLASS_SCOPE_P (t)
+              && uses_template_parms (DECL_CONTEXT (t)))
+       {
+         /* Template template argument like the following example need
+            special treatment:
+
+              template <template <class> class TT> struct C {};
+              template <class T> struct D {
+                template <class U> struct E {};
+                C<E> c;                                // #1
+              };
+              D<int> d;                                // #2
+
+            We are processing the template argument `E' in #1 for
+            the template instantiation #2.  Originally, `E' is a
+            TEMPLATE_DECL with `D<T>' as its DECL_CONTEXT.  Now we
+            have to substitute this with one having context `D<int>'.  */
+
+         tree context = tsubst (DECL_CONTEXT (t), args, complain, in_decl);
+         return lookup_field (context, DECL_NAME(t), 0, false);
+       }
       else
+       /* Ordinary template template argument.  */
        return t;
 
     case LOOKUP_EXPR:
index 7493ddf..ade2507 100644 (file)
@@ -1,3 +1,8 @@
+2003-05-11  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
+
+       PR c++/10552
+       * g++.dg/template/ttp6.C: New test.
+
 2003-05-11  Richard Sandiford  <rsandifo@redhat.com>
 
        * gcc.c-torture/execute/builtins: New directory.
diff --git a/gcc/testsuite/g++.dg/template/ttp6.C b/gcc/testsuite/g++.dg/template/ttp6.C
new file mode 100644 (file)
index 0000000..a4c6ab0
--- /dev/null
@@ -0,0 +1,21 @@
+// { dg-do compile }
+
+// Origin: Eelis van der Weegen <gccbugs@contacts.eelis.net>
+
+// PR c++/10552: Member class template as template template argument
+// substitution issue.
+
+template <template <typename> class A, typename>
+struct B
+{
+  typedef typename A<int>::t t;
+};
+
+template <typename D>
+struct E
+{
+  template <typename> struct F { typedef int t; };
+  typedef typename B<F, D>::t t;
+};
+
+typedef E<int>::t t;