[PATCH] D66919: Warn about zero-parameter K&R definitions in -Wstrict-prototypes
Aaron Puchert via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 28 19:30:26 PDT 2019
aaronpuchert added a comment.
Note that I'm just copying GCC, which seems the be the original intent behind the warning (https://bugs.llvm.org/show_bug.cgi?id=20796). So people who use both compilers will have seen that warning already. Note also that there is no warning if any declaration provides a prototype, so this is fine:
void f(void); // provides a prototype
void f() {} // not a prototype, but we have one already
In D66919#1650174 <https://reviews.llvm.org/D66919#1650174>, @dexonsmith wrote:
> We could carve out a `-W` flag (if it doesn't already exist) that warns if you incorrectly pass parameters to a function whose definition has no prototype
The warning exists, but there is no flag apparently.
void f() {}
void g() {
f(0);
}
spits out
test.c:3:8: warning: too many arguments in call to 'f'
f(0);
~ ^
But with `f(void)` we get
test.c:3:7: error: too many arguments to function call, expected 0, have 1
f(0);
~ ^
test.c:1:1: note: 'f' declared here
void f(void) {}
^
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D66919/new/
https://reviews.llvm.org/D66919
More information about the cfe-commits
mailing list