ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprno_listpersistent-indexerpthread-emulationqualifiedEnum
Last change
on this file since bdff89d was
bf71cfd,
checked in by Thierry Delisle <tdelisle@…>, 6 years ago
|
Moved up many directories in source
|
-
Property mode set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | // Draft memory management test. (remember -fexceptions) |
---|
2 | // Outdated: The integer constant exceptions need to be replaced with virtual |
---|
3 | // exceptions for the new system. |
---|
4 | |
---|
5 | #include <stdio.h> |
---|
6 | |
---|
7 | #include "except-mac.h" |
---|
8 | TRIVIAL_EXCEPTION(yin) |
---|
9 | TRIVIAL_EXCEPTION(yang) |
---|
10 | |
---|
11 | int main() |
---|
12 | { |
---|
13 | try { |
---|
14 | yin a; |
---|
15 | THROW(&a); |
---|
16 | } |
---|
17 | catch( yin * err ) { |
---|
18 | printf("First Caught\n"); |
---|
19 | try { |
---|
20 | yang b; |
---|
21 | THROW(&b); |
---|
22 | } |
---|
23 | catch( yang * err ) { |
---|
24 | printf("Both Caught\n"); |
---|
25 | } |
---|
26 | } |
---|
27 | printf("Part A Complete\n"); |
---|
28 | |
---|
29 | try { |
---|
30 | try { |
---|
31 | yang c; |
---|
32 | THROW(&c); |
---|
33 | } |
---|
34 | catch( yang * err ) { |
---|
35 | printf("First Catch and rethrow\n"); |
---|
36 | throw; |
---|
37 | } |
---|
38 | } |
---|
39 | catch( yang * err ) { |
---|
40 | printf("Second Catch\n"); |
---|
41 | } |
---|
42 | printf("Part B Complete\n"); |
---|
43 | |
---|
44 | try { |
---|
45 | try { |
---|
46 | yin d; |
---|
47 | THROW(&d); |
---|
48 | } |
---|
49 | catch( yin * err ) { |
---|
50 | printf("Throw before cleanup\n"); |
---|
51 | yang e; |
---|
52 | THROW(&e); |
---|
53 | } |
---|
54 | } |
---|
55 | catch( yang * err ) { |
---|
56 | printf("Catch after cleanup\n"); |
---|
57 | } |
---|
58 | printf("Part C Complete\n"); |
---|
59 | |
---|
60 | try { |
---|
61 | try { |
---|
62 | yin f; |
---|
63 | THROW(&f); |
---|
64 | } |
---|
65 | catch( yin * err ) { |
---|
66 | printf("Caught initial throw.\n"); |
---|
67 | try { |
---|
68 | yang g; |
---|
69 | THROW(&g); |
---|
70 | } |
---|
71 | catch( yang * err ) { |
---|
72 | printf("Caught intermediate throw.\n"); |
---|
73 | } |
---|
74 | throw; |
---|
75 | } |
---|
76 | } |
---|
77 | catch( yin * err ) { |
---|
78 | printf("Caught final throw.\n"); |
---|
79 | } |
---|
80 | printf("Part D Complete\n"); |
---|
81 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.