-Wdeclaration-after-statement doesn't do anything if combined with -std=c99 or newer.
Take a look at the following program:
// prog.c
#include <stdio.h>
int main(void)
{
printf("hello world\n"); int i = 0; return 0;
}
If I compile it with clang with the following command:
$ clang -std=c99 -Wdeclaration-after-statement prog.c
it produces no warnings.
If I compile the same code with gcc with the following command:
$ gcc -std=c99 -Wdeclaration-after-statement prog.c
it produces the following warning:
prog.c: In function ‘main’:
prog.c:6:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
6 | int i = 0; | ^~~
This is the behavior I would like to have with clang, but it only produces this warning if I use it with -std=c90 or -std=c89 or -ansi, like this:
$ clang -std=c90 -Wdeclaration-after-statement prog.c
prog.c:6:6: warning: ISO C90 forbids mixing declarations and code [-Wdeclaration-after-statement]
int i = 0; ^
1 warning generated.