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.

Index: call.c
===================================================================
--- call.c	(revision 251779)
+++ call.c	(working copy)
@@ -3738,7 +3738,7 @@ build_user_type_conversion_1 (tree totyp
   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, bo
 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)
Index: class.c
===================================================================
--- class.c	(revision 251779)
+++ class.c	(working copy)
@@ -2745,7 +2745,7 @@ get_basefndecls (tree name, tree t, vec<
   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
 		  && !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;
Index: cp-tree.h
===================================================================
--- cp-tree.h	(revision 251779)
+++ cp-tree.h	(working copy)
@@ -216,7 +216,7 @@ extern GTY(()) tree cp_global_trees[CPTI
    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
Index: decl.c
===================================================================
--- decl.c	(revision 251779)
+++ decl.c	(working copy)
@@ -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,
Index: decl2.c
===================================================================
--- decl2.c	(revision 251779)
+++ decl2.c	(working copy)
@@ -606,7 +606,7 @@ check_classfn (tree ctype, tree function
      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
       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);
Index: method.c
===================================================================
--- method.c	(revision 251779)
+++ method.c	(working copy)
@@ -2408,7 +2408,7 @@ lazily_declare_fn (special_function_kind
       || 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);
 
Index: name-lookup.c
===================================================================
--- name-lookup.c	(revision 251779)
+++ name-lookup.c	(working copy)
@@ -1118,7 +1118,7 @@ extract_conversion_operator (tree fns, t
    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, bo
    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 na
 	}
     }
 
-  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
Index: name-lookup.h
===================================================================
--- name-lookup.h	(revision 251779)
+++ name-lookup.h	(working copy)
@@ -320,8 +320,8 @@ extern void do_namespace_alias (tree, tr
 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 *);
Index: pt.c
===================================================================
--- pt.c	(revision 251779)
+++ pt.c	(working copy)
@@ -1216,7 +1216,7 @@ retrieve_specialization (tree tmpl, tree
 	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 decl
 	     `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 tmp
     }
 
   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;
 
Index: search.c
===================================================================
--- search.c	(revision 251779)
+++ search.c	(working copy)
@@ -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 fnde
 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 vi
     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;
Index: semantics.c
===================================================================
--- semantics.c	(revision 251779)
+++ semantics.c	(working copy)
@@ -9009,10 +9009,10 @@ classtype_has_nothrow_assign_or_copy_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)
Index: tree.c
===================================================================
--- tree.c	(revision 251779)
+++ tree.c	(working copy)
@@ -3988,7 +3988,7 @@ type_has_nontrivial_copy_init (const_tre
 	    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;
