Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/usr.bin/xlint/lint1 tests/lint: make test for message ...



details:   https://anonhg.NetBSD.org/src/rev/f8da8948e137
branches:  trunk
changeset: 379020:f8da8948e137
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue May 04 19:57:56 2021 +0000

description:
tests/lint: make test for message 118 platform-independent

diffstat:

 tests/usr.bin/xlint/lint1/msg_118.c   |  39 ++++++++++++++++++++++++++--------
 tests/usr.bin/xlint/lint1/msg_118.exp |   2 +-
 2 files changed, 31 insertions(+), 10 deletions(-)

diffs (58 lines):

diff -r c1e06149902d -r f8da8948e137 tests/usr.bin/xlint/lint1/msg_118.c
--- a/tests/usr.bin/xlint/lint1/msg_118.c       Tue May 04 19:07:19 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_118.c       Tue May 04 19:57:56 2021 +0000
@@ -1,18 +1,39 @@
-/*     $NetBSD: msg_118.c,v 1.4 2021/04/06 21:59:58 rillig Exp $       */
+/*     $NetBSD: msg_118.c,v 1.5 2021/05/04 19:57:56 rillig Exp $       */
 # 3 "msg_118.c"
 
 /* Test for message: semantics of '%s' change in ANSI C; use explicit cast [118] */
 
-/* lint1-flags: -hsw */
+/* lint1-flags: -hw */
+
+int
+int_shl_uint(int left, unsigned int right)
+{
+       return left << right;
+}
+
+int
+int_shr_uint(int left, unsigned int right)
+{
+       /* expect+1: semantics of '>>' change in ANSI C */
+       return left >> right;
+}
 
 int
-int_shl_uint(int i, unsigned int u)
+int_shl_int(int left, int right)
 {
-       return i << u;
+       return left << right;
 }
 
-unsigned
-uint_shl_ulong(unsigned a, unsigned long ul)
-{
-       return a << ul;         /* expect: 118 */
-}
+/*
+ * The behavior of typeok_shl can only be triggered on 64-bit platforms, or
+ * in C99 mode, and the above tests require C90 mode.
+ *
+ * On 32-bit platforms both operands of the '<<' operator are first promoted
+ * individually, and since C90 does not know 'long long', the maximum
+ * bit-size for an integer type is 32 bits.
+ *
+ * Because of this difference there is no test for that case since as of
+ * 2021-05-04, all lint1 tests must be independent of the target platform and
+ * there is no way to toggle individual tests depending on the properties of
+ * the target platform.
+ */
diff -r c1e06149902d -r f8da8948e137 tests/usr.bin/xlint/lint1/msg_118.exp
--- a/tests/usr.bin/xlint/lint1/msg_118.exp     Tue May 04 19:07:19 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_118.exp     Tue May 04 19:57:56 2021 +0000
@@ -1,1 +1,1 @@
-msg_118.c(17): warning: semantics of '<<' change in ANSI C; use explicit cast [118]
+msg_118.c(18): warning: semantics of '>>' change in ANSI C; use explicit cast [118]



Home | Main Index | Thread Index | Old Index