Be careful about comdat boundary in ICF (PR ipa/82352).
[official-gcc.git] / gcc / testsuite / g++.dg / opt / pr57661.C
blob9573663afca2466c752d86da27ec9cce9d2e37c8
1 // PR tree-optimization/57661
2 // { dg-do compile { target c++11 } }
3 // { dg-options "-O2 -fno-tree-forwprop" }
5 template <typename>
6 struct A
8   ~A () {}
9 };
10 template <typename _Tp>
11 using B = A <_Tp>;
12 template <typename _Tp>
13 class C : B <_Tp> {};
14 namespace N { enum D { d }; }
15 template <class>
16 struct E
18   ~E ();
20 template <class, class V>
21 struct F : V {};
22 template <class U, class V>
23 struct G : F <U, V>
25   N::D g1;
26   void g2 ();
27   void g3 ();
28   void g4 () { g3 (); }
29   static void g5 (G *__t) { __t->g4 (); }
31 template <class U, class V>
32 struct H : G <U, V>
34   E <U> *h1;
35   bool h2;
36   ~H () throw ()
37   {
38     this->g2 ();
39     if (h2)
40       delete h1;
41   }
43 template <class U, class V>
44 struct I : H <U, V>, E <U>
46   G <U, V> *i;
47   ~I () throw ()
48   {
49     i->g4 ();
50   }
52 struct J
54   typedef C <char> j1;
55   typedef G <char, C <char>> j2;
56   J ();
57   j2 *j3;
59 struct K : J
61   typedef G <char, C <char>> j2;
62   K () { j2::g5 (this->j3); }
64 template <class U, class V>
65 void G <U, V>::g3 ()
67   switch (g1)
68     {
69     case N::d:
70       {
71         I <U, V> *q = (I <U, V> *) this;
72         q->I <U, V>::~I ();
73       }
74     }
76 K r;