[PATCH] Clean-up C's builtin function type matching.

Roger Sayle roger@eyesopen.com
Mon Jul 21 18:30:00 GMT 2003


On Mon, 21 Jul 2003, David O'Brien wrote:
> > > Consider the following program:
> > >
> > >   extern int exp;
> > >
> > >   int main() {
> > >     int sin=1;
> > >     return sin+exp;
> > >   }
> ...
> > >   x.c:1: warning: built-in function `exp' declared as non-function
> > >   x.c: In function `main':
> > >   x.c:4: warning: declaration of `sin' shadows a global declaration
> > >   <built-in>:0: warning: shadowed declaration is here
> ...
> > The warnings about `sin' are a bit more debatable.  Arguably it is bad
> > style to use the name of a standard C function as the name of a local
> > variable, if the relevant header file isn't included.  So whether this
> > change to the behaviour of -Wshadow is a regression or a progression is
> > in the eyes of the beholder.
>
> Lets just address this point for the moment -- ignoring 'exp'.  The
> FreeBSD community feels this is indead a regression.


Its not a "real" regression.  If the external symbol, you're declaring
was called "sin" or "cos", we'd issue the same warning back in 2.95.3!
The only change is that we've recently added "exp" to the list builtins
recognized by GCC.  And there's still plenty more symbols reserved by
the ISO C/C++ standards that could/should be recognized and/or warned.

I do believe there's a strong argument for -pedantic for the non-public
redeclaration, but perhaps the FreeBSD community might also consider
fixing their non-conformant usage of reserved symbols?

Roger
--



More information about the Gcc-patches mailing list