public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c/103960] New: Clang's -Wunknown-attributes is more useful than -Wattributes @ 2022-01-10 12:08 redi at gcc dot gnu.org 2022-01-10 12:26 ` [Bug c/103960] " pinskia at gcc dot gnu.org ` (5 more replies) 0 siblings, 6 replies; 7+ messages in thread From: redi at gcc dot gnu.org @ 2022-01-10 12:08 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103960 Bug ID: 103960 Summary: Clang's -Wunknown-attributes is more useful than -Wattributes Product: gcc Version: 12.0 Status: UNCONFIRMED Keywords: diagnostic Severity: enhancement Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- (This is really c-family not c) GCC's -Wattributes is used for both completely unknown attributes (e.g. the user has a typo, or they use a new attribute on an old GCC) and for misplaced attributes (e.g. a function attribute on a variable). This leaves users wondering what they've done wrong. For example, GCC 9 prints this because 'access' was added in GCC 10: f.c:5:1: warning: ‘access’ attribute directive ignored [-Wattributes] 5 | __attribute__ ((access (read_only, 1))) bool my_func (const MyStruct * const self); | ^~~~~~~~~~~~~ This doesn't tell the user *why* it was ignored. Did they just use the wrong grammar? You have to be quite familiar with GCC to know that using it in the wrong place would give a different diagnostic: f.c:5:1: warning: ‘access’ attribute only applies to function types [-Wattributes] 5 | bool my_func (const MyStruct * const __attribute__ ((access (read_only, 1))) self); | ^~~~ Apart from the caret being in the wrong place, this is pretty good. But for unknown attributes our diagnostic is vague about what the problem is. Clang's -Wunknown-attributes is more explicit: f.c:5:17: warning: unknown attribute 'access' ignored [-Wunknown-attributes] __attribute__ ((access (read_only, 1))) bool my_func (const MyStruct * const self); ^~~~~~~~~~~~~~~~~~~~~ This tells you clearly that clang simply doesn't recognize the 'access' attribute. Could we just add the word "unknown" to the diagnostic for unrecognised attributes? ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/103960] Clang's -Wunknown-attributes is more useful than -Wattributes 2022-01-10 12:08 [Bug c/103960] New: Clang's -Wunknown-attributes is more useful than -Wattributes redi at gcc dot gnu.org @ 2022-01-10 12:26 ` pinskia at gcc dot gnu.org 2022-01-10 12:31 ` pinskia at gcc dot gnu.org ` (4 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-01-10 12:26 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103960 --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- So it looks like the warning is coming from the front-end though and not from c-family :). I noticed this because take: struct MyStruct; [[gg (read_only, 1)]] int my_func (const struct MyStruct * const self); ----- CUT ---- The C front-end produces: <source>:2:1: warning: 'gg' attribute ignored [-Wattributes] While the C++ front-end produces: <source>:2:70: warning: 'gg' attribute directive ignored [-Wattributes] ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/103960] Clang's -Wunknown-attributes is more useful than -Wattributes 2022-01-10 12:08 [Bug c/103960] New: Clang's -Wunknown-attributes is more useful than -Wattributes redi at gcc dot gnu.org 2022-01-10 12:26 ` [Bug c/103960] " pinskia at gcc dot gnu.org @ 2022-01-10 12:31 ` pinskia at gcc dot gnu.org 2022-01-10 12:33 ` pinskia at gcc dot gnu.org ` (3 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-01-10 12:31 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103960 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2022-01-10 Ever confirmed|0 |1 Status|UNCONFIRMED |NEW --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- But yes I agree GCC's warning should be much better. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/103960] Clang's -Wunknown-attributes is more useful than -Wattributes 2022-01-10 12:08 [Bug c/103960] New: Clang's -Wunknown-attributes is more useful than -Wattributes redi at gcc dot gnu.org 2022-01-10 12:26 ` [Bug c/103960] " pinskia at gcc dot gnu.org 2022-01-10 12:31 ` pinskia at gcc dot gnu.org @ 2022-01-10 12:33 ` pinskia at gcc dot gnu.org 2023-05-25 10:30 ` avi at scylladb dot com ` (2 subsequent siblings) 5 siblings, 0 replies; 7+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-01-10 12:33 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103960 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=64332 --- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Note the location issue is PR 64332. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/103960] Clang's -Wunknown-attributes is more useful than -Wattributes 2022-01-10 12:08 [Bug c/103960] New: Clang's -Wunknown-attributes is more useful than -Wattributes redi at gcc dot gnu.org ` (2 preceding siblings ...) 2022-01-10 12:33 ` pinskia at gcc dot gnu.org @ 2023-05-25 10:30 ` avi at scylladb dot com 2023-05-25 10:46 ` jakub at gcc dot gnu.org 2023-05-25 10:56 ` avi at scylladb dot com 5 siblings, 0 replies; 7+ messages in thread From: avi at scylladb dot com @ 2023-05-25 10:30 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103960 Avi Kivity <avi at scylladb dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |avi at scylladb dot com --- Comment #4 from Avi Kivity <avi at scylladb dot com> --- It would be nice to have -fignore-attribute-namespace=clang, so we can ignore [[clang::very_useful_attribute(blah)]] on gcc and [[gnu::another_good_thing(foo)]] on clang, instead of having to wrap everything with macros. (complicated a little by clang recognizing some attributes in the gnu namespace). ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/103960] Clang's -Wunknown-attributes is more useful than -Wattributes 2022-01-10 12:08 [Bug c/103960] New: Clang's -Wunknown-attributes is more useful than -Wattributes redi at gcc dot gnu.org ` (3 preceding siblings ...) 2023-05-25 10:30 ` avi at scylladb dot com @ 2023-05-25 10:46 ` jakub at gcc dot gnu.org 2023-05-25 10:56 ` avi at scylladb dot com 5 siblings, 0 replies; 7+ messages in thread From: jakub at gcc dot gnu.org @ 2023-05-25 10:46 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103960 Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> --- -Wno-attributes=clang:: ? ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c/103960] Clang's -Wunknown-attributes is more useful than -Wattributes 2022-01-10 12:08 [Bug c/103960] New: Clang's -Wunknown-attributes is more useful than -Wattributes redi at gcc dot gnu.org ` (4 preceding siblings ...) 2023-05-25 10:46 ` jakub at gcc dot gnu.org @ 2023-05-25 10:56 ` avi at scylladb dot com 5 siblings, 0 replies; 7+ messages in thread From: avi at scylladb dot com @ 2023-05-25 10:56 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103960 --- Comment #6 from Avi Kivity <avi at scylladb dot com> --- Ah! thanks. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-05-25 10:56 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-01-10 12:08 [Bug c/103960] New: Clang's -Wunknown-attributes is more useful than -Wattributes redi at gcc dot gnu.org 2022-01-10 12:26 ` [Bug c/103960] " pinskia at gcc dot gnu.org 2022-01-10 12:31 ` pinskia at gcc dot gnu.org 2022-01-10 12:33 ` pinskia at gcc dot gnu.org 2023-05-25 10:30 ` avi at scylladb dot com 2023-05-25 10:46 ` jakub at gcc dot gnu.org 2023-05-25 10:56 ` avi at scylladb dot com
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).