aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/ipa/devirt-14.C
blob: 517173065c55cc5b4a12b5aa35ff8ded782bce83 (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
/* No devirtualization happens here, but A::foo should not end up as reachable
   because the constructor of A is unreachable and therefore the virtual
   method table referring to A::foo is optimized out.  */
/* { dg-do run } */
/* { dg-options "-O2 -fdump-tree-ssa -fdevirtualize"  } */
class B {
public:
  virtual int foo(void)
{
  return 0;
}
};
namespace {
class A : public B {
public:
  virtual int foo(void)
{
  return 1;
}
};
}
class B a, *b=&a;
main()
{
  if (0)
    {
    class A a;
    a.foo();
    }
  return b->foo();
}

/* { dg-final { scan-tree-dump-not "A::foo" "ssa"} } */
/* { dg-final { cleanup-tree-dump "ssa" } } */