From: Uros Bizjak Date: Wed, 23 Sep 2009 10:18:46 +0000 (+0200) Subject: re PR c/39779 (ICE shifting byte to the right with constant > 7FFFFFFF) X-Git-Tag: releases/gcc-4.3.5~372 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6284b63a80bf660350d58be398702741d43ba14f;p=thirdparty%2Fgcc.git re PR c/39779 (ICE shifting byte to the right with constant > 7FFFFFFF) PR c/39779 * c-typeck.c (build_binary_op) : Check that integer constant is more than zero. testsuite/ChangeLog: PR c/39779 * gcc.c-torture/compile/pr39779.c: New test. From-SVN: r152066 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cb659b1f56d2..ea2bfc48b2b2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2009-09-23 Uros Bizjak + + PR c/39779 + * c-typeck.c (build_binary_op) : Check that integer + constant is more than zero. + 2009-09-21 Janis Johnson PR c/41049 diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index c96f738ee3a7..5b2b61d30652 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -8425,6 +8425,7 @@ build_binary_op (enum tree_code code, tree orig_op0, tree orig_op1, unsigned_arg = TYPE_UNSIGNED (TREE_TYPE (op0)); if (TYPE_PRECISION (TREE_TYPE (arg0)) < TYPE_PRECISION (result_type) + && tree_int_cst_sgn (op1) > 0 /* We can shorten only if the shift count is less than the number of bits in the smaller type size. */ && compare_tree_int (op1, TYPE_PRECISION (TREE_TYPE (arg0))) < 0 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cee8d1007346..f0b65ed49ebc 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-09-23 Uros Bizjak + + PR c/39779 + * gcc.c-torture/compile/pr39779.c: New test. + 2009-09-21 Janis Johnson PR c/41049 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr39779.c b/gcc/testsuite/gcc.c-torture/compile/pr39779.c new file mode 100644 index 000000000000..d1680df29b9a --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr39779.c @@ -0,0 +1,5 @@ +int test (char v1) +{ + v1 >>= 0xdebecced; + return v1; +}