PR c++/61339 - add warning for mismatch between struct and class
authorMartin Sebor <msebor@redhat.com>
Tue, 17 Dec 2019 23:53:07 +0000 (23:53 +0000)
committerMartin Sebor <msebor@gcc.gnu.org>
Tue, 17 Dec 2019 23:53:07 +0000 (16:53 -0700)
commite8f1ade269a39ea86a76a2440818e1512ed480ee
tree6e3d510dd85b3c1cd750eb1e46594fa5374f03e0
parent54ba911fd1670654d494f238d83e337a4aeb0cb4
PR c++/61339 - add warning for mismatch between struct and class

gcc/c-family/ChangeLog:

PR c++/61339
* c.opt (-Wmismatched-tags, -Wredundant-tags): New options.

gcc/cp/ChangeLog:

PR c++/61339
* parser.c (cp_parser_maybe_warn_enum_key): New function.
(class_decl_loc_t): New class.
(cp_parser_elaborated_type_specifier): Call
cp_parser_maybe_warn_enum_key.
(cp_parser_class_head): Call cp_parser_check_class_key.
(cp_parser_check_class_key): Add arguments.  Call class_decl_loc_t::add.
(c_parse_file): Call class_decl_loc_t::diag_mismatched_tags.

gcc/testsuite/ChangeLog:

PR c++/61339
* g++.dg/warn/Wmismatched-tags.C: New test.
* g++.dg/warn/Wredundant-tags.C: New test.
* g++.dg/pch/Wmismatched-tags.C: New test.
* g++.dg/pch/Wmismatched-tags.Hs: New test header.

gcc/ChangeLog:

PR c++/61339
* doc/invoke.texi (-Wmismatched-tags, -Wredundant-tags): Document
new C++ options.

From-SVN: r279480
gcc/ChangeLog
gcc/c-family/ChangeLog
gcc/c-family/c.opt
gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/doc/invoke.texi
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/pch/Wmismatched-tags.C [new file with mode: 0644]
gcc/testsuite/g++.dg/pch/Wmismatched-tags.Hs [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/Wmismatched-tags.C [new file with mode: 0644]
gcc/testsuite/g++.dg/warn/Wredundant-tags.C [new file with mode: 0644]