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: test messages 183 and 187



details:   https://anonhg.NetBSD.org/src/rev/6ce9a0ffc02b
branches:  trunk
changeset: 985643:6ce9a0ffc02b
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Sep 02 18:20:00 2021 +0000

description:
tests/lint: test messages 183 and 187

diffstat:

 tests/usr.bin/xlint/lint1/msg_183.c   |  30 +++++++++++++++++++++++++++---
 tests/usr.bin/xlint/lint1/msg_183.exp |   4 +++-
 tests/usr.bin/xlint/lint1/msg_187.c   |  24 +++++++++++++++++++++---
 tests/usr.bin/xlint/lint1/msg_187.exp |   4 +++-
 4 files changed, 54 insertions(+), 8 deletions(-)

diffs (86 lines):

diff -r 55b817fd0f2b -r 6ce9a0ffc02b tests/usr.bin/xlint/lint1/msg_183.c
--- a/tests/usr.bin/xlint/lint1/msg_183.c       Thu Sep 02 17:55:27 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_183.c       Thu Sep 02 18:20:00 2021 +0000
@@ -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;
+}
diff -r 55b817fd0f2b -r 6ce9a0ffc02b tests/usr.bin/xlint/lint1/msg_183.exp
--- a/tests/usr.bin/xlint/lint1/msg_183.exp     Thu Sep 02 17:55:27 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_183.exp     Thu Sep 02 18:20:00 2021 +0000
@@ -1,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]
diff -r 55b817fd0f2b -r 6ce9a0ffc02b tests/usr.bin/xlint/lint1/msg_187.c
--- a/tests/usr.bin/xlint/lint1/msg_187.c       Thu Sep 02 17:55:27 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_187.c       Thu Sep 02 18:20:00 2021 +0000
@@ -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";
diff -r 55b817fd0f2b -r 6ce9a0ffc02b tests/usr.bin/xlint/lint1/msg_187.exp
--- a/tests/usr.bin/xlint/lint1/msg_187.exp     Thu Sep 02 17:55:27 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_187.exp     Thu Sep 02 18:20:00 2021 +0000
@@ -1,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]



Home | Main Index | Thread Index | Old Index