[PATCH] D122895: [C89/C2x] Improve diagnostics around strict prototypes in C
Duncan P. N. Exon Smith via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu May 12 14:31:20 PDT 2022
dexonsmith added inline comments.
================
Comment at: clang/test/Sema/warn-strict-prototypes.m:20
+ // know it's a block when diagnosing.
+ void (^block2)(void) = ^void() { // expected-warning {{a function declaration without a prototype is deprecated in all versions of C}}
};
----------------
dexonsmith wrote:
> This is a definition, so the compiler knows that there are no parameters. Why would we warn here? Reading https://discourse.llvm.org/t/rfc-enabling-wstrict-prototypes-by-default-in-c/60521/18 it looks to me like an example of what @rnk was referring to, about churning code to add `(void)` and then return back to `()` later.
>
> (cc: @steven_wu and @rjmccall as well)
Specifically, `^void() { /* anything */}` is the definition of a block with zero parameters. Maybe pedantically it's lacking a prototype, but the compiler knows (since this is the definition) how many parameters there are.
(Same goes for `void() { /* anything */ }` at global scope; is that triggering `-Wstrict-prototypes` now too?)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D122895/new/
https://reviews.llvm.org/D122895
More information about the cfe-commits
mailing list