OSDN Git Service

PR c++/18925
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 14 Dec 2004 02:15:55 +0000 (02:15 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 14 Dec 2004 02:15:55 +0000 (02:15 +0000)
* class.c (layout_class_type): Determine the visibility of static
data members.

PR c++/18925
* g++.dg/ext/visibility/staticdatamem.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@92120 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/visibility/staticdatamem.C [new file with mode: 0644]

index 55b467c..71cce5f 100644 (file)
@@ -1,3 +1,9 @@
+2004-12-13  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/18925
+       * class.c (layout_class_type): Determine the visibility of static
+       data members.
+
 2004-12-12  Roger Sayle  <roger@eyesopen.com>
 
        PR middle-end/12454
index 886d301..f7e5c7b 100644 (file)
@@ -4553,7 +4553,13 @@ layout_class_type (tree t, tree *virtuals_p)
              At this point, finish_record_layout will be called, but
             S1 is still incomplete.)  */
          if (TREE_CODE (field) == VAR_DECL)
-           maybe_register_incomplete_var (field);
+           {
+             maybe_register_incomplete_var (field);
+             /* The visibility of static data members is determined
+                at their point of declaration, not their point of
+                definition.  */
+             determine_visibility (field);
+           }
          continue;
        }
 
index 2341dec..957c5eb 100644 (file)
@@ -1,3 +1,8 @@
+2004-12-13  Mark Mitchell  <mark@codesourcery.com>
+
+       PR c++/18925
+       * g++.dg/ext/visibility/staticdatamem.C: New test.
+
 2004-12-13  Kelley Cook  <kcook@gcc.gnu.org>
 
        * gcc.target/xstormy16/below100.S: Remove DOS line endings.
diff --git a/gcc/testsuite/g++.dg/ext/visibility/staticdatamem.C b/gcc/testsuite/g++.dg/ext/visibility/staticdatamem.C
new file mode 100644 (file)
index 0000000..4ec9479
--- /dev/null
@@ -0,0 +1,20 @@
+// PR c++/18925
+// { dg-do compile { target ia64-*-linux* } }
+// { dg-options "-fPIC -fvisibility=hidden" }
+// { dg-final { scan-assembler-not "gprel" } }
+
+class __attribute__ ((visibility("default"))) Type 
+{ 
+ private: 
+  static long _staticTypeCount; 
+ public: 
+  Type() { _staticTypeCount++; } 
+  ~Type(); 
+}; 
+long Type::_staticTypeCount = 0; 
+Type::~Type() 
+{ 
+ _staticTypeCount--; 
+}