[PATCH] D122895: [C89/C2x] Improve diagnostics around strict prototypes in C

James Y Knight via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 13 07:34:17 PDT 2022


jyknight added a comment.

The warnings for this case aren't great:

  int foo();
  
  int
  foo(int arg) {
    return 5;
  }

results in:

  /tmp/test.c:1:5: warning: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
  int foo();
      ^
          void
  /tmp/test.c:4:1: warning: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
  foo(int arg) {
  ^

Two warnings for the problem, instead of a warning and a note, plus, the fix-it hint is incorrect, which the compiler should know, since we see that there are arguments expected.

I'd expect more like:

  /tmp/test.c:1:5: warning: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
  int foo();
  /tmp/test.c:4:1: note: subsequent declaration specifies arguments.
  foo(int arg) {
      ^


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