Module Name: src Committed By: rillig Date: Sun May 22 13:53:39 UTC 2022
Modified Files: src/tests/usr.bin/xlint/lint1: msg_206.c msg_206.exp Log Message: tests/lint: demonstrate wrong warning for switch on enum To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_206.c \ src/tests/usr.bin/xlint/lint1/msg_206.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/usr.bin/xlint/lint1/msg_206.c diff -u src/tests/usr.bin/xlint/lint1/msg_206.c:1.4 src/tests/usr.bin/xlint/lint1/msg_206.c:1.5 --- src/tests/usr.bin/xlint/lint1/msg_206.c:1.4 Thu Jul 8 18:53:57 2021 +++ src/tests/usr.bin/xlint/lint1/msg_206.c Sun May 22 13:53:39 2022 @@ -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 @@ test(enum number num) 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; +} Index: src/tests/usr.bin/xlint/lint1/msg_206.exp diff -u src/tests/usr.bin/xlint/lint1/msg_206.exp:1.4 src/tests/usr.bin/xlint/lint1/msg_206.exp:1.5 --- src/tests/usr.bin/xlint/lint1/msg_206.exp:1.4 Thu Jul 8 18:53:57 2021 +++ src/tests/usr.bin/xlint/lint1/msg_206.exp Sun May 22 13:53:39 2022 @@ -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]