This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PING^3] Wconversion: fixes for C++ front-end
On 06/02/07, Gabriel Dos Reis <gdr@cs.tamu.edu> wrote:
On Tue, 6 Feb 2007, Manuel López-Ibáñez wrote:
| I am sure I already did this a long time ago, but to be sure, I did it
| again, and some tests fail if we use the return value of
| convert_and_check directly rather than calling cp_convert.
that should be expected. what is needed is the relationship of
convert_and_check and cp_convert.
/* C++ conversions, preference to static cast conversions. */
tree
cp_convert (tree type, tree expr)
{
return ocp_convert (type, expr, CONV_OLD_CONVERT, LOOKUP_NORMAL);
}
while:
/* 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);
}
So the basic differences are the call to fold_if_not_in_template and
the use of LOOKUP_NO_CONVERSION when calling ocp_convert. I honestly
cannot see how to relate cp_convert and convert. Do you have any
ideas?
Cheers,
Manuel.