FreeBSD/contrib/gcc/cp/decl.c
/* If a local static variable is declared in an inline function, or if
   we have a weak definition, we must endeavor to create only one
   instance of the variable at link-time.  */
If a local static variable is declared in an inline function, or if
we have a weak definition, we must endeavor to create only one
instance of the variable at link-time.
If a local static variable is declared in an inline function or if we have a weak definition we must endeavor to create only one instance of the variable at link - time .
static void
maybe_commonize_var (tree decl)
{
  if (TREE_STATIC (decl)
      && ! DECL_ARTIFICIAL (decl)
      && DECL_FUNCTION_SCOPE_P (decl)
      && (DECL_COMDAT (DECL_CONTEXT (decl))
	  || ((DECL_DECLARED_INLINE_P (DECL_CONTEXT (decl))
	       || DECL_TEMPLATE_INSTANTIATION (DECL_CONTEXT (decl)))
	      && TREE_PUBLIC (DECL_CONTEXT (decl)))))
    {
      if (flag_weak)
	{
	  comdat_linkage (decl);
	}
      else
	{
	  if (DECL_INITIAL (decl) == NULL_TREE
	      || DECL_INITIAL (decl) == error_mark_node)
	    {
	      TREE_PUBLIC (decl) = 1;
	      DECL_COMMON (decl) = 1;
	    }
	  else
	    {
	      TREE_PUBLIC (decl) = 0;
	      DECL_COMMON (decl) = 0;
	      warning (0, "sorry: semantics of inline function static "
		       "data %q+#D are wrong (you'll wind up "
		       "with multiple copies)", decl);
	      warning (0, "%J  you can work around this by removing "
		       "the initializer",
		       decl);
	    }
	}
    }
  else if (DECL_LANG_SPECIFIC (decl) && DECL_COMDAT (decl))
    comdat_linkage (decl);
}
static void maybe_commonize_var ( tree decl ) { if ( TREE_STATIC ( decl ) && ! DECL_ARTIFICIAL ( decl ) && DECL_FUNCTION_SCOPE_P ( decl ) && ( DECL_COMDAT ( DECL_CONTEXT ( decl ) ) || ( ( DECL_DECLARED_INLINE_P ( DECL_CONTEXT ( decl ) ) || DECL_TEMPLATE_INSTANTIATION ( DECL_CONTEXT ( decl ) ) ) && TREE_PUBLIC ( DECL_CONTEXT ( decl ) ) ) ) ) { if ( flag_weak ) { comdat_linkage ( decl ) ; } else { if ( DECL_INITIAL ( decl ) == NULL_TREE || DECL_INITIAL ( decl ) == error_mark_node ) { TREE_PUBLIC ( decl ) = 1 ; DECL_COMMON ( decl ) = 1 ; } else { TREE_PUBLIC ( decl ) = 0 ; DECL_COMMON ( decl ) = 0 ; warning ( 0 , " " " " " " , decl ) ; warning ( 0 , " " " " , decl ) ; } } } else if ( DECL_LANG_SPECIFIC ( decl ) && DECL_COMDAT ( decl ) ) comdat_linkage ( decl ) ; }
If a local static variable is declared in an inline function, or if
we have a weak definition, we must endeavor to create only one
instance of the variable at link-time.
If a local static variable is declared in an inline function or if we have a weak definition we must endeavor to create only one instance of the variable at link - time .
/* Static data in a function with comdat linkage also has comdat
     linkage.  */ /* Don't mess with __FUNCTION__.  */ /* Unfortunately, import_export_decl has not always been called
	 before the function is processed, so we cannot simply check
	 DECL_COMDAT.  */ /* With weak symbols, we simply make the variable COMDAT;
	     that will cause copies in multiple translations units to
	     be merged.  */ /* Without weak symbols, we can use COMMON to merge
		 uninitialized variables.  */ /* While for initialized variables, we must use internal
		 linkage -- which means that multiple copies will not
		 be merged.  */ /* Set it up again; we might have set DECL_INITIAL since the last
       time.  */