* g++.dg/ipa/devirt-15.C: New testcase.
[official-gcc.git] / gcc / testsuite / g++.dg / ipa / devirt-15.C
blobf9cd3ae5a67f69025667a180ffe0dc72c2c117b5
1 /* Check that we speculatively devirutalize call to FOO to B::foo becuase
2    A is noreturn.  */
3 /* { dg-do compile } */
4 /* { dg-options "-O2 -fdump-ipa-devirt"  } */
5 class A {
6 public:
7   virtual int foo(void)
8     {
9       throw (1);
10       return 0;
11     }
15 class B : public A {
16 public:
17   virtual int foo(void);
20 int
21 B::foo(void)
23   return 1;
25 class A a, *b=&a;
26 void
27 m(void)
29   b->foo();
31 main()
33   m();
36 /* { dg-final { scan-ipa-dump "Speculatively devirtualizing call" "devirt"} } */
37 /* { dg-final { cleanup-ipa-dump "devirt" } } */
38 /* Match if (PROF_6 == foo) to verify that the speculation survived.  */
39 /* { dg-final { scan-tree-dump "== foo" "optimized"} } */
40 /* { dg-final { cleanup-tree-dump "optimized" } } */