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: precedence confusion is only possi...



details:   https://anonhg.NetBSD.org/src/rev/96bebb185e7b
branches:  trunk
changeset: 979668:96bebb185e7b
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Jan 04 23:58:19 2021 +0000

description:
lint: precedence confusion is only possible with binary operators

No functional change.

The operator table in ops.def states that every operator that has
possibly confusing precedence is also a binary operator, so assert that
instead of having two different code paths.

diffstat:

 usr.bin/xlint/lint1/op.h   |   4 ++--
 usr.bin/xlint/lint1/tree.c |  21 ++++++++++-----------
 2 files changed, 12 insertions(+), 13 deletions(-)

diffs (75 lines):

diff -r c1a7a537794d -r 96bebb185e7b usr.bin/xlint/lint1/op.h
--- a/usr.bin/xlint/lint1/op.h  Mon Jan 04 23:50:46 2021 +0000
+++ b/usr.bin/xlint/lint1/op.h  Mon Jan 04 23:58:19 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: op.h,v 1.8 2021/01/02 01:06:15 rillig Exp $    */
+/*     $NetBSD: op.h,v 1.9 2021/01/04 23:58:19 rillig Exp $    */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -49,7 +49,7 @@
        bool    m_sideeff : 1;  /* operator has side effect */
        bool    m_tlansiu : 1;  /* warn if left op. is unsign. in ANSI C */
        bool    m_transiu : 1;  /* warn if right op. is unsign. in ANSI C */
-       bool    m_tpconf : 1;   /* test possible precedence confusion */
+       bool    m_possible_precedence_confusion : 1;
        bool    m_comp : 1;     /* operator performs comparison */
        bool    m_valid_on_enum : 1;    /* valid operation on enums */
        bool    m_bad_on_enum : 1;      /* dubious operation on enums */
diff -r c1a7a537794d -r 96bebb185e7b usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Mon Jan 04 23:50:46 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Mon Jan 04 23:58:19 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.132 2021/01/04 23:50:46 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.133 2021/01/04 23:58:19 rillig Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.132 2021/01/04 23:50:46 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.133 2021/01/04 23:58:19 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -608,7 +608,7 @@
                return NULL;
 
        /* Print a warning if precedence confusion is possible */
-       if (mp->m_tpconf)
+       if (mp->m_possible_precedence_confusion)
                check_precedence_confusion(ntn);
 
        /*
@@ -3997,6 +3997,9 @@
                return;
 
        mp = &modtab[tn->tn_op];
+       lint_assert(mp->m_binary);
+
+       dprint_node(tn);
 
        lparn = 0;
        for (ln = tn->tn_left; ln->tn_op == CVT; ln = ln->tn_left)
@@ -4004,15 +4007,11 @@
        lparn |= ln->tn_parenthesized;
        lop = ln->tn_op;
 
-       dprint_node(tn);
-
-       if (mp->m_binary) {
-               rparn = 0;
-               for (rn = tn->tn_right; rn->tn_op == CVT; rn = rn->tn_left)
-                       rparn |= rn->tn_parenthesized;
+       rparn = 0;
+       for (rn = tn->tn_right; rn->tn_op == CVT; rn = rn->tn_left)
                rparn |= rn->tn_parenthesized;
-               rop = rn->tn_op;
-       }
+       rparn |= rn->tn_parenthesized;
+       rop = rn->tn_op;
 
        dowarn = 0;
 



Home | Main Index | Thread Index | Old Index