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