This patch gets the remaining stragglers outside of name-lookup. Nothing particularly exciting here.

Remaining patches will be primarily in name-lookup.c, with a few in cp-tree.h, tree.c and the parser. These will be the patches that are the significant changes (all this lot was just ground work!)

nathan
--
Nathan Sidwell
2017-05-19  Nathan Sidwell  <nat...@acm.org>

	* call.c (add_list_candidates): Use OVL_FIRST.
	(build_new_method_call_1): Likewise.
	* cp-tree.h (OVL_SINGLE_P): New.
	(TYPE_HIDDEN_P): New.
	* decl.c (xref_tag_1): Use TYPE_HIDDEN_P.
	* dump.c (cp_tump_tree): Adjust overload dumping.
	* error.c (dump_decl): Use OVL_SINGLE_P, simplify context
	printing.
	* method.c (lazily_declare_fn): Assert we added it.
	* parser.c (cp_parser_nested_name_specifier): Use OVL_SINGLE_P,
	OVL_FIRST.
	(cp_parser_template_name): Use lkp_iterator.
	* pt.c (begin_template_parm_list): Fixup comment.
	(instantiate_class_template_1): Use TYPE_HIDDEN_P.
	* tree.c (ovl_iterator::remove_node): Cope with inherited ctors.
	(ovl_scope): Use lkp_iterator.

Index: call.c
===================================================================
--- call.c	(revision 248265)
+++ call.c	(working copy)
@@ -3666,7 +3666,7 @@ add_list_candidates (tree fns, tree firs
      avoid the copy constructor call for copy-list-initialization.  */
   flags |= LOOKUP_NO_NARROWING;
 
-  unsigned nart = num_artificial_parms_for (get_first_fn (fns)) - 1;
+  unsigned nart = num_artificial_parms_for (OVL_FIRST (fns)) - 1;
   tree init_list = (*args)[nart];
 
   /* Always use the default constructor if the list is empty (DR 990).  */
@@ -8539,7 +8539,7 @@ build_new_method_call_1 (tree instance,
   gcc_assert (TREE_CODE (fns) == FUNCTION_DECL
 	      || TREE_CODE (fns) == TEMPLATE_DECL
 	      || TREE_CODE (fns) == OVERLOAD);
-  fn = get_first_fn (fns);
+  fn = OVL_FIRST (fns);
   name = DECL_NAME (fn);
 
   basetype = TYPE_MAIN_VARIANT (TREE_TYPE (instance));
@@ -8708,7 +8708,7 @@ build_new_method_call_1 (tree instance,
 	      tree errname = name;
 	      if (IDENTIFIER_CTOR_OR_DTOR_P (errname))
 		{
-		  tree fn = DECL_ORIGIN (get_first_fn (fns));
+		  tree fn = DECL_ORIGIN (OVL_FIRST (fns));
 		  errname = DECL_NAME (fn);
 		}
 	      if (explicit_targs)
Index: cp-tree.h
===================================================================
--- cp-tree.h	(revision 248265)
+++ cp-tree.h	(working copy)
@@ -655,6 +655,10 @@ typedef struct ptrmem_cst * ptrmem_cst_t
 /* The name of the overload set.  */
 #define OVL_NAME(NODE) DECL_NAME (OVL_FIRST (NODE))
 
+/* Whether this is a single member overload.  */
+#define OVL_SINGLE_P(NODE) \
+  (TREE_CODE (NODE) != OVERLOAD || !OVL_CHAIN (NODE))
+
 struct GTY(()) tree_overload {
   struct tree_common common;
   tree function;
@@ -3750,6 +3754,11 @@ more_aggr_init_expr_args_p (const aggr_i
   (DECL_LANG_SPECIFIC (TYPE_FUNCTION_OR_TEMPLATE_DECL_CHECK (NODE)) \
    ->u.base.anticipated_p)
 
+/* True if this is a hidden class type.    */
+#define TYPE_HIDDEN_P(NODE) \
+  (DECL_LANG_SPECIFIC (TYPE_NAME (NODE)) \
+   && DECL_ANTICIPATED (TYPE_NAME (NODE)))
+
 /* True for artificial decls added for OpenMP privatized non-static
    data members.  */
 #define DECL_OMP_PRIVATIZED_MEMBER(NODE) \
Index: decl.c
===================================================================
--- decl.c	(revision 248265)
+++ decl.c	(working copy)
@@ -13636,16 +13636,18 @@ xref_tag_1 (enum tag_types tag_code, tre
 	}
 
       /* Make injected friend class visible.  */
-      if (scope != ts_within_enclosing_non_class
-	  && hidden_name_p (TYPE_NAME (t)))
+      if (scope != ts_within_enclosing_non_class && TYPE_HIDDEN_P (t))
 	{
-	  DECL_ANTICIPATED (TYPE_NAME (t)) = 0;
-	  DECL_FRIEND_P (TYPE_NAME (t)) = 0;
+	  tree decl = TYPE_NAME (t);
+
+	  DECL_ANTICIPATED (decl) = false;
+	  DECL_FRIEND_P (decl) = false;
 
 	  if (TYPE_TEMPLATE_INFO (t))
 	    {
-	      DECL_ANTICIPATED (TYPE_TI_TEMPLATE (t)) = 0;
-	      DECL_FRIEND_P (TYPE_TI_TEMPLATE (t)) = 0;
+	      tree tmpl = TYPE_TI_TEMPLATE (t);
+	      DECL_ANTICIPATED (tmpl) = false;
+	      DECL_FRIEND_P (tmpl) = false;
 	    }
 	}
     }
Index: dump.c
===================================================================
--- dump.c	(revision 248265)
+++ dump.c	(working copy)
@@ -364,8 +364,10 @@ cp_dump_tree (void* dump_info, tree t)
       break;
 
     case OVERLOAD:
-      dump_child ("crnt", OVL_CURRENT (t));
-      dump_child ("chan", OVL_CHAIN (t));
+      dump_child ("name", OVL_NAME (t));
+      if (!dump_flag (di, TDF_SLIM, t))
+	for (lkp_iterator iter (t); iter; ++iter)
+	  dump_child ("chld", *iter);
       break;
 
     case TRY_BLOCK:
Index: error.c
===================================================================
--- error.c	(revision 248265)
+++ error.c	(working copy)
@@ -1189,17 +1189,16 @@ dump_decl (cxx_pretty_printer *pp, tree
       break;
 
     case OVERLOAD:
-      if (OVL_CHAIN (t))
+      if (!OVL_SINGLE_P (t))
 	{
-	  t = OVL_CURRENT (t);
-	  if (DECL_CLASS_SCOPE_P (t))
+	  t = OVL_FIRST (t);
+	  tree ctx = CP_DECL_CONTEXT (t);
+	  if (ctx != global_namespace)
 	    {
-	      dump_type (pp, DECL_CONTEXT (t), flags);
-	      pp_cxx_colon_colon (pp);
-	    }
-	  else if (!DECL_FILE_SCOPE_P (t))
-	    {
-	      dump_decl (pp, DECL_CONTEXT (t), flags);
+	      if (TYPE_P (ctx))
+		dump_type (pp, ctx, flags);
+	      else
+		dump_decl (pp, ctx, flags);
 	      pp_cxx_colon_colon (pp);
 	    }
 	  dump_decl (pp, DECL_NAME (t), flags);
Index: method.c
===================================================================
--- method.c	(revision 248265)
+++ method.c	(working copy)
@@ -2387,7 +2387,8 @@ lazily_declare_fn (special_function_kind
       || sfk == sfk_copy_assignment)
     check_for_override (fn, type);
   /* Add it to CLASSTYPE_METHOD_VEC.  */
-  add_method (type, fn, false);
+  bool added = add_method (type, fn, false);
+  gcc_assert (added);
   /* Add it to TYPE_METHODS.  */
   if (sfk == sfk_destructor
       && DECL_VIRTUAL_P (fn))
Index: parser.c
===================================================================
--- parser.c	(revision 248265)
+++ parser.c	(working copy)
@@ -6028,8 +6028,8 @@ cp_parser_nested_name_specifier_opt (cp_
 		  if (is_overloaded_fn (tid))
 		    {
 		      tree fns = get_fns (tid);
-		      if (!OVL_CHAIN (fns))
-			tmpl = OVL_CURRENT (fns);
+		      if (OVL_SINGLE_P (fns))
+			tmpl = OVL_FIRST (fns);
 		      error_at (token->location, "function template-id %qD "
 				"in nested-name-specifier", tid);
 		    }
@@ -15639,7 +15639,6 @@ cp_parser_template_name (cp_parser* pars
 {
   tree identifier;
   tree decl;
-  tree fns;
   cp_token *token = cp_lexer_peek_token (parser->lexer);
 
   /* If the next token is `operator', then we have either an
@@ -15765,20 +15764,19 @@ cp_parser_template_name (cp_parser* pars
     }
   else
     {
-      tree fn = NULL_TREE;
-
       /* The standard does not explicitly indicate whether a name that
 	 names a set of overloaded declarations, some of which are
 	 templates, is a template-name.  However, such a name should
 	 be a template-name; otherwise, there is no way to form a
 	 template-id for the overloaded templates.  */
-      fns = BASELINK_P (decl) ? BASELINK_FUNCTIONS (decl) : decl;
-      if (TREE_CODE (fns) == OVERLOAD)
-	for (fn = fns; fn; fn = OVL_NEXT (fn))
-	  if (TREE_CODE (OVL_CURRENT (fn)) == TEMPLATE_DECL)
-	    break;
+      bool found = false;
+
+      for (lkp_iterator iter (MAYBE_BASELINK_FUNCTIONS (decl));
+	   !found && iter; ++iter)
+	if (TREE_CODE (*iter) == TEMPLATE_DECL)
+	  found = true;
 
-      if (!fn)
+      if (!found)
 	{
 	  /* The name does not name a template.  */
 	  cp_parser_error (parser, "expected template-name");
Index: pt.c
===================================================================
--- pt.c	(revision 248265)
+++ pt.c	(working copy)
@@ -648,8 +648,8 @@ begin_template_parm_list (void)
 	 template <class T> struct S2 {};
        };
 
-     pushtag contains special code to call pushdecl_with_scope on the
-     TEMPLATE_DECL for S2.  */
+     pushtag contains special code to insert the TEMPLATE_DECL for S2
+     at the right scope.  */
   begin_scope (sk_template_parms, NULL);
   ++processing_template_decl;
   ++processing_template_parmlist;
@@ -10592,7 +10592,7 @@ instantiate_class_template_1 (tree type)
 		  --processing_template_decl;
 		}
 	      else if (!CLASSTYPE_USE_TEMPLATE (friend_type)
-		       && hidden_name_p (TYPE_NAME (friend_type)))
+		       && TYPE_HIDDEN_P (friend_type))
 		{
 		  /* friend class C;
 
Index: tree.c
===================================================================
--- tree.c	(revision 248265)
+++ tree.c	(working copy)
@@ -2230,7 +2230,11 @@ ovl_iterator::remove_node (tree overload
      singleton overload (and consequently maybe setting its type),
      because all uses of this function will be followed by inserting a
      new node that must follow the place we've cut this out from.  */
-  *slot = OVL_CHAIN (node);
+  if (TREE_CODE (node) != OVERLOAD)
+    /* Cloned inherited ctors don't mark themselves as via_using.  */
+    *slot = NULL_TREE;
+  else
+    *slot = OVL_CHAIN (node);
 
   return overload;
 }
@@ -2362,9 +2366,12 @@ ovl_scope (tree ovl)
   if (TREE_CODE (ovl) == TEMPLATE_ID_EXPR)
     ovl = TREE_OPERAND (ovl, 0);
   /* Skip using-declarations.  */
-  while (TREE_CODE (ovl) == OVERLOAD && OVL_USING_P (ovl) && OVL_CHAIN (ovl))
-    ovl = OVL_CHAIN (ovl);
-  return CP_DECL_CONTEXT (OVL_CURRENT (ovl));
+  lkp_iterator iter (ovl);
+  do
+    ovl = *iter;
+  while (iter.using_p () && ++iter);
+
+  return CP_DECL_CONTEXT (ovl);
 }
 
 #define PRINT_RING_SIZE 4

Reply via email to