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: extend tests for messa...
details: https://anonhg.NetBSD.org/src/rev/973fecc2f06c
branches: trunk
changeset: 380006:973fecc2f06c
user: rillig <rillig%NetBSD.org@localhost>
date: Wed Jun 30 14:02:11 2021 +0000
description:
tests/lint: extend tests for message 101
This demonstrates the wrong type name in the message.
diffstat:
tests/usr.bin/xlint/lint1/msg_101.c | 36 +++++++++++++++++++++++++++++++---
tests/usr.bin/xlint/lint1/msg_101.exp | 7 +++++-
2 files changed, 38 insertions(+), 5 deletions(-)
diffs (60 lines):
diff -r e1c2234edb2c -r 973fecc2f06c tests/usr.bin/xlint/lint1/msg_101.c
--- a/tests/usr.bin/xlint/lint1/msg_101.c Wed Jun 30 13:50:15 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_101.c Wed Jun 30 14:02:11 2021 +0000
@@ -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);
}
diff -r e1c2234edb2c -r 973fecc2f06c tests/usr.bin/xlint/lint1/msg_101.exp
--- a/tests/usr.bin/xlint/lint1/msg_101.exp Wed Jun 30 13:50:15 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_101.exp Wed Jun 30 14:02:11 2021 +0000
@@ -1,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]
Home |
Main Index |
Thread Index |
Old Index