From: rguenth Date: Sun, 31 Dec 2006 14:01:19 +0000 (+0000) Subject: 2006-12-31 Richard Guenther X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a7ede36ac5267c5134900a3e457a47ac3ad50901;p=thirdparty%2Fgcc.git 2006-12-31 Richard Guenther PR middle-end/30338 * fold-const.c (fold_binary): Fix type-mismatch in folding of -1 - A to ~A. * gcc.c-torture/compile/pr30338.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@120297 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ff58d77ab54b..1e2601bac491 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2006-12-31 Richard Guenther + + PR middle-end/30338 + * fold-const.c (fold_binary): Fix type-mismatch in folding + of -1 - A to ~A. + 2006-12-30 Kazu Hirata * tree-inline.c: Fix a comment typo. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 18746096b5a3..dbdc9c26367e 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -9009,7 +9009,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) /* Convert -1 - A to ~A. */ if (INTEGRAL_TYPE_P (type) && integer_all_onesp (arg0)) - return fold_build1 (BIT_NOT_EXPR, type, arg1); + return fold_build1 (BIT_NOT_EXPR, type, op1); if (! FLOAT_TYPE_P (type)) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 564312da9348..a24138920b20 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2006-12-31 Richard Guenther + + PR middle-end/30338 + * gcc.c-torture/compile/pr30338.c: New testcase. + 2006-12-31 Paul Thomas PR fortran/27900 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr30338.c b/gcc/testsuite/gcc.c-torture/compile/pr30338.c new file mode 100644 index 000000000000..2d6245d014d9 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr30338.c @@ -0,0 +1,14 @@ +/* We used to do folding with mismatched types which caused us to + infinitely loop in comparison foldings. */ + +extern char *grub_scratch_mem; +int testload_func (char *arg, int flags) +{ + int i; + for (i = 0; i < 0x10ac0; i++) + if (*((unsigned char *) ((0x200000 + i + (int) grub_scratch_mem))) + != *((unsigned char *) ((0x300000 + i + (int) grub_scratch_mem)))) + return 0; + return 1; +} +