]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR libstdc++/56557 (Link error about `std::fstream' or `std::stringstream' with...
authorJan Hubicka <jh@suse.cz>
Tue, 12 Mar 2013 12:38:47 +0000 (13:38 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Tue, 12 Mar 2013 12:38:47 +0000 (12:38 +0000)
PR lto/56557
* lto-streamer-out.c (output_symbol_p): Skip references from
constructors of external variables.

From-SVN: r196613

gcc/ChangeLog
gcc/lto-streamer-out.c

index 8fad9e630a9bb175fbe49cfa209e0f066cb55431..9acbb52eb0ade7de0e30f8bcd10382c712202028 100644 (file)
@@ -1,3 +1,9 @@
+2013-03-11  Jan Hubicka  <jh@suse.cz>
+
+       PR lto/56557
+       * lto-streamer-out.c (output_symbol_p): Skip references from
+       constructors of external variables.
+
 2013-03-11  Jan Hubicka  <jh@suse.cz>
 
        PR middle-end/56571
index 6cbe045ce504f0a50c34cac30de7d1714042d2e8..b205092f597b0c0219f69e7d737d935cb95cb84b 100644 (file)
@@ -1265,17 +1265,36 @@ bool
 output_symbol_p (symtab_node node)
 {
   struct cgraph_node *cnode;
-  struct ipa_ref *ref;
-
   if (!symtab_real_symbol_p (node))
     return false;
   /* We keep external functions in symtab for sake of inlining
      and devirtualization.  We do not want to see them in symbol table as
-     references.  */
+     references unless they are really used.  */
   cnode = dyn_cast <cgraph_node> (node);
-  if (cnode && DECL_EXTERNAL (cnode->symbol.decl))
-    return (cnode->callers
-           || ipa_ref_list_referring_iterate (&cnode->symbol.ref_list, 0, ref));
+  if (cnode && DECL_EXTERNAL (cnode->symbol.decl)
+      && cnode->callers)
+    return true;
+
+ /* Ignore all references from external vars initializers - they are not really
+    part of the compilation unit until they are used by folding.  Some symbols,
+    like references to external construction vtables can not be referred to at all.
+    We decide this at can_refer_decl_in_current_unit_p.  */
+ if (DECL_EXTERNAL (node->symbol.decl))
+    {
+      int i;
+      struct ipa_ref *ref;
+      for (i = 0; ipa_ref_list_referring_iterate (&node->symbol.ref_list,
+                                                 i, ref); i++)
+       {
+         if (ref->use == IPA_REF_ALIAS)
+           continue;
+          if (is_a <cgraph_node> (ref->referring))
+           return true;
+         if (!DECL_EXTERNAL (ref->referring->symbol.decl))
+           return true;
+       }
+      return false;
+    }
   return true;
 }