1 /* $NetBSD: platform_ilp32_int.c,v 1.7 2024/03/30 16:47:45 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+2: warning: conversion of 'unsigned int' to 'int' is out of range [119] */ 48 /* expect+1: warning: array subscript -2147483648 cannot be negative [167] */ 49 u8 += u8_buf[0x80000000]; 50 /* expect+2: warning: conversion of 'unsigned int' to 'int' is out of range [119] */ 51 /* expect+1: warning: array subscript -1 cannot be negative [167] */ 52 u8 += u8_buf[0xffffffff]; 53 /* expect+2: warning: conversion of 'unsigned int' to 'int' is out of range [119] */ 54 /* expect+1: warning: array subscript -2147483648 cannot be negative [167] */ 55 u8 += u8_buf[0x80000000]; 56 /* expect+2: warning: conversion of 'unsigned int' to 'int' is out of range [119] */ 57 /* expect+1: warning: array subscript -1 cannot be negative [167] */ 58 u8 += u8_buf[0xffffffff]; 59 /* expect+2: warning: conversion of 'long long' to 'int' is out of range [119] */ 60 /* expect+1: warning: array subscript -1 cannot be negative [167] */ 61 u8 += u8_buf[0x00ffffffffffffff]; 62 /* expect+1: warning: array subscript -1 cannot be negative [167] */ 63 u8 += u8_buf[0xffffffffffffffff]; 64 65 /* expect+1: warning: array subscript 16777215 cannot be > 19 [168] */ 66 u64 += u64_buf[0x00ffffff]; 67 /* expect+2: warning: '2147483647 * 8' overflows 'int' [141] */ 68 /* expect+1: warning: array subscript 268435455 cannot be > 19 [168] */ 69 u64 += u64_buf[0x7fffffff]; 70 /* expect+3: warning: conversion of 'long long' to 'int' is out of range [119] */ 71 /* expect+2: warning: '-2147483648 * 8' overflows 'int' [141] */ 72 /* expect+1: warning: array subscript -268435456 cannot be negative [167] */ 73 u64 += u64_buf[2147483648]; 74 /* expect+3: warning: conversion of 'unsigned int' to 'int' is out of range [119] */ 75 /* expect+2: warning: '-2147483648 * 8' overflows 'int' [141] */ 76 /* expect+1: warning: array subscript -268435456 cannot be negative [167] */ 77 u64 += u64_buf[0x80000000]; 78 /* expect+2: warning: conversion of 'unsigned int' to 'int' is out of range [119] */ 79 /* expect+1: warning: array subscript -1 cannot be negative [167] */ 80 u64 += u64_buf[0xffffffff]; 81 /* expect+3: warning: conversion of 'unsigned int' to 'int' is out of range [119] */ 82 /* expect+2: warning: '-2147483648 * 8' overflows 'int' [141] */ 83 /* expect+1: warning: array subscript -268435456 cannot be negative [167] */ 84 u64 += u64_buf[0x80000000]; 85 /* expect+2: warning: conversion of 'unsigned int' to 'int' is out of range [119] */ 86 /* expect+1: warning: array subscript -1 cannot be negative [167] */ 87 u64 += u64_buf[0xffffffff]; 88 /* expect+2: warning: conversion of 'long long' to 'int' is out of range [119] */ 89 /* expect+1: warning: array subscript -1 cannot be negative [167] */ 90 u64 += u64_buf[0x00ffffffffffffff]; 91 /* expect+2: warning: conversion of 'long long' to 'int' is out of range [119] */ 92 /* expect+1: warning: array subscript -1 cannot be negative [167] */ 93 u64 += u64_buf[0x0fffffffffffffff]; 94 /* expect+2: warning: conversion of 'long long' to 'int' is out of range [119] */ 95 /* expect+1: warning: array subscript -1 cannot be negative [167] */ 96 u64 += u64_buf[0x1fffffffffffffff]; 97 /* expect+2: warning: conversion of 'long long' to 'int' is out of range [119] */ 98 /* expect+1: warning: array subscript -1 cannot be negative [167] */ 99 u64 += u64_buf[0x3fffffffffffffff]; 100 /* expect+2: warning: conversion of 'long long' to 'int' is out of range [119] */ 101 /* expect+1: warning: array subscript -1 cannot be negative [167] */ 102 u64 += u64_buf[0x7fffffffffffffff]; 103 /* expect+1: warning: array subscript -1 cannot be negative [167] */ 104 u64 += u64_buf[0xffffffffffffffff]; 105 } 106