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]

Fix PR 31903, type info for types in anonymous namespaces


In the 'else' clause right below the code I remove, there is:

      else if (TREE_CODE (decl) == VAR_DECL && DECL_TINFO_P (decl))
        {
          /* tinfo visibility is based on the type it's for.  */
          constrain_visibility
            (decl, type_visibility (TREE_TYPE (DECL_NAME (decl))));
        }

which is more correct, and in the presence of the code I deleted, is
never used for type info of class types.

Tested with 'make bootstrap', rebuilding libsdc++, and running the C++
dejagnu testsuite on i386-apple-darwin9.

-- 
- Geoffrey Keating <geoffk@apple.com>

===File ~/patches/gcc-cp-tinfovis.patch=====================
Index: gcc/cp/ChangeLog
2007-06-13  geoffk  <geoffk@apple.com>

	* decl2.c (determine_visibility): Remove duplicate code for
	handling type info.

Index: gcc/testsuite/ChangeLog
2007-06-13  Geoff Keating  <geoffk@apple.com>

	* g++.dg/ext/visibility/anon4.C: New.

Index: gcc/cp/decl2.c
===================================================================
--- gcc/cp/decl2.c	(revision 125627)
+++ gcc/cp/decl2.c	(working copy)
@@ -1698,10 +1698,6 @@
      class can influence the visibility of the DECL.  */
   if (DECL_CLASS_SCOPE_P (decl))
     class_type = DECL_CONTEXT (decl);
-  else if (TREE_CODE (decl) == VAR_DECL
-	   && DECL_TINFO_P (decl)
-	   && CLASS_TYPE_P (TREE_TYPE (DECL_NAME (decl))))
-    class_type = TREE_TYPE (DECL_NAME (decl));
   else
     {
       /* Not a class member.  */
Index: gcc/testsuite/g++.dg/ext/visibility/anon4.C
===================================================================
--- gcc/testsuite/g++.dg/ext/visibility/anon4.C	(revision 0)
+++ gcc/testsuite/g++.dg/ext/visibility/anon4.C	(revision 0)
@@ -0,0 +1,16 @@
+// PR c++/31903
+// Test for anonymous namespace internal linkage, for typeinfo
+
+// { dg-do compile }
+// { dg-final { scan-assembler-not "globl.*_ZTIN*3fooE" } }
+
+#include <typeinfo>
+namespace 
+{
+  class foo 
+  {
+    virtual void bar();
+  };
+}
+
+const std::type_info &X = typeid(foo);
============================================================


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