FreeBSD/contrib/gcc/varasm.c
/* Merge weak status between NEWDECL and OLDDECL.  */
Merge weak status between NEWDECL and OLDDECL.
Merge weak status between NEWDECL and OLDDECL .
void
merge_weak (tree newdecl, tree olddecl)
{
  if (DECL_WEAK (newdecl) == DECL_WEAK (olddecl))
    {
      if (DECL_WEAK (newdecl) && SUPPORTS_WEAK)
        {
          tree *pwd;
	  for (pwd = &weak_decls; *pwd; pwd = &TREE_CHAIN (*pwd))
	    if (TREE_VALUE (*pwd) == newdecl)
	      {
	        *pwd = TREE_CHAIN (*pwd);
		break;
	      }
        }
      return;
    }
  if (DECL_WEAK (newdecl))
    {
      tree wd;
      if (TREE_ASM_WRITTEN (olddecl))
	error ("weak declaration of %q+D must precede definition",
	       newdecl);
      else if (TREE_USED (olddecl)
	       && TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (olddecl)))
	warning (0, "weak declaration of %q+D after first use results "
                 "in unspecified behavior", newdecl);
      if (SUPPORTS_WEAK)
	{
	  for (wd = weak_decls; wd; wd = TREE_CHAIN (wd))
	    if (TREE_VALUE (wd) == newdecl)
	      {
		TREE_VALUE (wd) = olddecl;
		break;
	      }
	}
      mark_weak (olddecl);
    }
  else
    mark_weak (newdecl);
}
void merge_weak ( tree newdecl , tree olddecl ) { if ( DECL_WEAK ( newdecl ) == DECL_WEAK ( olddecl ) ) { if ( DECL_WEAK ( newdecl ) && SUPPORTS_WEAK ) { tree * pwd ; for ( pwd = & weak_decls ; * pwd ; pwd = & TREE_CHAIN ( * pwd ) ) if ( TREE_VALUE ( * pwd ) == newdecl ) { * pwd = TREE_CHAIN ( * pwd ) ; break ; } } return ; } if ( DECL_WEAK ( newdecl ) ) { tree wd ; if ( TREE_ASM_WRITTEN ( olddecl ) ) error ( " " , newdecl ) ; else if ( TREE_USED ( olddecl ) && TREE_SYMBOL_REFERENCED ( DECL_ASSEMBLER_NAME ( olddecl ) ) ) warning ( 0 , " " " " , newdecl ) ; if ( SUPPORTS_WEAK ) { for ( wd = weak_decls ; wd ; wd = TREE_CHAIN ( wd ) ) if ( TREE_VALUE ( wd ) == newdecl ) { TREE_VALUE ( wd ) = olddecl ; break ; } } mark_weak ( olddecl ) ; } else mark_weak ( newdecl ) ; }
Merge weak status between NEWDECL and OLDDECL.
Merge weak status between NEWDECL and OLDDECL .
/* We put the NEWDECL on the weak_decls list at some point
             and OLDDECL as well.  Keep just OLDDECL on the list.  */ /* NEWDECL is weak, but OLDDECL is not.  */ /* If we already output the OLDDECL, we're in trouble; we can't
	 go back and make it weak.  This error cannot caught in
	 declare_weak because the NEWDECL and OLDDECL was not yet
	 been merged; therefore, TREE_ASM_WRITTEN was not set.  */ /* If we've already generated rtl referencing OLDDECL, we may
	 have done so in a way that will not function properly with
	 a weak symbol.  */ /* We put the NEWDECL on the weak_decls list at some point.
	     Replace it with the OLDDECL.  */ /* We may not find the entry on the list.  If NEWDECL is a
	     weak alias, then we will have already called
	     globalize_decl to remove the entry; in that case, we do
	     not need to do anything.  */ /* Make the OLDDECL weak; it's OLDDECL that we'll be keeping.  */ /* OLDDECL was weak, but NEWDECL was not explicitly marked as
       weak.  Just update NEWDECL to indicate that it's weak too.  */