(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
globalalias.c
       1  /* This test checks that local aliases behave sanely.  This is necessary for code correctness
       2     of aliases introduced by ipa-visibility pass.
       3  
       4     This test expose weird behavior of AIX's .set pseudo-op where the global symbol is created,
       5     but all uses of the alias are syntactically replaced by uses of the target.  This means that
       6     both counters are increased to 2.  */
       7  
       8  /* { dg-do run }
       9     { dg-options "-O2" } 
      10     { dg-require-alias "" }
      11     { dg-additional-sources "globalalias-2.c" } */
      12  extern int test2count;
      13  extern void abort (void);
      14  extern void tt ();
      15  int testcount;
      16  static
      17  void test(void)
      18  {
      19    testcount++;
      20  }
      21  __attribute__ ((weak,noinline))
      22  __attribute ((alias("test")))
      23  void test2(void);
      24  
      25  int main()
      26  {
      27    test();
      28    /* This call must bind locally.  */
      29    if (!testcount)
      30      abort ();
      31    test2();
      32    /* Depending on linker choice, this one may bind locally
      33       or to the other unit.  */
      34    if (!testcount && !test2count)
      35      abort();
      36    tt();
      37  
      38    if ((testcount != 1 || test2count != 3)
      39        && (testcount != 3 || test2count != 1))
      40      abort ();
      41    return 0;
      42  }