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: Drop GCC 2.6 ABI change note for H8/h8300-hms
[official-gcc.git]
/
gcc
/
testsuite
/
g++.old-deja
/
g++.other
/
init19.C
blob
15c160dad90335b2c2b1265cca585c7d5756ef19
1
// { dg-do run { xfail { { ! cxa_atexit } && { ! *-*-solaris2* } } } }
2
// { dg-require-effective-target cxa_atexit }
3
#include <stdlib.h>
4
5
#define assert(x) do { if (! (x)) abort(); } while (0)
6
7
int count = 0;
8
9
class A
10
{
11
public:
12
explicit A(int i);
13
~A();
14
15
int i;
16
17
A(const A&);
18
A& operator=(const A&);
19
};
20
21
A::A(int i_)
22
: i(i_)
23
{
24
}
25
26
A::~A()
27
{
28
assert(++count == i);
29
i = -1;
30
}
31
32
extern "C" {
33
34
void one()
35
{
36
static bool second_time;
37
if (second_time)
38
assert(++count == 9);
39
else
40
{
41
assert(++count == 1);
42
second_time = true;
43
}
44
static A a(10);
45
assert(a.i == 10);
46
}
47
48
void two()
49
{
50
assert(++count == 7);
51
static A a(8);
52
assert(a.i == 8);
53
}
54
55
void three()
56
{
57
assert(++count == 2);
58
static A a(6);
59
assert(a.i == 6);
60
}
61
62
void five()
63
{
64
assert(++count == 4);
65
static A a(5);
66
assert(a.i == 5);
67
}
68
69
void four()
70
{
71
assert(++count == 3);
72
atexit(five);
73
}
74
75
}
76
77
A zero(11);
78
79
int main()
80
{
81
one();
82
atexit(one);
83
atexit(two);
84
three();
85
atexit(four);
86
}