From f58c04acd70df794d50afb1cd8879e16ca73bc92 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Thu, 22 Feb 2001 21:46:06 +0000 Subject: [PATCH] mangle.c (write_encoding): Pass write_function_type the FUNCTION_DECL for the function being encoded. * mangle.c (write_encoding): Pass write_function_type the FUNCTION_DECL for the function being encoded. (write_function_type): Pass it along to write_bare_function_type. (write_bare_function_type): Pass it along to write_method_parms. (write_method_parms): Don't mangle the compiler-generated parameters to a constructor or destructor. From-SVN: r39985 --- gcc/cp/ChangeLog | 9 +++++++ gcc/cp/mangle.c | 65 ++++++++++++++++++++++++++++++++---------------- 2 files changed, 52 insertions(+), 22 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 36f24a464f7..26899a55a9e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2001-02-22 Mark Mitchell + + * mangle.c (write_encoding): Pass write_function_type the + FUNCTION_DECL for the function being encoded. + (write_function_type): Pass it along to write_bare_function_type. + (write_bare_function_type): Pass it along to write_method_parms. + (write_method_parms): Don't mangle the compiler-generated + parameters to a constructor or destructor. + 2001-02-22 Andreas Jaeger * optimize.c: Include toplev.h for diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 10f0bc89828..6736d1e6743 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -163,8 +163,8 @@ static void write_type PARAMS ((tree)); static int write_CV_qualifiers_for_type PARAMS ((tree)); static void write_builtin_type PARAMS ((tree)); static void write_function_type PARAMS ((tree)); -static void write_bare_function_type PARAMS ((tree, int)); -static void write_method_parms PARAMS ((tree, int)); +static void write_bare_function_type PARAMS ((tree, int, tree)); +static void write_method_parms PARAMS ((tree, int, tree)); static void write_class_enum_type PARAMS ((tree)); static void write_template_args PARAMS ((tree)); static void write_expression PARAMS ((tree)); @@ -653,7 +653,8 @@ write_encoding (decl) (!DECL_CONSTRUCTOR_P (decl) && !DECL_DESTRUCTOR_P (decl) && !DECL_CONV_FN_P (decl) - && decl_is_template_id (decl, NULL))); + && decl_is_template_id (decl, NULL)), + decl); } } @@ -1530,20 +1531,23 @@ write_function_type (type) extern "C" function_t f; // Vice versa. See [dcl.link]. */ - write_bare_function_type (type, /*include_return_type_p=*/1); + write_bare_function_type (type, /*include_return_type_p=*/1, + /*decl=*/NULL); write_char ('E'); } -/* Non-terminal . NODE is a FUNCTION_DECL or a +/* Non-terminal . TYPE is a FUNCTION_TYPE or METHOD_TYPE. If INCLUDE_RETURN_TYPE is non-zero, the return value - is mangled before the parameter types. + 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 (type, include_return_type_p) +write_bare_function_type (type, include_return_type_p, decl) tree type; int include_return_type_p; + tree decl; { MANGLE_TRACE_TREE ("bare-function-type", type); @@ -1553,19 +1557,25 @@ write_bare_function_type (type, include_return_type_p) /* Now mangle the types of the arguments. */ write_method_parms (TYPE_ARG_TYPES (type), - TREE_CODE (type) == METHOD_TYPE); + TREE_CODE (type) == METHOD_TYPE, + decl); } /* Write the mangled representation of a method parameter list of - types given in PARM_LIST. If METHOD_P is non-zero, the function is - considered a non-static method, and the this parameter is omitted. */ + types given in PARM_TYPES. If METHOD_P is non-zero, the function is + considered a non-static method, and the this parameter is omitted. + If non-NULL, DECL is the FUNCTION_DECL for the function whose + parameters are being emitted. */ static void -write_method_parms (parm_list, method_p) - tree parm_list; +write_method_parms (parm_types, method_p, decl) + tree decl; + tree parm_types; int method_p; { - tree first_parm; + tree first_parm_type; + tree parm_decl = decl ? DECL_ARGUMENTS (decl) : NULL_TREE; + /* Assume this parameter type list is variable-length. If it ends with a void type, then it's not. */ int varargs_p = 1; @@ -1573,28 +1583,39 @@ write_method_parms (parm_list, method_p) /* If this is a member function, skip the first arg, which is the this pointer. "Member functions do not encode the type of their implicit this - parameter." */ + parameter." + + Similarly, there's no need to mangle artificial parameters, like + the VTT parameters for constructors and destructors. */ if (method_p) - parm_list = TREE_CHAIN (parm_list); - - for (first_parm = parm_list; - parm_list; - parm_list = TREE_CHAIN (parm_list)) { - tree parm = TREE_VALUE (parm_list); + parm_types = TREE_CHAIN (parm_types); + parm_decl = parm_decl ? TREE_CHAIN (parm_decl) : NULL_TREE; + while (parm_decl && DECL_ARTIFICIAL (parm_decl)) + { + parm_types = TREE_CHAIN (parm_types); + parm_decl = TREE_CHAIN (parm_decl); + } + } + + for (first_parm_type = parm_types; + parm_types; + parm_types = TREE_CHAIN (parm_types)) + { + tree parm = TREE_VALUE (parm_types); if (parm == void_type_node) { /* "Empty parameter lists, whether declared as () or conventionally as (void), are encoded with a void parameter (v)." */ - if (parm_list == first_parm) + if (parm_types == first_parm_type) write_type (parm); /* If the parm list is terminated with a void type, it's fixed-length. */ varargs_p = 0; /* A void type better be the last one. */ - my_friendly_assert (TREE_CHAIN (parm_list) == NULL, 20000523); + my_friendly_assert (TREE_CHAIN (parm_types) == NULL, 20000523); } else write_type (parm); -- 2.30.2