xref: /netbsd-src/tests/usr.bin/xlint/lint1/platform_lp64.c (revision 2dd295436a0082eb4f8d294f4aa73c223413d0f2)
1 /*	$NetBSD: platform_lp64.c,v 1.7 2023/07/08 12:45:43 rillig Exp $	*/
2 # 3 "platform_lp64.c"
3 
4 /*
5  * Test features that only apply to platforms that have 32-bit int and 64-bit
6  * long and pointer types.
7  */
8 
9 /* lint1-only-if: lp64 */
10 /* lint1-extra-flags: -c -h -a -p -b -r -z -X 351 */
11 
12 int s32;
13 unsigned int u32;
14 long sl32;
15 unsigned long ul32;
16 __int128_t s128;
17 __uint128_t u128;
18 
19 void
20 convert_between_int_and_long(void)
21 {
22 	/* expect+1: warning: conversion from 'long' to 'int' may lose accuracy [132] */
23 	s32 = sl32;
24 	sl32 = s32;
25 	/* expect+1: warning: conversion from 'unsigned long' to 'unsigned int' may lose accuracy [132] */
26 	u32 = ul32;
27 	ul32 = u32;
28 }
29 
30 void to_size_t(typeof(sizeof(int)));
31 
32 void
33 convert_unsigned_char_to_size_t(unsigned char uc)
34 {
35 	/* no warning, unlike platform_int */
36 	to_size_t(uc);
37 }
38 
39 void
40 convert_128(void)
41 {
42 	/* expect+1: warning: conversion from '__int128_t' to 'int' may lose accuracy [132] */
43 	s32 = s128;
44 	/* expect+1: warning: conversion from '__uint128_t' to 'unsigned int' may lose accuracy [132] */
45 	u32 = u128;
46 }
47