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: finish the comments in check_prece...



details:   https://anonhg.NetBSD.org/src/rev/e1aec30b5afb
branches:  trunk
changeset: 949207:e1aec30b5afb
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Jan 04 22:41:56 2021 +0000

description:
lint: finish the comments in check_precedence_confusion

diffstat:

 tests/usr.bin/xlint/lint1/msg_169.c |   7 ++++---
 usr.bin/xlint/lint1/tree.c          |  17 +++++++++++++++--
 2 files changed, 19 insertions(+), 5 deletions(-)

diffs (56 lines):

diff -r 9f8d63df0540 -r e1aec30b5afb tests/usr.bin/xlint/lint1/msg_169.c
--- a/tests/usr.bin/xlint/lint1/msg_169.c       Mon Jan 04 22:33:47 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_169.c       Mon Jan 04 22:41:56 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_169.c,v 1.2 2021/01/04 15:52:51 rillig Exp $       */
+/*     $NetBSD: msg_169.c,v 1.3 2021/01/04 22:41:56 rillig Exp $       */
 # 3 "msg_169.c"
 
 // Test for message: precedence confusion possible: parenthesize! [169]
@@ -146,5 +146,6 @@
        ok = a + b * c;
 }
 
-// TODO: add a test with unsigned long instead of unsigned, to demonstrate
-//  that the typo in
+// TODO: add a test with unsigned long instead of unsigned, trying to
+//  demonstrate that the typo in check_precedence_confusion actually has an
+//  effect.
diff -r 9f8d63df0540 -r e1aec30b5afb usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Mon Jan 04 22:33:47 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Mon Jan 04 22:41:56 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.128 2021/01/04 22:33:47 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.129 2021/01/04 22:41:56 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.128 2021/01/04 22:33:47 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.129 2021/01/04 22:41:56 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -4016,6 +4016,19 @@
                 * Before fixing this though, there should be a unit test
                 * that demonstrates an actual change in behavior when this
                 * bug gets fixed.
+                *
+                * Right now, the condition is always false.  To make it true
+                * after fixing the typo, the right-hand operand must be an
+                * explicit cast or an implicit conversion that is
+                * parenthesized.  For the right-hand operand itself, this
+                * would already be done using the line below the loop.
+                *
+                * To make a difference, the right-hand operand must not be
+                * parenthesized, but its indirect cast or conversion must be.
+                *
+                * An implicit conversion is never parenthesized.  Therefore
+                * this must be a cast that is later converted, to build a
+                * chain.
                 */
                for (rn = tn->tn_right; tn->tn_op == CVT; rn = rn->tn_left)
                        rparn |= rn->tn_parenthesized;



Home | Main Index | Thread Index | Old Index