decl2.c (determine_visibility): Allow class visibility directives to override targetm...
authorMark Mitchell <mark@codesourcery.com>
Sun, 19 Sep 2004 23:18:19 +0000 (23:18 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Sun, 19 Sep 2004 23:18:19 +0000 (23:18 +0000)
* decl2.c (determine_visibility): Allow class visibility
directives to override targetm.cxx.export_class_data.

[[Split portion of a mixed commit.]]

From-SVN: r87735.2

gcc/cp/ChangeLog
gcc/cp/decl2.c

index 7cb83b51fa7352f7c52ec1c0d20e59cc497949fe..c94a8ccc653d1eb906129714964b482a6939805c 100644 (file)
@@ -1,3 +1,8 @@
+2004-09-19  Mark Mitchell  <mark@codesourcery.com>
+
+       * decl2.c (determine_visibility): Allow class visibility
+       directives to override targetm.cxx.export_class_data.
+
 2004-09-18  Kazu Hirata  <kazu@cs.umass.edu>
 
        * call.c, semantics.c: Follow spelling conventions.
index 92233c7cd288c60b89d3e229903d4260cd28f1f4..c6b8f51895d0bcf07805f73e0358550d89418109 100644 (file)
@@ -1655,18 +1655,8 @@ determine_visibility (tree decl)
      the visibility of their containing class.  */
   if (class_type)
     {
-      if (TREE_CODE (decl) == VAR_DECL
-         && targetm.cxx.export_class_data ()
-         && (DECL_TINFO_P (decl)
-             || (DECL_VTABLE_OR_VTT_P (decl)
-                 /* Construction virtual tables are not emitted
-                    because they cannot be referred to from other
-                    object files; their name is not standardized by
-                    the ABI.  */
-                 && !DECL_CONSTRUCTION_VTABLE_P (decl))))
-       DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT;
-      else if (TARGET_DLLIMPORT_DECL_ATTRIBUTES
-              && lookup_attribute ("dllexport", TYPE_ATTRIBUTES (class_type)))
+      if (TARGET_DLLIMPORT_DECL_ATTRIBUTES
+         && lookup_attribute ("dllexport", TYPE_ATTRIBUTES (class_type)))
        {
          DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT;
          DECL_VISIBILITY_SPECIFIED (decl) = 1;
@@ -1678,11 +1668,28 @@ determine_visibility (tree decl)
          DECL_VISIBILITY (decl) = VISIBILITY_HIDDEN;
          DECL_VISIBILITY_SPECIFIED (decl) = 1;
        }
+      else if (CLASSTYPE_VISIBILITY_SPECIFIED (class_type))
+       {
+         DECL_VISIBILITY (decl) = CLASSTYPE_VISIBILITY (class_type);
+         DECL_VISIBILITY_SPECIFIED (decl) = 1;
+       }
+      /* If no explicit visibility information has been provided for
+        this class, some targets require that class data be
+        exported.  */
+      else if (TREE_CODE (decl) == VAR_DECL
+              && targetm.cxx.export_class_data ()
+              && (DECL_TINFO_P (decl)
+                  || (DECL_VTABLE_OR_VTT_P (decl)
+                      /* Construction virtual tables are not emitted
+                         because they cannot be referred to from other
+                         object files; their name is not standardized by
+                         the ABI.  */
+                      && !DECL_CONSTRUCTION_VTABLE_P (decl))))
+       DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT;
       else
        {
          DECL_VISIBILITY (decl) = CLASSTYPE_VISIBILITY (class_type);
-         DECL_VISIBILITY_SPECIFIED (decl)
-           = CLASSTYPE_VISIBILITY_SPECIFIED (class_type);
+         DECL_VISIBILITY_SPECIFIED (decl) = 0;
        }
     }
 }