| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: msg_130.c,v 1.5 2021/02/28 01:30:22 rillig Exp $ */ | | 1 | /* $NetBSD: msg_130.c,v 1.6 2021/03/05 16:31:49 rillig Exp $ */ |
2 | # 3 "msg_130.c" | | 2 | # 3 "msg_130.c" |
3 | | | 3 | |
4 | // Test for message: enum type mismatch: '%s' '%s' '%s' [130] | | 4 | // Test for message: enum type mismatch: '%s' '%s' '%s' [130] |
5 | | | 5 | |
6 | enum color { | | 6 | enum color { |
7 | RED = 1 << 0, | | 7 | RED = 1 << 0, |
8 | GREEN = 1 << 1, | | 8 | GREEN = 1 << 1, |
9 | BLUE = 1 << 2 | | 9 | BLUE = 1 << 2 |
10 | }; | | 10 | }; |
11 | | | 11 | |
12 | enum size { | | 12 | enum size { |
13 | SMALL, | | 13 | SMALL, |
14 | MEDIUM, | | 14 | MEDIUM, |
| @@ -27,13 +27,26 @@ example(_Bool cond, enum color c, enum s | | | @@ -27,13 +27,26 @@ example(_Bool cond, enum color c, enum s |
27 | sink(cond ? GREEN : MORNING); /* expect: 130 */ | | 27 | sink(cond ? GREEN : MORNING); /* expect: 130 */ |
28 | | | 28 | |
29 | sink(c != s); /* expect: 130 */ | | 29 | sink(c != s); /* expect: 130 */ |
30 | sink(c == s); /* expect: 130 */ | | 30 | sink(c == s); /* expect: 130 */ |
31 | sink((c & MEDIUM) != 0); /* might be useful to warn about */ | | 31 | sink((c & MEDIUM) != 0); /* might be useful to warn about */ |
32 | sink((c | MEDIUM) != 0); /* might be useful to warn about */ | | 32 | sink((c | MEDIUM) != 0); /* might be useful to warn about */ |
33 | | | 33 | |
34 | c |= MEDIUM; /* might be useful to warn about */ | | 34 | c |= MEDIUM; /* might be useful to warn about */ |
35 | c &= MEDIUM; /* might be useful to warn about */ | | 35 | c &= MEDIUM; /* might be useful to warn about */ |
36 | | | 36 | |
37 | /* The cast to unsigned is required by GCC at WARNS=6. */ | | 37 | /* The cast to unsigned is required by GCC at WARNS=6. */ |
38 | c &= ~(unsigned)MEDIUM; /* might be useful to warn about */ | | 38 | c &= ~(unsigned)MEDIUM; /* might be useful to warn about */ |
39 | } | | 39 | } |
| | | 40 | |
| | | 41 | void |
| | | 42 | switch_example(enum color c) |
| | | 43 | { |
| | | 44 | switch (c) { |
| | | 45 | case EVENING: /* TODO: 130 */ |
| | | 46 | case LARGE: /* TODO: 130 */ |
| | | 47 | sink(1 == 1); |
| | | 48 | break; |
| | | 49 | default: |
| | | 50 | break; |
| | | 51 | } |
| | | 52 | } |