class.c (handle_using_decl): Use OVL_FIRST, ovl_iterator.

* 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
This commit is contained in:
Nathan Sidwell 2017-05-17 11:21:50 +00:00 committed by Nathan Sidwell
parent 142473df8e
commit 19b476fb8d
6 changed files with 107 additions and 122 deletions

View file

@ -1,3 +1,24 @@
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> 2017-05-17 Martin Liska <mliska@suse.cz>
* class.c (dump_class_hierarchy): Introduce dump_flags_t type and * class.c (dump_class_hierarchy): Introduce dump_flags_t type and

View file

@ -1359,7 +1359,7 @@ handle_using_decl (tree using_decl, tree t)
tf_warning_or_error); tf_warning_or_error);
if (old_value) 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) if (DECL_P (old_value) && DECL_CONTEXT (old_value) == t)
/* OK */; /* OK */;
@ -1396,10 +1396,10 @@ handle_using_decl (tree using_decl, tree t)
/* Make type T see field decl FDECL with access ACCESS. */ /* Make type T see field decl FDECL with access ACCESS. */
if (flist) if (flist)
for (; flist; flist = OVL_NEXT (flist)) for (ovl_iterator iter (flist); iter; ++iter)
{ {
add_method (t, OVL_CURRENT (flist), using_decl); add_method (t, *iter, true);
alter_access (t, OVL_CURRENT (flist), access); alter_access (t, *iter, access);
} }
else else
alter_access (t, decl, access); alter_access (t, decl, access);
@ -2245,7 +2245,7 @@ maybe_warn_about_overly_private_class (tree t)
&& (!CLASSTYPE_LAZY_DEFAULT_CTOR (t) && (!CLASSTYPE_LAZY_DEFAULT_CTOR (t)
|| !CLASSTYPE_LAZY_COPY_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 /* If a non-template class does not define a copy
constructor, one is defined for it, enabling it to avoid constructor, one is defined for it, enabling it to avoid
@ -2258,25 +2258,20 @@ maybe_warn_about_overly_private_class (tree t)
complete non-template or fully instantiated classes have this complete non-template or fully instantiated classes have this
flag set. */ flag set. */
if (!TYPE_HAS_COPY_CTOR (t)) if (!TYPE_HAS_COPY_CTOR (t))
nonprivate_ctor = 1; nonprivate_ctor = true;
else else
for (fn = CLASSTYPE_CONSTRUCTORS (t); fn; fn = OVL_NEXT (fn)) for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t));
{ !nonprivate_ctor && iter; ++iter)
tree ctor = OVL_CURRENT (fn);
/* Ideally, we wouldn't count copy constructors (or, in /* Ideally, we wouldn't count copy constructors (or, in
fact, any constructor that takes an argument of the fact, any constructor that takes an argument of the class
class type as a parameter) because such things cannot type as a parameter) because such things cannot be used
be used to construct an instance of the class unless to construct an instance of the class unless you already
you already have one. But, for now at least, we're have one. But, for now at least, we're more
more generous. */ generous. */
if (! TREE_PRIVATE (ctor)) if (! TREE_PRIVATE (*iter))
{ nonprivate_ctor = true;
nonprivate_ctor = 1;
break;
}
}
if (nonprivate_ctor == 0) if (!nonprivate_ctor)
{ {
warning (OPT_Wctor_dtor_privacy, warning (OPT_Wctor_dtor_privacy,
"%q#T only defines private constructors and has no friends", "%q#T only defines private constructors and has no friends",
@ -2305,7 +2300,7 @@ method_name_cmp (const void* m1_p, const void* m2_p)
return -1; return -1;
if (*m2 == NULL_TREE) if (*m2 == NULL_TREE)
return 1; return 1;
if (DECL_NAME (OVL_CURRENT (*m1)) < DECL_NAME (OVL_CURRENT (*m2))) if (OVL_NAME (*m1) < OVL_NAME (*m2))
return -1; return -1;
return 1; return 1;
} }
@ -2325,8 +2320,8 @@ resort_method_name_cmp (const void* m1_p, const void* m2_p)
if (*m2 == NULL_TREE) if (*m2 == NULL_TREE)
return 1; return 1;
{ {
tree d1 = DECL_NAME (OVL_CURRENT (*m1)); tree d1 = OVL_NAME (*m1);
tree d2 = DECL_NAME (OVL_CURRENT (*m2)); tree d2 = OVL_NAME (*m2);
resort_data.new_value (&d1, resort_data.cookie); resort_data.new_value (&d1, resort_data.cookie);
resort_data.new_value (&d2, resort_data.cookie); resort_data.new_value (&d2, resort_data.cookie);
if (d1 < d2) if (d1 < d2)
@ -2353,7 +2348,7 @@ resort_type_method_vec (void* obj,
for (slot = CLASSTYPE_FIRST_CONVERSION_SLOT; for (slot = CLASSTYPE_FIRST_CONVERSION_SLOT;
vec_safe_iterate (method_vec, slot, &fn); vec_safe_iterate (method_vec, slot, &fn);
++slot) ++slot)
if (!DECL_CONV_FN_P (OVL_CURRENT (fn))) if (!DECL_CONV_FN_P (OVL_FIRST (fn)))
break; break;
if (len - slot > 1) if (len - slot > 1)
@ -2398,7 +2393,7 @@ finish_struct_methods (tree t)
for (slot = CLASSTYPE_FIRST_CONVERSION_SLOT; for (slot = CLASSTYPE_FIRST_CONVERSION_SLOT;
method_vec->iterate (slot, &fn_fields); method_vec->iterate (slot, &fn_fields);
++slot) ++slot)
if (!DECL_CONV_FN_P (OVL_CURRENT (fn_fields))) if (!DECL_CONV_FN_P (OVL_FIRST (fn_fields)))
break; break;
if (len - slot > 1) if (len - slot > 1)
qsort (method_vec->address () + slot, qsort (method_vec->address () + slot,
@ -2973,7 +2968,6 @@ modify_all_vtables (tree t, tree virtuals)
static void static void
get_basefndecls (tree name, tree t, vec<tree> *base_fndecls) get_basefndecls (tree name, tree t, vec<tree> *base_fndecls)
{ {
tree methods;
int n_baseclasses = BINFO_N_BASE_BINFOS (TYPE_BINFO (t)); int n_baseclasses = BINFO_N_BASE_BINFOS (TYPE_BINFO (t));
int i; int i;
@ -2981,11 +2975,9 @@ get_basefndecls (tree name, tree t, vec<tree> *base_fndecls)
i = lookup_fnfields_1 (t, name); i = lookup_fnfields_1 (t, name);
bool found_decls = false; bool found_decls = false;
if (i != -1) if (i != -1)
for (methods = (*CLASSTYPE_METHOD_VEC (t))[i]; for (ovl_iterator iter ((*CLASSTYPE_METHOD_VEC (t))[i]); iter; ++iter)
methods;
methods = OVL_NEXT (methods))
{ {
tree method = OVL_CURRENT (methods); tree method = *iter;
if (TREE_CODE (method) == FUNCTION_DECL if (TREE_CODE (method) == FUNCTION_DECL
&& DECL_VINDEX (method)) && DECL_VINDEX (method))
@ -3065,8 +3057,6 @@ warn_hidden (tree t)
vec_safe_iterate (method_vec, i, &fns); vec_safe_iterate (method_vec, i, &fns);
++i) ++i)
{ {
tree fn;
tree name;
tree fndecl; tree fndecl;
tree base_binfo; tree base_binfo;
tree binfo; tree binfo;
@ -3074,7 +3064,7 @@ warn_hidden (tree t)
/* All functions in this slot in the CLASSTYPE_METHOD_VEC will /* All functions in this slot in the CLASSTYPE_METHOD_VEC will
have the same name. Figure out what name that is. */ 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. */ /* There are no possibly hidden functions yet. */
auto_vec<tree, 20> base_fndecls; auto_vec<tree, 20> base_fndecls;
/* Iterate through all of the base classes looking for possibly /* Iterate through all of the base classes looking for possibly
@ -3091,9 +3081,9 @@ warn_hidden (tree t)
continue; continue;
/* Remove any overridden functions. */ /* 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 if (TREE_CODE (fndecl) == FUNCTION_DECL
&& DECL_VINDEX (fndecl)) && DECL_VINDEX (fndecl))
{ {
@ -3455,9 +3445,8 @@ add_implicitly_declared_members (tree t, tree* access_decls,
tree ctor_list = decl; tree ctor_list = decl;
location_t loc = input_location; location_t loc = input_location;
input_location = DECL_SOURCE_LOCATION (using_decl); input_location = DECL_SOURCE_LOCATION (using_decl);
if (ctor_list) for (ovl_iterator iter (ctor_list); iter; ++iter)
for (; ctor_list; ctor_list = OVL_NEXT (ctor_list)) one_inherited_ctor (*iter, t, using_decl);
one_inherited_ctor (OVL_CURRENT (ctor_list), t, using_decl);
*access_decls = TREE_CHAIN (*access_decls); *access_decls = TREE_CHAIN (*access_decls);
input_location = loc; input_location = loc;
} }

View file

@ -738,10 +738,7 @@ normalize_template_id_expression (tree t)
} }
/* Check that we didn't refer to a function concept like a variable. */ /* Check that we didn't refer to a function concept like a variable. */
tree tmpl = TREE_OPERAND (t, 0); tree fn = OVL_FIRST (TREE_OPERAND (t, 0));
if (TREE_CODE (tmpl) == OVERLOAD)
{
tree fn = OVL_FUNCTION (tmpl);
if (TREE_CODE (fn) == TEMPLATE_DECL if (TREE_CODE (fn) == TEMPLATE_DECL
&& DECL_DECLARED_CONCEPT_P (DECL_TEMPLATE_RESULT (fn))) && DECL_DECLARED_CONCEPT_P (DECL_TEMPLATE_RESULT (fn)))
{ {
@ -749,7 +746,6 @@ normalize_template_id_expression (tree t)
"invalid reference to function concept %qD", fn); "invalid reference to function concept %qD", fn);
return error_mark_node; return error_mark_node;
} }
}
return build_nt (PRED_CONSTR, t); return build_nt (PRED_CONSTR, t);
} }
@ -1283,15 +1279,9 @@ finish_shorthand_constraint (tree decl, tree constr)
/* Build the concept check. If it the constraint needs to be /* Build the concept check. If it the constraint needs to be
applied to all elements of the parameter pack, then make applied to all elements of the parameter pack, then make
the constraint an expansion. */ the constraint an expansion. */
tree check;
tree tmpl = DECL_TI_TEMPLATE (con); tree tmpl = DECL_TI_TEMPLATE (con);
if (VAR_P (con)) tree check = VAR_P (con) ? tmpl : ovl_make (tmpl);
check = build_concept_check (tmpl, arg, args); check = build_concept_check (check, arg, args);
else
{
tree ovl = build_overload (tmpl, NULL_TREE);
check = build_concept_check (ovl, arg, args);
}
/* Make the check a pack expansion if needed. /* Make the check a pack expansion if needed.

View file

@ -24653,11 +24653,8 @@ make_constrained_auto (tree con, tree args)
/* Build the constraint. */ /* Build the constraint. */
tree tmpl = DECL_TI_TEMPLATE (con); tree tmpl = DECL_TI_TEMPLATE (con);
tree expr; tree expr = VAR_P (con) ? tmpl : ovl_make (tmpl);
if (VAR_P (con)) expr = build_concept_check (expr, type, args);
expr = build_concept_check (tmpl, type, args);
else
expr = build_concept_check (build_overload (tmpl, NULL_TREE), type, args);
tree constr = normalize_expression (expr); tree constr = normalize_expression (expr);
PLACEHOLDER_TYPE_CONSTRAINTS (type) = constr; PLACEHOLDER_TYPE_CONSTRAINTS (type) = constr;

View file

@ -1047,13 +1047,9 @@ shared_member_p (tree t)
return 1; return 1;
if (is_overloaded_fn (t)) if (is_overloaded_fn (t))
{ {
t = get_fns (t); for (ovl_iterator iter (get_fns (t)); iter; ++iter)
for (; t; t = OVL_NEXT (t)) if (DECL_NONSTATIC_MEMBER_FUNCTION_P (*iter))
{
tree fn = OVL_CURRENT (t);
if (DECL_NONSTATIC_MEMBER_FUNCTION_P (fn))
return 0; return 0;
}
return 1; return 1;
} }
return 0; return 0;
@ -1396,7 +1392,7 @@ lookup_field_fuzzy_info::fuzzy_lookup_fnfields (tree type)
for (i = 0; vec_safe_iterate (method_vec, i, &fn); ++i) for (i = 0; vec_safe_iterate (method_vec, i, &fn); ++i)
if (fn) 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. */ /* Locate all fields within TYPE, append them to m_candidates. */
@ -1550,7 +1546,7 @@ lookup_conversion_operator (tree class_type, tree type)
the class. Therefore, if FN is not a conversion the class. Therefore, if FN is not a conversion
operator, there is no matching conversion operator in operator, there is no matching conversion operator in
CLASS_TYPE. */ CLASS_TYPE. */
fn = OVL_CURRENT (fn); fn = OVL_FIRST (fn);
if (!DECL_CONV_FN_P (fn)) if (!DECL_CONV_FN_P (fn))
break; break;
@ -1575,7 +1571,6 @@ lookup_fnfields_idx_nolazy (tree type, tree name)
{ {
vec<tree, va_gc> *method_vec; vec<tree, va_gc> *method_vec;
tree fn; tree fn;
tree tmp;
size_t i; size_t i;
if (!CLASS_TYPE_P (type)) if (!CLASS_TYPE_P (type))
@ -1607,7 +1602,7 @@ lookup_fnfields_idx_nolazy (tree type, tree name)
for (i = CLASSTYPE_FIRST_CONVERSION_SLOT; for (i = CLASSTYPE_FIRST_CONVERSION_SLOT;
vec_safe_iterate (method_vec, i, &fn); vec_safe_iterate (method_vec, i, &fn);
++i) ++i)
if (!DECL_CONV_FN_P (OVL_CURRENT (fn))) if (!DECL_CONV_FN_P (OVL_FIRST (fn)))
break; break;
/* If the type is complete, use binary search. */ /* If the type is complete, use binary search. */
@ -1625,8 +1620,8 @@ lookup_fnfields_idx_nolazy (tree type, tree name)
if (GATHER_STATISTICS) if (GATHER_STATISTICS)
n_outer_fields_searched++; n_outer_fields_searched++;
tmp = (*method_vec)[i]; tree tmp = (*method_vec)[i];
tmp = DECL_NAME (OVL_CURRENT (tmp)); tmp = OVL_NAME (tmp);
if (tmp > name) if (tmp > name)
hi = i; hi = i;
else if (tmp < name) else if (tmp < name)
@ -1640,7 +1635,7 @@ lookup_fnfields_idx_nolazy (tree type, tree name)
{ {
if (GATHER_STATISTICS) if (GATHER_STATISTICS)
n_outer_fields_searched++; n_outer_fields_searched++;
if (DECL_NAME (OVL_CURRENT (fn)) == name) if (OVL_NAME (fn) == name)
return i; return i;
} }
@ -2433,12 +2428,9 @@ look_for_overrides_here (tree type, tree fndecl)
else else
ix = lookup_fnfields_1 (type, DECL_NAME (fndecl)); ix = lookup_fnfields_1 (type, DECL_NAME (fndecl));
if (ix >= 0) if (ix >= 0)
for (ovl_iterator iter ((*CLASSTYPE_METHOD_VEC (type))[ix]); iter; ++iter)
{ {
tree fns = (*CLASSTYPE_METHOD_VEC (type))[ix]; tree fn = *iter;
for (; fns; fns = OVL_NEXT (fns))
{
tree fn = OVL_CURRENT (fns);
if (!DECL_VIRTUAL_P (fn)) if (!DECL_VIRTUAL_P (fn))
/* Not a virtual. */; /* Not a virtual. */;
@ -2454,7 +2446,7 @@ look_for_overrides_here (tree type, tree fndecl)
else if (same_signature_p (fndecl, fn)) else if (same_signature_p (fndecl, fn))
return fn; return fn;
} }
}
return NULL_TREE; return NULL_TREE;
} }
@ -2797,20 +2789,17 @@ lookup_conversions_r (tree binfo,
vec_safe_iterate (method_vec, i, &conv); vec_safe_iterate (method_vec, i, &conv);
++i) ++i)
{ {
tree cur = OVL_CURRENT (conv); tree cur = OVL_FIRST (conv);
if (!DECL_CONV_FN_P (cur)) if (!DECL_CONV_FN_P (cur))
break; break;
if (TREE_CODE (cur) == TEMPLATE_DECL) if (TREE_CODE (cur) == TEMPLATE_DECL)
{
/* Only template conversions can be overloaded, and we must /* Only template conversions can be overloaded, and we must
flatten them out and check each one individually. */ flatten them out and check each one individually. */
tree tpls; for (ovl_iterator iter (conv); iter; ++iter)
for (tpls = conv; tpls; tpls = OVL_NEXT (tpls))
{ {
tree tpl = OVL_CURRENT (tpls); tree tpl = *iter;
tree type = DECL_CONV_FN_TYPE (tpl); tree type = DECL_CONV_FN_TYPE (tpl);
if (check_hidden_convs (binfo, virtual_depth, virtualness, if (check_hidden_convs (binfo, virtual_depth, virtualness,
@ -2825,7 +2814,6 @@ lookup_conversions_r (tree binfo,
} }
} }
} }
}
else else
{ {
tree name = DECL_NAME (cur); tree name = DECL_NAME (cur);
@ -2891,7 +2879,7 @@ lookup_conversions_r (tree binfo,
/* Unmark the conversions found at this level */ /* Unmark the conversions found at this level */
for (conv = my_convs; conv; conv = TREE_CHAIN (conv)) 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, *convs = split_conversions (my_convs, parent_convs,
child_convs, other_convs); child_convs, other_convs);

View file

@ -5519,7 +5519,7 @@ build_x_unary_op (location_t loc, enum tree_code code, cp_expr xarg,
pointer-to-member. */ pointer-to-member. */
xarg = build2 (OFFSET_REF, TREE_TYPE (xarg), xarg = build2 (OFFSET_REF, TREE_TYPE (xarg),
TREE_OPERAND (xarg, 0), TREE_OPERAND (xarg, 0),
ovl_cons (TREE_OPERAND (xarg, 1), NULL_TREE)); ovl_make (TREE_OPERAND (xarg, 1)));
PTRMEM_OK_P (xarg) = ptrmem; PTRMEM_OK_P (xarg) = ptrmem;
} }
} }