1 /* $NetBSD: platform_ilp32_int.c,v 1.8 2024/03/30 17:12:26 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 unsigned char u8; 32 unsigned long long u64; 33 unsigned char u8_buf[20]; 34 unsigned long long u64_buf[20]; 35 36 void 37 array_index(void) 38 { 39 40 /* expect+1: warning: array subscript 16777215 cannot be > 19 [168] */ 41 u8 += u8_buf[0x00ffffff]; 42 /* expect+1: warning: array subscript 2147483647 cannot be > 19 [168] */ 43 u8 += u8_buf[0x7fffffff]; 44 /* expect+2: warning: conversion of 'long long' to 'int' is out of range [119] */ 45 /* expect+1: warning: array subscript -2147483648 cannot be negative [167] */ 46 u8 += u8_buf[2147483648]; 47 /* expect+1: warning: array subscript 2147483648 cannot be > 19 [168] */ 48 u8 += u8_buf[0x80000000]; 49 /* expect+1: warning: array subscript 4294967295 cannot be > 19 [168] */ 50 u8 += u8_buf[0xffffffff]; 51 /* expect+1: warning: array subscript 2147483648 cannot be > 19 [168] */ 52 u8 += u8_buf[0x80000000]; 53 /* expect+1: warning: array subscript 4294967295 cannot be > 19 [168] */ 54 u8 += u8_buf[0xffffffff]; 55 /* expect+2: warning: conversion of 'long long' to 'int' is out of range [119] */ 56 /* expect+1: warning: array subscript -1 cannot be negative [167] */ 57 u8 += u8_buf[0x00ffffffffffffff]; 58 /* expect+1: warning: array subscript -1 cannot be negative [167] */ 59 u8 += u8_buf[0xffffffffffffffff]; 60 61 /* expect+1: warning: array subscript 16777215 cannot be > 19 [168] */ 62 u64 += u64_buf[0x00ffffff]; 63 /* expect+2: warning: '2147483647 * 8' overflows 'int' [141] */ 64 /* expect+1: warning: array subscript 268435455 cannot be > 19 [168] */ 65 u64 += u64_buf[0x7fffffff]; 66 /* expect+3: warning: conversion of 'long long' to 'int' is out of range [119] */ 67 /* expect+2: warning: '-2147483648 * 8' overflows 'int' [141] */ 68 /* expect+1: warning: array subscript -268435456 cannot be negative [167] */ 69 u64 += u64_buf[2147483648]; 70 /* expect+1: warning: '2147483648 * 8' overflows 'unsigned int' [141] */ 71 u64 += u64_buf[0x80000000]; 72 /* expect+2: warning: '4294967295 * 8' overflows 'unsigned int' [141] */ 73 /* expect+1: warning: array subscript 536870911 cannot be > 19 [168] */ 74 u64 += u64_buf[0xffffffff]; 75 /* expect+1: warning: '2147483648 * 8' overflows 'unsigned int' [141] */ 76 u64 += u64_buf[0x80000000]; 77 /* expect+2: warning: '4294967295 * 8' overflows 'unsigned int' [141] */ 78 /* expect+1: warning: array subscript 536870911 cannot be > 19 [168] */ 79 u64 += u64_buf[0xffffffff]; 80 /* expect+2: warning: conversion of 'long long' to 'int' is out of range [119] */ 81 /* expect+1: warning: array subscript -1 cannot be negative [167] */ 82 u64 += u64_buf[0x00ffffffffffffff]; 83 /* expect+2: warning: conversion of 'long long' to 'int' is out of range [119] */ 84 /* expect+1: warning: array subscript -1 cannot be negative [167] */ 85 u64 += u64_buf[0x0fffffffffffffff]; 86 /* expect+2: warning: conversion of 'long long' to 'int' is out of range [119] */ 87 /* expect+1: warning: array subscript -1 cannot be negative [167] */ 88 u64 += u64_buf[0x1fffffffffffffff]; 89 /* expect+2: warning: conversion of 'long long' to 'int' is out of range [119] */ 90 /* expect+1: warning: array subscript -1 cannot be negative [167] */ 91 u64 += u64_buf[0x3fffffffffffffff]; 92 /* expect+2: warning: conversion of 'long long' to 'int' is out of range [119] */ 93 /* expect+1: warning: array subscript -1 cannot be negative [167] */ 94 u64 += u64_buf[0x7fffffffffffffff]; 95 /* expect+1: warning: array subscript -1 cannot be negative [167] */ 96 u64 += u64_buf[0xffffffffffffffff]; 97 } 98