summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2002-12-01 20:27:37 +0000
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2002-12-01 20:27:37 +0000
commitd085a8479fa3ca78beb178f93079ef58da3c2d0d (patch)
tree949e579a2127ed5b717cc2f0c87ffab7e3cf700e
parent9363c37324826dda40e07ef99fd64422c365b7f5 (diff)
downloadppe42-gcc-d085a8479fa3ca78beb178f93079ef58da3c2d0d.tar.gz
ppe42-gcc-d085a8479fa3ca78beb178f93079ef58da3c2d0d.zip
PR c++/8727
* g++.dg/inherit/typeinfo1.C: New test. PR c++/8663 * g++.dg/inherit/typedef1.C: New test. PR c++/8727 * cp-tree.h (lang_type_class): Add typeinfo_var. (CLASSTYPE_TYPEINFO_VAR): New macro. * rtti.c (get_tinfo_decl): Use it. PR c++/8663 * init.c (expand_member_init): Always get the main variant of a base class. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@59694 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog11
-rw-r--r--gcc/cp/cp-tree.h7
-rw-r--r--gcc/cp/init.c2
-rw-r--r--gcc/cp/rtti.c12
-rw-r--r--gcc/testsuite/ChangeLog8
-rw-r--r--gcc/testsuite/g++.dg/inherit/typedef1.C8
-rw-r--r--gcc/testsuite/g++.dg/inherit/typeinfo1.C18
7 files changed, 65 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index f00d0fb0ff8..8c784806e35 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,16 @@
2002-12-01 Mark Mitchell <mark@codesourcery.com>
+ PR c++/8727
+ * cp-tree.h (lang_type_class): Add typeinfo_var.
+ (CLASSTYPE_TYPEINFO_VAR): New macro.
+ * rtti.c (get_tinfo_decl): Use it.
+
+ PR c++/8663
+ * init.c (expand_member_init): Always get the main variant of a
+ base class.
+
+2002-12-01 Mark Mitchell <mark@codesourcery.com>
+
PR c++/8332
PR c++/8493
* decl.c (cxx_init_decl_processing): Use size_type_node, not
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index db2f082a3f3..0c8c37a7e20 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -1159,6 +1159,7 @@ struct lang_type_class GTY(())
tree vfields;
tree vcall_indices;
tree vtables;
+ tree typeinfo_var;
tree vbases;
tree tags;
tree as_base;
@@ -1637,6 +1638,12 @@ struct lang_type GTY(())
#define CLASSTYPE_VTABLES(NODE) \
(LANG_TYPE_CLASS_CHECK (NODE)->vtables)
+/* The std::type_info variable representing this class, or NULL if no
+ such variable has been created. This field is only set for the
+ TYPE_MAIN_VARIANT of the class. */
+#define CLASSTYPE_TYPEINFO_VAR(NODE) \
+ (LANG_TYPE_CLASS_CHECK (NODE)->typeinfo_var)
+
/* Accessor macros for the vfield slots in structures. */
/* List of virtual table fields that this type contains (both the primary
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index a7db6267853..39d4c57047e 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -967,7 +967,7 @@ expand_member_init (tree name, tree init)
}
else if (TYPE_P (name))
{
- basetype = name;
+ basetype = TYPE_MAIN_VARIANT (name);
name = TYPE_NAME (name);
}
else if (TREE_CODE (name) == TYPE_DECL)
diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c
index 17942c30fd6..7540b5c0e72 100644
--- a/gcc/cp/rtti.c
+++ b/gcc/cp/rtti.c
@@ -328,6 +328,15 @@ get_tinfo_decl (type)
type = build_function_type (TREE_TYPE (type),
TREE_CHAIN (TYPE_ARG_TYPES (type)));
+ /* For a class type, the variable is cached in the type node
+ itself. */
+ if (CLASS_TYPE_P (type))
+ {
+ d = CLASSTYPE_TYPEINFO_VAR (TYPE_MAIN_VARIANT (type));
+ if (d)
+ return d;
+ }
+
name = mangle_typeinfo_for_type (type);
d = IDENTIFIER_GLOBAL_VALUE (name);
@@ -347,6 +356,9 @@ get_tinfo_decl (type)
pushdecl_top_level (d);
+ if (CLASS_TYPE_P (type))
+ CLASSTYPE_TYPEINFO_VAR (TYPE_MAIN_VARIANT (type)) = d;
+
/* Remember the type it is for. */
TREE_TYPE (name) = type;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index bad7921ffba..844d5926731 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2002-12-01 Mark Mitchell <mark@codesourcery.com>
+
+ PR c++/8727
+ * g++.dg/inherit/typeinfo1.C: New test.
+
+ PR c++/8663
+ * g++.dg/inherit/typedef1.C: New test.
+
2002-11-30 Mark Mitchell <mark@codesourcery.com>
PR c++/8332
diff --git a/gcc/testsuite/g++.dg/inherit/typedef1.C b/gcc/testsuite/g++.dg/inherit/typedef1.C
new file mode 100644
index 00000000000..20da08b2c43
--- /dev/null
+++ b/gcc/testsuite/g++.dg/inherit/typedef1.C
@@ -0,0 +1,8 @@
+namespace NS {
+class X {};
+typedef X Y;
+}
+
+struct Base : virtual public NS::Y {
+ Base() : NS::Y() {}
+};
diff --git a/gcc/testsuite/g++.dg/inherit/typeinfo1.C b/gcc/testsuite/g++.dg/inherit/typeinfo1.C
new file mode 100644
index 00000000000..794776ecbe8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/inherit/typeinfo1.C
@@ -0,0 +1,18 @@
+typedef struct {
+ virtual const char *blah() {
+ return "Heya::blah";
+ }
+} Heya;
+
+struct Grok : public Heya {
+ virtual const char *blah() {
+ return "Grok::blah";
+ }
+};
+
+int main() {
+ Grok *g = new Grok();
+ delete g;
+ return 0;
+}
+
OpenPOWER on IntegriCloud