* class.c (handle_using_decl): Use OVL_FIRST, ovl_iterator.
(maybe_warn_about_overly_private_class): Use ovl_iterator.
(method_name_cmp, resort_method_name_cmp): Use OVL_NAME.
(resort_type_method_vec, finish_struct_methods): Use OVL_FIRST.
(get_base_fndecls): Use ovl_iterator.
(warn_hidden): Use OVL_NAME, ovl_iterator.
(add_implicitly_declared_members): Use ovl_iterator.
* constraint.cc (normalize_template_id_expression): Use OVL_FIRST,
flatten nested if.
(finish_shorthand_constraint): Simplify, use ovl_make.
* pt.c (make_constrained_auto): Simplify. Use ovl_make.
* search.c (shared_member_p): Use ovl_iterator.
(lookup_field_fuzzy_info::fuzzy_lookup_fn): Use OVL_NAME.
(lookup_conversion_operator): Use OVL_FIRST.
(lookup_fnfiels_idx_nolazy): Use OVL_FIRST, OVL_NAME.
(look_for_overrides_here): Use ovl_iterator.
(lookup_conversions_r): Use OVL_FIRST, OVL_NAME, ovl_iterator.
* typeck.c (build_x_unary_op): Use ovl_make.
From-SVN: r248144
+2017-05-17 Nathan Sidwell <nathan@acm.org>
+
+ * class.c (handle_using_decl): Use OVL_FIRST, ovl_iterator.
+ (maybe_warn_about_overly_private_class): Use ovl_iterator.
+ (method_name_cmp, resort_method_name_cmp): Use OVL_NAME.
+ (resort_type_method_vec, finish_struct_methods): Use OVL_FIRST.
+ (get_base_fndecls): Use ovl_iterator.
+ (warn_hidden): Use OVL_NAME, ovl_iterator.
+ (add_implicitly_declared_members): Use ovl_iterator.
+ * constraint.cc (normalize_template_id_expression): Use OVL_FIRST,
+ flatten nested if.
+ (finish_shorthand_constraint): Simplify, use ovl_make.
+ * pt.c (make_constrained_auto): Simplify. Use ovl_make.
+ * search.c (shared_member_p): Use ovl_iterator.
+ (lookup_field_fuzzy_info::fuzzy_lookup_fn): Use OVL_NAME.
+ (lookup_conversion_operator): Use OVL_FIRST.
+ (lookup_fnfiels_idx_nolazy): Use OVL_FIRST, OVL_NAME.
+ (look_for_overrides_here): Use ovl_iterator.
+ (lookup_conversions_r): Use OVL_FIRST, OVL_NAME, ovl_iterator.
+ * typeck.c (build_x_unary_op): Use ovl_make.
+
2017-05-17 Martin Liska <mliska@suse.cz>
* class.c (dump_class_hierarchy): Introduce dump_flags_t type and
tf_warning_or_error);
if (old_value)
{
- old_value = OVL_CURRENT (old_value);
+ old_value = OVL_FIRST (old_value);
if (DECL_P (old_value) && DECL_CONTEXT (old_value) == t)
/* OK */;
/* Make type T see field decl FDECL with access ACCESS. */
if (flist)
- for (; flist; flist = OVL_NEXT (flist))
+ for (ovl_iterator iter (flist); iter; ++iter)
{
- add_method (t, OVL_CURRENT (flist), using_decl);
- alter_access (t, OVL_CURRENT (flist), access);
+ add_method (t, *iter, true);
+ alter_access (t, *iter, access);
}
else
alter_access (t, decl, access);
&& (!CLASSTYPE_LAZY_DEFAULT_CTOR (t)
|| !CLASSTYPE_LAZY_COPY_CTOR (t)))
{
- int nonprivate_ctor = 0;
+ bool nonprivate_ctor = false;
/* If a non-template class does not define a copy
constructor, one is defined for it, enabling it to avoid
complete non-template or fully instantiated classes have this
flag set. */
if (!TYPE_HAS_COPY_CTOR (t))
- nonprivate_ctor = 1;
+ nonprivate_ctor = true;
else
- for (fn = CLASSTYPE_CONSTRUCTORS (t); fn; fn = OVL_NEXT (fn))
- {
- tree ctor = OVL_CURRENT (fn);
- /* Ideally, we wouldn't count copy constructors (or, in
- fact, 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. But, for now at least, we're
- more generous. */
- if (! TREE_PRIVATE (ctor))
- {
- nonprivate_ctor = 1;
- break;
- }
- }
-
- if (nonprivate_ctor == 0)
+ for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t));
+ !nonprivate_ctor && iter; ++iter)
+ /* Ideally, we wouldn't count copy constructors (or, in
+ fact, 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. But, for now at least, we're more
+ generous. */
+ if (! TREE_PRIVATE (*iter))
+ nonprivate_ctor = true;
+
+ if (!nonprivate_ctor)
{
warning (OPT_Wctor_dtor_privacy,
"%q#T only defines private constructors and has no friends",
return -1;
if (*m2 == NULL_TREE)
return 1;
- if (DECL_NAME (OVL_CURRENT (*m1)) < DECL_NAME (OVL_CURRENT (*m2)))
+ if (OVL_NAME (*m1) < OVL_NAME (*m2))
return -1;
return 1;
}
if (*m2 == NULL_TREE)
return 1;
{
- tree d1 = DECL_NAME (OVL_CURRENT (*m1));
- tree d2 = DECL_NAME (OVL_CURRENT (*m2));
+ tree d1 = OVL_NAME (*m1);
+ tree d2 = OVL_NAME (*m2);
resort_data.new_value (&d1, resort_data.cookie);
resort_data.new_value (&d2, resort_data.cookie);
if (d1 < d2)
for (slot = CLASSTYPE_FIRST_CONVERSION_SLOT;
vec_safe_iterate (method_vec, slot, &fn);
++slot)
- if (!DECL_CONV_FN_P (OVL_CURRENT (fn)))
+ if (!DECL_CONV_FN_P (OVL_FIRST (fn)))
break;
if (len - slot > 1)
for (slot = CLASSTYPE_FIRST_CONVERSION_SLOT;
method_vec->iterate (slot, &fn_fields);
++slot)
- if (!DECL_CONV_FN_P (OVL_CURRENT (fn_fields)))
+ if (!DECL_CONV_FN_P (OVL_FIRST (fn_fields)))
break;
if (len - slot > 1)
qsort (method_vec->address () + slot,
static void
get_basefndecls (tree name, tree t, vec<tree> *base_fndecls)
{
- tree methods;
int n_baseclasses = BINFO_N_BASE_BINFOS (TYPE_BINFO (t));
int i;
i = lookup_fnfields_1 (t, name);
bool found_decls = false;
if (i != -1)
- for (methods = (*CLASSTYPE_METHOD_VEC (t))[i];
- methods;
- methods = OVL_NEXT (methods))
+ for (ovl_iterator iter ((*CLASSTYPE_METHOD_VEC (t))[i]); iter; ++iter)
{
- tree method = OVL_CURRENT (methods);
+ tree method = *iter;
if (TREE_CODE (method) == FUNCTION_DECL
&& DECL_VINDEX (method))
vec_safe_iterate (method_vec, i, &fns);
++i)
{
- tree fn;
- tree name;
tree fndecl;
tree base_binfo;
tree binfo;
/* All functions in this slot in the CLASSTYPE_METHOD_VEC will
have the same name. Figure out what name that is. */
- name = DECL_NAME (OVL_CURRENT (fns));
+ tree name = OVL_NAME (fns);
/* There are no possibly hidden functions yet. */
auto_vec<tree, 20> base_fndecls;
/* Iterate through all of the base classes looking for possibly
continue;
/* Remove any overridden functions. */
- for (fn = fns; fn; fn = OVL_NEXT (fn))
+ for (ovl_iterator iter (fns); iter; ++iter)
{
- fndecl = OVL_CURRENT (fn);
+ 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);
- if (ctor_list)
- for (; ctor_list; ctor_list = OVL_NEXT (ctor_list))
- one_inherited_ctor (OVL_CURRENT (ctor_list), t, using_decl);
+ for (ovl_iterator iter (ctor_list); iter; ++iter)
+ one_inherited_ctor (*iter, t, using_decl);
*access_decls = TREE_CHAIN (*access_decls);
input_location = loc;
}
}
/* Check that we didn't refer to a function concept like a variable. */
- tree tmpl = TREE_OPERAND (t, 0);
- if (TREE_CODE (tmpl) == OVERLOAD)
+ tree fn = OVL_FIRST (TREE_OPERAND (t, 0));
+ if (TREE_CODE (fn) == TEMPLATE_DECL
+ && DECL_DECLARED_CONCEPT_P (DECL_TEMPLATE_RESULT (fn)))
{
- tree fn = OVL_FUNCTION (tmpl);
- if (TREE_CODE (fn) == TEMPLATE_DECL
- && DECL_DECLARED_CONCEPT_P (DECL_TEMPLATE_RESULT (fn)))
- {
- error_at (location_of (t),
- "invalid reference to function concept %qD", fn);
- return error_mark_node;
- }
+ error_at (location_of (t),
+ "invalid reference to function concept %qD", fn);
+ return error_mark_node;
}
return build_nt (PRED_CONSTR, t);
/* Build the concept check. If it the constraint needs to be
applied to all elements of the parameter pack, then make
the constraint an expansion. */
- tree check;
tree tmpl = DECL_TI_TEMPLATE (con);
- if (VAR_P (con))
- check = build_concept_check (tmpl, arg, args);
- else
- {
- tree ovl = build_overload (tmpl, NULL_TREE);
- check = build_concept_check (ovl, arg, args);
- }
+ tree check = VAR_P (con) ? tmpl : ovl_make (tmpl);
+ check = build_concept_check (check, arg, args);
/* Make the check a pack expansion if needed.
/* Build the constraint. */
tree tmpl = DECL_TI_TEMPLATE (con);
- tree expr;
- if (VAR_P (con))
- expr = build_concept_check (tmpl, type, args);
- else
- expr = build_concept_check (build_overload (tmpl, NULL_TREE), type, args);
+ tree expr = VAR_P (con) ? tmpl : ovl_make (tmpl);
+ expr = build_concept_check (expr, type, args);
tree constr = normalize_expression (expr);
PLACEHOLDER_TYPE_CONSTRAINTS (type) = constr;
return 1;
if (is_overloaded_fn (t))
{
- t = get_fns (t);
- for (; t; t = OVL_NEXT (t))
- {
- tree fn = OVL_CURRENT (t);
- if (DECL_NONSTATIC_MEMBER_FUNCTION_P (fn))
- return 0;
- }
+ for (ovl_iterator iter (get_fns (t)); iter; ++iter)
+ if (DECL_NONSTATIC_MEMBER_FUNCTION_P (*iter))
+ return 0;
return 1;
}
return 0;
for (i = 0; vec_safe_iterate (method_vec, i, &fn); ++i)
if (fn)
- m_candidates.safe_push (DECL_NAME (OVL_CURRENT (fn)));
+ m_candidates.safe_push (OVL_NAME (fn));
}
/* Locate all fields within TYPE, append them to m_candidates. */
the class. Therefore, if FN is not a conversion
operator, there is no matching conversion operator in
CLASS_TYPE. */
- fn = OVL_CURRENT (fn);
+ fn = OVL_FIRST (fn);
if (!DECL_CONV_FN_P (fn))
break;
{
vec<tree, va_gc> *method_vec;
tree fn;
- tree tmp;
size_t i;
if (!CLASS_TYPE_P (type))
for (i = CLASSTYPE_FIRST_CONVERSION_SLOT;
vec_safe_iterate (method_vec, i, &fn);
++i)
- if (!DECL_CONV_FN_P (OVL_CURRENT (fn)))
+ if (!DECL_CONV_FN_P (OVL_FIRST (fn)))
break;
/* If the type is complete, use binary search. */
if (GATHER_STATISTICS)
n_outer_fields_searched++;
- tmp = (*method_vec)[i];
- tmp = DECL_NAME (OVL_CURRENT (tmp));
+ tree tmp = (*method_vec)[i];
+ tmp = OVL_NAME (tmp);
if (tmp > name)
hi = i;
else if (tmp < name)
{
if (GATHER_STATISTICS)
n_outer_fields_searched++;
- if (DECL_NAME (OVL_CURRENT (fn)) == name)
+ if (OVL_NAME (fn) == name)
return i;
}
else
ix = lookup_fnfields_1 (type, DECL_NAME (fndecl));
if (ix >= 0)
- {
- tree fns = (*CLASSTYPE_METHOD_VEC (type))[ix];
+ for (ovl_iterator iter ((*CLASSTYPE_METHOD_VEC (type))[ix]); iter; ++iter)
+ {
+ tree fn = *iter;
- for (; fns; fns = OVL_NEXT (fns))
- {
- tree fn = OVL_CURRENT (fns);
+ if (!DECL_VIRTUAL_P (fn))
+ /* Not a virtual. */;
+ else if (DECL_CONTEXT (fn) != type)
+ /* Introduced with a using declaration. */;
+ else if (DECL_STATIC_FUNCTION_P (fndecl))
+ {
+ tree btypes = TYPE_ARG_TYPES (TREE_TYPE (fn));
+ tree dtypes = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
+ if (compparms (TREE_CHAIN (btypes), dtypes))
+ return fn;
+ }
+ else if (same_signature_p (fndecl, fn))
+ return fn;
+ }
- if (!DECL_VIRTUAL_P (fn))
- /* Not a virtual. */;
- else if (DECL_CONTEXT (fn) != type)
- /* Introduced with a using declaration. */;
- else if (DECL_STATIC_FUNCTION_P (fndecl))
- {
- tree btypes = TYPE_ARG_TYPES (TREE_TYPE (fn));
- tree dtypes = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
- if (compparms (TREE_CHAIN (btypes), dtypes))
- return fn;
- }
- else if (same_signature_p (fndecl, fn))
- return fn;
- }
- }
return NULL_TREE;
}
vec_safe_iterate (method_vec, i, &conv);
++i)
{
- tree cur = OVL_CURRENT (conv);
+ tree cur = OVL_FIRST (conv);
if (!DECL_CONV_FN_P (cur))
break;
if (TREE_CODE (cur) == TEMPLATE_DECL)
- {
- /* Only template conversions can be overloaded, and we must
- flatten them out and check each one individually. */
- tree tpls;
-
- for (tpls = conv; tpls; tpls = OVL_NEXT (tpls))
- {
- tree tpl = OVL_CURRENT (tpls);
- tree type = DECL_CONV_FN_TYPE (tpl);
+ /* Only template conversions can be overloaded, and we must
+ flatten them out and check each one individually. */
+ for (ovl_iterator iter (conv); iter; ++iter)
+ {
+ tree tpl = *iter;
+ tree type = DECL_CONV_FN_TYPE (tpl);
- if (check_hidden_convs (binfo, virtual_depth, virtualness,
- type, parent_tpl_convs, other_tpl_convs))
- {
- my_tpl_convs = tree_cons (binfo, tpl, my_tpl_convs);
- TREE_TYPE (my_tpl_convs) = type;
- if (virtual_depth)
- {
- TREE_STATIC (my_tpl_convs) = 1;
- my_virtualness = 1;
- }
- }
- }
- }
+ if (check_hidden_convs (binfo, virtual_depth, virtualness,
+ type, parent_tpl_convs, other_tpl_convs))
+ {
+ my_tpl_convs = tree_cons (binfo, tpl, my_tpl_convs);
+ TREE_TYPE (my_tpl_convs) = type;
+ if (virtual_depth)
+ {
+ TREE_STATIC (my_tpl_convs) = 1;
+ my_virtualness = 1;
+ }
+ }
+ }
else
{
tree name = DECL_NAME (cur);
/* Unmark the conversions found at this level */
for (conv = my_convs; conv; conv = TREE_CHAIN (conv))
- IDENTIFIER_MARKED (DECL_NAME (OVL_CURRENT (TREE_VALUE (conv)))) = 0;
+ IDENTIFIER_MARKED (OVL_NAME (TREE_VALUE (conv))) = 0;
*convs = split_conversions (my_convs, parent_convs,
child_convs, other_convs);
pointer-to-member. */
xarg = build2 (OFFSET_REF, TREE_TYPE (xarg),
TREE_OPERAND (xarg, 0),
- ovl_cons (TREE_OPERAND (xarg, 1), NULL_TREE));
+ ovl_make (TREE_OPERAND (xarg, 1)));
PTRMEM_OK_P (xarg) = ptrmem;
}
}