[PATCH] D66919: Warn about zero-parameter K&R definitions in -Wstrict-prototypes

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 14 06:23:21 PST 2020


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

Thanks for your patience while I thought about this more. I think the direction makes sense, so this LGTM with some extra test cases.



================
Comment at: clang/test/Sema/warn-strict-prototypes.c:11
+// function definition with 0 params, no prototype.
+void foo1() {} // expected-warning {{this old-style function definition is not preceded by a prototype}}
+// function definition with 0 params, prototype.
----------------
I'd like a few more test cases:
```
// Test that a non-prototyped definition with no preceding prototype whines about lacking a preceding prototype
void fooN() {} // expected-warning {{this old-style function definition is not preceded by a prototype}}

// Test that an existing declaration with no prototype still warns that a corresponding definition with a type list is still not preceded by a prototype.
void fooN1(); // expected-warning {{this function declaration is not a prototype}}
void fooN1(void) {} // expected-warning {{this old-style function definition is not preceded by a prototype}}
```


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