PR c/64249
authormpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 2 Oct 2015 12:56:17 +0000 (12:56 +0000)
committermpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 2 Oct 2015 12:56:17 +0000 (12:56 +0000)
commitef17a71ae4f67e4d5a0af39395a6035553d226c9
tree2068f8ebdec3daf3c4cd446ea0c01a7dfe75c37d
parent446e1fdf52f7399d390b623600947899eae9eef9
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@228388 138bc75d-0d04-0410-961f-82ee72b054a4
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