/* Demangler for g++ V3 ABI.
- Copyright (C) 2003-2024 Free Software Foundation, Inc.
+ Copyright (C) 2003-2025 Free Software Foundation, Inc.
Written by Ian Lance Taylor <ian@wasabisystems.com>.
This file is part of the libiberty library, which is part of GCC.
static struct demangle_component *d_unnamed_type (struct d_info *);
+static struct demangle_component *d_unnamed_enum (struct d_info *);
+
static struct demangle_component *
d_clone_suffix (struct d_info *, struct demangle_component *);
/* If this is a non-top-level local-name, clear the
return type, so it doesn't confuse the user by
- being confused with the return type of whaever
+ being confused with the return type of whatever
this is nested within. */
if (!top_level && dc->type == DEMANGLE_COMPONENT_LOCAL_NAME
&& ftype->type == DEMANGLE_COMPONENT_FUNCTION_TYPE)
{
switch (d_peek_next_char (di))
{
+ case 'e':
+ ret = d_unnamed_enum (di);
+ break;
case 'l':
ret = d_lambda (di);
break;
break;
case 'U':
- d_advance (di, 1);
- ret = d_source_name (di);
- if (d_peek_char (di) == 'I')
- ret = d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, ret,
- d_template_args (di));
- ret = d_make_comp (di, DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL,
- cplus_demangle_type (di), ret);
+ peek = d_peek_next_char (di);
+ if (IS_DIGIT (peek))
+ {
+ d_advance (di, 1);
+ ret = d_source_name (di);
+ if (d_peek_char (di) == 'I')
+ ret = d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, ret,
+ d_template_args (di));
+ ret = d_make_comp (di, DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL,
+ cplus_demangle_type (di), ret);
+ }
+ else
+ /* Could be a closure type or an unnamed enum. */
+ ret = d_unqualified_name (di, NULL, NULL);
break;
case 'D':
return ret;
}
+/* <unnamed-enum-name> ::= Ue <underlying type> <enumerator source-name> */
+
+static struct demangle_component *
+d_unnamed_enum (struct d_info *di)
+{
+ if (! d_check_char (di, 'U'))
+ return NULL;
+ if (! d_check_char (di, 'e'))
+ return NULL;
+
+ struct demangle_component *underlying = cplus_demangle_type (di);
+ struct demangle_component *name = d_source_name (di);
+
+ struct demangle_component *ret = d_make_empty (di);
+ if (ret)
+ {
+ ret->type = DEMANGLE_COMPONENT_UNNAMED_ENUM;
+ d_left (ret) = underlying;
+ d_right (ret) = name;
+ }
+
+ if (! d_add_substitution (di, ret))
+ return NULL;
+
+ return ret;
+}
+
/* <clone-suffix> ::= [ . <clone-type-identifier> ] [ . <nonnegative number> ]*
*/
case DEMANGLE_COMPONENT_CHARACTER:
case DEMANGLE_COMPONENT_NUMBER:
case DEMANGLE_COMPONENT_UNNAMED_TYPE:
+ case DEMANGLE_COMPONENT_UNNAMED_ENUM:
case DEMANGLE_COMPONENT_STRUCTURED_BINDING:
case DEMANGLE_COMPONENT_MODULE_NAME:
case DEMANGLE_COMPONENT_MODULE_PARTITION:
case DEMANGLE_COMPONENT_CHARACTER:
case DEMANGLE_COMPONENT_FUNCTION_PARAM:
case DEMANGLE_COMPONENT_UNNAMED_TYPE:
+ case DEMANGLE_COMPONENT_UNNAMED_ENUM:
case DEMANGLE_COMPONENT_DEFAULT_ARG:
case DEMANGLE_COMPONENT_NUMBER:
return NULL;
d_append_char (dpi, '}');
return;
+ case DEMANGLE_COMPONENT_UNNAMED_ENUM:
+ d_append_string (dpi, "{enum:");
+ d_print_comp (dpi, options, d_left (dc));
+ d_append_string (dpi, "{");
+ d_print_comp (dpi, options, d_right (dc));
+ d_append_string (dpi, "}}");
+ return;
+
case DEMANGLE_COMPONENT_CLONE:
d_print_comp (dpi, options, d_left (dc));
d_append_string (dpi, " [clone ");