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: add type information for message a...



details:   https://anonhg.NetBSD.org/src/rev/68c2c50fbc3b
branches:  trunk
changeset: 1020118:68c2c50fbc3b
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Mar 30 15:18:19 2021 +0000

description:
lint: add type information for message about unknown member name

diffstat:

 tests/usr.bin/xlint/lint1/d_c99_init.c   |  14 +++++++-------
 tests/usr.bin/xlint/lint1/d_c99_init.exp |  12 ++++++------
 tests/usr.bin/xlint/lint1/msg_101.c      |   4 ++--
 tests/usr.bin/xlint/lint1/msg_101.exp    |   2 +-
 usr.bin/xlint/lint1/err.c                |   6 +++---
 usr.bin/xlint/lint1/init.c               |   9 ++++-----
 usr.bin/xlint/lint1/tree.c               |   8 ++++----
 7 files changed, 27 insertions(+), 28 deletions(-)

diffs (184 lines):

diff -r 5559b8dcf1f9 -r 68c2c50fbc3b tests/usr.bin/xlint/lint1/d_c99_init.c
--- a/tests/usr.bin/xlint/lint1/d_c99_init.c    Tue Mar 30 15:10:46 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_init.c    Tue Mar 30 15:18:19 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: d_c99_init.c,v 1.25 2021/03/30 15:05:05 rillig Exp $   */
+/*     $NetBSD: d_c99_init.c,v 1.26 2021/03/30 15:18:19 rillig Exp $   */
 # 3 "d_c99_init.c"
 
 /*
@@ -329,21 +329,21 @@
 }
 
 struct point unknown_member_name_beginning = {
-       .r = 5,                 /* expect: undefined struct/union member: r */
+       .r = 5,                 /* expect: does not have member 'r' */
        .x = 4,
        .y = 3,
 };
 
 struct point unknown_member_name_middle = {
        .x = 4,
-       .r = 5,                 /* expect: undefined struct/union member: r */
+       .r = 5,                 /* expect: does not have member 'r' */
        .y = 3,
 };
 
 struct point unknown_member_name_end = {
        .x = 4,
        .y = 3,
-       .r = 5,                 /* expect: undefined struct/union member: r */
+       .r = 5,                 /* expect: does not have member 'r' */
 };
 
 union value {
@@ -352,18 +352,18 @@
 };
 
 union value unknown_union_member_name_first = {
-       .unknown_value = 4,     /* expect: undefined struct/union member */
+       .unknown_value = 4,     /* expect: does not have member */
        .int_value = 3,
 };
 
 union value unknown_union_member_name_second = {
        .int_value = 3,
-       .unknown_value = 4,     /* expect: undefined struct/union member */
+       .unknown_value = 4,     /* expect: does not have member */
 };
 
 struct point designators_with_subscript = {
        [0] = 3,                /* expect: only for arrays */
-       .member[0][0].member = 4, /* expect: undefined struct/union member */
+       .member[0][0].member = 4, /* expect: does not have member 'member' */
        .x.y.z = 5,     /* intentionally not caught, see designator_look_up */
 };
 
diff -r 5559b8dcf1f9 -r 68c2c50fbc3b tests/usr.bin/xlint/lint1/d_c99_init.exp
--- a/tests/usr.bin/xlint/lint1/d_c99_init.exp  Tue Mar 30 15:10:46 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_init.exp  Tue Mar 30 15:18:19 2021 +0000
@@ -8,13 +8,13 @@
 d_c99_init.c(242): warning: illegal combination of integer (char) and pointer (pointer to char) [183]
 d_c99_init.c(281): error: cannot initialize 'struct <unnamed>' from 'int' [185]
 d_c99_init.c(323): error: duplicate case in switch: 0 [199]
-d_c99_init.c(332): error: undefined struct/union member: r [101]
-d_c99_init.c(339): error: undefined struct/union member: r [101]
-d_c99_init.c(346): error: undefined struct/union member: r [101]
-d_c99_init.c(355): error: undefined struct/union member: unknown_value [101]
-d_c99_init.c(361): error: undefined struct/union member: unknown_value [101]
+d_c99_init.c(332): error: type 'struct point' does not have member 'r' [101]
+d_c99_init.c(339): error: type 'struct point' does not have member 'r' [101]
+d_c99_init.c(346): error: type 'struct point' does not have member 'r' [101]
+d_c99_init.c(355): error: type 'union value' does not have member 'unknown_value' [101]
+d_c99_init.c(361): error: type 'union value' does not have member 'unknown_value' [101]
 d_c99_init.c(365): error: syntax error 'designator '[...]' is only for arrays' [249]
-d_c99_init.c(366): error: undefined struct/union member: member [101]
+d_c99_init.c(366): error: type 'struct point' does not have member 'member' [101]
 d_c99_init.c(372): warning: structure has no named members [65]
 d_c99_init.c(373): error: too many struct/union initializers [172]
 d_c99_init.c(378): warning: union has no named members [65]
diff -r 5559b8dcf1f9 -r 68c2c50fbc3b tests/usr.bin/xlint/lint1/msg_101.c
--- a/tests/usr.bin/xlint/lint1/msg_101.c       Tue Mar 30 15:10:46 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_101.c       Tue Mar 30 15:18:19 2021 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: msg_101.c,v 1.3 2021/01/31 11:12:07 rillig Exp $       */
+/*     $NetBSD: msg_101.c,v 1.4 2021/03/30 15:18:19 rillig Exp $       */
 # 3 "msg_101.c"
 
-// Test for message: undefined struct/union member: %s [101]
+// Test for message: type '%s' does not have member '%s' [101]
 
 struct point {
        int x, y;
diff -r 5559b8dcf1f9 -r 68c2c50fbc3b tests/usr.bin/xlint/lint1/msg_101.exp
--- a/tests/usr.bin/xlint/lint1/msg_101.exp     Tue Mar 30 15:10:46 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_101.exp     Tue Mar 30 15:18:19 2021 +0000
@@ -1,1 +1,1 @@
-msg_101.c(13): error: undefined struct/union member: z [101]
+msg_101.c(13): error: type 'int' does not have member 'z' [101]
diff -r 5559b8dcf1f9 -r 68c2c50fbc3b usr.bin/xlint/lint1/err.c
--- a/usr.bin/xlint/lint1/err.c Tue Mar 30 15:10:46 2021 +0000
+++ b/usr.bin/xlint/lint1/err.c Tue Mar 30 15:18:19 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: err.c,v 1.98 2021/03/30 15:07:53 rillig Exp $  */
+/*     $NetBSD: err.c,v 1.99 2021/03/30 15:18:19 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.98 2021/03/30 15:07:53 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.99 2021/03/30 15:18:19 rillig Exp $");
 #endif
 
 #include <sys/types.h>
@@ -155,7 +155,7 @@
        "suffixes F and L are illegal in traditional C",              /* 98 */
        "'%s' undefined",                                             /* 99 */
        "unary + is illegal in traditional C",                        /* 100 */
-       "undefined struct/union member: %s",                          /* 101 */
+       "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 */
diff -r 5559b8dcf1f9 -r 68c2c50fbc3b usr.bin/xlint/lint1/init.c
--- a/usr.bin/xlint/lint1/init.c        Tue Mar 30 15:10:46 2021 +0000
+++ b/usr.bin/xlint/lint1/init.c        Tue Mar 30 15:18:19 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init.c,v 1.181 2021/03/30 15:10:46 rillig Exp $        */
+/*     $NetBSD: init.c,v 1.182 2021/03/30 15:18:19 rillig Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: init.c,v 1.181 2021/03/30 15:10:46 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.182 2021/03/30 15:18:19 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -306,9 +306,8 @@
 
        member = look_up_member(tp, name);
        if (member == NULL) {
-               /* TODO: add type information */
-               /* undefined struct/union member: %s */
-               error(101, name);
+               /* type '%s' does not have member '%s' */
+               error(101, type_name(tp), name);
        }
 
        return sym_type(member);
diff -r 5559b8dcf1f9 -r 68c2c50fbc3b usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Tue Mar 30 15:10:46 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Tue Mar 30 15:18:19 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.253 2021/03/28 13:09:43 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.254 2021/03/30 15:18:19 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.253 2021/03/28 13:09:43 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.254 2021/03/30 15:18:19 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -347,8 +347,8 @@
         * that no defined struct or union has a member with the same name.
         */
        if (msym->s_scl == NOSCL) {
-               /* undefined struct/union member: %s */
-               error(101, msym->s_name);
+               /* type '%s' does not have member '%s' */
+               error(101, type_name(msym->s_type), msym->s_name);
                rmsym(msym);
                msym->s_kind = FMEMBER;
                msym->s_scl = MOS;



Home | Main Index | Thread Index | Old Index