Module Name: src Committed By: rillig Date: Mon Jan 4 23:58:19 UTC 2021
Modified Files: src/usr.bin/xlint/lint1: op.h tree.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/usr.bin/xlint/lint1/op.h cvs rdiff -u -r1.132 -r1.133 src/usr.bin/xlint/lint1/tree.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/xlint/lint1/op.h diff -u src/usr.bin/xlint/lint1/op.h:1.8 src/usr.bin/xlint/lint1/op.h:1.9 --- src/usr.bin/xlint/lint1/op.h:1.8 Sat Jan 2 01:06:15 2021 +++ src/usr.bin/xlint/lint1/op.h Mon Jan 4 23:58:19 2021 @@ -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 @@ typedef struct { 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 */ Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.132 src/usr.bin/xlint/lint1/tree.c:1.133 --- src/usr.bin/xlint/lint1/tree.c:1.132 Mon Jan 4 23:50:46 2021 +++ src/usr.bin/xlint/lint1/tree.c Mon Jan 4 23:58:19 2021 @@ -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 @@ build(op_t op, tnode_t *ln, tnode_t *rn) 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 @@ check_precedence_confusion(tnode_t *tn) 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 @@ check_precedence_confusion(tnode_t *tn) 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;