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: do not warn about parenthesized as...
details: https://anonhg.NetBSD.org/src/rev/e27f924c52c2
branches: trunk
changeset: 374428:e27f924c52c2
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Apr 22 15:14:37 2023 +0000
description:
lint: do not warn about parenthesized assignment in controlling expr
Same as for GCC and Clang.
diffstat:
tests/usr.bin/xlint/lint1/msg_159.c | 13 +++++++++----
usr.bin/xlint/lint1/tree.c | 6 +++---
2 files changed, 12 insertions(+), 7 deletions(-)
diffs (62 lines):
diff -r ce3c25e40436 -r e27f924c52c2 tests/usr.bin/xlint/lint1/msg_159.c
--- a/tests/usr.bin/xlint/lint1/msg_159.c Sat Apr 22 14:30:54 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_159.c Sat Apr 22 15:14:37 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_159.c,v 1.4 2022/07/06 21:13:13 rillig Exp $ */
+/* $NetBSD: msg_159.c,v 1.5 2023/04/22 15:14:37 rillig Exp $ */
# 3 "msg_159.c"
// Test for message: assignment in conditional context [159]
@@ -12,6 +12,11 @@ example(int a, int b)
if (a == b)
return "comparison, not parenthesized";
+ /*
+ * Clang-Tidy marks a comparison with extra parentheses as an error,
+ * expecting that assignments are parenthesized and comparisons
+ * aren't.
+ */
if ((a == b))
return "comparison, parenthesized";
@@ -27,10 +32,10 @@ example(int a, int b)
return "assignment, not parenthesized";
/*
- * XXX: GCC has the convention that an assignment that is
- * parenthesized is intended as an assignment.
+ * GCC established the convention that an assignment that is
+ * parenthesized is intended as an assignment, so don't warn about
+ * that case.
*/
- /* expect+1: warning: assignment in conditional context [159] */
if ((a = b))
return "assignment, parenthesized";
diff -r ce3c25e40436 -r e27f924c52c2 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c Sat Apr 22 14:30:54 2023 +0000
+++ b/usr.bin/xlint/lint1/tree.c Sat Apr 22 15:14:37 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.514 2023/04/22 09:39:14 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.515 2023/04/22 15:14:37 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: tree.c,v 1.514 2023/04/22 09:39:14 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.515 2023/04/22 15:14:37 rillig Exp $");
#endif
#include <float.h>
@@ -4372,7 +4372,7 @@ expr(tnode_t *tn, bool vctx, bool cond,
check_statement_reachable();
check_expr_misc(tn, vctx, cond, !cond, false, false, false);
- if (tn->tn_op == ASSIGN) {
+ if (tn->tn_op == ASSIGN && !tn->tn_parenthesized) {
if (hflag && cond)
/* assignment in conditional context */
warning(159);
Home |
Main Index |
Thread Index |
Old Index