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