[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / libcxxabi / test / catch_member_pointer_nullptr.pass.cpp
blob3aea1f3cf3ddaf34ca4ab7b524898aa135d56dd4
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 //===----------------------------------------------------------------------===//
9 // Catching an exception thrown as nullptr was not properly handled before
10 // 2f984cab4fa7, which landed in macOS 10.13
11 // XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12}}
13 // UNSUPPORTED: no-exceptions
15 #include <cassert>
17 #if __has_feature(cxx_nullptr)
19 struct A
21 const int i;
22 int j;
25 typedef const int A::*md1;
26 typedef int A::*md2;
28 void test1()
30 try
32 throw nullptr;
33 assert(false);
35 catch (md2 p)
37 assert(!p);
39 catch (md1)
41 assert(false);
45 void test2()
47 try
49 throw nullptr;
50 assert(false);
52 catch (md1 p)
54 assert(!p);
56 catch (md2)
58 assert(false);
62 #else
64 void test1()
68 void test2()
72 #endif
74 int main(int, char**)
76 test1();
77 test2();
79 return 0;