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: document usage of 'convert'



details:   https://anonhg.NetBSD.org/src/rev/817482e1f31a
branches:  trunk
changeset: 368278:817482e1f31a
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jul 02 10:41:13 2022 +0000

description:
lint: document usage of 'convert'

No functional change.

diffstat:

 usr.bin/xlint/lint1/tree.c |  16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diffs (51 lines):

diff -r af43a7c49c94 -r 817482e1f31a usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Sat Jul 02 10:23:38 2022 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Sat Jul 02 10:41:13 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.467 2022/07/02 10:23:38 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.468 2022/07/02 10:41:13 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.467 2022/07/02 10:23:38 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.468 2022/07/02 10:41:13 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -2272,7 +2272,15 @@
 /*
  * Insert a conversion operator, which converts the type of the node
  * to another given type.
- * If op is FARG, arg is the number of the argument (used for warnings).
+ *
+ * Possible values for 'op':
+ *     CVT     a cast-expression
+ *     binary  integer promotion for one of the operands, or a usual
+ *             arithmetic conversion
+ *     binary  plain or compound assignments to bit-fields
+ *     FARG    'arg' is the number of the argument (used for warnings)
+ *     NOOP    several other implicit conversions
+ *     ...
  */
 tnode_t *
 convert(op_t op, int arg, type_t *tp, tnode_t *tn)
@@ -3499,6 +3507,7 @@
                        ovfl = true;
                break;
        case SHL:
+               /* TODO: warn against out-of-bounds 'sr'. */
                q = utyp ? (int64_t)(ul << sr) : sl << sr;
                break;
        case SHR:
@@ -3506,6 +3515,7 @@
                 * The sign must be explicitly extended because
                 * shifts of signed values are implementation dependent.
                 */
+               /* TODO: warn against out-of-bounds 'sr'. */
                q = ul >> sr;
                q = convert_integer(q, t, size_in_bits(t) - (int)sr);
                break;



Home | Main Index | Thread Index | Old Index