|| TYPE_REFFN_P (totype)
|| (TYPE_REF_P (totype)
&& TYPE_PTRFN_P (TREE_TYPE (totype))))
- for (ovl_iterator iter (TREE_VALUE (convs)); iter; ++iter)
+ for (tree fn : ovl_range (TREE_VALUE (convs)))
{
- tree fn = *iter;
-
if (DECL_NONCONVERTING_P (fn))
continue;
which = non_templates;
again:
- for (lkp_iterator iter (fns); iter; ++iter)
+ for (tree fn : lkp_range (fns))
{
- fn = *iter;
-
if (check_converting && DECL_NONCONVERTING_P (fn))
continue;
if (check_list_ctor && !is_list_ctor (fn))
the usual deallocation function, so we shouldn't complain
about using the operator delete (void *, size_t). */
if (DECL_CLASS_SCOPE_P (fn))
- for (lkp_iterator iter (MAYBE_BASELINK_FUNCTIONS (fns));
- iter; ++iter)
+ for (tree elt : lkp_range (MAYBE_BASELINK_FUNCTIONS (fns)))
{
- tree elt = *iter;
if (usual_deallocation_fn_p (elt)
&& FUNCTION_ARG_CHAIN (elt) == void_list_node)
goto ok;
allocation function. If the lookup finds a single matching
deallocation function, that function will be called; otherwise, no
deallocation function will be called." */
- for (lkp_iterator iter (MAYBE_BASELINK_FUNCTIONS (fns)); iter; ++iter)
+ for (tree elt : lkp_range (MAYBE_BASELINK_FUNCTIONS (fns)))
{
- tree elt = *iter;
dealloc_info di_elt;
if (usual_deallocation_fn_p (elt, &di_elt))
{
/* Iterate over overloads of the assignment operator, checking
accessible copy assignments for triviality. */
- for (ovl_iterator oi (fns); oi; ++oi)
+ for (tree f : ovl_range (fns))
{
- tree f = *oi;
-
/* Skip operators that aren't copy assignments. */
if (!copy_fn_p (f))
continue;
tree fns = get_class_binding (type, complete_ctor_identifier);
bool all_trivial = true;
- for (ovl_iterator oi (fns); oi; ++oi)
+ for (tree f : ovl_range (fns))
{
- tree f = *oi;
-
/* Skip template constructors. */
if (TREE_CODE (f) != FUNCTION_DECL)
continue;
/* Make type T see field decl FDECL with access ACCESS. */
if (flist)
- for (ovl_iterator iter (flist); iter; ++iter)
+ for (tree f : ovl_range (flist))
{
- add_method (t, *iter, true);
- alter_access (t, *iter, access);
+ add_method (t, f, true);
+ alter_access (t, f, access);
}
else if (USING_DECL_UNRELATED_P (using_decl))
{
if (!TYPE_HAS_COPY_CTOR (t))
nonprivate_ctor = true;
else
- for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t));
- !nonprivate_ctor && iter; ++iter)
- if (TREE_PRIVATE (*iter))
+ for (tree fn : ovl_range (CLASSTYPE_CONSTRUCTORS (t)))
+ if (TREE_PRIVATE (fn))
continue;
- else if (copy_fn_p (*iter) || move_fn_p (*iter))
+ else if (copy_fn_p (fn) || move_fn_p (fn))
/* Ideally, we wouldn't count any constructor that takes
an argument of the class type as a parameter, because
such things cannot be used to construct an instance of
the class unless you already have one. */
- copy_or_move = *iter;
+ copy_or_move = fn;
else
- nonprivate_ctor = true;
+ {
+ nonprivate_ctor = true;
+ break;
+ }
if (!nonprivate_ctor)
{
bool found_decls = false;
/* Find virtual functions in T with the indicated NAME. */
- for (ovl_iterator iter (get_class_binding (t, name)); iter; ++iter)
+ for (tree method : ovl_range (get_class_binding (t, name)))
{
- tree method = *iter;
-
if (TREE_CODE (method) == FUNCTION_DECL && DECL_VINDEX (method))
{
base_fndecls->safe_push (method);
continue;
/* Remove any overridden functions. */
- for (ovl_iterator iter (fns); iter; ++iter)
+ for (tree fndecl : ovl_range (fns))
{
- tree fndecl = *iter;
if (TREE_CODE (fndecl) == FUNCTION_DECL
&& DECL_VINDEX (fndecl))
{
tree ctor_list = decl;
location_t loc = input_location;
input_location = DECL_SOURCE_LOCATION (using_decl);
- for (ovl_iterator iter (ctor_list); iter; ++iter)
- one_inherited_ctor (*iter, t, using_decl);
+ for (tree fn : ovl_range (ctor_list))
+ one_inherited_ctor (fn, t, using_decl);
*access_decls = TREE_CHAIN (*access_decls);
input_location = loc;
}
TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t) = true;
}
- for (ovl_iterator i (CLASSTYPE_CONSTRUCTORS (t)); i; ++i)
+ for (tree fn : ovl_range (CLASSTYPE_CONSTRUCTORS (t)))
{
- tree fn = *i;
if (!user_provided_p (fn))
/* Might be trivial. */;
else if (copy_fn_p (fn))
TYPE_HAS_COMPLEX_MOVE_CTOR (t) = true;
}
- for (ovl_iterator i (get_class_binding_direct (t, assign_op_identifier));
- i; ++i)
+ for (tree fn : ovl_range (get_class_binding_direct (t, assign_op_identifier)))
{
- tree fn = *i;
if (!user_provided_p (fn))
/* Might be trivial. */;
else if (copy_fn_p (fn))
{
/* We do not need to propagate the usingness to the clone, at this
point that is not needed. */
- for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter)
- clone_cdtor (*iter, /*update_methods=*/true);
+ for (tree fn : ovl_range (CLASSTYPE_CONSTRUCTORS (t)))
+ clone_cdtor (fn, /*update_methods=*/true);
if (tree dtor = CLASSTYPE_DESTRUCTOR (t))
clone_cdtor (dtor, /*update_methods=*/true);
if (!TYPE_HAS_USER_CONSTRUCTOR (t))
return false;
- for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter)
+ for (tree fn : ovl_range (CLASSTYPE_CONSTRUCTORS (t)))
{
- tree fn = *iter;
if (user_provided_p (fn)
&& (TREE_CODE (fn) == TEMPLATE_DECL
|| (skip_artificial_parms_for (fn, DECL_ARGUMENTS (fn))
{
}
- private:
- /* Do not duplicate. */
- ovl_iterator &operator= (const ovl_iterator &);
- ovl_iterator (const ovl_iterator &);
-
public:
operator bool () const
{
return fn;
}
+ bool operator== (const ovl_iterator &o) const
+ {
+ return ovl == o.ovl;
+ }
tree get_using () const
{
gcc_checking_assert (using_p ());
static tree reveal_node (tree ovl, tree node);
};
+/* Treat a tree as a range of ovl_iterator, e.g.
+ for (tree f : ovl_range (fns)) { ... } */
+
+class ovl_range
+{
+ tree t;
+ bool allow;
+public:
+ explicit ovl_range (tree t, bool allow = false): t(t), allow(allow) { }
+ ovl_iterator begin() { return ovl_iterator (t, allow); }
+ ovl_iterator end() { return ovl_iterator (NULL_TREE, allow); }
+};
+
/* Iterator over a (potentially) 2 dimensional overload, which is
produced by name lookup. */
}
};
+/* Treat a tree as a range of lkp_iterator, e.g.
+ for (tree f : lkp_range (fns)) { ... } */
+
+class lkp_range
+{
+ tree t;
+public:
+ lkp_range (tree t): t(t) { }
+ lkp_iterator begin() { return lkp_iterator (t); }
+ lkp_iterator end() { return lkp_iterator (NULL_TREE); }
+};
+
/* hash traits for declarations. Hashes potential overload sets via
DECL_NAME. */