Debian Codegraph @

gcc/testsuite/g++.target/powerpc/uncaught3.C

raw
1 // { dg-do compile { target *-*-darwin* } }
2 // { dg-final { scan-assembler-not "__cxa_get_exception" } }
3 // { dg-options "-mmacosx-version-min=10.4" }
4 // { dg-additional-options "-Wno-deprecated" { target c++17 } }
5
6 #include <exception>
7 #include <cstdlib>
8
9
10 struct Check {
11 int obj1, obj2;
12 bool state;
13 };
14
15 static Check const data[] = {
16 { 0, 0, false }, // construct [0]
17 { 1, 0, true }, // [1] = [0]
18 { 0, 0, true }, // destruct [0]
19 { 2, 1, true }, // [2] = [1]
20 { 2, 2, true }, // destruct [2]
21 { 3, 1, true }, // [3] = [1]
22 { 3, 3, false }, // destruct [3]
23 { 1, 1, false }, // destruct [1]
24 { 9, 9, false } // end-of-data
25 };
26
27 static int pos = 0;
28
29 static void test(int obj1, int obj2, bool state)
30 {
31 if (obj1 != data[pos].obj1) abort ();
32 if (obj2 != data[pos].obj2) abort ();
33 if (state != data[pos].state) abort ();
34 pos++;
35 }
36
37
38 struct S {
39 int id;
40 S ();
41 S (const S &);
42 ~S ();
43 };
44
45 static int next_id = 0;
46
47 S::S()
48 : id (next_id++)
49 {
50 test (id, id, std::uncaught_exception ());
51 }
52
53 S::S(const S &x)
54 : id (next_id++)
55 {
56 test (id, x.id, std::uncaught_exception ());
57 }
58
59 S::~S()
60 {
61 test (id, id, std::uncaught_exception ());
62 }
63
64 extern void foo (S *);
65
66 int main()
67 {
68 try
69 {
70 try
71 {
72 S s0;
73 throw s0; // s1 is the exception object
74 }
75 catch (S s2)
76 {
77 throw;
78 }
79 }
80 catch (S s3)
81 {
82 }
83
84 return 0;
85 }