+2017-09-06 Nathan Sidwell <nathan@acm.org>
+
+ * name-lookup.h (lookup_fnfields_slot_nolazy,
+ lookup_fnfields_slot): Rename to ...
+ (get_class_binding_direct, get_class_binding): ... here.
+ * name-lookup.c (lookup_fnfields_slot_nolazy,
+ lookup_fnfields_slot): Rename to ...
+ (get_class_binding_direct, get_class_binding): ... here.
+ * cp-tree.h (CLASSTYPE_CONSTRUCTORS, CLASSTYPE_DESTRUCTOR): Adjust.
+ * call.c (build_user_type_conversion_1): Adjust.
+ (has_trivial_copy_assign_p): Adjust.
+ (has_trivial_copy_p): Adjust.
+ * class.c (get_basefndecls) Adjust.
+ (vbase_has_user_provided_move_assign) Adjust.
+ (classtype_has_move_assign_or_move_ctor_p): Adjust.
+ (type_build_ctor_call, type_build_dtor_call): Adjust.
+ * decl.c (register_dtor_fn): Adjust.
+ * decl2.c (check_classfn): Adjust.
+ * pt.c (retrieve_specialization): Adjust.
+ (check_explicit_specialization): Adjust.
+ (do_class_deduction): Adjust.
+ * search.c (lookup_field_r): Adjust.
+ (look_for_overrides_here, lookup_conversions_r): Adjust.
+ * semantics.c (classtype_has_nothrow_assign_or_copy_p): Adjust.
+ * tree.c (type_has_nontrivial_copy_init): Adjust.
+ * method.c (lazily_declare_fn): Adjust comment.
+
2017-09-05 Nathan Sidwell <nathan@acm.org>
* name-lookup.c (do_class_using_decl): Elide read-once temps.
if (CLASS_TYPE_P (totype))
/* Use lookup_fnfields_slot instead of lookup_fnfields to avoid
creating a garbage BASELINK; constructors can't be inherited. */
- ctors = lookup_fnfields_slot (totype, complete_ctor_identifier);
+ ctors = get_class_binding (totype, complete_ctor_identifier);
/* FIXME P0135 doesn't say what to do in C++17 about list-initialization from
a single element. For now, let's handle constructors as before and also
static bool
has_trivial_copy_assign_p (tree type, bool access, bool *hasassign)
{
- tree fns = cp_assignment_operator_id (NOP_EXPR);
- fns = lookup_fnfields_slot (type, fns);
-
+ tree fns = get_class_binding (type, cp_assignment_operator_id (NOP_EXPR));
bool all_trivial = true;
/* Iterate over overloads of the assignment operator, checking
static bool
has_trivial_copy_p (tree type, bool access, bool hasctor[2])
{
- tree fns = lookup_fnfields_slot (type, complete_ctor_identifier);
-
+ tree fns = get_class_binding (type, complete_ctor_identifier);
bool all_trivial = true;
for (ovl_iterator oi (fns); oi; ++oi)
bool found_decls = false;
/* Find virtual functions in T with the indicated NAME. */
- for (ovl_iterator iter (lookup_fnfields_slot (t, name)); iter; ++iter)
+ for (ovl_iterator iter (get_class_binding (t, name)); iter; ++iter)
{
tree method = *iter;
vbase_has_user_provided_move_assign (tree type)
{
/* Does the type itself have a user-provided move assignment operator? */
- for (ovl_iterator iter (lookup_fnfields_slot_nolazy
- (type, cp_assignment_operator_id (NOP_EXPR)));
- iter; ++iter)
- {
- tree fn = *iter;
- if (move_fn_p (fn) && user_provided_p (fn))
+ if (!CLASSTYPE_LAZY_MOVE_ASSIGN (type))
+ for (ovl_iterator iter (get_class_binding_direct
+ (type, cp_assignment_operator_id (NOP_EXPR)));
+ iter; ++iter)
+ if (!DECL_ARTIFICIAL (*iter) && move_fn_p (*iter))
return true;
- }
/* Do any of its bases? */
tree binfo = TYPE_BINFO (type);
&& !CLASSTYPE_LAZY_MOVE_ASSIGN (t)));
if (!CLASSTYPE_LAZY_MOVE_CTOR (t))
- for (ovl_iterator iter (lookup_fnfields_slot_nolazy (t, ctor_identifier));
- iter; ++iter)
+ for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter)
if ((!user_p || !DECL_ARTIFICIAL (*iter)) && move_fn_p (*iter))
return true;
if (!CLASSTYPE_LAZY_MOVE_ASSIGN (t))
- for (ovl_iterator iter (lookup_fnfields_slot_nolazy
+ for (ovl_iterator iter (get_class_binding_direct
(t, cp_assignment_operator_id (NOP_EXPR)));
iter; ++iter)
if ((!user_p || !DECL_ARTIFICIAL (*iter)) && move_fn_p (*iter))
return false;
/* A user-declared constructor might be private, and a constructor might
be trivial but deleted. */
- for (ovl_iterator iter
- (lookup_fnfields_slot (inner, complete_ctor_identifier));
+ for (ovl_iterator iter (get_class_binding (inner, complete_ctor_identifier));
iter; ++iter)
{
tree fn = *iter;
return false;
/* A user-declared destructor might be private, and a destructor might
be trivial but deleted. */
- for (ovl_iterator iter
- (lookup_fnfields_slot (inner, complete_dtor_identifier));
+ for (ovl_iterator iter (get_class_binding (inner, complete_dtor_identifier));
iter; ++iter)
{
tree fn = *iter;
example:
tree ovlid = cp_assignment_operator_id (NOP_EXPR);
- tree overloads = lookup_fnfields_slot (type, ovlid);
+ tree overloads = get_class_binding (type, ovlid);
for (ovl_iterator it (overloads); it; ++it) { ... }
iterates over the set of implicitly and explicitly defined overloads
/* A FUNCTION_DECL or OVERLOAD for the constructors for NODE. These
are the constructors that take an in-charge parameter. */
#define CLASSTYPE_CONSTRUCTORS(NODE) \
- (lookup_fnfields_slot_nolazy (NODE, ctor_identifier))
+ (get_class_binding_direct (NODE, ctor_identifier))
/* A FUNCTION_DECL for the destructor for NODE. This is the
destructors that take an in-charge parameter. If
CLASSTYPE_LAZY_DESTRUCTOR is true, then this entry will be NULL
until the destructor is created with lazily_declare_fn. */
#define CLASSTYPE_DESTRUCTOR(NODE) \
- (lookup_fnfields_slot_nolazy (NODE, dtor_identifier))
+ (get_class_binding_direct (NODE, dtor_identifier))
/* A dictionary of the nested user-defined-types (class-types, or enums)
found within this class. This table includes nested member class
use_dtor = ob_parm && CLASS_TYPE_P (type);
if (use_dtor)
{
- cleanup = lookup_fnfields_slot (type, complete_dtor_identifier);
+ cleanup = get_class_binding (type, complete_dtor_identifier);
/* Make sure it is accessible. */
perform_or_defer_access_check (TYPE_BINFO (type), cleanup, cleanup,
resolving within the scope of CTYPE. */
tree pushed_scope = push_scope (ctype);
tree matched = NULL_TREE;
- tree fns = lookup_fnfields_slot (ctype, DECL_NAME (function));
+ tree fns = get_class_binding (ctype, DECL_NAME (function));
for (ovl_iterator iter (fns); !matched && iter; ++iter)
{
else
{
if (DECL_CONV_FN_P (function))
- fns = lookup_fnfields_slot (ctype, conv_op_identifier);
+ fns = get_class_binding (ctype, conv_op_identifier);
error_at (DECL_SOURCE_LOCATION (function),
"no declaration matches %q#D", function);
|| sfk == sfk_copy_assignment)
check_for_override (fn, type);
- /* Add it to CLASSTYPE_METHOD_VEC. */
+ /* Add it to the class */
bool added = add_method (type, fn, false);
gcc_assert (added);
member functions. */
tree
-lookup_fnfields_slot_nolazy (tree type, tree name)
+get_class_binding_direct (tree type, tree name)
{
vec<tree, va_gc> *method_vec = CLASSTYPE_METHOD_VEC (type);
if (!method_vec)
the method vector with name NAME. Lazily create ctors etc. */
tree
-lookup_fnfields_slot (tree type, tree name)
+get_class_binding (tree type, tree name)
{
type = complete_type (type);
}
}
- return lookup_fnfields_slot_nolazy (type, name);
+ return get_class_binding_direct (type, name);
}
/* Find the slot containing overloads called 'NAME'. If there is no
extern tree do_class_using_decl (tree, tree);
extern tree lookup_arg_dependent (tree, tree, vec<tree, va_gc> *);
extern tree lookup_field_1 (tree, tree, bool);
-extern tree lookup_fnfields_slot (tree, tree);
-extern tree lookup_fnfields_slot_nolazy (tree, tree);
+extern tree get_class_binding_direct (tree, tree);
+extern tree get_class_binding (tree, tree);
extern tree *get_method_slot (tree klass, tree name);
extern void resort_type_method_vec (void *, void *,
gt_pointer_operator, void *);
return NULL_TREE;
/* Find the instance of TMPL. */
- tree fns = lookup_fnfields_slot (class_specialization, DECL_NAME (tmpl));
+ tree fns = get_class_binding (class_specialization, DECL_NAME (tmpl));
for (ovl_iterator iter (fns); iter; ++iter)
{
tree fn = *iter;
`operator int' which will be a specialization of
`operator T'. Grab all the conversion operators, and
then select from them. */
- tree fns = lookup_fnfields_slot_nolazy (ctype,
- IDENTIFIER_CONV_OP_P (name)
- ? conv_op_identifier : name);
+ tree fns = get_class_binding (ctype, IDENTIFIER_CONV_OP_P (name)
+ ? conv_op_identifier : name);
if (fns == NULL_TREE)
{
}
bool saw_ctor = false;
- if (CLASSTYPE_METHOD_VEC (type))
- // FIXME cache artificial deduction guides
- for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (type));
- iter; ++iter)
- {
- tree guide = build_deduction_guide (*iter, outer_args, complain);
- if ((flags & LOOKUP_ONLYCONVERTING)
- && DECL_NONCONVERTING_P (STRIP_TEMPLATE (guide)))
- elided = true;
- else
- cands = lookup_add (guide, cands);
+ // FIXME cache artificial deduction guides
+ for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (type)); iter; ++iter)
+ {
+ tree guide = build_deduction_guide (*iter, outer_args, complain);
+ if ((flags & LOOKUP_ONLYCONVERTING)
+ && DECL_NONCONVERTING_P (STRIP_TEMPLATE (guide)))
+ elided = true;
+ else
+ cands = lookup_add (guide, cands);
- saw_ctor = true;
- }
+ saw_ctor = true;
+ }
tree call = error_mark_node;
member with the same name, and if there's a function and a type
with the same name, the type is hidden by the function. */
if (!lfi->want_type)
- nval = lookup_fnfields_slot (type, lfi->name);
+ nval = get_class_binding (type, lfi->name);
if (!nval)
/* Look for a data member or type. */
tree
look_for_overrides_here (tree type, tree fndecl)
{
- tree ovl = lookup_fnfields_slot (type, DECL_NAME (fndecl));
+ tree ovl = get_class_binding (type, DECL_NAME (fndecl));
for (ovl_iterator iter (ovl); iter; ++iter)
{
virtual_depth++;
/* First, locate the unhidden ones at this level. */
- tree conv = lookup_fnfields_slot_nolazy (BINFO_TYPE (binfo),
- conv_op_identifier);
+ if (tree conv = get_class_binding (BINFO_TYPE (binfo), conv_op_identifier))
for (ovl_iterator iter (conv); iter; ++iter)
{
tree fn = *iter;
{
tree fns = NULL_TREE;
- if (assign_p)
- fns = lookup_fnfields_slot (type, cp_assignment_operator_id (NOP_EXPR));
- else if (TYPE_HAS_COPY_CTOR (type))
- fns = lookup_fnfields_slot (type, ctor_identifier);
+ if (assign_p || TYPE_HAS_COPY_CTOR (type))
+ fns = get_class_binding (type,
+ assign_p ? cp_assignment_operator_id (NOP_EXPR)
+ : ctor_identifier);
bool saw_copy = false;
for (ovl_iterator iter (fns); iter; ++iter)
saw_non_deleted = true;
}
- if (!saw_non_deleted && CLASSTYPE_METHOD_VEC (t))
+ if (!saw_non_deleted)
for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter)
{
tree fn = *iter;