This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Add warning about false being implicitly converted to NULL in parameter passing
- From: Gabriel Dos Reis <gdr at cs dot tamu dot edu>
- To: Dirk Mueller <dmueller at suse dot de>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: 12 Mar 2007 09:47:39 -0500
- Subject: Re: [PATCH] Add warning about false being implicitly converted to NULL in parameter passing
- References: <200703121341.36802.dmueller@suse.de>
Dirk Mueller <dmueller@suse.de> writes:
| Hi,
|
| Patch below was bootstrapped and regtested on i686-suse-linux.
|
|
| 2007-03-11 Dirk Mueller <dmueller@suse.de>
|
| PR c++/30860
| * call.c (convert_like_real): Add conversion warning
| about false being converted to NULL in argument passing.
This area is growing in warning issuance, and that function starts
competing with other monsters. Please factor the
junk inside the if (issue_conversion_warnings)
if (issue_conversion_warnings)
{
tree t = non_reference (totype);
/* Issue warnings about peculiar, but valid, uses of NULL. */
if (expr == null_node && TREE_CODE (t) != BOOLEAN_TYPE && ARITHMETIC_TYPE\
_P (t))
{
if (fn)
warning (OPT_Wconversion, "passing NULL to non-pointer argument %P \
of %qD",
argnum, fn);
else
warning (OPT_Wconversion, "converting to non-pointer type %qT from \
NULL", t);
}
/* Warn about assigning a floating-point type to an integer type. */
if (TREE_CODE (TREE_TYPE (expr)) == REAL_TYPE
&& TREE_CODE (t) == INTEGER_TYPE)
{
if (fn)
warning (OPT_Wconversion, "passing %qT for argument %P to %qD",
TREE_TYPE (expr), argnum, fn);
else
warning (OPT_Wconversion, "converting to %qT from %qT", t, TREE_TYP\
E (expr));
}
}
where you add your new warning, into a separate function.
Patch approved with that change.
Thanks,
-- Gaby