Last change
on this file since 329c62f was
d3cf623,
checked in by Andrew Beach <ajbeach@…>, 5 weeks ago
|
Solved the requested warning with exceptions. Also went through the exceptions tests and managed to remove about 2/3rds of them from the lax list that now either didn't have any warnings or warnings because of the test itself.
|
-
Property mode set to
100644
|
File size:
751 bytes
|
Line | |
---|
1 | // Test exceptions that add data but no functionality. |
---|
2 | |
---|
3 | #include <fstream.hfa> |
---|
4 | |
---|
5 | exception paired { |
---|
6 | int first; |
---|
7 | int second; |
---|
8 | }; |
---|
9 | |
---|
10 | vtable(paired) paired_vt; |
---|
11 | |
---|
12 | const char * virtual_msg(paired * this) { |
---|
13 | return this->virtual_table->msg(this); |
---|
14 | } |
---|
15 | |
---|
16 | int main() { |
---|
17 | paired except = {&paired_vt, 3, 13}; |
---|
18 | |
---|
19 | try { |
---|
20 | throw except; |
---|
21 | } catch (paired * exc) { |
---|
22 | sout | virtual_msg(exc) | '(' | exc->first | ", " | exc->second | ')'; |
---|
23 | ++exc->first; |
---|
24 | } |
---|
25 | |
---|
26 | sout | virtual_msg(&except) | '(' | except.first | ", " | except.second | ')'; |
---|
27 | |
---|
28 | try { |
---|
29 | throwResume except; |
---|
30 | } catchResume (paired * exc) { |
---|
31 | sout | virtual_msg(exc) | '(' | exc->first | ", " | exc->second | ')'; |
---|
32 | ++exc->first; |
---|
33 | } |
---|
34 | |
---|
35 | sout | virtual_msg(&except) | '(' | except.first | ", " | except.second | ')'; |
---|
36 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.