* g++.dg/ipa/devirt-15.C: New testcase.
authorJan Hubicka <jh@suse.cz>
Sun, 1 Sep 2013 17:06:40 +0000 (19:06 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Sun, 1 Sep 2013 17:06:40 +0000 (17:06 +0000)
From-SVN: r202153

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ipa/devirt-15.C [new file with mode: 0644]

index c42a3dae39cf1a493be1ea5ce761179742d408b0..7ff5882d6b948bde77a33ad756910a5b06f7f58d 100644 (file)
@@ -1,3 +1,7 @@
+2013-09-01  Jan Hubicka  <jh@suse.cz>  
+
+       * g++.dg/ipa/devirt-15.C: New testcase.
+
 2013-09-01  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/specs/linker_alias.ads: Skip on Darwin.
diff --git a/gcc/testsuite/g++.dg/ipa/devirt-15.C b/gcc/testsuite/g++.dg/ipa/devirt-15.C
new file mode 100644 (file)
index 0000000..f9cd3ae
--- /dev/null
@@ -0,0 +1,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"  } */
+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" } } */