fix weak-5 on alpha
Richard Henderson
rth@redhat.com
Wed May 15 17:20:00 GMT 2002
On Wed, May 15, 2002 at 08:23:31PM +0200, Franz Sirl wrote:
> Remember:
>
> extern int __cxa_atexit (void (*func) (void *), void *arg, void *d);
> extern void *__dso_handle;
> int
> atexit (void (*func) (void))
> {
> return __cxa_atexit ((void (*) (void *)) func, ((void *)0) ,
> &__dso_handle == ((void *)0) ? ((void *)0) :
> __dso_handle);
> }
> extern void *__dso_handle __attribute__((weak));
Fixed thus.
r~
* varasm.c (merge_weak): Remove special case for extern and common.
* gcc.dg/weak-5.c (vfoo1c, vfoo1g): Warn here.
Index: varasm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/varasm.c,v
retrieving revision 1.274
diff -c -p -d -r1.274 varasm.c
*** varasm.c 15 May 2002 16:50:38 -0000 1.274
--- varasm.c 16 May 2002 00:11:09 -0000
*************** merge_weak (newdecl, olddecl)
*** 4848,4863 ****
have done so in a way that will not function properly with
a weak symbol. */
else if (TREE_USED (olddecl)
! && TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (olddecl))
! /* ??? Not impossible that some platform may generate code
! that doesn't function *at all* with incorrect declaration
! before use. However, all known at present will assume
! exteral and common symbols are not "local". */
! /* ??? Probably these exceptions to the rule will just
! confuse users about the true nature of the problem and
! we should warn for *any* use before weakening. */
! && ! (DECL_EXTERNAL (olddecl)
! || DECL_COMMON (olddecl)))
warning_with_decl (newdecl, "weak declaration of `%s' after first use results in unspecified behavior");
if (SUPPORTS_WEAK)
--- 4848,4854 ----
have done so in a way that will not function properly with
a weak symbol. */
else if (TREE_USED (olddecl)
! && TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (olddecl)))
warning_with_decl (newdecl, "weak declaration of `%s' after first use results in unspecified behavior");
if (SUPPORTS_WEAK)
Index: testsuite/gcc.dg/weak-5.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/gcc.dg/weak-5.c,v
retrieving revision 1.3
diff -c -p -d -r1.3 weak-5.c
*** testsuite/gcc.dg/weak-5.c 15 May 2002 16:50:44 -0000 1.3
--- testsuite/gcc.dg/weak-5.c 16 May 2002 00:11:10 -0000
*************** void * foo1c (void)
*** 44,50 ****
{
return (void *)&vfoo1c;
}
! extern int vfoo1c __attribute__((weak));
extern int vfoo1d __attribute__((weak));
--- 44,50 ----
{
return (void *)&vfoo1c;
}
! extern int vfoo1c __attribute__((weak)); /* { dg-warning "unspecified behavior" } */
extern int vfoo1d __attribute__((weak));
*************** void * foo1f (void)
*** 68,74 ****
{
return (void *)&vfoo1f;
}
! extern int vfoo1f __attribute__((weak)); /* { dg-warning "weak declaration" "weak declaration" } */
extern int vfoo1g;
--- 68,74 ----
{
return (void *)&vfoo1f;
}
! extern int vfoo1f __attribute__((weak)); /* { dg-warning "unspecified behavior" } */
extern int vfoo1g;
*************** void * foo1g (void)
*** 76,82 ****
{
return (void *)&vfoo1g;
}
! int vfoo1g __attribute__((weak));
extern int vfoo1h __attribute__((weak));
--- 76,82 ----
{
return (void *)&vfoo1g;
}
! int vfoo1g __attribute__((weak)); /* { dg-warning "unspecified behavior" } */
extern int vfoo1h __attribute__((weak));
More information about the Gcc-patches
mailing list