]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/symtab.c
re PR c++/41090 (Using static label reference in c++ class constructor produces wrong...
[thirdparty/gcc.git] / gcc / symtab.c
index dc700e7c73542d0ed34502b7b6eb3066c9afb424..8d36cae7b2712caae13214a2210e9f414b629e27 100644 (file)
@@ -538,6 +538,10 @@ symtab_dissolve_same_comdat_group_list (symtab_node *node)
     {
       next = n->same_comdat_group;
       n->same_comdat_group = NULL;
+      /* Clear DECL_COMDAT_GROUP for comdat locals, since
+         make_decl_local doesn't.  */
+      if (!TREE_PUBLIC (n->decl))
+       DECL_COMDAT_GROUP (n->decl) = NULL_TREE;
       n = next;
     }
   while (n != node);
@@ -844,6 +848,21 @@ verify_symtab_base (symtab_node *node)
          n = n->same_comdat_group;
        }
       while (n != node);
+      if (symtab_comdat_local_p (node))
+       {
+         struct ipa_ref_list *refs = &node->ref_list;
+         struct ipa_ref *ref;
+         for (int i = 0; ipa_ref_list_referring_iterate (refs, i, ref); ++i)
+           {
+             if (!symtab_in_same_comdat_p (ref->referring, node))
+               {
+                 error ("comdat-local symbol referred to by %s outside its "
+                        "comdat",
+                        identifier_to_locale (ref->referring->name()));
+                 error_found = true;
+               }
+           }
+       }
     }
   return error_found;
 }
@@ -911,6 +930,10 @@ symtab_make_decl_local (tree decl)
 {
   rtx rtl, symbol;
 
+  /* Avoid clearing DECL_COMDAT_GROUP on comdat-local decls.  */
+  if (TREE_PUBLIC (decl) == 0)
+    return;
+
   if (TREE_CODE (decl) == VAR_DECL)
     DECL_COMMON (decl) = 0;
   else gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);