[Bug c++/78425] Atrtibute warning message location incorrect
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Nov 21 21:04:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78425
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2016-11-21
CC| |msebor at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Confirmed. The location information for attributes isn't correct either in C
or in C++ as the following test case shows:
$ cat x.C && /build/gcc-svn/gcc/xgcc -B /build/gcc-svn/gcc -S -Wall -Wextra
-xc++ x.C
#define ARG_NONNULL __attribute__ ((nonnull))
#define RET_NONNULL __attribute__ ((returns_nonnull))
void ARG_NONNULL f0 (void*) RET_NONNULL;
void RET_NONNULL f1 (void*) ARG_NONNULL;
void __attribute__ ((nonnull)) f2 (void*) __attribute__ ((returns_nonnull));
void __attribute__ ((returns_nonnull)) f3 (void*) __attribute__ ((nonnull));
x.C:2:53: error: returns_nonnull attribute on a function not returning a
pointer
#define RET_NONNULL __attribute__ ((returns_nonnull))
^
x.C:4:29: note: in expansion of macro ‘RET_NONNULL’
void ARG_NONNULL f0 (void*) RET_NONNULL;
^~~~~~~~~~~
x.C:1:45: error: returns_nonnull attribute on a function not returning a
pointer
#define ARG_NONNULL __attribute__ ((nonnull))
^
x.C:5:29: note: in expansion of macro ‘ARG_NONNULL’
void RET_NONNULL f1 (void*) ARG_NONNULL;
^~~~~~~~~~~
x.C:7:75: error: returns_nonnull attribute on a function not returning a
pointer
void __attribute__ ((nonnull)) f2 (void*) __attribute__ ((returns_nonnull));
^
x.C:8:75: error: returns_nonnull attribute on a function not returning a
pointer
void __attribute__ ((returns_nonnull)) f3 (void*) __attribute__ ((nonnull));
^
When compiled in C mode the messages are almost as bad (though more obviously
wrong and so less confusing)
x.C:4:1: error: returns_nonnull attribute on a function not returning a pointer
void ARG_NONNULL f0 (void*) RET_NONNULL;
^~~~
x.C:5:1: error: returns_nonnull attribute on a function not returning a pointer
void RET_NONNULL f1 (void*) ARG_NONNULL;
^~~~
x.C:7:1: error: returns_nonnull attribute on a function not returning a pointer
void __attribute__ ((nonnull)) f2 (void*) __attribute__ ((returns_nonnull));
^~~~
x.C:8:1: error: returns_nonnull attribute on a function not returning a pointer
void __attribute__ ((returns_nonnull)) f3 (void*) __attribute__ ((nonnull));
^~~~
More information about the Gcc-bugs
mailing list