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

     1  /* PR middle-end/29695 */
     2  
     3  extern void abort (void);
     4  
     5  int
     6  f1 (void)
     7  {
     8    int a = 128;
     9    return (a & 0x80) ? 0x80 : 0;
    10  }
    11  
    12  int
    13  f2 (void)
    14  {
    15    unsigned char a = 128;
    16    return (a & 0x80) ? 0x80 : 0;
    17  }
    18  
    19  int
    20  f3 (void)
    21  {
    22    unsigned char a = 128;
    23    return (a & 0x80) ? 0x380 : 0;
    24  }
    25  
    26  int
    27  f4 (void)
    28  {
    29    unsigned char a = 128;
    30    return (a & 0x80) ? -128 : 0;
    31  }
    32  
    33  long long
    34  f5 (void)
    35  {
    36    long long a = 0x80000000LL;
    37    return (a & 0x80000000) ? 0x80000000LL : 0LL;
    38  }
    39  
    40  long long
    41  f6 (void)
    42  {
    43    unsigned int a = 0x80000000;
    44    return (a & 0x80000000) ? 0x80000000LL : 0LL;
    45  }
    46  
    47  long long
    48  f7 (void)
    49  {
    50    unsigned int a = 0x80000000;
    51    return (a & 0x80000000) ? 0x380000000LL : 0LL;
    52  }
    53  
    54  long long
    55  f8 (void)
    56  {
    57    unsigned int a = 0x80000000;
    58    return (a & 0x80000000) ? -2147483648LL : 0LL;
    59  }
    60  
    61  int
    62  main (void)
    63  {
    64    if ((char) 128 != -128 || (int) 0x80000000 != -2147483648)
    65      return 0;
    66    if (f1 () != 128)
    67      abort ();
    68    if (f2 () != 128)
    69      abort ();
    70    if (f3 () != 896)
    71      abort ();
    72    if (f4 () != -128)
    73      abort ();
    74    if (f5 () != 0x80000000LL)
    75      abort ();
    76    if (f6 () != 0x80000000LL)
    77      abort ();
    78    if (f7 () != 0x380000000LL)
    79      abort ();
    80    if (f8 () != -2147483648LL)
    81      abort ();
    82    return 0;
    83  }