builtin-has-attribute-4.c: Skip on 32-bit hppa*-*-hpux*.
[official-gcc.git] / gcc / testsuite / gcc.dg / Wswitch-error.c
blob0d2f0b37eaeccc05d5f7e2c71d531472b08ac42b
2 /* { dg-do compile } */
3 /* { dg-options "-Werror=switch -Wswitch-enum" } */
5 enum e { e1, e2 };
7 int
8 foo (int i, int j, enum e ei, enum e ej, enum e ek, enum e el,
9 enum e em, enum e en, enum e eo, enum e ep)
11 switch (i)
13 case 1: return 1;
14 case 2: return 2;
16 switch (j)
18 case 3: return 4;
19 case 4: return 3;
20 default: break;
22 switch (ei) /* { dg-error "enumeration value 'e1' not handled in switch" "enum e1" } */
23 { /* { dg-error "enumeration value 'e2' not handled in switch" "enum e2" { target *-*-* } .-1 } */
25 switch (ej) /* { dg-warning "enumeration value 'e1' not handled in switch" "enum e1" } */
26 { /* { dg-warning "enumeration value 'e2' not handled in switch" "enum e2" { target *-*-* } .-1 } */
27 default: break;
29 switch (ek) /* { dg-error "enumeration value 'e2' not handled in switch" "enum e2" } */
31 case e1: return 1;
33 switch (el) /* { dg-warning "enumeration value 'e2' not handled in switch" "enum e2" } */
35 case e1: return 1;
36 default: break;
38 switch (em)
40 case e1: return 1;
41 case e2: return 2;
43 switch (en)
45 case e1: return 1;
46 case e2: return 2;
47 default: break;
49 switch (eo)
51 case e1: return 1;
52 case e2: return 2;
53 case 3: return 3; /* { dg-error "case value '3' not in enumerated type 'enum e'" "excess 3" } */
55 switch (ep)
57 case e1: return 1;
58 case e2: return 2;
59 case 3: return 3; /* { dg-error "case value '3' not in enumerated type 'enum e'" "excess 3" } */
60 default: break;
62 return 0;
64 /* { dg-message "some warnings being treated as errors" "" {target "*-*-*"} 0 } */