This implements another previously undocumented part of the D ABI
spec, where symbols with no name are always encoded into the mangled
name.

    SymbolName:
        LName
        TemplateInstanceName
        0             // anonymous symbols

This has never really been a problem, as strtol() kindly jumps over
any leading zeros in the number it is parsing.  However this change
makes it so they are at least explicitly skipped over, rather than
silently ignored.

---
commit 6ffcb4ce75e471304960c97bec596c89e26894f8
Author: Iain Buclaw <ibuc...@gdcproject.org>
Date:   Sat Apr 15 11:32:07 2017 +0200

    libiberty/ChangeLog:
    
    2017-04-15  Iain Buclaw  <ibuc...@gdcproject.org>
    
    	* d-demangle.c (dlang_parse_symbol): Skip over anonymous symbols.
    	* testsuite/d-demangle-expected: Add tests.

diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c
index 74dde9d..533653f 100644
--- a/libiberty/d-demangle.c
+++ b/libiberty/d-demangle.c
@@ -1362,6 +1362,10 @@ dlang_parse_symbol (string *decl, const char *mangled,
       if (n++)
 	string_append (decl, ".");
 
+      /* Skip over anonymous symbols.  */
+      while (*mangled == '0')
+	mangled++;
+
       mangled = dlang_identifier (decl, mangled, kind);
 
       if (mangled && dlang_call_convention_p (mangled))
diff --git a/libiberty/testsuite/d-demangle-expected b/libiberty/testsuite/d-demangle-expected
index 6725684..530e0e6 100644
--- a/libiberty/testsuite/d-demangle-expected
+++ b/libiberty/testsuite/d-demangle-expected
@@ -929,6 +929,14 @@ demangle.test(char() delegate shared inout)
 _D8demangle4testFDONgxFZaZv
 demangle.test(char() delegate shared inout const)
 #
+--format=dlang
+_D8demangle004testFaZv
+demangle.test(char)
+#
+--format=dlang
+_D8demangle000000004testFaZv
+demangle.test(char)
+#
 # Unittests
 #
 --format=dlang

Reply via email to