[Bug c/42562] New: attribute((warning(""))) should work for variables
ebb9 at byu dot net
gcc-bugzilla@gcc.gnu.org
Thu Dec 31 04:38:00 GMT 2009
It would be nice if __attribute__((warning(""))) (and error) worked anywhere
that __attribute__((deprecated)) is accepted. After all, there are other
reasons to warn other than deprecation, and the warning attribute allows an
explanation string.
However, as of gcc 4.3.4, attribute((warning)) is silently ignored on
variables. The best fix would be issuing the warning, as is done for
deprecation. But if that can't be done, for whatever reason, then an
alternative would be to emit an error at the point of the __attribute__ stating
that the attribute is invalid on variables and only implemented for functions,
as is done when using the wrong arguments to __warning__, rather than the
current behavior of silently ignoring the attribute with the correct arguments.
$ cat foo.c
#include <stdio.h>
int a __attribute__((warning("warn1")));
int b __attribute__((error("err2")));
int c __attribute__((deprecated));
int d __attribute__((warning));
int
main ()
{
printf ("%d\n", a);
printf ("%d\n", b);
printf ("%d\n", c);
}
$ gcc -Wall -o foo foo.c
foo.c:5: error: wrong number of arguments specified for Âwarning attribute
foo.c: In function ÂmainÂ:
foo.c:10: warning: Âc is deprecated (declared at foo.c:4)
--
Summary: attribute((warning(""))) should work for variables
Product: gcc
Version: 4.3.4
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ebb9 at byu dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42562
More information about the Gcc-bugs
mailing list