[cfe-commits] [PATCH] Add -Wknr-promoted-parameter option
dimitry at andric.com
Sun Dec 18 12:44:45 PST 2011
While compiling a certain unnamed piece of mail server software, that is
a sort of mix of C99-like constructs and an extremely old K&R core, I
repeatedly received the following type of warning:
int foo(char x, int y);
int foo(x, y)
return x * y;
// $ clang -c knrpromo.c
// knrpromo.c:4:6: warning: promoted type 'int' of K&R function parameter is not compatible with the parameter type 'char' declared in a previous prototype
// char x;
// knrpromo.c:1:14: note: previous declaration is here
// int foo(char x, int y);
// 1 warning generated.
Apparently, this is because of the promotion rules for K&R function
parameters, which are always converted to int.
While this warning is fine in itself, it cannot be turned off, which is
a nuisance, as it would be very disruptive to edit all the dozens, if
not hundreds, of prototypes and definitions in the program to fix these
Therefore, I propose the attached patch, which adds a new warning option
(-Wknr-promoted-parameter) for turning it on or off. This runs through
the standard tests just fine.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 1936 bytes
Desc: not available
More information about the cfe-commits