diff options
author | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-01-26 14:03:54 +0000 |
---|---|---|
committer | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-01-26 14:03:54 +0000 |
commit | d05db70d8219033f331cd398a1498082eaf2d018 (patch) | |
tree | 23e86173693e6e051ef3662dcfc23b2dff6f5b46 /gcc/cgraphunit.c | |
parent | 031c6e7df2af54ffe70ece1e9a395c1109f4fadc (diff) | |
download | gcc-d05db70d8219033f331cd398a1498082eaf2d018.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@169288 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cgraphunit.c')
-rw-r--r-- | gcc/cgraphunit.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index 92e5aa95461..2eb3285290b 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -791,6 +791,23 @@ cgraph_analyze_function (struct cgraph_node *node) 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))) + { + warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wattributes, + "%<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 (struct cgraph_node *first, 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 (struct cgraph_node *first, else if (vnode->finalized) varpool_mark_needed_node (vnode); } + process_common_attributes (decl); } } |