Home | History | Annotate | Line # | Download | only in lint1
platform_ilp32_int.c revision 1.3
      1  1.3  rillig /*	$NetBSD: platform_ilp32_int.c,v 1.3 2024/03/09 16:47:09 rillig Exp $	*/
      2  1.1  rillig # 3 "platform_ilp32_int.c"
      3  1.1  rillig 
      4  1.1  rillig /*
      5  1.1  rillig  * Test features that only apply to platforms that have 32-bit int, long and
      6  1.1  rillig  * pointer types and where size_t is unsigned int, not unsigned long.
      7  1.1  rillig  */
      8  1.1  rillig 
      9  1.1  rillig /* lint1-only-if: ilp32 int */
     10  1.2  rillig /* lint1-extra-flags: -c -h -a -p -b -r -z -X 351 */
     11  1.1  rillig 
     12  1.1  rillig int s32;
     13  1.1  rillig unsigned int u32;
     14  1.1  rillig long sl32;
     15  1.1  rillig unsigned long ul32;
     16  1.1  rillig 
     17  1.1  rillig void
     18  1.1  rillig convert_between_int_and_long(void)
     19  1.1  rillig {
     20  1.1  rillig 	/*
     21  1.1  rillig 	 * No warning about possible loss of accuracy, as the types have the
     22  1.1  rillig 	 * same size, both in target platform mode as well as in portable
     23  1.1  rillig 	 * mode.
     24  1.1  rillig 	 */
     25  1.1  rillig 	s32 = sl32;
     26  1.1  rillig 	sl32 = s32;
     27  1.1  rillig 	u32 = ul32;
     28  1.1  rillig 	ul32 = u32;
     29  1.1  rillig }
     30  1.3  rillig 
     31  1.3  rillig char ch;
     32  1.3  rillig 
     33  1.3  rillig void
     34  1.3  rillig array_index(void)
     35  1.3  rillig {
     36  1.3  rillig 	static char buf[20];
     37  1.3  rillig 
     38  1.3  rillig 	/* expect+1: warning: array subscript cannot be > 19: 2147483647 [168] */
     39  1.3  rillig 	ch += buf[2147483647];
     40  1.3  rillig 	/* expect+2: warning: conversion of 'long long' to 'int' is out of range [119] */
     41  1.3  rillig 	/* expect+1: warning: array subscript cannot be negative: -2147483648 [167] */
     42  1.3  rillig 	ch += buf[2147483648];
     43  1.3  rillig 	/* expect+2: warning: conversion of 'unsigned int' to 'int' is out of range [119] */
     44  1.3  rillig 	/* expect+1: warning: array subscript cannot be negative: -2147483648 [167] */
     45  1.3  rillig 	ch += buf[0x80000000];
     46  1.3  rillig 	/* expect+2: warning: conversion of 'unsigned int' to 'int' is out of range [119] */
     47  1.3  rillig 	/* expect+1: warning: array subscript cannot be negative: -1 [167] */
     48  1.3  rillig 	ch += buf[0xffffffff];
     49  1.3  rillig 	/* expect+1: warning: array subscript cannot be negative: -1 [167] */
     50  1.3  rillig 	ch += buf[0xffffffffffffffff];
     51  1.3  rillig }
     52