Consider this source: extern char *index(const char *,int); static int index;
"index" is a builtin as well, but because it's a builtin gcc skips the "previous declaration was here..." despite having *a* previous decl it could complain about. Note that newlib provides decls for many builtins (the decl above is from newlib), so this could be a common case. So I added a check for !C_DECL_DECLARED_BUILTIN (decl) which seems to specifically cover this case. Ok to apply? * c-decl.c (locate_old_decl): If a previous conflicting decl is both explicit and builtin, print the location of the explicit one. Index: c-decl.c =================================================================== --- c-decl.c (revision 204300) +++ c-decl.c (working copy) @@ -1630,13 +1630,14 @@ validate_proto_after_old_defn (tree newd /* Subroutine of diagnose_mismatched_decls. Report the location of DECL, first in a pair of mismatched declarations, using the diagnostic function DIAG. */ static void locate_old_decl (tree decl) { - if (TREE_CODE (decl) == FUNCTION_DECL && DECL_BUILT_IN (decl)) + if (TREE_CODE (decl) == FUNCTION_DECL && DECL_BUILT_IN (decl) + && !C_DECL_DECLARED_BUILTIN (decl)) ; else if (DECL_INITIAL (decl)) inform (input_location, "previous definition of %q+D was here", decl); else if (C_DECL_IMPLICIT (decl)) inform (input_location, "previous implicit declaration of %q+D was here", decl); else