[flang] Lower procedure pointer components (#75453)
[llvm-project.git] / libcxxabi / test / catch_class_02.pass.cpp
blobda375cd67eaf0dfc1644dfd74476cac1087a84e3
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 // UNSUPPORTED: no-exceptions
11 #include <exception>
12 #include <stdlib.h>
13 #include <assert.h>
15 struct B
17 static int count;
18 int id_;
19 explicit B(int id) : id_(id) {count++;}
20 B(const B& a) : id_(a.id_) {count++;}
21 ~B() {count--;}
24 int B::count = 0;
26 struct A
27 : B
29 static int count;
30 int id_;
31 explicit A(int id) : B(id-1), id_(id) {count++;}
32 A(const A& a) : B(a.id_-1), id_(a.id_) {count++;}
33 ~A() {count--;}
36 int A::count = 0;
38 void f1()
40 assert(A::count == 0);
41 assert(B::count == 0);
42 A a(3);
43 assert(A::count == 1);
44 assert(B::count == 1);
45 throw a;
46 assert(false);
49 void f2()
51 try
53 assert(A::count == 0);
54 f1();
55 assert(false);
57 catch (A a)
59 assert(A::count != 0);
60 assert(B::count != 0);
61 assert(a.id_ == 3);
62 throw;
64 catch (B b)
66 assert(false);
70 int main(int, char**)
72 try
74 f2();
75 assert(false);
77 catch (const B& b)
79 assert(B::count != 0);
80 assert(b.id_ == 2);
82 assert(A::count == 0);
83 assert(B::count == 0);
85 return 0;