summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.robertl/eh990323-4.C
blob: 24c740dd1ddec2adf9fdadab3a64a9a4f9a673bc (plain)
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
// { dg-do run  }
// check MI and VBC offsets on throw
extern "C" void abort ();
extern "C" void exit (int);

struct A {
	int x[23];
};

struct B : virtual public A {
	int y[33];
};

struct C : virtual public A, public B {
	int z[43];
};

struct D {
	int xx[53];
};

struct E : public D, public A {
	int yy[63];
};

C c;

E e;

void f1()
{
	throw (C*)0;
}

void f2()
{
	throw &c;
}

void f3()
{
	throw (E*)0;
}

void f4()
{
	throw &e;
}

int
main()
{
	int flag;

	flag = 0;
	try {
		f1();
	}
	catch (void* p) {
		if (p)
			abort();
		flag = 1;
	}
	if (!flag)
		abort();

	flag = 0;
	try {
		f2();
	}
	catch (void* p) {
		if (!p || (void*)p != (void*)&c)
			abort();
		flag = 1;
	}
	if (!flag)
		abort();

	flag = 0;
	try {
		f3();
	}
	catch (void* p) {
		if (p)
			abort();
		flag = 1;
	}
	if (!flag)
		abort();

	flag = 0;
	try {
		f4();
	}
	catch (void* p) {
		if (!p || (void*)p != (void*)&e)
			abort();
		flag = 1;
	}
	if (!flag)
		abort();

	exit(0);
}