public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Iain Buclaw <ibuclaw@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-3214] libiberty: Add support for D `typeof(*null)' types
Date: Sun, 29 Aug 2021 23:42:41 +0000 (GMT)	[thread overview]
Message-ID: <20210829234241.A835A3858C3B@sourceware.org> (raw)

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


                 reply	other threads:[~2021-08-29 23:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210829234241.A835A3858C3B@sourceware.org \
    --to=ibuclaw@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).