fold-const.c (force_fit_type): Unsigned values can overflow if they are sizetype.
authorRichard Kenner <kenner@vlsi1.ultra.nyu.edu>
Fri, 20 Oct 2000 17:51:52 +0000 (17:51 +0000)
committerRichard Kenner <kenner@gcc.gnu.org>
Fri, 20 Oct 2000 17:51:52 +0000 (13:51 -0400)
* fold-const.c (force_fit_type): Unsigned values can overflow
if they are sizetype.
(int_const_binop): Don't use cache if overflows.
* cp/typeck.c (dubious_conversion_warning): Suppress if
TYPE_IS_SIZETYPE.

From-SVN: r36970

gcc/ChangeLog
gcc/cp/ChangeLog
gcc/cp/typeck.c
gcc/fold-const.c

index 5cd78f7f45fc81add5056b2d7b7a8cb0b8af36fa..eab623841c26dde2c6a5c504b61d6c8ab829ae68 100644 (file)
@@ -1,3 +1,8 @@
+Fri Oct 20 13:33:16 2000  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
+
+       * fold-const.c (force_fit_type): Unsigned values can overflow
+       if they are sizetype.
+       (int_const_binop): Don't use cache if overflows.
 2000-10-20  Richard Henderson  <rth@cygnus.com>
 
        * function.c (locate_and_pad_parm): Zero alignment_pad.
index cd6fafa7cc18797ff08999c0a7b3077e821a376d..3c2e244fb903d4d3556fa1572a8074e69020b432 100644 (file)
@@ -1,3 +1,7 @@
+Fri Oct 20 13:54:59 2000  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
+
+       * typeck.c (dubious_conversion_warning): Suppress if TYPE_IS_SIZETYPE.
+
 2000-10-20  Jeffrey Oldham  <oldham@codesourcery.com>
 
        * decl.c (revert_static_member_fn): Fixed typo.
index c26580836c8064c8586be15c4ce0aaa9c5aa370f..d72d8e6c00df65ce0eb7844c6978beb4da683455 100644 (file)
@@ -6353,7 +6353,16 @@ dubious_conversion_warnings (type, expr, errtype, fndecl, parmnum)
            cp_warning ("%s of negative value `%E' to `%T'",
                        errtype, expr, type);
        }
-      overflow_warning (expr);
+
+      /* Suppress warning for a sizetype since we never used to issue it.
+        ??? This needs to be looked at more carefully someday.  */
+      if (TREE_CODE (expr) == INTEGER_CST
+         && TREE_CODE (TREE_TYPE (expr)) == INTEGER_TYPE
+         && TYPE_IS_SIZETYPE (TREE_TYPE (expr)))
+       TREE_OVERFLOW (expr) = TREE_CONSTANT_OVERFLOW (expr) = 0;
+      else
+       overflow_warning (expr);
+
       if (TREE_CONSTANT (expr))
        expr = fold (expr);
     }
index c8b0fd2486dbe80e45127e742c54b4dbcc02bee1..efd1055b9e21b24f6be7c68d95e8d9fca72cd1ed 100644 (file)
@@ -216,8 +216,11 @@ force_fit_type (t, overflow)
        TREE_INT_CST_LOW (t) &= ~((unsigned HOST_WIDE_INT) (-1) << prec);
     }
 
-  /* Unsigned types do not suffer sign extension or overflow.  */
-  if (TREE_UNSIGNED (TREE_TYPE (t)))
+  /* Unsigned types do not suffer sign extension or overflow unless they
+     are a sizetype.  */
+  if (TREE_UNSIGNED (TREE_TYPE (t))
+      && ! (TREE_CODE (TREE_TYPE (t)) == INTEGER_TYPE
+           && TYPE_IS_SIZETYPE (TREE_TYPE (t))))
     return overflow;
 
   /* If the value's sign bit is set, extend the sign.  */
@@ -1604,7 +1607,8 @@ int_const_binop (code, arg1, arg2, notrunc, forsize)
       abort ();
     }
 
-  if (forsize && hi == 0 && low < 10000)
+  if (forsize && hi == 0 && low < 10000
+      && overflow == 0 && ! TREE_OVERFLOW (arg1) && ! TREE_OVERFLOW (arg2))
     return size_int_type_wide (low, TREE_TYPE (arg1));
   else
     {