lex_integer_ilp32.c revision 1.9
1/*	$NetBSD: lex_integer_ilp32.c,v 1.9 2024/01/28 06:57:41 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/* lint1-extra-flags: -X 351 */
12
13void sinki(int);
14void sinku(unsigned int);
15
16/* All platforms supported by lint have 32-bit int in two's complement. */
17void
18test_signed_int(void)
19{
20	sinki(0);
21
22	sinki(-1);
23
24	sinki(2147483647);
25
26	/* expect+1: warning: conversion of 'long long' to 'int' is out of range, arg #1 [295] */
27	sinki(2147483648);
28
29	sinki(-2147483647);
30
31	sinki(-2147483648);
32}
33
34void
35test_unsigned_int(void)
36{
37	sinku(0);
38
39	sinku(2147483647);
40	sinku(2147483648);
41
42	sinku(2147483648U);
43	sinku(4294967295U);
44
45	/* expect+1: warning: conversion of 'unsigned long long' to 'unsigned int' is out of range, arg #1 [295] */
46	sinku(4294967296U);
47}
48