semantics.c (finish_unary_op_expr): Only set TREE_NEGATED_INT when actually negative.
authorNathan Sidwell <nathan@acm.org>
Mon, 22 Nov 1999 16:08:14 +0000 (16:08 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Mon, 22 Nov 1999 16:08:14 +0000 (16:08 +0000)
* 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.

From-SVN: r30616

gcc/cp/ChangeLog
gcc/cp/semantics.c
gcc/cp/typeck.c

index 298bab7..c2f9d74 100644 (file)
@@ -1,3 +1,13 @@
+1999-11-22  Nathan Sidwell  <nathan@acm.org>
+
+       * 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  <oliva@lsd.ic.unicamp.br>
 
        * cp-tree.h (build_vec_delete): Remove `auto_delete' argument.
index 0f201f6..741f710 100644 (file)
@@ -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;
index dc6c9c9..ec2f606 100644 (file)
@@ -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);
 }
 \f