1 /* { dg-do compile } */
2 /* { dg-options "-fsanitize=shift -w" } */
3 /* { dg-shouldfail "ubsan" } */
4 
5 int
foo(int x)6 foo (int x)
7 {
8   /* None of the following should pass.  */
9   switch (x)
10     {
11     case 1 >> -1: /* { dg-error "case label does not reduce to an integer constant" } */
12     case -1 >> -1: /* { dg-error "case label does not reduce to an integer constant" } */
13     case 1 << -1: /* { dg-error "case label does not reduce to an integer constant" } */
14     case -1 << -1: /* { dg-error "case label does not reduce to an integer constant" } */
15       return 1;
16     }
17   return 0;
18 }
19 
20 int
bar(int x)21 bar (int x)
22 {
23   /* None of the following should pass.  */
24   switch (x)
25     {
26     case -1 >> 200: /* { dg-error "case label does not reduce to an integer constant" } */
27     case 1 << 200: /* { dg-error "case label does not reduce to an integer constant" } */
28       return 1;
29     }
30   return 0;
31 }
32