FreeBSD/contrib/gcc/cp/typeck.c
/* Convert the actual parameter expressions in the list VALUES
   to the types in the list TYPELIST.
   If parmdecls is exhausted, or when an element has NULL as its type,
   perform the default conversions.

   NAME is an IDENTIFIER_NODE or 0.  It is used only for error messages.

   This is also where warnings about wrong number of args are generated.

   Return a list of expressions for the parameters as converted.

   Both VALUES and the returned value are chains of TREE_LIST nodes
   with the elements of the list in the TREE_VALUE slots of those nodes.

   In C++, unspecified trailing parameters can be filled in with their
   default arguments, if such were specified.  Do so here.  */
Convert the actual parameter expressions in the list VALUES
to the types in the list TYPELIST.
If parmdecls is exhausted, or when an element has NULL as its type,
perform the default conversions.

NAME is an IDENTIFIER_NODE or 0.  It is used only for error messages.

This is also where warnings about wrong number of args are generated.

Return a list of expressions for the parameters as converted.

Both VALUES and the returned value are chains of TREE_LIST nodes
with the elements of the list in the TREE_VALUE slots of those nodes.

In C++, unspecified trailing parameters can be filled in with their
default arguments, if such were specified.  Do so here.
Convert the actual parameter expressions in the list VALUES to the types in the list TYPELIST . If parmdecls is exhausted or when an element has NULL as its type perform the default conversions . NAME is an IDENTIFIER_NODE or 0 . It is used only for error messages . This is also where warnings about wrong number of args are generated . Return a list of expressions for the parameters as converted . Both VALUES and the returned value are chains of TREE_LIST nodes with the elements of the list in the TREE_VALUE slots of those nodes . In C ++ unspecified trailing parameters can be filled in with their default arguments if such were specified . Do so here .
static tree
convert_arguments (tree typelist, tree values, tree fndecl, int flags, int block_call)
{
  tree typetail, valtail;
  tree result = NULL_TREE;
  const char *called_thing = 0;
  int i = 0;
  flags |= LOOKUP_ONLYCONVERTING;
  if (fndecl)
    {
      if (TREE_CODE (TREE_TYPE (fndecl)) == METHOD_TYPE)
	{
	  if (DECL_NAME (fndecl) == NULL_TREE
	      || IDENTIFIER_HAS_TYPE_VALUE (DECL_NAME (fndecl)))
	    called_thing = "constructor";
	  else
	    called_thing = "member function";
	}
      else
	called_thing = "function";
    }
  for (valtail = values, typetail = typelist;
       valtail;
       valtail = TREE_CHAIN (valtail), i++)
    {
      tree type = typetail ? TREE_VALUE (typetail) : 0;
      tree val = TREE_VALUE (valtail);
      if (val == error_mark_node || type == error_mark_node)
	return error_mark_node;
      if (type == void_type_node)
	{
	  if (fndecl)
	    {
	      error ("too many arguments to %s %q+#D", called_thing, fndecl);
	      error ("at this point in file");
	    }
	  else
	    error ("too many arguments to %s", (block_call ? "block call" : "function"));
	  if (result)
	    TREE_TYPE (tree_last (result)) = error_mark_node;
	  break;
	}
      if (TREE_CODE (val) == NOP_EXPR
	  && TREE_TYPE (val) == TREE_TYPE (TREE_OPERAND (val, 0))
	  && (type == 0 || TREE_CODE (type) != REFERENCE_TYPE))
	val = TREE_OPERAND (val, 0);
      if (type == 0 || TREE_CODE (type) != REFERENCE_TYPE)
	{
	  if (TREE_CODE (TREE_TYPE (val)) == ARRAY_TYPE
	      || TREE_CODE (TREE_TYPE (val)) == FUNCTION_TYPE
	      || TREE_CODE (TREE_TYPE (val)) == METHOD_TYPE)
	    val = decay_conversion (val);
	}
      if (val == error_mark_node)
	return error_mark_node;
      if (type != 0)
	{
	  tree parmval;
	  if (!COMPLETE_TYPE_P (complete_type (type)))
	    {
	      if (fndecl)
		error ("parameter %P of %qD has incomplete type %qT",
		       i, fndecl, type);
	      else
		error ("parameter %P has incomplete type %qT", i, type);
	      parmval = error_mark_node;
	    }
	  else
	    {
	      parmval = convert_for_initialization
		(NULL_TREE, type, val, flags,
		 "argument passing", fndecl, i);
	      parmval = convert_for_arg_passing (type, parmval);
	    }
	  if (parmval == error_mark_node)
	    return error_mark_node;
	  result = tree_cons (NULL_TREE, parmval, result);
	}
      else
	{
	  if (fndecl && DECL_BUILT_IN (fndecl)
	      && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_CONSTANT_P)
	    val = require_complete_type (val);
	  else
	    val = convert_arg_to_ellipsis (val);
	  result = tree_cons (NULL_TREE, val, result);
	}
      if (typetail)
	typetail = TREE_CHAIN (typetail);
    }
  if (typetail != 0 && typetail != void_list_node)
    {
      if (TREE_PURPOSE (typetail)
	  && TREE_CODE (TREE_PURPOSE (typetail)) != DEFAULT_ARG)
	{
	  for (; typetail != void_list_node; ++i)
	    {
	      tree parmval
		= convert_default_arg (TREE_VALUE (typetail),
				       TREE_PURPOSE (typetail),
				       fndecl, i);
	      if (parmval == error_mark_node)
		return error_mark_node;
	      result = tree_cons (0, parmval, result);
	      typetail = TREE_CHAIN (typetail);
	      if (typetail == NULL_TREE)
		break;
	    }
	}
      else
	{
	  if (fndecl)
	    {
	      error ("too few arguments to %s %q+#D", called_thing, fndecl);
	      error ("at this point in file");
	    }
	  else
	    error ("too few arguments to %s", (block_call ? "block call" : "function"));
	  return error_mark_node;
	}
    }
  return nreverse (result);
}
static tree convert_arguments ( tree typelist , tree values , tree fndecl , int flags , int block_call ) { tree typetail , valtail ; tree result = NULL_TREE ; const char * called_thing = 0 ; int i = 0 ; flags |= LOOKUP_ONLYCONVERTING ; if ( fndecl ) { if ( TREE_CODE ( TREE_TYPE ( fndecl ) ) == METHOD_TYPE ) { if ( DECL_NAME ( fndecl ) == NULL_TREE || IDENTIFIER_HAS_TYPE_VALUE ( DECL_NAME ( fndecl ) ) ) called_thing = " " ; else called_thing = " " ; } else called_thing = " " ; } for ( valtail = values , typetail = typelist ; valtail ; valtail = TREE_CHAIN ( valtail ) , i ++ ) { tree type = typetail ? TREE_VALUE ( typetail ) : 0 ; tree val = TREE_VALUE ( valtail ) ; if ( val == error_mark_node || type == error_mark_node ) return error_mark_node ; if ( type == void_type_node ) { if ( fndecl ) { error ( " " , called_thing , fndecl ) ; error ( " " ) ; } else error ( " " , ( block_call ? " " : " " ) ) ; if ( result ) TREE_TYPE ( tree_last ( result ) ) = error_mark_node ; break ; } if ( TREE_CODE ( val ) == NOP_EXPR && TREE_TYPE ( val ) == TREE_TYPE ( TREE_OPERAND ( val , 0 ) ) && ( type == 0 || TREE_CODE ( type ) != REFERENCE_TYPE ) ) val = TREE_OPERAND ( val , 0 ) ; if ( type == 0 || TREE_CODE ( type ) != REFERENCE_TYPE ) { if ( TREE_CODE ( TREE_TYPE ( val ) ) == ARRAY_TYPE || TREE_CODE ( TREE_TYPE ( val ) ) == FUNCTION_TYPE || TREE_CODE ( TREE_TYPE ( val ) ) == METHOD_TYPE ) val = decay_conversion ( val ) ; } if ( val == error_mark_node ) return error_mark_node ; if ( type != 0 ) { tree parmval ; if ( ! COMPLETE_TYPE_P ( complete_type ( type ) ) ) { if ( fndecl ) error ( " " , i , fndecl , type ) ; else error ( " " , i , type ) ; parmval = error_mark_node ; } else { parmval = convert_for_initialization ( NULL_TREE , type , val , flags , " " , fndecl , i ) ; parmval = convert_for_arg_passing ( type , parmval ) ; } if ( parmval == error_mark_node ) return error_mark_node ; result = tree_cons ( NULL_TREE , parmval , result ) ; } else { if ( fndecl && DECL_BUILT_IN ( fndecl ) && DECL_FUNCTION_CODE ( fndecl ) == BUILT_IN_CONSTANT_P ) val = require_complete_type ( val ) ; else val = convert_arg_to_ellipsis ( val ) ; result = tree_cons ( NULL_TREE , val , result ) ; } if ( typetail ) typetail = TREE_CHAIN ( typetail ) ; } if ( typetail != 0 && typetail != void_list_node ) { if ( TREE_PURPOSE ( typetail ) && TREE_CODE ( TREE_PURPOSE ( typetail ) ) != DEFAULT_ARG ) { for ( ; typetail != void_list_node ; ++ i ) { tree parmval = convert_default_arg ( TREE_VALUE ( typetail ) , TREE_PURPOSE ( typetail ) , fndecl , i ) ; if ( parmval == error_mark_node ) return error_mark_node ; result = tree_cons ( 0 , parmval , result ) ; typetail = TREE_CHAIN ( typetail ) ; if ( typetail == NULL_TREE ) break ; } } else { if ( fndecl ) { error ( " " , called_thing , fndecl ) ; error ( " " ) ; } else error ( " " , ( block_call ? " " : " " ) ) ; return error_mark_node ; } } return nreverse ( result ) ; }
Convert the actual parameter expressions in the list VALUES
to the types in the list TYPELIST.
Convert the actual parameter expressions in the list VALUES to the types in the list TYPELIST .
/* APPLE LOCAL radar 6087117 */ /* Argument passing is always copy-initialization.  */ /* APPLE LOCAL radar 6087117 */ /* In case anybody wants to know if this argument
	     list is valid.  */ /* build_c_cast puts on a NOP_EXPR to make the result not an lvalue.
	 Strip such NOP_EXPRs, since VAL is used in non-lvalue context.  */ /* Formal parm type is specified by a function prototype.  */ /* Don't do ellipsis conversion for __built_in_constant_p
	       as this will result in spurious warnings for non-POD
	       types.  */ /* See if there are default arguments that can be used.  */ /* ends with `...'.  */ /* APPLE LOCAL radar 6087117 */