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: loosen assertion that unary operat...



details:   https://anonhg.NetBSD.org/src/rev/862d98818f6a
branches:  trunk
changeset: 376173:862d98818f6a
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jun 03 20:58:00 2023 +0000

description:
lint: loosen assertion that unary operators have only a single operand

diffstat:

 usr.bin/xlint/lint1/debug.c |  8 +++++---
 usr.bin/xlint/lint1/ops.def |  7 ++++++-
 2 files changed, 11 insertions(+), 4 deletions(-)

diffs (50 lines):

diff -r aed2e3576bbe -r 862d98818f6a usr.bin/xlint/lint1/debug.c
--- a/usr.bin/xlint/lint1/debug.c       Sat Jun 03 20:41:44 2023 +0000
+++ b/usr.bin/xlint/lint1/debug.c       Sat Jun 03 20:58:00 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: debug.c,v 1.32 2023/06/03 20:40:28 rillig Exp $ */
+/* $NetBSD: debug.c,v 1.33 2023/06/03 20:58:00 rillig Exp $ */
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: debug.c,v 1.32 2023/06/03 20:40:28 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.33 2023/06/03 20:58:00 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -220,7 +220,9 @@ debug_node(const tnode_t *tn) // NOLINT(
                debug_indent_inc();
                lint_assert(tn->tn_left != NULL);
                debug_node(tn->tn_left);
-               lint_assert(is_binary(tn) == (tn->tn_right != NULL));
+               if (op != INCBEF && op != INCAFT
+                   && op != DECBEF && op != DECAFT)
+                       lint_assert(is_binary(tn) == (tn->tn_right != NULL));
                if (tn->tn_right != NULL)
                        debug_node(tn->tn_right);
                debug_indent_dec();
diff -r aed2e3576bbe -r 862d98818f6a usr.bin/xlint/lint1/ops.def
--- a/usr.bin/xlint/lint1/ops.def       Sat Jun 03 20:41:44 2023 +0000
+++ b/usr.bin/xlint/lint1/ops.def       Sat Jun 03 20:58:00 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ops.def,v 1.29 2022/06/15 18:44:41 rillig Exp $ */
+/*     $NetBSD: ops.def,v 1.30 2023/06/03 20:58:00 rillig Exp $ */
 
 begin_ops()
 
@@ -34,6 +34,11 @@ op(  NOT,    "!",             ,1,1,1, , , ,1,1, , , , 
 op(    COMPL,  "~",             , , , , ,1, , ,1,1, , , , , , , , ,1,1)
 op(    INC,    "++",            , , , , , , , , , , , , , , , , , , , )
 op(    DEC,    "--",            , , , , , , , , , , , , , , , , , , , )
+/*
+ * The '++' and '--' operators are conceptually unary operators, but lint
+ * implements them as binary operators due to the pre-multiplied pointer
+ * arithmetics, see build_prepost_incdec and build_plus_minus.
+ */
 op(    INCBEF, "++x",           , , , , , , ,1, , , , ,1, , , , , ,1, )
 op(    DECBEF, "--x",           , , , , , , ,1, , , , ,1, , , , , ,1, )
 op(    INCAFT, "x++",           , , , , , , ,1, , , , ,1, , , , , ,1, )



Home | Main Index | Thread Index | Old Index