2015-03-24 Paolo Carlini <paolo.carlini@oracle.com>
[official-gcc.git] / gcc / testsuite / g++.dg / ipa / devirt-14.C
blob456d44f84bd6aa427cc01a5474ba660db502d3a1
1 /* No devirtualization happens here, but A::foo should not end up as reachable
2    because the constructor of A is unreachable and therefore the virtual
3    method table referring to A::foo is optimized out.  */
4 /* { dg-do run } */
5 /* { dg-options "-O2 -fdump-tree-ssa"  } */
6 class B {
7 public:
8   virtual int foo(void)
10   return 0;
13 namespace {
14 class A : public B {
15 public:
16   virtual int foo(void)
18   return 1;
22 class B a, *b=&a;
23 main()
25   if (0)
26     {
27     class A a;
28     a.foo();
29     }
30   return b->foo();
33 /* { dg-final { scan-tree-dump-not "A::foo" "ssa"} } */
34 /* { dg-final { cleanup-tree-dump "ssa" } } */