From 802b38c91f7c5a03e69e37bd4a1ad54a46020671 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 10 Oct 2017 18:17:47 +0200 Subject: [PATCH] re PR c/82437 (false-positive -Wtautological-compare warning with -std=gnu89) 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 | 6 ++++++ gcc/c-family/c-warn.c | 4 ++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/c-c++-common/Wtautological-compare-7.c | 11 +++++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/c-c++-common/Wtautological-compare-7.c diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index f70b6f83832..49d055aeb4d 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2017-10-10 Jakub Jelinek + + PR c/82437 + * c-warn.c (warn_tautological_bitwise_comparison): Use wi::to_wide + instead of wide_int::from. + 2017-10-06 Jakub Jelinek PR c/82437 diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c index 2eb4cf5dd41..717fe7f54ee 100644 --- a/gcc/c-family/c-warn.c +++ b/gcc/c-family/c-warn.c @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 78a0cc40f9a..9317e4df749 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-10-10 Jakub Jelinek + + PR c/82437 + * c-c++-common/Wtautological-compare-7.c: New test. + 2017-10-10 Bin Cheng * 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 index 00000000000..1dab5877f3b --- /dev/null +++ b/gcc/testsuite/c-c++-common/Wtautological-compare-7.c @@ -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; +} -- 2.30.2