+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>
PR lto/81968
(d_encoding): Hold bare_function_type in local var.
(d_local_name): Build name in both cases and build result once.
Collapse switch-if to single conditional.
+ (d_local_name):
+
* testsuite/demangle-expected: Realign blank lines with tests.
2017-09-12 Jiong Wang <jiong.wang@arm.com>
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_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 *);
{
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)
{
*/
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);
struct demangle_component *dc;
return d_nested_name (di);
case 'Z':
- return d_local_name (di);
+ return d_local_name (di, top_level);
case 'U':
return d_unqualified_name (di);
case 'H':
return d_make_comp (di, DEMANGLE_COMPONENT_TLS_INIT,
- d_name (di), NULL);
+ d_name (di, 0), NULL);
case 'W':
return d_make_comp (di, DEMANGLE_COMPONENT_TLS_WRAPPER,
- d_name (di), NULL);
+ d_name (di, 0), NULL);
default:
return NULL;
switch (d_next_char (di))
{
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':
{
- struct demangle_component *name = d_name (di);
+ struct demangle_component *name = d_name (di, 0);
return d_make_comp (di, DEMANGLE_COMPONENT_REFTEMP, name,
d_number_component (di));
}
static struct demangle_component *
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>
*/
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 *name;
return NULL;
}
- name = d_name (di);
+ name = d_name (di, 0);
+
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_UNNAMED_TYPE
- /* Otherwise read and ignore an optional discriminator. */
- && ! d_discriminator (di))
- return NULL;
+ && name->type != DEMANGLE_COMPONENT_UNNAMED_TYPE)
+ {
+ if (!top_level
+ && 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)
name = d_make_default_arg (di, num, name);