]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/39779 (ICE shifting byte to the right with constant > 7FFFFFFF)
authorUros Bizjak <ubizjak@gmail.com>
Wed, 23 Sep 2009 10:18:46 +0000 (12:18 +0200)
committerUros Bizjak <uros@gcc.gnu.org>
Wed, 23 Sep 2009 10:18:46 +0000 (12:18 +0200)
PR c/39779
* c-typeck.c (build_binary_op) <short_shift>: Check that integer
constant is more than zero.

testsuite/ChangeLog:

PR c/39779
* gcc.c-torture/compile/pr39779.c: New test.

From-SVN: r152066

gcc/ChangeLog
gcc/c-typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr39779.c [new file with mode: 0644]

index cb659b1f56d2adfa4f70c0d9d4d2c7b76e12862e..ea2bfc48b2b26fb75161f6b0e12aa4f2b87da337 100644 (file)
@@ -1,3 +1,9 @@
+2009-09-23  Uros Bizjak  <ubizjak@gmail.com>
+
+       PR c/39779
+       * c-typeck.c (build_binary_op) <short_shift>: Check that integer
+       constant is more than zero.
+
 2009-09-21  Janis Johnson  <janis187@us.ibm.com>
 
        PR c/41049
index c96f738ee3a7ba9a57a557f5dbb59d4679798c04..5b2b61d3065223341ee925221c18ed649cb6a09f 100644 (file)
@@ -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
index cee8d1007346d05b0acd9083dd5471aee1b92654..f0b65ed49ebcc76eb03f5e1da513a2f275412424 100644 (file)
@@ -1,3 +1,8 @@
+2009-09-23  Uros Bizjak  <ubizjak@gmail.com>
+
+       PR c/39779
+       * gcc.c-torture/compile/pr39779.c: New test.
+
 2009-09-21  Janis Johnson  <janis187@us.ibm.com>
 
        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 (file)
index 0000000..d1680df
--- /dev/null
@@ -0,0 +1,5 @@
+int test (char v1)
+{
+  v1 >>= 0xdebecced;
+  return v1;
+}