From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12283 invoked by alias); 23 Apr 2002 22:02:42 -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 12177 invoked from network); 23 Apr 2002 22:02:35 -0000 Received: from unknown (HELO linuxpc1.lauterbach.com) (213.70.137.66) by sources.redhat.com with SMTP; 23 Apr 2002 22:02:35 -0000 Received: (qmail 19240 invoked by uid 82); 23 Apr 2002 22:02:33 -0000 Received: from Franz.Sirl-kernel@lauterbach.com by linuxpc1.lauterbach.com with qmail-scanner-1.01 (inocmd32: /. . Clean. Processed in 1.154988 secs); 23 Apr 2002 22:02:33 -0000 Received: from dsl-213-023-060-071.arcor-ip.net (HELO enzo) (213.23.60.71) by linuxpc1.lauterbach.com with SMTP; 23 Apr 2002 22:02:32 -0000 From: Franz Sirl To: Richard Henderson Subject: Re: GCC 3.1 Prerelease Date: Tue, 23 Apr 2002 15:08:00 -0000 Cc: Alan Modra , Mark Mitchell , gcc@gcc.gnu.org, Jason Merrill References: <5.1.1.2.2.20020423130143.04a21008@mail.lauterbach.com> <5.1.1.2.2.20020423190859.04dc6b88@mail.lauterbach.com> <20020423110433.A728@redhat.com> In-Reply-To: <20020423110433.A728@redhat.com> MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="------------Boundary-00=_6YJ1J2WSLG12YBD6X8BE" Message-Id: <200204240003.42142@enzo.bigblue.local> X-SW-Source: 2002-04/txt/msg01204.txt.bz2 --------------Boundary-00=_6YJ1J2WSLG12YBD6X8BE Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Content-length: 1548 On Tuesday 23 April 2002 20:04, Richard Henderson wrote: > On Tue, Apr 23, 2002 at 07:28:22PM +0200, Franz Sirl wrote: > > What do you all think about this patch? It covers all the cases I could > > think of, but maybe I missed something. > > I don't see why functions should be singled out in having to have > the weakening before the definition. Hmm, I didn't want to get too aggressive in here (declare_weak wasn't called for VAR_DECLs before) and judging from the comments in tree.h it looks like TREE_ASM_WRITTEN has a slightly different meaning for a VAR_DECL. But if you think it's OK, I'll happily change it. Looking at the warnings in glibc it turned out I was already too aggressive, the patch would warn for: extern double strtod (__const char *__restrict __nptr, char **__restrict __endptr); extern double __strtod_internal (__const char *__restrict __nptr, char **__restrict __endptr, int __group); extern __inline double strtod (__const char *__restrict __nptr, char **__restrict __endptr) { return __strtod_internal (__nptr, __endptr, 0); } extern __inline double atof (__const char *__nptr) { return strtod (__nptr, (char **) ((void *)0)); } double __attribute__ ((weak)) strtod (nptr, endptr) const char *nptr; char **endptr; { return __strtod_internal (nptr, endptr, 0 ); } I don't think we want a warning here for strtod? Appended an updated patch with Jason's suggestions integrated as well. I'll run a few more tests tomorrow. Franz. --------------Boundary-00=_6YJ1J2WSLG12YBD6X8BE Content-Type: text/plain; charset="iso-8859-1"; name="gcc-weaksym-5.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="gcc-weaksym-5.patch" Content-length: 2826 Index: gcc/c-decl.c =================================================================== RCS file: /cvsroot/gcc/gcc/gcc/c-decl.c,v retrieving revision 1.300.2.5 diff -u -p -r1.300.2.5 c-decl.c --- gcc/c-decl.c 28 Mar 2002 18:49:57 -0000 1.300.2.5 +++ gcc/c-decl.c 23 Apr 2002 21:41:28 -0000 @@ -1955,7 +1955,11 @@ duplicate_decls (newdecl, olddecl, diffe } /* Merge the storage class information. */ - DECL_WEAK (newdecl) |= DECL_WEAK (olddecl); + if (DECL_WEAK (newdecl) && !DECL_WEAK (olddecl)) + declare_weak (olddecl); + if (!DECL_WEAK (newdecl) && DECL_WEAK (olddecl)) + declare_weak (newdecl); + /* For functions, static overrides non-static. */ if (TREE_CODE (newdecl) == FUNCTION_DECL) { Index: gcc/varasm.c =================================================================== RCS file: /cvsroot/gcc/gcc/gcc/varasm.c,v retrieving revision 1.250.2.7 diff -u -p -r1.250.2.7 varasm.c --- gcc/varasm.c 25 Mar 2002 00:54:26 -0000 1.250.2.7 +++ gcc/varasm.c 23 Apr 2002 21:41:28 -0000 @@ -4998,17 +4998,25 @@ declare_weak (decl) { if (! TREE_PUBLIC (decl)) error_with_decl (decl, "weak declaration of `%s' must be public"); - else if (TREE_ASM_WRITTEN (decl)) + else if (TREE_CODE (decl) == FUNCTION_DECL && TREE_ASM_WRITTEN (decl)) error_with_decl (decl, "weak declaration of `%s' must precede definition"); else if (SUPPORTS_WEAK) { if (! DECL_WEAK (decl)) weak_decls = tree_cons (NULL, decl, weak_decls); + if (TREE_CODE (decl) != FUNCTION_DECL && TREE_USED (decl)) + warning_with_decl (decl, "weak declaration of `%s' after first use may result in unspecified behaviour"); } else warning_with_decl (decl, "weak declaration of `%s' not supported"); DECL_WEAK (decl) = 1; + + if (DECL_RTL_SET_P (decl) + && GET_CODE (DECL_RTL (decl)) == MEM + && XEXP (DECL_RTL (decl), 0) + && GET_CODE (XEXP (DECL_RTL (decl), 0)) == SYMBOL_REF) + SYMBOL_REF_WEAK (XEXP (DECL_RTL (decl), 0)) = 1; } /* Emit any pending weak declarations. */ Index: gcc/cp/decl.c =================================================================== RCS file: /cvsroot/gcc/gcc/gcc/cp/decl.c,v retrieving revision 1.866.2.23 diff -u -p -r1.866.2.23 decl.c --- gcc/cp/decl.c 16 Apr 2002 03:15:54 -0000 1.866.2.23 +++ gcc/cp/decl.c 23 Apr 2002 21:41:28 -0000 @@ -3645,7 +3645,11 @@ duplicate_decls (newdecl, olddecl) } /* Merge the storage class information. */ - DECL_WEAK (newdecl) |= DECL_WEAK (olddecl); + if (DECL_WEAK (newdecl) && !DECL_WEAK (olddecl)) + declare_weak (olddecl); + if (!DECL_WEAK (newdecl) && DECL_WEAK (olddecl)) + declare_weak (newdecl); + DECL_ONE_ONLY (newdecl) |= DECL_ONE_ONLY (olddecl); DECL_DEFER_OUTPUT (newdecl) |= DECL_DEFER_OUTPUT (olddecl); TREE_PUBLIC (newdecl) = TREE_PUBLIC (olddecl); --------------Boundary-00=_6YJ1J2WSLG12YBD6X8BE--