On Tue, Dec 17, 2024 at 05:54:36PM -0500, Jason Merrill wrote:
> On 9/5/24 3:27 AM, Jakub Jelinek wrote:
> > When adding test coverage for maybe_unused attribute, I've run into
> > several things:
> > 1) similarly to deprecated attribute, the attribute shouldn't pedantically
> >     appertain to types other than class/enumeration definitions
> > 2) similarly to deprecated attribute, the attribute shouldn't pedantically
> >     appertain to unnamed bit-fields
> > 3) the standard says that it can appertain to identifier labels, but
> >     we handled it silently also on case and default labels
> 
> As with deprecated, wouldn't it be an improvement to warn for the GNU
> attribute in these cases as well?

Similar to the deprecated case, I see the 1) case e.g. in
g++.dg/cpp0x/gen-attrs-22.C
c-c++-common/Wunused-var-11.c
g++.dg/ext/attrib61.C
c-c++-common/Wunused-var-11.c
g++.dg/warn/Wunused-local-typedefs.C
tests and 3) case in gcc.dg/c23-attr-maybe_unused-1.c

I don't see any 2) cases in the GCC testsuite, haven't searched for it in other
codebases.  But I'm still worried of changing something that has been
accepted for 23 years without a standard telling it is not ok anymore (which
is the case of [[maybe_unused]] in C++.
>From what I see, even when the C added some pedantic diagnostics for
standard attributes, it added them just to the standard ones and not the GNU
ones, e.g. handle_std_noreturn_attribute adds those on top of
handle_noreturn_attribute.

I think PR27648 has been filed long before the advent of fuzzers, so maybe
it came from some real-world code or somebody at least tried to use it like
that.

        Jakub

Reply via email to