Hi,
On 09/19/2014 07:32 PM, Jason Merrill wrote:
On 09/19/2014 11:40 AM, Paolo Carlini wrote:
if (TREE_CODE (CP_DECL_CONTEXT (decl)) == FUNCTION_DECL
- || (TREE_CODE (decl) == FUNCTION_DECL && DECL_LOCAL_FUNCTION_P
(decl)))
+ || (TREE_CODE (decl) == FUNCTION_DECL
+ && (DECL_LOCAL_FUNCTION_P (decl) || LAMBDA_FUNCTION_P (decl))))
/* You can't have a function template declaration in a local
scope, nor you can you define a member of a class template in a
local scope. */
Rather than adding it to this condition, let's group the new test with
the other lambda test, immediately below.
Yeah, I was unsure about that. By the way, we fixed c++/60605 even in
4.8, what about 4.8 and 4.9?
Thanks,
Paolo.
////////////////////
/cp
2014-09-19 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/62219
* pt.c (check_default_tmpl_args): Check LAMBDA_FUNCTION_P.
/testsuite
2014-09-19 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/62219
* g++.dg/cpp0x/lambda/lambda-template14.C: New.
Index: cp/pt.c
===================================================================
--- cp/pt.c (revision 215393)
+++ cp/pt.c (working copy)
@@ -4456,9 +4456,11 @@ check_default_tmpl_args (tree decl, tree parms, bo
local scope. */
return true;
- if (TREE_CODE (decl) == TYPE_DECL
- && TREE_TYPE (decl)
- && LAMBDA_TYPE_P (TREE_TYPE (decl)))
+ if ((TREE_CODE (decl) == TYPE_DECL
+ && TREE_TYPE (decl)
+ && LAMBDA_TYPE_P (TREE_TYPE (decl)))
+ || (TREE_CODE (decl) == FUNCTION_DECL
+ && LAMBDA_FUNCTION_P (decl)))
/* A lambda doesn't have an explicit declaration; don't complain
about the parms of the enclosing class. */
return true;
Index: testsuite/g++.dg/cpp0x/lambda/lambda-template14.C
===================================================================
--- testsuite/g++.dg/cpp0x/lambda/lambda-template14.C (revision 0)
+++ testsuite/g++.dg/cpp0x/lambda/lambda-template14.C (working copy)
@@ -0,0 +1,11 @@
+// PR c++/62219
+// { dg-do compile { target c++11 } }
+
+template< class = void >
+struct S
+{
+ friend void foo( S )
+ {
+ [](){};
+ }
+};