source: src/tests/except-1.c@ b4f0dde

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum with_gc
Last change on this file since b4f0dde was e9145a3, checked in by Andrew Beach <ajbeach@…>, 8 years ago

Updated exception tests to exception structures. Should be re-orginized still.

  • 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"
8TRIVIAL_EXCEPTION(yin)
9TRIVIAL_EXCEPTION(yang)
10
11int 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.