Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / gcc.dg / switch-warn-1.c
blob04ca4e36765493dc3cf88699f18009e491669fc6
1 /* { dg-do run } */
2 /* { dg-options "-O0" } */
4 extern void abort (void);
5 extern void exit (int);
7 /* Check that out-of-bounds case warnings work in the case that the
8 testing expression is promoted. */
9 int
10 foo1 (unsigned char i)
12 switch (i)
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;
23 /* Like above, but for case ranges that need to be satured. */
24 int
25 foo2 (unsigned char i)
27 switch (i)
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;
38 int
39 main (void)
41 if (foo1 (10) != 3)
42 abort ();
43 if (foo2 (10) != 3)
44 abort ();
45 exit (0);