Home | History | Annotate | Line # | Download | only in lint1
platform_ilp32_long.c revision 1.2
      1 /*	$NetBSD: platform_ilp32_long.c,v 1.2 2023/03/28 14:44:35 rillig Exp $	*/
      2 # 3 "platform_ilp32_long.c"
      3 
      4 /*
      5  * Test features that only apply to platforms that have 32-bit int, long and
      6  * pointer types and where size_t is unsigned long, not unsigned int.
      7  *
      8  * On these platforms, in portable mode (-p), the type 'int' is in some cases
      9  * assumed to be only 24 bits wide, in order to detect conversions from
     10  * 'long' (or more probably 'size_t') to 'int', which can lose accuracy.
     11  */
     12 
     13 /* lint1-only-if: ilp32 long */
     14 /* lint1-extra-flags: -c -h -a -p -b -r -z -X 351 */
     15 
     16 int s32;
     17 unsigned int u32;
     18 long sl32;
     19 unsigned long ul32;
     20 
     21 void
     22 convert_between_int_and_long(void)
     23 {
     24 	/*
     25 	 * Even though 'long' and 'int' have the same size on this platform,
     26 	 * the option '-p' enables additional portability checks that assume
     27 	 * a 24-bit int and a 32-bit long type, to proactively detect loss of
     28 	 * accuracy on potential other platforms.
     29 	 */
     30 	/* expect+1: warning: conversion from 'long' to 'int' may lose accuracy [132] */
     31 	s32 = sl32;
     32 	sl32 = s32;
     33 	u32 = ul32;
     34 	ul32 = u32;
     35 }
     36