aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/ipa/devirt-11.C
blob: ca8ea4cc24b790fee1e1a348c71a10cc1818caad (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-ipa-inline -fno-devirtualize-speculatively" } */
int baz ();
struct A
{
  virtual int fn2 () = 0;
  virtual int *fn3 ();
  double *fn4 ();
  int fn5 (int);
  template <class T>
  void fn1 (A &, T) { fn3 (); fn4 (); fn2 (); }
};
struct B : A
{
  int fn2 () { return 6; }
  void fn3 (int, double);
  B (bool = true);
  B (int, int);
};
template <typename T>
void
foo (B &x, A &y, A &z)
{
  y.fn2 ();
  z.fn2 ();
  int i = baz ();
  int j = (y.fn3 ())[i];
  x.fn3 (j, (y.fn4 ())[i] + (z.fn4 ())[z.fn5 (j)]);
}
inline B
operator+ (A &y, A &z)
{
  B x;
  foo<int> (x, y, z);
  return x;
}
void
bar ()
{
  B a, b, c (4, 0), d;
  a.fn1 (b, .6);
  baz ();
  c + d;
}
/* While inlining function called once we should devirtualize a new call to fn2
   and two to fn3. While doing so the new symbol for fn2 needs to be
   introduced.  */
/* { dg-final { scan-ipa-dump-times "Discovered a virtual call to a known target" 1 "inline"  } } */
/* { dg-final { cleanup-ipa-dump "inline" } } */