This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH: PR 18925


This patch fixes PR c++/18925, a problem with the visibility attribute
on static data members on IA64 GNU/Linux.  The problem here is, again,
that calling assemble_external results in setting DECL_RTL on this
platform, but not on many other platforms.  As a result, we decided on
the RTL for the static data member before we had a chance to set up
the visibility.  Fixed by moving the visibility setting earlier -- but
we really need to fix the compiler so that assemble_external is not
called until the end of the compilation, which, of course, implies
making unit-at-a-time mode the only mode.

Tested on i686-pc-linux-gnu, and with a cross compiler to ia64-linux,
applied on the mainline. 

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
 
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-13  Mark Mitchell  <mark@codesourcery.com>

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

Index: cp/class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/class.c,v
retrieving revision 1.692
diff -c -5 -p -r1.692 class.c
*** cp/class.c	8 Dec 2004 08:35:33 -0000	1.692
--- cp/class.c	14 Dec 2004 02:14:23 -0000
*************** layout_class_type (tree t, tree *virtual
*** 4551,4561 ****
  	       struct S2 { static S1 s1; };
  	       
               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);
  	  continue;
  	}
  
        type = TREE_TYPE (field);
        
--- 4551,4567 ----
  	       struct S2 { static S1 s1; };
  	       
               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);
! 	      /* The visibility of static data members is determined
! 		 at their point of declaration, not their point of
! 		 definition.  */
! 	      determine_visibility (field);
! 	    }
  	  continue;
  	}
  
        type = TREE_TYPE (field);
        
Index: testsuite/g++.dg/ext/visibility/staticdatamem.C
===================================================================
RCS file: testsuite/g++.dg/ext/visibility/staticdatamem.C
diff -N testsuite/g++.dg/ext/visibility/staticdatamem.C
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/ext/visibility/staticdatamem.C	14 Dec 2004 02:14:23 -0000
***************
*** 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--; 
+ } 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]