annotate libcxxabi/test/catch_member_pointer_nullptr.pass.cpp @ 223:5f17cb93ff66 llvm-original

LLVM13 (2021/7/18)
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 18 Jul 2021 22:43:00 +0900
parents 79ff65ed7e25
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 //===----------------- catch_member_pointer_nullptr.cpp -------------------===//
anatofuz
parents:
diff changeset
2 //
anatofuz
parents:
diff changeset
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
anatofuz
parents:
diff changeset
4 // See https://llvm.org/LICENSE.txt for license information.
anatofuz
parents:
diff changeset
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
anatofuz
parents:
diff changeset
6 //
anatofuz
parents:
diff changeset
7 //===----------------------------------------------------------------------===//
anatofuz
parents:
diff changeset
8
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
9 // Catching an exception thrown as nullptr was not properly handled before
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
10 // 2f984cab4fa7, which landed in macOS 10.13
223
5f17cb93ff66 LLVM13 (2021/7/18)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 221
diff changeset
11 // XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12}}
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
12
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
13 // UNSUPPORTED: no-exceptions
150
anatofuz
parents:
diff changeset
14
anatofuz
parents:
diff changeset
15 #include <cassert>
anatofuz
parents:
diff changeset
16
anatofuz
parents:
diff changeset
17 #if __has_feature(cxx_nullptr)
anatofuz
parents:
diff changeset
18
anatofuz
parents:
diff changeset
19 struct A
anatofuz
parents:
diff changeset
20 {
anatofuz
parents:
diff changeset
21 const int i;
anatofuz
parents:
diff changeset
22 int j;
anatofuz
parents:
diff changeset
23 };
anatofuz
parents:
diff changeset
24
anatofuz
parents:
diff changeset
25 typedef const int A::*md1;
anatofuz
parents:
diff changeset
26 typedef int A::*md2;
anatofuz
parents:
diff changeset
27
anatofuz
parents:
diff changeset
28 void test1()
anatofuz
parents:
diff changeset
29 {
anatofuz
parents:
diff changeset
30 try
anatofuz
parents:
diff changeset
31 {
anatofuz
parents:
diff changeset
32 throw nullptr;
anatofuz
parents:
diff changeset
33 assert(false);
anatofuz
parents:
diff changeset
34 }
anatofuz
parents:
diff changeset
35 catch (md2 p)
anatofuz
parents:
diff changeset
36 {
anatofuz
parents:
diff changeset
37 assert(!p);
anatofuz
parents:
diff changeset
38 }
anatofuz
parents:
diff changeset
39 catch (md1)
anatofuz
parents:
diff changeset
40 {
anatofuz
parents:
diff changeset
41 assert(false);
anatofuz
parents:
diff changeset
42 }
anatofuz
parents:
diff changeset
43 }
anatofuz
parents:
diff changeset
44
anatofuz
parents:
diff changeset
45 void test2()
anatofuz
parents:
diff changeset
46 {
anatofuz
parents:
diff changeset
47 try
anatofuz
parents:
diff changeset
48 {
anatofuz
parents:
diff changeset
49 throw nullptr;
anatofuz
parents:
diff changeset
50 assert(false);
anatofuz
parents:
diff changeset
51 }
anatofuz
parents:
diff changeset
52 catch (md1 p)
anatofuz
parents:
diff changeset
53 {
anatofuz
parents:
diff changeset
54 assert(!p);
anatofuz
parents:
diff changeset
55 }
anatofuz
parents:
diff changeset
56 catch (md2)
anatofuz
parents:
diff changeset
57 {
anatofuz
parents:
diff changeset
58 assert(false);
anatofuz
parents:
diff changeset
59 }
anatofuz
parents:
diff changeset
60 }
anatofuz
parents:
diff changeset
61
anatofuz
parents:
diff changeset
62 #else
anatofuz
parents:
diff changeset
63
anatofuz
parents:
diff changeset
64 void test1()
anatofuz
parents:
diff changeset
65 {
anatofuz
parents:
diff changeset
66 }
anatofuz
parents:
diff changeset
67
anatofuz
parents:
diff changeset
68 void test2()
anatofuz
parents:
diff changeset
69 {
anatofuz
parents:
diff changeset
70 }
anatofuz
parents:
diff changeset
71
anatofuz
parents:
diff changeset
72 #endif
anatofuz
parents:
diff changeset
73
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
74 int main(int, char**)
150
anatofuz
parents:
diff changeset
75 {
anatofuz
parents:
diff changeset
76 test1();
anatofuz
parents:
diff changeset
77 test2();
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
78
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 173
diff changeset
79 return 0;
150
anatofuz
parents:
diff changeset
80 }