re PR c++/66555 (Fails to warn for if (j == 0 && i == i))
authorMarek Polacek <polacek@redhat.com>
Mon, 27 Jul 2015 12:40:45 +0000 (12:40 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Mon, 27 Jul 2015 12:40:45 +0000 (12:40 +0000)
commit05b28fd6f91016151e758c2414d7245a54512c99
treea50a804e0d3bacf0015564dabec36d9c9121f14d
parent0fd357f27d55de9d05662ebce1f166974891f52e
re PR c++/66555 (Fails to warn for if (j == 0 && i == i))

PR c++/66555
PR c/54979
* c-common.c (find_array_ref_with_const_idx_r): New function.
(warn_tautological_cmp): New function.
* c-common.h (warn_tautological_cmp): Declare.
* c.opt (Wtautological-compare): New option.

* c-typeck.c (parser_build_binary_op): Call warn_tautological_cmp.

* call.c (build_new_op_1): Call warn_tautological_cmp.
* pt.c (tsubst_copy_and_build): Use sentinel to suppress tautological
compare warnings.

* doc/invoke.texi: Document -Wtautological-compare.

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

From-SVN: r226242
15 files changed:
gcc/ChangeLog
gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/c-family/c-common.h
gcc/c-family/c.opt
gcc/c/ChangeLog
gcc/c/c-typeck.c
gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/pt.c
gcc/doc/invoke.texi
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/Wtautological-compare-1.c [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/decltype-54581.C
gcc/testsuite/g++.dg/other/vector-compare.C