Last change
on this file since d7c0ad5 was
0a6d2045,
checked in by Andrew Beach <ajbeach@…>, 11 months ago
|
You can how use local control flow out of 'catch' clauses. Added a test to show that it works.
|
-
Property mode set to
100644
|
File size:
896 bytes
|
Line | |
---|
1 | // Control Flow out of Termination Handler Clauses |
---|
2 | |
---|
3 | exception zen {}; |
---|
4 | |
---|
5 | vtable(zen) zen_vt; |
---|
6 | |
---|
7 | void test_loop() { |
---|
8 | do { |
---|
9 | try { |
---|
10 | throw (zen){&zen_vt}; |
---|
11 | } catch (zen *) { |
---|
12 | printf("Continue\n"); |
---|
13 | continue; |
---|
14 | } |
---|
15 | printf("Reached end of loop.\n."); |
---|
16 | } while (false); |
---|
17 | printf("After Loop\n"); |
---|
18 | |
---|
19 | while (true) { |
---|
20 | try { |
---|
21 | throw (zen){&zen_vt}; |
---|
22 | } catch (zen *) { |
---|
23 | printf("Break\n"); |
---|
24 | break; |
---|
25 | } |
---|
26 | printf("Reached end of loop.\n."); |
---|
27 | } |
---|
28 | printf("After Loop\n"); |
---|
29 | } |
---|
30 | |
---|
31 | void test_switch() { |
---|
32 | switch (0) { |
---|
33 | case 0: |
---|
34 | try { |
---|
35 | throw (zen){&zen_vt}; |
---|
36 | } catch (zen *) { |
---|
37 | printf("Break\n"); |
---|
38 | break; |
---|
39 | } |
---|
40 | default: |
---|
41 | printf("Reached default.\n"); |
---|
42 | } |
---|
43 | printf("After Switch\n"); |
---|
44 | } |
---|
45 | |
---|
46 | int test_return() { |
---|
47 | try { |
---|
48 | throw (zen){&zen_vt}; |
---|
49 | } catch (zen *) { |
---|
50 | return 1; |
---|
51 | } |
---|
52 | return 0; |
---|
53 | } |
---|
54 | |
---|
55 | int main(int argc, char * argv[]) { |
---|
56 | test_loop(); |
---|
57 | test_switch(); |
---|
58 | printf("Result of test_return: %d\n", test_return()); |
---|
59 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.