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

source code of bolt/test/runtime/X86/Inputs/exception3.cpp