]> gcc.gnu.org Git - gcc.git/commitdiff
cp-tree.h (struct lang_decl_flags): Add comdat.
authorJason Merrill <jason@yorick.cygnus.com>
Thu, 27 Nov 1997 19:26:15 +0000 (19:26 +0000)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 27 Nov 1997 19:26:15 +0000 (14:26 -0500)
* 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: r16804

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

index a62a3981d9b14fba25494de7926c98a179609760..53d2fdf773ae69122dc5f33b06d759da40c6aa6f 100644 (file)
@@ -1,5 +1,11 @@
 Thu Nov 27 00:59:46 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.
+
        * class.c: Remove static pending_hard_virtuals.
        (add_virtual_function): Take pointers to pending_virtuals
        and pending_hard_virtuals.
index 47b9fe6062eff0a2b3980010f5815eb7f346d64d..9b69b7bc5dca4f9ee192aa3746ad537f1167f7a5 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;
@@ -1148,16 +1149,6 @@ struct lang_decl
    one that does).  */
 #define TYPE_VIRTUAL_P(NODE) (TREE_LANG_FLAG_2 (NODE))
 
-#if 0
-/* Same, but tells if this field is private in current context.  */
-#define DECL_PRIVATE(NODE) (FOO)
-
-/* Same, but tells if this field is private in current context.  */
-#define DECL_PROTECTED(NODE) (DECL_LANG_FLAG_6 (NODE))
-
-#define DECL_PUBLIC(NODE) (DECL_LANG_FLAG_7 (NODE))
-#endif
-
 extern int flag_new_for_scope;
 
 /* This flag is true of a local VAR_DECL if it was declared in a for
@@ -1420,6 +1411,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 7b2e1c246224fadb53a5229a4e1bb24c50697199..2a57fa9e4f382c92e567ef7f576e3f431604c7c0 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)
@@ -6720,6 +6721,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 a2821eeb375ef46603b6ee120f6537a5a2bad297..93452b293923e632659334e17c69e3669361f109 100644 (file)
@@ -2776,26 +2776,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;
index 370c9e2a5279dbc8918140be745cdb9f5098e69f..3b56dacb88feba874d2604a6f72f40843c554b04 100644 (file)
@@ -4497,7 +4497,6 @@ instantiate_decl (d)
       popclass (1);
     }
 
-  /* import_export_decl has to happen after DECL_INITIAL is set up.  */
   if (pattern_defined)
     {
       repo_template_used (d);
This page took 0.100191 seconds and 5 git commands to generate.