xref: /netbsd-src/tests/usr.bin/xlint/lint1/msg_121.c (revision e6298b924c5ba98f3a22919b56dab04a87cdbb1c)
1 /*	$NetBSD: msg_121.c,v 1.7 2023/07/07 19:45:22 rillig Exp $	*/
2 # 3 "msg_121.c"
3 
4 // Test for message: negative shift [121]
5 
6 /* lint1-extra-flags: -X 351 */
7 
8 int
example(int x)9 example(int x)
10 {
11 	/* expect+1: warning: negative shift [121] */
12 	return x << (3 - 5);
13 }
14 
15 void /*ARGSUSED*/
shift_by_double(int x,double amount)16 shift_by_double(int x, double amount)
17 {
18 	/*
19 	 * This is already caught by typeok_scalar, so it doesn't reach
20 	 * typeok_shift via typeok_op.
21 	 */
22 	/* expect+1: error: operands of '<<' have incompatible types 'int' and 'double' [107] */
23 	return x << amount;
24 }
25