Module Name: src
Committed By: rillig
Date: Tue Jan 28 20:21:59 UTC 2025
Modified Files:
src/tests/usr.bin/xlint/lint1: msg_341.c platform_ilp32_int.c
platform_ilp32_long.c platform_lp64.c
Log Message:
tests/lint: fix platform-specific tests for <ctype.h> usage
On arm (32-bit, ptrdiff_t is long), there was an extra warning that
didn't show up on i386 or x86_64.
After moving the test to the platform-specific tests, the i386 test shows
an additional warning about integer overflow. This is because the
platform-specific tests run with more lint warnings enabled than in
msg_341.c.
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_341.c
cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/xlint/lint1/platform_ilp32_int.c
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/xlint/lint1/platform_ilp32_long.c
cvs rdiff -u -r1.14 -r1.15 src/tests/usr.bin/xlint/lint1/platform_lp64.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/msg_341.c
diff -u src/tests/usr.bin/xlint/lint1/msg_341.c:1.4 src/tests/usr.bin/xlint/lint1/msg_341.c:1.5
--- src/tests/usr.bin/xlint/lint1/msg_341.c:1.4 Wed Dec 18 18:14:54 2024
+++ src/tests/usr.bin/xlint/lint1/msg_341.c Tue Jan 28 20:21:59 2025
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_341.c,v 1.4 2024/12/18 18:14:54 rillig Exp $ */
+/* $NetBSD: msg_341.c,v 1.5 2025/01/28 20:21:59 rillig Exp $ */
# 3 "msg_341.c"
// Test for message: argument to '%s' must be 'unsigned char' or EOF, not '%s' [341]
@@ -77,9 +77,9 @@ macro_invocation_NetBSD(char c, signed c
/* expect+1: warning: argument to 'function from <ctype.h>' must be cast to 'unsigned char', not to 'unsigned int' [342] */
sink(((int)((_ctype_tab_ + 1)[((unsigned int)c)] & 0x0040)));
- // https://mail-index.netbsd.org/current-users/2024/12/15/msg045888.html
- /* expect+1: warning: argument to 'function from <ctype.h>' must be 'unsigned char' or EOF, not 'unsigned int' [341] */
- sink(((int)((_ctype_tab_ + 1)[(0xffffffffu)])));
+ // See platform_ilp32_int.c.
+ // See platform_ilp32_long.c.
+ // See platform_lp64.c.
/* expect+1: warning: argument to 'function from <ctype.h>' must be 'unsigned char' or EOF, not 'signed char' [341] */
sink(((int)((_ctype_tab_ + 1)[sc])));
Index: src/tests/usr.bin/xlint/lint1/platform_ilp32_int.c
diff -u src/tests/usr.bin/xlint/lint1/platform_ilp32_int.c:1.8 src/tests/usr.bin/xlint/lint1/platform_ilp32_int.c:1.9
--- src/tests/usr.bin/xlint/lint1/platform_ilp32_int.c:1.8 Sat Mar 30 17:12:26 2024
+++ src/tests/usr.bin/xlint/lint1/platform_ilp32_int.c Tue Jan 28 20:21:59 2025
@@ -1,4 +1,4 @@
-/* $NetBSD: platform_ilp32_int.c,v 1.8 2024/03/30 17:12:26 rillig Exp $ */
+/* $NetBSD: platform_ilp32_int.c,v 1.9 2025/01/28 20:21:59 rillig Exp $ */
# 3 "platform_ilp32_int.c"
/*
@@ -95,3 +95,16 @@ array_index(void)
/* expect+1: warning: array subscript -1 cannot be negative [167] */
u64 += u64_buf[0xffffffffffffffff];
}
+
+
+extern const unsigned short *_ctype_tab_;
+
+int
+msg_341(void)
+{
+ // https://mail-index.netbsd.org/current-users/2024/12/15/msg045888.html
+ /* expect+2: warning: argument to 'function from <ctype.h>' must be 'unsigned char' or EOF, not 'unsigned int' [341] */
+ /* expect+1: warning: '4294967295 * 2' overflows 'unsigned int' [141] */
+ return (((int)((_ctype_tab_ + 1)[(0xffffffffu)])));
+
+}
Index: src/tests/usr.bin/xlint/lint1/platform_ilp32_long.c
diff -u src/tests/usr.bin/xlint/lint1/platform_ilp32_long.c:1.9 src/tests/usr.bin/xlint/lint1/platform_ilp32_long.c:1.10
--- src/tests/usr.bin/xlint/lint1/platform_ilp32_long.c:1.9 Sat Mar 30 16:47:45 2024
+++ src/tests/usr.bin/xlint/lint1/platform_ilp32_long.c Tue Jan 28 20:21:59 2025
@@ -1,4 +1,4 @@
-/* $NetBSD: platform_ilp32_long.c,v 1.9 2024/03/30 16:47:45 rillig Exp $ */
+/* $NetBSD: platform_ilp32_long.c,v 1.10 2025/01/28 20:21:59 rillig Exp $ */
# 3 "platform_ilp32_long.c"
/*
@@ -112,3 +112,16 @@ array_index(void)
/* expect+1: warning: array subscript -1 cannot be negative [167] */
u64 += u64_buf[0xffffffffffffffff];
}
+
+
+extern const unsigned short *_ctype_tab_;
+
+int
+msg_341(void)
+{
+ // https://mail-index.netbsd.org/current-users/2024/12/15/msg045888.html
+ /* expect+2: warning: argument to 'function from <ctype.h>' must be 'unsigned char' or EOF, not 'unsigned int' [341] */
+ /* expect+1: warning: conversion of 'unsigned int' to 'long' is out of range [119] */
+ return (((int)((_ctype_tab_ + 1)[(0xffffffffu)])));
+
+}
Index: src/tests/usr.bin/xlint/lint1/platform_lp64.c
diff -u src/tests/usr.bin/xlint/lint1/platform_lp64.c:1.14 src/tests/usr.bin/xlint/lint1/platform_lp64.c:1.15
--- src/tests/usr.bin/xlint/lint1/platform_lp64.c:1.14 Sat Mar 30 17:12:26 2024
+++ src/tests/usr.bin/xlint/lint1/platform_lp64.c Tue Jan 28 20:21:59 2025
@@ -1,4 +1,4 @@
-/* $NetBSD: platform_lp64.c,v 1.14 2024/03/30 17:12:26 rillig Exp $ */
+/* $NetBSD: platform_lp64.c,v 1.15 2025/01/28 20:21:59 rillig Exp $ */
# 3 "platform_lp64.c"
/*
@@ -104,3 +104,14 @@ array_index(void)
/* expect+1: warning: array subscript 2305843009213693951 cannot be > 19 [168] */
u64 += u64_buf[0xffffffffffffffff];
}
+
+extern const unsigned short *_ctype_tab_;
+
+int
+msg_341(void)
+{
+ // https://mail-index.netbsd.org/current-users/2024/12/15/msg045888.html
+ /* expect+1: warning: argument to 'function from <ctype.h>' must be 'unsigned char' or EOF, not 'unsigned int' [341] */
+ return (((int)((_ctype_tab_ + 1)[(0xffffffffu)])));
+
+}