From f260bdb92f361d3b4e3ab9d23e5f0eb4faafd698 Mon Sep 17 00:00:00 2001 From: rillig Date: Fri, 7 Jul 2023 06:03:31 +0000 Subject: lint: only skip 'unused' warnings after errors, not other warnings Previously, in -w mode, any warning suppressed further 'unused' warnings, even though there was no need to do that. This can be seen in the test gcc_attribute_var.c, where only the last unused variable from a function was marked as unused, the others slipped through. Fixed by counting the errors and the warnings separately and only combining them if actually desired. --- tests/usr.bin/xlint/lint1/msg_324.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests/usr.bin/xlint/lint1/msg_324.c') diff --git a/tests/usr.bin/xlint/lint1/msg_324.c b/tests/usr.bin/xlint/lint1/msg_324.c index 288319e3b9d..5dd0d7e8aad 100644 --- a/tests/usr.bin/xlint/lint1/msg_324.c +++ b/tests/usr.bin/xlint/lint1/msg_324.c @@ -1,4 +1,4 @@ -/* $NetBSD: msg_324.c,v 1.7 2022/06/22 19:23:18 rillig Exp $ */ +/* $NetBSD: msg_324.c,v 1.8 2023/07/07 06:03:31 rillig Exp $ */ # 3 "msg_324.c" // Test for message: suggest cast from '%s' to '%s' on op '%s' to avoid overflow [324] @@ -22,10 +22,12 @@ example(char c, int i, unsigned u) long long ll; unsigned long long ull; + /* expect+2: warning: 'll' set but not used in function 'example' [191] */ /* expect+1: warning: suggest cast from 'int' to 'long long' on op '+' to avoid overflow [324] */ ll = c + i; /* expect+1: warning: suggest cast from 'int' to 'long long' on op '-' to avoid overflow [324] */ ll = i - c; + /* expect+2: warning: 'ull' set but not used in function 'example' [191] */ /* expect+1: warning: suggest cast from 'unsigned int' to 'unsigned long long' on op '*' to avoid overflow [324] */ ull = c * u; /* expect+1: warning: suggest cast from 'unsigned int' to 'unsigned long long' on op '+' to avoid overflow [324] */ -- cgit