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 c1()12void c1() { 13 if (i++ != 0) 14 abort (); 15 } 16 c2()17void c2() { 18 if (i++ != 2) 19 abort (); 20 } 21 c3()22void 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 d1()31void d1() { 32 if (--i != 0) 33 abort (); 34 } 35 d2()36void d2() { 37 if (--i != 2) 38 abort (); 39 } 40 d3()41void d3() { 42 if (j != 2) 43 abort (); 44 if (--i != 1) 45 abort (); 46 } 47 48 void cd4() __attribute__((constructor (800), destructor (800))); 49 cd4()50void cd4() { 51 if (i != 3) 52 abort (); 53 ++j; 54 } 55 main()56int main () { 57 if (i != 3) 58 return 1; 59 if (j != 1) 60 abort (); 61 return 0; 62 } 63