Module Name: src Committed By: rillig Date: Sun Jan 28 06:57:41 UTC 2024
Modified Files: src/tests/usr.bin/xlint/lint1: lex_integer_ilp32.c msg_218.c Log Message: tests/lint: fix tests for integer constants on ILP32 platforms The comment in msg_218 was both off-topic and wrong, so remove it. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/xlint/lint1/lex_integer_ilp32.c cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/xlint/lint1/msg_218.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/usr.bin/xlint/lint1/lex_integer_ilp32.c diff -u src/tests/usr.bin/xlint/lint1/lex_integer_ilp32.c:1.8 src/tests/usr.bin/xlint/lint1/lex_integer_ilp32.c:1.9 --- src/tests/usr.bin/xlint/lint1/lex_integer_ilp32.c:1.8 Tue Mar 28 14:44:34 2023 +++ src/tests/usr.bin/xlint/lint1/lex_integer_ilp32.c Sun Jan 28 06:57:41 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: lex_integer_ilp32.c,v 1.8 2023/03/28 14:44:34 rillig Exp $ */ +/* $NetBSD: lex_integer_ilp32.c,v 1.9 2024/01/28 06:57:41 rillig Exp $ */ # 3 "lex_integer_ilp32.c" /* @@ -23,12 +23,11 @@ test_signed_int(void) sinki(2147483647); - /* expect+1: warning: conversion of 'unsigned long' to 'int' is out of range, arg #1 [295] */ + /* expect+1: warning: conversion of 'long long' to 'int' is out of range, arg #1 [295] */ sinki(2147483648); sinki(-2147483647); - /* expect+1: warning: conversion of 'unsigned long' to 'int' is out of range, arg #1 [295] */ sinki(-2147483648); } @@ -43,6 +42,6 @@ test_unsigned_int(void) sinku(2147483648U); sinku(4294967295U); - /* expect+1: warning: integer constant out of range [252] */ + /* expect+1: warning: conversion of 'unsigned long long' to 'unsigned int' is out of range, arg #1 [295] */ sinku(4294967296U); } Index: src/tests/usr.bin/xlint/lint1/msg_218.c diff -u src/tests/usr.bin/xlint/lint1/msg_218.c:1.9 src/tests/usr.bin/xlint/lint1/msg_218.c:1.10 --- src/tests/usr.bin/xlint/lint1/msg_218.c:1.9 Sat Aug 26 10:43:53 2023 +++ src/tests/usr.bin/xlint/lint1/msg_218.c Sun Jan 28 06:57:41 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: msg_218.c,v 1.9 2023/08/26 10:43:53 rillig Exp $ */ +/* $NetBSD: msg_218.c,v 1.10 2024/01/28 06:57:41 rillig Exp $ */ # 3 "msg_218.c" /* Test for message: C90 treats constant as unsigned, op '%s' [218] */ @@ -20,40 +20,41 @@ void sink_int(int); void test_signed_int(void) { + /* expect+3: warning: integer constant out of range [252] */ /* expect+2: warning: C90 treats constant as unsigned, op '-' [218] */ /* expect+1: warning: conversion of 'unsigned long' to 'int' is out of range, arg #1 [295] */ sink_int(-2147483648); } /* - * In traditional C, integer constants with an 'L' suffix that didn't fit - * into 'long' were promoted to the next larger integer type, if that existed - * at all, as the suffix 'LL' was introduced by C90. - * - * Starting with C90, integer constants with an 'L' suffix that didn't fit - * into 'long' were promoted to 'unsigned long' first, before trying 'long - * long'. - * - * In C99 mode, this distinction is no longer necessary since it is far - * enough from traditional C. + * TODO: Investigate whether the message 218 is actually correct. + * See C1978 2.4.1 "Integer constants" and 6.6 "Arithmetic conversions". */ void compare_large_constant(void) { + /* expect+2: warning: integer constant out of range [252] */ /* expect+1: warning: C90 treats constant as unsigned, op '<' [218] */ cond = s32 < 3000000000L; + /* expect+2: warning: integer constant out of range [252] */ /* expect+1: warning: C90 treats constant as unsigned, op '<' [218] */ cond = 3000000000L < s32; + /* expect+2: warning: integer constant out of range [252] */ /* expect+1: warning: C90 treats constant as unsigned, op '<' [218] */ cond = u32 < 3000000000L; + /* expect+2: warning: integer constant out of range [252] */ /* expect+1: warning: C90 treats constant as unsigned, op '<' [218] */ cond = 3000000000L < u32; + /* expect+2: warning: integer constant out of range [252] */ /* expect+1: warning: C90 treats constant as unsigned, op '<' [218] */ cond = s64 < 3000000000L; + /* expect+2: warning: integer constant out of range [252] */ /* expect+1: warning: C90 treats constant as unsigned, op '<' [218] */ cond = 3000000000L < s64; + /* expect+2: warning: integer constant out of range [252] */ /* expect+1: warning: C90 treats constant as unsigned, op '<' [218] */ cond = u64 < 3000000000L; + /* expect+2: warning: integer constant out of range [252] */ /* expect+1: warning: C90 treats constant as unsigned, op '<' [218] */ cond = 3000000000L < u64; }