diff options
author | Richard Guenther <rguenther@suse.de> | 2008-04-08 22:11:09 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2008-04-08 22:11:09 +0000 |
commit | c1483d17f948424678adf4b2d3c314516e6b7819 (patch) | |
tree | 3f8926657d4c8dc04827413dd646f3548d976648 /gcc | |
parent | 396e2fa18232ed8bbebe1dc0e822de446cb9b19d (diff) | |
download | gcc-c1483d17f948424678adf4b2d3c314516e6b7819.zip gcc-c1483d17f948424678adf4b2d3c314516e6b7819.tar.gz gcc-c1483d17f948424678adf4b2d3c314516e6b7819.tar.bz2 |
fold-const.c (fold_widened_comparison): Do not allow sign-changes that change the result.
2008-04-08 Richard Guenther <rguenther@suse.de>
* fold-const.c (fold_widened_comparison): Do not allow
sign-changes that change the result.
* gcc.c-torture/execute/20080408-1.c: New testcase.
From-SVN: r134113
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/fold-const.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/20080408-1.c | 11 |
4 files changed, 25 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9c97832..f05e325 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2008-04-08 Richard Guenther <rguenther@suse.de> + + * fold-const.c (fold_widened_comparison): Do not allow + sign-changes that change the result. + 2008-03-25 Richard Guenther <rguenther@suse.de> Backport from mainline: diff --git a/gcc/fold-const.c b/gcc/fold-const.c index bac759ec..c394e55 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -6308,7 +6308,11 @@ fold_widened_comparison (enum tree_code code, tree type, tree arg0, tree arg1) || TYPE_UNSIGNED (TREE_TYPE (arg0)) == TYPE_UNSIGNED (shorter_type)) && (TREE_TYPE (arg1_unw) == shorter_type || (TYPE_PRECISION (shorter_type) - >= TYPE_PRECISION (TREE_TYPE (arg1_unw))) + > TYPE_PRECISION (TREE_TYPE (arg1_unw))) + || ((TYPE_PRECISION (shorter_type) + == TYPE_PRECISION (TREE_TYPE (arg1_unw))) + && (TYPE_UNSIGNED (shorter_type) + == TYPE_UNSIGNED (TREE_TYPE (arg1_unw)))) || (TREE_CODE (arg1_unw) == INTEGER_CST && (TREE_CODE (shorter_type) == INTEGER_TYPE || TREE_CODE (shorter_type) == BOOLEAN_TYPE) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4a6e9eb..900ff95 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2008-04-08 Richard Guenther <rguenther@suse.de> + + * gcc.c-torture/execute/20080408-1.c: New testcase. + 2008-03-25 Richard Guenther <rguenther@suse.de> Backport from mainline: diff --git a/gcc/testsuite/gcc.c-torture/execute/20080408-1.c b/gcc/testsuite/gcc.c-torture/execute/20080408-1.c new file mode 100644 index 0000000..9e1ff63 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20080408-1.c @@ -0,0 +1,11 @@ +extern void abort (void); +int main () +{ + short ssi = 126; + unsigned short usi = 65280; + int fail = !(ssi < usi); + if (fail) + abort (); + return 0; +} + |