Module Name:    src
Committed By:   rillig
Date:           Wed Jun 30 14:02:11 UTC 2021

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

Log Message:
tests/lint: extend tests for message 101

This demonstrates the wrong type name in the message.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_101.c \
    src/tests/usr.bin/xlint/lint1/msg_101.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_101.c
diff -u src/tests/usr.bin/xlint/lint1/msg_101.c:1.4 src/tests/usr.bin/xlint/lint1/msg_101.c:1.5
--- src/tests/usr.bin/xlint/lint1/msg_101.c:1.4	Tue Mar 30 15:18:19 2021
+++ src/tests/usr.bin/xlint/lint1/msg_101.c	Wed Jun 30 14:02:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_101.c,v 1.4 2021/03/30 15:18:19 rillig Exp $	*/
+/*	$NetBSD: msg_101.c,v 1.5 2021/06/30 14:02:11 rillig Exp $	*/
 # 3 "msg_101.c"
 
 // Test for message: type '%s' does not have member '%s' [101]
@@ -7,8 +7,36 @@ struct point {
 	int x, y;
 };
 
-int
-get_z(const struct point *p)
+void sink(int);
+
+void
+test(const struct point *ptr, const struct point pt)
 {
-	return p.z;		/* expect: 101 */
+	/* accessing an existing member */
+	sink(ptr->x);
+	sink(pt.x);
+
+	/* accessing a nonexistent member */
+	/* FIXME: "type 'int'" is wrong. */
+	/* expect+1: error: type 'int' does not have member 'z' [101] */
+	sink(ptr->z);
+	/* FIXME: "type 'int'" is wrong. */
+	/* expect+1: error: type 'int' does not have member 'z' [101] */
+	sink(pt.z);
+
+	/* mixed up '.' and '->' */
+	/* TODO: mention actual type in the diagnostic */
+	/* expect+1: error: left operand of '.' must be struct/union object [103] */
+	sink(ptr.x);
+	/* TODO: put actual type in 'quotes' */
+	/* expect+1: error: left operand of '->' must be pointer to struct/union not struct point [104] */
+	sink(pt->x);
+
+	/* accessing a nonexistent member via the wrong operator */
+	/* FIXME: "type 'int'" is wrong. */
+	/* expect+1: error: type 'int' does not have member 'z' [101] */
+	sink(ptr.z);
+	/* FIXME: "type 'int'" is wrong. */
+	/* expect+1: error: type 'int' does not have member 'z' [101] */
+	sink(pt->z);
 }
Index: src/tests/usr.bin/xlint/lint1/msg_101.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_101.exp:1.4 src/tests/usr.bin/xlint/lint1/msg_101.exp:1.5
--- src/tests/usr.bin/xlint/lint1/msg_101.exp:1.4	Tue Mar 30 15:18:19 2021
+++ src/tests/usr.bin/xlint/lint1/msg_101.exp	Wed Jun 30 14:02:11 2021
@@ -1 +1,6 @@
-msg_101.c(13): error: type 'int' does not have member 'z' [101]
+msg_101.c(22): error: type 'int' does not have member 'z' [101]
+msg_101.c(25): error: type 'int' does not have member 'z' [101]
+msg_101.c(30): error: left operand of '.' must be struct/union object [103]
+msg_101.c(33): error: left operand of '->' must be pointer to struct/union not struct point [104]
+msg_101.c(38): error: type 'int' does not have member 'z' [101]
+msg_101.c(41): error: type 'int' does not have member 'z' [101]

Reply via email to