From: Mark Mitchell Date: Sun, 1 Dec 2002 20:40:38 +0000 (+0000) Subject: re PR c++/8727 (compiler confused by inheritance from an anonymous struct) X-Git-Tag: releases/gcc-3.2.2~233 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=685d4f0abfb80a90d4d975931ba1954922efeefb;p=thirdparty%2Fgcc.git 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: r59697 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ea9463d584c1..9aee794d4f14 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,14 @@ +2002-12-01 Mark Mitchell + + 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 PR c++/8332 diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 9e8199f9faf8..3a43eaa06e79 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -1266,6 +1266,7 @@ struct lang_type tree primary_base; tree vfields; + tree typeinfo_var; tree vbases; tree tags; tree size; @@ -1686,6 +1687,12 @@ struct lang_type /* Used by various search routines. */ #define IDENTIFIER_MARKED(NODE) TREE_LANG_FLAG_0 (NODE) +/* 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) \ + (TYPE_LANG_SPECIFIC (NODE)->typeinfo_var) + /* Accessor macros for the vfield slots in structures. */ /* The virtual function pointer fields that this type contains. For a diff --git a/gcc/cp/init.c b/gcc/cp/init.c index df63e6767701..1e08908910ab 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -1062,7 +1062,7 @@ expand_member_init (exp, name, 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 39cb1c680545..fbb37fe2f5c1 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -327,6 +327,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); @@ -346,6 +355,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 554f55cd8a49..9ce6bf1bfcc9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2002-12-01 Mark Mitchell + + 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 PR c++/8332