public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-3214] libiberty: Add support for D `typeof(*null)' types
@ 2021-08-29 23:42 Iain Buclaw
  0 siblings, 0 replies; only message in thread
From: Iain Buclaw @ 2021-08-29 23:42 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:0e32a5aa8bc967bc183142a596d0a6460be27438

commit r12-3214-g0e32a5aa8bc967bc183142a596d0a6460be27438
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Sun Aug 29 19:00:33 2021 +0200

    libiberty: Add support for D `typeof(*null)' types
    
    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.

Diff:
---
 libiberty/d-demangle.c                  | 12 ++++++++++--
 libiberty/testsuite/d-demangle-expected |  6 +++++-
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c
index 822c7580782..c34f91843de 100644
--- a/libiberty/d-demangle.c
+++ b/libiberty/d-demangle.c
@@ -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++;
diff --git a/libiberty/testsuite/d-demangle-expected b/libiberty/testsuite/d-demangle-expected
index ba0ffed5c8d..00036e7810a 100644
--- a/libiberty/testsuite/d-demangle-expected
+++ b/libiberty/testsuite/d-demangle-expected
@@ -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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-29 23:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-29 23:42 [gcc r12-3214] libiberty: Add support for D `typeof(*null)' types Iain Buclaw

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).