Source-Changes-HG archive

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

[src/trunk]: src/tests/usr.bin/xlint/lint1 tests/lint: demonstrate wrong warn...



details:   https://anonhg.NetBSD.org/src/rev/2b2d09b492ac
branches:  trunk
changeset: 366349:2b2d09b492ac
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun May 22 13:53:39 2022 +0000

description:
tests/lint: demonstrate wrong warning for switch on enum

diffstat:

 tests/usr.bin/xlint/lint1/msg_206.c   |  20 +++++++++++++++++++-
 tests/usr.bin/xlint/lint1/msg_206.exp |   1 +
 2 files changed, 20 insertions(+), 1 deletions(-)

diffs (37 lines):

diff -r af976143bd00 -r 2b2d09b492ac tests/usr.bin/xlint/lint1/msg_206.c
--- a/tests/usr.bin/xlint/lint1/msg_206.c       Sun May 22 13:38:08 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_206.c       Sun May 22 13:53:39 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_206.c,v 1.4 2021/07/08 18:53:57 rillig Exp $       */
+/*     $NetBSD: msg_206.c,v 1.5 2022/05/22 13:53:39 rillig Exp $       */
 # 3 "msg_206.c"
 
 // Test for message: enumeration value(s) not handled in switch [206]
@@ -26,3 +26,21 @@
                break;
        }
 }
+
+int
+too_many(enum number num)
+{
+       switch (num) {
+       case ONE:
+               return 1;
+       case TWO:
+               return 2;
+       case THREE:
+               return 3;
+       case 3:
+               return -1;
+       }
+       /* FIXME: There are _too many_ branches, not _too few_. */
+       /* expect-2: warning: enumeration value(s) not handled in switch [206] */
+       return 3;
+}
diff -r af976143bd00 -r 2b2d09b492ac tests/usr.bin/xlint/lint1/msg_206.exp
--- a/tests/usr.bin/xlint/lint1/msg_206.exp     Sun May 22 13:38:08 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_206.exp     Sun May 22 13:53:39 2022 +0000
@@ -1,1 +1,2 @@
 msg_206.c(19): warning: enumeration value(s) not handled in switch [206]
+msg_206.c(42): warning: enumeration value(s) not handled in switch [206]



Home | Main Index | Thread Index | Old Index