FreeBSD/contrib/gcc/cp/call.c
/* Create an overload candidate for the function or method FN called with
   the argument list ARGLIST and add it to CANDIDATES.  FLAGS is passed on
   to implicit_conversion.

   CTYPE, if non-NULL, is the type we want to pretend this function
   comes from for purposes of overload resolution.  */
Create an overload candidate for the function or method FN called with
the argument list ARGLIST and add it to CANDIDATES.  FLAGS is passed on
to implicit_conversion.

CTYPE, if non-NULL, is the type we want to pretend this function
comes from for purposes of overload resolution.
Create an overload candidate for the function or method FN called with the argument list ARGLIST and add it to CANDIDATES . FLAGS is passed on to implicit_conversion . CTYPE if non - NULL is the type we want to pretend this function comes from for purposes of overload resolution .
static struct z_candidate *
add_function_candidate (struct z_candidate **candidates,
			tree fn, tree ctype, tree arglist,
			tree access_path, tree conversion_path,
			int flags)
{
  tree parmlist = TYPE_ARG_TYPES (TREE_TYPE (fn));
  int i, len;
  conversion **convs;
  tree parmnode, argnode;
  tree orig_arglist;
  int viable = 1;
  gcc_assert (!DECL_ANTICIPATED (fn) || DECL_HIDDEN_FRIEND_P (fn));
  if (DECL_CONSTRUCTOR_P (fn))
    {
      parmlist = skip_artificial_parms_for (fn, parmlist);
      orig_arglist = arglist;
      arglist = skip_artificial_parms_for (fn, arglist);
    }
  else
    orig_arglist = arglist;
  len = list_length (arglist);
  convs = alloc_conversions (len);
  parmnode = parmlist;
  for (i = 0; i < len; ++i)
    {
      if (parmnode == NULL_TREE || parmnode == void_list_node)
	break;
      parmnode = TREE_CHAIN (parmnode);
    }
  if (i < len && parmnode)
    viable = 0;
  else if (!sufficient_parms_p (parmnode))
    viable = 0;
  if (! viable)
    goto out;
  parmnode = parmlist;
  argnode = arglist;
  for (i = 0; i < len; ++i)
    {
      tree arg = TREE_VALUE (argnode);
      tree argtype = lvalue_type (arg);
      conversion *t;
      int is_this;
      if (parmnode == void_list_node)
	break;
      is_this = (i == 0 && DECL_NONSTATIC_MEMBER_FUNCTION_P (fn)
		 && ! DECL_CONSTRUCTOR_P (fn));
      if (parmnode)
	{
	  tree parmtype = TREE_VALUE (parmnode);
	  if (ctype && is_this)
	    {
	      parmtype
		= build_qualified_type (ctype,
					TYPE_QUALS (TREE_TYPE (parmtype)));
	      parmtype = build_pointer_type (parmtype);
	    }
	  t = implicit_conversion (parmtype, argtype, arg,
				   false, flags);
	}
      else
	{
	  t = build_identity_conv (argtype, arg);
	  t->ellipsis_p = true;
	}
      if (t && is_this)
	t->this_p = true;
      convs[i] = t;
      if (! t)
	{
	  viable = 0;
	  break;
	}
      if (t->bad_p)
	viable = -1;
      if (parmnode)
	parmnode = TREE_CHAIN (parmnode);
      argnode = TREE_CHAIN (argnode);
    }
 out:
  return add_candidate (candidates, fn, orig_arglist, len, convs,
			access_path, conversion_path, viable);
}
static struct z_candidate * add_function_candidate ( struct z_candidate * * candidates , tree fn , tree ctype , tree arglist , tree access_path , tree conversion_path , int flags ) { tree parmlist = TYPE_ARG_TYPES ( TREE_TYPE ( fn ) ) ; int i , len ; conversion * * convs ; tree parmnode , argnode ; tree orig_arglist ; int viable = 1 ; gcc_assert ( ! DECL_ANTICIPATED ( fn ) || DECL_HIDDEN_FRIEND_P ( fn ) ) ; if ( DECL_CONSTRUCTOR_P ( fn ) ) { parmlist = skip_artificial_parms_for ( fn , parmlist ) ; orig_arglist = arglist ; arglist = skip_artificial_parms_for ( fn , arglist ) ; } else orig_arglist = arglist ; len = list_length ( arglist ) ; convs = alloc_conversions ( len ) ; parmnode = parmlist ; for ( i = 0 ; i < len ; ++ i ) { if ( parmnode == NULL_TREE || parmnode == void_list_node ) break ; parmnode = TREE_CHAIN ( parmnode ) ; } if ( i < len && parmnode ) viable = 0 ; else if ( ! sufficient_parms_p ( parmnode ) ) viable = 0 ; if ( ! viable ) goto out ; parmnode = parmlist ; argnode = arglist ; for ( i = 0 ; i < len ; ++ i ) { tree arg = TREE_VALUE ( argnode ) ; tree argtype = lvalue_type ( arg ) ; conversion * t ; int is_this ; if ( parmnode == void_list_node ) break ; is_this = ( i == 0 && DECL_NONSTATIC_MEMBER_FUNCTION_P ( fn ) && ! DECL_CONSTRUCTOR_P ( fn ) ) ; if ( parmnode ) { tree parmtype = TREE_VALUE ( parmnode ) ; if ( ctype && is_this ) { parmtype = build_qualified_type ( ctype , TYPE_QUALS ( TREE_TYPE ( parmtype ) ) ) ; parmtype = build_pointer_type ( parmtype ) ; } t = implicit_conversion ( parmtype , argtype , arg , false , flags ) ; } else { t = build_identity_conv ( argtype , arg ) ; t -> ellipsis_p = true ; } if ( t && is_this ) t -> this_p = true ; convs [ i ] = t ; if ( ! t ) { viable = 0 ; break ; } if ( t -> bad_p ) viable = -1 ; if ( parmnode ) parmnode = TREE_CHAIN ( parmnode ) ; argnode = TREE_CHAIN ( argnode ) ; } out : return add_candidate ( candidates , fn , orig_arglist , len , convs , access_path , conversion_path , viable ) ; }
Create an overload candidate for the function or method FN called with
the argument list ARGLIST and add it to CANDIDATES.
Create an overload candidate for the function or method FN called with the argument list ARGLIST and add it to CANDIDATES .
/* At this point we should not see any functions which haven't been
     explicitly declared, except for friend functions which will have
     been found using argument dependent lookup.  */ /* The `this', `in_chrg' and VTT arguments to constructors are not
     considered in overload resolution.  */ /* 13.3.2 - Viable functions [over.match.viable]
     First, to be a viable function, a candidate function shall have enough
     parameters to agree in number with the arguments in the list.

     We need to check this first; otherwise, checking the ICSes might cause
     us to produce an ill-formed template instantiation.  */ /* Make sure there are default args for the rest of the parms.  */ /* Second, for F to be a viable function, there shall exist for each
     argument an implicit conversion sequence that converts that argument
     to the corresponding parameter of F.  */ /* The type of the implicit object parameter ('this') for
	     overload resolution is not always the same as for the
	     function itself; conversion functions are considered to
	     be members of the class being converted, and functions
	     introduced by a using-declaration are considered to be
	     members of the class that uses them.

	     Since build_over_call ignores the ICS for the `this'
	     parameter, we can just change the parm type.  */ /*c_cast_p=*/