xref: /netbsd-src/tests/usr.bin/xlint/lint1/msg_118.c (revision dcb32fd76a6d98c4a9af231446a80d630943641c)
1 /*	$NetBSD: msg_118.c,v 1.8 2023/08/26 10:43:53 rillig Exp $	*/
2 # 3 "msg_118.c"
3 
4 /* Test for message: semantics of '%s' change in C90; use explicit cast [118] */
5 
6 /* lint1-flags: -hw -X 351 */
7 
8 int
int_shl_uint(int left,unsigned int right)9 int_shl_uint(int left, unsigned int right)
10 {
11 	return left << right;
12 }
13 
14 int
int_shr_uint(int left,unsigned int right)15 int_shr_uint(int left, unsigned int right)
16 {
17 	/* expect+1: warning: semantics of '>>' change in C90; use explicit cast [118] */
18 	return left >> right;
19 }
20 
21 int
int_shl_int(int left,int right)22 int_shl_int(int left, int right)
23 {
24 	return left << right;
25 }
26 
27 /*
28  * The behavior of typeok_shl can only be triggered on 64-bit platforms, or
29  * in C99 mode, and the above tests require C90 mode.
30  *
31  * On 32-bit platforms both operands of the '<<' operator are first promoted
32  * individually, and since C90 does not know 'long long', the maximum
33  * bit-size for an integer type is 32 bits.
34  *
35  * Because of this difference there is no test for that case since as of
36  * 2021-05-04, all lint1 tests must be independent of the target platform and
37  * there is no way to toggle individual tests depending on the properties of
38  * the target platform.
39  */
40