PR middle-end/46949: ICE on weakrefs
Jan Hubicka
hubicka@ucw.cz
Thu Jan 27 01:47:00 GMT 2011
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)
+ {
+ warning_at (DECL_SOURCE_LOCATION (node->decl), OPT_Wattributes,
+ "%<weakref%> attribute ignored"
+ " because variable is initialized");
+ DECL_WEAK (decl) = 0;
+ }
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" } */
More information about the Gcc-patches
mailing list