PR c++/47873
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 28 Feb 2011 21:41:21 +0000 (21:41 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 28 Feb 2011 21:41:21 +0000 (21:41 +0000)
* class.c (update_vtable_entry_for_fn): Check BINFO_LOST_PRIMARY_P
after checking for a non-thunk.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@170576 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/class.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/inherit/covariant18.C [new file with mode: 0644]

index 50e4b48..d1b1b4a 100644 (file)
@@ -1,3 +1,9 @@
+2011-02-28  Jason Merrill  <jason@redhat.com>
+
+       PR c++/47873
+       * class.c (update_vtable_entry_for_fn): Check BINFO_LOST_PRIMARY_P
+       after checking for a non-thunk.
+
 2011-02-26  Jason Merrill  <jason@redhat.com>
 
        PR c++/47904
index 0d485fc..1325260 100644 (file)
@@ -2250,10 +2250,10 @@ update_vtable_entry_for_fn (tree t, tree binfo, tree fn, tree* virtuals,
        {
          tree main_binfo = TYPE_BINFO (BINFO_TYPE (b));
          tree bv = chain_index (ix, BINFO_VIRTUALS (main_binfo));
-         if (BINFO_LOST_PRIMARY_P (b))
-           lost = true;
          if (!DECL_THUNK_P (TREE_VALUE (bv)))
            break;
+         if (BINFO_LOST_PRIMARY_P (b))
+           lost = true;
        }
       first_defn = b;
     }
index 10c430a..fc2ad4f 100644 (file)
@@ -1,3 +1,7 @@
+2011-02-28  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/inherit/covariant18.C: New.
+
 2011-02-28  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/47893
diff --git a/gcc/testsuite/g++.dg/inherit/covariant18.C b/gcc/testsuite/g++.dg/inherit/covariant18.C
new file mode 100644 (file)
index 0000000..31e6216
--- /dev/null
@@ -0,0 +1,41 @@
+// PR c++/47873
+// { dg-do run }
+
+struct Base
+{
+    virtual ~Base(){}
+
+    virtual Base& This() { return *this; }
+};
+
+
+struct Ent : virtual Base
+{
+    void *m_Body;
+
+    Ent& This() { return *this; }
+
+    virtual Ent& body()
+    {
+        return This();
+    }
+
+};
+
+
+struct Msg : virtual Ent
+{
+    Msg()
+    {
+        body();
+    }
+
+    Msg& This() { return *this; }
+};
+
+int main()
+{
+    Msg m;
+
+    return 0;
+}