From b1a3f709e00989391fb79c788ed68afd78183cff Mon Sep 17 00:00:00 2001 From: nathan Date: Mon, 22 Nov 1999 16:08:14 +0000 Subject: [PATCH] * semantics.c (finish_unary_op_expr): Only set TREE_NEGATED_INT when actually negative. * typeck.c (convert_for_assignment): Expand comment about strange NULL check, moved from ... (convert_for_initialization): ... here. Remove unneeded code. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@30616 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 10 ++++++++++ gcc/cp/semantics.c | 4 +++- gcc/cp/typeck.c | 20 ++++---------------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 298bab7..c2f9d74 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +1999-11-22 Nathan Sidwell + + * semantics.c (finish_unary_op_expr): Only set TREE_NEGATED_INT + when actually negative. + + * typeck.c (convert_for_assignment): Expand comment about + strange NULL check, moved from ... + (convert_for_initialization): ... here. Remove unneeded + code. + 1999-11-21 Alexandre Oliva * cp-tree.h (build_vec_delete): Remove `auto_delete' argument. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 0f201f6..741f710 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1598,7 +1598,9 @@ finish_unary_op_expr (code, expr) expression. So check whether the result is folded before setting TREE_NEGATED_INT. */ if (code == NEGATE_EXPR && TREE_CODE (expr) == INTEGER_CST - && TREE_CODE (result) == INTEGER_CST) + && TREE_CODE (result) == INTEGER_CST + && !TREE_UNSIGNED (TREE_TYPE (result)) + && INT_CST_LT (result, integer_zero_node)) TREE_NEGATED_INT (result) = 1; overflow_warning (result); return result; diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index dc6c9c9..ec2f606 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -6390,7 +6390,10 @@ convert_for_assignment (type, rhs, errtype, fndecl, parmnum) if (TREE_CODE (rhs) == TREE_LIST && TREE_VALUE (rhs) == error_mark_node) return error_mark_node; - /* Issue warnings about peculiar, but legal, uses of NULL. */ + /* 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"); @@ -6567,21 +6570,6 @@ convert_for_initialization (exp, type, rhs, flags, errtype, fndecl, parmnum) if (IS_AGGR_TYPE (type)) return ocp_convert (type, rhs, CONV_IMPLICIT|CONV_FORCE_TEMP, flags); - 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; - } - return convert_for_assignment (type, rhs, errtype, fndecl, parmnum); } -- 2.7.4