From owner-freebsd-current@FreeBSD.ORG Thu Jul 17 04:37:09 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D8C1A37B401; Thu, 17 Jul 2003 04:37:09 -0700 (PDT) Received: from mailhub.fokus.fraunhofer.de (mailhub.fokus.fraunhofer.de [193.174.154.14]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3775F43F75; Thu, 17 Jul 2003 04:37:08 -0700 (PDT) (envelope-from brandt@fokus.fraunhofer.de) Received: from beagle (beagle [193.175.132.100])h6HBb1v22796; Thu, 17 Jul 2003 13:37:02 +0200 (MEST) Date: Thu, 17 Jul 2003 13:37:01 +0200 (CEST) From: Harti Brandt To: Jun Kuriyama In-Reply-To: <7mfzl74f2p.wl@black.imgsrc.co.jp> Message-ID: <20030717133313.X972@beagle.fokus.fraunhofer.de> References: <7madbg60b1.wl@black.imgsrc.co.jp> <20030715075429.M34004@beagle.fokus.fraunhofer.de> <7mfzl74f2p.wl@black.imgsrc.co.jp> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: Current Subject: Re: src/bin/ed/re.c: warning: declaration of `exp' shadows a global declaration X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Harti Brandt List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jul 2003 11:37:10 -0000 Hi, here is a somewhat crude hack, that makes the warning go away. It just prevents the warning if the shadowed symbol is a function and its source file happens to be "". Once a real declaration is seen (as in math.h) the source file will be the real source file of the declaration and the warning is emitted. There are sure better ways to do something like this... And, well, I did not make a world, just checked the example program. harti Index: c-decl.c =================================================================== RCS file: /home/ncvs/src/contrib/gcc/c-decl.c,v retrieving revision 1.8 diff -u -r1.8 c-decl.c --- c-decl.c 11 Jul 2003 05:11:14 -0000 1.8 +++ c-decl.c 17 Jul 2003 11:33:00 -0000 @@ -1637,7 +1637,9 @@ shadow_warning ("a previous local", name, oldlocal); } else if (IDENTIFIER_GLOBAL_VALUE (name) != 0 - && IDENTIFIER_GLOBAL_VALUE (name) != error_mark_node) + && IDENTIFIER_GLOBAL_VALUE (name) != error_mark_node + && (!FUNCTION_TYPE_CHECK(IDENTIFIER_GLOBAL_VALUE(name)) || + strcmp(DECL_SOURCE_FILE(IDENTIFIER_GLOBAL_VALUE(name)), "") != 0)) shadow_warning ("a global declaration", name, IDENTIFIER_GLOBAL_VALUE (name)); } On Wed, 16 Jul 2003, Jun Kuriyama wrote: JK>At Tue, 15 Jul 2003 11:54:06 -0700, JK>David O'Brien wrote: JK>> Much, much better if you can point to the specific GCC source code file JK>> where this is handled. JK> JK>May this help you? JK> JK> JK>waterblue% cat exp.c JK>int JK>main(int argc, char** argv) JK>{ JK> int exp = 5; JK> JK> return 0; JK>} JK>waterblue% cc -Wshadow -c exp.c JK>exp.c: In function `main': JK>exp.c:4: warning: declaration of `exp' shadows a global declaration JK>:0: warning: shadowed declaration is here JK> JK> JK> -- harti brandt, http://www.fokus.fraunhofer.de/research/cc/cats/employees/hartmut.brandt/private brandt@fokus.fraunhofer.de, harti@freebsd.org