[Bug c++/93810] missing -Wmismatched-tags and -Wredundant-tags on a typedef of an implicit class template specialization

2021-08-24 Thread msebor at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93810

Martin Sebor  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED
   Target Milestone|--- |10.0

--- Comment #3 from Martin Sebor  ---
Fixed.

[Bug c++/93810] missing -Wmismatched-tags and -Wredundant-tags on a typedef of an implicit class template specialization

2020-03-27 Thread cvs-commit at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93810

--- Comment #2 from CVS Commits  ---
The master branch has been updated by Jason Merrill :

https://gcc.gnu.org/g:04dd734b52de121853e1ea6b3c197a598b294e23

commit r10-7424-g04dd734b52de121853e1ea6b3c197a598b294e23
Author: Martin Sebor 
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  

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  

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.

[Bug c++/93810] missing -Wmismatched-tags and -Wredundant-tags on a typedef of an implicit class template specialization

2020-02-19 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93810

Martin Liška  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2020-02-19
 CC||marxin at gcc dot gnu.org
 Ever confirmed|0   |1

[Bug c++/93810] missing -Wmismatched-tags and -Wredundant-tags on a typedef of an implicit class template specialization

2020-02-18 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93810

Martin Sebor  changed:

   What|Removed |Added

Summary|missing -Wmismatched-tags   |missing -Wmismatched-tags
   |on a typedef of an implicit |and -Wredundant-tags on a
   |class template  |typedef of an implicit
   |specialization  |class template
   ||specialization

--- Comment #1 from Martin Sebor  ---
Also missing -Wredundant-tags:

$ cat t.C && gcc -S -Wmismatched-tags -Wredundant-tags t.C
template  class C { };

typedef C<0> C0;   // okay
typedef class C<0> C0; // missing -Wredundant-tags

typedef C<1> C1;   // okay
typedef struct C<1> C1;// missing -Wmismatched-tags