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: Correct visibility bug in 4.1


Internal testing showed that g++.dg/ext/visibility/arm3.C is a 4.1
regression, resulting in class data (like vtables) getting the wrong
visibility.  The problem here was an inverted conditional: we were
apply the target hook for visibility only if the user had explicitly
specified the visibility for the virtual table, where clearly the
opposite condition is desired.

Jason fixed this as part of another cleanup.  I've now backported the
relevant portion of his patch to the 4.1 branch.

Tested on arm-none-eabi, committed to the 4.1 branch.

--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713

2007-02-19  Mark Mitchell  <mark@codesourcery.com>

	* decl2.c (import_export_decl): Reverse sense of 
	DECL_VISIBILITY_SPECIFIED test for target-specific visibility
	rules.

	Backport of:
	2006-07-20  Jason Merrill  <jason@redhat.com>
	* decl2.c (determine_visibility_from_class): Reverse sense of 
	DECL_VISIBILITY_SPECIFIED test for target-specific visibility
	rules.

Index: decl2.c
===================================================================
--- decl2.c	(revision 121944)
+++ decl2.c	(working copy)
@@ -1905,8 +1905,8 @@ import_export_decl (tree decl)
       comdat_linkage (decl);
     }
 
-  /* Give the target a chance to override the visibility associated
-     with DECL.  */
+  /* Give the target a chance to override the visibility of class
+     data, like virtual tables.  */
   if (TREE_CODE (decl) == VAR_DECL
       && (DECL_TINFO_P (decl)
 	  || (DECL_VTABLE_OR_VTT_P (decl)
@@ -1914,9 +1914,16 @@ import_export_decl (tree decl)
 		 they cannot be referred to from other object files;
 		 their name is not standardized by the ABI.  */
 	      && !DECL_CONSTRUCTION_VTABLE_P (decl)))
-      && TREE_PUBLIC (decl)
+      /* Visibility only applies to objects with external linkage.  */
+      && TREE_PUBLIC (decl) 
+      /* Visibility is specified by the definition of the object, not
+	 its declaration.  */
       && !DECL_REALLY_EXTERN (decl)
-      && DECL_VISIBILITY_SPECIFIED (decl)
+      /* Respect any explicit specification of visibility for the
+	 class data itself.  */
+      && !DECL_VISIBILITY_SPECIFIED (decl)
+      /* If the visibility of the class has been explicitly specified,
+	 that visibility applies to class data as well.  */
       && (!class_type || !CLASSTYPE_VISIBILITY_SPECIFIED (class_type)))
     targetm.cxx.determine_class_data_visibility (decl);
 


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