From bfec1a842feaaff7d4bda47e35f22de1e8c4f373 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Mon, 7 Jun 1999 13:28:06 +0000 Subject: [PATCH] search.c (convert_pointer_to_single_level): Reimplement without using get_binfo. * search.c (convert_pointer_to_single_level): Reimplement without using get_binfo. From-SVN: r27394 --- gcc/cp/ChangeLog | 10 +++++++ gcc/cp/search.c | 26 ++++++++++++++----- .../g++.old-deja/g++.other/virtual5.C | 20 ++++++++++++++ 3 files changed, 49 insertions(+), 7 deletions(-) create mode 100644 gcc/testsuite/g++.old-deja/g++.other/virtual5.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e89dfdff1a2..72aa8d47962 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +1999-06-07 Mark Mitchell + + * search.c (convert_pointer_to_single_level): Reimplement without + using get_binfo. + +1999-06-06 Mark Mitchell + + * method.c (is_back_referenceable_type): Back-reference bools when + not squangling. + 1999-06-07 Dave Brolley * lex.c (real_yylex): Replace unused bytes from bad multibyte char. diff --git a/gcc/cp/search.c b/gcc/cp/search.c index 63b733d3ad8..9bac6e6ad49 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -2057,17 +2057,29 @@ static tree convert_pointer_to_single_level (to_type, expr) tree to_type, expr; { + tree derived; tree binfo_of_derived; - tree last; + int i; - binfo_of_derived = TYPE_BINFO (TREE_TYPE (TREE_TYPE (expr))); - last = get_binfo (to_type, TREE_TYPE (TREE_TYPE (expr)), 0); - my_friendly_assert (BINFO_INHERITANCE_CHAIN (last) == binfo_of_derived, - 980827); + derived = TREE_TYPE (TREE_TYPE (expr)); + binfo_of_derived = TYPE_BINFO (derived); my_friendly_assert (BINFO_INHERITANCE_CHAIN (binfo_of_derived) == NULL_TREE, 980827); - return build_vbase_path (PLUS_EXPR, build_pointer_type (to_type), expr, - last, 1); + for (i = CLASSTYPE_N_BASECLASSES (derived) - 1; i >= 0; --i) + { + tree binfo = BINFO_BASETYPE (binfo_of_derived, i); + my_friendly_assert (BINFO_INHERITANCE_CHAIN (binfo) == binfo_of_derived, + 980827); + if (same_type_p (BINFO_TYPE (binfo), to_type)) + return build_vbase_path (PLUS_EXPR, + build_pointer_type (to_type), + expr, binfo, 1); + } + + my_friendly_abort (19990607); + + /* NOTREACHED */ + return NULL_TREE; } tree markedp (binfo, data) diff --git a/gcc/testsuite/g++.old-deja/g++.other/virtual5.C b/gcc/testsuite/g++.old-deja/g++.other/virtual5.C new file mode 100644 index 00000000000..bf700569de4 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/virtual5.C @@ -0,0 +1,20 @@ +// Build don't link: +// Special g++ Options: -w +// Origin: Derived from code by Andris Pavenis + +class vector {}; + +class V +{ +}; + +class A : public vector +{ +}; + +class B : public A, virtual V, public vector +{ + B() {} +}; + + -- 2.30.2