This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 5/7] [D] libiberty: Add support for return parameter and attributes


The next version of D introduces two new mangle conventions.

- Nj to represent methods whose 'this' parameter is also the function
return value
- Nk to represent a 'ref' parameter that is also the function return value

This patch introduces support for these two symbols.

---
libiberty/ChangeLog:

2015-05-13 Iain Buclaw  <ibuclaw@gdcproject.org>

    * d-demangle.c (dlang_attributes): Handle return attributes, ignoring
    return parameters in the mangled string.  Return NULL if have encountered
    an unknown attribute.
    (dlang_function_args): Handle return parameters in the mangled string.
    * testsuite/d-demangle-expected: Add coverage tests for functions with
    return parameters and return attributes.
From 8d4f404a7181390983aef485e1bcb7d568d9751d Mon Sep 17 00:00:00 2001
From: Iain Buclaw <ibuclaw@gdcproject.org>
Date: Mon, 11 May 2015 09:22:21 +0200
Subject: [PATCH 5/7] D demangle: Add support for return parameter and
 attribute symbols

---
 libiberty/d-demangle.c                  | 15 +++++++++++++
 libiberty/testsuite/d-demangle-expected | 40 +++++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+)

diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c
index 4315071..0af926c 100644
--- a/libiberty/d-demangle.c
+++ b/libiberty/d-demangle.c
@@ -292,8 +292,10 @@ dlang_attributes (string *decl, const char *mangled)
 	  continue;
 	case 'g':
 	case 'h':
+	case 'k':
 	  /* inout parameter is represented as 'Ng'.
 	     vector parameter is represented as 'Nh'.
+	     return paramenter is represented as 'Nk'.
 	     If we see this, then we know we're really in the
 	     parameter list.  Rewind and break.  */
 	  mangled--;
@@ -302,6 +304,13 @@ dlang_attributes (string *decl, const char *mangled)
 	  mangled++;
 	  string_append (decl, "@nogc ");
 	  continue;
+	case 'j': /* return */
+	  mangled++;
+	  string_append (decl, "return ");
+	  continue;
+
+	default: /* unknown attribute */
+	  return NULL;
 	}
       break;
     }
@@ -391,6 +400,12 @@ dlang_function_args (string *decl, const char *mangled)
 	  string_append (decl, "scope ");
 	}
 
+      if (mangled[0] == 'N' && mangled[1] == 'k') /* return(T) */
+	{
+	  mangled += 2;
+	  string_append (decl, "return ");
+	}
+
       switch (*mangled)
 	{
 	case 'J': /* out(T) */
diff --git a/libiberty/testsuite/d-demangle-expected b/libiberty/testsuite/d-demangle-expected
index 43de5af..ae0e8d3 100644
--- a/libiberty/testsuite/d-demangle-expected
+++ b/libiberty/testsuite/d-demangle-expected
@@ -314,6 +314,14 @@ _D8demangle4testFMaZv
 demangle.test(scope char)
 #
 --format=dlang
+_D8demangle4testFNjaZv
+demangle.test(char)
+#
+--format=dlang
+_D8demangle4testFNkaZv
+demangle.test(return char)
+#
+--format=dlang
 _D8demangle4testFaXv
 demangle.test(char...)
 #
@@ -434,6 +442,22 @@ _D8demangle4testFDFNdNfNaZaZv
 demangle.test(char() @property @safe pure delegate)
 #
 --format=dlang
+_D8demangle4testFNjDFZaZv
+demangle.test(char() delegate)
+#
+--format=dlang
+_D8demangle4testFNkDFZaZv
+demangle.test(return char() delegate)
+#
+--format=dlang
+_D8demangle4testFDFNjZaZv
+demangle.test(char() return delegate)
+#
+--format=dlang
+_D8demangle4testFNjNkDFNjZaZv
+demangle.test(return char() return delegate)
+#
+--format=dlang
 _D8demangle4testFFNaZaZv
 demangle.test(char() pure function)
 #
@@ -474,6 +498,22 @@ _D8demangle4testFFNdNfNaZaZv
 demangle.test(char() @property @safe pure function)
 #
 --format=dlang
+_D8demangle4testFNjFZaZv
+demangle.test(char() function)
+#
+--format=dlang
+_D8demangle4testFNkFZaZv
+demangle.test(return char() function)
+#
+--format=dlang
+_D8demangle4testFFNjZaZv
+demangle.test(char() return function)
+#
+--format=dlang
+_D8demangle4testFNjNkFNjZaZv
+demangle.test(return char() return function)
+#
+--format=dlang
 _D8demangle4test6__initZ
 demangle.test.init$
 #
-- 
2.1.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]