From 7ce4461f3712b9a979a41a5914ca729fe635616c Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Sat, 16 May 2015 16:49:57 +0000 Subject: [PATCH] d-demangle.c (dlang_attributes): Handle return attributes, ignoring return parameters in the mangled string. libiberty/ChangeLog: 2015-05-16 Iain Buclaw * 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 --- libiberty/ChangeLog | 9 ++++++ libiberty/d-demangle.c | 15 ++++++++++ libiberty/testsuite/d-demangle-expected | 40 +++++++++++++++++++++++++ 3 files changed, 64 insertions(+) diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 37425c8df81..609c5e85863 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,12 @@ +2015-05-16 Iain Buclaw + + * 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 * d-demangle.c (dlang_identifier): Check encoded length of identifier diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c index 011e62bc662..8104a345e1d 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 b0b9ca0b49d..5dd0678a01b 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.30.2