[PATCH] D125814: Improve the strict prototype diagnostic behavior

James Y Knight via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 24 14:13:41 PDT 2022


jyknight added a comment.

Good improvement, but an additional change to wording for just the zero-arg non-prototype function declaration case could help a lot. The fact that zero-arg it's only being warned about because of the "...because of" note isn't particularly clear -- especially when the "because of" isn't emitted.

So, suggestion for zero-arg-specific warning text:
`this function %select{declaration|definition}0 without a prototype is deprecated before C2x, and is treated as a zero-parameter prototype in C2x, conflicting with a %select{previous|subsequent}1 declaration`. Then, the note_func_decl_changes_behavior text can just be e.g.: `conflicting prototype is here`

That'd result in: `printf 'int f();\nint f(a) int a; {return 1;}' | build/bin/clang -c -fsyntax-only -xc -` showing:

  <stdin>:2:5: warning: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
  int f(a) int a; {return 1;}
      ^
  <stdin>:1:5: warning: this function declaration without a prototype is deprecated before C2x, and is treated as a zero-parameter prototype in C2x, conflicting with a subsequent declaration [-Wdeprecated-non-prototype]
  int f();
      ^


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125814/new/

https://reviews.llvm.org/D125814



More information about the cfe-commits mailing list