Commit a736411a by Nathan Sidwell Committed by Nathan Sidwell

call.c (build_user_type_conversion_1): Use OVL_FIRST.

	* call.c (build_user_type_conversion_1): Use OVL_FIRST.
	(print_error_for_call_faulure): Use OVL_NAME.
	(build_op_call_1): Use ovl_iterator.
	(add_candidates): Use OVL_FIRST & lkp_iterator.
	(build_op_delete_call): Use MAYBE_BASELINK_FUNCTIONS &
	lkp_iterator.
	* class.c (deduce_noexcept_on_destructors): Use ovl_iterator.
	(type_has_user_nondefault_constructor)
	in_class_defaulted_default_constructor,
	type_has_user_provided_constructor,
	type_has_user_provided_or_explicit_constructor,
	type_has_non_user_provided_default_constructor,
	vbase_has_user_provided_move_assign,
	type_has_move_constructor, type_has_move_assign,
	type_has_user_declared_move_constructor,
	type_has_user_declared_move_assign,
	type_build_ctor_call, type_build_dtor_call,
	type_requires_array_cookie, explain_non_literal_class): Likewise.
	(finish_struct): Use lkp_iterator.
	(resolve_address_of_overloaded_function): Use OVL_NAME,
	lkp_iterator.
	(note_name_declared_in_class): Use OVL_NAME.
	* cxx-pretty-print.c (pp_cxx_unqualified_id): Use OVL_FIRST.
	(pp_cxx_qualified_id, cxx_pretty_printer::id_expression)
	cxx_pretty_printer::expression): Likewise.
	* decl2.c (check_classfn): Use ovl_iterator.
	* pt.c (retrieve_specialization): Use ovl_iterator.
	* tree.c (cp_tree_equal): Use lkp_iterator.
	(type_has_nontrivial_copy_init): Use ovl_iterator.
((--This line, and those below, will be ignored--

M    cp/ChangeLog
M    cp/call.c
M    cp/class.c
M    cp/pt.c
M    cp/decl2.c
M    cp/tree.c
M    cp/cxx-pretty-print.c

From-SVN: r248120
parent c20c3b42
2017-05-16 Nathan Sidwell <nathan@acm.org>
* call.c (build_user_type_conversion_1): Use OVL_FIRST.
(print_error_for_call_faulure): Use OVL_NAME.
(build_op_call_1): Use ovl_iterator.
(add_candidates): Use OVL_FIRST & lkp_iterator.
(build_op_delete_call): Use MAYBE_BASELINK_FUNCTIONS &
lkp_iterator.
* class.c (deduce_noexcept_on_destructors): Use ovl_iterator.
(type_has_user_nondefault_constructor,
in_class_defaulted_default_constructor,
type_has_user_provided_constructor,
type_has_user_provided_or_explicit_constructor,
type_has_non_user_provided_default_constructor,
vbase_has_user_provided_move_assign,
type_has_move_constructor, type_has_move_assign,
type_has_user_declared_move_constructor,
type_has_user_declared_move_assign,
type_build_ctor_call, type_build_dtor_call,
type_requires_array_cookie, explain_non_literal_class): Likewise.
(finish_struct): Use lkp_iterator.
(resolve_address_of_overloaded_function): Use OVL_NAME, lkp_iterator.
(note_name_declared_in_class): Use OVL_NAME.
* cxx-pretty-print.c (pp_cxx_unqualified_id): Use OVL_FIRST.
(pp_cxx_qualified_id, cxx_pretty_printer::id_expression,
cxx_pretty_printer::expression): Likewise.
* decl2.c (check_classfn): Use ovl_iterator.
* pt.c (retrieve_specialization): Use ovl_iterator.
* tree.c (cp_tree_equal): Use lkp_iterator.
(type_has_nontrivial_copy_init): Use ovl_iterator.
* typeck2.c (cxx_incomplete_type_diagnostic): Revert change and
check is_overloaded_fn.
......
......@@ -3783,8 +3783,8 @@ build_user_type_conversion_1 (tree totype, tree expr, int flags,
/* We should never try to call the abstract or base constructor
from here. */
gcc_assert (!DECL_HAS_IN_CHARGE_PARM_P (OVL_CURRENT (ctors))
&& !DECL_HAS_VTT_PARM_P (OVL_CURRENT (ctors)));
gcc_assert (!DECL_HAS_IN_CHARGE_PARM_P (OVL_FIRST (ctors))
&& !DECL_HAS_VTT_PARM_P (OVL_FIRST (ctors)));
args = make_tree_vector_single (expr);
if (BRACE_ENCLOSED_INITIALIZER_P (expr))
......@@ -4172,7 +4172,7 @@ print_error_for_call_failure (tree fn, vec<tree, va_gc> *args,
targs = TREE_OPERAND (fn, 1);
fn = TREE_OPERAND (fn, 0);
}
tree name = DECL_NAME (OVL_CURRENT (fn));
tree name = OVL_NAME (fn);
location_t loc = location_of (name);
if (targs)
name = lookup_template_function (name, targs);
......@@ -4449,16 +4449,15 @@ build_op_call_1 (tree obj, vec<tree, va_gc> **args, tsubst_flags_t complain)
for (; convs; convs = TREE_CHAIN (convs))
{
tree fns = TREE_VALUE (convs);
tree totype = TREE_TYPE (convs);
if (TYPE_PTRFN_P (totype)
|| TYPE_REFFN_P (totype)
|| (TREE_CODE (totype) == REFERENCE_TYPE
&& TYPE_PTRFN_P (TREE_TYPE (totype))))
for (; fns; fns = OVL_NEXT (fns))
for (ovl_iterator iter (TREE_VALUE (convs)); iter; ++iter)
{
tree fn = OVL_CURRENT (fns);
tree fn = *iter;
if (DECL_NONCONVERTING_P (fn))
continue;
......@@ -5376,13 +5375,12 @@ add_candidates (tree fns, tree first_arg, const vec<tree, va_gc> *args,
bool check_list_ctor;
bool check_converting;
unification_kind_t strict;
tree fn;
if (!fns)
return;
/* Precalculate special handling of constructors and conversion ops. */
fn = OVL_CURRENT (fns);
tree fn = OVL_FIRST (fns);
if (DECL_CONV_FN_P (fn))
{
check_list_ctor = false;
......@@ -5425,12 +5423,12 @@ add_candidates (tree fns, tree first_arg, const vec<tree, va_gc> *args,
/* Delay creating the implicit this parameter until it is needed. */
non_static_args = NULL;
for (; fns; fns = OVL_NEXT (fns))
for (lkp_iterator iter (fns); iter; ++iter)
{
tree fn_first_arg;
const vec<tree, va_gc> *fn_args;
fn = OVL_CURRENT (fns);
fn = *iter;
if (check_converting && DECL_NONCONVERTING_P (fn))
continue;
......@@ -6201,8 +6199,7 @@ build_op_delete_call (enum tree_code code, tree addr, tree size,
if (fn == error_mark_node)
return NULL_TREE;
if (BASELINK_P (fn))
fn = BASELINK_FUNCTIONS (fn);
fn = MAYBE_BASELINK_FUNCTIONS (fn);
/* "If the lookup finds the two-parameter form of a usual deallocation
function (3.7.4.2) and that function, considered as a placement
......@@ -6221,10 +6218,10 @@ build_op_delete_call (enum tree_code code, tree addr, tree size,
the usual deallocation function, so we shouldn't complain
about using the operator delete (void *, size_t). */
if (DECL_CLASS_SCOPE_P (fn))
for (t = BASELINK_P (fns) ? BASELINK_FUNCTIONS (fns) : fns;
t; t = OVL_NEXT (t))
for (lkp_iterator iter (MAYBE_BASELINK_FUNCTIONS (fns));
iter; ++iter)
{
tree elt = OVL_CURRENT (t);
tree elt = *iter;
if (usual_deallocation_fn_p (elt)
&& FUNCTION_ARG_CHAIN (elt) == void_list_node)
goto ok;
......@@ -6263,10 +6260,9 @@ build_op_delete_call (enum tree_code code, tree addr, tree size,
allocation function. If the lookup finds a single matching
deallocation function, that function will be called; otherwise, no
deallocation function will be called." */
for (t = BASELINK_P (fns) ? BASELINK_FUNCTIONS (fns) : fns;
t; t = OVL_NEXT (t))
for (lkp_iterator iter (MAYBE_BASELINK_FUNCTIONS (fns)); iter; ++iter)
{
tree elt = OVL_CURRENT (t);
tree elt = *iter;
if (usual_deallocation_fn_p (elt))
{
if (!fn)
......
......@@ -141,7 +141,7 @@ pp_cxx_unqualified_id (cxx_pretty_printer *pp, tree t)
break;
case OVERLOAD:
t = OVL_CURRENT (t);
t = OVL_FIRST (t);
/* FALLTHRU */
case VAR_DECL:
case PARM_DECL:
......@@ -281,7 +281,7 @@ pp_cxx_qualified_id (cxx_pretty_printer *pp, tree t)
FIXME: This is probably the wrong pretty-printing for conversion
functions and some function templates. */
case OVERLOAD:
t = OVL_CURRENT (t);
t = OVL_FIRST (t);
/* FALLTHRU */
case FUNCTION_DECL:
if (DECL_FUNCTION_MEMBER_P (t))
......@@ -350,7 +350,7 @@ void
cxx_pretty_printer::id_expression (tree t)
{
if (TREE_CODE (t) == OVERLOAD)
t = OVL_CURRENT (t);
t = OVL_FIRST (t);
if (DECL_P (t) && DECL_CONTEXT (t))
pp_cxx_qualified_id (this, t);
else
......@@ -1066,7 +1066,7 @@ cxx_pretty_printer::expression (tree t)
break;
case OVERLOAD:
t = OVL_CURRENT (t);
t = OVL_FIRST (t);
/* FALLTHRU */
case VAR_DECL:
case PARM_DECL:
......
......@@ -608,18 +608,12 @@ check_classfn (tree ctype, tree function, tree template_parms)
if (ix >= 0)
{
vec<tree, va_gc> *methods = CLASSTYPE_METHOD_VEC (ctype);
tree fndecls, fndecl = 0;
bool is_conv_op;
const char *format = NULL;
for (fndecls = (*methods)[ix];
fndecls; fndecls = OVL_NEXT (fndecls))
for (ovl_iterator iter ((*methods)[ix]); iter; ++iter)
{
tree p1, p2;
fndecl = OVL_CURRENT (fndecls);
p1 = TYPE_ARG_TYPES (TREE_TYPE (function));
p2 = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
tree fndecl = *iter;
tree p1 = TYPE_ARG_TYPES (TREE_TYPE (function));
tree p2 = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
/* We cannot simply call decls_match because this doesn't
work for static member functions that are pretending to
......@@ -662,49 +656,47 @@ check_classfn (tree ctype, tree function, tree template_parms)
&& (!DECL_TEMPLATE_SPECIALIZATION (function)
|| (DECL_TI_TEMPLATE (function)
== DECL_TI_TEMPLATE (fndecl))))
break;
}
if (fndecls)
{
if (pushed_scope)
pop_scope (pushed_scope);
return OVL_CURRENT (fndecls);
{
if (pushed_scope)
pop_scope (pushed_scope);
return fndecl;
}
}
error_at (DECL_SOURCE_LOCATION (function),
"prototype for %q#D does not match any in class %qT",
function, ctype);
is_conv_op = DECL_CONV_FN_P (fndecl);
const char *format = NULL;
tree first = OVL_FIRST ((*methods)[ix]);
bool is_conv_op = DECL_CONV_FN_P (first);
tree prev = NULL_TREE;
if (is_conv_op)
ix = CLASSTYPE_FIRST_CONVERSION_SLOT;
fndecls = (*methods)[ix];
while (fndecls)
do
{
fndecl = OVL_CURRENT (fndecls);
fndecls = OVL_NEXT (fndecls);
if (!fndecls && is_conv_op)
ovl_iterator iter ((*methods)[ix++]);
if (is_conv_op && !DECL_CONV_FN_P (*iter))
break;
for (; iter; ++iter)
{
if (methods->length () > (size_t) ++ix)
if (prev)
{
fndecls = (*methods)[ix];
if (!DECL_CONV_FN_P (OVL_CURRENT (fndecls)))
{
fndecls = NULL_TREE;
is_conv_op = false;
}
if (!format)
format = N_("candidates are: %+#D");
error (format, prev);
format = " %+#D";
}
else
is_conv_op = false;
prev = *iter;
}
if (format)
format = " %+#D";
else if (fndecls)
format = N_("candidates are: %+#D");
else
}
while (is_conv_op && size_t (ix) < methods->length ());
if (prev)
{
if (!format)
format = N_("candidate is: %+#D");
error (format, fndecl);
error (format, prev);
}
}
else if (!COMPLETE_TYPE_P (ctype))
......
......@@ -1187,31 +1187,25 @@ retrieve_specialization (tree tmpl, tree args, hashval_t hash)
if (optimize_specialization_lookup_p (tmpl))
{
tree class_template;
tree class_specialization;
vec<tree, va_gc> *methods;
tree fns;
int idx;
/* The template arguments actually apply to the containing
class. Find the class specialization with those
arguments. */
class_template = CLASSTYPE_TI_TEMPLATE (DECL_CONTEXT (tmpl));
class_specialization
tree class_template = CLASSTYPE_TI_TEMPLATE (DECL_CONTEXT (tmpl));
tree class_specialization
= retrieve_specialization (class_template, args, 0);
if (!class_specialization)
return NULL_TREE;
/* Now, find the appropriate entry in the CLASSTYPE_METHOD_VEC
for the specialization. */
idx = class_method_index_for_fn (class_specialization, tmpl);
int idx = class_method_index_for_fn (class_specialization, tmpl);
if (idx == -1)
return NULL_TREE;
/* Iterate through the methods with the indicated name, looking
for the one that has an instance of TMPL. */
methods = CLASSTYPE_METHOD_VEC (class_specialization);
for (fns = (*methods)[idx]; fns; fns = OVL_NEXT (fns))
vec<tree, va_gc> *methods = CLASSTYPE_METHOD_VEC (class_specialization);
for (ovl_iterator iter ((*methods)[idx]); iter; ++iter)
{
tree fn = OVL_CURRENT (fns);
tree fn = *iter;
if (DECL_TEMPLATE_INFO (fn) && DECL_TI_TEMPLATE (fn) == tmpl
/* using-declarations can add base methods to the method vec,
and we don't want those here. */
......
......@@ -3403,9 +3403,16 @@ cp_tree_equal (tree t1, tree t2)
return same_type_p (PTRMEM_CST_CLASS (t1), PTRMEM_CST_CLASS (t2));
case OVERLOAD:
if (OVL_FUNCTION (t1) != OVL_FUNCTION (t2))
return false;
return cp_tree_equal (OVL_CHAIN (t1), OVL_CHAIN (t2));
{
/* Two overloads. Must be exactly the same set of decls. */
lkp_iterator first (t1);
lkp_iterator second (t2);
for (; first && second; ++first, ++second)
if (*first != *second)
return false;
return !(first || second);
}
case TRAIT_EXPR:
if (TRAIT_EXPR_KIND (t1) != TRAIT_EXPR_KIND (t2))
......@@ -3682,9 +3689,9 @@ type_has_nontrivial_copy_init (const_tree type)
}
if (!saw_non_deleted && CLASSTYPE_METHOD_VEC (t))
for (tree fns = CLASSTYPE_CONSTRUCTORS (t); fns; fns = OVL_NEXT (fns))
for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter)
{
tree fn = OVL_CURRENT (fns);
tree fn = *iter;
if (copy_fn_p (fn))
{
saw_copy = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment