------- Comment #22 from manu at gcc dot gnu dot org 2010-02-16 18:05 ------- Testing this:
Index: gcc/doc/invoke.texi =================================================================== --- gcc/doc/invoke.texi (revision 156812) +++ gcc/doc/invoke.texi (working copy) @@ -3835,18 +3835,23 @@ like @code{unsigned ui = -1}; and conver ((int) x)} and @code{ui = (unsigned) -1}, or if the value is not changed by the conversion like in @code{abs (2.0)}. Warnings about conversions between signed and unsigned integers can be disabled by using @option{-Wno-sign-conversion}. -For C++, also warn for conversions between @code{NULL} and non-pointer -types; confusing overload resolution for user-defined conversions; and -conversions that will never use a type conversion operator: -conversions to @code{void}, the same type, a base class or a reference -to them. Warnings about conversions between signed and unsigned -integers are disabled by default in C++ unless +For C++, also warn for confusing overload resolution for user-defined +conversions; and conversions that will never use a type conversion +operator: conversions to @code{void}, the same type, a base class or a +reference to them. Warnings about conversions between signed and +unsigned integers are disabled by default in C++ unless @option{-Wsign-conversion} is explicitly enabled. +...@item -Wno-conversion-nul +...@opindex Wconversion-nul +...@opindex Wno-conversion-nul +Do not warn for conversions between @code{NULL} and non-pointer +types. @option{-Wconversion-nul} is enabled by default. + @item -Wempty-body @opindex Wempty-body @opindex Wno-empty-body Warn if an empty body occurs in an @samp{if}, @samp{else} or @samp{do while} statement. This warning is also enabled by @option{-Wextra}. Index: gcc/cp/call.c =================================================================== --- gcc/cp/call.c (revision 156812) +++ gcc/cp/call.c (working copy) @@ -4802,19 +4802,19 @@ conversion_null_warnings (tree totype, t /* 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", + warning (OPT_Wconversion_nul, "passing NULL to non-pointer argument %P of %qD", argnum, fn); else - warning (OPT_Wconversion, "converting to non-pointer type %qT from NULL", t); + warning (OPT_Wconversion_nul, "converting to non-pointer type %qT from NULL", t); } /* Issue warnings if "false" is converted to a NULL pointer */ else if (expr == boolean_false_node && fn && POINTER_TYPE_P (t)) - warning (OPT_Wconversion, + warning (OPT_Wconversion_nul, "converting %<false%> to pointer type for argument %P of %qD", argnum, fn); } /* Perform the conversions in CONVS on the expression EXPR. FN and Index: gcc/cp/cvt.c =================================================================== --- gcc/cp/cvt.c (revision 156812) +++ gcc/cp/cvt.c (working copy) @@ -1139,11 +1139,11 @@ build_expr_type_conversion (int desires, tree winner = NULL_TREE; if (expr == null_node && (desires & WANT_INT) && !(desires & WANT_NULL)) - warning (OPT_Wconversion, "converting NULL to non-pointer type"); + warning (OPT_Wconversion_nul, "converting NULL to non-pointer type"); basetype = TREE_TYPE (expr); if (basetype == error_mark_node) return error_mark_node; Index: gcc/c.opt =================================================================== --- gcc/c.opt (revision 156812) +++ gcc/c.opt (working copy) @@ -169,10 +169,14 @@ Synonym for -Wcomment Wconversion C ObjC C++ ObjC++ Var(warn_conversion) Warning Warn for implicit type conversions that may change a value +Wconversion-nul +C++ ObjC++ Var(warn_conversion_nul) Init(1) Warning +Warn for converting NULL from/to a non-pointer type + Wsign-conversion C ObjC C++ ObjC++ Var(warn_sign_conversion) Init(-1) Warn for implicit type conversions between signed and unsigned integers Wctor-dtor-privacy -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35669