From 9b03516da48c1d86b290595032444bc8bbfd4ed5 Mon Sep 17 00:00:00 2001 From: mmitchel Date: Thu, 10 Feb 2000 08:24:15 +0000 Subject: [PATCH] * class.c (dfs_modify_vtables): Tweak calculation of functions to override. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@31886 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 5 ++ gcc/cp/class.c | 16 +++--- gcc/testsuite/g++.old-deja/g++.other/vtbl2.C | 76 ++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/g++.old-deja/g++.other/vtbl2.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e632672..bd471d2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2000-02-10 Mark Mitchell + + * class.c (dfs_modify_vtables): Tweak calculation of functions to + override. + 2000-02-08 Nathan Sidwell * typeck.c (strip_all_pointer_quals): Use TYPE_MAIN_VARIANT, to diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 3f8e348..9b0bae5 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -3009,9 +3009,9 @@ dfs_modify_vtables (binfo, data) t = (tree) data; - /* If we're support RTTI then we always need a new vtable to point - to the RTTI information. Under the new ABI we may need a new - vtable to contain vcall and vbase offsets. */ + /* If we're supporting RTTI then we always need a new vtable to + point to the RTTI information. Under the new ABI we may need + a new vtable to contain vcall and vbase offsets. */ if (flag_rtti || flag_new_abi) make_new_vtable (t, binfo); @@ -3031,6 +3031,7 @@ dfs_modify_vtables (binfo, data) tree overrider; tree vindex; tree delta; + int i; /* Find the function which originally caused this vtable entry to be present. */ @@ -3039,9 +3040,12 @@ dfs_modify_vtables (binfo, data) b = dfs_walk (binfo, dfs_find_base, NULL, DECL_VIRTUAL_CONTEXT (fn)); fn = skip_rtti_stuff (TYPE_BINFO (BINFO_TYPE (b)), BINFO_TYPE (b), - NULL); - while (!tree_int_cst_equal (DECL_VINDEX (BV_FN (fn)), vindex)) - fn = TREE_CHAIN (fn); + &i); + while (i < TREE_INT_CST_LOW (vindex)) + { + fn = TREE_CHAIN (fn); + ++i; + } fn = BV_FN (fn); /* Handle the case of a virtual function defined in BINFO diff --git a/gcc/testsuite/g++.old-deja/g++.other/vtbl2.C b/gcc/testsuite/g++.old-deja/g++.other/vtbl2.C new file mode 100644 index 0000000..c812d30 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/vtbl2.C @@ -0,0 +1,76 @@ +// Copyright (C) 2000 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 8 Feb 2000 + +// vtable construction reorganisation broke this + +// execution test + +#include + +static int fail = 0; + +void bad (char const *name) +{ + printf ("Bad %s\n", name); + fail = 1; +} +void ok (char const *name) +{ + printf ("Ok %s\n", name); +} + +struct Core +{ + virtual ~Core (); + virtual void Wibble () {bad (__PRETTY_FUNCTION__);} + virtual void Wobble () {bad (__PRETTY_FUNCTION__);} + virtual void Bogus () {bad (__PRETTY_FUNCTION__);} +}; +struct Side +{ + virtual ~Side (); + virtual void Arfle () {bad (__PRETTY_FUNCTION__);} + virtual void Barfle () {bad (__PRETTY_FUNCTION__);} + virtual void Gloop () {bad (__PRETTY_FUNCTION__);} + virtual void Glorp () {bad (__PRETTY_FUNCTION__);} + virtual void Glump () {bad (__PRETTY_FUNCTION__);} + virtual void Bogus () {bad (__PRETTY_FUNCTION__);} +}; +struct Base : Core +{ + virtual ~Base (); + virtual void Bink () {bad (__PRETTY_FUNCTION__);} + virtual void Bonk () {bad (__PRETTY_FUNCTION__);} + virtual void Bogus () {bad (__PRETTY_FUNCTION__);} +}; +struct Multi : Base, Side +{ + virtual ~Multi (); + virtual void Stomped () {ok (__PRETTY_FUNCTION__);} + virtual void Bunk () {bad (__PRETTY_FUNCTION__);} + virtual void Bogus () {bad (__PRETTY_FUNCTION__);} +}; +struct Trail : Multi +{ + virtual ~Trail (); +}; +Core::~Core () {} +Side::~Side () {} +Base::~Base () {} +Multi::~Multi () {} +Trail::~Trail () {} + +void foo (Multi *ptr) +{ + ptr->Stomped (); +} + +int main () +{ + Multi m; + Trail t; + + foo (&m); + foo (&t); + return fail != 0; +} -- 2.7.4