This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PR middle-end/46949: ICE on weakrefs


> > ? for (vnode = varpool_nodes; vnode != first_var; vnode = vnode->next)
> > @@ -887,6 +895,14 @@ process_function_and_variable_attributes
> > ? ? ? ? ?else if (vnode->finalized)
> > ? ? ? ? ? ?varpool_mark_needed_node (vnode);
> > ? ? ? ?}
> > + ? ? ?if (lookup_attribute ("weakref", DECL_ATTRIBUTES (decl))
> > + ? ? ? ? && vnode->finalized)
> 
> your testcase has a function and you test vnode?

Yes, there is typo. I fixed it and also added DECL_INITIAL(decl) != NULL
to handle darwin that finalize BSS.

> 
> > + ? ? ? {
> > + ? ? ? ? warning_at (DECL_SOURCE_LOCATION (node->decl), OPT_Wattributes,
> > + ? ? ? ? ? ? ? ? ? ? "%<weakref%> attribute ignored"
> > + ? ? ? ? ? ? ? ? ? ? " because variable is initialized");
> > + ? ? ? ? DECL_WEAK (decl) = 0;
> 
> What if the function has __attribute__((weak,weakref))?  Then the
> above is wrong as we want to retain the weak but not the weakref.

You can't have this, since weak is allowed only on public, while weakref
only on static vars.

Honza
> 
> Richard.
> 
> > + ? ? ? }
> > ? ? ? process_common_attributes (decl);
> > ? ? }
> > ?}
> > Index: testsuite/gcc.dg/attr-weakref-4.c
> > ===================================================================
> > --- testsuite/gcc.dg/attr-weakref-4.c ? (revision 0)
> > +++ testsuite/gcc.dg/attr-weakref-4.c ? (revision 0)
> > @@ -0,0 +1,3 @@
> > +/* { dg-do compile } */
> > +/* { dg-require-weak "" } */
> > +static void __attribute__((weakref("bar"))) foo(void) { } /* { dg-warning "attribute ignored because function is defined" } */
> >


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]