aboutsummaryrefslogtreecommitdiff
path: root/libiberty
diff options
context:
space:
mode:
Diffstat (limited to 'libiberty')
-rw-r--r--libiberty/ChangeLog22
-rw-r--r--libiberty/cp-demangle.c65
-rw-r--r--libiberty/testsuite/demangle-expected7
-rw-r--r--libiberty/testsuite/test-doubly-linked-list.c13
4 files changed, 96 insertions, 11 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index cf90917..84edafa 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,25 @@
+2025-08-17 Nathaniel Shead <nathanieloshead@gmail.com>
+
+ PR c++/120503
+ PR c++/120824
+ * cp-demangle.c (d_unnamed_enum): New function.
+ (d_unqualified_name): Call it.
+ (cplus_demangle_type): Handle unscoped unnamed types
+ (Ue, Ul, etc.)
+ (d_count_templates_scopes): Handle unnamed enums.
+ (d_find_pack): Likewise.
+ (d_print_comp_inner): Print unnamed enums.
+ * testsuite/demangle-expected: Add tests.
+
+2025-08-13 Jakub Jelinek <jakub@redhat.com>
+
+ * cp-demangle.c (d_encoding): Fix a comment typo, whaever -> whatever.
+
+2025-08-06 Matthieu Longo <matthieu.longo@arm.com>
+
+ * testsuite/test-doubly-linked-list.c: disable debug logging on
+ stdout.
+
2025-07-09 Matthieu Longo <matthieu.longo@arm.com>
* Makefile.in: Add new header.
diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index 1922046..8b4c6d1 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -499,6 +499,8 @@ static struct demangle_component *d_lambda (struct d_info *);
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 *);
@@ -1424,7 +1426,7 @@ d_encoding (struct d_info *di, int top_level)
/* 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)
@@ -1799,6 +1801,9 @@ d_unqualified_name (struct d_info *di, struct demangle_component *scope,
{
switch (d_peek_next_char (di))
{
+ case 'e':
+ ret = d_unnamed_enum (di);
+ break;
case 'l':
ret = d_lambda (di);
break;
@@ -2728,13 +2733,20 @@ cplus_demangle_type (struct d_info *di)
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':
@@ -4090,6 +4102,33 @@ d_unnamed_type (struct d_info *di)
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> ]*
*/
@@ -4396,6 +4435,7 @@ d_count_templates_scopes (struct d_print_info *dpi,
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:
@@ -4780,6 +4820,7 @@ d_find_pack (struct d_print_info *dpi,
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;
@@ -6258,6 +6299,14 @@ d_print_comp_inner (struct d_print_info *dpi, int options,
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 ");
diff --git a/libiberty/testsuite/demangle-expected b/libiberty/testsuite/demangle-expected
index 0f7b97a..e5cd8ec 100644
--- a/libiberty/testsuite/demangle-expected
+++ b/libiberty/testsuite/demangle-expected
@@ -1709,3 +1709,10 @@ void S::bar<5, int>(this S, int)
_ZNH1S3bazERKS_
S::baz(this S const&)
+
+_Z3fooUlvE_
+foo({lambda()#1})
+
+# P2115R0 unnamed enums
+_Z3fooUei1ES_
+foo({enum:int{E}}, {enum:int{E}})
diff --git a/libiberty/testsuite/test-doubly-linked-list.c b/libiberty/testsuite/test-doubly-linked-list.c
index 1e1fc63..93fe19a 100644
--- a/libiberty/testsuite/test-doubly-linked-list.c
+++ b/libiberty/testsuite/test-doubly-linked-list.c
@@ -155,19 +155,26 @@ bool check(const char *op,
bool success = true;
bool res;
- l_print (wrapper->first);
+#define DUMP_LIST 0
+
+ if (DUMP_LIST)
+ l_print (wrapper->first);
+
res = run_test (expect, wrapper, false);
printf ("%s: test-linked-list::%s: check forward conformity\n",
res ? "PASS": "FAIL", op);
success &= res;
- l_reverse_print (wrapper->last);
+ if (DUMP_LIST)
+ l_reverse_print (wrapper->last);
+
res = run_test (expect, wrapper, true);
printf ("%s: test-linked-list::%s: check backward conformity\n",
res ? "PASS": "FAIL", op);
success &= res;
- printf("\n");
+ if (DUMP_LIST)
+ printf("\n");
return success;
}