ADT
arm-eh
ast-experimental
enum
forall-pointer-decay
jacob/cs343-translation
new-ast
new-ast-unique-expr
pthread-emulation
qualifiedEnum
|
Last change
on this file since 1cf2a9b was 0e7e3c17, checked in by Andrew Beach <ajbeach@…>, 5 years ago |
|
Removed an unused function from tests/exceptions/data-except.cfa.
|
-
Property mode
set to
100644
|
|
File size:
939 bytes
|
| Line | |
|---|
| 1 | // Test exceptions that add data but no functionality.
|
|---|
| 2 |
|
|---|
| 3 | #include <exception.hfa>
|
|---|
| 4 |
|
|---|
| 5 | DATA_EXCEPTION(paired)(
|
|---|
| 6 | int first;
|
|---|
| 7 | int second;
|
|---|
| 8 | );
|
|---|
| 9 |
|
|---|
| 10 | void ?{}(paired & this, int first, int second) {
|
|---|
| 11 | VTABLE_INIT(this, paired);
|
|---|
| 12 | this.first = first;
|
|---|
| 13 | this.second = second;
|
|---|
| 14 | }
|
|---|
| 15 |
|
|---|
| 16 | const char * paired_msg(paired * this) {
|
|---|
| 17 | return "paired";
|
|---|
| 18 | }
|
|---|
| 19 |
|
|---|
| 20 | VTABLE_INSTANCE(paired)(paired_msg);
|
|---|
| 21 |
|
|---|
| 22 | void throwPaired(int first, int second) {
|
|---|
| 23 | paired exc = {first, second};
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | int main(int argc, char * argv[]) {
|
|---|
| 27 | paired except = {3, 13};
|
|---|
| 28 |
|
|---|
| 29 | try {
|
|---|
| 30 | throw &except;
|
|---|
| 31 | } catch (paired * exc) {
|
|---|
| 32 | printf("%s(%d, %d)\n", paired_msg(exc), exc->first, exc->second);
|
|---|
| 33 | ++exc->first;
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | printf("%s(%d, %d)\n", paired_msg(&except), except.first, except.second);
|
|---|
| 37 |
|
|---|
| 38 | try {
|
|---|
| 39 | throwResume &except;
|
|---|
| 40 | } catchResume (paired * exc) {
|
|---|
| 41 | printf("%s(%d, %d)\n", paired_msg(exc), exc->first, exc->second);
|
|---|
| 42 | ++exc->first;
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| 45 | printf("%s(%d, %d)\n", paired_msg(&except), except.first, except.second);
|
|---|
| 46 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.