Index: libiberty/cp-demangle.c =================================================================== RCS file: /cvsroot/gcc/gcc/libiberty/cp-demangle.c,v retrieving revision 1.83 diff -c -3 -p -r1.83 cp-demangle.c *** libiberty/cp-demangle.c 1 Jul 2005 16:39:35 -0000 1.83 --- libiberty/cp-demangle.c 27 Sep 2005 17:41:39 -0000 *************** d_function_type (struct d_info *di) *** 1939,1945 **** return ret; } ! /* ::= + */ static struct demangle_component * d_bare_function_type (struct d_info *di, int has_return_type) --- 1939,1945 ---- return ret; } ! /* ::= [J]+ */ static struct demangle_component * d_bare_function_type (struct d_info *di, int has_return_type) *************** d_bare_function_type (struct d_info *di, *** 1947,1959 **** struct demangle_component *return_type; struct demangle_component *tl; struct demangle_component **ptl; return_type = NULL; tl = NULL; ptl = &tl; while (1) { - char peek; struct demangle_component *type; peek = d_peek_char (di); --- 1947,1968 ---- 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) { struct demangle_component *type; peek = d_peek_char (di); *************** d_print_comp (struct d_print_info *dpi, *** 3025,3037 **** case DEMANGLE_COMPONENT_FUNCTION_TYPE: { 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; --- 3034,3050 ---- 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; *************** d_print_comp (struct d_print_info *dpi, *** 3045,3054 **** if (dpm.printed) return; ! d_append_char (dpi, ' '); } ! d_print_function_type (dpi, dc, dpi->modifiers); return; } --- 3058,3071 ---- if (dpm.printed) return; ! /* 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, ' '); } ! if ((dpi->options & DMGL_RET_POSTFIX) == 0) ! d_print_function_type (dpi, dc, dpi->modifiers); return; } *************** java_demangle_v3 (const char* mangled) *** 4003,4009 **** char *from; char *to; ! demangled = d_demangle (mangled, DMGL_JAVA | DMGL_PARAMS, &alc); if (demangled == NULL) return NULL; --- 4020,4027 ---- char *from; char *to; ! demangled = d_demangle (mangled, DMGL_JAVA | DMGL_PARAMS | DMGL_RET_POSTFIX, ! &alc); if (demangled == NULL) return NULL; Index: libiberty/testsuite/test-demangle.c =================================================================== RCS file: /cvsroot/gcc/gcc/libiberty/testsuite/test-demangle.c,v retrieving revision 1.6 diff -c -3 -p -r1.6 test-demangle.c *** libiberty/testsuite/test-demangle.c 17 Aug 2005 03:31:04 -0000 1.6 --- libiberty/testsuite/test-demangle.c 27 Sep 2005 17:41:39 -0000 *************** exp: %s\n", *** 114,119 **** --- 114,120 ---- --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 *************** main(argc, argv) *** 129,134 **** --- 130,136 ---- int no_params; int is_v3_ctor; int is_v3_dtor; + int ret_postfix; struct line format; struct line input; struct line expect; *************** main(argc, argv) *** 158,163 **** --- 160,166 ---- tests++; no_params = 0; + ret_postfix = 0; is_v3_ctor = 0; is_v3_dtor = 0; if (format.data[0] == '\0') *************** main(argc, argv) *** 212,217 **** --- 215,222 ---- 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", *************** main(argc, argv) *** 255,261 **** cplus_demangle_set_style (style); result = cplus_demangle (input.data, ! DMGL_PARAMS|DMGL_ANSI|DMGL_TYPES); if (result ? strcmp (result, expect.data) --- 260,267 ---- cplus_demangle_set_style (style); result = cplus_demangle (input.data, ! DMGL_PARAMS|DMGL_ANSI|DMGL_TYPES| ! (ret_postfix ? DMGL_RET_POSTFIX : 0)); if (result ? strcmp (result, expect.data) Index: libiberty/testsuite/demangle-expected =================================================================== RCS file: /cvsroot/gcc/gcc/libiberty/testsuite/demangle-expected,v retrieving revision 1.33 diff -c -3 -p -r1.33 demangle-expected *** libiberty/testsuite/demangle-expected 1 Jul 2005 16:39:36 -0000 1.33 --- libiberty/testsuite/demangle-expected 27 Sep 2005 17:41:39 -0000 *************** *** 11,16 **** --- 11,17 ---- # --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 *************** _test_array__L_1__B23b___clean.6 *** 3781,3783 **** --- 3782,3807 ---- --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 + make Index: include/demangle.h =================================================================== RCS file: /cvsroot/gcc/gcc/include/demangle.h,v retrieving revision 1.29 diff -c -3 -p -r1.29 demangle.h *** include/demangle.h 25 May 2005 23:29:53 -0000 1.29 --- include/demangle.h 27 Sep 2005 17:41:39 -0000 *************** extern "C" { *** 35,40 **** --- 35,42 ---- #define DMGL_JAVA (1 << 2) /* Demangle as Java rather than C++. */ #define DMGL_VERBOSE (1 << 3) /* Include implementation details. */ #define DMGL_TYPES (1 << 4) /* Also try to demangle type encodings. */ + #define DMGL_RET_POSTFIX (1 << 5) /* Print function return types (when + present) after function signature */ #define DMGL_AUTO (1 << 8) #define DMGL_GNU (1 << 9)