struct d_print_mod *modifiers;
/* Set to 1 if we saw a demangling error. */
int demangle_failure;
+ /* Non-zero if we're printing a lambda argument. A template
+ parameter reference actually means 'auto'. */
+ int is_lambda_arg;
/* The current index into any template argument packs we are using
for printing, or -1 to print the whole pack. */
int pack_index;
dpi->opaque = opaque;
dpi->demangle_failure = 0;
+ dpi->is_lambda_arg = 0;
dpi->component_stack = NULL;
}
case DEMANGLE_COMPONENT_TEMPLATE_PARAM:
- {
- struct d_print_template *hold_dpt;
- struct demangle_component *a = d_lookup_template_argument (dpi, dc);
-
- if (a && a->type == DEMANGLE_COMPONENT_TEMPLATE_ARGLIST)
- a = d_index_template_argument (a, dpi->pack_index);
+ if (dpi->is_lambda_arg)
+ {
+ /* Show the template parm index, as that's how g++ displays
+ these, and future proofs us against potential
+ '[]<typename T> (T *a, T *b) {...}'. */
+ d_append_buffer (dpi, "auto:", 5);
+ d_append_num (dpi, dc->u.s_number.number + 1);
+ }
+ else
+ {
+ struct d_print_template *hold_dpt;
+ struct demangle_component *a = d_lookup_template_argument (dpi, dc);
- if (a == NULL)
- {
- d_print_error (dpi);
- return;
- }
+ if (a && a->type == DEMANGLE_COMPONENT_TEMPLATE_ARGLIST)
+ a = d_index_template_argument (a, dpi->pack_index);
- /* While processing this parameter, we need to pop the list of
- templates. This is because the template parameter may
- itself be a reference to a parameter of an outer
- template. */
+ if (a == NULL)
+ {
+ d_print_error (dpi);
+ return;
+ }
- hold_dpt = dpi->templates;
- dpi->templates = hold_dpt->next;
+ /* While processing this parameter, we need to pop the list
+ of templates. This is because the template parameter may
+ itself be a reference to a parameter of an outer
+ template. */
- d_print_comp (dpi, options, a);
+ hold_dpt = dpi->templates;
+ dpi->templates = hold_dpt->next;
- dpi->templates = hold_dpt;
+ d_print_comp (dpi, options, a);
- return;
- }
+ dpi->templates = hold_dpt;
+ }
+ return;
case DEMANGLE_COMPONENT_CTOR:
d_print_comp (dpi, options, dc->u.s_ctor.name);
{
/* Handle reference smashing: & + && = &. */
const struct demangle_component *sub = d_left (dc);
- if (sub->type == DEMANGLE_COMPONENT_TEMPLATE_PARAM)
+ if (!dpi->is_lambda_arg
+ && sub->type == DEMANGLE_COMPONENT_TEMPLATE_PARAM)
{
struct d_saved_scope *scope = d_get_saved_scope (dpi, sub);
struct demangle_component *a;
case DEMANGLE_COMPONENT_LAMBDA:
d_append_string (dpi, "{lambda(");
+ /* Generic lambda auto parms are mangled as the template type
+ parm they are. */
+ dpi->is_lambda_arg++;
d_print_comp (dpi, options, dc->u.s_unary_num.sub);
+ dpi->is_lambda_arg--;
d_append_string (dpi, ")#");
d_append_num (dpi, dc->u.s_unary_num.num + 1);
d_append_char (dpi, '}');
# ?: expression with missing third component could crash.
AquT_quT_4mxautouT_4mxxx
AquT_quT_4mxautouT_4mxxx
+
+# pr c++/78252 generic lambda mangling uses template parms, and leads
+# to unbounded recursion if not dealt with properly
+_Z7forwardIRZ3FoovEUlRT_E_EOS0_S1_
+Foo()::{lambda(auto:1&)#1}& forward<Foo()::{lambda(auto:1&)#1}&>(Foo()::{lambda(auto:1&)#1}&)
+
+_Z7forwardIZ3FoovEUlRiRT_E_EOS1_S2_
+Foo()::{lambda(int&, auto:1&)#1}&& forward<Foo()::{lambda(int&, auto:1&)#1}>(Foo()::{lambda(int&, auto:1&)#1}&)
+
+_Z7forwardIZ3FoovEUlRT_R1XIiEE0_EOS0_S1_
+Foo()::{lambda(auto:1&, X<int>&)#2}&& forward<Foo()::{lambda(auto:1&, X<int>&)#2}>(Foo()::{lambda(auto:1&, X<int>&)#2}&)
+
+_Z7forwardIZ3FoovEUlPA5_T_E1_EOS0_RS0_
+Foo()::{lambda(auto:1 (*&&forward<Foo()::{lambda(auto:1 (*) [5])#3}>(auto:1&)) [5])#3}
+
+_Z3eatIZ3FoovEUlRiRT_E_EvS2_
+void eat<Foo()::{lambda(int&, auto:1&)#1}>(Foo()::{lambda(int&, auto:1&)#1}&)
+
+_Z3eatIZ3FoovEUlRT_R1XIiEE0_EvS1_
+void eat<Foo()::{lambda(auto:1&, X<int>&)#2}>(Foo()::{lambda(auto:1&, X<int>&)#2}&)
+
+_Z3eatIZ3FoovEUlPA5_T_E1_EvRS0_
+void eat<Foo()::{lambda(auto:1 (*) [5])#3}>(Foo()::{lambda(auto:1 (*&) [5])#3})
+
+_Z3eatIPiZ3FoovEUlPT_PT0_E4_EvRS1_RS3_
+void eat<int*, Foo()::{lambda(auto:1*, auto:2*)#6}>(int*&, Foo()::{lambda(auto:1*, auto:2*)#6}&)
+
+_Z3eatIPiZ3BarIsEvvEUlPsPT_PT0_E0_EvRS3_RS5_
+void eat<int*, void Bar<short>()::{lambda(short*, auto:1*, auto:2*)#2}>(int*&, void Bar<short>()::{lambda(short*, auto:1*, auto:2*)#2}&)