1 /* $NetBSD: msg_218.c,v 1.7 2023/03/28 14:44:35 rillig Exp $ */ 2 # 3 "msg_218.c" 3 4 // Test for message: ANSI C treats constant as unsigned, op '%s' [218] 5 6 /* lint1-only-if: ilp32 */ 7 /* lint1-extra-flags: -X 351 */ 8 9 _Bool cond; 10 signed int s32; 11 unsigned int u32; 12 signed long long s64; 13 unsigned long long u64; 14 15 void sink_int(int); 16 17 /* All platforms supported by lint have 32-bit int in two's complement. */ 18 void 19 test_signed_int(void) 20 { 21 /* expect+1: warning: conversion of 'unsigned long' to 'int' is out of range, arg #1 [295] */ 22 sink_int(-2147483648); 23 } 24 25 /* 26 * In traditional C, integer constants with an 'L' suffix that didn't fit 27 * into 'long' were promoted to the next larger integer type, if that existed 28 * at all, as the suffix 'LL' was introduced by C90. 29 * 30 * Starting with C90, integer constants with an 'L' suffix that didn't fit 31 * into 'long' were promoted to 'unsigned long' first, before trying 'long 32 * long'. 33 * 34 * In C99 mode, this distinction is no longer necessary since it is far 35 * enough from traditional C. 36 */ 37 void 38 compare_large_constant(void) 39 { 40 cond = s32 < 3000000000L; 41 cond = 3000000000L < s32; 42 cond = u32 < 3000000000L; 43 cond = 3000000000L < u32; 44 cond = s64 < 3000000000L; 45 cond = 3000000000L < s64; 46 cond = u64 < 3000000000L; 47 cond = 3000000000L < u64; 48 } 49