libiberty: Add support for D `typeof(*null)' types
authorIain Buclaw <ibuclaw@gdcproject.org>
Sun, 29 Aug 2021 17:00:33 +0000 (19:00 +0200)
committerIain Buclaw <ibuclaw@gdcproject.org>
Sun, 29 Aug 2021 23:14:18 +0000 (01:14 +0200)
The D language has a new bottom type `typeof(*null)'.  Null types were
also incorrectly being demangled as `none', this has been fixed to be
`typeof(null)'.

libiberty/ChangeLog:

* d-demangle.c (dlang_attributes): Handle typeof(*null).
(dlang_type): Likewise.  Demangle 'n' as typeof(null).
* testsuite/d-demangle-expected: Update tests.

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

index 822c758..c34f918 100644 (file)
@@ -573,9 +573,11 @@ dlang_attributes (string *decl, const char *mangled)
        case 'g':
        case 'h':
        case 'k':
+       case 'n':
          /* inout parameter is represented as 'Ng'.
             vector parameter is represented as 'Nh'.
-            return paramenter is represented as 'Nk'.
+            return parameter is represented as 'Nk'.
+            typeof(*null) parameter is represented as 'Nn'.
             If we see this, then we know we're really in the
             parameter list.  Rewind and break.  */
          mangled--;
@@ -787,6 +789,12 @@ dlang_type (string *decl, const char *mangled, struct dlang_info *info)
          string_append (decl, ")");
          return mangled;
        }
+      else if (*mangled == 'n') /* typeof(*null) */
+       {
+         mangled++;
+         string_append (decl, "typeof(*null)");
+         return mangled;
+       }
       else
        return NULL;
     case 'A': /* dynamic array (T[]) */
@@ -884,7 +892,7 @@ dlang_type (string *decl, const char *mangled, struct dlang_info *info)
     /* Basic types */
     case 'n':
       mangled++;
-      string_append (decl, "none");
+      string_append (decl, "typeof(null)");
       return mangled;
     case 'v':
       mangled++;
index ba0ffed..00036e7 100644 (file)
@@ -83,7 +83,11 @@ demangle.test(ulong)
 #
 --format=dlang
 _D8demangle4testFnZv
-demangle.test(none)
+demangle.test(typeof(null))
+#
+--format=dlang
+_D8demangle4testFNnZv
+demangle.test(typeof(*null))
 #
 --format=dlang
 _D8demangle4testFoZv