]> git.ipfire.org Git - thirdparty/gcc.git/commit - gcc/c-family/c.opt
re PR c/64249 (Missing warning for if (A) else if (A))
authorMarek Polacek <polacek@redhat.com>
Fri, 2 Oct 2015 12:56:17 +0000 (12:56 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Fri, 2 Oct 2015 12:56:17 +0000 (12:56 +0000)
commit3e3b8d63e54773e0f5add898ad55acf1be22d950
tree2068f8ebdec3daf3c4cd446ea0c01a7dfe75c37d
parent0f6ca79c15711e28ea7a6330fc9ac017077fbaad
re PR c/64249 (Missing warning for if (A) else if (A))

PR c/64249
* c-common.c (warn_duplicated_cond_add_or_warn): New function.
* c-common.h (warn_duplicated_cond_add_or_warn): Declare.
* c.opt (Wduplicated-cond): New option.

* c-parser.c (c_parser_statement_after_labels): Add CHAIN parameter
and pass it down to c_parser_if_statement.
(c_parser_else_body): Add CHAIN parameter and pass it down to
c_parser_statement_after_labels.
(c_parser_if_statement): Add CHAIN parameter.  Add code to warn about
duplicated if-else-if conditions.

* parser.c (cp_parser_statement): Add CHAIN parameter and pass it
down to cp_parser_selection_statement.
(cp_parser_selection_statement): Add CHAIN parameter.  Add code to
warn about duplicated if-else-if conditions.
(cp_parser_implicitly_scoped_statement): Add CHAIN parameter and pass
it down to cp_parser_statement.

* doc/invoke.texi: Document -Wduplicated-cond.
* Makefile.in (insn-latencytab.o): Use -Wno-duplicated-cond.
(insn-dfatab.o): Likewise.
* genemit.c (gen_exp): Rewrite condition to avoid -Wduplicated-cond
warning.

* c-c++-common/Wduplicated-cond-1.c: New test.
* c-c++-common/Wduplicated-cond-2.c: New test.
* c-c++-common/Wduplicated-cond-3.c: New test.
* c-c++-common/Wduplicated-cond-4.c: New test.
* c-c++-common/Wmisleading-indentation.c (fn_37): Avoid
-Wduplicated-cond warning.

From-SVN: r228388
18 files changed:
gcc/ChangeLog
gcc/Makefile.in
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-parser.c
gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/doc/invoke.texi
gcc/genemit.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/Wduplicated-cond-1.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/Wduplicated-cond-2.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/Wduplicated-cond-3.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/Wduplicated-cond-4.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/Wmisleading-indentation.c