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 23 Sep 2005 18:25:22 -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); Index: libiberty/ChangeLog =================================================================== RCS file: /cvsroot/gcc/gcc/libiberty/ChangeLog,v retrieving revision 1.601 diff -c -3 -p -r1.601 ChangeLog *** libiberty/ChangeLog 15 Sep 2005 00:46:19 -0000 1.601 --- libiberty/ChangeLog 23 Sep 2005 18:25:24 -0000 *************** *** 1,3 **** --- 1,10 ---- + 2005-09-23 Terry Laurenzo + + PR java/9861 + * cp-demangle.c (d_bare_function_type): Recognize new 'J' qualifier + and include return type when found. + * testsuite/demangle-expected: Test cases to verify extended encoding + 2005-09-14 Christopher Faylor * pex-win32.c: Include "windows.h". 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 23 Sep 2005 18:25:24 -0000 *************** _test_array__L_1__B23b___clean.6 *** 3781,3783 **** --- 3781,3797 ---- --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 + double java.lang.Math.acos(double) + # + --format=auto + _ZN4java4lang4Math4acosEJdd + double java::lang::Math::acos(double) + # + --format=auto + _ZN4java4lang4Math4acosEJvd + void java::lang::Math::acos(double) \ No newline at end of file Index: gcc/java/mangle.c =================================================================== RCS file: /cvsroot/gcc/gcc/gcc/java/mangle.c,v retrieving revision 1.34 diff -c -3 -p -r1.34 mangle.c *** gcc/java/mangle.c 25 Jun 2005 00:33:04 -0000 1.34 --- gcc/java/mangle.c 23 Sep 2005 18:25:24 -0000 *************** mangle_method_decl (tree mdecl) *** 188,193 **** --- 188,201 ---- if (TREE_CODE (TREE_TYPE (mdecl)) == METHOD_TYPE) arglist = TREE_CHAIN (arglist); + /* Output literal 'J' and mangle the return type IF not a + constructor. */ + if (!ID_INIT_P (method_name)) + { + obstack_1grow (mangle_obstack, 'J'); + mangle_type(TREE_TYPE(TREE_TYPE(mdecl))); + } + /* No arguments is easy. We shortcut it. */ if (arglist == end_params_node) obstack_1grow (mangle_obstack, 'v'); Index: gcc/java/builtins.c =================================================================== RCS file: /cvsroot/gcc/gcc/gcc/java/builtins.c,v retrieving revision 1.34 diff -c -3 -p -r1.34 builtins.c *** gcc/java/builtins.c 18 Sep 2005 19:10:10 -0000 1.34 --- gcc/java/builtins.c 23 Sep 2005 18:25:24 -0000 *************** initialize_builtins (void) *** 194,236 **** float_ftype_float_float, "fmodf", BUILTIN_CONST); define_builtin (BUILT_IN_ACOS, "__builtin_acos", ! double_ftype_double, "_ZN4java4lang4Math4acosEd", BUILTIN_CONST); define_builtin (BUILT_IN_ASIN, "__builtin_asin", ! double_ftype_double, "_ZN4java4lang4Math4asinEd", BUILTIN_CONST); define_builtin (BUILT_IN_ATAN, "__builtin_atan", ! double_ftype_double, "_ZN4java4lang4Math4atanEd", BUILTIN_CONST); define_builtin (BUILT_IN_ATAN2, "__builtin_atan2", ! double_ftype_double_double, "_ZN4java4lang4Math5atan2Edd", BUILTIN_CONST); define_builtin (BUILT_IN_CEIL, "__builtin_ceil", ! double_ftype_double, "_ZN4java4lang4Math4ceilEd", BUILTIN_CONST); define_builtin (BUILT_IN_COS, "__builtin_cos", ! double_ftype_double, "_ZN4java4lang4Math3cosEd", BUILTIN_CONST); define_builtin (BUILT_IN_EXP, "__builtin_exp", ! double_ftype_double, "_ZN4java4lang4Math3expEd", BUILTIN_CONST); define_builtin (BUILT_IN_FLOOR, "__builtin_floor", ! double_ftype_double, "_ZN4java4lang4Math5floorEd", BUILTIN_CONST); define_builtin (BUILT_IN_LOG, "__builtin_log", ! double_ftype_double, "_ZN4java4lang4Math3logEd", BUILTIN_CONST); define_builtin (BUILT_IN_POW, "__builtin_pow", ! double_ftype_double_double, "_ZN4java4lang4Math3powEdd", BUILTIN_CONST); define_builtin (BUILT_IN_SIN, "__builtin_sin", ! double_ftype_double, "_ZN4java4lang4Math3sinEd", BUILTIN_CONST); define_builtin (BUILT_IN_SQRT, "__builtin_sqrt", ! double_ftype_double, "_ZN4java4lang4Math4sqrtEd", BUILTIN_CONST); define_builtin (BUILT_IN_TAN, "__builtin_tan", ! double_ftype_double, "_ZN4java4lang4Math3tanEd", BUILTIN_CONST); t = tree_cons (NULL_TREE, boolean_type_node, end_params_node); --- 194,236 ---- float_ftype_float_float, "fmodf", BUILTIN_CONST); define_builtin (BUILT_IN_ACOS, "__builtin_acos", ! double_ftype_double, "_ZN4java4lang4Math4acosEJdd", BUILTIN_CONST); define_builtin (BUILT_IN_ASIN, "__builtin_asin", ! double_ftype_double, "_ZN4java4lang4Math4asinEJdd", BUILTIN_CONST); define_builtin (BUILT_IN_ATAN, "__builtin_atan", ! double_ftype_double, "_ZN4java4lang4Math4atanEJdd", BUILTIN_CONST); define_builtin (BUILT_IN_ATAN2, "__builtin_atan2", ! double_ftype_double_double, "_ZN4java4lang4Math5atan2EJddd", BUILTIN_CONST); define_builtin (BUILT_IN_CEIL, "__builtin_ceil", ! double_ftype_double, "_ZN4java4lang4Math4ceilEJdd", BUILTIN_CONST); define_builtin (BUILT_IN_COS, "__builtin_cos", ! double_ftype_double, "_ZN4java4lang4Math3cosEJdd", BUILTIN_CONST); define_builtin (BUILT_IN_EXP, "__builtin_exp", ! double_ftype_double, "_ZN4java4lang4Math3expEJdd", BUILTIN_CONST); define_builtin (BUILT_IN_FLOOR, "__builtin_floor", ! double_ftype_double, "_ZN4java4lang4Math5floorEJdd", BUILTIN_CONST); define_builtin (BUILT_IN_LOG, "__builtin_log", ! double_ftype_double, "_ZN4java4lang4Math3logEJdd", BUILTIN_CONST); define_builtin (BUILT_IN_POW, "__builtin_pow", ! double_ftype_double_double, "_ZN4java4lang4Math3powEJddd", BUILTIN_CONST); define_builtin (BUILT_IN_SIN, "__builtin_sin", ! double_ftype_double, "_ZN4java4lang4Math3sinEJdd", BUILTIN_CONST); define_builtin (BUILT_IN_SQRT, "__builtin_sqrt", ! double_ftype_double, "_ZN4java4lang4Math4sqrtEJdd", BUILTIN_CONST); define_builtin (BUILT_IN_TAN, "__builtin_tan", ! double_ftype_double, "_ZN4java4lang4Math3tanEJdd", BUILTIN_CONST); t = tree_cons (NULL_TREE, boolean_type_node, end_params_node); Index: gcc/java/ChangeLog =================================================================== RCS file: /cvsroot/gcc/gcc/gcc/java/ChangeLog,v retrieving revision 1.1666 diff -c -3 -p -r1.1666 ChangeLog *** gcc/java/ChangeLog 21 Sep 2005 13:34:27 -0000 1.1666 --- gcc/java/ChangeLog 23 Sep 2005 18:25:28 -0000 *************** *** 1,3 **** --- 1,11 ---- + 2005-09-23 Terry Laurenzo + + PR java/9861 + * mangle.c (mangle_method_decl): Mangle Java methods by prepending 'J' + to bare_function_type and including the return type + * builtins.c (initialize_builtins): Change builtin mangled name + constants to conform to new mangling scheme + 2005-09-21 Ranjit Mathew PR java/21418 Index: gcc/cp/mangle.c =================================================================== RCS file: /cvsroot/gcc/gcc/gcc/cp/mangle.c,v retrieving revision 1.128 diff -c -3 -p -r1.128 mangle.c *** gcc/cp/mangle.c 13 Sep 2005 15:15:31 -0000 1.128 --- gcc/cp/mangle.c 23 Sep 2005 18:25:29 -0000 *************** write_function_type (const tree type) *** 1858,1873 **** is mangled before the parameter types. If non-NULL, DECL is FUNCTION_DECL for the function whose type is being emitted. ! ::= + */ static void write_bare_function_type (const tree type, const int include_return_type_p, const tree decl) { MANGLE_TRACE_TREE ("bare-function-type", type); /* Mangle the return type, if requested. */ ! if (include_return_type_p) write_type (TREE_TYPE (type)); /* Now mangle the types of the arguments. */ --- 1858,1895 ---- is mangled before the parameter types. If non-NULL, DECL is FUNCTION_DECL for the function whose type is being emitted. ! If DECL is a member of a Java type, then a literal 'J' ! is output and the return type is mangled as if INCLUDE_RETURN_TYPE ! were nonzero. ! ! ::= [J]+ */ static void write_bare_function_type (const tree type, const int include_return_type_p, const tree decl) { + int java_method_p; + MANGLE_TRACE_TREE ("bare-function-type", type); + /* Detect Java methods and emit special encoding. */ + if (decl != NULL + && DECL_FUNCTION_MEMBER_P (decl) + && TYPE_FOR_JAVA (DECL_CONTEXT (decl)) + && !DECL_CONSTRUCTOR_P (decl) + && !DECL_DESTRUCTOR_P (decl) + && !DECL_CONV_FN_P (decl)) + { + java_method_p = 1; + write_char ('J'); + } + else + { + java_method_p = 0; + } + /* Mangle the return type, if requested. */ ! if (include_return_type_p || java_method_p) write_type (TREE_TYPE (type)); /* Now mangle the types of the arguments. */ Index: gcc/cp/ChangeLog =================================================================== RCS file: /cvsroot/gcc/gcc/gcc/cp/ChangeLog,v retrieving revision 1.4900 diff -c -3 -p -r1.4900 ChangeLog *** gcc/cp/ChangeLog 22 Sep 2005 00:11:18 -0000 1.4900 --- gcc/cp/ChangeLog 23 Sep 2005 18:25:30 -0000 *************** *** 1,3 **** --- 1,9 ---- + 2005-09-23 Terry Laurenzo + + PR java/9861 + * mangle.c (write_bare_function_type): Mangle return type for + methods of Java classes + 2005-09-21 Mark Mitchell PR c++/23993