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