mirror of git://gcc.gnu.org/git/gcc.git
* name-lookup.c (push_class_level_binding): Simplify.
From-SVN: r84585
This commit is contained in:
parent
5e89a381f9
commit
f31045fde1
|
@ -1,3 +1,7 @@
|
|||
2004-07-12 Mark Mitchell <mark@codesourcery.com>
|
||||
|
||||
* name-lookup.c (push_class_level_binding): Simplify.
|
||||
|
||||
2004-07-12 Andrew Pinski <apinski@apple.com>
|
||||
|
||||
PR c++/16475
|
||||
|
|
|
@ -2820,8 +2820,10 @@ push_class_level_binding (tree name, tree x)
|
|||
if (!class_binding_level)
|
||||
POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, true);
|
||||
|
||||
/* Make sure that this new member does not have the same name
|
||||
as a template parameter. */
|
||||
/* Check for invalid member names, if the class is being defined.
|
||||
This function is also used to restore IDENTIFIER_CLASS_VALUE,
|
||||
when reentering the class scope, and there is no point in
|
||||
checking again at that time. */
|
||||
if (TYPE_BEING_DEFINED (current_class_type))
|
||||
{
|
||||
tree decl = x;
|
||||
|
@ -2834,7 +2836,6 @@ push_class_level_binding (tree name, tree x)
|
|||
decl = TREE_VALUE (decl);
|
||||
|
||||
check_template_shadow (decl);
|
||||
}
|
||||
|
||||
/* [class.mem]
|
||||
|
||||
|
@ -2865,11 +2866,13 @@ push_class_level_binding (tree name, tree x)
|
|||
tree scope = context_for_name_lookup (x);
|
||||
if (TYPE_P (scope) && same_type_p (scope, current_class_type))
|
||||
{
|
||||
error ("`%D' has the same name as the class in which it is declared",
|
||||
error ("`%D' has the same name as the class in which it is "
|
||||
"declared",
|
||||
x);
|
||||
POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If this declaration shadows a declaration from an enclosing
|
||||
class, then we will need to restore IDENTIFIER_CLASS_VALUE when
|
||||
|
@ -2906,29 +2909,23 @@ push_class_level_binding (tree name, tree x)
|
|||
else if (TREE_CODE (bval) == USING_DECL && is_overloaded_fn (x))
|
||||
POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, true);
|
||||
|
||||
if (old_decl)
|
||||
{
|
||||
cp_class_binding *cb;
|
||||
size_t i;
|
||||
|
||||
/* Find the previous binding of name on the class-shadowed
|
||||
list, and update it. */
|
||||
for (i = 0;
|
||||
(cb = VEC_iterate (cp_class_binding,
|
||||
class_binding_level->class_shadowed,
|
||||
i));
|
||||
++i)
|
||||
if (cb->identifier == name
|
||||
&& (cb->base.value == old_decl
|
||||
|| cb->base.type == old_decl))
|
||||
if (old_decl
|
||||
&& binding->scope == class_binding_level)
|
||||
{
|
||||
binding->value = x;
|
||||
/* It is always safe to clear INHERITED_VALUE_BINDING_P
|
||||
here. That flag is only set when setup_class_bindings
|
||||
inserts a binding from a base class, and
|
||||
setup_class_bindings only inserts a binding once for
|
||||
every name declared in the class and its base classes.
|
||||
So, if we see a second binding for this name, it must be
|
||||
coming from a definition in the body of the class
|
||||
itself. */
|
||||
INHERITED_VALUE_BINDING_P (binding) = 0;
|
||||
IDENTIFIER_CLASS_VALUE (name) = x;
|
||||
POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If we didn't replace an existing binding, put the binding on the
|
||||
stack of bindings for the identifier, and update the shadowed list. */
|
||||
|
|
Loading…
Reference in New Issue