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 to message ab...



details:   https://anonhg.NetBSD.org/src/rev/2cf44cb93bf0
branches:  trunk
changeset: 952923:2cf44cb93bf0
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Feb 21 10:28:32 2021 +0000

description:
lint: add type information to message about enum mismatch

diffstat:

 tests/usr.bin/xlint/lint1/d_struct_init_nested.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_210.exp              |   4 ++--
 usr.bin/xlint/common/tyname.c                      |  17 ++++++++++++-----
 usr.bin/xlint/lint1/err.c                          |   6 +++---
 usr.bin/xlint/lint1/tree.c                         |   9 +++++----
 5 files changed, 23 insertions(+), 15 deletions(-)

diffs (113 lines):

diff -r 6d5327908f3f -r 2cf44cb93bf0 tests/usr.bin/xlint/lint1/d_struct_init_nested.exp
--- a/tests/usr.bin/xlint/lint1/d_struct_init_nested.exp        Sun Feb 21 10:12:29 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_struct_init_nested.exp        Sun Feb 21 10:28:32 2021 +0000
@@ -1,4 +1,4 @@
 d_struct_init_nested.c(35): initialisation type mismatch (enum I1) and (struct Inner1) [185]
 d_struct_init_nested.c(37): too many struct/union initializers [172]
 d_struct_init_nested.c(62): initialisation type mismatch (enum I1) and (struct Inner2) [185]
-d_struct_init_nested.c(64): warning: enum type mismatch in initialisation [210]
+d_struct_init_nested.c(64): warning: enum type mismatch between 'enum I2' and 'enum O3' in initialisation [210]
diff -r 6d5327908f3f -r 2cf44cb93bf0 tests/usr.bin/xlint/lint1/msg_210.exp
--- a/tests/usr.bin/xlint/lint1/msg_210.exp     Sun Feb 21 10:12:29 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_210.exp     Sun Feb 21 10:28:32 2021 +0000
@@ -1,2 +1,2 @@
-msg_210.c(23): warning: enum type mismatch in initialisation [210]
-msg_210.c(25): warning: enum type mismatch in initialisation [210]
+msg_210.c(23): warning: enum type mismatch between 'enum A' and 'enum B' in initialisation [210]
+msg_210.c(25): warning: enum type mismatch between 'C' and 'D' in initialisation [210]
diff -r 6d5327908f3f -r 2cf44cb93bf0 usr.bin/xlint/common/tyname.c
--- a/usr.bin/xlint/common/tyname.c     Sun Feb 21 10:12:29 2021 +0000
+++ b/usr.bin/xlint/common/tyname.c     Sun Feb 21 10:28:32 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tyname.c,v 1.29 2021/02/19 22:27:49 rillig Exp $       */
+/*     $NetBSD: tyname.c,v 1.30 2021/02/21 10:28:32 rillig Exp $       */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tyname.c,v 1.29 2021/02/19 22:27:49 rillig Exp $");
+__RCSID("$NetBSD: tyname.c,v 1.30 2021/02/21 10:28:32 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -337,10 +337,17 @@
                buf_add(&buf, type_name(tp->t_subt));
                break;
        case ENUM:
+#ifdef t_enum
+               if (tp->t_enum->en_tag->s_name == unnamed &&
+                   tp->t_enum->en_first_typedef != NULL) {
+                       buf.len -= strlen(tspec_name(t));
+                       buf_add(&buf, tp->t_enum->en_first_typedef->s_name);
+               } else {
+                       buf_add(&buf, " ");
+                       buf_add(&buf, tp->t_enum->en_tag->s_name);
+               }
+#else
                buf_add(&buf, " ");
-#ifdef t_enum
-               buf_add(&buf, tp->t_enum->en_tag->s_name);
-#else
                buf_add(&buf,
                    tp->t_isuniqpos ? "*anonymous*" : tp->t_tag->h_name);
 #endif
diff -r 6d5327908f3f -r 2cf44cb93bf0 usr.bin/xlint/lint1/err.c
--- a/usr.bin/xlint/lint1/err.c Sun Feb 21 10:12:29 2021 +0000
+++ b/usr.bin/xlint/lint1/err.c Sun Feb 21 10:28:32 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: err.c,v 1.79 2021/02/19 12:28:56 rillig Exp $  */
+/*     $NetBSD: err.c,v 1.80 2021/02/21 10:28:33 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.79 2021/02/19 12:28:56 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.80 2021/02/21 10:28:33 rillig Exp $");
 #endif
 
 #include <sys/types.h>
@@ -269,7 +269,7 @@
        "loop not entered at top",                                    /* 207 */
        "break outside loop or switch",                               /* 208 */
        "continue outside loop",                                      /* 209 */
-       "enum type mismatch in initialisation",                       /* 210 */
+       "enum type mismatch between '%s' and '%s' in initialisation", /* 210 */
        "return value type mismatch (%s) and (%s)",                   /* 211 */
        "cannot return incomplete type",                              /* 212 */
        "void function %s cannot return value",                       /* 213 */
diff -r 6d5327908f3f -r 2cf44cb93bf0 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Sun Feb 21 10:12:29 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Sun Feb 21 10:28:32 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.213 2021/02/21 07:21:57 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.214 2021/02/21 10:28:33 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.213 2021/02/21 07:21:57 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.214 2021/02/21 10:28:33 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -1717,8 +1717,9 @@
        if (ln->tn_type->t_enum != rn->tn_type->t_enum) {
                switch (op) {
                case INIT:
-                       /* enum type mismatch in initialisation */
-                       warning(210);
+                       /* enum type mismatch between '%s' and '%s' in ... */
+                       warning(210,
+                           type_name(ln->tn_type), type_name(rn->tn_type));
                        break;
                case FARG:
                        /* enum type mismatch, arg #%d (%s != %s) */



Home | Main Index | Thread Index | Old Index