Module Name:    src
Committed By:   rillig
Date:           Sat Aug 21 11:19:38 UTC 2021

Modified Files:
        src/tests/usr.bin/xlint/lint1: msg_259.c msg_259.exp

Log Message:
tests/lint: add tests for conversion from signed to unsigned


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/xlint/lint1/msg_259.c
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/msg_259.exp

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_259.c
diff -u src/tests/usr.bin/xlint/lint1/msg_259.c:1.9 src/tests/usr.bin/xlint/lint1/msg_259.c:1.10
--- src/tests/usr.bin/xlint/lint1/msg_259.c:1.9	Sun Jul  4 17:32:24 2021
+++ src/tests/usr.bin/xlint/lint1/msg_259.c	Sat Aug 21 11:19:38 2021
@@ -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 @@ example(char c, int i, long l)
 	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);
+}

Index: src/tests/usr.bin/xlint/lint1/msg_259.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_259.exp:1.7 src/tests/usr.bin/xlint/lint1/msg_259.exp:1.8
--- src/tests/usr.bin/xlint/lint1/msg_259.exp:1.7	Sun Jul  4 17:32:24 2021
+++ src/tests/usr.bin/xlint/lint1/msg_259.exp	Sat Aug 21 11:19:38 2021
@@ -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]

Reply via email to