| 1 | #include <stdio.h> |
| 2 | |
| 3 | class ExcA {}; |
| 4 | class ExcB {}; |
| 5 | class ExcC {}; |
| 6 | class ExcD {}; |
| 7 | class ExcE {}; |
| 8 | class ExcF {}; |
| 9 | class ExcG {}; |
| 10 | |
| 11 | void foo(int a) |
| 12 | { |
| 13 | if (a > 1) |
| 14 | throw ExcG(); |
| 15 | else |
| 16 | throw ExcC(); |
| 17 | } |
| 18 | |
| 19 | void never_throws() throw () { |
| 20 | printf(format: "this statement is cold and should be outlined\n" ); |
| 21 | } |
| 22 | |
| 23 | int main(int argc, char **argv) |
| 24 | { |
| 25 | for (unsigned i = 0; i < 1000; ++i) { |
| 26 | try { |
| 27 | if (argc == 2) { |
| 28 | never_throws(); // should be cold |
| 29 | } |
| 30 | try { |
| 31 | if (argc == 2) { |
| 32 | never_throws(); // should be cold |
| 33 | } |
| 34 | throw ExcA(); |
| 35 | } catch (ExcA) { |
| 36 | printf(format: "catch 2\n" ); |
| 37 | throw new int(); |
| 38 | } |
| 39 | } catch (...) { |
| 40 | printf(format: "catch 1\n" ); |
| 41 | } |
| 42 | |
| 43 | try { |
| 44 | try { |
| 45 | foo(a: argc); |
| 46 | } catch (ExcC) { |
| 47 | printf(format: "caught ExcC\n" ); |
| 48 | } |
| 49 | } catch (ExcG) { |
| 50 | printf(format: "caught ExcG\n" ); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | return 0; |
| 55 | } |
| 56 | |