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