This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[objc++] Fix code setting binfo
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 28 Jun 2014 21:47:35 +0200
- Subject: [objc++] Fix code setting binfo
- Authentication-results: sourceware.org; auth=none
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));