From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5547 invoked by alias); 29 Apr 2002 17:58:55 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 5489 invoked from network); 29 Apr 2002 17:58:33 -0000 Received: from unknown (HELO linuxpc1.lauterbach.com) (213.70.137.66) by sources.redhat.com with SMTP; 29 Apr 2002 17:58:33 -0000 Received: (qmail 4000 invoked by uid 82); 29 Apr 2002 17:58:30 -0000 Received: from Franz.Sirl-kernel@lauterbach.com by linuxpc1.lauterbach.com with qmail-scanner-1.01 (inocmd32: /. . Clean. Processed in 0.828732 secs); 29 Apr 2002 17:58:30 -0000 Received: from dsl-213-023-062-210.arcor-ip.net (HELO enzo) (213.23.62.210) by linuxpc1.lauterbach.com with SMTP; 29 Apr 2002 17:58:29 -0000 Content-Type: text/plain; charset="iso-8859-1" From: Franz Sirl To: Jason Merrill Subject: Re: [PATCH] Fix PR c/6343 (was: Re: GCC 3.1 Prerelease) Date: Mon, 29 Apr 2002 11:36:00 -0000 Cc: gcc-patches@gcc.gnu.org, Richard Henderson , Alan Modra , Mark Mitchell , gcc@gcc.gnu.org References: <5.1.1.2.2.20020423130143.04a21008@mail.lauterbach.com> <200204281640.27693@enzo.bigblue.local> In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200204291959.42699@enzo.bigblue.local> X-SW-Source: 2002-04/txt/msg01568.txt.bz2 On Sunday 28 April 2002 23:57, Jason Merrill wrote: > >>>>> "Franz" == Franz Sirl writes: > > > > + if (SUPPORTS_WEAK > > + && DECL_EXTERNAL (newdecl) && DECL_EXTERNAL (olddecl) > > + && (TREE_CODE (decl) != VAR_DECL > > + || ! TREE_STATIC (decl)) > > + && TREE_USED (decl) > > + && TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))) > > + warning_with_decl (decl, "weak declaration of `%s' after first use > > may result in unspecified behaviour"); > > I intended that TREE_SYMBOL_REFERENCED should be used rather than > TREE_USED, not in addition. I'd probably check DECL_ASSEMBLER_NAME_SET_P > here, too; if the name hasn't been generated, it hasn't been referenced. > Perhaps we want a new macro, say > > #define DECL_SYMBOL_REFERENCED(DECL) \ > (DECL_ASSEMBLER_NAME_SET_P (DECL) \ > && TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (DECL))) But this would warn for these cases, which I think isn't correct: // case 1 extern void * ffoo1g (void); extern void * ffoox1g (void); extern void * ffoo1g (void) __attribute__((weak, alias ("ffoox1g"))); void * foo1g (void) { if (ffoo1g) ffoo1g (); return 0; } // case 2 extern int vfoo1i __attribute__((weak)); void * foo1i (void) { return (void *)&vfoo1i; } extern int vfoo1i __attribute__((weak)); extern int vfoo1i; // case 3 extern int vfoo1j __attribute__((weak)); void * foo1j (void) { return (void *)&vfoo1j; } extern int vfoo1j; extern int vfoo1j __attribute__((weak)); Actually, looking at handle_alias_attribute(), TREE_USED is exactly the flag to test here. The addition of DECL_ASSEMBLER_NAME_SET_P seems reasonable though. What do you think? Franz.