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 wrong error in strict bool mod...



details:   https://anonhg.NetBSD.org/src/rev/5235e1132d0d
branches:  trunk
changeset: 1029131:5235e1132d0d
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Dec 22 15:36:37 2021 +0000

description:
lint: fix wrong error in strict bool mode in condition with comma

For the result of the comma operator, it doesn't matter whether the
comma itself comes from a system header or not.  Instead, it's the main
operator of the right operand.

Since 2021-11-16.

diffstat:

 tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c   |  20 ++++++-----------
 tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp |   1 -
 usr.bin/xlint/lint1/ckbool.c                           |   7 ++++-
 3 files changed, 12 insertions(+), 16 deletions(-)

diffs (83 lines):

diff -r 6aec04b72e43 -r 5235e1132d0d tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c
--- a/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c      Wed Dec 22 15:20:08 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.c      Wed Dec 22 15:36:37 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: d_c99_bool_strict_syshdr.c,v 1.11 2021/12/22 15:20:08 rillig Exp $     */
+/*     $NetBSD: d_c99_bool_strict_syshdr.c,v 1.12 2021/12/22 15:36:37 rillig Exp $     */
 # 3 "d_c99_bool_strict_syshdr.c"
 
 /*
@@ -181,6 +181,12 @@
 
 int read_char(void);
 
+/*
+ * Between tree.c 1.395 from 2021-11-16 and ckbool.c 1.10 from 2021-12-22,
+ * lint wrongly complained that the controlling expression would have to be
+ * _Bool instead of int.  Since the right-hand side of the ',' operator comes
+ * from a system header, this is OK though.
+ */
 void
 controlling_expression_with_comma_operator(void)
 {
@@ -195,17 +201,5 @@
            )] & 0x0040 /* Space     */))
 # 197 "c_c99_bool_strict_syshdr.c"
            )
-       /* expect-1: error: controlling expression must be bool, not 'int' [333] */
                continue;
-       /*
-        * TODO: investigate why lint doesn't accept this call to isspace().
-        *  It comes from a system header, therefore type 'int' should be OK.
-        *  It is probably because the ',' of the controlling expression
-        *  comes from the main source file, and lint assumes that the main
-        *  operator of the controlling expression decides its outcome.  This
-        *  assumption does not hold for the ',' operator since its result
-        *  only depends on its right-hand operand.
-        *
-        *  Since tree.c 1.395 from 2021-11-16.
-        */
 }
diff -r 6aec04b72e43 -r 5235e1132d0d tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp
--- a/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp    Wed Dec 22 15:20:08 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp    Wed Dec 22 15:36:37 2021 +0000
@@ -4,4 +4,3 @@
 d_c99_bool_strict_syshdr.c(157): error: return value type mismatch (_Bool) and (int) [211]
 d_c99_bool_strict_syshdr.c(172): error: operand of '!' must be bool, not 'int' [330]
 d_c99_bool_strict_syshdr.c(172): warning: function 'str_equal_bad' expects to return value [214]
-c_c99_bool_strict_syshdr.c(197): error: controlling expression must be bool, not 'int' [333]
diff -r 6aec04b72e43 -r 5235e1132d0d usr.bin/xlint/lint1/ckbool.c
--- a/usr.bin/xlint/lint1/ckbool.c      Wed Dec 22 15:20:08 2021 +0000
+++ b/usr.bin/xlint/lint1/ckbool.c      Wed Dec 22 15:36:37 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ckbool.c,v 1.9 2021/11/16 21:01:05 rillig Exp $ */
+/* $NetBSD: ckbool.c,v 1.10 2021/12/22 15:36:37 rillig Exp $ */
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 #include <sys/cdefs.h>
 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: ckbool.c,v 1.9 2021/11/16 21:01:05 rillig Exp $");
+__RCSID("$NetBSD: ckbool.c,v 1.10 2021/12/22 15:36:37 rillig Exp $");
 #endif
 
 #include <string.h>
@@ -49,6 +49,7 @@
  * See d_c99_bool_strict.c for the exact rules and for examples.
  */
 
+
 static const char *
 op_name(op_t op)
 {
@@ -215,6 +216,8 @@
 
        lint_assert(Tflag);
 
+       while (tn->tn_op == COMMA)
+               tn = tn->tn_right;
        tn = before_conversion(tn);
        t = tn->tn_type->t_tspec;
 



Home | Main Index | Thread Index | Old Index