lex_integer.c revision 1.2
1/*	$NetBSD: lex_integer.c,v 1.2 2021/06/27 10:14:43 rillig Exp $	*/
2# 3 "lex_integer.c"
3
4/*
5 * Tests for lexical analysis of integer constants.
6 *
7 * C99 6.4.4.1 "Integer constants"
8 */
9
10/* lint1-not-on-arch: i386 (has 32-bit long) */
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+2: converted from 'long' to 'int' due to prototype */
26	/* expect+1: conversion of 'long' to 'int' is out of range */
27	sinki(2147483648);
28
29	sinki(-2147483647);
30
31	/* expect+1: converted from 'long' to 'int' due to prototype */
32	sinki(-2147483648);
33}
34
35void
36test_unsigned_int(void)
37{
38	sinku(0);
39
40	sinku(4294967295U);
41
42	/* expect+2: from 'unsigned long' to 'unsigned int' due to prototype */
43	/* expect+1: conversion of 'unsigned long' to 'unsigned int' is out of range */
44	sinku(4294967296U);
45}
46