diff options
author | Jakub Jelinek <jakub@redhat.com> | 2001-04-02 10:08:22 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2001-04-02 10:08:22 +0200 |
commit | d791ea1e0a2341a8fb2ca8b593063af8e471fcac (patch) | |
tree | 6f9d0c57a696399a9f82b1e41a0aad581a8490a3 | |
parent | c6955d85188d84404ae1fdfe594e59166d90b755 (diff) | |
download | gcc-d791ea1e0a2341a8fb2ca8b593063af8e471fcac.zip gcc-d791ea1e0a2341a8fb2ca8b593063af8e471fcac.tar.gz gcc-d791ea1e0a2341a8fb2ca8b593063af8e471fcac.tar.bz2 |
fold-const.c (fold): Before optimizing unsigned comparison with 0x7fffffffU...
* 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
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/fold-const.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/20010329-1.c | 14 |
4 files changed, 26 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 424b4c7..81bd6e7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index ed98822..a595b6e 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -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)) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c6e1eb3..61ee72e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 index 0000000..e28d6d7 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20010329-1.c @@ -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 (); +} |