modernc.org/ccgo/v3@v3.16.14/lib/testdata/gcc-9.1.0/gcc/testsuite/gcc.c-torture/execute/pr56799.c (about)

     1  /* { dg-require-effective-target int32plus } */
     2  
     3  #include <stdio.h>
     4  typedef struct { int x; int y;} S;
     5  extern int foo(S*);
     6  int hi = 0, lo = 0;
     7  
     8  int main()
     9  {
    10    S a;
    11    int r;
    12    a.x = (int) 0x00010000;
    13    a.y = 1;
    14    r = foo (&a);
    15    if (r == 2 && lo==0 && hi==1)
    16      {
    17        exit (0);
    18      }
    19    abort ();
    20  }
    21  
    22  typedef unsigned short u16;
    23  
    24  __attribute__ ((noinline)) int foo (S* ptr)
    25  {
    26    int a = ptr->x;
    27    int c = 0;
    28    u16 b = (u16) a;
    29    if (b != 0)
    30    {
    31      lo = 1;
    32      c += ptr->y;
    33    }
    34    b = a >> 16;
    35    if (b != 0)
    36    {
    37      hi = 1;
    38      c+= ptr->y;
    39    }
    40    c += ptr->y;
    41    return c;
    42  }
    43  
    44