Debian Codegraph @

gcc/testsuite/g++.dg/opt/eh5.C

raw
1 // PR 41377
2 // { dg-do compile }
3 // { dg-options "-O3" }
4
5 struct A
6 {
7 bool foo(int*) const;
8 } a;
9
10 struct B {};
11
12 struct B1 : B
13 {
14 bool (A::*pmf)(int*) const;
15 const A* pa;
16
17 B1() : pmf(&A::foo), pa(&a) {}
18 bool operator()() const { return (pa->*pmf)(new int); }
19 };
20
21 struct B2 : B
22 {
23 B1 b1;
24
25 B2(const B1& _b1) : b1(_b1) {}
26 bool operator()() const { return b1(); }
27 };
28
29 template<int> struct C
30 {
31 void bar(B2 b2) { while (b2()) ; }
32 C() { bar(B2(B1())); }
33 };
34
35 void baz(int i)
36 {
37 switch(i)
38 {
39 case 0: new C<0>;
40 case 1: new C<1>;
41 case 2: new C<2>;
42 }
43 }