]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/8727 (compiler confused by inheritance from an anonymous struct)
authorMark Mitchell <mark@codesourcery.com>
Sun, 1 Dec 2002 20:40:38 +0000 (20:40 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Sun, 1 Dec 2002 20:40:38 +0000 (20:40 +0000)
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

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/init.c
gcc/cp/rtti.c
gcc/testsuite/ChangeLog

index ea9463d584c13b26b535e1cd57791d8c0a203796..9aee794d4f14dc59076074f4d9baa6163406e102 100644 (file)
@@ -1,3 +1,14 @@
+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
index 9e8199f9faf8ea72ce933d586221553c0bf1e201..3a43eaa06e79aefbe9d8444123917eec8d61f174 100644 (file)
@@ -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)
 \f
+/* 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
index df63e6767701cb5750f93830025484fea261ca48..1e08908910ab46b518d8b282cd9470e17cb31437 100644 (file)
@@ -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)
index 39cb1c680545226469a5e5858f8d1024d645372a..fbb37fe2f5c10c5c07e0d8bd9d0bb74a9880a0e0 100644 (file)
@@ -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;
     }
index 554f55cd8a49b2d09708f38d15959861b7ebde58..9ce6bf1bfcc94c3238759998440d88530c4864f9 100644 (file)
@@ -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