Module Name:    src
Committed By:   rillig
Date:           Sun Jan 17 16:00:16 UTC 2021

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

Log Message:
lint: add test for ordered comparison between incompatible types


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_123.c \
    src/tests/usr.bin/xlint/lint1/msg_123.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_123.c
diff -u src/tests/usr.bin/xlint/lint1/msg_123.c:1.1 src/tests/usr.bin/xlint/lint1/msg_123.c:1.2
--- src/tests/usr.bin/xlint/lint1/msg_123.c:1.1	Sat Jan  2 10:22:43 2021
+++ src/tests/usr.bin/xlint/lint1/msg_123.c	Sun Jan 17 16:00:16 2021
@@ -1,7 +1,28 @@
-/*	$NetBSD: msg_123.c,v 1.1 2021/01/02 10:22:43 rillig Exp $	*/
+/*	$NetBSD: msg_123.c,v 1.2 2021/01/17 16:00:16 rillig Exp $	*/
 # 3 "msg_123.c"
 
 // Test for message: illegal combination of %s (%s) and %s (%s), op %s [123]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+void ok(_Bool);
+void bad(_Bool);
+
+void
+compare(_Bool b, int i, double d, const char *p)
+{
+	ok(b < b);
+	ok(b < i);
+	ok(b < d);
+	bad(b < p);		/* expect: 123 */
+	ok(i < b);
+	ok(i < i);
+	ok(i < d);
+	bad(i < p);		/* expect: 123 */
+	ok(d < b);
+	ok(d < i);
+	ok(d < d);
+	bad(d < p);		/* expect: 107 */
+	bad(p < b);		/* expect: 123 */
+	bad(p < i);		/* expect: 123 */
+	bad(p < d);		/* expect: 107 */
+	ok(p < p);
+}
Index: src/tests/usr.bin/xlint/lint1/msg_123.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_123.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_123.exp:1.2
--- src/tests/usr.bin/xlint/lint1/msg_123.exp:1.1	Sat Jan  2 10:22:43 2021
+++ src/tests/usr.bin/xlint/lint1/msg_123.exp	Sun Jan 17 16:00:16 2021
@@ -1 +1,6 @@
-msg_123.c(6): syntax error ':' [249]
+msg_123.c(15): warning: illegal combination of integer (_Bool) and pointer (pointer to const char), op < [123]
+msg_123.c(19): warning: illegal combination of integer (int) and pointer (pointer to const char), op < [123]
+msg_123.c(23): operands of '<' have incompatible types (double != pointer) [107]
+msg_123.c(24): warning: illegal combination of pointer (pointer to const char) and integer (_Bool), op < [123]
+msg_123.c(25): warning: illegal combination of pointer (pointer to const char) and integer (int), op < [123]
+msg_123.c(26): operands of '<' have incompatible types (pointer != double) [107]

Reply via email to