summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ipa/devirt-15.C
blob: 2ea85f487f4d92ef22723d0974c8e4ef6e9a563f (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
/* Check that we speculatively devirutalize call to FOO to B::foo becuase
   A is noreturn.  */
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-ipa-devirt -fdump-tree-optimized"  } */
class A {
public:
  virtual int foo(void)
    {
      throw (1);
      return 0;
    }
};


class B : public A {
public:
  virtual int foo(void);
};

int
B::foo(void)
{
  return 1;
}
class A a, *b=&a;
void
m(void)
{
  b->foo();
}
main()
{
  m();
}

/* { dg-final { scan-ipa-dump "Speculatively devirtualizing call" "devirt"} } */
/* { dg-final { cleanup-ipa-dump "devirt" } } */
/* Match if (PROF_6 == foo) to verify that the speculation survived.  */
/* { dg-final { scan-tree-dump "== foo" "optimized"} } */
/* { dg-final { cleanup-tree-dump "optimized" } } */