ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change
on this file since edf3ff1 was
88e0080,
checked in by Andrew Beach <ajbeach@…>, 7 years ago
|
Added a file with notes about the new exception design.
|
-
Property mode set to
100644
|
File size:
510 bytes
|
Line | |
---|
1 | #include <stdio.h> |
---|
2 | #include "except.h" |
---|
3 | |
---|
4 | struct raii_t { |
---|
5 | char * msg; |
---|
6 | }; |
---|
7 | |
---|
8 | void ^?{}( type_raii_t * this ) { |
---|
9 | printf("%s\n", this->msg); |
---|
10 | } |
---|
11 | |
---|
12 | void bar() { |
---|
13 | raii_t a = { "Bar dtor" }; |
---|
14 | |
---|
15 | throw( 3 ); |
---|
16 | } |
---|
17 | |
---|
18 | void foo() { |
---|
19 | raii_t a = { "Foo dtor" }; |
---|
20 | |
---|
21 | try { |
---|
22 | raii_t b = { "Foo try dtor" }; |
---|
23 | |
---|
24 | bar(); |
---|
25 | |
---|
26 | printf("Called bar successfully\n"); |
---|
27 | } |
---|
28 | catch( 2 ) { |
---|
29 | printf("Exception caught\n"); |
---|
30 | } |
---|
31 | |
---|
32 | printf( "Foo exited normally\n" ); |
---|
33 | } |
---|
34 | |
---|
35 | int main() { |
---|
36 | raii_t a = { "Main dtor" }; |
---|
37 | |
---|
38 | foo(); |
---|
39 | |
---|
40 | printf("End of program reached\n"); |
---|
41 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.