cp:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 14 Oct 2005 08:38:59 +0000 (08:38 +0000)
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 14 Oct 2005 08:38:59 +0000 (08:38 +0000)
PR c++/23984
* class.c (build_base_path): The vtable is always the first thing
in the vtt.
testsuite:
PR c++/23984
* g++.dg/init/ctor7.C: New.

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

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

index ec81292..75ca019 100644 (file)
@@ -1,3 +1,9 @@
+2005-10-13  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR c++/23984
+       * class.c (build_base_path): The vtable is always the first thing
+       in the vtt.
+
 2005-10-13  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/20721
index dceeffe..dc52975 100644 (file)
@@ -325,16 +325,14 @@ build_base_path (enum tree_code code,
 
       if (fixed_type_p < 0 && in_base_initializer)
        {
-         /* In a base member initializer, we cannot rely on
-            the vtable being set up. We have to use the vtt_parm.  */
-         tree derived = BINFO_INHERITANCE_CHAIN (v_binfo);
+         /* In a base member initializer, we cannot rely on the
+            vtable being set up.  We have to indirect via the
+            vtt_parm.  */
          tree t;
 
-         t = TREE_TYPE (TYPE_VFIELD (BINFO_TYPE (derived)));
+         t = TREE_TYPE (TYPE_VFIELD (current_class_type));
          t = build_pointer_type (t);
          v_offset = convert (t, current_vtt_parm);
-         v_offset = build2 (PLUS_EXPR, t, v_offset,
-                            BINFO_VPTR_INDEX (derived));
          v_offset = build_indirect_ref (v_offset, NULL);
        }
       else
index 11807d3..a119dca 100644 (file)
@@ -1,3 +1,8 @@
+2005-10-14  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR c++/23984
+       * g++.dg/init/ctor7.C: New.
+
 2005-10-13  David Edelsohn  <edelsohn@gnu.org>
 
        PR c++/23730
diff --git a/gcc/testsuite/g++.dg/init/ctor7.C b/gcc/testsuite/g++.dg/init/ctor7.C
new file mode 100644 (file)
index 0000000..3378a15
--- /dev/null
@@ -0,0 +1,51 @@
+// { dg-do run }
+
+// Copyright (C) 2005 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 13 Oct 2005 <nathan@codesourcery.com>
+
+// PR 23984:ICE
+// Origin:  Andrew Pinski pinskia@gcc.gnu.org
+
+struct B
+{
+  virtual void Foo ();
+};
+
+void B::Foo ()
+{
+}
+
+struct D : virtual B
+{
+};
+
+struct E
+{
+  B *ptr;
+  
+  E (B *);
+};
+
+static B *ptr;
+
+E::E (B *ptr_)
+  :ptr (ptr_)
+{
+}
+
+struct G : D, E
+{
+  G ();
+};
+
+G::G ()
+  : E (this)
+{
+}
+
+int main ()
+{
+  G object;
+
+  return object.ptr != &object;
+}