view gcc/testsuite/g++.dg/ipa/pr66616.C @ 152:2b5abeee2509

update gcc11
author anatofuz
date Mon, 25 May 2020 07:50:57 +0900
parents 04ced10e8804
children
line wrap: on
line source

// { dg-do run }
// { dg-options "-O2 -fipa-cp-clone" }

struct Distraction
{
  char fc[8];
  virtual Distraction * return_self ()
  { return this; }
};

static int go;

struct A;

struct A
{
  int fi;

  A () : fi(0) {}
  A (int pi) : fi (pi) {}
  virtual void foo (int p) = 0;
};

struct B;

struct B : public Distraction, A
{
  B () : Distraction(), A() { }
  B (int pi) : Distraction (), A (pi) {}
  virtual void foo (int p)
  {
    int o = fi;
    for (int i = 0; i < p; i++)
      o += i + i * i;
    go = o;
  }
};

struct B gb2 (2);

extern "C" void abort (void);

int
main (void)
{
  for (int i = 0; i < 2; i++)
    {
      struct A *p = &gb2;
      p->foo (0);
      if (go != 2)
	abort ();
    }
  return 0;
}