static cp_binding_level *innermost_nonclass_level (void);
static void set_identifier_type_value_with_scope (tree id, tree decl,
cp_binding_level *b);
-static void set_namespace_binding (tree name, tree scope, tree val);
+static void set_namespace_binding (tree scope, tree name, tree val);
/* The bindings for a particular name in a particular scope. */
}
}
+/* Find the binding for NAME in the local binding level B. */
+
+static cxx_binding *
+find_local_binding (cp_binding_level *b, tree name)
+{
+ if (cxx_binding *binding = IDENTIFIER_BINDING (name))
+ for (;; b = b->level_chain)
+ {
+ if (binding->scope == b
+ && !(VAR_P (binding->value)
+ && DECL_DEAD_FOR_LOCAL (binding->value)))
+ return binding;
+
+ /* Cleanup contours are transparent to the language. */
+ if (b->kind != sk_cleanup)
+ break;
+ }
+ return NULL;
+}
+
/* [basic.lookup.koenig] */
/* A nonzero return value in the functions below indicates an error. */
|| TREE_CODE (x) == NAMESPACE_DECL
|| TREE_CODE (x) == CONST_DECL
|| TREE_CODE (x) == TEMPLATE_DECL))
- set_namespace_binding (name, current_namespace, x);
+ set_namespace_binding (current_namespace, name, x);
/* If new decl is `static' and an `extern' was seen previously,
warn about it. */
new_binding = decl;
if (doing_global)
- set_namespace_binding (name, current_namespace, new_binding);
+ set_namespace_binding (current_namespace, name, new_binding);
else
{
/* We only create an OVERLOAD if there was a previous binding at
static tree
-namespace_binding_1 (tree name, tree scope)
+namespace_binding_1 (tree scope, tree name)
{
cxx_binding *binding;
bool subtime = timevar_cond_start (TV_NAME_LOOKUP);
if (!ns)
ns = global_namespace;
- tree ret = namespace_binding_1 (name, ns);
+ tree ret = namespace_binding_1 (ns, name);
timevar_cond_stop (TV_NAME_LOOKUP, subtime);
return ret;
}
static void
-set_namespace_binding (tree name, tree scope, tree val)
+set_namespace_binding (tree scope, tree name, tree val)
{
cxx_binding *b;
{
bool subtime = timevar_cond_start (TV_NAME_LOOKUP);
- set_namespace_binding (name, global_namespace, val);
+ set_namespace_binding (global_namespace, name, val);
timevar_cond_stop (TV_NAME_LOOKUP, subtime);
}
static tree
lookup_name_innermost_nonclass_level_1 (tree name)
{
- cp_binding_level *b;
- tree t = NULL_TREE;
-
- b = innermost_nonclass_level ();
+ cp_binding_level *b = innermost_nonclass_level ();
if (b->kind == sk_namespace)
- {
- t = get_namespace_binding (current_namespace, name);
-
- /* extern "C" function() */
- if (t != NULL_TREE && TREE_CODE (t) == TREE_LIST)
- t = TREE_VALUE (t);
- }
- else if (IDENTIFIER_BINDING (name)
- && LOCAL_BINDING_P (IDENTIFIER_BINDING (name)))
- {
- cxx_binding *binding;
- binding = IDENTIFIER_BINDING (name);
- while (1)
- {
- if (binding->scope == b
- && !(VAR_P (binding->value)
- && DECL_DEAD_FOR_LOCAL (binding->value)))
- return binding->value;
-
- if (b->kind == sk_cleanup)
- b = b->level_chain;
- else
- break;
- }
- }
-
- return t;
+ return namespace_binding_1 (current_namespace, name);
+ else if (cxx_binding *binding = find_local_binding (b, name))
+ return binding->value;
+ else
+ return NULL_TREE;
}
/* Wrapper for lookup_name_innermost_nonclass_level_1. */