From 9700b81f206df1f8c6ae76cccf91f7d69b513342 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Mon, 24 Aug 1998 11:12:27 +0000 Subject: 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 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/typeck.c | 12 ++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'gcc') 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 + + * typeck.c (convert_for_initialization): Move check for odd uses + of NULL to avoid duplicate warnings. + 1998-08-24 Jason Merrill * 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; } -- cgit v1.1