Module Name:    src
Committed By:   rillig
Date:           Thu Sep  2 18:20:00 UTC 2021

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

Log Message:
tests/lint: test messages 183 and 187


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_183.c \
    src/tests/usr.bin/xlint/lint1/msg_183.exp \
    src/tests/usr.bin/xlint/lint1/msg_187.c \
    src/tests/usr.bin/xlint/lint1/msg_187.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_183.c
diff -u src/tests/usr.bin/xlint/lint1/msg_183.c:1.2 src/tests/usr.bin/xlint/lint1/msg_183.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_183.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_183.c	Thu Sep  2 18:20:00 2021
@@ -1,7 +1,31 @@
-/*	$NetBSD: msg_183.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_183.c,v 1.3 2021/09/02 18:20:00 rillig Exp $	*/
 # 3 "msg_183.c"
 
 // Test for message: illegal combination of %s (%s) and %s (%s) [183]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* expect+2: warning: argument 'x' unused in function 'example' [231] */
+void *
+example(double x, int i, void *vp, int *ip, double *dp, void (*fp)(void))
+{
+	if (i < 0)
+		/* expect+1: error: return value type mismatch (pointer to void) and (double) [211] */
+		return x;
+
+	if (i < 1)
+		/* expect+1: warning: illegal combination of pointer (pointer to void) and integer (int) [183] */
+		return i;
+
+	if (i < 2)
+		return vp;
+
+	if (i < 3)
+		return ip;
+
+	if (i < 4)
+		return dp;
+
+	if (i < 5)
+		return fp;
+
+	return (void *)0;
+}
Index: src/tests/usr.bin/xlint/lint1/msg_183.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_183.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_183.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_183.exp:1.2	Sun Mar 21 20:45:00 2021
+++ src/tests/usr.bin/xlint/lint1/msg_183.exp	Thu Sep  2 18:20:00 2021
@@ -1 +1,3 @@
-msg_183.c(6): error: syntax error ':' [249]
+msg_183.c(12): error: return value type mismatch (pointer to void) and (double) [211]
+msg_183.c(16): warning: illegal combination of pointer (pointer to void) and integer (int) [183]
+msg_183.c(8): warning: argument 'x' unused in function 'example' [231]
Index: src/tests/usr.bin/xlint/lint1/msg_187.c
diff -u src/tests/usr.bin/xlint/lint1/msg_187.c:1.2 src/tests/usr.bin/xlint/lint1/msg_187.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_187.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_187.c	Thu Sep  2 18:20:00 2021
@@ -1,7 +1,25 @@
-/*	$NetBSD: msg_187.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_187.c,v 1.3 2021/09/02 18:20:00 rillig Exp $	*/
 # 3 "msg_187.c"
 
 // Test for message: non-null byte ignored in string initializer [187]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+char auto_msg[] = "the string length is determined automatically";
+
+char large_enough[10] = "0123456789";
+
+/* expect+1: warning: non-null byte ignored in string initializer [187] */
+char too_small[9] = "0123456789";
+
+char x0[3] = "x\0";
+
+char xx0[3] = "xx\0";
+
+/* expect+1: warning: non-null byte ignored in string initializer [187] */
+char xxx0[3] = "012\0";
+
+/*
+ * The warning is not entirely correct.  It is a non-terminating byte that
+ * is ignored.
+ */
+/* expect+1: warning: non-null byte ignored in string initializer [187] */
+char xx00[3] = "01\0\0";
Index: src/tests/usr.bin/xlint/lint1/msg_187.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_187.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_187.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_187.exp:1.2	Sun Mar 21 20:45:00 2021
+++ src/tests/usr.bin/xlint/lint1/msg_187.exp	Thu Sep  2 18:20:00 2021
@@ -1 +1,3 @@
-msg_187.c(6): error: syntax error ':' [249]
+msg_187.c(11): warning: non-null byte ignored in string initializer [187]
+msg_187.c(18): warning: non-null byte ignored in string initializer [187]
+msg_187.c(25): warning: non-null byte ignored in string initializer [187]

Reply via email to