OSDN Git Service

PR c++/35368
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 27 Feb 2008 09:09:05 +0000 (09:09 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 27 Feb 2008 09:09:05 +0000 (09:09 +0000)
* rtti.c: Include c-pragma.h.
(push_abi_namespace, pop_abi_namespace): New functions.
(build_dynamic_cast_1, tinfo_base_init, get_pseudo_ti_index,
create_tinfo_types, emit_support_tinfos): Use them.
* Make-lang.in (cp/rtti.o): Depend on $(C_PRAGMA_H).

* g++.dg/ext/visibility/typeinfo2.C: New test.
* g++.dg/ext/visibility/typeinfo3.C: New test.

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

gcc/cp/ChangeLog
gcc/cp/Make-lang.in
gcc/cp/rtti.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/visibility/typeinfo2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/ext/visibility/typeinfo3.C [new file with mode: 0644]

index 2a06b6f..fe719cd 100644 (file)
@@ -1,3 +1,12 @@
+2008-02-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/35368
+       * rtti.c: Include c-pragma.h.
+       (push_abi_namespace, pop_abi_namespace): New functions.
+       (build_dynamic_cast_1, tinfo_base_init, get_pseudo_ti_index,
+       create_tinfo_types, emit_support_tinfos): Use them.
+       * Make-lang.in (cp/rtti.o): Depend on $(C_PRAGMA_H).
+
 2008-02-26  Jason Merrill  <jason@redhat.com>
 
        PR c++/35315
index d2a69f4..6207ed1 100644 (file)
@@ -264,7 +264,7 @@ cp/tree.o: cp/tree.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) toplev.h $(RTL_H) \
   $(TARGET_H) debug.h $(TREE_FLOW_H)
 cp/ptree.o: cp/ptree.c $(CXX_TREE_H) $(TM_H)
 cp/rtti.o: cp/rtti.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) toplev.h convert.h \
-  $(TARGET_H) gt-cp-rtti.h
+  $(TARGET_H) $(C_PRAGMA_H) gt-cp-rtti.h
 cp/except.o: cp/except.c $(CXX_TREE_H) $(TM_H) $(FLAGS_H) $(RTL_H) except.h \
   toplev.h cp/cfns.h $(EXPR_H) libfuncs.h $(TREE_INLINE_H) $(TARGET_H)
 cp/expr.o: cp/expr.c $(CXX_TREE_H) $(TM_H) $(RTL_H) $(FLAGS_H) $(EXPR_H) \
index 1925d04..f2085e4 100644 (file)
@@ -1,6 +1,6 @@
 /* RunTime Type Identification
    Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-   2005, 2006, 2007
+   2005, 2006, 2007, 2008
    Free Software Foundation, Inc.
    Mostly written by Jason Merrill (jason@cygnus.com).
 
@@ -32,6 +32,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "toplev.h"
 #include "convert.h"
 #include "target.h"
+#include "c-pragma.h"
 
 /* C++ returns type information to the user in struct type_info
    objects. We also use type information to implement dynamic_cast and
@@ -124,6 +125,19 @@ static bool typeinfo_in_lib_p (tree);
 
 static int doing_runtime = 0;
 \f
+static void
+push_abi_namespace (void)
+{
+  push_nested_namespace (abi_node);
+  push_visibility ("default");
+}
+
+static void
+pop_abi_namespace (void)
+{
+  pop_visibility ();
+  pop_nested_namespace (abi_node);
+}
 
 /* Declare language defined type_info type and a pointer to const
    type_info.  This is incomplete here, and will be completed when
@@ -669,10 +683,9 @@ build_dynamic_cast_1 (tree type, tree expr)
            {
              tree tmp;
              tree tinfo_ptr;
-             tree ns = abi_node;
              const char *name;
 
-             push_nested_namespace (ns);
+             push_abi_namespace ();
              tinfo_ptr = xref_tag (class_type,
                                    get_identifier ("__class_type_info"),
                                    /*tag_scope=*/ts_current, false);
@@ -689,7 +702,7 @@ build_dynamic_cast_1 (tree type, tree expr)
              tmp = build_function_type (ptr_type_node, tmp);
              dcast_fn = build_library_fn_ptr (name, tmp);
              DECL_IS_PURE (dcast_fn) = 1;
-             pop_nested_namespace (ns);
+             pop_abi_namespace ();
              dynamic_cast_node = dcast_fn;
            }
          result = build_cxx_call (dcast_fn, 4, elems);
@@ -848,10 +861,10 @@ tinfo_base_init (tinfo_s *ti, tree target)
   if (!vtable_ptr)
     {
       tree real_type;
-      push_nested_namespace (abi_node);
+      push_abi_namespace ();
       real_type = xref_tag (class_type, ti->name,
                            /*tag_scope=*/ts_current, false);
-      pop_nested_namespace (abi_node);
+      pop_abi_namespace ();
 
       if (!COMPLETE_TYPE_P (real_type))
        {
@@ -1268,14 +1281,14 @@ get_pseudo_ti_index (tree type)
                                             TK_BASE_TYPE)->type,
                                  array_domain);
 
-             push_nested_namespace (abi_node);
+             push_abi_namespace ();
              create_pseudo_type_info
                (ix, "__vmi_class_type_info",
                 build_decl (FIELD_DECL, NULL_TREE, integer_type_node),
                 build_decl (FIELD_DECL, NULL_TREE, integer_type_node),
                 build_decl (FIELD_DECL, NULL_TREE, base_array),
                 NULL);
-             pop_nested_namespace (abi_node);
+             pop_abi_namespace ();
              break;
            }
        }
@@ -1298,7 +1311,7 @@ create_tinfo_types (void)
 
   VEC_safe_grow (tinfo_s, gc, tinfo_descs, TK_FIXED);
 
-  push_nested_namespace (abi_node);
+  push_abi_namespace ();
 
   /* Create the internal type_info structure. This is used as a base for
      the other structures.  */
@@ -1376,7 +1389,7 @@ create_tinfo_types (void)
        build_decl (FIELD_DECL, NULL_TREE, type_info_ptr_type),
        NULL);
 
-  pop_nested_namespace (abi_node);
+  pop_abi_namespace ();
 }
 
 /* Emit the type_info descriptors which are guaranteed to be in the runtime
@@ -1404,11 +1417,11 @@ emit_support_tinfos (void)
   int ix;
   tree bltn_type, dtor;
 
-  push_nested_namespace (abi_node);
+  push_abi_namespace ();
   bltn_type = xref_tag (class_type,
                        get_identifier ("__fundamental_type_info"),
                        /*tag_scope=*/ts_current, false);
-  pop_nested_namespace (abi_node);
+  pop_abi_namespace ();
   if (!COMPLETE_TYPE_P (bltn_type))
     return;
   dtor = CLASSTYPE_DESTRUCTORS (bltn_type);
index bb3326a..8f652d2 100644 (file)
@@ -2,6 +2,10 @@
 
        * gcc.dg/gomp/preprocess-1.c: New test.
 
+       PR c++/35368
+       * g++.dg/ext/visibility/typeinfo2.C: New test.
+       * g++.dg/ext/visibility/typeinfo3.C: New test.
+
 2008-02-26  Joseph Myers  <joseph@codesourcery.com>
 
        * gcc.dg/bf-ms-attrib.c (main): Return 0.
diff --git a/gcc/testsuite/g++.dg/ext/visibility/typeinfo2.C b/gcc/testsuite/g++.dg/ext/visibility/typeinfo2.C
new file mode 100644 (file)
index 0000000..54f541d
--- /dev/null
@@ -0,0 +1,23 @@
+// PR c++/35368
+// { dg-require-visibility "" }
+
+#pragma GCC visibility push (hidden)
+
+struct A
+{
+  A();
+  virtual ~A() { }
+};
+
+A::A()
+{
+}
+
+void foo(A *a)
+{
+  delete a;
+}
+
+// { dg-final { scan-not-hidden "_ZTVN10__cxxabiv117__class_type_infoE" } }
+// { dg-final { scan-hidden "_ZTI1A" } }
+// { dg-final { scan-hidden "_ZTV1A" } }
diff --git a/gcc/testsuite/g++.dg/ext/visibility/typeinfo3.C b/gcc/testsuite/g++.dg/ext/visibility/typeinfo3.C
new file mode 100644 (file)
index 0000000..5102b64
--- /dev/null
@@ -0,0 +1,24 @@
+// PR c++/35368
+// { dg-require-visibility "" }
+
+#pragma GCC visibility push (hidden)
+
+#include <typeinfo>
+
+const std::type_info& info1 = typeid(int []);
+const std::type_info& info2 = typeid(int);
+enum E { e = 0 };
+const std::type_info& info3 = typeid(E);
+struct S { S (); };
+const std::type_info& info4 = typeid(S);
+const std::type_info& info5 = typeid(int *);
+
+// { dg-final { scan-not-hidden "_ZTVN10__cxxabiv117__array_type_infoE" } }
+// { dg-final { scan-not-hidden "_ZTVN10__cxxabiv116__enum_type_infoE" } }
+// { dg-final { scan-hidden "_ZTI1S" } }
+// { dg-final { scan-hidden "_ZTS1S" } }
+// { dg-final { scan-hidden "info1" } }
+// { dg-final { scan-hidden "info2" } }
+// { dg-final { scan-hidden "info3" } }
+// { dg-final { scan-hidden "info4" } }
+// { dg-final { scan-hidden "info5" } }