platform_ilp32_int.c revision 1.6 1 /* $NetBSD: platform_ilp32_int.c,v 1.6 2024/03/10 19:45:14 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 cannot be > 19: 16777215 [168] */
41 u8 += u8_buf[0x00ffffff];
42 /* expect+1: warning: array subscript cannot be > 19: 2147483647 [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 cannot be negative: -2147483648 [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 cannot be negative: -2147483648 [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 cannot be negative: -1 [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 cannot be negative: -2147483648 [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 cannot be negative: -1 [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 cannot be negative: -1 [167] */
61 u8 += u8_buf[0x00ffffffffffffff];
62 /* expect+1: warning: array subscript cannot be negative: -1 [167] */
63 u8 += u8_buf[0xffffffffffffffff];
64
65 /* expect+1: warning: array subscript cannot be > 19: 16777215 [168] */
66 u64 += u64_buf[0x00ffffff];
67 /* expect+2: warning: '2147483647 * 8' overflows 'int' [141] */
68 /* expect+1: warning: array subscript cannot be > 19: 268435455 [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 cannot be negative: -268435456 [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 cannot be negative: -268435456 [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 cannot be negative: -1 [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 cannot be negative: -268435456 [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 cannot be negative: -1 [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 cannot be negative: -1 [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 cannot be negative: -1 [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 cannot be negative: -1 [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 cannot be negative: -1 [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 cannot be negative: -1 [167] */
102 u64 += u64_buf[0x7fffffffffffffff];
103 /* expect+1: warning: array subscript cannot be negative: -1 [167] */
104 u64 += u64_buf[0xffffffffffffffff];
105 }
106