1 // { dg-do run { target c++11 } }
2 
3 // Test catching as pointer and pointer to member types, [except.handle] p3.
4 
5 extern "C" void abort (void);
6 
7 typedef decltype(nullptr) nullptr_t;
8 
9 int result = 0;
10 
11 void __attribute__((noinline))
caught(int bit)12 caught(int bit)
13 {
14   result |= bit;
15 }
16 
17 struct A { };
18 
main()19 int main()
20 {
21   try {
22     try {
23       try {
24         try {
25           try {
26             throw nullptr;
27           } catch (void* p) {
28             if (p == nullptr)
29               caught(1);
30             throw;
31           }
32         } catch (void(*pf)()) {
33           if (pf == nullptr)
34             caught(2);
35           throw;
36         }
37       } catch (int A::*pm) {
38         if (pm == nullptr)
39           caught(4);
40         throw;
41       }
42     } catch (int (A::*pmf)()) {
43       if (pmf == nullptr)
44         caught(8);
45       throw;
46     }
47   } catch (nullptr_t) {
48   }
49 
50   try {
51     try {
52       try {
53         try {
54           try {
55             throw nullptr;
56           } catch (void* const& p) {
57             if (p == nullptr)
58               caught(16);
59             throw;
60           }
61         } catch (void(* const& pf)()) {
62           if (pf == nullptr)
63             caught(32);
64           throw;
65         }
66       } catch (int A::* const& pm) {
67         if (pm == nullptr)
68           caught(64);
69         throw;
70       }
71     } catch (int (A::* const& pmf)()) {
72       if (pmf == nullptr)
73         caught(128);
74       throw;
75     }
76   } catch (nullptr_t) {
77   }
78 
79   if (result != 255)
80     abort ();
81 }
82