From: Eric Botcazou Date: Sat, 29 Mar 2003 10:29:33 +0000 (+0000) Subject: re PR c/8224 (Incorrect joining of signed and unsigned division) X-Git-Tag: releases/gcc-3.2.3~51 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b9039708e28347ea6d507564ae1a4542ca5425e1;p=thirdparty%2Fgcc.git re PR c/8224 (Incorrect joining of signed and unsigned division) PR c/8224 * fold-const.c (extract_muldiv_1): Don't pass through type conversions when signedness changes for division or modulus. From-SVN: r65012 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 65d1d38a5889..7d75144d716c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2003-03-29 Glen Nakamura + + PR c/8224 + * fold-const.c (extract_muldiv_1): Don't pass through type conversions + when signedness changes for division or modulus. + 2003-03-29 Alan Modra * reload1.c (reload_as_needed): Allow a USE in asm reloads. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 06f36d8542de..e341bd98f07d 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -4558,7 +4558,12 @@ extract_muldiv_1 (t, c, code, wide_type) /* ...and its type is larger than ctype, then we cannot pass through this truncation. */ || (GET_MODE_SIZE (TYPE_MODE (ctype)) - < GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (op0)))))) + < GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (op0)))) + /* ... or signedness changes for division or modulus, + then we cannot pass through this conversion. */ + || (code != MULT_EXPR + && (TREE_UNSIGNED (ctype) + != TREE_UNSIGNED (TREE_TYPE (op0)))))) break; /* Pass the constant down and see if we can make a simplification. If diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dfbdf4e9f2c8..0459d46ffd10 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2003-03-29 Mikulas Patocka + + * gcc.dg/20030323-1.c: New test. + 2003-03-28 Eric Botcazou * gcc.dg/ultrasp8.c: New test.