When I define a function that is already declared in a system header
file (same signature, of course), all warnings are disabled not only
in that function, but any following function definitions in the same
compilation unit.

For example, with this code,

cat <<'EOF' > k.c
#include <stdlib.h>
int clearenv (void) {}
int bar (int i) { return 0; int j; return j; }
EOF

I would expect compiling with -W -Wall -Wdeclaration-after-statement
to warn about the decl-after-stmt and the unused parameter, but get
neither:

    $ gcc -O -W -Wall -Wdeclaration-after-statement -c k.c

    $ gcc --version
    gcc (GCC) 4.3.2 20081007 (Red Hat 4.3.2-6)

gcc-4.2 does what I expect:

    $ gcc-4.2 -c -O -W -Wall -Wdeclaration-after-statement random_r.c
    random_r.c: In function 'srandom_r':
    random_r.c:4: warning: unused parameter 'seed'
    random_r.c:4: warning: unused parameter 'buf'
    random_r.c: In function 'bar':
    random_r.c:15: warning: ISO C90 forbids mixed declarations and code
    random_r.c:15: warning: unused variable 'i'

FYI, just filed as:

  http://bugzilla.redhat.com/468145

Reply via email to