On 2025-11-29 15:30, Jason Merrill wrote:

> Once we enter cp_parser_placeholder_type_specifier with
> parser->auto_is_implicit_function_template_parm_p we know we're dealing with
> an abbreviated function template, no need to wait until we actually see the
> 'auto'.
> 
> > > In the meantime I think it'd be good to document in tsubst_expr that
> > > TARGET_EXPR is deliberately not handled since it's not a valid templated
> > > tree.
> 
> Indeed.  Perhaps with a separate gcc_unreachable case.

Thanks for the input Jason!

I tried this in cp_parser_simple_type_specifier but the lambda still
becomes a TARGET_EXPR:

+         if (parser->auto_is_implicit_function_template_parm_p)
+           ++processing_template_decl;

          cp_parser_parse_tentatively (parser);

          type = cp_parser_template_id (parser,
                                        /*template_keyword_p=*/false,
                                        /*check_dependency_p=*/true,
                                        none_type,
                                        /*is_declaration=*/false);

+         if (parser->auto_is_implicit_function_template_parm_p)
+           --processing_template_decl;

Additionally, when cp_parser_placeholder_type_specifier receives the 
TEMPLATE_ID_EXPR, it already contains the semantic TARGET_EXPR tree.

I looked around for alternative fixes, but I'm not sure how to force the
lambda to be parsed as a syntactic tree, or how to convert the current 
TARGET_EXPR tree into a syntactic form.

Any suggestions on the right approach?

Reply via email to