Commit fa0cdfb6 by Nathan Sidwell Committed by Nathan Sidwell

[demangler] Fix nested generic lambda

https://gcc.gnu.org/ml/gcc-patches/2017-09/msg00994.html
	PR demangler/82195
	* cp-demangle.c (d_name): Add 'toplevel' parm.  Pass to	...
	(d_local_name): ... here.  Parse trailing function args on nested
	local_name.
	(d_encoding, d_special_name, d_class_enum_type): Adjust d_name calls.
	* testsuite/demangle-expected: Add tests.

From-SVN: r252815
parent dc4b8c68
2017-09-15 Nathan Sidwell <nathan@acm.org>
PR demangler/82195
* cp-demangle.c (d_name): Add 'toplevel' parm. Pass to ...
(d_local_name): ... here. Parse trailing function args on nested
local_name.
(d_encoding, d_special_name, d_class_enum_type): Adjust d_name calls.
* testsuite/demangle-expected: Add tests.
2017-09-15 Richard Biener <rguenther@suse.de> 2017-09-15 Richard Biener <rguenther@suse.de>
PR lto/81968 PR lto/81968
...@@ -11,6 +20,8 @@ ...@@ -11,6 +20,8 @@
(d_encoding): Hold bare_function_type in local var. (d_encoding): Hold bare_function_type in local var.
(d_local_name): Build name in both cases and build result once. (d_local_name): Build name in both cases and build result once.
Collapse switch-if to single conditional. Collapse switch-if to single conditional.
(d_local_name):
* testsuite/demangle-expected: Realign blank lines with tests. * testsuite/demangle-expected: Realign blank lines with tests.
2017-09-12 Jiong Wang <jiong.wang@arm.com> 2017-09-12 Jiong Wang <jiong.wang@arm.com>
......
...@@ -425,7 +425,7 @@ is_ctor_dtor_or_conversion (struct demangle_component *); ...@@ -425,7 +425,7 @@ is_ctor_dtor_or_conversion (struct demangle_component *);
static struct demangle_component *d_encoding (struct d_info *, int); static struct demangle_component *d_encoding (struct d_info *, int);
static struct demangle_component *d_name (struct d_info *); static struct demangle_component *d_name (struct d_info *, int);
static struct demangle_component *d_nested_name (struct d_info *); static struct demangle_component *d_nested_name (struct d_info *);
...@@ -484,7 +484,7 @@ static struct demangle_component *d_expression (struct d_info *); ...@@ -484,7 +484,7 @@ static struct demangle_component *d_expression (struct d_info *);
static struct demangle_component *d_expr_primary (struct d_info *); static struct demangle_component *d_expr_primary (struct d_info *);
static struct demangle_component *d_local_name (struct d_info *); static struct demangle_component *d_local_name (struct d_info *, int);
static int d_discriminator (struct d_info *); static int d_discriminator (struct d_info *);
...@@ -1308,7 +1308,7 @@ d_encoding (struct d_info *di, int top_level) ...@@ -1308,7 +1308,7 @@ d_encoding (struct d_info *di, int top_level)
{ {
struct demangle_component *dc, *dcr; struct demangle_component *dc, *dcr;
dc = d_name (di); dc = d_name (di, top_level);
if (dc != NULL && top_level && (di->options & DMGL_PARAMS) == 0) if (dc != NULL && top_level && (di->options & DMGL_PARAMS) == 0)
{ {
...@@ -1383,7 +1383,7 @@ d_abi_tags (struct d_info *di, struct demangle_component *dc) ...@@ -1383,7 +1383,7 @@ d_abi_tags (struct d_info *di, struct demangle_component *dc)
*/ */
static struct demangle_component * static struct demangle_component *
d_name (struct d_info *di) d_name (struct d_info *di, int top_level)
{ {
char peek = d_peek_char (di); char peek = d_peek_char (di);
struct demangle_component *dc; struct demangle_component *dc;
...@@ -1394,7 +1394,7 @@ d_name (struct d_info *di) ...@@ -1394,7 +1394,7 @@ d_name (struct d_info *di)
return d_nested_name (di); return d_nested_name (di);
case 'Z': case 'Z':
return d_local_name (di); return d_local_name (di, top_level);
case 'U': case 'U':
return d_unqualified_name (di); return d_unqualified_name (di);
...@@ -2079,11 +2079,11 @@ d_special_name (struct d_info *di) ...@@ -2079,11 +2079,11 @@ d_special_name (struct d_info *di)
case 'H': case 'H':
return d_make_comp (di, DEMANGLE_COMPONENT_TLS_INIT, return d_make_comp (di, DEMANGLE_COMPONENT_TLS_INIT,
d_name (di), NULL); d_name (di, 0), NULL);
case 'W': case 'W':
return d_make_comp (di, DEMANGLE_COMPONENT_TLS_WRAPPER, return d_make_comp (di, DEMANGLE_COMPONENT_TLS_WRAPPER,
d_name (di), NULL); d_name (di, 0), NULL);
default: default:
return NULL; return NULL;
...@@ -2094,11 +2094,12 @@ d_special_name (struct d_info *di) ...@@ -2094,11 +2094,12 @@ d_special_name (struct d_info *di)
switch (d_next_char (di)) switch (d_next_char (di))
{ {
case 'V': case 'V':
return d_make_comp (di, DEMANGLE_COMPONENT_GUARD, d_name (di), NULL); return d_make_comp (di, DEMANGLE_COMPONENT_GUARD,
d_name (di, 0), NULL);
case 'R': case 'R':
{ {
struct demangle_component *name = d_name (di); struct demangle_component *name = d_name (di, 0);
return d_make_comp (di, DEMANGLE_COMPONENT_REFTEMP, name, return d_make_comp (di, DEMANGLE_COMPONENT_REFTEMP, name,
d_number_component (di)); d_number_component (di));
} }
...@@ -2934,7 +2935,7 @@ d_bare_function_type (struct d_info *di, int has_return_type) ...@@ -2934,7 +2935,7 @@ d_bare_function_type (struct d_info *di, int has_return_type)
static struct demangle_component * static struct demangle_component *
d_class_enum_type (struct d_info *di) d_class_enum_type (struct d_info *di)
{ {
return d_name (di); return d_name (di, 0);
} }
/* <array-type> ::= A <(positive dimension) number> _ <(element) type> /* <array-type> ::= A <(positive dimension) number> _ <(element) type>
...@@ -3567,7 +3568,7 @@ d_expr_primary (struct d_info *di) ...@@ -3567,7 +3568,7 @@ d_expr_primary (struct d_info *di)
*/ */
static struct demangle_component * static struct demangle_component *
d_local_name (struct d_info *di) d_local_name (struct d_info *di, int top_level)
{ {
struct demangle_component *function; struct demangle_component *function;
struct demangle_component *name; struct demangle_component *name;
...@@ -3600,14 +3601,30 @@ d_local_name (struct d_info *di) ...@@ -3600,14 +3601,30 @@ d_local_name (struct d_info *di)
return NULL; return NULL;
} }
name = d_name (di); name = d_name (di, 0);
if (name if (name
/* Lambdas and unnamed types have internal discriminators. */ /* Lambdas and unnamed types have internal discriminators
and are not functions. */
&& name->type != DEMANGLE_COMPONENT_LAMBDA && name->type != DEMANGLE_COMPONENT_LAMBDA
&& name->type != DEMANGLE_COMPONENT_UNNAMED_TYPE && name->type != DEMANGLE_COMPONENT_UNNAMED_TYPE)
/* Otherwise read and ignore an optional discriminator. */ {
&& ! d_discriminator (di)) if (!top_level
return NULL; && d_peek_char (di) != 0 /* Not end of string. */
&& d_peek_char (di) != 'E' /* Not end of nested encoding. */
&& d_peek_char (di) != '_') /* Not discriminator. */
{
struct demangle_component *args;
args = d_bare_function_type (di, has_return_type (name));
name = d_make_comp (di, DEMANGLE_COMPONENT_TYPED_NAME,
name, args);
}
/* Read and ignore an optional discriminator. */
if (! d_discriminator (di))
return NULL;
}
if (num >= 0) if (num >= 0)
name = d_make_default_arg (di, num, name); name = d_make_default_arg (di, num, name);
......
...@@ -4736,3 +4736,17 @@ __thunk_16a_$_1x ...@@ -4736,3 +4736,17 @@ __thunk_16a_$_1x
__thunk_4294967297__$_1x __thunk_4294967297__$_1x
__thunk_4294967297__$_1x __thunk_4294967297__$_1x
# #
# demangler/82195 members of lambdas
--no-params
_ZZZ3FoovENKUlT_E_clIiEEfS_EN5Local2fnEv
Foo()::float {lambda(auto:1)#1}::operator()<int>(int) const::Local::fn()
Foo()::float {lambda(auto:1)#1}::operator()<int>(int) const::Local::fn
--no-params
_Z7CaptureIZZ3FoovENKUlT_E_clIiEEvS0_EUlvE_EvOS0_
void Capture<Foo()::void {lambda(auto:1)#1}::operator()<int>(int) const::{lambda()#1}>(Foo()::void {lambda(auto:1)#1}::operator()<int>(int) const::{lambda()#1}&&)
Capture<Foo()::void {lambda(auto:1)#1}::operator()<int>(int) const::{lambda()#1}>
--no-params
_Z4FrobIZZ3FoovENKUlT_E_clIiEEvS0_EUlvE_Evv
void Frob<Foo()::void {lambda(auto:1)#1}::operator()<int>(int) const::{lambda()#1}>()
Frob<Foo()::void {lambda(auto:1)#1}::operator()<int>(int) const::{lambda()#1}>
#
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment