[Bug c/51579] New: GCC should be able report a warning for usage of parameters marked with __attribute__((unused))
yann at droneaud dot fr
gcc-bugzilla@gcc.gnu.org
Fri Dec 16 14:25:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51579
Bug #: 51579
Summary: GCC should be able report a warning for usage of
parameters marked with __attribute__((unused))
Classification: Unclassified
Product: gcc
Version: 4.6.2
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: yann@droneaud.fr
I would like to see GCC emit a warning when a parameter marked as unused is in
fact used in the function. The warning option could be something like
-Wunused-parameter-used
For example, the following code doesn't produce any warning.
int foo (int *ptr, int val __attribute__((unused)))
{
int res;
res = *ptr + val;
return res;
}
It would be interesting to have a warning like this:
test.c: In function 'foo':
test.c:5:21: warning: parameter 'val' is used but marked as "unused" in
declaration [-Wunused-parameter-used]
Same thing could apply to function, type and variable specified with
__attribute__((unused))
Additionally, a new attribute "warn_use" could be introduced to enforce the
"unused" attribute, since "unused" attribute is not meant to prevent usage:
- "This attribute, attached to a function, means that the function is meant to
be possibly unused"
- "When attached to a type (including a union or a struct), this attribute
means that variables of that type are meant to appear possibly unused"
- "This attribute, attached to a variable, means that the variable is meant to
be possibly unused"
More information about the Gcc-bugs
mailing list