]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/gcc.dg/switch-warn-1.c
replace ISL with isl
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / switch-warn-1.c
CommitLineData
a6c0a76c
SB
1/* { dg-do run } */
2/* { dg-options "-O0" } */
3
ee712eab
JM
4extern void abort (void);
5extern void exit (int);
6
a6c0a76c
SB
7/* Check that out-of-bounds case warnings work in the case that the
8 testing expression is promoted. */
9int
10foo1 (unsigned char i)
11{
12 switch (i)
13 {
14 case -1: /* { dg-warning "case label value is less than minimum value for type" } */
15 return 1;
16 case 256: /* { dg-warning "case label value exceeds maximum value for type" } */
17 return 2;
18 default:
19 return 3;
20 }
21}
22
23/* Like above, but for case ranges that need to be satured. */
24int
25foo2 (unsigned char i)
26{
27 switch (i)
28 {
29 case -1 ... 1: /* { dg-warning "lower value in case label range less than minimum value for type" } */
30 return 1;
31 case 254 ... 256: /* { dg-warning "upper value in case label range exceeds maximum value for type" } */
32 return 2;
33 default:
34 return 3;
35 }
36}
37
38int
39main (void)
40{
41 if (foo1 (10) != 3)
42 abort ();
43 if (foo2 (10) != 3)
44 abort ();
45 exit (0);
46}
47