[Bug c++/78425] Atrtibute warning message location incorrect

2016-11-21 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78425

Martin Sebor  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  ---
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));
 ^~~~

[Bug c++/78425] Atrtibute warning message location incorrect

2016-11-21 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78425

Martin Sebor  changed:

   What|Removed |Added

  Known to fail||5.3.0, 6.2.0, 7.0

--- Comment #2 from Martin Sebor  ---
Besides 7.0 this also affects both of 6.x and 5.x so it's not a regression.