]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/57222 (Template alias not working in argument of template class template...
authorJason Merrill <jason@redhat.com>
Thu, 9 May 2013 16:43:49 +0000 (12:43 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 9 May 2013 16:43:49 +0000 (12:43 -0400)
PR c++/57222
* pt.c (lookup_template_class_1): Handle getting a template
template parameter as D1.

From-SVN: r198747

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp0x/alias-decl-34.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/crash84.C

index 74480f65339f69fceb926682b8a09bb5185fdea8..a254a8e74e2d30a71ecf9b114b8e2b89afc924ac 100644 (file)
@@ -1,5 +1,9 @@
 2013-05-09  Jason Merrill  <jason@redhat.com>
 
+       PR c++/57222
+       * pt.c (lookup_template_class_1): Handle getting a template
+       template parameter as D1.
+
        N3639 C++1y VLA diagnostics
        * decl.c (grokdeclarator): Complain about reference, pointer, or
        typedef to VLA.
index 2cb2abd213fb78744b85960572c3e707bc246014..0747de62df61ac1fdba5dc053ada952bfde6414a 100644 (file)
@@ -7016,7 +7016,7 @@ maybe_get_template_decl_from_type_decl (tree decl)
     ? CLASSTYPE_TI_TEMPLATE (TREE_TYPE (decl)) : decl;
 }
 
-/* Given an IDENTIFIER_NODE (type TEMPLATE_DECL) and a chain of
+/* Given an IDENTIFIER_NODE (or type TEMPLATE_DECL) and a chain of
    parameters, find the desired type.
 
    D1 is the PTYPENAME terminal, and ARGLIST is the list of arguments.
@@ -7097,6 +7097,11 @@ lookup_template_class_1 (tree d1, tree arglist, tree in_decl, tree context,
       d1 = DECL_NAME (templ);
       context = DECL_CONTEXT (templ);
     }
+  else if (DECL_TEMPLATE_TEMPLATE_PARM_P (d1))
+    {
+      templ = d1;
+      d1 = DECL_NAME (templ);
+    }
 
   /* Issue an error message if we didn't find a template.  */
   if (! templ)
diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-34.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-34.C
new file mode 100644 (file)
index 0000000..4306ab7
--- /dev/null
@@ -0,0 +1,23 @@
+// PR c++/57222
+// { dg-require-effective-target c++11 }
+
+template <template <typename T> class Templ>
+using Bool = Templ<bool>;
+
+template <typename T>
+class Foo {
+private:
+public:
+    template<template<typename U> class Templ>
+    void method(Bool<Templ> boolTempl);
+};
+
+template <typename T>
+template <template <typename U> class Templ>
+void Foo<T>::method(Bool<Templ> boolTempl) {
+}
+
+int main() {
+    Foo<char> foo;
+    return 0;
+}
index c42f85ce550b39cc40aa01070c36e5dddda0314d..103e90a7076cd43271cef57630952bf4b66727d6 100644 (file)
@@ -5,7 +5,7 @@
 template<typename T> struct a
 {
     template <template <typename> class C, typename X, C<X>* =0>
-    struct b // { dg-error "class C' is not a template|is not a valid type" }
+    struct b
     {
     };
 };
@@ -13,7 +13,8 @@ template<typename T> struct a
 void
 foo ()
 {
-    a<int> v; // { dg-message "required from here" }
+  a<int> a1; // OK
+  a<int>::b<a,int> b1; // { dg-error "template argument" }
 }
 
-
+// { dg-prune-output "invalid type in declaration" }