d-demangle.c (dlang_attributes): Handle return attributes, ignoring return parameters in the mangled string.

libiberty/ChangeLog:

2015-05-16  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-SVN: r223244
This commit is contained in:
Iain Buclaw 2015-05-16 16:49:57 +00:00 committed by Iain Buclaw
parent 5cc158e9a9
commit 7ce4461f37
3 changed files with 64 additions and 0 deletions

View File

@ -1,3 +1,12 @@
2015-05-16 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.
2015-05-16 Iain Buclaw <ibuclaw@gdcproject.org>
* d-demangle.c (dlang_identifier): Check encoded length of identifier

View File

@ -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) */

View File

@ -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$
#