C++ PATCH for virtual bases and templates
Mark Mitchell
mark@codesourcery.com
Sun May 30 21:50:00 GMT 1999
This patch fixes a regression involving virtual base classes. It is
simple, and causes a crash compiling MICO, which is a widely-used C++
application, so I have applied this patch to the branch as well.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
1999-05-30 Mark Mitchell <mark@codesourcery.com>
* lex.c (make_lang_type): Create TYPE_BINFO for
TEMPLATE_TYPE_PARMs just like for non-template types.
Index: testsuite/g++.old-deja/g++.pt/virtual3.C
===================================================================
RCS file: virtual3.C
diff -N virtual3.C
--- /dev/null Sat Dec 5 20:30:03 1998
+++ virtual3.C Sun May 30 21:39:38 1999
@@ -0,0 +1,16 @@
+// Build don't link:
+// Origin: Mark Mitchell <mark@codesourcery.com>
+
+template <typename X>
+struct S : virtual public X
+{
+ int i;
+};
+
+template <typename T>
+struct X : virtual public T, virtual public S<T>
+{
+ int i;
+
+ X () : i (3) {}
+};
Index: cp/lex.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/lex.c,v
retrieving revision 1.112
diff -u -p -r1.112 lex.c
--- lex.c 1999/05/24 00:46:52 1.112
+++ lex.c 1999/05/31 04:39:40
@@ -4680,7 +4680,6 @@ make_lang_type (code)
TYPE_LANG_SPECIFIC (t) = pi;
SET_CLASSTYPE_INTERFACE_UNKNOWN_X (t, interface_unknown);
CLASSTYPE_INTERFACE_ONLY (t) = interface_only;
- TYPE_BINFO (t) = make_binfo (integer_zero_node, t, NULL_TREE, NULL_TREE);
/* Make sure this is laid out, for ease of use later. In the
presence of parse errors, the normal was of assuring this
@@ -4697,6 +4696,13 @@ make_lang_type (code)
TYPE_ALIAS_SET is initialized to -1 by default, so we must
clear it here. */
TYPE_ALIAS_SET (t) = 0;
+
+ /* We need to allocate a TYPE_BINFO even for TEMPALTE_TYPE_PARMs
+ since they can be virtual base types, and we then need a
+ canonical binfo for them. Ideally, this would be done lazily for
+ all types. */
+ if (IS_AGGR_TYPE_CODE (code) || code == TEMPLATE_TYPE_PARM)
+ TYPE_BINFO (t) = make_binfo (integer_zero_node, t, NULL_TREE, NULL_TREE);
return t;
}
More information about the Gcc-patches
mailing list