https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93824

--- Comment #4 from Stephan Bergmann <sbergman at redhat dot com> ---
(In reply to Martin Sebor from comment #3)
> Ah, I see.  I'm not sure there's anything I can do about the first case --
> the warning there is by design.

So users will have to be careful when they fix a -Wredundant-tags warning in an
included file.  They may have to introduce a forward declaration into the
included file in order not to break (or silently alter) other translation units
that also include that file.  (A case where removal of the "redundant" tag in
the included file inc.h

> struct S {};
> namespace N {
>   int f(struct S); // -Wredundant-tags
> }

can silently alter the behavior of another translation unit is when that other
translation unit contains

> namespace N { int S = 0; }
> #include "inc.h"

so that N::f would now be a variable rather than a function there.)

> Out of curiosity, what is your interest in -Wredundant-tag?  (Are you hoping
> to use it to clean up a code base or something else?)

My motivation is to see if -Wmismatched-tags and -Wredundant-tags could be used
by LibreOffice.  The former would be useful for compatibility with MSVC, where
mismatched tags already produce a warning (i.e., error, with our
--enable-werror regime).  And we have a number of source files that migrated
from C to C++ over time, where the latter could help clean up some accidental
clutter.  (Plus, LibreOffice always proves to be a good testbed for new
diagnostics. :)

Reply via email to