Debian Codegraph @

gcc/testsuite/g++.dg/ipa/devirt-19.C

raw
1 /* We should specialize for &b and devirtualize the call.
2 Previously we were failing by considering CLOBBER statement to be
3 a type change. */
4 /* { dg-do compile } */
5 /* { dg-options "-O2 -fdump-ipa-cp -fipa-cp-clone -Wno-return-type" } */
6
7 struct A {
8 void operator==(const A &);
9 };
10 class B {
11 public:
12 A m_fn1();
13 A m_fn2();
14 };
15 template <typename T, typename M> class C {
16 public:
17 T Key;
18 const M &m_fn2(const T &);
19 virtual void m_fn1() {}
20 B _map;
21 };
22
23 C<int, int> b;
24 template <typename T, typename M> const M &C<T, M>::m_fn2(const T &) {
25
26 A a = _map.m_fn2();
27 a == _map.m_fn1();
28 m_fn1();
29 static M m;
30 return m;
31 }
32
33 void fn1() { b.m_fn2(0); }
34 /* { dg-final { scan-ipa-dump-times "Discovered a virtual call to a known target" 1 "cp" } } */
35