Commit 39fb05d0 by Mark Mitchell Committed by Mark Mitchell

cp-tree.h (lang_identifier): Remove class_value.

	* cp-tree.h (lang_identifier): Remove class_value.
	(IDENTIFIER_CLASS_VALUE): Remove.
	(pop_class_decls): Likewise.
	(init_search_processing): Likewise.
	* class.c (handle_using_decl): Use lookup_member, not
	IDENTIFIER_CLASS_VALUE.
	(restore_class_cache): New function, split out from ...
	(pushclass): ... here.  Do not call clear_identifier_class_values.
	(invalidate_class_lookup_cache): Do not clear
	IDENTIFIER_CLASS_VALUE.
	(popclass): Do not call pop_class_decls.
	(maybe_note_name_used_in_class): Do not save names looked up after
	the class is complete.  Use lookup_member, not
	IDENTIFIER_CLASS_VALUE.
	* config-lang.in (gtfiles): Add $(srcdir)/cp/search.c.
	* decl.c (cxx_init_decl_processing): Do not call
	init_search_processing.
	* method.c (do_build_copy_constructor): Remove unnecessary code.
	(do_build_assign_ref): Likewise.
	* name-lookup.c (pushdecl): Use lookup_member, not
	IDENTIFIER_CLASS_VALUE.
	(set_identifier_type_value_with_scope): Set TREE_TYPE on the
	type_shadowed list.
	(poplevel_class): Do not restore IDENTIFIER_CLASS_VALUE.
	(push_class_binding): Do not set it.
	(clear_identifier_class_values): Remove.
	(push_class_level_binding): Do not set IDENTIFIER_CLASS_VALUE.
	(store_binding): Do not save it.
	(pop_from_top_level): Do not restore it.
	* name-lookup.h (cxx_saved_binding): Remove class_value.
	(clear_identifier_class_values): Remove.
	* ptree.c (cxx_print_identifier): Do not print
	IDENTIFIER_CLASS_VALUE.
	* search.c (search_obstack): Remove.
	(push_stack_level): Remove.
	(pop_stack_level): Remove.
	(search_level): Remove.
	(search_stack): Remove.
	(lookup_member): Don't check IDENTIFIER_CLASS_VALUE.
	(setup_class_bindings): Use IDENTIFIER_MARKED, not
	IDENTIFIER_CLASS_VALUE.
	(marked_identifiers): New variable.
	(push_class_decls): Clear IDENTIFIER_MARKED.
	(pop_class_decls): Don't call pop_search_level.
	(init_search_processing): Remove.

From-SVN: r84629
parent 6aa57acc
2004-07-13 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (lang_identifier): Remove class_value.
(IDENTIFIER_CLASS_VALUE): Remove.
(pop_class_decls): Likewise.
(init_search_processing): Likewise.
* class.c (handle_using_decl): Use lookup_member, not
IDENTIFIER_CLASS_VALUE.
(restore_class_cache): New function, split out from ...
(pushclass): ... here. Do not call clear_identifier_class_values.
(invalidate_class_lookup_cache): Do not clear
IDENTIFIER_CLASS_VALUE.
(popclass): Do not call pop_class_decls.
(maybe_note_name_used_in_class): Do not save names looked up after
the class is complete. Use lookup_member, not
IDENTIFIER_CLASS_VALUE.
* config-lang.in (gtfiles): Add $(srcdir)/cp/search.c.
* decl.c (cxx_init_decl_processing): Do not call
init_search_processing.
* method.c (do_build_copy_constructor): Remove unnecessary code.
(do_build_assign_ref): Likewise.
* name-lookup.c (pushdecl): Use lookup_member, not
IDENTIFIER_CLASS_VALUE.
(set_identifier_type_value_with_scope): Set TREE_TYPE on the
type_shadowed list.
(poplevel_class): Do not restore IDENTIFIER_CLASS_VALUE.
(push_class_binding): Do not set it.
(clear_identifier_class_values): Remove.
(push_class_level_binding): Do not set IDENTIFIER_CLASS_VALUE.
(store_binding): Do not save it.
(pop_from_top_level): Do not restore it.
* name-lookup.h (cxx_saved_binding): Remove class_value.
(clear_identifier_class_values): Remove.
* ptree.c (cxx_print_identifier): Do not print
IDENTIFIER_CLASS_VALUE.
* search.c (search_obstack): Remove.
(push_stack_level): Remove.
(pop_stack_level): Remove.
(search_level): Remove.
(search_stack): Remove.
(lookup_member): Don't check IDENTIFIER_CLASS_VALUE.
(setup_class_bindings): Use IDENTIFIER_MARKED, not
IDENTIFIER_CLASS_VALUE.
(marked_identifiers): New variable.
(push_class_decls): Clear IDENTIFIER_MARKED.
(pop_class_decls): Don't call pop_search_level.
(init_search_processing): Remove.
2004-07-12 Mark Mitchell <mark@codesourcery.com> 2004-07-12 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (get_aggr_typedef): Remove. * cp-tree.h (get_aggr_typedef): Remove.
......
...@@ -1130,7 +1130,7 @@ handle_using_decl (tree using_decl, tree t) ...@@ -1130,7 +1130,7 @@ handle_using_decl (tree using_decl, tree t)
/* Ignore base type this came from. */ /* Ignore base type this came from. */
fdecl = BASELINK_FUNCTIONS (fdecl); fdecl = BASELINK_FUNCTIONS (fdecl);
old_value = IDENTIFIER_CLASS_VALUE (name); old_value = lookup_member (t, name, /*protect=*/0, /*want_type=*/false);
if (old_value) if (old_value)
{ {
if (is_overloaded_fn (old_value)) if (is_overloaded_fn (old_value))
...@@ -5479,6 +5479,40 @@ init_class_processing (void) ...@@ -5479,6 +5479,40 @@ init_class_processing (void)
ridpointers[(int) RID_PROTECTED] = access_protected_node; ridpointers[(int) RID_PROTECTED] = access_protected_node;
} }
/* Restore the cached PREVIOUS_CLASS_LEVEL. */
static void
restore_class_cache (void)
{
cp_class_binding *cb;
tree type;
size_t i;
/* We are re-entering the same class we just left, so we don't
have to search the whole inheritance matrix to find all the
decls to bind again. Instead, we install the cached
class_shadowed list and walk through it binding names. */
push_binding_level (previous_class_level);
class_binding_level = previous_class_level;
for (i = 0;
(cb = VEC_iterate (cp_class_binding,
previous_class_level->class_shadowed,
i));
++i)
{
tree id;
id = cb->identifier;
cb->base.previous = IDENTIFIER_BINDING (id);
IDENTIFIER_BINDING (id) = &cb->base;
}
/* Restore IDENTIFIER_TYPE_VALUE. */
for (type = class_binding_level->type_shadowed;
type;
type = TREE_CHAIN (type))
SET_IDENTIFIER_TYPE_VALUE (TREE_PURPOSE (type), TREE_TYPE (type));
}
/* Set global variables CURRENT_CLASS_NAME and CURRENT_CLASS_TYPE as /* Set global variables CURRENT_CLASS_NAME and CURRENT_CLASS_TYPE as
appropriate for TYPE. appropriate for TYPE.
...@@ -5486,12 +5520,7 @@ init_class_processing (void) ...@@ -5486,12 +5520,7 @@ init_class_processing (void)
nodes of local TYPE_DECLs in the TREE_TYPE field of the name. nodes of local TYPE_DECLs in the TREE_TYPE field of the name.
For multiple inheritance, we perform a two-pass depth-first search For multiple inheritance, we perform a two-pass depth-first search
of the type lattice. The first pass performs a pre-order search, of the type lattice. */
marking types after the type has had its fields installed in
the appropriate IDENTIFIER_CLASS_VALUE slot. The second pass merely
unmarks the marked types. If a field or member function name
appears in an ambiguous way, the IDENTIFIER_CLASS_VALUE of
that name becomes `error_mark_node'. */
void void
pushclass (tree type) pushclass (tree type)
...@@ -5535,11 +5564,6 @@ pushclass (tree type) ...@@ -5535,11 +5564,6 @@ pushclass (tree type)
invalidate_class_lookup_cache (); invalidate_class_lookup_cache ();
} }
/* If we're about to enter a nested class, clear
IDENTIFIER_CLASS_VALUE for the enclosing classes. */
if (current_class_depth > 1)
clear_identifier_class_values ();
if (!previous_class_level if (!previous_class_level
|| type != previous_class_level->this_entity || type != previous_class_level->this_entity
|| current_class_depth > 1) || current_class_depth > 1)
...@@ -5560,58 +5584,18 @@ pushclass (tree type) ...@@ -5560,58 +5584,18 @@ pushclass (tree type)
} }
} }
else else
{ restore_class_cache ();
cp_class_binding *cb;
size_t i;
/* We are re-entering the same class we just left, so we don't
have to search the whole inheritance matrix to find all the
decls to bind again. Instead, we install the cached
class_shadowed list, and walk through it binding names and
setting up IDENTIFIER_TYPE_VALUEs. */
push_binding_level (previous_class_level);
class_binding_level = previous_class_level;
for (i = 0;
(cb = VEC_iterate (cp_class_binding,
previous_class_level->class_shadowed,
i));
++i)
{
tree id;
tree type_decl;
id = cb->identifier;
cb->base.previous = IDENTIFIER_BINDING (id);
IDENTIFIER_BINDING (id) = &cb->base;
type_decl = cb->base.value;
if (!type_decl || TREE_CODE (type_decl) != TYPE_DECL)
type_decl = cb->base.type;
if (type_decl && TREE_CODE (type_decl) == TYPE_DECL)
set_identifier_type_value (id, type_decl);
}
}
cxx_remember_type_decls (CLASSTYPE_NESTED_UTDS (type)); cxx_remember_type_decls (CLASSTYPE_NESTED_UTDS (type));
} }
/* When we exit a toplevel class scope, we save the /* When we exit a toplevel class scope, we save its binding level so
IDENTIFIER_CLASS_VALUEs so that we can restore them quickly if we that we can restore it quickly. Here, we've entered some other
reenter the class. Here, we've entered some other class, so we class, so we must invalidate our cache. */
must invalidate our cache. */
void void
invalidate_class_lookup_cache (void) invalidate_class_lookup_cache (void)
{ {
size_t i;
cp_class_binding *cb;
/* The IDENTIFIER_CLASS_VALUEs are no longer valid. */
for (i = 0;
(cb = VEC_iterate (cp_class_binding,
previous_class_level->class_shadowed, i));
++i)
IDENTIFIER_CLASS_VALUE (cb->identifier) = NULL_TREE;
previous_class_level = NULL; previous_class_level = NULL;
} }
...@@ -5622,7 +5606,6 @@ void ...@@ -5622,7 +5606,6 @@ void
popclass (void) popclass (void)
{ {
poplevel_class (); poplevel_class ();
pop_class_decls ();
current_class_depth--; current_class_depth--;
current_class_name = current_class_stack[current_class_depth].name; current_class_name = current_class_stack[current_class_depth].name;
...@@ -6448,12 +6431,14 @@ maybe_note_name_used_in_class (tree name, tree decl) ...@@ -6448,12 +6431,14 @@ maybe_note_name_used_in_class (tree name, tree decl)
splay_tree names_used; splay_tree names_used;
/* If we're not defining a class, there's nothing to do. */ /* If we're not defining a class, there's nothing to do. */
if (innermost_scope_kind() != sk_class) if (!(innermost_scope_kind() == sk_class
&& TYPE_BEING_DEFINED (current_class_type)))
return; return;
/* If there's already a binding for this NAME, then we don't have /* If there's already a binding for this NAME, then we don't have
anything to worry about. */ anything to worry about. */
if (IDENTIFIER_CLASS_VALUE (name)) if (lookup_member (current_class_type, name,
/*protect=*/0, /*want_type=*/false))
return; return;
if (!current_class_stack[current_class_depth - 1].names_used) if (!current_class_stack[current_class_depth - 1].names_used)
......
...@@ -34,4 +34,4 @@ stagestuff="g++\$(exeext) g++-cross\$(exeext) cc1plus\$(exeext)" ...@@ -34,4 +34,4 @@ stagestuff="g++\$(exeext) g++-cross\$(exeext) cc1plus\$(exeext)"
target_libs="target-libstdc++-v3 target-gperf" target_libs="target-libstdc++-v3 target-gperf"
gtfiles="\$(srcdir)/cp/mangle.c \$(srcdir)/cp/name-lookup.h \$(srcdir)/cp/name-lookup.c \$(srcdir)/cp/cp-tree.h \$(srcdir)/cp/decl.h \$(srcdir)/cp/call.c \$(srcdir)/cp/decl.c \$(srcdir)/cp/decl2.c \$(srcdir)/cp/pt.c \$(srcdir)/cp/repo.c \$(srcdir)/cp/semantics.c \$(srcdir)/cp/tree.c \$(srcdir)/cp/parser.c \$(srcdir)/cp/method.c \$(srcdir)/cp/typeck2.c \$(srcdir)/c-common.c \$(srcdir)/c-common.h \$(srcdir)/c-lex.c \$(srcdir)/c-pragma.c" gtfiles="\$(srcdir)/cp/mangle.c \$(srcdir)/cp/name-lookup.h \$(srcdir)/cp/name-lookup.c \$(srcdir)/cp/cp-tree.h \$(srcdir)/cp/decl.h \$(srcdir)/cp/call.c \$(srcdir)/cp/decl.c \$(srcdir)/cp/decl2.c \$(srcdir)/cp/pt.c \$(srcdir)/cp/repo.c \$(srcdir)/cp/search.c \$(srcdir)/cp/semantics.c \$(srcdir)/cp/tree.c \$(srcdir)/cp/parser.c \$(srcdir)/cp/method.c \$(srcdir)/cp/typeck2.c \$(srcdir)/c-common.c \$(srcdir)/c-common.h \$(srcdir)/c-lex.c \$(srcdir)/c-pragma.c"
...@@ -170,7 +170,6 @@ struct lang_identifier GTY(()) ...@@ -170,7 +170,6 @@ struct lang_identifier GTY(())
struct c_common_identifier c_common; struct c_common_identifier c_common;
cxx_binding *namespace_bindings; cxx_binding *namespace_bindings;
cxx_binding *bindings; cxx_binding *bindings;
tree class_value;
tree class_template_info; tree class_template_info;
tree label_value; tree label_value;
}; };
...@@ -340,14 +339,6 @@ typedef enum cp_id_kind ...@@ -340,14 +339,6 @@ typedef enum cp_id_kind
#define IDENTIFIER_VALUE(NODE) \ #define IDENTIFIER_VALUE(NODE) \
(IDENTIFIER_BINDING (NODE) ? IDENTIFIER_BINDING (NODE)->value : NULL) (IDENTIFIER_BINDING (NODE) ? IDENTIFIER_BINDING (NODE)->value : NULL)
/* If IDENTIFIER_CLASS_VALUE is set, then NODE is bound in the current
class, and IDENTIFIER_CLASS_VALUE is the value binding. This is
just a pointer to the VALUE field of one of the bindings in the
IDENTIFIER_BINDINGs list, so any time that this is non-NULL so is
IDENTIFIER_BINDING. */
#define IDENTIFIER_CLASS_VALUE(NODE) \
(LANG_IDENTIFIER_CAST (NODE)->class_value)
/* TREE_TYPE only indicates on local and class scope the current /* TREE_TYPE only indicates on local and class scope the current
type. For namespace scope, the presence of a type in any namespace type. For namespace scope, the presence of a type in any namespace
is indicated with global_type_node, and the real type behind must is indicated with global_type_node, and the real type behind must
...@@ -4013,9 +4004,7 @@ extern void get_pure_virtuals (tree); ...@@ -4013,9 +4004,7 @@ extern void get_pure_virtuals (tree);
extern void maybe_suppress_debug_info (tree); extern void maybe_suppress_debug_info (tree);
extern void note_debug_info_needed (tree); extern void note_debug_info_needed (tree);
extern void push_class_decls (tree); extern void push_class_decls (tree);
extern void pop_class_decls (void);
extern void print_search_statistics (void); extern void print_search_statistics (void);
extern void init_search_processing (void);
extern void reinit_search_statistics (void); extern void reinit_search_statistics (void);
extern tree current_scope (void); extern tree current_scope (void);
extern int at_function_scope_p (void); extern int at_function_scope_p (void);
......
...@@ -3047,7 +3047,6 @@ cxx_init_decl_processing (void) ...@@ -3047,7 +3047,6 @@ cxx_init_decl_processing (void)
/* Perform other language dependent initializations. */ /* Perform other language dependent initializations. */
init_class_processing (); init_class_processing ();
init_search_processing ();
init_rtti_processing (); init_rtti_processing ();
if (flag_exceptions) if (flag_exceptions)
......
...@@ -567,10 +567,6 @@ do_build_copy_constructor (tree fndecl) ...@@ -567,10 +567,6 @@ do_build_copy_constructor (tree fndecl)
{ {
if (VFIELD_NAME_P (DECL_NAME (field))) if (VFIELD_NAME_P (DECL_NAME (field)))
continue; continue;
/* True for duplicate members. */
if (IDENTIFIER_CLASS_VALUE (DECL_NAME (field)) != field)
continue;
} }
else if ((t = TREE_TYPE (field)) != NULL_TREE else if ((t = TREE_TYPE (field)) != NULL_TREE
&& ANON_AGGR_TYPE_P (t) && ANON_AGGR_TYPE_P (t)
...@@ -673,10 +669,6 @@ do_build_assign_ref (tree fndecl) ...@@ -673,10 +669,6 @@ do_build_assign_ref (tree fndecl)
{ {
if (VFIELD_NAME_P (DECL_NAME (field))) if (VFIELD_NAME_P (DECL_NAME (field)))
continue; continue;
/* True for duplicate members. */
if (IDENTIFIER_CLASS_VALUE (DECL_NAME (field)) != field)
continue;
} }
else if ((t = TREE_TYPE (field)) != NULL_TREE else if ((t = TREE_TYPE (field)) != NULL_TREE
&& ANON_AGGR_TYPE_P (t) && ANON_AGGR_TYPE_P (t)
......
...@@ -997,9 +997,17 @@ pushdecl (tree x) ...@@ -997,9 +997,17 @@ pushdecl (tree x)
/* No shadow warnings for vars made for inlining. */ /* No shadow warnings for vars made for inlining. */
&& ! DECL_FROM_INLINE (x)) && ! DECL_FROM_INLINE (x))
{ {
if (IDENTIFIER_CLASS_VALUE (name) != NULL_TREE tree member;
&& current_class_ptr
&& !TREE_STATIC (name)) if (current_class_ptr)
member = lookup_member (current_class_type,
name,
/*protect=*/0,
/*want_type=*/false);
else
member = NULL_TREE;
if (member && !TREE_STATIC (member))
{ {
/* Location of previous decl is not useful in this case. */ /* Location of previous decl is not useful in this case. */
warning ("declaration of '%D' shadows a member of 'this'", warning ("declaration of '%D' shadows a member of 'this'",
...@@ -1777,6 +1785,7 @@ set_identifier_type_value_with_scope (tree id, tree decl, cxx_scope *b) ...@@ -1777,6 +1785,7 @@ set_identifier_type_value_with_scope (tree id, tree decl, cxx_scope *b)
b->type_shadowed b->type_shadowed
= tree_cons (id, old_type_value, b->type_shadowed); = tree_cons (id, old_type_value, b->type_shadowed);
type = decl ? TREE_TYPE (decl) : NULL_TREE; type = decl ? TREE_TYPE (decl) : NULL_TREE;
TREE_TYPE (b->type_shadowed) = type;
} }
else else
{ {
...@@ -2629,46 +2638,8 @@ poplevel_class (void) ...@@ -2629,46 +2638,8 @@ poplevel_class (void)
timevar_push (TV_NAME_LOOKUP); timevar_push (TV_NAME_LOOKUP);
my_friendly_assert (level != 0, 354); my_friendly_assert (level != 0, 354);
/* If we're leaving a toplevel class, don't bother to do the setting /* If we're leaving a toplevel class, cache its binding level. */
of IDENTIFIER_CLASS_VALUE to NULL_TREE, since first of all this slot if (current_class_depth == 1)
shouldn't even be used when current_class_type isn't set, and second,
if we don't touch it here, we're able to use the cache effect if the
next time we're entering a class scope, it is the same class. */
if (current_class_depth != 1)
{
struct cp_binding_level* b;
cp_class_binding* cb;
size_t i;
/* Clear out our IDENTIFIER_CLASS_VALUEs. */
clear_identifier_class_values ();
/* Find the next enclosing class, and recreate
IDENTIFIER_CLASS_VALUEs appropriate for that class. */
b = level->level_chain;
while (b && b->kind != sk_class)
b = b->level_chain;
if (b)
for (i = 0;
(cb = VEC_iterate (cp_class_binding,
b->class_shadowed,
i));
++i)
{
cxx_binding *binding;
binding = IDENTIFIER_BINDING (cb->identifier);
while (binding && binding->scope != b)
binding = binding->previous;
if (binding)
IDENTIFIER_CLASS_VALUE (cb->identifier) = binding->value;
}
}
else
/* Remember to save what IDENTIFIER's were bound in this scope so we
can recover from cache misses. */
previous_class_level = level; previous_class_level = level;
for (shadowed = level->type_shadowed; for (shadowed = level->type_shadowed;
shadowed; shadowed;
...@@ -2713,13 +2684,6 @@ push_class_binding (tree id, tree decl) ...@@ -2713,13 +2684,6 @@ push_class_binding (tree id, tree decl)
/* Create a new binding. */ /* Create a new binding. */
push_binding (id, decl, class_binding_level); push_binding (id, decl, class_binding_level);
/* Update the IDENTIFIER_CLASS_VALUE for this ID to be the
class-level declaration. Note that we do not use DECL here
because of the possibility of the `struct stat' hack; if DECL is
a class-name or enum-name we might prefer a field-name, or some
such. */
IDENTIFIER_CLASS_VALUE (id) = IDENTIFIER_BINDING (id)->value;
/* If this is a binding from a base class, mark it as such. */ /* If this is a binding from a base class, mark it as such. */
binding = IDENTIFIER_BINDING (id); binding = IDENTIFIER_BINDING (id);
if (binding->value == decl && TREE_CODE (decl) != TREE_LIST) if (binding->value == decl && TREE_CODE (decl) != TREE_LIST)
...@@ -2746,24 +2710,6 @@ push_class_binding (tree id, tree decl) ...@@ -2746,24 +2710,6 @@ push_class_binding (tree id, tree decl)
POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, result); POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, result);
} }
/* We are entering the scope of a class. Clear IDENTIFIER_CLASS_VALUE
for any names in enclosing classes. */
void
clear_identifier_class_values (void)
{
size_t i;
cp_class_binding *cb;
if (class_binding_level)
for (i = 0;
(cb = VEC_iterate (cp_class_binding,
class_binding_level->class_shadowed,
i));
++i)
IDENTIFIER_CLASS_VALUE (cb->identifier) = NULL_TREE;
}
/* Make the declaration of X appear in CLASS scope. */ /* Make the declaration of X appear in CLASS scope. */
bool bool
...@@ -2821,9 +2767,9 @@ push_class_level_binding (tree name, tree x) ...@@ -2821,9 +2767,9 @@ push_class_level_binding (tree name, tree x)
POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, true); POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, true);
/* Check for invalid member names, if the class is being defined. /* Check for invalid member names, if the class is being defined.
This function is also used to restore IDENTIFIER_CLASS_VALUE, This function is also used to restore bindings when reentering
when reentering the class scope, and there is no point in the class scope, and there is no point in checking again at that
checking again at that time. */ time. */
if (TYPE_BEING_DEFINED (current_class_type)) if (TYPE_BEING_DEFINED (current_class_type))
{ {
tree decl = x; tree decl = x;
...@@ -2875,8 +2821,8 @@ push_class_level_binding (tree name, tree x) ...@@ -2875,8 +2821,8 @@ push_class_level_binding (tree name, tree x)
} }
/* If this declaration shadows a declaration from an enclosing /* If this declaration shadows a declaration from an enclosing
class, then we will need to restore IDENTIFIER_CLASS_VALUE when class, then we will need to restore bindings when we leave this
we leave this class. Record the shadowed declaration here. */ class. Record the shadowed declaration here. */
binding = IDENTIFIER_BINDING (name); binding = IDENTIFIER_BINDING (name);
if (binding && binding->value) if (binding && binding->value)
{ {
...@@ -2922,7 +2868,6 @@ push_class_level_binding (tree name, tree x) ...@@ -2922,7 +2868,6 @@ push_class_level_binding (tree name, tree x)
coming from a definition in the body of the class coming from a definition in the body of the class
itself. */ itself. */
INHERITED_VALUE_BINDING_P (binding) = 0; INHERITED_VALUE_BINDING_P (binding) = 0;
IDENTIFIER_CLASS_VALUE (name) = x;
POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, true); POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, true);
} }
} }
...@@ -3994,11 +3939,8 @@ qualified_lookup_using_namespace (tree name, tree scope, ...@@ -3994,11 +3939,8 @@ qualified_lookup_using_namespace (tree name, tree scope,
If PREFER_TYPE is > 1, we reject non-type decls (e.g. namespaces). If PREFER_TYPE is > 1, we reject non-type decls (e.g. namespaces).
Otherwise we prefer non-TYPE_DECLs. Otherwise we prefer non-TYPE_DECLs.
If NONCLASS is nonzero, we don't look for the NAME in class scope, If NONCLASS is nonzero, bindings in class scopes are ignored. If
using IDENTIFIER_CLASS_VALUE. BLOCK_P is false, bindings in block scopes are ignored. */
If BLOCK_P is true, block scopes are examined; otherwise, they are
skipped. */
tree tree
lookup_name_real (tree name, int prefer_type, int nonclass, bool block_p, lookup_name_real (tree name, int prefer_type, int nonclass, bool block_p,
...@@ -4831,11 +4773,7 @@ store_binding (tree id, VEC(cxx_saved_binding) **old_bindings) ...@@ -4831,11 +4773,7 @@ store_binding (tree id, VEC(cxx_saved_binding) **old_bindings)
{ {
cxx_saved_binding *saved; cxx_saved_binding *saved;
if (!id if (!id || !IDENTIFIER_BINDING (id))
/* Note that we may have an IDENTIFIER_CLASS_VALUE even when
we have no IDENTIFIER_BINDING if we have left the class
scope, but cached the class-level declarations. */
|| !(IDENTIFIER_BINDING (id) || IDENTIFIER_CLASS_VALUE (id)))
return; return;
if (IDENTIFIER_MARKED (id)) if (IDENTIFIER_MARKED (id))
...@@ -4846,10 +4784,8 @@ store_binding (tree id, VEC(cxx_saved_binding) **old_bindings) ...@@ -4846,10 +4784,8 @@ store_binding (tree id, VEC(cxx_saved_binding) **old_bindings)
saved = VEC_safe_push (cxx_saved_binding, *old_bindings, NULL); saved = VEC_safe_push (cxx_saved_binding, *old_bindings, NULL);
saved->identifier = id; saved->identifier = id;
saved->binding = IDENTIFIER_BINDING (id); saved->binding = IDENTIFIER_BINDING (id);
saved->class_value = IDENTIFIER_CLASS_VALUE (id);;
saved->real_type_value = REAL_IDENTIFIER_TYPE_VALUE (id); saved->real_type_value = REAL_IDENTIFIER_TYPE_VALUE (id);
IDENTIFIER_BINDING (id) = NULL; IDENTIFIER_BINDING (id) = NULL;
IDENTIFIER_CLASS_VALUE (id) = NULL_TREE;
} }
static void static void
...@@ -4981,7 +4917,6 @@ pop_from_top_level (void) ...@@ -4981,7 +4917,6 @@ pop_from_top_level (void)
tree id = saved->identifier; tree id = saved->identifier;
IDENTIFIER_BINDING (id) = saved->binding; IDENTIFIER_BINDING (id) = saved->binding;
IDENTIFIER_CLASS_VALUE (id) = saved->class_value;
SET_IDENTIFIER_TYPE_VALUE (id, saved->real_type_value); SET_IDENTIFIER_TYPE_VALUE (id, saved->real_type_value);
} }
......
...@@ -88,7 +88,6 @@ typedef struct cxx_saved_binding GTY(()) ...@@ -88,7 +88,6 @@ typedef struct cxx_saved_binding GTY(())
tree identifier; tree identifier;
/* The binding we're saving. */ /* The binding we're saving. */
cxx_binding *binding; cxx_binding *binding;
tree class_value;
tree real_type_value; tree real_type_value;
} cxx_saved_binding; } cxx_saved_binding;
...@@ -97,7 +96,6 @@ DEF_VEC_O(cxx_saved_binding); ...@@ -97,7 +96,6 @@ DEF_VEC_O(cxx_saved_binding);
extern tree identifier_type_value (tree); extern tree identifier_type_value (tree);
extern void set_identifier_type_value (tree, tree); extern void set_identifier_type_value (tree, tree);
extern void pop_binding (tree, tree); extern void pop_binding (tree, tree);
extern void clear_identifier_class_values (void);
extern tree constructor_name_full (tree); extern tree constructor_name_full (tree);
extern tree constructor_name (tree); extern tree constructor_name (tree);
extern bool constructor_name_p (tree, tree); extern bool constructor_name_p (tree, tree);
......
...@@ -157,7 +157,6 @@ cxx_print_identifier (FILE *file, tree node, int indent) ...@@ -157,7 +157,6 @@ cxx_print_identifier (FILE *file, tree node, int indent)
{ {
indent_to (file, indent); indent_to (file, indent);
cxx_print_binding (file, IDENTIFIER_NAMESPACE_BINDINGS (node), "bindings"); cxx_print_binding (file, IDENTIFIER_NAMESPACE_BINDINGS (node), "bindings");
print_node (file, "class", IDENTIFIER_CLASS_VALUE (node), indent + 4);
indent_to (file, indent); indent_to (file, indent);
cxx_print_binding (file, IDENTIFIER_BINDING (node), "local bindings"); cxx_print_binding (file, IDENTIFIER_BINDING (node), "local bindings");
print_node (file, "label", IDENTIFIER_LABEL_VALUE (node), indent + 4); print_node (file, "label", IDENTIFIER_LABEL_VALUE (node), indent + 4);
......
...@@ -36,39 +36,6 @@ Boston, MA 02111-1307, USA. */ ...@@ -36,39 +36,6 @@ Boston, MA 02111-1307, USA. */
#include "toplev.h" #include "toplev.h"
#include "stack.h" #include "stack.h"
/* Obstack used for remembering decision points of breadth-first. */
static struct obstack search_obstack;
/* Methods for pushing and popping objects to and from obstacks. */
struct stack_level *
push_stack_level (struct obstack *obstack, char *tp,/* Sony NewsOS 5.0 compiler doesn't like void * here. */
int size)
{
struct stack_level *stack;
obstack_grow (obstack, tp, size);
stack = (struct stack_level *) ((char*)obstack_next_free (obstack) - size);
obstack_finish (obstack);
stack->obstack = obstack;
stack->first = (tree *) obstack_base (obstack);
stack->limit = obstack_room (obstack) / sizeof (tree *);
return stack;
}
struct stack_level *
pop_stack_level (struct stack_level *stack)
{
struct stack_level *tem = stack;
struct obstack *obstack = tem->obstack;
stack = tem->prev;
obstack_free (obstack, tem);
return stack;
}
#define search_level stack_level
static struct search_level *search_stack;
struct vbase_info struct vbase_info
{ {
/* The class dominating the hierarchy. */ /* The class dominating the hierarchy. */
...@@ -90,9 +57,6 @@ static tree dfs_push_type_decls (tree, void *); ...@@ -90,9 +57,6 @@ static tree dfs_push_type_decls (tree, void *);
static tree dfs_push_decls (tree, void *); static tree dfs_push_decls (tree, void *);
static tree add_conversions (tree, void *); static tree add_conversions (tree, void *);
static int look_for_overrides_r (tree, tree); static int look_for_overrides_r (tree, tree);
static struct search_level *push_search_level (struct stack_level *,
struct obstack *);
static struct search_level *pop_search_level (struct stack_level *);
static tree bfs_walk (tree, tree (*) (tree, void *), static tree bfs_walk (tree, tree (*) (tree, void *),
tree (*) (tree, int, void *), void *); tree (*) (tree, int, void *), void *);
static tree lookup_field_queue_p (tree, int, void *); static tree lookup_field_queue_p (tree, int, void *);
...@@ -108,26 +72,6 @@ static void setup_class_bindings (tree, int); ...@@ -108,26 +72,6 @@ static void setup_class_bindings (tree, int);
static int template_self_reference_p (tree, tree); static int template_self_reference_p (tree, tree);
static tree dfs_get_pure_virtuals (tree, void *); static tree dfs_get_pure_virtuals (tree, void *);
/* Allocate a level of searching. */
static struct search_level *
push_search_level (struct stack_level *stack, struct obstack *obstack)
{
struct search_level tem;
tem.prev = stack;
return push_stack_level (obstack, (char *)&tem, sizeof (tem));
}
/* Discard a level of search allocation. */
static struct search_level *
pop_search_level (struct stack_level *obstack)
{
struct search_level *stack = pop_stack_level (obstack);
return stack;
}
/* Variables for gathering statistics. */ /* Variables for gathering statistics. */
#ifdef GATHER_STATISTICS #ifdef GATHER_STATISTICS
...@@ -1263,17 +1207,6 @@ lookup_member (tree xbasetype, tree name, int protect, bool want_type) ...@@ -1263,17 +1207,6 @@ lookup_member (tree xbasetype, tree name, int protect, bool want_type)
xbasetype = NULL_TREE; xbasetype = NULL_TREE;
} }
if (type == current_class_type && TYPE_BEING_DEFINED (type)
&& IDENTIFIER_CLASS_VALUE (name))
{
tree field = IDENTIFIER_CLASS_VALUE (name);
if (! is_overloaded_fn (field)
&& ! (want_type && TREE_CODE (field) != TYPE_DECL))
/* We're in the scope of this class, and the value has already
been looked up. Just return the cached value. */
return field;
}
type = complete_type (type); type = complete_type (type);
if (!basetype_path) if (!basetype_path)
basetype_path = TYPE_BINFO (type); basetype_path = TYPE_BINFO (type);
...@@ -2099,6 +2032,11 @@ note_debug_info_needed (tree type) ...@@ -2099,6 +2032,11 @@ note_debug_info_needed (tree type)
dfs_walk (TYPE_BINFO (type), dfs_debug_mark, dfs_debug_unmarkedp, 0); dfs_walk (TYPE_BINFO (type), dfs_debug_mark, dfs_debug_unmarkedp, 0);
} }
/* A vector of IDENTIFIER_NODEs that have been processed by
setup_class_bindings. */
static GTY(()) VEC(tree) *marked_identifiers;
/* Subroutines of push_class_decls (). */ /* Subroutines of push_class_decls (). */
static void static void
...@@ -2109,9 +2047,12 @@ setup_class_bindings (tree name, int type_binding_p) ...@@ -2109,9 +2047,12 @@ setup_class_bindings (tree name, int type_binding_p)
/* If we've already done the lookup for this declaration, we're /* If we've already done the lookup for this declaration, we're
done. */ done. */
if (IDENTIFIER_CLASS_VALUE (name)) if (IDENTIFIER_MARKED (name))
return; return;
IDENTIFIER_MARKED (name) = 1;
VEC_safe_push (tree, marked_identifiers, name);
/* First, deal with the type binding. */ /* First, deal with the type binding. */
if (type_binding_p) if (type_binding_p)
{ {
...@@ -2161,8 +2102,13 @@ setup_class_bindings (tree name, int type_binding_p) ...@@ -2161,8 +2102,13 @@ setup_class_bindings (tree name, int type_binding_p)
{ {
tree fns; tree fns;
for (fns = value_binding; fns; fns = OVL_NEXT (fns)) for (fns = value_binding; fns; fns = OVL_NEXT (fns))
if (IDENTIFIER_CLASS_VALUE (DECL_NAME (OVL_CURRENT (fns)))) {
return; tree name = DECL_NAME (OVL_CURRENT (fns));
if (IDENTIFIER_MARKED (name))
return;
IDENTIFIER_MARKED (name) = 1;
VEC_safe_push (tree, marked_identifiers, name);
}
} }
pushdecl_class_level (value_binding); pushdecl_class_level (value_binding);
} }
...@@ -2245,7 +2191,8 @@ dfs_push_decls (tree binfo, void *data) ...@@ -2245,7 +2191,8 @@ dfs_push_decls (tree binfo, void *data)
void void
push_class_decls (tree type) push_class_decls (tree type)
{ {
search_stack = push_search_level (search_stack, &search_obstack); tree id;
size_t i;
if (!TYPE_BINFO (type)) if (!TYPE_BINFO (type))
/* This occurs when parsing an invalid declarator id where the /* This occurs when parsing an invalid declarator id where the
...@@ -2257,15 +2204,14 @@ push_class_decls (tree type) ...@@ -2257,15 +2204,14 @@ push_class_decls (tree type)
/* Enter non-type declarations and unmark. */ /* Enter non-type declarations and unmark. */
dfs_walk (TYPE_BINFO (type), dfs_push_decls, marked_pushdecls_p, 0); dfs_walk (TYPE_BINFO (type), dfs_push_decls, marked_pushdecls_p, 0);
}
void /* Clear the IDENTIFIER_MARKED bits. */
pop_class_decls (void) for (i = 0;
{ (id = VEC_iterate (tree, marked_identifiers, i));
/* We haven't pushed a search level when dealing with cached classes, ++i)
so we'd better not try to pop it. */ IDENTIFIER_MARKED (id) = 0;
if (search_stack) if (marked_identifiers)
search_stack = pop_search_level (search_stack); VEC_truncate (tree, marked_identifiers, 0);
} }
void void
...@@ -2283,12 +2229,6 @@ print_search_statistics (void) ...@@ -2283,12 +2229,6 @@ print_search_statistics (void)
} }
void void
init_search_processing (void)
{
gcc_obstack_init (&search_obstack);
}
void
reinit_search_statistics (void) reinit_search_statistics (void)
{ {
#ifdef GATHER_STATISTICS #ifdef GATHER_STATISTICS
...@@ -2593,3 +2533,4 @@ original_binfo (tree binfo, tree here) ...@@ -2593,3 +2533,4 @@ original_binfo (tree binfo, tree here)
return result; return result;
} }
#include "gt-cp-search.h"
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