aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Mitchell <mark@markmitchell.com>1998-08-24 11:12:27 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>1998-08-24 11:12:27 +0000
commit9700b81f206df1f8c6ae76cccf91f7d69b513342 (patch)
tree79416321bcb2ac1fb0b6a6edbcab49ad79e6219c
parent1eb79505a9e355513012405179ce495076d086fd (diff)
downloadgcc-9700b81f206df1f8c6ae76cccf91f7d69b513342.zip
gcc-9700b81f206df1f8c6ae76cccf91f7d69b513342.tar.gz
gcc-9700b81f206df1f8c6ae76cccf91f7d69b513342.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/typeck.c12
2 files changed, 13 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 19db217..57dc30e 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+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.
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 61ebe18..3bbd6bd 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -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;
}