diff options
author | Jan Hubicka <jh@suse.cz> | 2011-01-27 17:16:34 +0100 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2011-01-27 16:16:34 +0000 |
commit | 779d4b91eb824eb36824dee52bbcfdfe173b2753 (patch) | |
tree | 784a1770f374d75d4f9b660d04cb6a474b323f3e /gcc/cgraphunit.c | |
parent | e80b21edaebbc271cc2b3f996f51694c3c9bafe6 (diff) | |
download | gcc-779d4b91eb824eb36824dee52bbcfdfe173b2753.zip gcc-779d4b91eb824eb36824dee52bbcfdfe173b2753.tar.gz gcc-779d4b91eb824eb36824dee52bbcfdfe173b2753.tar.bz2 |
re PR middle-end/46949 (ICE when weakref is used on a definition (internal compiler error: in function_and_variable_visibility, at ipa.c:904))
PR middle-end/46949
* 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
From-SVN: r169332
Diffstat (limited to 'gcc/cgraphunit.c')
-rw-r--r-- | gcc/cgraphunit.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index 2245164..848eba6 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -804,7 +804,8 @@ process_common_attributes (tree decl) "%<weakref%> attribute should be accompanied with" " an %<alias%> attribute"); DECL_WEAK (decl) = 0; - remove_attribute ("weakref", DECL_ATTRIBUTES (decl)); + DECL_ATTRIBUTES (decl) = remove_attribute ("weakref", + DECL_ATTRIBUTES (decl)); } } @@ -860,6 +861,16 @@ process_function_and_variable_attributes (struct cgraph_node *first, 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) @@ -887,6 +898,17 @@ process_function_and_variable_attributes (struct cgraph_node *first, 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); } } |