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:
parent
142473df8e
commit
19b476fb8d
6 changed files with 107 additions and 122 deletions
|
@ -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>
|
||||
|
||||
* class.c (dump_class_hierarchy): Introduce dump_flags_t type and
|
||||
|
|
|
@ -1359,7 +1359,7 @@ handle_using_decl (tree using_decl, tree t)
|
|||
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 */;
|
||||
|
@ -1396,10 +1396,10 @@ handle_using_decl (tree using_decl, tree t)
|
|||
|
||||
/* 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);
|
||||
|
@ -2245,7 +2245,7 @@ maybe_warn_about_overly_private_class (tree t)
|
|||
&& (!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
|
||||
|
@ -2258,25 +2258,20 @@ maybe_warn_about_overly_private_class (tree t)
|
|||
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;
|
||||
}
|
||||
}
|
||||
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 == 0)
|
||||
if (!nonprivate_ctor)
|
||||
{
|
||||
warning (OPT_Wctor_dtor_privacy,
|
||||
"%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;
|
||||
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;
|
||||
}
|
||||
|
@ -2325,8 +2320,8 @@ resort_method_name_cmp (const void* m1_p, const void* m2_p)
|
|||
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)
|
||||
|
@ -2353,7 +2348,7 @@ resort_type_method_vec (void* obj,
|
|||
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)
|
||||
|
@ -2398,7 +2393,7 @@ finish_struct_methods (tree t)
|
|||
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,
|
||||
|
@ -2973,7 +2968,6 @@ modify_all_vtables (tree t, tree virtuals)
|
|||
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;
|
||||
|
||||
|
@ -2981,11 +2975,9 @@ get_basefndecls (tree name, tree t, vec<tree> *base_fndecls)
|
|||
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))
|
||||
|
@ -3065,8 +3057,6 @@ warn_hidden (tree t)
|
|||
vec_safe_iterate (method_vec, i, &fns);
|
||||
++i)
|
||||
{
|
||||
tree fn;
|
||||
tree name;
|
||||
tree fndecl;
|
||||
tree base_binfo;
|
||||
tree binfo;
|
||||
|
@ -3074,7 +3064,7 @@ warn_hidden (tree t)
|
|||
|
||||
/* 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
|
||||
|
@ -3091,9 +3081,9 @@ warn_hidden (tree t)
|
|||
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))
|
||||
{
|
||||
|
@ -3455,9 +3445,8 @@ add_implicitly_declared_members (tree t, tree* access_decls,
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -738,17 +738,13 @@ normalize_template_id_expression (tree t)
|
|||
}
|
||||
|
||||
/* 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);
|
||||
|
@ -1283,15 +1279,9 @@ finish_shorthand_constraint (tree decl, tree constr)
|
|||
/* 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.
|
||||
|
||||
|
|
|
@ -24653,11 +24653,8 @@ make_constrained_auto (tree con, tree args)
|
|||
|
||||
/* 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;
|
||||
|
|
104
gcc/cp/search.c
104
gcc/cp/search.c
|
@ -1047,13 +1047,9 @@ shared_member_p (tree t)
|
|||
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;
|
||||
|
@ -1396,7 +1392,7 @@ lookup_field_fuzzy_info::fuzzy_lookup_fnfields (tree type)
|
|||
|
||||
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. */
|
||||
|
@ -1550,7 +1546,7 @@ lookup_conversion_operator (tree class_type, tree type)
|
|||
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;
|
||||
|
||||
|
@ -1575,7 +1571,6 @@ lookup_fnfields_idx_nolazy (tree type, tree name)
|
|||
{
|
||||
vec<tree, va_gc> *method_vec;
|
||||
tree fn;
|
||||
tree tmp;
|
||||
size_t i;
|
||||
|
||||
if (!CLASS_TYPE_P (type))
|
||||
|
@ -1607,7 +1602,7 @@ lookup_fnfields_idx_nolazy (tree type, tree name)
|
|||
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. */
|
||||
|
@ -1625,8 +1620,8 @@ lookup_fnfields_idx_nolazy (tree type, tree name)
|
|||
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)
|
||||
|
@ -1640,7 +1635,7 @@ lookup_fnfields_idx_nolazy (tree type, tree name)
|
|||
{
|
||||
if (GATHER_STATISTICS)
|
||||
n_outer_fields_searched++;
|
||||
if (DECL_NAME (OVL_CURRENT (fn)) == name)
|
||||
if (OVL_NAME (fn) == name)
|
||||
return i;
|
||||
}
|
||||
|
||||
|
@ -2433,28 +2428,25 @@ look_for_overrides_here (tree type, tree fndecl)
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -2797,35 +2789,31 @@ lookup_conversions_r (tree binfo,
|
|||
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;
|
||||
/* 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);
|
||||
|
||||
for (tpls = conv; tpls; tpls = OVL_NEXT (tpls))
|
||||
{
|
||||
tree tpl = OVL_CURRENT (tpls);
|
||||
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);
|
||||
|
@ -2891,7 +2879,7 @@ lookup_conversions_r (tree binfo,
|
|||
|
||||
/* 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);
|
||||
|
|
|
@ -5519,7 +5519,7 @@ build_x_unary_op (location_t loc, enum tree_code code, cp_expr xarg,
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue