Date: Wed, 29 Oct 2003 16:11:05 +1100 (EST) From: Bruce Evans <bde@zeta.org.au> To: Peter Wemm <peter@wemm.org> Cc: kientzle@acm.org Subject: Re: cvs commit: src/usr.bin/chat Makefile Message-ID: <20031029155812.M8125@gamplex.bde.org> In-Reply-To: <20031029004113.D517C2A8D5@canning.wemm.org> References: <20031029004113.D517C2A8D5@canning.wemm.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 28 Oct 2003, Peter Wemm wrote: > Tim Kientzle wrote: > > > On Sat, 25 Oct 2003, Peter Wemm wrote: > > >>peter 2003/10/25 21:49:58 PDT > > >> > > >> FreeBSD src repository > > >> > > >> Modified files: > > >> usr.bin/chat Makefile > > >> Log: > > >> The math function logf() probably isn't doing us much good for logging > > >> stuff. Add -fno-builtin-logf. > > > > Rather than commit ugly Makefile hacks like > > this, just rename the damned function and > > be done with it. > > Be my guest. Be sure to get your changes are sent back to the vendor, or > that the vendor has fixed it already. This is not what you asked for, but here is a quick fix for the main bugs in -Wshadow. It has not been sent to the vendor or built the world. It doesn't affect chat unless chat is compiled with a C90 compiler (so that <math.h> doesn't declare logf()), since chat bogusly declares logf() as global. %%% Index: c-decl.c =================================================================== RCS file: /home/ncvs/src/contrib/gcc/c-decl.c,v retrieving revision 1.9 diff -u -2 -r1.9 c-decl.c --- c-decl.c 22 Aug 2003 03:14:37 -0000 1.9 +++ c-decl.c 29 Oct 2003 04:57:16 -0000 @@ -977,5 +977,7 @@ built-in definition is overridden, but optionally warn this was a bad choice of name. */ - if (warn_shadow) + /* XXX Actually only warn if the built-in is declared somewhere + other than in the compiler. */ + if (warn_shadow && DECL_SOURCE_LINE (olddecl) != 0) warning_with_decl (newdecl, "shadowing built-in function `%s'"); /* Discard the old built-in function. */ @@ -1647,5 +1649,8 @@ } else if (IDENTIFIER_GLOBAL_VALUE (name) != 0 - && IDENTIFIER_GLOBAL_VALUE (name) != error_mark_node) + && IDENTIFIER_GLOBAL_VALUE (name) != error_mark_node + /* XXX No shadow warnings for shadowing built-ins that are + not declared somewhere other than in the compiler. */ + && DECL_SOURCE_LINE (IDENTIFIER_GLOBAL_VALUE (name)) != 0) shadow_warning ("a global declaration", name, IDENTIFIER_GLOBAL_VALUE (name)); %%% Test program: %%% #ifdef DECLARE_MATH_FUNCTIONS #include <math.h> #endif /* This shouldn't shadow log() unless math.h is included. */ static int log(double x) { return (x); } int main(void) { /* This shouldn't shadow logf() unless math.h is included. */ int logf; logf = 1; return (logf); } %%% Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20031029155812.M8125>