Module Name: src
Committed By: rillig
Date: Fri Oct 4 11:38:03 UTC 2024
Modified Files:
src/tests/usr.bin/xlint/lint1: lex_comment.c
src/usr.bin/xlint/lint1: cgram.y
Log Message:
lint: fix suppressed warnings after if-else-if statement
Seen in sbin/dump/main.c, the "cp = strchr" line.
The bug had been there since at least 2002.
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/lex_comment.c
cvs rdiff -u -r1.511 -r1.512 src/usr.bin/xlint/lint1/cgram.y
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/lex_comment.c
diff -u src/tests/usr.bin/xlint/lint1/lex_comment.c:1.2 src/tests/usr.bin/xlint/lint1/lex_comment.c:1.3
--- src/tests/usr.bin/xlint/lint1/lex_comment.c:1.2 Fri Oct 4 11:24:13 2024
+++ src/tests/usr.bin/xlint/lint1/lex_comment.c Fri Oct 4 11:38:03 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: lex_comment.c,v 1.2 2024/10/04 11:24:13 rillig Exp $ */
+/* $NetBSD: lex_comment.c,v 1.3 2024/10/04 11:38:03 rillig Exp $ */
# 3 "lex_comment.c"
/*
@@ -68,14 +68,12 @@ lint_comment(void)
} else if (s8 == 1)
;
/* LINTED 132 */
- /* expect+1: warning: conversion from 'long long' to 'signed char' may lose accuracy [132] */
s8 = s64;
if (s8 == 0) {
} else if (s8 == 1) {
}
/* LINTED 132 */
- /* expect+1: warning: conversion from 'long long' to 'signed char' may lose accuracy [132] */
s8 = s64;
}
Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.511 src/usr.bin/xlint/lint1/cgram.y:1.512
--- src/usr.bin/xlint/lint1/cgram.y:1.511 Sat Sep 28 16:09:23 2024
+++ src/usr.bin/xlint/lint1/cgram.y Fri Oct 4 11:38:03 2024
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.511 2024/09/28 16:09:23 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.512 2024/10/04 11:38:03 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: cgram.y,v 1.511 2024/09/28 16:09:23 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.512 2024/10/04 11:38:03 rillig Exp $");
#endif
#include <limits.h>
@@ -2158,7 +2158,7 @@ selection_statement:
save_warning_flags();
stmt_if_then_stmt();
} statement {
- clear_warning_flags();
+ restore_warning_flags();
stmt_if_else_stmt(true);
}
| if_without_else T_ELSE error {