aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/typeck.c11
-rw-r--r--gcc/fold-const.c10
4 files changed, 26 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5cd78f7..eab6238 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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.
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index cd6fafa..3c2e244 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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.
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index c265808..d72d8e6 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -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);
}
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index c8b0fd2..efd1055 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -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
{