diff options
author | Martin Sebor <msebor@gmail.com> | 2020-03-27 12:07:45 -0400 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2020-03-27 12:08:18 -0400 |
commit | 04dd734b52de121853e1ea6b3c197a598b294e23 (patch) | |
tree | a616c0615d955949ed65701bfa024982698473f9 /gcc/gimple-builder.c | |
parent | 9dba60130dc3ebf7cce8716a36672281688693f7 (diff) | |
download | gcc-04dd734b52de121853e1ea6b3c197a598b294e23.zip gcc-04dd734b52de121853e1ea6b3c197a598b294e23.tar.gz gcc-04dd734b52de121853e1ea6b3c197a598b294e23.tar.bz2 |
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 <msebor@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 <msebor@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.
Diffstat (limited to 'gcc/gimple-builder.c')
0 files changed, 0 insertions, 0 deletions