summaryrefslogtreecommitdiff
path: root/libiberty
diff options
context:
space:
mode:
authorDJ Delorie <dj@delorie.com>2005-12-11 02:16:09 +0000
committerDJ Delorie <dj@delorie.com>2005-12-11 02:16:09 +0000
commitc655249a3e95fbcd35841c8051d1e4b3e86aaf62 (patch)
tree9a149ae95c99ab1c9cfb0ffa3f2385e11c6019d6 /libiberty
parent8a176d63847715c95a3f82a7367d203b0663922b (diff)
downloadgdb-c655249a3e95fbcd35841c8051d1e4b3e86aaf62.tar.gz
merge from gcc
Diffstat (limited to 'libiberty')
-rw-r--r--libiberty/ChangeLog14
-rw-r--r--libiberty/cp-demangle.c29
-rw-r--r--libiberty/testsuite/demangle-expected24
-rw-r--r--libiberty/testsuite/test-demangle.c8
4 files changed, 68 insertions, 7 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index 6fdeba3e852..85e96bad04b 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,17 @@
+2005-12-10 Terry Laurenzo <tlaurenzo@gmail.com>
+
+ PR java/9861
+ * cp-demangle.c (d_bare_function_type): Recognize new 'J' qualifer
+ and include return type when found.
+ (d_print_comp)[DEMANGLE_COMPONENT_FUNCTION_TYPE]: Add
+ conditional logic to change printing order of return type.when
+ the DMGL_RET_POSTFIX option is present.
+ (java_demangle_v3): Add DMGL_RET_POSTFIX option to d_demangle
+ call.
+ * testsuite/test-demangle.c (main): Recognize option --ret-postfix
+ * testsuite/demangle-expected: Test cases to verify extended encoding.
+ Updated comment to document --ret-postfix option.
+
2005-11-06 Richard Guenther <rguenther@suse.de>
* splay-tree.c (rotate_left): New function.
diff --git a/libiberty/cp-demangle.c b/libiberty/cp-demangle.c
index 8f1cfb17f87..109d533b524 100644
--- a/libiberty/cp-demangle.c
+++ b/libiberty/cp-demangle.c
@@ -1939,7 +1939,7 @@ d_function_type (struct d_info *di)
return ret;
}
-/* <bare-function-type> ::= <type>+ */
+/* <bare-function-type> ::= [J]<type>+ */
static struct demangle_component *
d_bare_function_type (struct d_info *di, int has_return_type)
@@ -1947,13 +1947,22 @@ d_bare_function_type (struct d_info *di, int has_return_type)
struct demangle_component *return_type;
struct demangle_component *tl;
struct demangle_component **ptl;
+ char peek;
+
+ /* Detect special qualifier indicating that the first argument
+ is the return type. */
+ peek = d_peek_char (di);
+ if (peek == 'J')
+ {
+ d_advance (di, 1);
+ has_return_type = 1;
+ }
return_type = NULL;
tl = NULL;
ptl = &tl;
while (1)
{
- char peek;
struct demangle_component *type;
peek = d_peek_char (di);
@@ -3025,13 +3034,16 @@ d_print_comp (struct d_print_info *dpi,
case DEMANGLE_COMPONENT_FUNCTION_TYPE:
{
+ if ((dpi->options & DMGL_RET_POSTFIX) != 0)
+ d_print_function_type (dpi, dc, dpi->modifiers);
+
+ /* Print return type if present */
if (d_left (dc) != NULL)
{
struct d_print_mod dpm;
/* We must pass this type down as a modifier in order to
print it in the right location. */
-
dpm.next = dpi->modifiers;
dpi->modifiers = &dpm;
dpm.mod = dc;
@@ -3045,10 +3057,14 @@ d_print_comp (struct d_print_info *dpi,
if (dpm.printed)
return;
- d_append_char (dpi, ' ');
+ /* In standard prefix notation, there is a space between the
+ return type and the function signature. */
+ if ((dpi->options & DMGL_RET_POSTFIX) == 0)
+ d_append_char (dpi, ' ');
}
- d_print_function_type (dpi, dc, dpi->modifiers);
+ if ((dpi->options & DMGL_RET_POSTFIX) == 0)
+ d_print_function_type (dpi, dc, dpi->modifiers);
return;
}
@@ -4003,7 +4019,8 @@ java_demangle_v3 (const char* mangled)
char *from;
char *to;
- demangled = d_demangle (mangled, DMGL_JAVA | DMGL_PARAMS, &alc);
+ demangled = d_demangle (mangled, DMGL_JAVA | DMGL_PARAMS | DMGL_RET_POSTFIX,
+ &alc);
if (demangled == NULL)
return NULL;
diff --git a/libiberty/testsuite/demangle-expected b/libiberty/testsuite/demangle-expected
index 4526773a780..fa2a2fed245 100644
--- a/libiberty/testsuite/demangle-expected
+++ b/libiberty/testsuite/demangle-expected
@@ -11,6 +11,7 @@
# --is-v3-ctor Calls is_gnu_v3_mangled_ctor on input; expected
# output is an integer representing ctor_kind.
# --is-v3-dtor Likewise, but for dtors.
+# --ret-postfix Passes the DMGL_RET_POSTFIX option
#
# For compatibility, just in case it matters, the options line may be
# empty, to mean --format=auto. If it doesn't start with --, then it
@@ -3781,3 +3782,26 @@ _test_array__L_1__B23b___clean.6
--format=java
_ZGAN4java4lang5Class7forNameEPNS0_6StringE
hidden alias for java.lang.Class.forName(java.lang.String)
+#
+# Test cases to verify encoding that determines if a return type is present
+# Related to PR9861
+--format=java
+_ZN4java4lang4Math4acosEJdd
+java.lang.Math.acos(double)double
+#
+--format=auto
+_ZN4java4lang4Math4acosEJdd
+double java::lang::Math::acos(double)
+#
+--format=auto
+_ZN4java4lang4Math4acosEJvd
+void java::lang::Math::acos(double)
+#
+--format=auto --ret-postfix
+_ZN4java4lang4Math4acosEJdd
+java::lang::Math::acos(double)double
+#
+--format=gnu-v3 --no-params --ret-postfix
+_Z4makeI7FactoryiET_IT0_Ev
+make<Factory, int>()Factory<int>
+make<Factory, int>
diff --git a/libiberty/testsuite/test-demangle.c b/libiberty/testsuite/test-demangle.c
index dcb27d259d4..93793996fe0 100644
--- a/libiberty/testsuite/test-demangle.c
+++ b/libiberty/testsuite/test-demangle.c
@@ -114,6 +114,7 @@ exp: %s\n",
--is-v3-ctor Calls is_gnu_v3_mangled_ctor on input; expected
output is an integer representing ctor_kind.
--is-v3-dtor Likewise, but for dtors.
+ --ret-postfix Passes the DMGL_RET_POSTFIX option
For compatibility, just in case it matters, the options line may be
empty, to mean --format=auto. If it doesn't start with --, then it
@@ -129,6 +130,7 @@ main(argc, argv)
int no_params;
int is_v3_ctor;
int is_v3_dtor;
+ int ret_postfix;
struct line format;
struct line input;
struct line expect;
@@ -158,6 +160,7 @@ main(argc, argv)
tests++;
no_params = 0;
+ ret_postfix = 0;
is_v3_ctor = 0;
is_v3_dtor = 0;
if (format.data[0] == '\0')
@@ -212,6 +215,8 @@ main(argc, argv)
is_v3_ctor = 1;
else if (strcmp (opt, "--is-v3-dtor") == 0)
is_v3_dtor = 1;
+ else if (strcmp (opt, "--ret-postfix") == 0)
+ ret_postfix = 1;
else
{
printf ("FAIL at line %d: unrecognized option %s\n",
@@ -255,7 +260,8 @@ main(argc, argv)
cplus_demangle_set_style (style);
result = cplus_demangle (input.data,
- DMGL_PARAMS|DMGL_ANSI|DMGL_TYPES);
+ DMGL_PARAMS|DMGL_ANSI|DMGL_TYPES
+ |(ret_postfix ? DMGL_RET_POSTFIX : 0));
if (result
? strcmp (result, expect.data)