111
|
1 /* { dg-do run { target init_priority } } */
|
|
2
|
|
3 extern void abort ();
|
|
4
|
|
5 int i;
|
|
6 int j;
|
|
7
|
|
8 void c1() __attribute__((constructor (500)));
|
|
9 void c2() __attribute__((constructor (700)));
|
|
10 void c3() __attribute__((constructor (600)));
|
|
11
|
|
12 void c1() {
|
|
13 if (i++ != 0)
|
|
14 abort ();
|
|
15 }
|
|
16
|
|
17 void c2() {
|
|
18 if (i++ != 2)
|
|
19 abort ();
|
|
20 }
|
|
21
|
|
22 void c3() {
|
|
23 if (i++ != 1)
|
|
24 abort ();
|
|
25 }
|
|
26
|
|
27 void d1() __attribute__((destructor (500)));
|
|
28 void d2() __attribute__((destructor (700)));
|
|
29 void d3() __attribute__((destructor (600)));
|
|
30
|
|
31 void d1() {
|
|
32 if (--i != 0)
|
|
33 abort ();
|
|
34 }
|
|
35
|
|
36 void d2() {
|
|
37 if (--i != 2)
|
|
38 abort ();
|
|
39 }
|
|
40
|
|
41 void d3() {
|
|
42 if (j != 2)
|
|
43 abort ();
|
|
44 if (--i != 1)
|
|
45 abort ();
|
|
46 }
|
|
47
|
|
48 void cd4() __attribute__((constructor (800), destructor (800)));
|
|
49
|
|
50 void cd4() {
|
|
51 if (i != 3)
|
|
52 abort ();
|
|
53 ++j;
|
|
54 }
|
|
55
|
|
56 int main () {
|
|
57 if (i != 3)
|
|
58 return 1;
|
|
59 if (j != 1)
|
|
60 abort ();
|
|
61 return 0;
|
|
62 }
|