aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/ipa/devirt-24.C
blob: 01bfdc2ec504254538a194d885f13bea74566723 (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
/* { dg-do compile } */
/* { dg-options "-O3 -fno-ipa-sra -fdump-ipa-inline -fdump-ipa-cp"  } */
void pad(void);
class A {};
class B {
public:
  A &operator[](int);
};
class C : B {
public:
  virtual int m_fn1() { return 0; }
  inline A &operator[](int p1) {
    int a;
    a = m_fn1();
    static_cast<void>(__builtin_expect(a, 0) ?: 0);
    return B::operator[](p1);
  }
};

int *e;
static void sort(C &p1, C &p2) {
  for (int i=0;; i++) {
    A c, d = p2[0];
	pad();
	pad();
	pad();
  }
}

int test ();

void update_sources() {
while (test()) {
    C f;
C *b = new (C);
    sort(f, *b);
  }
}
/* { dg-final { scan-ipa-dump-times "Discovered a virtual call to a known target" 1 "inline"  } } */
/* { dg-final { cleanup-ipa-dump "inline" } } */
/* { dg-final { scan-ipa-dump-times "Aggregate passed by reference" 1 "cp"  } } */
/* { dg-final { cleanup-ipa-dump "cp" } } */