lex_integer_ilp32.c revision 1.3
1/*	$NetBSD: lex_integer_ilp32.c,v 1.3 2021/08/21 11:50:57 rillig Exp $	*/
2# 3 "lex_integer_ilp32.c"
3
4/*
5 * Tests for lexical analysis of integer constants.
6 *
7 * C99 6.4.4.1 "Integer constants"
8 */
9
10/* lint1-only-if: ilp32 */
11
12void sinki(int);
13void sinku(unsigned int);
14
15/* All platforms supported by lint have 32-bit int in two's complement. */
16void
17test_signed_int(void)
18{
19	sinki(0);
20
21	sinki(-1);
22
23	sinki(2147483647);
24
25	/* expect+1: 'unsigned long' to 'int' is out of range, arg #1 [295] */
26	sinki(2147483648);
27
28	sinki(-2147483647);
29
30	/* expect+2: ANSI C treats constant as unsigned, op - [218] */
31	/* expect+1: 'unsigned long' to 'int' is out of range, arg #1 [295] */
32	sinki(-2147483648);
33}
34
35void
36test_unsigned_int(void)
37{
38	sinku(0);
39
40	sinku(4294967295U);
41
42	/* expect+1: integer constant out of range [252] */
43	sinku(4294967296U);
44}
45