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: in the warning about ordered enums...



details:   https://anonhg.NetBSD.org/src/rev/ecbef9459dfd
branches:  trunk
changeset: 377372:ecbef9459dfd
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jul 09 12:04:08 2023 +0000

description:
lint: in the warning about ordered enums, mention the affected type

diffstat:

 tests/usr.bin/xlint/lint1/msg_243.c |  12 ++++++------
 usr.bin/xlint/lint1/err.c           |   6 +++---
 usr.bin/xlint/lint1/tree.c          |  12 +++++-------
 3 files changed, 14 insertions(+), 16 deletions(-)

diffs (91 lines):

diff -r 930e24c5d145 -r ecbef9459dfd tests/usr.bin/xlint/lint1/msg_243.c
--- a/tests/usr.bin/xlint/lint1/msg_243.c       Sun Jul 09 11:18:55 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_243.c       Sun Jul 09 12:04:08 2023 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: msg_243.c,v 1.5 2023/03/28 14:44:35 rillig Exp $       */
+/*     $NetBSD: msg_243.c,v 1.6 2023/07/09 12:04:08 rillig Exp $       */
 # 3 "msg_243.c"
 
-// Test for message: dubious comparison of enums, op '%s' [243]
+// Test for message: operator '%s' assumes that '%s' is ordered [243]
 
 /* lint1-extra-flags: -eP -X 351 */
 
@@ -16,13 +16,13 @@ void eval(_Bool);
 void
 example(enum color a, enum color b)
 {
-       /* expect+1: warning: dubious comparison of enums, op '<' [243] */
+       /* expect+1: warning: operator '<' assumes that 'enum color' is ordered [243] */
        eval(a < b);
-       /* expect+1: warning: dubious comparison of enums, op '<=' [243] */
+       /* expect+1: warning: operator '<=' assumes that 'enum color' is ordered [243] */
        eval(a <= b);
-       /* expect+1: warning: dubious comparison of enums, op '>' [243] */
+       /* expect+1: warning: operator '>' assumes that 'enum color' is ordered [243] */
        eval(a > b);
-       /* expect+1: warning: dubious comparison of enums, op '>=' [243] */
+       /* expect+1: warning: operator '>=' assumes that 'enum color' is ordered [243] */
        eval(a >= b);
        eval(a == b);
        eval(a != b);
diff -r 930e24c5d145 -r ecbef9459dfd usr.bin/xlint/lint1/err.c
--- a/usr.bin/xlint/lint1/err.c Sun Jul 09 11:18:55 2023 +0000
+++ b/usr.bin/xlint/lint1/err.c Sun Jul 09 12:04:08 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: err.c,v 1.208 2023/07/09 11:18:55 rillig Exp $ */
+/*     $NetBSD: err.c,v 1.209 2023/07/09 12:04:08 rillig Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: err.c,v 1.208 2023/07/09 11:18:55 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.209 2023/07/09 12:04:08 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -298,7 +298,7 @@ static const char *const msgs[] = {
        "",                     /* unused */                          /* 240 */
        "dubious operation '%s' on enum",                             /* 241 */
        "combination of '%s' and '%s', op '%s'",                      /* 242 */
-       "dubious comparison of enums, op '%s'",                       /* 243 */
+       "operator '%s' assumes that '%s' is ordered",                 /* 243 */
        "illegal structure pointer combination",                      /* 244 */
        "incompatible structure pointers: '%s' '%s' '%s'",            /* 245 */
        "dubious conversion of enum to '%s'",                         /* 246 */
diff -r 930e24c5d145 -r ecbef9459dfd usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Sun Jul 09 11:18:55 2023 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Sun Jul 09 12:04:08 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.557 2023/07/09 11:18:55 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.558 2023/07/09 12:04:08 rillig Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: tree.c,v 1.557 2023/07/09 11:18:55 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.558 2023/07/09 12:04:08 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -3132,11 +3132,9 @@ check_enum_type_mismatch(op_t op, int ar
                            type_name(rn->tn_type));
                        break;
                }
-       } else if (Pflag && mp->m_comparison && op != EQ && op != NE) {
-               if (eflag)
-                       /* dubious comparison of enums, op '%s' */
-                       warning(243, mp->m_name);
-       }
+       } else if (Pflag && eflag && mp->m_comparison && op != EQ && op != NE)
+               /* operator '%s' assumes that '%s' is ordered */
+               warning(243, mp->m_name, type_name(ln->tn_type));
 }
 
 /* Prints a warning if the operands mix between enum and integer. */



Home | Main Index | Thread Index | Old Index