2018-11-07 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / g++.dg / opt / eh5.C
blob3557ab2aa54a5a645316d2ee8c060db7ff3ac525
1 // PR 41377
2 // { dg-do compile }
3 // { dg-options "-O3" }
5 struct A
7   bool foo(int*) const;
8 } a;
10 struct B {};
12 struct B1 : B
14   bool (A::*pmf)(int*) const;
15   const A* pa;
17   B1() : pmf(&A::foo), pa(&a) {}
18   bool operator()() const { return (pa->*pmf)(new int); }
21 struct B2 : B
23   B1 b1;
25   B2(const B1& _b1) : b1(_b1) {}
26   bool operator()() const { return b1(); }
29 template<int> struct C
31   void bar(B2 b2) { while (b2()) ; }
32   C() { bar(B2(B1())); }
35 void baz(int i)
37   switch(i)
38   {
39     case 0: new C<0>;
40     case 1: new C<1>;
41     case 2: new C<2>;
42   }