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: test variants of the F...



details:   https://anonhg.NetBSD.org/src/rev/f6cfe6282761
branches:  trunk
changeset: 985517:f6cfe6282761
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Aug 29 08:57:50 2021 +0000

description:
tests/lint: test variants of the FALLTHROUGH comment

diffstat:

 tests/usr.bin/xlint/lint1/msg_220.c   |  31 ++++++++++++++++++++++++++++++-
 tests/usr.bin/xlint/lint1/msg_220.exp |   4 ++++
 2 files changed, 34 insertions(+), 1 deletions(-)

diffs (52 lines):

diff -r a1553cef1efd -r f6cfe6282761 tests/usr.bin/xlint/lint1/msg_220.c
--- a/tests/usr.bin/xlint/lint1/msg_220.c       Sun Aug 29 08:43:12 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_220.c       Sun Aug 29 08:57:50 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_220.c,v 1.3 2021/04/12 15:54:55 christos Exp $     */
+/*     $NetBSD: msg_220.c,v 1.4 2021/08/29 08:57:50 rillig Exp $       */
 # 3 "msg_220.c"
 
 // Test for message: fallthrough on case statement [220]
@@ -41,3 +41,32 @@
                println("number");
        }
 }
+
+/* https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wimplicit-fallthrough */
+void
+annotation_comment_variations(int n)
+{
+       switch (n) {
+       case 0:
+               println("0");
+               /* FALLTHROUGH */
+       case 1:
+               println("1");
+               /* FALL THROUGH */
+               /* expect+1: warning: fallthrough on case statement [220] */
+       case 2:
+               println("2");
+               /* FALLS THROUGH */
+               /* expect+1: warning: fallthrough on case statement [220] */
+       case 3:
+               println("3");
+               /* intentionally falls through */
+               /* expect+1: warning: fallthrough on case statement [220] */
+       case 4:
+               println("4");
+               /* @fallthrough@ */
+               /* expect+1: warning: fallthrough on case statement [220] */
+       case 5:
+               println("5");
+       }
+}
diff -r a1553cef1efd -r f6cfe6282761 tests/usr.bin/xlint/lint1/msg_220.exp
--- a/tests/usr.bin/xlint/lint1/msg_220.exp     Sun Aug 29 08:43:12 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_220.exp     Sun Aug 29 08:57:50 2021 +0000
@@ -1,2 +1,6 @@
 msg_220.c(19): warning: fallthrough on case statement [220]
 msg_220.c(22): warning: fallthrough on default statement [284]
+msg_220.c(57): warning: fallthrough on case statement [220]
+msg_220.c(61): warning: fallthrough on case statement [220]
+msg_220.c(65): warning: fallthrough on case statement [220]
+msg_220.c(69): warning: fallthrough on case statement [220]



Home | Main Index | Thread Index | Old Index