(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
alias-14.c
       1  /* { dg-do run } */
       2  /* { dg-options "-O2" } */
       3  #include <stddef.h>
       4  void *a;
       5  int *b;
       6  struct c {void * a;} c;
       7  struct d {short * a;} d;
       8  
       9  int *ip= (int *)(size_t)2;
      10  int **ipp = &ip;
      11  
      12  int
      13  main()
      14  {
      15    float **ptr;
      16    void **uptr;
      17    int* const* cipp = (int* const*)ipp;
      18    /* as an extension we consider void * universal. Writes to it should alias.  */
      19    asm ("":"=r"(ptr):"0"(&a));
      20    a=NULL;
      21    *ptr=(float*)(size_t)1;
      22    if (!a)
      23      __builtin_abort ();
      24    a=NULL;
      25    if (*ptr)
      26      __builtin_abort ();
      27  
      28    asm ("":"=r"(uptr):"0"(&b));
      29    b=NULL;
      30    *uptr=(void*)(size_t)1;
      31    if (!b)
      32      __builtin_abort ();
      33    b=NULL;
      34    if (*uptr)
      35      __builtin_abort ();
      36  
      37    /* Check that we disambiguate int * and char *.  */
      38    asm ("":"=r"(ptr):"0"(&b));
      39    b=NULL;
      40    *ptr=(float*)(size_t)1;
      41    if (b)
      42      __builtin_abort ();
      43  
      44    /* Again we should make void * in the structure conflict with any pointer.  */
      45    asm ("":"=r"(ptr):"0"(&c));
      46    c.a=NULL;
      47    *ptr=(float*)(size_t)1;
      48    if (!c.a)
      49      __builtin_abort ();
      50    c.a=NULL;
      51    if (*ptr)
      52      __builtin_abort ();
      53  
      54    asm ("":"=r"(uptr):"0"(&d));
      55    d.a=NULL;
      56    *uptr=(void*)(size_t)1;
      57    if (!d.a)
      58      __builtin_abort ();
      59    d.a=NULL;
      60    if (*uptr)
      61      __builtin_abort ();
      62  
      63    if ((void *)*cipp != (void*)(size_t)2)
      64      __builtin_abort ();
      65    *ipp = NULL;
      66    if (*cipp)
      67      __builtin_abort ();
      68  
      69    return 0;
      70  }