------- 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

Reply via email to