/* Fixup the current bindings, as they might have moved. */
size_t i;
- for (i = 0;
- VEC_iterate (cp_class_binding, scope->class_shadowed, i, cb);
- i++)
+ FOR_EACH_VEC_ELT (cp_class_binding, scope->class_shadowed, i, cb)
{
cxx_binding **b;
b = &IDENTIFIER_BINDING (cb->identifier);
if (TREE_CODE (decl) == NAMESPACE_DECL
&& !DECL_NAMESPACE_ALIAS (decl))
{
- TREE_CHAIN (decl) = b->namespaces;
+ DECL_CHAIN (decl) = b->namespaces;
b->namespaces = decl;
}
else
inlining. */
&& (!TYPE_NAME (type)
|| TYPE_NAME (type) != DECL_ABSTRACT_ORIGIN (x))))
- cp_set_underlying_type (x);
+ set_underlying_type (x);
if (type != error_mark_node
&& TYPE_NAME (type)
/* Inline decls shadow nothing. */
&& !DECL_FROM_INLINE (x)
&& (TREE_CODE (oldlocal) == PARM_DECL
- || TREE_CODE (oldlocal) == VAR_DECL)
- /* Don't check the `this' parameter. */
- && !DECL_ARTIFICIAL (oldlocal)
- && !DECL_ARTIFICIAL (x))
+ || TREE_CODE (oldlocal) == VAR_DECL
+ /* If the old decl is a type decl, only warn if the
+ old decl is an explicit typedef or if both the old
+ and new decls are type decls. */
+ || (TREE_CODE (oldlocal) == TYPE_DECL
+ && (!DECL_ARTIFICIAL (oldlocal)
+ || TREE_CODE (x) == TYPE_DECL)))
+ /* Don't check the `this' parameter or internally generated
+ vars unless it's an implicit typedef (see
+ create_implicit_typedef in decl.c). */
+ && (!DECL_ARTIFICIAL (oldlocal)
+ || DECL_IMPLICIT_TYPEDEF_P (oldlocal))
+ /* Don't check for internally generated vars unless
+ it's an implicit typedef (see create_implicit_typedef
+ in decl.c). */
+ && (!DECL_ARTIFICIAL (x) || DECL_IMPLICIT_TYPEDEF_P (x)))
{
bool nowarn = false;
/* Maybe warn if shadowing something else. */
else if (warn_shadow && !DECL_EXTERNAL (x)
- /* No shadow warnings for internally generated vars. */
- && ! DECL_ARTIFICIAL (x)
- /* No shadow warnings for vars made for inlining. */
- && ! DECL_FROM_INLINE (x))
+ /* No shadow warnings for internally generated vars unless
+ it's an implicit typedef (see create_implicit_typedef
+ in decl.c). */
+ && (! DECL_ARTIFICIAL (x) || DECL_IMPLICIT_TYPEDEF_P (x))
+ /* No shadow warnings for vars made for inlining. */
+ && ! DECL_FROM_INLINE (x))
{
tree member;
x);
}
else if (oldglobal != NULL_TREE
- && TREE_CODE (oldglobal) == VAR_DECL)
+ && (TREE_CODE (oldglobal) == VAR_DECL
+ /* If the old decl is a type decl, only warn if the
+ old decl is an explicit typedef or if both the
+ old and new decls are type decls. */
+ || (TREE_CODE (oldglobal) == TYPE_DECL
+ && (!DECL_ARTIFICIAL (oldglobal)
+ || TREE_CODE (x) == TYPE_DECL))))
/* XXX shadow warnings in outer-more namespaces */
{
warning_at (input_location, OPT_Wshadow,
&& DECL_CONTEXT (decl) != NULL_TREE
/* Definitions of namespace members outside their namespace are
possible. */
- && TREE_CODE (DECL_CONTEXT (decl)) != NAMESPACE_DECL)
+ && !DECL_NAMESPACE_SCOPE_P (decl))
|| (TREE_CODE (decl) == TEMPLATE_DECL && !namespace_bindings_p ())
|| type == unknown_type_node
/* The declaration of a template specialization does not affect
size_t i;
cp_class_binding *b;
fprintf (stderr, " class-shadowed:");
- for (i = 0;
- VEC_iterate(cp_class_binding, lvl->class_shadowed, i, b);
- ++i)
+ FOR_EACH_VEC_ELT (cp_class_binding, lvl->class_shadowed, i, b)
fprintf (stderr, " %s ", IDENTIFIER_POINTER (b->identifier));
fprintf (stderr, "\n");
}
timevar_push (TV_NAME_LOOKUP);
gcc_assert (TREE_CODE (scope) == NAMESPACE_DECL);
gcc_assert (TREE_CODE (name) == IDENTIFIER_NODE);
- for (decl = current_binding_level->usings; decl; decl = TREE_CHAIN (decl))
+ for (decl = current_binding_level->usings; decl; decl = DECL_CHAIN (decl))
if (USING_DECL_SCOPE (decl) == scope && DECL_NAME (decl) == name)
break;
if (decl)
namespace_bindings_p () ? decl : NULL_TREE);
decl = build_lang_decl (USING_DECL, name, NULL_TREE);
USING_DECL_SCOPE (decl) = scope;
- TREE_CHAIN (decl) = current_binding_level->usings;
+ DECL_CHAIN (decl) = current_binding_level->usings;
current_binding_level->usings = decl;
POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, decl);
}
void
pop_scope (tree t)
{
+ if (t == NULL_TREE)
+ return;
if (TREE_CODE (t) == NAMESPACE_DECL)
pop_decl_namespace ();
else if CLASS_TYPE_P (t)
/* Remove the bindings for all of the class-level declarations. */
if (level->class_shadowed)
{
- for (i = 0;
- VEC_iterate (cp_class_binding, level->class_shadowed, i, cb);
- ++i)
+ FOR_EACH_VEC_ELT (cp_class_binding, level->class_shadowed, i, cb)
IDENTIFIER_BINDING (cb->identifier) = cb->base.previous;
ggc_free (level->class_shadowed);
level->class_shadowed = NULL;
aggregate, for naming purposes. */
tree f;
- for (f = TYPE_FIELDS (TREE_TYPE (x)); f; f = TREE_CHAIN (f))
+ for (f = TYPE_FIELDS (TREE_TYPE (x)); f; f = DECL_CHAIN (f))
{
location_t save_location = input_location;
input_location = DECL_SOURCE_LOCATION (f);
{
cxx_binding *binding;
- if (scope == NULL)
+ if (SCOPE_FILE_SCOPE_P (scope))
scope = global_namespace;
else
/* Unnecessary for the global namespace because it can't be an alias. */
{
unsigned int i;
tree elt;
- for (i = 0; VEC_iterate(tree,vec,i,elt); ++i)
+ FOR_EACH_VEC_ELT (tree,vec,i,elt)
if (elt == target)
return true;
return false;
lookup_arg_dependent (name,
lookup_name_real (name, 0, 1, block_p, 0,
LOOKUP_COMPLAIN),
- args);
+ args, false);
}
tree
bool
is_associated_namespace (tree current, tree scope)
{
- tree seen = NULL_TREE;
- tree todo = NULL_TREE;
+ VEC(tree,gc) *seen = make_tree_vector ();
+ VEC(tree,gc) *todo = make_tree_vector ();
tree t;
+ bool ret;
+
while (1)
{
if (scope == current)
- return true;
- seen = tree_cons (scope, NULL_TREE, seen);
+ {
+ ret = true;
+ break;
+ }
+ VEC_safe_push (tree, gc, seen, scope);
for (t = DECL_NAMESPACE_ASSOCIATIONS (scope); t; t = TREE_CHAIN (t))
- if (!purpose_member (TREE_PURPOSE (t), seen))
- todo = tree_cons (TREE_PURPOSE (t), NULL_TREE, todo);
- if (todo)
+ if (!vec_member (TREE_PURPOSE (t), seen))
+ VEC_safe_push (tree, gc, todo, TREE_PURPOSE (t));
+ if (!VEC_empty (tree, todo))
{
- scope = TREE_PURPOSE (todo);
- todo = TREE_CHAIN (todo);
+ scope = VEC_last (tree, todo);
+ VEC_pop (tree, todo);
}
else
- return false;
+ {
+ ret = false;
+ break;
+ }
}
+
+ release_tree_vector (seen);
+ release_tree_vector (todo);
+
+ return ret;
}
/* Add functions of a namespace to the lookup structure.
case BOOLEAN_TYPE:
case FIXED_POINT_TYPE:
case DECLTYPE_TYPE:
+ case NULLPTR_TYPE:
return false;
case RECORD_TYPE:
if (TYPE_PTRMEMFUNC_P (type))
return false;
case LANG_TYPE:
gcc_assert (type == unknown_type_node
- || NULLPTR_TYPE_P (type)
|| type == init_list_type_node);
return false;
case TYPE_PACK_EXPANSION:
unsigned int ix;
tree arg;
- for (ix = 0; VEC_iterate (tree, args, ix, arg); ++ix)
+ FOR_EACH_VEC_ELT (tree, args, ix, arg)
if (arg_assoc (k, arg))
return true;
return false;
are the functions found in normal lookup. */
tree
-lookup_arg_dependent (tree name, tree fns, VEC(tree,gc) *args)
+lookup_arg_dependent (tree name, tree fns, VEC(tree,gc) *args,
+ bool include_std)
{
struct arg_lookup k;
picking up later definitions) in the second stage. */
k.namespaces = make_tree_vector ();
+ if (include_std)
+ arg_assoc_namespace (&k, std_node);
arg_assoc_args_vec (&k, args);
fns = k.functions;
SET_IDENTIFIER_TYPE_VALUE (TREE_PURPOSE (t), TREE_VALUE (t));
}
- for (i = 0; VEC_iterate (cxx_saved_binding, s->old_bindings, i, sb); ++i)
+ FOR_EACH_VEC_ELT (cxx_saved_binding, s->old_bindings, i, sb)
IDENTIFIER_MARKED (sb->identifier) = 0;
s->prev = scope_chain;
current_lang_base = 0;
scope_chain = s->prev;
- for (i = 0; VEC_iterate (cxx_saved_binding, s->old_bindings, i, saved); ++i)
+ FOR_EACH_VEC_ELT (cxx_saved_binding, s->old_bindings, i, saved)
{
tree id = saved->identifier;