Module Name: src Committed By: rillig Date: Mon Mar 10 22:08:36 UTC 2025
Modified Files: src/tests/usr.bin/xlint/lint1: msg_385.c src/usr.bin/xlint/lint1: lex.c Log Message: lint: only warn about do-while macro if the 'do' is a keyword To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_385.c cvs rdiff -u -r1.233 -r1.234 src/usr.bin/xlint/lint1/lex.c 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_385.c diff -u src/tests/usr.bin/xlint/lint1/msg_385.c:1.1 src/tests/usr.bin/xlint/lint1/msg_385.c:1.2 --- src/tests/usr.bin/xlint/lint1/msg_385.c:1.1 Sun Dec 8 17:12:01 2024 +++ src/tests/usr.bin/xlint/lint1/msg_385.c Mon Mar 10 22:08:36 2025 @@ -1,4 +1,4 @@ -/* $NetBSD: msg_385.c,v 1.1 2024/12/08 17:12:01 rillig Exp $ */ +/* $NetBSD: msg_385.c,v 1.2 2025/03/10 22:08:36 rillig Exp $ */ # 3 "msg_385.c" // Test for message: do-while macro '%.*s' ends with semicolon [385] @@ -52,3 +52,7 @@ call_correct_stmt(int x) else do { } while (0); } + +// The macro expansion does start with "do", but not with the keyword "do", +// so don't warn in this case. +#define unrelated() do_something(); Index: src/usr.bin/xlint/lint1/lex.c diff -u src/usr.bin/xlint/lint1/lex.c:1.233 src/usr.bin/xlint/lint1/lex.c:1.234 --- src/usr.bin/xlint/lint1/lex.c:1.233 Thu Feb 27 06:48:28 2025 +++ src/usr.bin/xlint/lint1/lex.c Mon Mar 10 22:08:35 2025 @@ -1,4 +1,4 @@ -/* $NetBSD: lex.c,v 1.233 2025/02/27 06:48:28 rillig Exp $ */ +/* $NetBSD: lex.c,v 1.234 2025/03/10 22:08:35 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) -__RCSID("$NetBSD: lex.c,v 1.233 2025/02/27 06:48:28 rillig Exp $"); +__RCSID("$NetBSD: lex.c,v 1.234 2025/03/10 22:08:35 rillig Exp $"); #endif #include <ctype.h> @@ -1137,7 +1137,7 @@ check_stmt_macro(const char *text) while (*p == ' ') p++; - if (strncmp(p, "do", 2) == 0 && !ch_isalnum(p[2])) + if (strncmp(p, "do", 2) == 0 && !ch_isalnum(p[2]) && p[2] != '_') /* do-while macro '%.*s' ends with semicolon */ warning(385, (int)(name_end - name_start), name_start); }