blob: 69e812125cdf54a24e71f002b07907b514b1f33d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
/* $NetBSD: msg_339.c,v 1.4 2023/03/28 14:44:35 rillig Exp $ */
# 3 "msg_339.c"
// Test for message: option '%c' should be listed in the options string [339]
/* lint1-extra-flags: -X 351 */
int getopt(int, char *const *, const char *);
extern char *optarg;
int
main(int argc, char **argv)
{
int o;
/* expect+2: warning: option 'c' should be handled in the switch [338] */
/* expect+1: warning: option 'd' should be handled in the switch [338] */
while ((o = getopt(argc, argv, "a:bc:d")) != -1) {
switch (o) {
case 'a':
break;
case 'b':
/*
* The following while loop must not finish the check
* for the getopt options.
*/
while (optarg[0] != '\0')
optarg++;
break;
case 'e':
/* expect-1: warning: option 'e' should be listed in the options string [339] */
break;
case 'f':
/* expect-1: warning: option 'f' should be listed in the options string [339] */
/*
* The case labels in nested switch statements are
* ignored by the check for getopt options.
*/
switch (optarg[0]) {
case 'X':
break;
}
break;
case '?':
default:
break;
}
}
return 0;
}
|