When we have a lambda-expression in the initializer for a specialization
of a class template static data member, we end up in
maybe_process_partial_specialization, which sees that
processing_specialization is set and concludes that we're trying to
specialize the lambda. But we aren't.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit 1631ee6dca428836c7733e5d78e8644af2058ae7
Author: Jason Merrill <ja...@redhat.com>
Date: Wed Feb 13 13:25:20 2013 -0500
PR c++/55680
* pt.c (maybe_process_partial_specialization): A lambda
isn't what's being specialized.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 2aadd4d..bd44fde 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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
index 0000000..720941d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template8.C
@@ -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 ) () = [](){};