re PR c++/55680 ([C++11] Member specialization with lambda is rejected)
authorJason Merrill <jason@redhat.com>
Thu, 14 Feb 2013 04:30:26 +0000 (23:30 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 14 Feb 2013 04:30:26 +0000 (23:30 -0500)
PR c++/55680
* pt.c (maybe_process_partial_specialization): A lambda
isn't what's being specialized.

From-SVN: r196042

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template8.C [new file with mode: 0644]

index 7cb0653cea159f71983595cd3a95bf59cd6e9648..d28a6049a81db12e7919c4f124180a8180f23983 100644 (file)
@@ -1,5 +1,9 @@
 2013-02-13  Jason Merrill  <jason@redhat.com>
 
+       PR c++/55680
+       * pt.c (maybe_process_partial_specialization): A lambda
+       isn't what's being specialized.
+
        PR c++/55710
        * semantics.c (maybe_add_lambda_conv_op): Mark static thunk
        TREE_USED.
index 2aadd4d0bf410766e156e10fbb0ea527327dd7f2..bd44fdebb8c3774c5296d69b27790a9d38f6d91c 100644 (file)
@@ -802,6 +802,11 @@ maybe_process_partial_specialization (tree type)
   if (type == error_mark_node)
     return error_mark_node;
 
+  /* A lambda that appears in specialization context is not itself a
+     specialization.  */
+  if (CLASS_TYPE_P (type) && CLASSTYPE_LAMBDA_EXPR (type))
+    return type;
+
   if (TREE_CODE (type) == BOUND_TEMPLATE_TEMPLATE_PARM)
     {
       error ("name of class shadows template template parameter %qD",
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template8.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template8.C
new file mode 100644 (file)
index 0000000..720941d
--- /dev/null
@@ -0,0 +1,7 @@
+// PR c++/55680
+// { dg-do compile { target c++11 } }
+
+template <class T> struct X {
+    static void (* code ) ();
+};
+template <> void (* X<int>::code ) () = [](){};