[objc++] Fix code setting binfo

Jan Hubicka hubicka@ucw.cz
Sat Jun 28 19:47:00 GMT 2014


Hi,
this patch fixes similar bug as in ipa-devirt.  objc_xref_basetypes is used when
building obj-C++ structure.  The structure always contains self-reference that
builds type variant early.  The variant's binfo is one assigned by
C++ FE's version of xref_basetypes, while the main variant gets overwritten
here.  Fixed thus.

Honza

Bootstrapped/regtested x86_64-linux, comitted.

	* objc-act.c (objc_xref_basetypes): Set TYPE_BINFO of type variants,
	too.
Index: objc-act.c
===================================================================
--- objc-act.c	(revision 212098)
+++ objc-act.c	(working copy)
@@ -2695,12 +2695,16 @@ objc_copy_binfo (tree binfo)
 static void
 objc_xref_basetypes (tree ref, tree basetype)
 {
+  tree variant;
   tree binfo = make_tree_binfo (basetype ? 1 : 0);
-
   TYPE_BINFO (ref) = binfo;
   BINFO_OFFSET (binfo) = size_zero_node;
   BINFO_TYPE (binfo) = ref;
 
+  gcc_assert (TYPE_MAIN_VARIANT (ref) == ref);
+  for (variant = ref; variant; variant = TYPE_NEXT_VARIANT (variant))
+    TYPE_BINFO (variant) = binfo;
+
   if (basetype)
     {
       tree base_binfo = objc_copy_binfo (TYPE_BINFO (basetype));



More information about the Gcc-patches mailing list