dexonsmith added a comment. > 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); > ~ ^
Great; then I think we should add a flag. I would suggest `-Werror`-by-default since the compiler knows it's incorrect code. In D66919#1651473 <https://reviews.llvm.org/D66919#1651473>, @aaronpuchert wrote: > "Meaning" is a difficult term. What we know is that this is a K&R-style > definition, and does not define a prototype. So one would expect > `-Wstrict-prototypes` to warn about this. All I'm suggesting is that the compiler knows that the call is wrong, so it should error (by-default). After adding that, my feeling is that diagnosing a missing prototype on a defining declaration would be a style nitpick that might fit better in clang-tidy. IIRC, when we rolled out `-Wstrict-prototypes` we explicitly excluded this case since it hit a lot of code without finding bugs. But at the same time, I don't want to block this. If you do pursue this please use a distinct `-W` flag so it can be turned off without losing the benefits of `-Wstrict-prototypes`. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D66919/new/ https://reviews.llvm.org/D66919 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits