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: disable check for enum type mismat...



details:   https://anonhg.NetBSD.org/src/rev/68721e060a3d
branches:  trunk
changeset: 953474:68721e060a3d
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Mar 10 00:02:00 2021 +0000

description:
lint: disable check for enum type mismatch in switch statement

This check has been too quick and broke the lint build.  Among others,
lib/libpuffs has -w included in LINTFLAGS, which means that the build
can fail even for new warnings, not only for errors.

libpuffs compares a uint16_t with constants from an unnamed enum type.
Since the enum type is completely unnamed (neither a tag nor a typedef),
there is no way to define a struct member having this type. This was a
scenario that I just didn't consider when I added the check to lint.

For now, disable the new check completely.  The previously existing lint
checks stay enabled, including the one that warns about mismatched
anonymous enum types in the '==' operator, which is very similar to the
now disabled check.

diffstat:

 tests/usr.bin/xlint/lint1/msg_130.c   |  13 +++++++------
 tests/usr.bin/xlint/lint1/msg_130.exp |   9 ++-------
 usr.bin/xlint/lint1/func.c            |   6 ++++--
 3 files changed, 13 insertions(+), 15 deletions(-)

diffs (82 lines):

diff -r bccee610a6a8 -r 68721e060a3d tests/usr.bin/xlint/lint1/msg_130.c
--- a/tests/usr.bin/xlint/lint1/msg_130.c       Tue Mar 09 23:40:43 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_130.c       Wed Mar 10 00:02:00 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_130.c,v 1.10 2021/03/09 23:40:43 rillig Exp $      */
+/*     $NetBSD: msg_130.c,v 1.11 2021/03/10 00:02:00 rillig Exp $      */
 # 3 "msg_130.c"
 
 // Test for message: enum type mismatch: '%s' '%s' '%s' [130]
@@ -44,9 +44,9 @@
 switch_example(enum color c)
 {
        switch (c) {
-       case EVENING:                   /* expect: 130 */
-       case LARGE:                     /* expect: 130 */
-       case 0:                         /* expect: 130 */
+       case EVENING:                   /* maybe someday expect: 130 */
+       case LARGE:                     /* maybe someday expect: 130 */
+       case 0:                         /* maybe someday expect: 130 */
                sink(1 == 1);
                break;
        default:
@@ -71,10 +71,11 @@
 int
 enum_constant_from_unnamed_type(int x)
 {
+       /* using an enum constant as constant-expression */
        switch (x) {
-       case sizeof_int:                /* expect: 130 *//* FIXME */
+       case sizeof_int:
                return 1;
-       case sizeof_long:               /* expect: 130 *//* FIXME */
+       case sizeof_long:
                return 2;
        default:
                break;
diff -r bccee610a6a8 -r 68721e060a3d tests/usr.bin/xlint/lint1/msg_130.exp
--- a/tests/usr.bin/xlint/lint1/msg_130.exp     Tue Mar 09 23:40:43 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_130.exp     Wed Mar 10 00:02:00 2021 +0000
@@ -1,10 +1,5 @@
 msg_130.c(29): warning: enum type mismatch: 'enum color' ':' 'enum daytime' [130]
 msg_130.c(31): warning: enum type mismatch: 'enum color' '!=' 'enum size' [130]
 msg_130.c(32): warning: enum type mismatch: 'enum color' '==' 'enum size' [130]
-msg_130.c(47): warning: enum type mismatch: 'enum color' '==' 'enum daytime' [130]
-msg_130.c(48): warning: enum type mismatch: 'enum color' '==' 'enum size' [130]
-msg_130.c(49): warning: enum type mismatch: 'enum color' '==' 'int' [130]
-msg_130.c(75): warning: enum type mismatch: 'int' '==' 'enum <unnamed>' [130]
-msg_130.c(77): warning: enum type mismatch: 'int' '==' 'enum <unnamed>' [130]
-msg_130.c(88): warning: enum type mismatch: 'enum <unnamed>' '==' 'enum <unnamed>' [130]
-msg_130.c(126): warning: enum type mismatch: 'enum <unnamed>' '==' 'enum <unnamed>' [130]
+msg_130.c(89): warning: enum type mismatch: 'enum <unnamed>' '==' 'enum <unnamed>' [130]
+msg_130.c(127): warning: enum type mismatch: 'enum <unnamed>' '==' 'enum <unnamed>' [130]
diff -r bccee610a6a8 -r 68721e060a3d usr.bin/xlint/lint1/func.c
--- a/usr.bin/xlint/lint1/func.c        Tue Mar 09 23:40:43 2021 +0000
+++ b/usr.bin/xlint/lint1/func.c        Wed Mar 10 00:02:00 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: func.c,v 1.75 2021/03/05 17:10:05 rillig Exp $ */
+/*     $NetBSD: func.c,v 1.76 2021/03/10 00:02:00 rillig Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: func.c,v 1.75 2021/03/05 17:10:05 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.76 2021/03/10 00:02:00 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -437,9 +437,11 @@
            tn->tn_type->t_enum == ci->c_swtype->t_enum)
                return;
 
+#if 0 /* not yet ready, see msg_130.c */
        /* enum type mismatch: '%s' '%s' '%s' */
        warning(130, type_name(ci->c_swtype), getopname(EQ),
            type_name(tn->tn_type));
+#endif
 }
 
 static void



Home | Main Index | Thread Index | Old Index