This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/79961] Should diagnose when '__nonnull__' attribute is applied to implicit this argument
- From: "palves at redhat dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 08 Mar 2017 23:14:26 +0000
- Subject: [Bug c++/79961] Should diagnose when '__nonnull__' attribute is applied to implicit this argument
- Auto-submitted: auto-generated
- References: <bug-79961-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79961
--- Comment #7 from Pedro Alves <palves at redhat dot com> ---
Funny enough, clang 3.7 (don't have more recent handy), warns in that case,
while it errors on the "this" arg:
nonnull.cc:3:39: error: '__nonnull__' attribute is invalid for the implicit
this argument
A (const char *arg) __attribute__ ((__nonnull__ (1)));
^ ~
nonnull.cc:4:46: error: '__nonnull__' attribute is invalid for the implicit
this argument
void foo (const char *arg) __attribute__ ((__nonnull__ (1)));
^ ~
nonnull.cc:5:51: warning: '__nonnull__' attribute only applies to pointer
arguments [-Wignored-attributes]
void foo (int, const char *arg) __attribute__ ((__nonnull__ (2)));
~~~ ^ ~
1 warning and 2 errors generated.
So nobody's consistent. :-)