Commit a82d6da5 by Mark Mitchell Committed by Mark Mitchell

re PR c++/8727 (compiler confused by inheritance from an anonymous struct)

	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.

From-SVN: r59694
parent 558bb2c4
2002-12-01 Mark Mitchell <mark@codesourcery.com> 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++/8332
PR c++/8493 PR c++/8493
* decl.c (cxx_init_decl_processing): Use size_type_node, not * decl.c (cxx_init_decl_processing): Use size_type_node, not
......
...@@ -1159,6 +1159,7 @@ struct lang_type_class GTY(()) ...@@ -1159,6 +1159,7 @@ struct lang_type_class GTY(())
tree vfields; tree vfields;
tree vcall_indices; tree vcall_indices;
tree vtables; tree vtables;
tree typeinfo_var;
tree vbases; tree vbases;
tree tags; tree tags;
tree as_base; tree as_base;
...@@ -1637,6 +1638,12 @@ struct lang_type GTY(()) ...@@ -1637,6 +1638,12 @@ struct lang_type GTY(())
#define CLASSTYPE_VTABLES(NODE) \ #define CLASSTYPE_VTABLES(NODE) \
(LANG_TYPE_CLASS_CHECK (NODE)->vtables) (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. */ /* Accessor macros for the vfield slots in structures. */
/* List of virtual table fields that this type contains (both the primary /* List of virtual table fields that this type contains (both the primary
......
...@@ -967,7 +967,7 @@ expand_member_init (tree name, tree init) ...@@ -967,7 +967,7 @@ expand_member_init (tree name, tree init)
} }
else if (TYPE_P (name)) else if (TYPE_P (name))
{ {
basetype = name; basetype = TYPE_MAIN_VARIANT (name);
name = TYPE_NAME (name); name = TYPE_NAME (name);
} }
else if (TREE_CODE (name) == TYPE_DECL) else if (TREE_CODE (name) == TYPE_DECL)
......
...@@ -328,6 +328,15 @@ get_tinfo_decl (type) ...@@ -328,6 +328,15 @@ get_tinfo_decl (type)
type = build_function_type (TREE_TYPE (type), type = build_function_type (TREE_TYPE (type),
TREE_CHAIN (TYPE_ARG_TYPES (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); name = mangle_typeinfo_for_type (type);
d = IDENTIFIER_GLOBAL_VALUE (name); d = IDENTIFIER_GLOBAL_VALUE (name);
...@@ -347,6 +356,9 @@ get_tinfo_decl (type) ...@@ -347,6 +356,9 @@ get_tinfo_decl (type)
pushdecl_top_level (d); pushdecl_top_level (d);
if (CLASS_TYPE_P (type))
CLASSTYPE_TYPEINFO_VAR (TYPE_MAIN_VARIANT (type)) = d;
/* Remember the type it is for. */ /* Remember the type it is for. */
TREE_TYPE (name) = type; TREE_TYPE (name) = type;
} }
......
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> 2002-11-30 Mark Mitchell <mark@codesourcery.com>
PR c++/8332 PR c++/8332
......
namespace NS {
class X {};
typedef X Y;
}
struct Base : virtual public NS::Y {
Base() : NS::Y() {}
};
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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment