diff options
Diffstat (limited to 'gcc/testsuite/g++.dg/ipa/devirt-11.C')
-rw-r--r-- | gcc/testsuite/g++.dg/ipa/devirt-11.C | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/ipa/devirt-11.C b/gcc/testsuite/g++.dg/ipa/devirt-11.C new file mode 100644 index 00000000000..c139f8f9633 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/devirt-11.C @@ -0,0 +1,50 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-ipa-inline" } */ +int baz (); +struct A +{ + virtual int fn2 () = 0; + virtual int *fn3 (); + double *fn4 (); + int fn5 (int); + template <class T> + void fn1 (A &, T) { fn3 (); fn4 (); fn2 (); } +}; +struct B : A +{ + int fn2 () { return 6; } + void fn3 (int, double); + B (bool = true); + B (int, int); +}; +template <typename T> +void +foo (B &x, A &y, A &z) +{ + y.fn2 (); + z.fn2 (); + int i = baz (); + int j = (y.fn3 ())[i]; + x.fn3 (j, (y.fn4 ())[i] + (z.fn4 ())[z.fn5 (j)]); +} +inline B +operator+ (A &y, A &z) +{ + B x; + foo<int> (x, y, z); + return x; +} +void +bar () +{ + B a, b, c (4, 0), d; + a.fn1 (b, .6); + baz (); + c + d; +} +/* While inlining function called once we should devirtualize a new call to fn2 + and two to fn3. While doing so the new symbol for fn2 needs to be + introduced. */ +/* { dg-final { scan-ipa-dump-times "Discovered a virtual call to a known target" 3 "inline" } } */ +/* { dg-final { scan-ipa-dump-times "and turned into root of the clone tree" 1 "inline" } } */ +/* { dg-final { cleanup-ipa-dump "inline" } } */ |