Commits

Iain Buclaw committed bd1f898

First attack at fixing issue #246

  • Participants
  • Parent commits 63647d6

Comments (0)

Files changed (2)

File d/d-objfile.cc

 
 
 void
-ObjectFile::makeDeclOneOnly(tree decl_tree)
+ObjectFile::makeDeclOneOnly(tree decl_tree, bool comdat)
 {
     if (! D_DECL_IS_TEMPLATE(decl_tree) || gen.emitTemplates != TEprivate)
     {   /* Weak definitions have to be public.  Nested functions may or
         if (SUPPORTS_ONE_ONLY)
         {
 #if D_GCC_VER >= 45
-            make_decl_one_only(decl_tree, d_comdat_group(decl_tree));
+            make_decl_one_only(decl_tree, comdat ? d_comdat_group(decl_tree) : NULL_TREE);
 #else
             make_decl_one_only(decl_tree);
 #endif
         (TREE_CODE(decl_tree) == VAR_DECL && (real_decl && real_decl->isDataseg())) ||
         (TREE_CODE(decl_tree) == FUNCTION_DECL))
     {
+        bool is_static;
+        bool is_comdat;
         bool is_template = false;
         Dsymbol * sym = dsym->toParent();
         Module * ti_obj_file_mod;
             sym = sym->toParent();
         }
 
-        bool is_static;
-
         if (is_template)
         {
             D_DECL_ONE_ONLY(decl_tree) = 1;
         else
             is_static = hasModule(dsym->getModule());
 
+        is_comdat = real_decl && (real_decl->storage_class & STCcomdat);
+
         if (real_decl && TREE_CODE(decl_tree) == VAR_DECL)
         {
             if (real_decl->storage_class & STCextern)
         {
             DECL_EXTERNAL(decl_tree) = 0;
             TREE_STATIC(decl_tree) = 1; // %% don't set until there is a body?
-            if (real_decl && (real_decl->storage_class & STCcomdat))
+            if (is_comdat)
                 D_DECL_ONE_ONLY(decl_tree) = 1;
         }
         else
             TREE_PUBLIC(decl_tree) = 1;
 
         if (D_DECL_ONE_ONLY(decl_tree))
-            makeDeclOneOnly(decl_tree);
+            makeDeclOneOnly(decl_tree, is_comdat);
 
     }
     else

File d/d-objfile.h

     // Definitely in static data, but not neccessarily this module.
     // Assumed to be public data.
     static void setupStaticStorage(Dsymbol * dsym, tree decl_tree);
-    static void makeDeclOneOnly(tree decl_tree);
+    static void makeDeclOneOnly(tree decl_tree, bool comdat = true);
 
     static void outputStaticSymbol(Symbol * s);
     static void outputFunction(FuncDeclaration * f);