FreeBSD/contrib/gcc/cp/typeck.c
/* Convert value RHS to type TYPE as preparation for an assignment to
   an lvalue of type TYPE.  ERRTYPE is a string to use in error
   messages: "assignment", "return", etc.  If FNDECL is non-NULL, we
   are doing the conversion in order to pass the PARMNUMth argument of
   FNDECL.  */
Convert value RHS to type TYPE as preparation for an assignment to
an lvalue of type TYPE.  ERRTYPE is a string to use in error
messages: "assignment", "return", etc.  If FNDECL is non-NULL, we
are doing the conversion in order to pass the PARMNUMth argument of
FNDECL.
Convert value RHS to type TYPE as preparation for an assignment to an lvalue of type TYPE . ERRTYPE is a string to use in error messages : " assignment " " return " etc . If FNDECL is non - NULL we are doing the conversion in order to pass the PARMNUMth argument of FNDECL .
static tree
convert_for_assignment (tree type, tree rhs,
			const char *errtype, tree fndecl, int parmnum)
{
  tree rhstype;
  enum tree_code coder;
  tree new_rhs = NULL_TREE;
  if (TREE_CODE (rhs) == NON_LVALUE_EXPR)
    rhs = TREE_OPERAND (rhs, 0);
  rhstype = TREE_TYPE (rhs);
  coder = TREE_CODE (rhstype);
  if (TREE_CODE (type) == VECTOR_TYPE && coder == VECTOR_TYPE
      && vector_types_convertible_p (type, rhstype, true))
    return convert (type, rhs);
  if (rhs == error_mark_node || rhstype == error_mark_node)
    return error_mark_node;
  if (TREE_CODE (rhs) == TREE_LIST && TREE_VALUE (rhs) == error_mark_node)
    return error_mark_node;
  if (coder == VOID_TYPE)
    {
      error ("void value not ignored as it ought to be");
      return error_mark_node;
    }
  if (TREE_CODE (rhs) == CONST_DECL)
    rhs = DECL_INITIAL (rhs);
  if (c_dialect_objc ())
    {
      int parmno;
      tree rname = fndecl;
      if (!strcmp (errtype, "assignment"))
	parmno = -1;
      else if (!strcmp (errtype, "initialization"))
	parmno = -2;
      else
	{
	  tree selector = objc_message_selector ();
	  parmno = parmnum;
	  if (selector && parmno > 1)
	    {
	      rname = selector;
	      parmno -= 1;
	    }
	}
      if (objc_compare_types (type, rhstype, parmno, rname, "comparison"))
	new_rhs = convert (type, rhs);
    }
  if (!can_convert_arg_bad (type, rhstype, rhs))
    {
      if (!warn_pmf2ptr
	  && TYPE_PTR_P (type)
	  && TYPE_PTRMEMFUNC_P (rhstype))
	rhs = cp_convert (strip_top_quals (type), rhs);
      else
	{
	  if (rhstype == unknown_type_node)
	    instantiate_type (type, rhs, tf_warning_or_error);
	  else if (fndecl)
	    error ("cannot convert %qT to %qT for argument %qP to %qD",
		   rhstype, type, parmnum, fndecl);
	  else
	    error ("cannot convert %qT to %qT in %s", rhstype, type, errtype);
	  return error_mark_node;
	}
    }
  if (warn_missing_format_attribute)
    {
      const enum tree_code codel = TREE_CODE (type);
      if ((codel == POINTER_TYPE || codel == REFERENCE_TYPE)
	  && coder == codel
	  && check_missing_format_attribute (type, rhstype))
	warning (OPT_Wmissing_format_attribute,
		 "%s might be a candidate for a format attribute",
		 errtype);
    }
  if (warn_parentheses
      && type == boolean_type_node
      && TREE_CODE (rhs) == MODIFY_EXPR
      && !TREE_NO_WARNING (rhs)
      && TREE_TYPE (rhs) != boolean_type_node)
    {
      warning (OPT_Wparentheses,
	       "suggest parentheses around assignment used as truth value");
      TREE_NO_WARNING (rhs) = 1;
    }
  return perform_implicit_conversion (strip_top_quals (type), rhs);
}
static tree convert_for_assignment ( tree type , tree rhs , const char * errtype , tree fndecl , int parmnum ) { tree rhstype ; enum tree_code coder ; tree new_rhs = NULL_TREE ; if ( TREE_CODE ( rhs ) == NON_LVALUE_EXPR ) rhs = TREE_OPERAND ( rhs , 0 ) ; rhstype = TREE_TYPE ( rhs ) ; coder = TREE_CODE ( rhstype ) ; if ( TREE_CODE ( type ) == VECTOR_TYPE && coder == VECTOR_TYPE && vector_types_convertible_p ( type , rhstype , true ) ) return convert ( type , rhs ) ; if ( rhs == error_mark_node || rhstype == error_mark_node ) return error_mark_node ; if ( TREE_CODE ( rhs ) == TREE_LIST && TREE_VALUE ( rhs ) == error_mark_node ) return error_mark_node ; if ( coder == VOID_TYPE ) { error ( " " ) ; return error_mark_node ; } if ( TREE_CODE ( rhs ) == CONST_DECL ) rhs = DECL_INITIAL ( rhs ) ; if ( c_dialect_objc ( ) ) { int parmno ; tree rname = fndecl ; if ( ! strcmp ( errtype , " " ) ) parmno = -1 ; else if ( ! strcmp ( errtype , " " ) ) parmno = -2 ; else { tree selector = objc_message_selector ( ) ; parmno = parmnum ; if ( selector && parmno > 1 ) { rname = selector ; parmno -= 1 ; } } if ( objc_compare_types ( type , rhstype , parmno , rname , " " ) ) new_rhs = convert ( type , rhs ) ; } if ( ! can_convert_arg_bad ( type , rhstype , rhs ) ) { if ( ! warn_pmf2ptr && TYPE_PTR_P ( type ) && TYPE_PTRMEMFUNC_P ( rhstype ) ) rhs = cp_convert ( strip_top_quals ( type ) , rhs ) ; else { if ( rhstype == unknown_type_node ) instantiate_type ( type , rhs , tf_warning_or_error ) ; else if ( fndecl ) error ( " " , rhstype , type , parmnum , fndecl ) ; else error ( " " , rhstype , type , errtype ) ; return error_mark_node ; } } if ( warn_missing_format_attribute ) { const enum tree_code codel = TREE_CODE ( type ) ; if ( ( codel == POINTER_TYPE || codel == REFERENCE_TYPE ) && coder == codel && check_missing_format_attribute ( type , rhstype ) ) warning ( OPT_Wmissing_format_attribute , " " , errtype ) ; } if ( warn_parentheses && type == boolean_type_node && TREE_CODE ( rhs ) == MODIFY_EXPR && ! TREE_NO_WARNING ( rhs ) && TREE_TYPE ( rhs ) != boolean_type_node ) { warning ( OPT_Wparentheses , " " ) ; TREE_NO_WARNING ( rhs ) = 1 ; } return perform_implicit_conversion ( strip_top_quals ( type ) , rhs ) ; }
Convert value RHS to type TYPE as preparation for an assignment to
an lvalue of type TYPE.
Convert value RHS to type TYPE as preparation for an assignment to an lvalue of type TYPE .
/* APPLE LOCAL radar 4874632 */ /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue.  */ /* The RHS of an assignment cannot have void type.  */ /* Simplify the RHS if possible.  */ /* APPLE LOCAL file radar 6231433 */ /* APPLE LOCAL radar 4874632 */ /* [expr.ass]

     The expression is implicitly converted (clause _conv_) to the
     cv-unqualified type of the left operand.

     We allow bad conversions here because by the time we get to this point
     we are committed to doing the conversion.  If we end up doing a bad
     conversion, convert_like will complain.  */ /* When -Wno-pmf-conversions is use, we just silently allow
	 conversions from pointers-to-members to plain pointers.  If
	 the conversion doesn't work, cp_convert will complain.  */ /* If the right-hand side has unknown type, then it is an
	     overloaded function.  Call instantiate_type to get error
	     messages.  */ /* If -Wparentheses, warn about a = b = c when a has type bool and b
     does not.  */