https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93810
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jason Merrill <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:04dd734b52de121853e1ea6b3c197a598b294e23 commit r10-7424-g04dd734b52de121853e1ea6b3c197a598b294e23 Author: Martin Sebor <mse...@gmail.com> Date: Fri Mar 27 12:07:45 2020 -0400 c++: avoid -Wredundant-tags on a first declaration in use [PR 93824] -Wredundant-tags doesn't consider type declarations that are also the first uses of the type, such as in 'void f (struct S);' and issues false positives for those. According to the reported that's making it harder to use the warning to clean up LibreOffice. The attached patch extends -Wredundant-tags to avoid these false positives by relying on the same class_decl_loc_t::class2loc mapping as -Wmismatched-tags. The patch also improves the detection of both issues in template declarations. gcc/cp/ChangeLog 2020-03-27 Martin Sebor <mse...@redhat.com> PR c++/94078 PR c++/93824 PR c++/93810 * cp-tree.h (most_specialized_partial_spec): Declare. * parser.c (cp_parser_elaborated_type_specifier): Distinguish alias from declarations. (specialization_of): New function. (cp_parser_check_class_key): Move code... (class_decl_loc_t::add): ...to here. Add parameters. Avoid issuing -Wredundant-tags on first-time declarations in other declarators. Correct handling of template specializations. (class_decl_loc_t::diag_mismatched_tags): Also expect to be called when -Wredundant-tags is enabled. Use primary template or partial specialization as the guide for uses of implicit instantiations. * pt.c (most_specialized_partial_spec): Declare extern. gcc/testsuite/ChangeLog 2020-03-27 Martin Sebor <mse...@redhat.com> PR c++/94078 PR c++/93824 PR c++/93810 * g++.dg/warn/Wmismatched-tags-3.C: New test. * g++.dg/warn/Wmismatched-tags-4.C: New test. * g++.dg/warn/Wmismatched-tags-5.C: New test. * g++.dg/warn/Wmismatched-tags-6.C: New test. * g++.dg/warn/Wredundant-tags-3.C: Remove xfails. * g++.dg/warn/Wredundant-tags-6.C: New test. * g++.dg/warn/Wredundant-tags-7.C: New test.