PR tree-optimization/47190: ICE on weakref missing alias info

Richard Guenther rguenther@suse.de
Mon Jan 24 17:08:00 GMT 2011


On Mon, 24 Jan 2011, Jan Hubicka wrote:

> > On Mon, 24 Jan 2011, Jan Hubicka wrote:
> > 
> > > > On Sat, 22 Jan 2011, Jan Hubicka wrote:
> > > > 
> > > > > Hi,
> > > > > this PR shows ICE on invalid
> > > > > static int i __attribute__ ((weakref));
> > > > > 
> > > > > according to docs, weakref attribute should be accompanied with an alias.
> > > > > This patch adds checking into cgraphunit.c.
> > > > > 
> > > > > Bootstrapped/regtested x86_64-linux, OK?
> > > > 
> > > > It's bad this is not possible in c-common when building the
> > > > weakref attribute.  Can't we simply ignore weakref without
> > > > alias?  That would be a tiny bit cleaner than verifying
> > > > attributes from cgraph ...
> > > Docs explicitly shows the testcase:
> > > static int x() __attribute__ ((weakref));
> > > static int x() __attribute__ ((alias ("y")));
> > > 
> > > I think whatever we do during parsing would refuse the first declaration.
> > > 
> > > Since we do this attribute finalization there anyway, I don't think it is that bad.
> > 
> > Any reason we can't ignore non-aliased weakrefs at uses?
> 
> The ICE is about fact that we drop WEAK flag on static var:
> 
>       if (lookup_attribute ("alias", DECL_ATTRIBUTES (*node)))
>         error_at (DECL_SOURCE_LOCATION (*node),
>                   "weakref attribute must appear before alias attribute");
> 
>       /* Can't call declare_weak because it wants this to be TREE_PUBLIC,
>          and that isn't supported; and because it wants to add it to
>          the list of weak decls, which isn't helpful.  */
>       DECL_WEAK (*node) = 1;
> 
> and my sanity check declares it as nonsential that it indeed is.
> So if we want to define that weakref alone is no-op (normal static var), we can
> just keep the code removing WEAK flag I added and remove the error.

Yes, I like that more.

Richard.



More information about the Gcc-patches mailing list