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 "" } */
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" } */
18 case (void *)0: ; /* { dg-error "pointers are not permitted as case values" } */
22 case (double)0: ; /* { dg-error "case label does not reduce to an integer constant" } */
34 case 0 ... -1: ; /* { dg-warning "empty range specified" } */
38 case 0 ... -2: ; /* { dg-warning "empty range specified" } */
43 default: /* { dg-message "this is the first default label" } */
45 default: ; /* { dg-error "multiple default labels in one switch" } */
49 case 0: /* { dg-message "previously used here" } */
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" } */
59 case a
: ; /* { dg-error "case label does not reduce to an integer constant" } */
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" } */
73 continue; /* { dg-error "continue statement not within a loop" } */