public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/101940] New: Implement -fignored-attributes
@ 2021-08-16 21:05 mpolacek at gcc dot gnu.org
  2021-08-17  7:48 ` [Bug c++/101940] " rguenth at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-08-16 21:05 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101940
           Summary: Implement -fignored-attributes
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mpolacek at gcc dot gnu.org
  Target Milestone: ---

It is desirable for -Wattributes to warn about e.g.

[[deprecate]] void g(); // typo, should warn

However, -Wattributes also warns about vendor-specific attributes (that's
because lookup_scoped_attribute_spec -> find_attribute_namespace finds
nothing), which, with -Werror, causes grief.  We don't want the -Wattributes
warning for

[[company::attr]] void f();

GCC warns because it doesn't know the "company" namespace; it only knows the
"gnu" and "omp" namespaces.  We could entirely disable warning about attributes
in unknown scopes but then the compiler would also miss typos like

  [[company::attrx]] void f();

or 

  [[gmu::warn_used_result]] int write();

so that is not a viable solution.  A workaround is to use a #pragma:

  #pragma GCC diagnostic push
  #pragma GCC diagnostic ignored "-Wattributes"
  [[company::attr]] void f() {}
  #pragma GCC diagnostic pop

but that's a mouthful and awkward to use and could also hide typos.  In fact,
any macro-based solution doesn't seem like a way forward.

So this RFE asks for -fignored-attributes=, which, IMHO, should take these
arguments:

company::attr
company::
clang

the last is a special option to ignore clang-only attributes.  Maybe we could
also accept ::attr.

This option should go well with using @file: we could have a file containing
-fignored-attributes=vendor::attr1,vendor::attr2
and then invoke gcc with '@attrs' or similar.

It might also make sense to implement a #pragma to go along:

#pragma GCC ignored-attributes=vendor::attr1,vendor::attr2.

This should help with various static analysis tools and similar.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-11-10 14:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-16 21:05 [Bug c++/101940] New: Implement -fignored-attributes mpolacek at gcc dot gnu.org
2021-08-17  7:48 ` [Bug c++/101940] " rguenth at gcc dot gnu.org
2021-08-17 14:19 ` mpolacek at gcc dot gnu.org
2021-08-17 15:31 ` msebor at gcc dot gnu.org
2021-08-17 15:49 ` mpolacek at gcc dot gnu.org
2021-09-20 17:07 ` [Bug c++/101940] Implement -Wno-attributes=vendor::attr mpolacek at gcc dot gnu.org
2021-11-10 14:26 ` cvs-commit at gcc dot gnu.org
2021-11-10 14:31 ` mpolacek at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).