view gcc/testsuite/gcc.dg/ipa/pr70306.c @ 152:2b5abeee2509

update gcc11
author anatofuz
date Mon, 25 May 2020 07:50:57 +0900
parents 04ced10e8804
children
line wrap: on
line source

/* { dg-options "-O2 -fdump-ipa-icf" } */
/* { dg-do run } */
/* { dg-require-effective-target global_constructor } */

int ctor_counter = 1;
int dtor_counter;

__attribute__((constructor))
void A()
{
  ctor_counter++;
}

__attribute__((destructor))
void B()
{
  if (dtor_counter == 0)
    __builtin_abort ();

  dtor_counter--;
}

__attribute__((constructor))
static void C() {
    ctor_counter++;
}

__attribute__((destructor))
static void D() {
  if (dtor_counter == 0)
    __builtin_abort ();

  dtor_counter--;
}

int main()
{
    if (ctor_counter != 3)
        __builtin_abort ();

    dtor_counter = 2;

    return 0;
}

/* { dg-final { scan-ipa-dump "Equal symbols: 0" "icf"  } } */