RFC: add inheritance support to nonoverlapping_component_refs_p

Dan Nicolaescu dann@godzilla.ICS.UCI.EDU
Sun May 26 16:01:00 GMT 2002


Richard Henderson <rth@redhat.com> writes:

  > 
  > I think the attached patch will do what you want.  I've only
  > tested it on the given test case.  It needs something more
  > thorough before being checked in.  Since you have an interest,
  > would you mind doing that?  

It turns out that the problem that I mentioned is not with your patch,
but with the information available. 

Look at the example below (derived from your example): 


/* { dg-do link } */

class first
{
public:
  double d;
  char f1;
};

class middle : public first
{
};

class second : public middle
{
public:
  int f2;
  short a;
};

class third
{
public:
  char a;
  int f3;
};

class multi: public third, public first
{
};

extern void link_error ();

void
foobar (first *s1, multi *s3)
{
  s1->f1 = 0;
  s3->f3 = 0;
  s1->f1++;
  s3->f3++;
  s1->f1++;
  s3->f3++;
  if (s1->f1 != 2)
    link_error ();
}

void
foo (first *s1, second *s2)
{
  s1->f1 = 0;
  s2->f2 = 0;
  s1->f1++;
  s2->f2++;
  s1->f1++;
  s2->f2++;
  if (s1->f1 != 2)
    link_error ();
}

int
main()
{
  first a;
  second b;
  multi c;
  foo(&a, &b);
  foobar(&a, &c);
  return 0;
}


For "foobar", in nonoverlapping_memrefs_p "typex" for s3->f3 has the
type "third", not "multi", so nonoverlapping_component_refs_p has no
chance on finding a common type. Is there a way to get to "multi" ? 


Testing is in progress. 



More information about the Gcc-patches mailing list