]> git.ipfire.org Git - thirdparty/gcc.git/commit
PR c/80116
authormpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 26 Jun 2017 10:02:27 +0000 (10:02 +0000)
committermpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 26 Jun 2017 10:02:27 +0000 (10:02 +0000)
commit2bfb0686cae41b7e742a26289969ce79ddd80505
treeeb5ce085c45fa8f538a1c2ea1da0f6b4aee02485
parent3e2314a91e2e20ace7ebd64b11d770462913fa19
PR c/80116
* c-common.h (warn_for_multistatement_macros): Declare.
* c-warn.c: Include "c-family/c-indentation.h".
(warn_for_multistatement_macros): New function.
* c.opt (Wmultistatement-macros): New option.
* c-indentation.c (guard_tinfo_to_string): No longer static.
Change the parameter type to "enum rid".  Handle RID_SWITCH.
* c-indentation.h (guard_tinfo_to_string): Declare.

* c-parser.c (c_parser_if_body): Set the location of the
body of the conditional after parsing all the labels.  Call
warn_for_multistatement_macros.
(c_parser_else_body): Likewise.
(c_parser_switch_statement): Likewise.
(c_parser_while_statement): Likewise.
(c_parser_for_statement): Likewise.
(c_parser_statement): Add a default argument.  Save the location
after labels have been parsed.
(c_parser_c99_block_statement): Likewise.

* parser.c (cp_parser_statement): Add a default argument.  Save the
location of the expression-statement after labels have been parsed.
(cp_parser_implicitly_scoped_statement): Set the location of the
body of the conditional after parsing all the labels.  Call
warn_for_multistatement_macros.
(cp_parser_already_scoped_statement): Likewise.

* doc/invoke.texi: Document -Wmultistatement-macros.

* c-c++-common/Wmultistatement-macros-1.c: New test.
* c-c++-common/Wmultistatement-macros-2.c: New test.
* c-c++-common/Wmultistatement-macros-3.c: New test.
* c-c++-common/Wmultistatement-macros-4.c: New test.
* c-c++-common/Wmultistatement-macros-5.c: New test.
* c-c++-common/Wmultistatement-macros-6.c: New test.
* c-c++-common/Wmultistatement-macros-7.c: New test.
* c-c++-common/Wmultistatement-macros-8.c: New test.
* c-c++-common/Wmultistatement-macros-9.c: New test.
* c-c++-common/Wmultistatement-macros-10.c: New test.
* c-c++-common/Wmultistatement-macros-11.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@249643 138bc75d-0d04-0410-961f-82ee72b054a4
24 files changed:
gcc/ChangeLog
gcc/c-family/ChangeLog
gcc/c-family/c-common.h
gcc/c-family/c-indentation.c
gcc/c-family/c-indentation.h
gcc/c-family/c-warn.c
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/testsuite/ChangeLog
gcc/testsuite/c-c++-common/Wmultistatement-macros-1.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/Wmultistatement-macros-10.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/Wmultistatement-macros-11.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/Wmultistatement-macros-2.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/Wmultistatement-macros-3.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/Wmultistatement-macros-4.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/Wmultistatement-macros-5.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/Wmultistatement-macros-6.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/Wmultistatement-macros-7.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/Wmultistatement-macros-8.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/Wmultistatement-macros-9.c [new file with mode: 0644]