summaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/ubsan/shift-6.c
blob: d596459b3eaf0c162e2f9579481b0870cb2587f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* PR sanitizer/58413 */
/* { dg-do run { target int32plus } } */
/* { dg-options "-fsanitize=shift -w -fno-sanitize-recover=shift" } */

int x = 7;
int
main (void)
{
  /* All of the following should pass.  */
  int A[128 >> 5] = {};
  int B[128 << 5] = {};

  static int e =
    ((int)
     (0x00000000 | ((31 & ((1 << (4)) - 1)) << (((15) + 6) + 4)) |
      ((0) << ((15) + 6)) | ((0) << (15))));

  if (e != 503316480)
    __builtin_abort ();

  switch (x)
    {
    case 1 >> 4:
    case 1 << 4:
    case 128 << (4 + 1):
    case 128 >> (4 + 1):
      return 1;
    }
  return 0;
}