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: restructure 'convert'



details:   https://anonhg.NetBSD.org/src/rev/38d659649ce2
branches:  trunk
changeset: 368250:38d659649ce2
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Jul 01 19:52:41 2022 +0000

description:
lint: restructure 'convert'

The conditions are now grouped by target type, highlighting that
conversions between integer and floating point types are not checked by
this function, in fact, they are not checked at all.

No functional change.

diffstat:

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

diffs (66 lines):

diff -r b1d5844e7573 -r 38d659649ce2 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Fri Jul 01 17:48:49 2022 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Fri Jul 01 19:52:41 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.464 2022/07/01 17:48:49 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.465 2022/07/01 19:52:41 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.464 2022/07/01 17:48:49 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.465 2022/07/01 19:52:41 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -2286,14 +2286,29 @@
        if (allow_trad && allow_c90 && op == FARG)
                check_prototype_conversion(arg, nt, ot, tp, tn);
 
-       if (is_integer(nt) && is_integer(ot)) {
-               convert_integer_from_integer(op, arg, nt, ot, tp, tn);
-       } else if (nt == PTR && is_null_pointer(tn)) {
-               /* a null pointer may be assigned to any pointer. */
-       } else if (is_integer(nt) && nt != BOOL && ot == PTR) {
-               convert_integer_from_pointer(op, nt, tp, tn);
-       } else if (nt == PTR && ot == PTR && op == CVT) {
-               convert_pointer_from_pointer(tp, tn);
+       if (nt == BOOL) {
+               /* No further checks. */
+
+       } else if (is_integer(nt)) {
+               if (ot == BOOL) {
+                       /* No further checks. */
+               } else if (is_integer(ot)) {
+                       convert_integer_from_integer(op, arg, nt, ot, tp, tn);
+               } else if (is_floating(ot)) {
+                       /* No further checks. */
+               } else if (ot == PTR) {
+                       convert_integer_from_pointer(op, nt, tp, tn);
+               }
+
+       } else if (is_floating(nt)) {
+               /* No further checks. */
+
+       } else if (nt == PTR) {
+               if (is_null_pointer(tn)) {
+                       /* a null pointer may be assigned to any pointer. */
+               } else if (ot == PTR && op == CVT) {
+                       convert_pointer_from_pointer(tp, tn);
+               }
        }
 
        ntn = expr_alloc_tnode();
@@ -2424,9 +2439,6 @@
        if (op == CVT)
                return;
 
-       if (allow_c99 && nt == BOOL)
-               return;         /* See C99 6.3.1.2 */
-
        if (Pflag && pflag && aflag > 0 &&
            portable_size_in_bits(nt) > portable_size_in_bits(ot) &&
            is_uinteger(nt) != is_uinteger(ot)) {



Home | Main Index | Thread Index | Old Index