On Fri, Jun 11, 2021 at 04:03:34PM -0400, Jason Merrill via Gcc wrote: > You can use #pragma to disable a warning for a particular section of code: > > #pragma GCC diagnostic push > #pragma GCC diagnostic ignored "-Wattributes" > class Test { > [[maybe_unused]] int a_; > void b() {}; > }; > #pragma GCC diagnostic pop > > But I also agree that GCC shouldn't warn here.
We could do that by using a wrapper around handle_unused_attribute for the maybe_unused attribute, that way warn on unused attribute on FIELD_DECLs, but not for maybe_unused (until we actually implement some warning that uses it). Jakub