lex_integer.c revision 1.1
1/* $NetBSD: lex_integer.c,v 1.1 2021/06/19 08:30:08 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 10void sinki(int); 11void sinku(unsigned int); 12 13/* All platforms supported by lint have 32-bit int in two's complement. */ 14void 15test_signed_int(void) 16{ 17 sinki(0); 18 19 sinki(-1); 20 21 sinki(2147483647); 22 23 /* expect+2: converted from 'long' to 'int' due to prototype */ 24 /* expect+1: conversion of 'long' to 'int' is out of range */ 25 sinki(2147483648); 26 27 sinki(-2147483647); 28 29 /* expect+1: converted from 'long' to 'int' due to prototype */ 30 sinki(-2147483648); 31} 32 33void 34test_unsigned_int(void) 35{ 36 sinku(0); 37 38 sinku(4294967295U); 39 40 /* expect+2: from 'unsigned long' to 'unsigned int' due to prototype */ 41 /* expect+1: conversion of 'unsigned long' to 'unsigned int' is out of range */ 42 sinku(4294967296U); 43} 44