1 /* { dg-options "-O2 -fdump-ipa-icf" } */ 2 /* { dg-do run } */ 3 4 int ctor_counter = 1; 5 int dtor_counter; 6 7 __attribute__((constructor)) A()8void A() 9 { 10 ctor_counter++; 11 } 12 13 __attribute__((destructor)) B()14void B() 15 { 16 if (dtor_counter == 0) 17 __builtin_abort (); 18 19 dtor_counter--; 20 } 21 22 __attribute__((constructor)) C()23static void C() { 24 ctor_counter++; 25 } 26 27 __attribute__((destructor)) D()28static void D() { 29 if (dtor_counter == 0) 30 __builtin_abort (); 31 32 dtor_counter--; 33 } 34 main()35int main() 36 { 37 if (ctor_counter != 3) 38 __builtin_abort (); 39 40 dtor_counter = 2; 41 42 return 0; 43 } 44 45 /* { dg-final { scan-ipa-dump "Equal symbols: 0" "icf" } } */ 46