summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ipa/devirt-44.C
blob: f69e1aa08ac778ef90dd2daf90ec8bada215fded (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* { dg-do compile } */
/* { dg-options "-O3 -fno-ipa-cp -fdump-ipa-inline-details -fno-early-inlining" } */
struct A {
  virtual int foo () {return 1;}
  int wrapfoo () {foo();}
  A() {wrapfoo();}
};
struct B:A {virtual int foo () {return 2;}};

void dostuff(struct A *);

static void
test (struct A *a)
{
  dostuff (a);
  if (a->foo ()!= 2)
    __builtin_abort ();
}

main()
{
  struct B a;
  dostuff (&a);
  test (&a);
}
/* Here one invocation of foo is while type is in construction, while other is not.
   Check that we handle that.  */

/* { dg-final { scan-ipa-dump "Second type is base of first" "inline"  } } */
/* { dg-final { scan-ipa-dump-times "Discovered a virtual call to a known target\[^\\n\]*A::foo" 1 "inline"  } } */
/* { dg-final { scan-ipa-dump-times "Discovered a virtual call to a known target\[^\\n\]*B::foo" 1 "inline"  } } */