fold-const.c (fold): Before optimizing unsigned comparison with 0x7fffffffU...
authorJakub Jelinek <jakub@redhat.com>
Mon, 2 Apr 2001 08:08:22 +0000 (10:08 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 2 Apr 2001 08:08:22 +0000 (10:08 +0200)
* fold-const.c (fold): Before optimizing unsigned comparison with
0x7fffffffU, make sure arg0 is integral type.

* gcc.c-torture/execute/20010329-1.c: New test.

From-SVN: r41000

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/20010329-1.c [new file with mode: 0644]

index 424b4c73ea1fe6033c754e4f7011b9d6e8a8345c..81bd6e7f63bb74f2414e394b83d736f70875a47b 100644 (file)
@@ -1,3 +1,8 @@
+2001-04-02  Jakub Jelinek  <jakub@redhat.com>
+
+       * fold-const.c (fold): Before optimizing unsigned comparison with
+       0x7fffffffU, make sure arg0 is integral type.
+
 2001-04-02  Joseph S. Myers  <jsm28@cam.ac.uk>
 
        * c-tree.texi: Document representation of wide strings.
index ed988222d4b19b7cdd4e85e323874ccd05632257..a595b6e40660a32fa8b0b0e258a55111367eb11d 100644 (file)
@@ -6613,7 +6613,9 @@ fold (expr)
            else if (TREE_INT_CST_HIGH (arg1) == 0
                      && (TREE_INT_CST_LOW (arg1)
                          == ((unsigned HOST_WIDE_INT) 1 << (width - 1)) - 1)
-                     && TREE_UNSIGNED (TREE_TYPE (arg1)))
+                     && TREE_UNSIGNED (TREE_TYPE (arg1))
+                        /* signed_type does not work on pointer types.  */
+                     && INTEGRAL_TYPE_P (TREE_TYPE (arg1)))
 
              switch (TREE_CODE (t))
                {
index c6e1eb370ea5d2fe3d76d3b24464f62f67f72855..61ee72e23fbff54f48dd7fda4b025943289ab09a 100644 (file)
@@ -1,3 +1,7 @@
+2001-04-02  Jakub Jelinek  <jakub@redhat.com>
+
+       * gcc.c-torture/execute/20010329-1.c: New test.
+
 2001-03-28  Loren J. Rittle  <ljrittle@acm.org>
 
        * g++.old-deja/g++.other/eh4.C: Fix typo.
diff --git a/gcc/testsuite/gcc.c-torture/execute/20010329-1.c b/gcc/testsuite/gcc.c-torture/execute/20010329-1.c
new file mode 100644 (file)
index 0000000..e28d6d7
--- /dev/null
@@ -0,0 +1,14 @@
+#include <limits.h>
+
+int main (void)
+{
+  void *x = ((void *)((unsigned int)INT_MAX + 2));
+  void *y = ((void *)((unsigned long)LONG_MAX + 2));
+  if (x >= ((void *)((unsigned int)INT_MAX + 1))
+      && x <= ((void *)((unsigned int)INT_MAX + 6))
+      && y >= ((void *)((unsigned long)LONG_MAX + 1))
+      && y <= ((void *)((unsigned long)LONG_MAX + 6)))
+    exit (0);
+  else
+    abort ();
+}