This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
weird logic about redeclaring builtins...
- From: DJ Delorie <dj at redhat dot com>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 31 Oct 2013 12:41:44 -0400
- Subject: weird logic about redeclaring builtins...
- Authentication-results: sourceware.org; auth=none
Given the logic in c/c-decl.c's diagnose_mismatched_decls, if a
built-in function is *also* declared in a system header (which is
common with newlib), gcc fails to mention either the builtin or the
declaration if you redeclare the function as something else.
I.e. this code:
int foo();
int foo;
gives the expected "previous declaration was at ..." error, and this
code:
int index;
gives the expected "built-in function 'index' declared ..." error.
However, this code:
char *index(const char *,int);
int index;
gives neither the built-in error nor the previous-decl error. It
*only* gives the "'index' was redeclared" error.
Is this intentional? Is there an easy fix for this that works for all
cases?