aboutsummaryrefslogtreecommitdiff
path: root/libiberty
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2017-05-27 11:29:52 +0000
committerIain Buclaw <ibuclaw@gcc.gnu.org>2017-05-27 11:29:52 +0000
commit0e3712f6aa8dcd27433ac8090a0d1c48976003ae (patch)
treee7902a4dfb5a0be30b80f4b0e0366df50eeabd62 /libiberty
parent1a122a71eeb0671f92037ccdf5d2dc0b307af620 (diff)
downloadgcc-0e3712f6aa8dcd27433ac8090a0d1c48976003ae.zip
gcc-0e3712f6aa8dcd27433ac8090a0d1c48976003ae.tar.gz
gcc-0e3712f6aa8dcd27433ac8090a0d1c48976003ae.tar.bz2
d-demangle.c (dlang_call_convention_p): Move declaration before dlang_type.
libiberty/ChangeLog: * d-demangle.c (dlang_call_convention_p): Move declaration before dlang_type. (dlang_type): Handle function types. * testsuite/d-demangle-expected: Add tests. From-SVN: r248538
Diffstat (limited to 'libiberty')
-rw-r--r--libiberty/ChangeLog7
-rw-r--r--libiberty/d-demangle.c53
-rw-r--r--libiberty/testsuite/d-demangle-expected8
3 files changed, 44 insertions, 24 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index 83f6d21..ba16ee5 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,5 +1,12 @@
2017-05-27 Iain Buclaw <ibuclaw@gdcproject.org>
+ * d-demangle.c (dlang_call_convention_p): Move declaration
+ before dlang_type.
+ (dlang_type): Handle function types.
+ * testsuite/d-demangle-expected: Add tests.
+
+2017-05-27 Iain Buclaw <ibuclaw@gdcproject.org>
+
* d-demangle.c (dlang_parse_real): Remove stack buffer, write
the demangled hexadecimal directly to string.
* testsuite/d-demangle-expected: Add tests.
diff --git a/libiberty/d-demangle.c b/libiberty/d-demangle.c
index 030cab3..829050b 100644
--- a/libiberty/d-demangle.c
+++ b/libiberty/d-demangle.c
@@ -251,6 +251,22 @@ dlang_hexdigit (const char *mangled, char *ret)
return mangled;
}
+/* Extract the function calling convention from MANGLED and
+ return 1 on success or 0 on failure. */
+static int
+dlang_call_convention_p (const char *mangled)
+{
+ switch (*mangled)
+ {
+ case 'F': case 'U': case 'V':
+ case 'W': case 'R': case 'Y':
+ return 1;
+
+ default:
+ return 0;
+ }
+}
+
/* Demangle the calling convention from MANGLED and append it to DECL.
Return the remaining string on success or NULL on failure. */
static const char *
@@ -600,17 +616,22 @@ dlang_type (string *decl, const char *mangled)
}
case 'P': /* pointer (T*) */
mangled++;
- /* Function pointer types don't include the trailing asterisk. */
- switch (*mangled)
+ if (!dlang_call_convention_p (mangled))
{
- case 'F': case 'U': case 'W':
- case 'V': case 'R': case 'Y':
- mangled = dlang_function_type (decl, mangled);
- string_append (decl, "function");
+ mangled = dlang_type (decl, mangled);
+ string_append (decl, "*");
return mangled;
}
- mangled = dlang_type (decl, mangled);
- string_append (decl, "*");
+ /* Fall through */
+ case 'F': /* function T (D) */
+ case 'U': /* function T (C) */
+ case 'W': /* function T (Windows) */
+ case 'V': /* function T (Pascal) */
+ case 'R': /* function T (C++) */
+ case 'Y': /* function T (Objective-C) */
+ /* Function pointer types don't include the trailing asterisk. */
+ mangled = dlang_function_type (decl, mangled);
+ string_append (decl, "function");
return mangled;
case 'I': /* ident T */
case 'C': /* class T */
@@ -1311,22 +1332,6 @@ dlang_value (string *decl, const char *mangled, const char *name, char type)
return mangled;
}
-/* Extract the function calling convention from MANGLED and
- return 1 on success or 0 on failure. */
-static int
-dlang_call_convention_p (const char *mangled)
-{
- switch (*mangled)
- {
- case 'F': case 'U': case 'V':
- case 'W': case 'R': case 'Y':
- return 1;
-
- default:
- return 0;
- }
-}
-
/* Extract and demangle the symbol in MANGLED and append it to DECL.
Returns the remaining signature on success or NULL on failure. */
static const char *
diff --git a/libiberty/testsuite/d-demangle-expected b/libiberty/testsuite/d-demangle-expected
index 950d495..7bf8b17 100644
--- a/libiberty/testsuite/d-demangle-expected
+++ b/libiberty/testsuite/d-demangle-expected
@@ -886,6 +886,10 @@ _D8demangle35__T4testVS8demangle1SS2i1a3_616263Zv
demangle.test!(demangle.S(1, "abc"))
#
--format=dlang
+_D8demangle13__T4testTFZaZ6mangleFZv
+demangle.test!(char() function).mangle()
+#
+--format=dlang
_D8demangle4testMxFZv
demangle.test() const
#
@@ -1298,3 +1302,7 @@ std.traits.fqnSym!(std).adjustIdent(immutable(char)[])
--format=dlang
_D2rt8lifetime36__T14_d_newarrayOpTS13_d_newarrayiTZ14_d_newarrayOpTFNaNbxC8TypeInfomPmZAv
rt.lifetime._d_newarrayOpT!(_d_newarrayiT)._d_newarrayOpT(const(TypeInfo), ulong, ulong*)
+#
+--format=dlang
+_D4core8demangle16__T6mangleTFZPvZ6mangleFNaNbNfAxaAaZ11DotSplitter5emptyMxFNaNbNdNiNfZb
+core.demangle.mangle!(void*() function).mangle(const(char)[], char[]).DotSplitter.empty() const