repo.or.cz
/
official-gcc.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
doc: Document struct-layout-1.exp for ABI checks
[official-gcc.git]
/
gcc
/
testsuite
/
g++.dg
/
init
/
aggr7-eh.C
blob
db45e15d9af70074d17e12712434362b227e6c23
1
// PR c++/50866, adjusted
2
// { dg-do run }
3
4
#if __cplusplus > 201100L
5
#define THROWING noexcept(false)
6
#else
7
#define THROWING
8
#endif
9
10
extern "C" void abort ();
11
12
int a;
13
int d = -1;
14
struct A {
15
A() { ++a; }
16
A(const A&);
17
~A() THROWING {
18
--a;
19
if (a == d)
20
throw (short)a;
21
}
22
};
23
int b;
24
int t;
25
struct B {
26
B(const char *, const A& = A())
27
{
28
if (b == t)
29
throw b;
30
++b;
31
if (a != b) abort ();
32
}
33
B(const B&);
34
~B()
35
{
36
--b;
37
}
38
};
39
struct C {
40
B b1, b2, b3;
41
};
42
void f()
43
{
44
try
45
{
46
C c = { "a","b","c" };
47
if (a != 0) abort ();
48
if (b != 3) abort ();
49
}
50
catch (int i) { }
51
catch (short s) { }
52
if (a != 0) abort ();
53
if (b != 0) abort ();
54
}
55
56
int main()
57
{
58
for (t = 0; t <= 3; ++t)
59
f();
60
for (d = 0; d <= 2; ++d)
61
f();
62
}