This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PR tree-optimization/47190: ICE on weakref missing alias info
- From: Richard Guenther <rguenther at suse dot de>
- To: Jan Hubicka <hubicka at ucw dot cz>
- Cc: gcc-patches at gcc dot gnu dot org, jakuB at redhat dot com
- Date: Mon, 24 Jan 2011 13:40:19 +0100 (CET)
- Subject: Re: PR tree-optimization/47190: ICE on weakref missing alias info
- References: <20110122174850.GB31129@kam.mff.cuni.cz>
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 ...
Richard.
> Honza
>
> PR tree-optimization/47190
> * cgraphunit.c (process_common_attributes): New function.
> (process_function_and_variable_attributes): Use it.
> * gcc.dg/attr-weakref-3.c: New testcase.
> Index: cgraphunit.c
> ===================================================================
> --- cgraphunit.c (revision 169127)
> +++ cgraphunit.c (working copy)
> @@ -791,6 +791,23 @@ cgraph_analyze_function (struct cgraph_n
> current_function_decl = save;
> }
>
> +/* Process attributes common for vars and functions. */
> +
> +static void
> +process_common_attributes (tree decl)
> +{
> + tree weakref = lookup_attribute ("weakref", DECL_ATTRIBUTES (decl));
> +
> + if (weakref && !lookup_attribute ("alias", DECL_ATTRIBUTES (decl)))
> + {
> + error_at (DECL_SOURCE_LOCATION (decl),
> + "%<weakref%> attribute should be accompanied with"
> + " an %<alias%> attribute");
> + DECL_WEAK (decl) = 0;
> + remove_attribute ("weakref", DECL_ATTRIBUTES (decl));
> + }
> +}
> +
> /* Look for externally_visible and used attributes and mark cgraph nodes
> accordingly.
>
> @@ -843,6 +860,7 @@ process_function_and_variable_attributes
> else if (node->local.finalized)
> cgraph_mark_needed_node (node);
> }
> + process_common_attributes (decl);
> }
> for (vnode = varpool_nodes; vnode != first_var; vnode = vnode->next)
> {
> @@ -869,6 +887,7 @@ process_function_and_variable_attributes
> else if (vnode->finalized)
> varpool_mark_needed_node (vnode);
> }
> + process_common_attributes (decl);
> }
> }
>
> Index: testsuite/gcc.dg/attr-weakref-3.c
> ===================================================================
> --- testsuite/gcc.dg/attr-weakref-3.c (revision 0)
> +++ testsuite/gcc.dg/attr-weakref-3.c (revision 0)
> @@ -0,0 +1,3 @@
> +/* { dg-do compile } */
> +/* { dg-require-weak "" } */
> +static int i __attribute__ ((weakref)); /* { dg-error "should be accompanied" } */
>
>
--
Richard Guenther <rguenther@suse.de>
Novell / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 - GF: Markus Rex