This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
p16146
- To: egcs-patches at cygnus dot com
- Subject: p16146
- From: mrs at wrs dot com (Mike Stump)
- Date: Tue, 7 Jul 1998 18:59:27 -0700
- Cc: jason at cygnus dot com
This solves PR 16146:
1998-07-07 Mike Stump <mrs@wrs.com>
* search.c (compute_access): We can't rely upon basetype_path
having a path, so we recalculate the path.
Cures problem with p16146.C.
The use of basetype_path in enforce_access and friends is wrong. I
think that we should remove the BINFO_INHERITANCE_CHAIN, and have a
cache of recently used values. They should be in the form of a
TREE_VEC, so that we can walk them in any order.
I think the code would be cleaner and easier to understand.
Doing diffs in gcc/cp/search.c.~1~:
*** gcc/cp/search.c.~1~ Mon Jun 15 12:14:01 1998
--- gcc/cp/search.c Tue Jul 7 18:42:30 1998
*************** compute_access (basetype_path, field)
*** 976,981 ****
--- 976,990 ----
if (DECL_NAME (field) && VFIELD_NAME_P (DECL_NAME (field)) == 1)
PUBLIC_RETURN;
+ /* We need to recalculate the path, as basetype_path isn't really a
+ path, just a binfo that can be found. */
+ if (current_class_type
+ && get_binfo (basetype_path, current_class_type, 0) == 0)
+ {
+ /* Oops, we need to find this sucker, but where did it
+ start? */
+ }
+
/* Member found immediately within object. */
if (BINFO_INHERITANCE_CHAIN (basetype_path) == NULL_TREE)
{
--------------
Doing diffs in gcc/testsuite/g++.old-deja/g++.mike/p16146.C.~1~:
*** gcc/testsuite/g++.old-deja/g++.mike/p16146.C.~1~ Mon Jul 6 19:28:27 1998
--- gcc/testsuite/g++.old-deja/g++.mike/p16146.C Mon Jul 6 19:28:01 1998
***************
*** 0 ****
--- 1,89 ----
+ // prms-id: 16146
+
+ extern "C" int printf (const char *, ...);
+
+ class myFoundation {
+ protected:
+ myFoundation () { count = 0; };
+ virtual ~myFoundation () {};
+
+ public:
+ void addRef () { ++count; }
+ void removeRef () { if (count > 0) --count; }
+
+ private:
+ long count;
+ };
+
+
+ class firstIntermediate :virtual public myFoundation {
+ public:
+ firstIntermediate () {};
+ ~firstIntermediate () {};
+
+ void bar () { printf ("Bar\n"); }
+ };
+
+
+ class firstBase : public firstIntermediate {
+ public:
+ firstBase () {};
+ ~firstBase () {};
+
+ virtual void g () {};
+ };
+
+
+ class secondIntermediate : virtual public myFoundation {
+ public:
+ secondIntermediate () {};
+ ~secondIntermediate () {};
+
+ virtual void h () {};
+ };
+
+
+ class secondBase : public secondIntermediate {
+ public:
+ secondBase () {};
+ ~secondBase () {};
+
+ virtual void h () {};
+ };
+
+
+ class typeInterface : virtual public firstBase {
+ public:
+ typeInterface () {};
+ ~typeInterface () {};
+
+ virtual void i () {};
+ };
+
+ class classServices : virtual public firstBase,
+ public secondBase {
+ public:
+ classServices () {};
+ ~classServices () {};
+
+ virtual void j () {};
+ };
+
+ class classImplementation : public typeInterface,
+ public classServices {
+ public:
+ classImplementation () {};
+ ~classImplementation () {};
+
+ void g () {};
+ void h () {};
+ void i () {};
+ void j () {};
+ };
+
+ main () {
+ firstBase* fbp = new classImplementation;
+ classImplementation* cip = dynamic_cast <classImplementation*> (fbp);
+ cip->addRef();
+ myFoundation* mfp = cip;
+ }
--------------