[PATCH] D66919: Warn about zero-parameter K&R definitions in -Wstrict-prototypes
Duncan P. N. Exon Smith via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 29 09:07:16 PDT 2019
dexonsmith added a comment.
In D66919#1650775 <https://reviews.llvm.org/D66919#1650775>, @aaron.ballman wrote:
> In D66919#1650174 <https://reviews.llvm.org/D66919#1650174>, @dexonsmith wrote:
>
> > This could cause a lot of churn in existing projects (especially with `static void foo()`), without giving Clang any new information. I'm wary of this.
>
>
> Those projects likely aren't aware they're using prototypeless functions, which are trivial to call incorrectly. I suspect this diagnostic will find real bugs in code.
To be clear, my understanding is that `-Wstrict-prototypes` already warns on non-prototype declarations like this:
void foo();
we just don't warn on non-prototype defining declarations, where the meaning is unambiguous:
void foo() {}
> It's not incorrect to pass arguments to a function without a prototype, so that should not be an error. It is incorrect to pass the wrong number or types of arguments to a function without a prototype. It's not a bad idea to error in that circumstances, but there's no solution for `extern void foo()` where we don't see the actual definition.
Given my understanding, then the only corner case that's left is when we *do* see the definition.
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