FreeBSD/contrib/gcc/cp/decl.c
/* Check that ARG, which is a default-argument expression for a
   parameter DECL, is valid.  Returns ARG, or ERROR_MARK_NODE, if
   something goes wrong.  DECL may also be a _TYPE node, rather than a
   DECL, if there is no DECL available.  */
Check that ARG, which is a default-argument expression for a
parameter DECL, is valid.  Returns ARG, or ERROR_MARK_NODE, if
something goes wrong.  DECL may also be a _TYPE node, rather than a
DECL, if there is no DECL available.
Check that ARG which is a default - argument expression for a parameter DECL is valid . Returns ARG or ERROR_MARK_NODE if something goes wrong . DECL may also be a _TYPE node rather than a DECL if there is no DECL available .
tree
check_default_argument (tree decl, tree arg)
{
  tree var;
  tree decl_type;
  if (TREE_CODE (arg) == DEFAULT_ARG)
    return arg;
  if (TYPE_P (decl))
    {
      decl_type = decl;
      decl = NULL_TREE;
    }
  else
    decl_type = TREE_TYPE (decl);
  if (arg == error_mark_node
      || decl == error_mark_node
      || TREE_TYPE (arg) == error_mark_node
      || decl_type == error_mark_node)
    return error_mark_node;
  if (!TREE_TYPE (arg)
      || !can_convert_arg (decl_type, TREE_TYPE (arg), arg, LOOKUP_NORMAL))
    {
      if (decl)
	error ("default argument for %q#D has type %qT",
	       decl, TREE_TYPE (arg));
      else
	error ("default argument for parameter of type %qT has type %qT",
	       decl_type, TREE_TYPE (arg));
      return error_mark_node;
    }
  var = walk_tree_without_duplicates (&arg, local_variable_p_walkfn,
				      NULL);
  if (var)
    {
      error ("default argument %qE uses local variable %qD", arg, var);
      return error_mark_node;
    }
  return arg;
}
tree check_default_argument ( tree decl , tree arg ) { tree var ; tree decl_type ; if ( TREE_CODE ( arg ) == DEFAULT_ARG ) return arg ; if ( TYPE_P ( decl ) ) { decl_type = decl ; decl = NULL_TREE ; } else decl_type = TREE_TYPE ( decl ) ; if ( arg == error_mark_node || decl == error_mark_node || TREE_TYPE ( arg ) == error_mark_node || decl_type == error_mark_node ) return error_mark_node ; if ( ! TREE_TYPE ( arg ) || ! can_convert_arg ( decl_type , TREE_TYPE ( arg ) , arg , LOOKUP_NORMAL ) ) { if ( decl ) error ( " " , decl , TREE_TYPE ( arg ) ) ; else error ( " " , decl_type , TREE_TYPE ( arg ) ) ; return error_mark_node ; } var = walk_tree_without_duplicates ( & arg , local_variable_p_walkfn , NULL ) ; if ( var ) { error ( " " , arg , var ) ; return error_mark_node ; } return arg ; }
Check that ARG, which is a default-argument expression for a
parameter DECL, is valid.
Check that ARG which is a default - argument expression for a parameter DECL is valid .
/* We get a DEFAULT_ARG when looking at an in-class declaration
       with a default argument.  Ignore the argument for now; we'll
       deal with it after the class is complete.  */ /* Something already went wrong.  There's no need to check
       further.  */ /* [dcl.fct.default]

     A default argument expression is implicitly converted to the
     parameter type.  */ /* [dcl.fct.default]

     Local variables shall not be used in default argument
     expressions.

     The keyword `this' shall not be used in a default argument of a
     member function.  */ /* All is well.  */