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