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]

PATCH: Fix g++.dg/visibility/virtual.C on ARM


When I added the TARGET_CXX_EXPORT_CLASS_DATA hook, I failed to allow
explicit visibility specifications on a class type to override the
hook, which caused g++.dg/visibility/virtual.C to FAIL when building
for arm-none-eabi.  

Tested on arm-none-eabi, applied on the csl-arm-branch and on the
mainline.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2004-09-19  Mark Mitchell  <mark@codesourcery.com>

	* cp/decl2.c (determine_visibility): Allow class visibility
	directives to override targetm.cxx.export_class_data.

Index: decl2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v
retrieving revision 1.685.4.10
diff -c -5 -p -r1.685.4.10 decl2.c
*** decl2.c	2 Sep 2004 19:32:59 -0000	1.685.4.10
--- decl2.c	19 Sep 2004 23:09:31 -0000
*************** determine_visibility (tree decl)
*** 1701,1722 ****
  
    /* By default, static data members and function members receive
       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)))
  	{
  	  DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT;
  	  DECL_VISIBILITY_SPECIFIED (decl) = 1;
  	}
        else if (TREE_CODE (decl) == FUNCTION_DECL
--- 1701,1712 ----
  
    /* By default, static data members and function members receive
       the visibility of their containing class.  */
    if (class_type)
      {
!       if (TARGET_DLLIMPORT_DECL_ATTRIBUTES
! 	  && lookup_attribute ("dllexport", TYPE_ATTRIBUTES (class_type)))
  	{
  	  DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT;
  	  DECL_VISIBILITY_SPECIFIED (decl) = 1;
  	}
        else if (TREE_CODE (decl) == FUNCTION_DECL
*************** determine_visibility (tree decl)
*** 1724,1738 ****
  	       && visibility_options.inlines_hidden)
  	{
  	  DECL_VISIBILITY (decl) = VISIBILITY_HIDDEN;
  	  DECL_VISIBILITY_SPECIFIED (decl) = 1;
  	}
        else
  	{
  	  DECL_VISIBILITY (decl) = CLASSTYPE_VISIBILITY (class_type);
! 	  DECL_VISIBILITY_SPECIFIED (decl)
! 	    = CLASSTYPE_VISIBILITY_SPECIFIED (class_type);
  	}
      }
  }
  
  /* Determines the proper settings of TREE_PUBLIC and DECL_EXTERNAL for an
--- 1714,1745 ----
  	       && visibility_options.inlines_hidden)
  	{
  	  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) = 0;
  	}
      }
  }
  
  /* Determines the proper settings of TREE_PUBLIC and DECL_EXTERNAL for an


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