https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93824
Bug ID: 93824 Summary: -Wredundant-tags false positives Product: gcc Version: 10.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: sbergman at redhat dot com CC: msebor at gcc dot gnu.org Target Milestone: --- With recent GCC trunk and > $ cat incA.h > struct S {}; > $ cat incB.h > void f(struct S *); > $ cat test1.cc > #include "incA.h" > #include "incB.h" > $ cat test2.cc > #include "incB.h" > $ g++ -Wredundant-tags -fsyntax-only test1.cc > In file included from test1.cc:2: > incB.h:1:8: warning: redundant class-key ‘struct’ in reference to ‘struct S’ > [-Wredundant-tags] > 1 | void f(struct S *); > | ^~~~~~ > | ------ > $ g++ -Wredundant-tags -fsyntax-only test2.cc > In file included from test2.cc:1: > incB.h:1:8: warning: redundant class-key ‘struct’ in reference to ‘struct S’ > [-Wredundant-tags] > 1 | void f(struct S *); > | ^~~~~~ > | ------ there should IMO not be warnings when compiling neither test1.ccc nor test2.cc. test2.cc clearly is a false positive, and arguably test1.cc is as well, albeit a little more subtly.