diff options
| -rw-r--r-- | tests/usr.bin/xlint/lint1/msg_220.c | 9 | ||||
| -rw-r--r-- | tests/usr.bin/xlint/lint1/msg_220.exp | 7 | ||||
| -rw-r--r-- | usr.bin/xlint/common/lint.h | 4 | ||||
| -rw-r--r-- | usr.bin/xlint/lint1/lex.c | 9 |
4 files changed, 18 insertions, 11 deletions
diff --git a/tests/usr.bin/xlint/lint1/msg_220.c b/tests/usr.bin/xlint/lint1/msg_220.c index 05b34a27712..98bd2ba2024 100644 --- a/tests/usr.bin/xlint/lint1/msg_220.c +++ b/tests/usr.bin/xlint/lint1/msg_220.c @@ -1,4 +1,4 @@ -/* $NetBSD: msg_220.c,v 1.6 2021/08/29 09:09:53 rillig Exp $ */ +/* $NetBSD: msg_220.c,v 1.7 2021/08/29 09:29:32 rillig Exp $ */ # 3 "msg_220.c" // Test for message: fallthrough on case statement [220] @@ -52,8 +52,9 @@ annotation_comment_variations(int n) /* FALLTHROUGH */ case 1: println("1"); + /* Seen in libarchive/archive_string.c, macro WRITE_UC. */ /* FALL THROUGH */ - /* Lint warned before 2021-08-29. */ + /* Lint warned before lex.c 1.79 from 2021-08-29. */ case 2: println("2"); /* FALLS THROUGH */ @@ -64,12 +65,14 @@ annotation_comment_variations(int n) /* expect+1: warning: fallthrough on case statement [220] */ case 4: println("4"); + /* This is the Splint variant, which is seldom used. */ /* @fallthrough@ */ /* expect+1: warning: fallthrough on case statement [220] */ case 5: println("5"); + /* Seen in unbound/lookup3.c, function hashlittle. */ + /* Lint warned before lex.c 1.80 from 2021-08-29. */ /* fallthrough */ - /* expect+1: warning: fallthrough on case statement [220] */ case 6: println("6"); } diff --git a/tests/usr.bin/xlint/lint1/msg_220.exp b/tests/usr.bin/xlint/lint1/msg_220.exp index 5fbd7e590db..d235e5b23ff 100644 --- a/tests/usr.bin/xlint/lint1/msg_220.exp +++ b/tests/usr.bin/xlint/lint1/msg_220.exp @@ -1,6 +1,5 @@ msg_220.c(19): warning: fallthrough on case statement [220] msg_220.c(22): warning: fallthrough on default statement [284] -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] -msg_220.c(73): warning: fallthrough on case statement [220] +msg_220.c(62): warning: fallthrough on case statement [220] +msg_220.c(66): warning: fallthrough on case statement [220] +msg_220.c(71): warning: fallthrough on case statement [220] diff --git a/usr.bin/xlint/common/lint.h b/usr.bin/xlint/common/lint.h index e3a4d62df8f..a05ec36d682 100644 --- a/usr.bin/xlint/common/lint.h +++ b/usr.bin/xlint/common/lint.h @@ -1,4 +1,4 @@ -/* $NetBSD: lint.h,v 1.30 2021/08/28 12:59:25 rillig Exp $ */ +/* $NetBSD: lint.h,v 1.31 2021/08/29 09:29:32 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -153,3 +153,5 @@ static inline bool ch_isprint(char ch) { return isprint((unsigned char)ch) != 0; } static inline bool ch_isspace(char ch) { return isspace((unsigned char)ch) != 0; } +static inline bool +ch_isupper(char ch) { return isupper((unsigned char)ch) != 0; } diff --git a/usr.bin/xlint/lint1/lex.c b/usr.bin/xlint/lint1/lex.c index f588f019957..7a199619fc8 100644 --- a/usr.bin/xlint/lint1/lex.c +++ b/usr.bin/xlint/lint1/lex.c @@ -1,4 +1,4 @@ -/* $NetBSD: lex.c,v 1.79 2021/08/29 09:05:35 rillig Exp $ */ +/* $NetBSD: lex.c,v 1.80 2021/08/29 09:29:32 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: lex.c,v 1.79 2021/08/29 09:05:35 rillig Exp $"); +__RCSID("$NetBSD: lex.c,v 1.80 2021/08/29 09:29:32 rillig Exp $"); #endif #include <ctype.h> @@ -1121,6 +1121,7 @@ lex_comment(void) { "FALLTHRU", false, fallthru }, { "FALLTHROUGH", false, fallthru }, { "FALL THROUGH", false, fallthru }, + { "fallthrough", false, fallthru }, { "LINTLIBRARY", false, lintlib }, { "LINTED", true, linted }, { "LONGLONG", false, longlong }, @@ -1146,7 +1147,9 @@ lex_comment(void) /* Read the potential keyword to keywd */ l = 0; while (c != EOF && l < sizeof(keywd) - 1 && - (isupper(c) || isspace(c))) { + (isalpha(c) || isspace(c))) { + if (islower(c) && l > 0 && ch_isupper(keywd[0])) + break; keywd[l++] = (char)c; c = inpc(); } |
