Commit 9700b81f by Mark Mitchell Committed by Mark Mitchell

typeck.c (convert_for_initialization): Move check for odd uses of NULL to avoid duplicate warnings.

	* typeck.c (convert_for_initialization): Move check for odd uses
	of NULL to avoid duplicate warnings.

From-SVN: r21938
parent 1eb79505
1998-08-24 Mark Mitchell <mark@markmitchell.com>
* typeck.c (convert_for_initialization): Move check for odd uses
of NULL to avoid duplicate warnings.
1998-08-24 Jason Merrill <jason@yorick.cygnus.com>
* tree.c (lvalue_type): Fix for arrays.
......
......@@ -7085,10 +7085,6 @@ convert_for_initialization (exp, type, rhs, flags, errtype, fndecl, parmnum)
register tree rhstype;
register enum tree_code coder;
/* Issue warnings about peculiar, but legal, uses of NULL. */
if (ARITHMETIC_TYPE_P (type) && rhs == null_node)
cp_warning ("converting NULL to non-pointer type");
/* build_c_cast puts on a NOP_EXPR to make the result not an lvalue.
Strip such NOP_EXPRs, since RHS is used in non-lvalue context. */
if (TREE_CODE (rhs) == NOP_EXPR
......@@ -7176,8 +7172,16 @@ convert_for_initialization (exp, type, rhs, flags, errtype, fndecl, parmnum)
if (type == TREE_TYPE (rhs))
{
/* Issue warnings about peculiar, but legal, uses of NULL. We
do this *before* the call to decl_constant_value so as to
avoid duplicate warnings on code like `const int I = NULL;
f(I);'. */
if (ARITHMETIC_TYPE_P (type) && rhs == null_node)
cp_warning ("converting NULL to non-pointer type");
if (TREE_READONLY_DECL_P (rhs))
rhs = decl_constant_value (rhs);
return rhs;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment