diff options
Diffstat (limited to 'gcc/testsuite/g++.dg/ipa/devirt-18.C')
-rw-r--r-- | gcc/testsuite/g++.dg/ipa/devirt-18.C | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/ipa/devirt-18.C b/gcc/testsuite/g++.dg/ipa/devirt-18.C new file mode 100644 index 00000000000..dbbe597c92c --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/devirt-18.C @@ -0,0 +1,37 @@ +/* We shall devirtualize to unreachable. No anonymous type method should surivve + reachability. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ssa" } */ +namespace { +class B { +public: + virtual int foo(void) +{ + return 0; +} +}; +class A : public B { +public: + virtual int foo(void) +{ + return 1; +} +}; +} +class B *b; +main() +{ + if (0) + { + class A a; + a.foo(); + class B b; + b.foo(); + } + return b->foo(); +} + +/* { dg-final { scan-tree-dump-not "A::foo" "ssa"} } */ +/* { dg-final { scan-tree-dump-not "B::foo" "ssa"} } */ +/* { dg-final { scan-tree-dump "builtin_unreachable" "ssa"} } */ +/* { dg-final { cleanup-tree-dump "ssa" } } */ |