Post-commit feedback on https://reviews.llvm.org/D122895 pointed out that the diagnostic wording for some code was using "declaration" in a confusing way, such as:
int foo(); // warning: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x int foo(int arg) { // warning: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x return 5; }
And that we had other minor issues with the diagnostics being somewhat confusing.
This patch addresses the confusion by reworking the implementation to be a bit more simple and a bit less chatty. Specifically, it changes the warning and note diagnostics to be able to specify "declaration" or "definition" as appropriate, and it changes the function merging logic so that the function without a prototype is always what gets warned on, and the function with a prototype is sometimes what gets noted. Additionally, when diagnosing a K&R C definition that is preceded by a function without a prototype, we don't note the prior declaration, we warn on it because it will also be changing behavior in C2x.
"when the new declaration is a definition without a prototype" perhaps?