Commit 8c152bad by Nathan Sidwell Committed by Nathan Sidwell

re PR c++/4361 (bogus ambiguity taking the address of a member template)

cp:
	PR c++/4361
	* mangle.c (struct globals) Add internal_mangling_p member.
	(write_template_param): Do internal mangling, if needed.
	(mangle_conv_op_name_for_type): Request internal mangling.

From-SVN: r51098
parent 852b81bb
2002-03-20 Nathan Sidwell <nathan@codesourcery.com>
PR c++/4361
* mangle.c (struct globals) Add internal_mangling_p member.
(write_template_param): Do internal mangling, if needed.
(mangle_conv_op_name_for_type): Request internal mangling.
2002-03-20 Jason Merrill <jason@redhat.com> 2002-03-20 Jason Merrill <jason@redhat.com>
PR c++/2136 PR c++/2136
...@@ -79,14 +86,11 @@ ...@@ -79,14 +86,11 @@
all end up on slot 2. all end up on slot 2.
* lex.c (do_identifier): A conversion operator token might be * lex.c (do_identifier): A conversion operator token might be
satisfied by a templated conversion operator. satisfied by a templated conversion operator.
* mangle.c (struct globals) Add internal_mangling_p member.
(write_template_param): Do internal mangling, if needed.
(mangle_conv_op_name_for_type): Request internal mangling.
* pt.c (check_explicit_specialization): Use * pt.c (check_explicit_specialization): Use
CLASSTYPE_FIRST_CONVERSION_SLOT. CLASSTYPE_FIRST_CONVERSION_SLOT.
(template_parm_this_level_p): New function. (template_parm_this_level_p): New function.
(push_template_decl_real): Determine DECL_TEMPLATE_CONV_FN_P. (push_template_decl_real): Determine DECL_TEMPLATE_CONV_FN_P.
* search.c (lookup_fn_fields_1): Template conversions will be on * search.c (lookup_fnfields_1): Template conversions will be on
the first slot. the first slot.
* typeck.c (build_component_ref): Preserve the type of an * typeck.c (build_component_ref): Preserve the type of an
conversion operator name on the overload type. conversion operator name on the overload type.
......
...@@ -93,6 +93,11 @@ static struct globals ...@@ -93,6 +93,11 @@ static struct globals
/* An array of the current substitution candidates, in the order /* An array of the current substitution candidates, in the order
we've seen them. */ we've seen them. */
varray_type substitutions; varray_type substitutions;
/* We are mangling an internal symbol. It is important to keep those
involving template parmeters distinct by distinguishing their level
and, for non-type parms, their type. */
bool internal_mangling_p;
} G; } G;
/* Indices into subst_identifiers. These are identifiers used in /* Indices into subst_identifiers. These are identifiers used in
...@@ -2049,13 +2054,22 @@ write_pointer_to_member_type (type) ...@@ -2049,13 +2054,22 @@ write_pointer_to_member_type (type)
TEMPLATE_TEMPLATE_PARM, BOUND_TEMPLATE_TEMPLATE_PARM or a TEMPLATE_TEMPLATE_PARM, BOUND_TEMPLATE_TEMPLATE_PARM or a
TEMPLATE_PARM_INDEX. TEMPLATE_PARM_INDEX.
<template-param> ::= T </parameter/ number> _ */ <template-param> ::= T </parameter/ number> _
If we are internally mangling then we distinguish level and, for
non-type parms, type too. The mangling appends
</level/ number> _ </non-type type/ type> _
This is used by mangle_conv_op_name_for_type. */
static void static void
write_template_param (parm) write_template_param (parm)
tree parm; tree parm;
{ {
int parm_index; int parm_index;
int parm_level;
tree parm_type = NULL_TREE;
MANGLE_TRACE_TREE ("template-parm", parm); MANGLE_TRACE_TREE ("template-parm", parm);
...@@ -2065,10 +2079,13 @@ write_template_param (parm) ...@@ -2065,10 +2079,13 @@ write_template_param (parm)
case TEMPLATE_TEMPLATE_PARM: case TEMPLATE_TEMPLATE_PARM:
case BOUND_TEMPLATE_TEMPLATE_PARM: case BOUND_TEMPLATE_TEMPLATE_PARM:
parm_index = TEMPLATE_TYPE_IDX (parm); parm_index = TEMPLATE_TYPE_IDX (parm);
parm_level = TEMPLATE_TYPE_LEVEL (parm);
break; break;
case TEMPLATE_PARM_INDEX: case TEMPLATE_PARM_INDEX:
parm_index = TEMPLATE_PARM_IDX (parm); parm_index = TEMPLATE_PARM_IDX (parm);
parm_level = TEMPLATE_PARM_LEVEL (parm);
parm_type = TREE_TYPE (TEMPLATE_PARM_DECL (parm));
break; break;
default: default:
...@@ -2081,6 +2098,15 @@ write_template_param (parm) ...@@ -2081,6 +2098,15 @@ write_template_param (parm)
if (parm_index > 0) if (parm_index > 0)
write_unsigned_number (parm_index - 1); write_unsigned_number (parm_index - 1);
write_char ('_'); write_char ('_');
if (G.internal_mangling_p)
{
if (parm_level > 0)
write_unsigned_number (parm_level - 1);
write_char ('_');
if (parm_type)
write_type (parm_type);
write_char ('_');
}
} }
/* <template-template-param> /* <template-template-param>
...@@ -2407,15 +2433,26 @@ mangle_conv_op_name_for_type (type) ...@@ -2407,15 +2433,26 @@ mangle_conv_op_name_for_type (type)
tree type; tree type;
{ {
tree identifier; tree identifier;
const char *mangled_type;
char *op_name;
/* Build the mangling for TYPE. */ /* Build the internal mangling for TYPE. */
const char *mangled_type = mangle_type_string (type); G.internal_mangling_p = true;
mangled_type = mangle_type_string (type);
G.internal_mangling_p = false;
/* Allocate a temporary buffer for the complete name. */ /* Allocate a temporary buffer for the complete name. */
char *op_name = concat ("operator ", mangled_type, NULL); op_name = concat ("operator ", mangled_type, NULL);
/* Find or create an identifier. */ /* Find or create an identifier. */
identifier = get_identifier (op_name); identifier = get_identifier (op_name);
/* Done with the temporary buffer. */ /* Done with the temporary buffer. */
free (op_name); free (op_name);
/* It had better be a unique mangling for the type. */
my_friendly_assert (!IDENTIFIER_TYPENAME_P (identifier)
|| same_type_p (type, TREE_TYPE (identifier)),
20011230);
/* Set bits on the identifier so we know later it's a conversion. */ /* Set bits on the identifier so we know later it's a conversion. */
IDENTIFIER_OPNAME_P (identifier) = 1; IDENTIFIER_OPNAME_P (identifier) = 1;
IDENTIFIER_TYPENAME_P (identifier) = 1; IDENTIFIER_TYPENAME_P (identifier) = 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment