This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/29299] [4.2 Regresion] gcc "used" attribute has no effect on local-scope static variables
- From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Oct 2006 13:04:55 -0000
- Subject: [Bug middle-end/29299] [4.2 Regresion] gcc "used" attribute has no effect on local-scope static variables
- References: <bug-29299-13334@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #4 from rguenth at gcc dot gnu dot org 2006-10-09 13:04 -------
We have
bool
decide_is_variable_needed (struct cgraph_varpool_node *node, tree decl)
{
/* If the user told us it is used, then it must be so. */
if (node->externally_visible || node->force_output)
return true;
if (!flag_unit_at_a_time
&& lookup_attribute ("used", DECL_ATTRIBUTES (decl)))
return true;
with "used" set on bar...
Now, the handler for attribute "used" sets DECL_PRESERVE_P on the decl, so
we might as well check that.
Index: cgraph.c
===================================================================
*** cgraph.c (revision 117569)
--- cgraph.c (working copy)
*************** bool
*** 939,948 ****
decide_is_variable_needed (struct cgraph_varpool_node *node, tree decl)
{
/* If the user told us it is used, then it must be so. */
! if (node->externally_visible || node->force_output)
! return true;
! if (!flag_unit_at_a_time
! && lookup_attribute ("used", DECL_ATTRIBUTES (decl)))
return true;
/* ??? If the assembler name is set by hand, it is possible to assemble
--- 939,947 ----
decide_is_variable_needed (struct cgraph_varpool_node *node, tree decl)
{
/* If the user told us it is used, then it must be so. */
! if (node->externally_visible
! || node->force_output
! || DECL_PRESERVE_P (decl))
return true;
/* ??? If the assembler name is set by hand, it is possible to assemble
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |rguenth at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
Last reconfirmed|2006-09-30 19:40:21 |2006-10-09 13:04:55
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29299