source: doc/theses/andrew_beach_MMath/code/throw-other.cpp@ eba9d27

ADT ast-experimental enum forall-pointer-decay jacob/cs343-translation new-ast-unique-expr pthread-emulation qualifiedEnum
Last change on this file since eba9d27 was ea593a3, checked in by Andrew Beach <ajbeach@…>, 4 years ago

First draft of all the exception benchmarks. There is an issue with the Cforall linking.

  • Property mode set to 100644
File size: 698 bytes
Line 
1// Throw Across Other Handler
2#include <exception>
3#include <cstdlib>
4
5struct EmptyException : public std::exception {};
6
7struct NotRaisedException {};
8
9void unwind_other(unsigned int frames) {
10 if (frames) {
11 try {
12 unwind_other(frames - 1);
13 } catch (NotRaisedException &) {
14 // ...
15 }
16 } else {
17 throw (EmptyException){};
18 }
19}
20
21int main(int argc, char * argv[]) {
22 unsigned int times = 1;
23 unsigned int total_frames = 1;
24 if (2 < argc) {
25 times = strtol(argv[1], nullptr, 10);
26 }
27 if (3 < argc) {
28 total_frames = strtol(argv[2], nullptr, 10);
29 }
30
31 for (int count = 0 ; count < times ; ++count) {
32 try {
33 unwind_other(total_frames);
34 } catch (EmptyException &) {
35 // ...
36 }
37 }
38}
Note: See TracBrowser for help on using the repository browser.