1 /* $NetBSD: msg_218.c,v 1.10 2024/01/28 06:57:41 rillig Exp $ */ 2 # 3 "msg_218.c" 3 4 /* Test for message: C90 treats constant as unsigned, op '%s' [218] */ 5 6 /* lint1-only-if: ilp32 */ 7 /* lint1-flags: -w -X 351 */ 8 9 int cond; 10 signed int s32; 11 unsigned int u32; 12 /* expect+1: warning: C90 does not support 'long long' [265] */ 13 signed long long s64; 14 /* expect+1: warning: C90 does not support 'long long' [265] */ 15 unsigned long long u64; 16 17 void sink_int(int); 18 19 /* All platforms supported by lint have 32-bit int in two's complement. */ 20 void 21 test_signed_int(void) 22 { 23 /* expect+3: warning: integer constant out of range [252] */ 24 /* expect+2: warning: C90 treats constant as unsigned, op '-' [218] */ 25 /* expect+1: warning: conversion of 'unsigned long' to 'int' is out of range, arg #1 [295] */ 26 sink_int(-2147483648); 27 } 28 29 /* 30 * TODO: Investigate whether the message 218 is actually correct. 31 * See C1978 2.4.1 "Integer constants" and 6.6 "Arithmetic conversions". 32 */ 33 void 34 compare_large_constant(void) 35 { 36 /* expect+2: warning: integer constant out of range [252] */ 37 /* expect+1: warning: C90 treats constant as unsigned, op '<' [218] */ 38 cond = s32 < 3000000000L; 39 /* expect+2: warning: integer constant out of range [252] */ 40 /* expect+1: warning: C90 treats constant as unsigned, op '<' [218] */ 41 cond = 3000000000L < s32; 42 /* expect+2: warning: integer constant out of range [252] */ 43 /* expect+1: warning: C90 treats constant as unsigned, op '<' [218] */ 44 cond = u32 < 3000000000L; 45 /* expect+2: warning: integer constant out of range [252] */ 46 /* expect+1: warning: C90 treats constant as unsigned, op '<' [218] */ 47 cond = 3000000000L < u32; 48 /* expect+2: warning: integer constant out of range [252] */ 49 /* expect+1: warning: C90 treats constant as unsigned, op '<' [218] */ 50 cond = s64 < 3000000000L; 51 /* expect+2: warning: integer constant out of range [252] */ 52 /* expect+1: warning: C90 treats constant as unsigned, op '<' [218] */ 53 cond = 3000000000L < s64; 54 /* expect+2: warning: integer constant out of range [252] */ 55 /* expect+1: warning: C90 treats constant as unsigned, op '<' [218] */ 56 cond = u64 < 3000000000L; 57 /* expect+2: warning: integer constant out of range [252] */ 58 /* expect+1: warning: C90 treats constant as unsigned, op '<' [218] */ 59 cond = 3000000000L < u64; 60 } 61