Debian Codegraph @

libcxxabi/test/catch_member_pointer_nullptr.pass.cpp

raw
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 // UNSUPPORTED: no-exceptions
10
11 #include <cassert>
12
13 #if __has_feature(cxx_nullptr)
14
15 struct A
16 {
17 const int i;
18 int j;
19 };
20
21 typedef const int A::*md1;
22 typedef int A::*md2;
23
24 void test1()
25 {
26 try
27 {
28 throw nullptr;
29 assert(false);
30 }
31 catch (md2 p)
32 {
33 assert(!p);
34 }
35 catch (md1)
36 {
37 assert(false);
38 }
39 }
40
41 void test2()
42 {
43 try
44 {
45 throw nullptr;
46 assert(false);
47 }
48 catch (md1 p)
49 {
50 assert(!p);
51 }
52 catch (md2)
53 {
54 assert(false);
55 }
56 }
57
58 #else
59
60 void test1()
61 {
62 }
63
64 void test2()
65 {
66 }
67
68 #endif
69
70 int main(int, char**)
71 {
72 test1();
73 test2();
74
75 return 0;
76 }