This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/2] PR c++/64382 * cp/parser.c (parsing_default_capturing_generic_lambda_in_template): New function. * cp/cp-tree.h: Declare it. * cp/semantics.c (finish_id_expression): Resolve names within a default capturing generic lambda defined within a template prior to instantiation to allow for captures to be added to the closure type.


On Fri, Apr 10, 2015 at 04:31:34AM +0100, Adam Butcher wrote:
> +/* Return true iff our current scope is a default capturing generic lambda
> +   defined within a template.  */
> +
> +bool
> +parsing_default_capturing_generic_lambda_in_template (void)
> +{
> +  if (processing_template_decl && current_class_type)
> +    if (tree lam = CLASSTYPE_LAMBDA_EXPR (current_class_type))
> +      if (LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (lam) != CPLD_NONE)
> +	if (tree callop = lambda_function (lam))
> +	  if (DECL_TEMPLATE_INFO (callop)
> +	      && (DECL_TEMPLATE_RESULT (DECL_TI_TEMPLATE (callop))
> +		  == callop)
> +	      && ((current_nonlambda_class_type ()
> +		   && CLASSTYPE_TEMPLATE_INFO (current_nonlambda_class_type ()))
> +		  || ((current_nonlambda_function ()
> +		       && DECL_TEMPLATE_INFO (current_nonlambda_function ())))))
> +	    return true;
> +  return false;
> +}
> +

Eek, why not &&s rather than cascading ifs?

> +++ b/gcc/testsuite/g++.dg/cpp1y/pr64382.C
> @@ -0,0 +1,23 @@
> +// PR c++/64382
> +// { dg-do compile { target c++1y } }

I think better use c++14 now.

	Marek


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]