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


On Thu, Jan 27, 2011 at 2:16 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
>>
>> static int bss __attribute__((weakref)) = 0;
>>
>> ? ?How's that not a definition? ;)
>
> This case is diagnose as definition (DECL_INITIAL is non-NULL). ?Previous patch
> was bogusly warning at
> static int bss __attribute__((weakref));
> Even these vars are finalized, it is not darwin specific. I confused myself.
>
> However we get double warning, this is because one needs to use
> DECL_ATTRIBUTES (decl) = remove_attribute (...)
> instead of just remove_attribute to properly update linked list.
>
> Here is updated patch, it also fixes attribute removal in my previous patch.
>
> Bootstrapped/regtested x86_64-linux,
> OK?

Ok.

Thanks,
Richard.

> Honza
>
> ? ? ? ?* cgraphunit.c (process_common_attributes): Fix use of remove_attribute.
> ? ? ? ?(process_function_and_variable_attributes): Check defined weakrefs.
> ? ? ? ?* gcc.dg/attr-weakref-4.c: New testcase
> Index: cgraphunit.c
> ===================================================================
> *** cgraphunit.c ? ? ? ?(revision 169294)
> --- cgraphunit.c ? ? ? ?(working copy)
> *************** process_common_attributes (tree decl)
> *** 804,810 ****
> ? ? ? ? ? ? ? ? ?"%<weakref%> attribute should be accompanied with"
> ? ? ? ? ? ? ? ? ?" an %<alias%> attribute");
> ? ? ? ?DECL_WEAK (decl) = 0;
> ! ? ? ? remove_attribute ("weakref", DECL_ATTRIBUTES (decl));
> ? ? ?}
> ?}
>
> --- 804,811 ----
> ? ? ? ? ? ? ? ? ?"%<weakref%> attribute should be accompanied with"
> ? ? ? ? ? ? ? ? ?" an %<alias%> attribute");
> ? ? ? ?DECL_WEAK (decl) = 0;
> ! ? ? ? DECL_ATTRIBUTES (decl) = remove_attribute ("weakref",
> ! ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?DECL_ATTRIBUTES (decl));
> ? ? ?}
> ?}
>
> *************** process_function_and_variable_attributes
> *** 860,865 ****
> --- 861,876 ----
> ? ? ? ? ?else if (node->local.finalized)
> ? ? ? ? ? ? cgraph_mark_needed_node (node);
> ? ? ? ?}
> + ? ? ? if (lookup_attribute ("weakref", DECL_ATTRIBUTES (decl))
> + ? ? ? ? && node->local.finalized)
> + ? ? ? {
> + ? ? ? ? warning_at (DECL_SOURCE_LOCATION (node->decl), OPT_Wattributes,
> + ? ? ? ? ? ? ? ? ? ? "%<weakref%> attribute ignored"
> + ? ? ? ? ? ? ? ? ? ? " because function is defined");
> + ? ? ? ? DECL_WEAK (decl) = 0;
> + ? ? ? ? DECL_ATTRIBUTES (decl) = remove_attribute ("weakref",
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?DECL_ATTRIBUTES (decl));
> + ? ? ? }
> ? ? ? ?process_common_attributes (decl);
> ? ? ?}
> ? ?for (vnode = varpool_nodes; vnode != first_var; vnode = vnode->next)
> *************** process_function_and_variable_attributes
> *** 887,892 ****
> --- 898,914 ----
> ? ? ? ? ?else if (vnode->finalized)
> ? ? ? ? ? ?varpool_mark_needed_node (vnode);
> ? ? ? ?}
> + ? ? ? if (lookup_attribute ("weakref", DECL_ATTRIBUTES (decl))
> + ? ? ? ? && vnode->finalized
> + ? ? ? ? && DECL_INITIAL (decl))
> + ? ? ? {
> + ? ? ? ? warning_at (DECL_SOURCE_LOCATION (vnode->decl), OPT_Wattributes,
> + ? ? ? ? ? ? ? ? ? ? "%<weakref%> attribute ignored"
> + ? ? ? ? ? ? ? ? ? ? " because variable is initialized");
> + ? ? ? ? DECL_WEAK (decl) = 0;
> + ? ? ? ? DECL_ATTRIBUTES (decl) = remove_attribute ("weakref",
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? DECL_ATTRIBUTES (decl));
> + ? ? ? }
> ? ? ? ?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 ****
> --- 1,4 ----
> + /* { dg-do compile } */
> + /* { dg-require-weak "" } */
> + static void __attribute__((weakref("bar"))) foo(void) { } /* { dg-warning "attribute ignored because function is defined" } */
> + static int __attribute__((weakref)) a=0; /* { dg-warning "attribute ignored because variable is initialized" } */
>


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