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 1:59 AM, Jan Hubicka <hubicka@ucw.cz> wrote:
> Hi,
> the testcase cause ICE in verifier on function that is both defined and has
> weakref alias. ?This seems to be nonsense, so it is better to warn on it and
> ignore the weakref
>
> Bootstrapped/regtested x86_64-linux, OK?
>
> Honza
>
> ? ? ? ?PR middle-end/46949
> ? ? ? ?* cgraphunit.c (process_function_and_variable_attributes): Warn on
> ? ? ? ?defined weakrefs.
> ? ? ? ?* gcc.dg/attr-weakref-4.c: New testcase.
> Index: cgraphunit.c
> ===================================================================
> --- cgraphunit.c ? ? ? ?(revision 169294)
> +++ cgraphunit.c ? ? ? ?(working copy)
> @@ -860,6 +860,14 @@ process_function_and_variable_attributes
> ? ? ? ? ?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;
> + ? ? ? }
> ? ? ? process_common_attributes (decl);
> ? ? }
> ? 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?

> + ? ? ? {
> + ? ? ? ? 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.

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]