This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
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.
- From: Marek Polacek <polacek at redhat dot com>
- To: Adam Butcher <adam at jessamine dot co dot uk>
- Cc: Jason Merrill <jason at redhat dot com>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 14 Apr 2015 09:16:32 +0200
- Subject: 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.
- Authentication-results: sourceware.org; auth=none
- References: <1428636694-6767-1-git-send-email-adam at jessamine dot co dot uk> <1428636694-6767-3-git-send-email-adam at jessamine dot co dot uk>
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