xref: /netbsd-src/tests/usr.bin/xlint/lint1/msg_271.c (revision 0eedaefa0b91e39f24d97248427f3cc57a457519)
1 /*	$NetBSD: msg_271.c,v 1.4 2021/08/22 13:52:19 rillig Exp $	*/
2 # 3 "msg_271.c"
3 
4 /* Test for message: switch expression must be of type 'int' in traditional C [271] */
5 
6 /* lint1-flags: -tw */
7 
example(long_int,unsigned_int)8 example(long_int, unsigned_int)
9 	long long_int;
10 	unsigned unsigned_int;
11 {
12 	/* expect+1: warning: switch expression must be of type 'int' in traditional C [271] */
13 	switch (long_int) {
14 	case 3:
15 		return 1;
16 	}
17 
18 	/*
19 	 * XXX: K&R clearly says "the result must be 'int'", but lint also
20 	 * allows unsigned int.
21 	 */
22 	switch (unsigned_int) {
23 	case 3:
24 		return 1;
25 	}
26 	return 2;
27 }
28