public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Franz Sirl <Franz.Sirl-kernel@lauterbach.com>
To: Alan Modra <amodra@bigpond.net.au>
Cc: Mark Mitchell <mark@codesourcery.com>,gcc@gcc.gnu.org,
	Jason Merrill <jason@redhat.com>,rth@redhat.com
Subject: Re: GCC 3.1 Prerelease
Date: Tue, 23 Apr 2002 10:40:00 -0000	[thread overview]
Message-ID: <5.1.1.2.2.20020423190859.04dc6b88@mail.lauterbach.com> (raw)
In-Reply-To: <20020423111326.GI31160@bubble.sa.bigpond.net.au>

[-- Attachment #1: Type: text/plain, Size: 1376 bytes --]

At 13:13 23.04.2002, Alan Modra wrote:
>On Tue, Apr 23, 2002 at 01:04:39PM +0200, Franz Sirl wrote:
> > At 12:28 23.04.2002, Alan Modra wrote:
> > >On Tue, Apr 23, 2002 at 02:01:25AM -0700, Mark Mitchell wrote:
> > >>
> > >> Joseph, if you have time to look at PR 6343 (C front end regression
> > >> involving "attribute((weak))"), please do so.  I can imagine this
> > >> being a significant problem.
> > >
> > >I've been using this, which at least cures the problem with
> > >__register_frame_info*.  Credit for the patch goes to Franz Sirl.
> >
> > Hmm, have you tried recompiling glibc with this patch? I seem to recall
> > glibc using constructs that would produce an error now.
>
>I've been compiling a glibc snapshot with a last ChangeLog entry of
>2002-01-18  Andreas Schwab  <schwab@suse.de>

OK, try compiling glibc with the attached patch, it should give you some 
warnings :-).

What do you all think about this patch? It covers all the cases I could 
think of, but maybe I missed something. Please take a close look at my 
changes to declare_weak, I'm not too sure my DECL checking is 100% 
correct/allowed. Can someone think of a better warning message? And what 
about a merge_weak() function (naming? in which file?) instead of 
duplicating the code?

The testcases are planned for the dg framework, but I haven't added all the 
dg funkiness yet :-).

Franz.


[-- Attachment #2: gcc-weaksym-4.patch --]
[-- Type: application/octet-stream, Size: 3000 bytes --]

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 16:51:11 -0000
@@ -1955,7 +1955,16 @@ 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);
+  if (DECL_WEAK (newdecl) && DECL_RTL (newdecl)
+      && GET_CODE (DECL_RTL (newdecl)) == MEM
+      && XEXP (DECL_RTL (newdecl), 0)
+      && GET_CODE (XEXP (DECL_RTL (newdecl), 0)) == SYMBOL_REF)
+    SYMBOL_REF_WEAK (XEXP (DECL_RTL (newdecl), 0)) = 1;
+
   /* 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 16:51:11 -0000
@@ -4998,12 +4998,14 @@ 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_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");
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 16:51:12 -0000
@@ -3645,7 +3645,16 @@ 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);
+  if (DECL_WEAK (newdecl) && DECL_RTL (newdecl)
+      && GET_CODE (DECL_RTL (newdecl)) == MEM
+      && XEXP (DECL_RTL (newdecl), 0)
+      && GET_CODE (XEXP (DECL_RTL (newdecl), 0)) == SYMBOL_REF)
+    SYMBOL_REF_WEAK (XEXP (DECL_RTL (newdecl), 0)) = 1;
+
   DECL_ONE_ONLY (newdecl) |= DECL_ONE_ONLY (olddecl);
   DECL_DEFER_OUTPUT (newdecl) |= DECL_DEFER_OUTPUT (olddecl);
   TREE_PUBLIC (newdecl) = TREE_PUBLIC (olddecl);

[-- Attachment #3: weak-2.c --]
[-- Type: text/plain, Size: 2508 bytes --]


// test function addresses with __attribute__((weak))
extern void * ffoo1a (void) __attribute__((weak));
extern void * ffoo1a (void);
void * foo1a (void)
{
  return (void *)ffoo1a;
}

extern void * ffoo2a (void);
extern void * ffoo2a (void) __attribute__((weak));
void * foo2a (void)
{
  return (void *)ffoo2a;
}

extern void * ffoo3a (void);
void * foo3a (void)
{
  return (void *)ffoo3a;
}
extern void * ffoo3a (void) __attribute__((weak));



// test function addresses with #pragma weak
#pragma weak ffoo1b
extern void * ffoo1b (void);
void * foo1b (void)
{
  return (void *)ffoo1b;
}

extern void * ffoo2b (void);
#pragma weak ffoo2b
void * foo2b (void)
{
  return (void *)ffoo2b;
}

extern void * ffoo3b (void);
void * foo3b (void)
{
  return (void *)ffoo3b;
}
#pragma weak ffoo3b




// test variable addresses with __attribute__((weak))
extern int vfoo1c __attribute__((weak));
extern int vfoo1c;
void * foo1c (void)
{
  return (void *)&vfoo1c;
}

extern int vfoo2c;
extern int vfoo2c __attribute__((weak));
void * foo2c (void)
{
  return (void *)&vfoo2c;
}

extern int vfoo3c;
void * foo3c (void)
{
  return (void *)&vfoo3c;
}
extern int vfoo3c __attribute__((weak));

extern int vfoo4c __attribute__((weak));
int vfoo4c;
void * foo4c (void)
{
  return (void *)&vfoo4c;
}

int vfoo5c;
extern int vfoo5c __attribute__((weak));
void * foo5c (void)
{
  return (void *)&vfoo5c;
}

int vfoo6c;
void * foo6c (void)
{
  return (void *)&vfoo6c;
}
extern int vfoo6c __attribute__((weak));

extern int vfoo7c;
void * foo7c (void)
{
  return (void *)&vfoo7c;
}
int vfoo7c __attribute__((weak));

extern int vfoo8c __attribute__((weak));
void * foo8c (void)
{
  return (void *)&vfoo8c;
}
extern int vfoo8c __attribute__((weak));
int vfoo8c;


// test variable addresses with #pragma weak
#pragma weak vfoo1d
extern int vfoo1d;
void * foo1d (void)
{
  return (void *)&vfoo1d;
}

extern int vfoo2d;
#pragma weak vfoo2d
void * foo2d (void)
{
  return (void *)&vfoo2d;
}

extern int vfoo3d;
void * foo3d (void)
{
  return (void *)&vfoo3d;
}
#pragma weak vfoo3d

#pragma weak vfoo4d
int vfoo4d;
void * foo4d (void)
{
  return (void *)&vfoo4d;
}

int vfoo5d;
#pragma weak vfoo5d
void * foo5d (void)
{
  return (void *)&vfoo5d;
}

int vfoo6d;
void * foo6d (void)
{
  return (void *)&vfoo6d;
}
#pragma weak vfoo6d

extern int vfoo7d;
void * foo7d (void)
{
  return (void *)&vfoo7d;
}
#pragma weak vfoo7d
int vfoo7d;

extern int vfoo8d;
void * foo8d (void)
{
  return (void *)&vfoo8d;
}
int vfoo8d;
#pragma weak vfoo8d

[-- Attachment #4: weak-3.c --]
[-- Type: text/plain, Size: 120 bytes --]



extern void * foo (void);
void * foo (void)
{
  return (void *)foo;
}
extern void * foo (void) __attribute__((weak));

[-- Attachment #5: weak-4.c --]
[-- Type: text/plain, Size: 89 bytes --]



extern void * foo (void);
void * foo (void)
{
  return (void *)foo;
}
#pragma weak foo

  reply	other threads:[~2002-04-23 17:30 UTC|newest]

Thread overview: 100+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-23  2:12 Mark Mitchell
2002-04-23  3:53 ` Alan Modra
2002-04-23  4:13   ` Franz Sirl
2002-04-23  4:32     ` Alan Modra
2002-04-23 10:40       ` Franz Sirl [this message]
2002-04-23 11:42         ` Richard Henderson
2002-04-23 15:08           ` Franz Sirl
2002-04-23 15:10             ` Richard Henderson
2002-04-24 10:56             ` Jason Merrill
2002-04-24 12:04               ` Franz Sirl
2002-04-24 13:03                 ` Richard Henderson
2002-04-24 13:14                 ` Jason Merrill
2002-04-25 12:57                   ` [PATCH] Fix PR c/6343 (was: Re: GCC 3.1 Prerelease) Franz Sirl
2002-04-25 12:59                     ` Jason Merrill
2002-04-28  8:44                       ` Franz Sirl
2002-04-28 11:59                         ` Mark Mitchell
2002-04-28 15:00                         ` Jason Merrill
2002-04-28 16:36                           ` Mark Mitchell
2002-04-29 11:36                           ` Franz Sirl
2002-04-30  6:20                             ` Jason Merrill
2002-04-30  9:40                               ` Mark Mitchell
2002-04-23 12:22         ` GCC 3.1 Prerelease Jason Merrill
2002-04-23  9:08 ` Per Bothner
2002-04-23  9:30   ` Mark Mitchell
2002-04-23 10:12     ` Per Bothner
2002-04-23 13:25       ` Mark Mitchell
2002-04-23 14:52       ` Tom Tromey
2002-04-23 15:02         ` Per Bothner
2002-04-23 16:11           ` Tom Tromey
2002-04-24 10:14             ` Alexandre Petit-Bianco
2002-04-24 10:30               ` Tom Tromey
2002-04-24 10:32                 ` Mark Mitchell
2002-04-23 13:19 ` Richard Henderson
2002-04-23 13:28   ` Mark Mitchell
2002-04-23 13:35     ` Richard Henderson
2002-04-23 13:50       ` Mark Mitchell
2002-04-23 13:52         ` Richard Henderson
2002-04-23 16:30         ` mips n64 eh failures Richard Henderson
2002-04-23 16:53           ` Mark Mitchell
2002-04-23 16:59             ` Richard Henderson
2002-04-23 18:00               ` Richard Henderson
2002-04-23 18:20                 ` Richard Henderson
2002-04-23 19:35                   ` Richard Henderson
2002-04-24  9:08                     ` Mark Mitchell
  -- strict thread matches above, loose matches on Subject: below --
2002-04-23 14:56 GCC 3.1 Prerelease Tom Tromey
2002-04-23 13:38 GCC 3.1 prerelease Mark Mitchell
2002-04-23 18:37 ` Kurt Wall
2002-04-23 19:23   ` Phil Edwards
2002-04-24  9:49   ` Mark Mitchell
2002-04-24 11:03     ` Joseph S. Myers
2002-04-24 19:03       ` Kurt Wall
2002-04-23 10:46 GCC 3.1 Prerelease Paolo Carlini
2002-04-22 20:00 Billinghurst, David (CRTS)
2002-04-22  4:07 Wolfgang Bangerth
2002-04-22  0:07 Toon Moene
2002-04-20 20:09 John David Anglin
2002-04-20 21:44 ` Mark Mitchell
2002-04-23 12:19   ` John David Anglin
2002-04-21  7:06 ` Toon Moene
2002-04-21 12:57   ` Mark Mitchell
2002-04-21 13:50     ` Franz Sirl
2002-04-22  3:20       ` Gerald Pfeifer
2002-04-22 10:50       ` Franz Sirl
2002-04-22 10:56         ` Mark Mitchell
2002-04-21 20:54     ` John David Anglin
2002-04-22  0:13     ` Richard Henderson
2002-04-22  7:48       ` Mark Mitchell
     [not found] <FAC87D7C874EAB46A847604DA4FD5A640346FC@crtsmail.corp.riotinto.o rg>
2002-04-20 20:05 ` Billinghurst, David (CRTS)
2002-04-20 20:16   ` Mark Mitchell
     [not found] <Pine.LNX.4.30.0204210235010.13395-100000@snake.iap.physik.tu-da rmstadt.de>
2002-04-20 17:16 ` Peter Schmid
2002-04-20 17:57   ` Mark Mitchell
2002-04-21 14:16     ` Richard Henderson
2002-04-21 16:54       ` Mark Mitchell
2002-04-23  5:46         ` Jason Merrill
2002-04-23  9:12           ` Mark Mitchell
2002-04-20 13:08 Mark Mitchell
2002-04-20 13:51 ` Stan Shebs
2002-04-20 14:07   ` Mark Mitchell
2002-04-20 16:10   ` Joel Sherrill
2002-04-20 13:56 ` Joseph S. Myers
2002-04-20 13:59   ` Mark Mitchell
2002-04-20 14:36 ` Jakub Jelinek
2002-04-20 17:17   ` Mark Mitchell
2002-04-23  9:49     ` Jakub Jelinek
2002-04-24 10:07       ` Mark Mitchell
2002-04-20 16:35 ` Tom Tromey
2002-04-20 17:28   ` Mark Mitchell
2002-04-20 19:04 ` David S. Miller
2002-04-20 20:08   ` Mark Mitchell
2002-04-20 20:13     ` David S. Miller
2002-04-20 20:18       ` Per Bothner
2002-04-21 11:27         ` Tom Tromey
2002-04-20 20:45       ` Mark Mitchell
2002-04-20 22:09 ` Alan Modra
2002-04-21  3:47 ` Gerald Pfeifer
2002-04-23  8:24   ` Gerald Pfeifer
2002-04-23  9:13     ` Mark Mitchell
2002-04-23  9:36       ` Joe Buck
2002-04-23 14:21         ` Gerald Pfeifer
2002-04-21  8:16 ` Andreas Schwab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5.1.1.2.2.20020423190859.04dc6b88@mail.lauterbach.com \
    --to=franz.sirl-kernel@lauterbach.com \
    --cc=amodra@bigpond.net.au \
    --cc=gcc@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=mark@codesourcery.com \
    --cc=rth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).