Prototypes for static functions that aren't used in between the prototype and the actual static function definition are useless and could be cleaned up, I think gcc itself has thousands of such useless prototypes. It isn't hard to add a warning for this. Given: static void foo (int); #ifdef D void bar (void) { foo (0); } #endif static void foo (int x) { x++; } void baz (void) { foo (0); } we'd warn about the foo prototype (unless compiling with -DD).
Created attachment 20367 [details] gcc46-pr43728.patch Quick patch, so far without documentation and testsuite and almost untested.
*** Bug 36195 has been marked as a duplicate of this bug. ***
If you are going to add such a warning, please be more explicit. I suggest: "redundant prototype for static function %qD because it is never used before its definition"
...and then after removing the prototype, compiling with -DD would fail. I don't object to having such a flag, but I don't think we want it in -Wall.
-Wredundant-decls is a non-default warning already, not enabled with -Wall nor -W and I certainly don't want to enable it by default.
Created attachment 20378 [details] gcc46-pr43728.patch Updated patch. There are still cases I'm unsure about. E.g. for: static void g (); void f() { void g(); g(); } void g() { } int main () { f (); } with -Wredundant-decls=2 in C we complain (even with -Wredundant-decls alone and before the patch) that void g(); in f function is redundant declaration, but in C++ we don't and instead with -Wredundant-decls=2 the warning newly diagnoses the first static void g (); prototype as redundant (in this case it isn't, because it affects whether void g (); in the subroutine is static or not). Not sure why TREE_USED isn't set in C++ case during the g call in f, Jason?
Presumably TREE_USED isn't set on the global declaration because the call uses the local one. And the local declaration might not be redundant if the programmer is using it to suppress argument-dependent lookup.
Confirmed, although I probably wouldn't use such a warning myself if it were added. (I like redundancy)
(In reply to Eric Gallager from comment #8) > Confirmed, although I probably wouldn't use such a warning myself if it were > added. (I like redundancy) Do people still want this? Putting in WAITING for someone to re-confirm.
(In reply to Eric Gallager from comment #9) > (In reply to Eric Gallager from comment #8) > > Confirmed, although I probably wouldn't use such a warning myself if it were > > added. (I like redundancy) > > Do people still want this? Putting in WAITING for someone to re-confirm. No reply, I guess no one really wants this after all.