Home | History | Annotate | Line # | Download | only in lint1
platform_ilp32_int.c revision 1.3
      1 /*	$NetBSD: platform_ilp32_int.c,v 1.3 2024/03/09 16:47:09 rillig Exp $	*/
      2 # 3 "platform_ilp32_int.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 int, not unsigned long.
      7  */
      8 
      9 /* lint1-only-if: ilp32 int */
     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 
     17 void
     18 convert_between_int_and_long(void)
     19 {
     20 	/*
     21 	 * No warning about possible loss of accuracy, as the types have the
     22 	 * same size, both in target platform mode as well as in portable
     23 	 * mode.
     24 	 */
     25 	s32 = sl32;
     26 	sl32 = s32;
     27 	u32 = ul32;
     28 	ul32 = u32;
     29 }
     30 
     31 char ch;
     32 
     33 void
     34 array_index(void)
     35 {
     36 	static char buf[20];
     37 
     38 	/* expect+1: warning: array subscript cannot be > 19: 2147483647 [168] */
     39 	ch += buf[2147483647];
     40 	/* expect+2: warning: conversion of 'long long' to 'int' is out of range [119] */
     41 	/* expect+1: warning: array subscript cannot be negative: -2147483648 [167] */
     42 	ch += buf[2147483648];
     43 	/* expect+2: warning: conversion of 'unsigned int' to 'int' is out of range [119] */
     44 	/* expect+1: warning: array subscript cannot be negative: -2147483648 [167] */
     45 	ch += buf[0x80000000];
     46 	/* expect+2: warning: conversion of 'unsigned int' to 'int' is out of range [119] */
     47 	/* expect+1: warning: array subscript cannot be negative: -1 [167] */
     48 	ch += buf[0xffffffff];
     49 	/* expect+1: warning: array subscript cannot be negative: -1 [167] */
     50 	ch += buf[0xffffffffffffffff];
     51 }
     52