Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/lint1 lint: fix strict bool mode errors in cgr...



details:   https://anonhg.NetBSD.org/src/rev/d0769dd8e252
branches:  trunk
changeset: 982621:d0769dd8e252
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Apr 18 21:53:37 2021 +0000

description:
lint: fix strict bool mode errors in cgram.y

The code generated by yacc already adheres to strict bool mode, in
default mode as well as in debug mode.

Running lint on the generated cgram.c as well avoids most of the
"declared but not used" warnings from lint2.

The code generated by lex does not adhere to strict bool mode though.
Suppressing the errors from strict bool mode works, but then lint1 runs
into an assertion failure:

        assertion "tn != NULL || nerr != 0" failed
            in expr at tree.c:3610 near scan.c:822

This leaves several warnings about "declared but not used" for the
functions from lex.c.

diffstat:

 usr.bin/xlint/lint1/Makefile |  13 ++++++++-----
 usr.bin/xlint/lint1/cgram.y  |  10 +++++-----
 2 files changed, 13 insertions(+), 10 deletions(-)

diffs (76 lines):

diff -r a12378fcafaa -r d0769dd8e252 usr.bin/xlint/lint1/Makefile
--- a/usr.bin/xlint/lint1/Makefile      Sun Apr 18 21:12:50 2021 +0000
+++ b/usr.bin/xlint/lint1/Makefile      Sun Apr 18 21:53:37 2021 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.68 2021/04/17 11:01:34 rillig Exp $
+#      $NetBSD: Makefile,v 1.69 2021/04/18 21:53:37 rillig Exp $
 
 .include <bsd.own.mk>
 
@@ -10,13 +10,16 @@
 
 MAN=           lint.7
 YHEADER=
-#DBG=-g
-#CPPFLAGS+=-DYYDEBUG=1
-#YFLAGS+=-v
-#LFLAGS+=-d
+#DBG=          -g
+#CPPFLAGS+=    -DYYDEBUG=1
+#YFLAGS+=      -v
+#LFLAGS+=      -d
 
 CWARNFLAGS.clang+=     -Wno-error=implicit-int-float-conversion
 LINTFLAGS+=            -T
+LOBJS.${PROG}+=                ${SRCS:M*.y:.y=.ln}
+#LOBJS.${PROG}+=       ${SRCS:M*.l:.l=.ln}
+LINTFLAGS.scan.c=      -X 107,330,331,333
 
 CPPFLAGS+=     -DIS_LINT1
 CPPFLAGS+=     -I${.CURDIR}
diff -r a12378fcafaa -r d0769dd8e252 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Sun Apr 18 21:12:50 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Sun Apr 18 21:53:37 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.218 2021/04/14 22:08:28 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.219 2021/04/18 21:53:37 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.218 2021/04/14 22:08:28 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.219 2021/04/18 21:53:37 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -118,7 +118,7 @@
 static void
 anonymize(sym_t *s)
 {
-       for ( ; s; s = s->s_next)
+       for ( ; s != NULL; s = s->s_next)
                s->s_styp = NULL;
 }
 %}
@@ -138,7 +138,7 @@
        range_t y_range;
        strg_t  *y_string;
        pqinf_t *y_pqinf;
-       int     y_seen_statement;
+       bool    y_seen_statement;
 };
 
 %token                 T_LBRACE T_RBRACE T_LBRACK T_RBRACK T_LPAREN T_RPAREN
@@ -2145,7 +2145,7 @@
 static sym_t *
 symbolrename(sym_t *s, sbuf_t *sb)
 {
-       if (sb)
+       if (sb != NULL)
                s->s_rename = sb->sb_name;
        return s;
 }



Home | Main Index | Thread Index | Old Index