aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/cp/ChangeLog27
-rw-r--r--gcc/cp/call.c9
-rw-r--r--gcc/cp/class.c25
-rw-r--r--gcc/cp/cp-tree.h6
-rw-r--r--gcc/cp/decl.c2
-rw-r--r--gcc/cp/decl2.c4
-rw-r--r--gcc/cp/method.c2
-rw-r--r--gcc/cp/name-lookup.c6
-rw-r--r--gcc/cp/name-lookup.h4
-rw-r--r--gcc/cp/pt.c31
-rw-r--r--gcc/cp/search.c7
-rw-r--r--gcc/cp/semantics.c8
-rw-r--r--gcc/cp/tree.c2
13 files changed, 74 insertions, 59 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 2021389..b9fab91 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,30 @@
+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.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 9e4a5c1..88af0d3 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -3738,7 +3738,7 @@ build_user_type_conversion_1 (tree totype, tree expr, int flags,
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
@@ -8243,9 +8243,7 @@ first_non_public_field (tree type)
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
@@ -8294,8 +8292,7 @@ has_trivial_copy_assign_p (tree type, bool access, bool *hasassign)
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)
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index d04c2ac..908edc4 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -2745,7 +2745,7 @@ get_basefndecls (tree name, tree t, vec<tree> *base_fndecls)
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;
@@ -5034,14 +5034,12 @@ bool
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);
@@ -5180,13 +5178,12 @@ classtype_has_move_assign_or_move_ctor_p (tree t, bool user_p)
&& !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))
@@ -5220,8 +5217,7 @@ type_build_ctor_call (tree t)
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;
@@ -5248,8 +5244,7 @@ type_build_dtor_call (tree t)
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;
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 9d24331..20fa039 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -216,7 +216,7 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];
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
@@ -2152,14 +2152,14 @@ struct GTY(()) lang_type {
/* 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
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index da5e16b..655445b 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -7857,7 +7857,7 @@ register_dtor_fn (tree decl)
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,
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 0f828b5..d950a85 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -606,7 +606,7 @@ check_classfn (tree ctype, tree function, tree template_parms)
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)
{
@@ -664,7 +664,7 @@ check_classfn (tree ctype, tree function, tree template_parms)
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);
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index 012d02a..b83a6f2 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -2408,7 +2408,7 @@ lazily_declare_fn (special_function_kind sfk, tree type)
|| 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);
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index a9ed429..81635ff 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -1118,7 +1118,7 @@ extract_conversion_operator (tree fns, tree type)
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)
@@ -1285,7 +1285,7 @@ lookup_field_1 (tree type, tree name, bool want_type)
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);
@@ -1314,7 +1314,7 @@ lookup_fnfields_slot (tree type, tree name)
}
}
- 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
diff --git a/gcc/cp/name-lookup.h b/gcc/cp/name-lookup.h
index aa96e15..0051bfc 100644
--- a/gcc/cp/name-lookup.h
+++ b/gcc/cp/name-lookup.h
@@ -320,8 +320,8 @@ extern void do_namespace_alias (tree, tree);
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 *);
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index f422e9c..eb27f6a 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -1216,7 +1216,7 @@ retrieve_specialization (tree tmpl, tree args, hashval_t hash)
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;
@@ -2915,9 +2915,8 @@ check_explicit_specialization (tree declarator,
`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)
{
@@ -25648,20 +25647,18 @@ do_class_deduction (tree ptype, tree tmpl, tree init, int flags,
}
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;
diff --git a/gcc/cp/search.c b/gcc/cp/search.c
index 266d8dd..38be467 100644
--- a/gcc/cp/search.c
+++ b/gcc/cp/search.c
@@ -978,7 +978,7 @@ lookup_field_r (tree binfo, void *data)
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. */
@@ -2048,7 +2048,7 @@ look_for_overrides (tree type, tree fndecl)
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)
{
@@ -2370,8 +2370,7 @@ lookup_conversions_r (tree binfo, int virtual_depth, int virtualness,
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;
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index b2e58d2..4f4c17f 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -9009,10 +9009,10 @@ classtype_has_nothrow_assign_or_copy_p (tree type, bool assign_p)
{
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)
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index aab92d5..12c31fb 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -3988,7 +3988,7 @@ type_has_nontrivial_copy_init (const_tree type)
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;