]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cp-tree.h (struct lang_decl_flags): Add comdat.
authorJason Merrill <jason@yorick.cygnus.com>
Fri, 19 Dec 1997 08:38:33 +0000 (08:38 +0000)
committerJeff Law <law@gcc.gnu.org>
Fri, 19 Dec 1997 08:38:33 +0000 (01:38 -0700)
* cp-tree.h (struct lang_decl_flags): Add comdat.
(DECL_COMDAT): New macro.
* decl.c (duplicate_decls): Propagate it.
(cp_finish_decl): Handle it.
* decl2.c (import_export_decl): Just set DECL_COMDAT on VAR_DECLs.

From-SVN: r17149

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/decl2.c

index a6c118c93cc302a68b49148c4a1859c34ed1f35b..14cd582b524cfad6965f82817dcd5df9ae3cffbb 100644 (file)
@@ -1,5 +1,11 @@
 Fri Dec 19 09:37:26 1997  Jason Merrill  <jason@yorick.cygnus.com>
 
+       * cp-tree.h (struct lang_decl_flags): Add comdat.
+       (DECL_COMDAT): New macro.
+       * decl.c (duplicate_decls): Propagate it.
+       (cp_finish_decl): Handle it.
+       * decl2.c (import_export_decl): Just set DECL_COMDAT on VAR_DECLs.
+
        * except.c (expand_start_catch_block): suspend_momentary for the
        terminate handler.
 
index 47b9fe6062eff0a2b3980010f5815eb7f346d64d..67cc22face89b862cc5ad333ac2efd13b860eb28 100644 (file)
@@ -943,7 +943,8 @@ struct lang_decl_flags
   unsigned nonconverting : 1;
   unsigned declared_inline : 1;
   unsigned not_really_extern : 1;
-  unsigned dummy : 5;
+  unsigned comdat : 1;
+  unsigned dummy : 4;
 
   tree access;
   tree context;
@@ -1420,6 +1421,10 @@ extern int flag_new_for_scope;
 #define DECL_REALLY_EXTERN(NODE) \
   (DECL_EXTERNAL (NODE) && ! DECL_NOT_REALLY_EXTERN (NODE))
 
+/* Used to tell cp_finish_decl that it should approximate comdat linkage
+   as best it can for this decl.  */
+#define DECL_COMDAT(NODE) (DECL_LANG_SPECIFIC (NODE)->decl_flags.comdat)
+
 #define THUNK_DELTA(DECL) ((DECL)->decl.frame_size.i)
 
 /* ...and for unexpanded-parameterized-type nodes.  */
index b60f842fa43b8bcc9939368a9c16e18b212b5615..193a6fd748639a495331cd14228595fb3cfef5ec 100644 (file)
@@ -2853,6 +2853,7 @@ duplicate_decls (newdecl, olddecl)
     {
       DECL_INTERFACE_KNOWN (newdecl) |= DECL_INTERFACE_KNOWN (olddecl);
       DECL_NOT_REALLY_EXTERN (newdecl) |= DECL_NOT_REALLY_EXTERN (olddecl);
+      DECL_COMDAT (newdecl) |= DECL_COMDAT (olddecl);
     }
 
   if (TREE_CODE (newdecl) == FUNCTION_DECL)
@@ -6716,6 +6717,32 @@ cp_finish_decl (decl, init, asmspec_tree, need_pop, flags)
            cp_warning_at ("sorry: semantics of inline function static data `%#D' are wrong (you'll wind up with multiple copies)", decl);
        }
 
+      else if (TREE_CODE (decl) == VAR_DECL
+              && DECL_LANG_SPECIFIC (decl)
+              && DECL_COMDAT (decl))
+       {
+         /* Dynamically initialized vars go into common.  */
+         if (DECL_INITIAL (decl) == NULL_TREE
+             || DECL_INITIAL (decl) == error_mark_node)
+           DECL_COMMON (decl) = 1;
+         else if (EMPTY_CONSTRUCTOR_P (DECL_INITIAL (decl)))
+           {
+             DECL_COMMON (decl) = 1;
+             DECL_INITIAL (decl) = error_mark_node;
+           }
+         else
+           {
+             /* Statically initialized vars are weak or comdat, if
+                 supported.  */
+             if (flag_weak)
+               make_decl_one_only (decl);
+             else
+               /* we can't do anything useful; leave vars for explicit
+                   instantiation.  */
+               DECL_EXTERNAL (decl) = 1;
+           }
+       }
+
       if (TREE_CODE (decl) == VAR_DECL && DECL_VIRTUAL_P (decl))
        make_decl_rtl (decl, NULL_PTR, toplev);
       else if (TREE_CODE (decl) == VAR_DECL
index 4513f75df56e13c6273d9745a3ef04e534647a6c..8beec1359dc8586c3bbb2b0d3b7236e0fdae58ba 100644 (file)
@@ -2769,26 +2769,8 @@ import_export_decl (decl)
        {
          if (TREE_CODE (decl) == FUNCTION_DECL)
            comdat_linkage (decl);
-         /* Dynamically initialized vars go into common.  */
-         else if (DECL_INITIAL (decl) == NULL_TREE
-                  || DECL_INITIAL (decl) == error_mark_node)
-           DECL_COMMON (decl) = 1;
-         else if (EMPTY_CONSTRUCTOR_P (DECL_INITIAL (decl)))
-           {
-             DECL_COMMON (decl) = 1;
-             DECL_INITIAL (decl) = error_mark_node;
-           }
          else
-           {
-             /* Statically initialized vars are weak or comdat, if
-                 supported.  */
-             if (flag_weak)
-               make_decl_one_only (decl);
-             else
-               /* we can't do anything useful; leave vars for explicit
-                   instantiation.  */
-               DECL_NOT_REALLY_EXTERN (decl) = 0;
-           }
+           DECL_COMDAT (decl) = 1;
        }
       else
        DECL_NOT_REALLY_EXTERN (decl) = 0;