The warning is currently disabled by default but can be enabled with
-Wstrict-calls-without-prototype. Enabling it by default will be
handled by future patches.
The warning is intended to catch C code like this:
int f(); // No prototype, accepts any number of arguments of any type. int call(void) { return f(1, 2, 3); }
While code like this is legal it can very easily invoke undefined behavior
by passing the wrong number of arguments or wrong types.
The warning only fires when arguments are passed to make it less noisy, i.e.
so that the warning does not fire on code like this:
int g(); int call(void) { return g(); }
While the above code could invoke undefined behavior, if the definition
of g() takes no arguments then the lack of a prototype is benign.
Writing function declarations that are not prototypes is also quite
common when the intention is for it to be a zero argument function
because it's easy to forget to add the void.
This warning while similar to -Wstrict-prototypes is distinct because
it warns at call sites rather at declarations.
This patch currently warns on calls to K&R style function declarations where a
previous declaration has a prototype. It is currently not clear if this is the correct behavior
as noted in the included test case.
rdar://87118271
This diagnostic doesn't tell me what's wrong with the code (and in fact, there's very possibly nothing wrong with the code whatsoever). Further, why does calling a function *with no arguments* matter when it has no prototype? I would imagine this should flag any call to a function without a prototype given that the function without a prototype may still expect arguments. e.g.,
I think the diagnostic text should be updated to something more like cannot verify %0 is being called with the correct number or %plural{1:type|:types}1 of arguments because it was declared without a prototype (or something along those lines that explains what's wrong with the code).