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: add tests for conversi...



details:   https://anonhg.NetBSD.org/src/rev/e52eaaf88abb
branches:  trunk
changeset: 1023051:e52eaaf88abb
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Aug 21 11:19:38 2021 +0000

description:
tests/lint: add tests for conversion from signed to unsigned

diffstat:

 tests/usr.bin/xlint/lint1/msg_259.c   |  27 ++++++++++++++++++++++++++-
 tests/usr.bin/xlint/lint1/msg_259.exp |   3 +++
 2 files changed, 29 insertions(+), 1 deletions(-)

diffs (46 lines):

diff -r 36241f088dad -r e52eaaf88abb tests/usr.bin/xlint/lint1/msg_259.c
--- a/tests/usr.bin/xlint/lint1/msg_259.c       Sat Aug 21 10:18:14 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_259.c       Sat Aug 21 11:19:38 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_259.c,v 1.9 2021/07/04 17:32:24 rillig Exp $       */
+/*     $NetBSD: msg_259.c,v 1.10 2021/08/21 11:19:38 rillig Exp $      */
 # 3 "msg_259.c"
 
 // Test for message: argument #%d is converted from '%s' to '%s' due to prototype [259]
@@ -28,3 +28,28 @@
        farg_int(l);
        farg_long(l);
 }
+
+void farg_unsigned_int(unsigned int);
+void farg_unsigned_long(unsigned long);
+void farg_unsigned_long_long(unsigned long long);
+
+/*
+ * Converting a signed integer type to its corresponding unsigned integer
+ * type (C99 6.2.5p6) is usually not a problem.  A common case where it
+ * occurs is when the difference of two pointers is converted to size_t.
+ */
+void
+convert_to_corresponding_unsigned(int i, long l, long long ll)
+{
+       /* TODO: don't warn here. */
+       /* expect+1: warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259] */
+       farg_unsigned_int(i);
+
+       /* TODO: don't warn here. */
+       /* expect+1: warning: argument #1 is converted from 'long' to 'unsigned long' due to prototype [259] */
+       farg_unsigned_long(l);
+
+       /* TODO: don't warn here. */
+       /* expect+1: warning: argument #1 is converted from 'long long' to 'unsigned long long' due to prototype [259] */
+       farg_unsigned_long_long(ll);
+}
diff -r 36241f088dad -r e52eaaf88abb tests/usr.bin/xlint/lint1/msg_259.exp
--- a/tests/usr.bin/xlint/lint1/msg_259.exp     Sat Aug 21 10:18:14 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_259.exp     Sat Aug 21 11:19:38 2021 +0000
@@ -1,1 +1,4 @@
 msg_259.c(28): warning: argument #1 is converted from 'long' to 'int' due to prototype [259]
+msg_259.c(46): warning: argument #1 is converted from 'int' to 'unsigned int' due to prototype [259]
+msg_259.c(50): warning: argument #1 is converted from 'long' to 'unsigned long' due to prototype [259]
+msg_259.c(54): warning: argument #1 is converted from 'long long' to 'unsigned long long' due to prototype [259]



Home | Main Index | Thread Index | Old Index