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