Message ID | 541C4E70.3000803@oracle.com |
---|---|
State | New |
Headers | show |
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. Jason
Index: cp/pt.c =================================================================== --- cp/pt.c (revision 215393) +++ cp/pt.c (working copy) @@ -4450,7 +4450,8 @@ check_default_tmpl_args (tree decl, tree parms, bo class template. */ 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. */ 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 ) + { + [](){}; + } +};