FreeBSD/contrib/gcc/cp/cvt.c
/* Create an expression whose value is that of EXPR,
   converted to type TYPE.  The TREE_TYPE of the value
   is always TYPE.  This function implements all reasonable
   conversions; callers should filter out those that are
   not permitted by the language being compiled.

   Most of this routine is from build_reinterpret_cast.

   The backend cannot call cp_convert (what was convert) because
   conversions to/from basetypes may involve memory references
   (vbases) and adding or subtracting small values (multiple
   inheritance), but it calls convert from the constant folding code
   on subtrees of already built trees after it has ripped them apart.

   Also, if we ever support range variables, we'll probably also have to
   do a little bit more work.  */
Create an expression whose value is that of EXPR,
converted to type TYPE.  The TREE_TYPE of the value
is always TYPE.  This function implements all reasonable
conversions; callers should filter out those that are
not permitted by the language being compiled.

Most of this routine is from build_reinterpret_cast.

The backend cannot call cp_convert (what was convert) because
conversions to/from basetypes may involve memory references
(vbases) and adding or subtracting small values (multiple
inheritance), but it calls convert from the constant folding code
on subtrees of already built trees after it has ripped them apart.

Also, if we ever support range variables, we'll probably also have to
do a little bit more work.
Create an expression whose value is that of EXPR converted to type TYPE . The TREE_TYPE of the value is always TYPE . This function implements all reasonable conversions ; callers should filter out those that are not permitted by the language being compiled . Most of this routine is from build_reinterpret_cast . The backend cannot call cp_convert ( what was convert ) because conversions to / from basetypes may involve memory references ( vbases ) and adding or subtracting small values ( multiple inheritance ) but it calls convert from the constant folding code on subtrees of already built trees after it has ripped them apart . Also if we ever support range variables we ' ll probably also have to do a little bit more work .
tree
convert (tree type, tree expr)
{
  tree intype;
  if (type == error_mark_node || expr == error_mark_node)
    return error_mark_node;
  intype = TREE_TYPE (expr);
  if (POINTER_TYPE_P (type) && POINTER_TYPE_P (intype))
    return fold_if_not_in_template (build_nop (type, expr));
  return ocp_convert (type, expr, CONV_OLD_CONVERT,
		      LOOKUP_NORMAL|LOOKUP_NO_CONVERSION);
}
tree convert ( tree type , tree expr ) { tree intype ; if ( type == error_mark_node || expr == error_mark_node ) return error_mark_node ; intype = TREE_TYPE ( expr ) ; if ( POINTER_TYPE_P ( type ) && POINTER_TYPE_P ( intype ) ) return fold_if_not_in_template ( build_nop ( type , expr ) ) ; return ocp_convert ( type , expr , CONV_OLD_CONVERT , LOOKUP_NORMAL | LOOKUP_NO_CONVERSION ) ; }
Create an expression whose value is that of EXPR,
converted to type TYPE.
Create an expression whose value is that of EXPR converted to type TYPE .