Add new test to verify that the array index, limit, and stride are
[official-gcc.git] / gcc / testsuite / gcc.dg / initpri3.c
blob1633da0141f67ce8d446c445625c5da58c8f38f9
1 /* { dg-do run { target init_priority } } */
2 /* { dg-require-effective-target lto } */
3 /* { dg-options "-flto -O3" } */
5 extern void abort ();
7 int i;
8 int j;
10 void c1() __attribute__((constructor (500)));
11 void c2() __attribute__((constructor (700)));
12 void c3() __attribute__((constructor (600)));
14 void c1() {
15 if (i++ != 0)
16 abort ();
19 void c2() {
20 if (i++ != 2)
21 abort ();
24 void c3() {
25 if (i++ != 1)
26 abort ();
29 void d1() __attribute__((destructor (500)));
30 void d2() __attribute__((destructor (700)));
31 void d3() __attribute__((destructor (600)));
33 void d1() {
34 if (--i != 0)
35 abort ();
38 void d2() {
39 if (--i != 2)
40 abort ();
43 void d3() {
44 if (j != 2)
45 abort ();
46 if (--i != 1)
47 abort ();
50 void cd4() __attribute__((constructor (800), destructor (800)));
52 void cd4() {
53 if (i != 3)
54 abort ();
55 ++j;
58 int main () {
59 if (i != 3)
60 return 1;
61 if (j != 1)
62 abort ();
63 return 0;