https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95445

--- Comment #4 from Florian Weimer <fw at gcc dot gnu.org> ---
Patch posted:

[PATCH] c: Implement -Wdeprecated-non-prototype
<https://inbox.sourceware.org/gcc-patches/87plmwyue3....@oldenburg.str.redhat.com/>

This is what the new warning produces for the input from the description:

t.c: In function ‘f0’:
t.c:5:10: warning: ISO C23 does not allow arguments for function ‘strchr’
declared without parameters [-Wdeprecated-non-prototype]
    5 |   return strchr (s, 'x');    // no warning (okay)
      |          ^~~~~~
t.c:1:7: note: declared here
    1 | char* strchr ();
      |       ^~~~~~
t.c: In function ‘f1’:
t.c:10:10: warning: ISO C23 does not allow arguments for function ‘strchr’
declared without parameters [-Wdeprecated-non-prototype]
   10 |   return strchr (s, "y");    // warning (good)
      |          ^~~~~~
t.c:1:7: note: declared here
    1 | char* strchr ();
      |       ^~~~~~
t.c:10:21: error: passing argument 2 of ‘strchr’ makes integer from pointer
without a cast [-Wint-conversion]
   10 |   return strchr (s, "y");    // warning (good)
      |                     ^~~
      |                     |
      |                     char *
t.c:1:7: note: expected ‘int’ but argument is of type ‘char *’
    1 | char* strchr ();
      |       ^~~~~~
t.c: In function ‘h’:
t.c:17:3: warning: ISO C23 does not allow arguments for function ‘g’ declared
without parameters [-Wdeprecated-non-prototype]
   17 |   g (1);                     // (presumably) okay, f's type is 'void
(int)'
      |   ^
t.c:13:6: note: declared here
   13 | void g ();
      |      ^
t.c:18:3: warning: ISO C23 does not allow arguments for function ‘g’ declared
without parameters [-Wdeprecated-non-prototype]
   18 |   g ("foo");                 // should be diagnosed
      |   ^
t.c:13:6: note: declared here
   13 | void g ();
      |      ^
t.c:19:3: warning: ISO C23 does not allow arguments for function ‘g’ declared
without parameters [-Wdeprecated-non-prototype]
   19 |   g (1, "bar");              // ditto
      |   ^
t.c:13:6: note: declared here
   13 | void g ();
      |      ^

Reply via email to