re PR c/82437 (false-positive -Wtautological-compare warning with -std=gnu89)
authorJakub Jelinek <jakub@redhat.com>
Tue, 10 Oct 2017 16:17:47 +0000 (18:17 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 10 Oct 2017 16:17:47 +0000 (18:17 +0200)
PR c/82437
* c-warn.c (warn_tautological_bitwise_comparison): Use wi::to_wide
instead of wide_int::from.

* c-c++-common/Wtautological-compare-7.c: New test.

From-SVN: r253589

gcc/c-family/ChangeLog
gcc/c-family/c-warn.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/Wtautological-compare-7.c [new file with mode: 0644]

index f70b6f838322ac9d80c847db095e4c92368c5c62..49d055aeb4de2f6bc38787ead0b9b2796f246b59 100644 (file)
@@ -1,3 +1,9 @@
+2017-10-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/82437
+       * c-warn.c (warn_tautological_bitwise_comparison): Use wi::to_wide
+       instead of wide_int::from.
+
 2017-10-06  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/82437
index 2eb4cf5dd41537ab498dbe608b5ca60f85ec24b2..717fe7f54ee1fe0cb6cfd6a3c1c07f0c84215507 100644 (file)
@@ -362,8 +362,8 @@ warn_tautological_bitwise_comparison (location_t loc, tree_code code,
   int prec = MAX (TYPE_PRECISION (TREE_TYPE (cst)),
                  TYPE_PRECISION (TREE_TYPE (bitopcst)));
 
-  wide_int bitopcstw = wide_int::from (bitopcst, prec, UNSIGNED);
-  wide_int cstw = wide_int::from (cst, prec, UNSIGNED);
+  wide_int bitopcstw = wi::to_wide (bitopcst, prec);
+  wide_int cstw = wi::to_wide (cst, prec);
 
   wide_int res;
   if (TREE_CODE (bitop) == BIT_AND_EXPR)
index 78a0cc40f9a6b9a2e388a6884d74716f95be336b..9317e4df749c93fdd0de5e89c4e557046cfed21d 100644 (file)
@@ -1,3 +1,8 @@
+2017-10-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/82437
+       * c-c++-common/Wtautological-compare-7.c: New test.
+
 2017-10-10  Bin Cheng  <bin.cheng@arm.com>
 
        * gcc.dg/tree-ssa/ldist-34.c: New test.
diff --git a/gcc/testsuite/c-c++-common/Wtautological-compare-7.c b/gcc/testsuite/c-c++-common/Wtautological-compare-7.c
new file mode 100644 (file)
index 0000000..1dab587
--- /dev/null
@@ -0,0 +1,11 @@
+/* PR c/82437 */
+/* { dg-do compile { target int32 } } */
+/* { dg-options "-Wtautological-compare" } */
+
+int
+foo (unsigned long long int x)
+{
+  if ((x | 0x190000000ULL) != -1879048192)     /* { dg-bogus "bitwise comparison always evaluates to" } */
+    return 0;
+  return 1;
+}