[PATCH] d-demangle: properly skip anonymous symbols
authorLuís Ferreira <contact@lsferreira.net>
Sun, 17 Oct 2021 22:34:25 +0000 (18:34 -0400)
committerJeff Law <jeffreyalaw@gmail.com>
Sun, 17 Oct 2021 22:38:10 +0000 (18:38 -0400)
libiberty/
PR d/102618
* d-demangle.c (dlang_parse_qualified): Handle anonymous
symbols correctly.

* testsuite/d-demangle-expected: New tests to cover anonymous
symbols.

libiberty/d-demangle.c
libiberty/testsuite/d-demangle-expected

index 880f2ec..6c7ac5a 100644 (file)
@@ -1650,13 +1650,19 @@ dlang_parse_qualified (string *decl, const char *mangled,
   size_t n = 0;
   do
     {
+      /* Skip over anonymous symbols.  */
+      if (*mangled == '0')
+      {
+       do
+         mangled++;
+       while (*mangled == '0');
+
+       continue;
+      }
+
       if (n++)
        string_append (decl, ".");
 
-      /* Skip over anonymous symbols.  */
-      while (*mangled == '0')
-       mangled++;
-
       mangled = dlang_identifier (decl, mangled, info);
 
       /* Consume the encoded arguments.  However if this is not followed by the
index e1b296f..47b059c 100644 (file)
@@ -1462,3 +1462,11 @@ mod.func().nested!(int).nested()
 --format=dlang
 _D6mangle__T8fun21753VSQv6S21753S1f_DQBj10__lambda71MFNaNbNiNfZvZQCbQp
 mangle.fun21753!(mangle.S21753(mangle.__lambda71())).fun21753
+#
+--format=dlang
+_D8demangle9anonymous0Z
+demangle.anonymous
+#
+--format=dlang
+_D8demangle9anonymous03fooZ
+demangle.anonymous.foo