Tighten condition in vect/pr85586.c (PR 85654)
[official-gcc.git] / gcc / testsuite / gcc.dg / switch-5.c
bloba097d446c1316393f13c457259d408acc72899bb
1 /* Test diagnostics for switch statements and labels therein. Test
2 with no special options. */
3 /* Origin: Joseph Myers <joseph@codesourcery.com> */
4 /* { dg-do compile } */
5 /* { dg-options "" } */
7 void
8 f (int a, double d, void *p)
10 switch (d) /* { dg-error "switch quantity not an integer" } */
13 switch (p) /* { dg-error "switch quantity not an integer" } */
16 switch (a)
18 case (void *)0: ; /* { dg-error "pointers are not permitted as case values" } */
20 switch (a)
22 case (double)0: ; /* { dg-error "case label does not reduce to an integer constant" } */
24 switch (a)
26 case (char)0: ;
28 switch (a)
30 case 0 ... 0: ;
32 switch (a)
34 case 0 ... -1: ; /* { dg-warning "empty range specified" } */
36 switch (a)
38 case 0 ... -2: ; /* { dg-warning "empty range specified" } */
40 switch (a)
42 case 0:
43 default: /* { dg-message "this is the first default label" } */
44 case 1:
45 default: ; /* { dg-error "multiple default labels in one switch" } */
47 switch (a)
49 case 0: /* { dg-message "previously used here" } */
50 case 1:
51 case 0: ; /* { dg-error "duplicate case value" } */
53 case 1: ; /* { dg-error "case label not within a switch statement" } */
54 default: ; /* { dg-error "'default' label not within a switch statement" } */
55 break; /* { dg-error "break statement not within loop or switch" } */
56 continue; /* { dg-error "continue statement not within a loop" } */
57 switch (a)
59 case a: ; /* { dg-error "case label does not reduce to an integer constant" } */
61 switch (a)
63 case 0: /* { dg-message "this is the first entry overlapping that value" } */
64 case -1 ... 1: /* { dg-error "duplicate \\(or overlapping\\) case value" } */
65 case 2 ... 3: /* { dg-message "previously used here" } */
66 case 2: /* { dg-error "duplicate case value" } */
67 case 4 ... 7: /* { dg-message "this is the first entry overlapping that value" } */
68 case 6 ... 9: ; /* { dg-error "duplicate \\(or overlapping\\) case value" } */
70 switch (a)
72 case 0:
73 continue; /* { dg-error "continue statement not within a loop" } */