Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/lint1 lint: align messages for invalid left op...



details:   https://anonhg.NetBSD.org/src/rev/73285e0351fc
branches:  trunk
changeset: 1022108:73285e0351fc
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jul 04 17:01:58 2021 +0000

description:
lint: align messages for invalid left operand of '.' or '->'

diffstat:

 tests/usr.bin/xlint/lint1/msg_101.c   |   8 +++-----
 tests/usr.bin/xlint/lint1/msg_101.exp |   8 ++++----
 tests/usr.bin/xlint/lint1/msg_103.c   |  17 +++++++++++++----
 tests/usr.bin/xlint/lint1/msg_103.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_104.c   |  18 ++++++++++++++----
 tests/usr.bin/xlint/lint1/msg_104.exp |   2 +-
 usr.bin/xlint/lint1/err.c             |   8 ++++----
 usr.bin/xlint/lint1/tree.c            |  12 ++++++------
 8 files changed, 46 insertions(+), 29 deletions(-)

diffs (161 lines):

diff -r 19216c170eca -r 73285e0351fc tests/usr.bin/xlint/lint1/msg_101.c
--- a/tests/usr.bin/xlint/lint1/msg_101.c       Sun Jul 04 16:44:13 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_101.c       Sun Jul 04 17:01:58 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_101.c,v 1.6 2021/06/30 14:11:08 rillig Exp $       */
+/*     $NetBSD: msg_101.c,v 1.7 2021/07/04 17:01:58 rillig Exp $       */
 # 3 "msg_101.c"
 
 // Test for message: type '%s' does not have member '%s' [101]
@@ -23,11 +23,9 @@
        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] */
+       /* expect+1: error: left operand of '.' must be struct or union, not 'pointer to const struct point' [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] */
+       /* expect+1: error: left operand of '->' must be pointer to struct or union, not 'struct point' [104] */
        sink(pt->x);
 
        /* accessing a nonexistent member via the wrong operator */
diff -r 19216c170eca -r 73285e0351fc tests/usr.bin/xlint/lint1/msg_101.exp
--- a/tests/usr.bin/xlint/lint1/msg_101.exp     Sun Jul 04 16:44:13 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_101.exp     Sun Jul 04 17:01:58 2021 +0000
@@ -1,6 +1,6 @@
 msg_101.c(21): error: type 'pointer to const struct point' does not have member 'z' [101]
 msg_101.c(23): error: type 'const struct point' does not have member 'z' [101]
-msg_101.c(28): error: left operand of '.' must be struct/union object [103]
-msg_101.c(31): error: left operand of '->' must be pointer to struct/union not struct point [104]
-msg_101.c(35): error: type 'pointer to const struct point' does not have member 'z' [101]
-msg_101.c(38): error: type 'struct point' does not have member 'z' [101]
+msg_101.c(27): error: left operand of '.' must be struct or union, not 'pointer to const struct point' [103]
+msg_101.c(29): error: left operand of '->' must be pointer to struct or union, not 'struct point' [104]
+msg_101.c(33): error: type 'pointer to const struct point' does not have member 'z' [101]
+msg_101.c(36): error: type 'struct point' does not have member 'z' [101]
diff -r 19216c170eca -r 73285e0351fc tests/usr.bin/xlint/lint1/msg_103.c
--- a/tests/usr.bin/xlint/lint1/msg_103.c       Sun Jul 04 16:44:13 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_103.c       Sun Jul 04 17:01:58 2021 +0000
@@ -1,7 +1,16 @@
-/*     $NetBSD: msg_103.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_103.c,v 1.3 2021/07/04 17:01:58 rillig Exp $       */
 # 3 "msg_103.c"
 
-// Test for message: left operand of '.' must be struct/union object [103]
+// Test for message: left operand of '.' must be struct or union, not '%s' [103]
+
+struct point {
+       int x, y;
+};
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+void
+test(struct point pt, struct point *ptr)
+{
+       pt.x = 0;
+       /* expect+1: left operand of '.' must be struct or union, not 'pointer to struct point' [103] */
+       ptr.y = 0;
+}
diff -r 19216c170eca -r 73285e0351fc tests/usr.bin/xlint/lint1/msg_103.exp
--- a/tests/usr.bin/xlint/lint1/msg_103.exp     Sun Jul 04 16:44:13 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_103.exp     Sun Jul 04 17:01:58 2021 +0000
@@ -1,1 +1,1 @@
-msg_103.c(6): error: syntax error ':' [249]
+msg_103.c(15): error: left operand of '.' must be struct or union, not 'pointer to struct point' [103]
diff -r 19216c170eca -r 73285e0351fc tests/usr.bin/xlint/lint1/msg_104.c
--- a/tests/usr.bin/xlint/lint1/msg_104.c       Sun Jul 04 16:44:13 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_104.c       Sun Jul 04 17:01:58 2021 +0000
@@ -1,7 +1,17 @@
-/*     $NetBSD: msg_104.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_104.c,v 1.3 2021/07/04 17:01:58 rillig Exp $       */
 # 3 "msg_104.c"
 
-// Test for message: left operand of '->' must be pointer to struct/union not %s [104]
+// Test for message: left operand of '->' must be pointer to struct or union, not '%s' [104]
+
+struct point {
+       int x, y;
+};
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* ARGSUSED */
+void
+test(struct point pt, struct point *ptr)
+{
+       /* expect+1: left operand of '->' must be pointer to struct or union, not 'struct point' [104] */
+       pt->x = 0;
+       ptr->y = 0;
+}
diff -r 19216c170eca -r 73285e0351fc tests/usr.bin/xlint/lint1/msg_104.exp
--- a/tests/usr.bin/xlint/lint1/msg_104.exp     Sun Jul 04 16:44:13 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_104.exp     Sun Jul 04 17:01:58 2021 +0000
@@ -1,1 +1,1 @@
-msg_104.c(6): error: syntax error ':' [249]
+msg_104.c(15): error: left operand of '->' must be pointer to struct or union, not 'struct point' [104]
diff -r 19216c170eca -r 73285e0351fc usr.bin/xlint/lint1/err.c
--- a/usr.bin/xlint/lint1/err.c Sun Jul 04 16:44:13 2021 +0000
+++ b/usr.bin/xlint/lint1/err.c Sun Jul 04 17:01:58 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: err.c,v 1.124 2021/07/04 13:31:10 rillig Exp $ */
+/*     $NetBSD: err.c,v 1.125 2021/07/04 17:01:58 rillig Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.124 2021/07/04 13:31:10 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.125 2021/07/04 17:01:58 rillig Exp $");
 #endif
 
 #include <sys/types.h>
@@ -157,8 +157,8 @@
        "unary + is illegal in traditional C",                        /* 100 */
        "type '%s' does not have member '%s'",                        /* 101 */
        "illegal member use: %s",                                     /* 102 */
-       "left operand of '.' must be struct/union object",            /* 103 */
-       "left operand of '->' must be pointer to struct/union not %s",/* 104 */
+       "left operand of '.' must be struct or union, not '%s'",      /* 103 */
+       "left operand of '->' must be pointer to struct or union, not '%s'", /* 104 */
        "non-unique member requires struct/union %s",                 /* 105 */
        "left operand of '->' must be pointer",                       /* 106 */
        "operands of '%s' have incompatible types (%s != %s)",        /* 107 */
diff -r 19216c170eca -r 73285e0351fc usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Sun Jul 04 16:44:13 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Sun Jul 04 17:01:58 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.309 2021/07/04 16:44:13 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.310 2021/07/04 17:01:58 rillig Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.309 2021/07/04 16:44:13 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.310 2021/07/04 17:01:58 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -457,11 +457,11 @@
        if (eq) {
                if (op == POINT) {
                        if (tflag) {
-                               /* left operand of '.' must be struct/... */
-                               warning(103);
+                               /* left operand of '.' must be struct ... */
+                               warning(103, type_name(tn->tn_type));
                        } else {
-                               /* left operand of '.' must be struct/... */
-                               error(103);
+                               /* left operand of '.' must be struct ... */
+                               error(103, type_name(tn->tn_type));
                        }
                } else {
                        if (tflag && tn->tn_type->t_tspec == PTR) {



Home | Main Index | Thread Index | Old Index