File: s-exception3.cpp

package info (click to toggle)
uftrace 0.18.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,356 kB
  • sloc: ansic: 49,770; python: 11,181; asm: 837; makefile: 769; sh: 637; cpp: 627; javascript: 191
file content (158 lines) | stat: -rw-r--r-- 1,258 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#include <stdio.h>
#include <stdlib.h>

struct exc {};

class A {
	volatile int i;

    public:
	A();
	~A();
};

// noinline
A::A()
{
	i++;
}
A::~A()
{
	i--;
}

class B {
	volatile int i;

    public:
	B();
	~B();
};

B::B()
{
	i++;
}
B::~B()
{
	i--;
}

class C {
	volatile int i;

    public:
	C();
	~C();
};

C::C()
{
	i++;
}
C::~C()
{
	i--;
}

extern void foo();
extern void bar();
extern void baz();
extern void catch_exc(int i);

extern void foo1();
extern void foo2();
extern void foo3();
extern void foo4();
extern void foo5();

extern void bar1();
extern void bar2();
extern void bar3();

void foo1()
{
	foo2();
}
void foo2()
{
	foo3();
}

void foo3()
{
	try {
		foo4();
	} catch (const exc &e) {
		throw;
	}
}

void foo4()
{
	C c;
	foo5();
}
void foo5()
{
	throw exc();
}

void foo()
{
	try {
		foo1();
	} catch (const exc &e) {
		B b;
		throw;
	}
}

void bar1()
{
	bar2();
}
void bar2()
{
	bar3();
}
void bar3()
{
	C c;
	throw exc();
}

void bar()
{
	try {
		B b;
		bar1();
	} catch (const exc &e) {
		catch_exc(2);
	}
}

void baz()
{
	static volatile int n;
	n++;
}

void catch_exc(int i)
{
	if (i == 1)
		bar();
	else
		baz();
}

int main(int argc, char *argv[])
{
	try {
		A a;
		foo();
	} catch (const exc &e) {
		catch_exc(1);
	}
	return 0;
}