blob: 6f9c52a72881c3aff270377037102c5b13029a84 (
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
31
32
33
|
/* { dg-do compile } */
/* { dg-options "-fsanitize=shift -w" } */
/* { dg-shouldfail "ubsan" } */
int x;
int
foo (void)
{
/* None of the following should pass. */
switch (x)
{
case 1 >> -1:
/* { dg-error "case label does not reduce to an integer constant" "" {target c } 12 } */
/* { dg-error "is not a constant expression" "" { target c++ } 12 } */
case -1 >> -1:
/* { dg-error "case label does not reduce to an integer constant" "" {target c } 15 } */
/* { dg-error "is not a constant expression" "" { target c++ } 15 } */
case 1 << -1:
/* { dg-error "case label does not reduce to an integer constant" "" {target c } 18 } */
/* { dg-error "is not a constant expression" "" { target c++ } 18 } */
case -1 << -1:
/* { dg-error "case label does not reduce to an integer constant" "" {target c } 21 } */
/* { dg-error "is not a constant expression" "" { target c++ } 21 } */
case -1 >> 200:
/* { dg-error "case label does not reduce to an integer constant" "" {target c } 24 } */
/* { dg-error "is not a constant expression" "" { target c++ } 24 } */
case 1 << 200:
/* { dg-error "case label does not reduce to an integer constant" "" {target c } 27 } */
/* { dg-error "is not a constant expression" "" { target c++ } 27 } */
return 1;
}
return 0;
}
|