xref: /netbsd-src/tests/usr.bin/xlint/lint1/msg_118.c (revision 82d56013d7b633d116a93943de88e08335357a7c)
1 /*	$NetBSD: msg_118.c,v 1.5 2021/05/04 19:57:56 rillig Exp $	*/
2 # 3 "msg_118.c"
3 
4 /* Test for message: semantics of '%s' change in ANSI C; use explicit cast [118] */
5 
6 /* lint1-flags: -hw */
7 
8 int
9 int_shl_uint(int left, unsigned int right)
10 {
11 	return left << right;
12 }
13 
14 int
15 int_shr_uint(int left, unsigned int right)
16 {
17 	/* expect+1: semantics of '>>' change in ANSI C */
18 	return left >> right;
19 }
20 
21 int
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