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: clean up handling of __real__ and ...



details:   https://anonhg.NetBSD.org/src/rev/b2a709d3073d
branches:  trunk
changeset: 377459:b2a709d3073d
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Jul 12 19:34:01 2023 +0000

description:
lint: clean up handling of __real__ and __imag__

These two operatos are not binary, therefore they don't need a right
operand.  The questionable operands were a copy-and-paste mistake, as
the code was taken from the ++ and -- operands (tree.c 1.46 from
2008-04-25).  The ++ and -- operands aren't binary either, but since
lint represents address calculations in their premultiplied form, the
expression ptr++ contains a hidden right operand specifying the number
of bytes by which to increment the pointer.

Creating an integer-constant-expression node with type 'long double'
didn't make sense either.  Luckily, these expressions are only built but
not analyzed any further.

diffstat:

 usr.bin/xlint/lint1/debug.c |   6 +++---
 usr.bin/xlint/lint1/tree.c  |  17 +++++++----------
 2 files changed, 10 insertions(+), 13 deletions(-)

diffs (78 lines):

diff -r 5ad606bf776b -r b2a709d3073d usr.bin/xlint/lint1/debug.c
--- a/usr.bin/xlint/lint1/debug.c       Wed Jul 12 18:26:04 2023 +0000
+++ b/usr.bin/xlint/lint1/debug.c       Wed Jul 12 19:34:01 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: debug.c,v 1.51 2023/07/12 18:26:04 rillig Exp $ */
+/* $NetBSD: debug.c,v 1.52 2023/07/12 19:34:01 rillig Exp $ */
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: debug.c,v 1.51 2023/07/12 18:26:04 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.52 2023/07/12 19:34:01 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -227,7 +227,7 @@ debug_node(const tnode_t *tn) // NOLINT(
                debug_node(tn->tn_left);
                if (op != INCBEF && op != INCAFT
                    && op != DECBEF && op != DECAFT
-                   && op != CALL && op != PUSH)
+                   && op != CALL && op != ICALL && op != PUSH)
                        lint_assert(is_binary(tn) == (tn->tn_right != NULL));
                if (tn->tn_right != NULL)
                        debug_node(tn->tn_right);
diff -r 5ad606bf776b -r b2a709d3073d usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Wed Jul 12 18:26:04 2023 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Wed Jul 12 19:34:01 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.560 2023/07/10 19:47:12 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.561 2023/07/12 19:34:01 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.560 2023/07/10 19:47:12 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.561 2023/07/12 19:34:01 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -1391,19 +1391,16 @@ build_real_imag(op_t op, bool sys, tnode
                mark_as_set(ln->tn_sym);
        }
 
-       tnode_t *cn;
+       tspec_t t;
        switch (ln->tn_type->t_tspec) {
        case LCOMPLEX:
-               /* XXX: integer and LDOUBLE don't match. */
-               cn = build_integer_constant(LDOUBLE, (int64_t)1);
+               t = LDOUBLE;
                break;
        case DCOMPLEX:
-               /* XXX: integer and DOUBLE don't match. */
-               cn = build_integer_constant(DOUBLE, (int64_t)1);
+               t = DOUBLE;
                break;
        case FCOMPLEX:
-               /* XXX: integer and FLOAT don't match. */
-               cn = build_integer_constant(FLOAT, (int64_t)1);
+               t = FLOAT;
                break;
        default:
                /* '__%s__' is illegal for type '%s' */
@@ -1412,7 +1409,7 @@ build_real_imag(op_t op, bool sys, tnode
                return NULL;
        }
 
-       tnode_t *ntn = new_tnode(op, sys, cn->tn_type, ln, cn);
+       tnode_t *ntn = new_tnode(op, sys, gettyp(t), ln, NULL);
        ntn->tn_lvalue = true;
        return ntn;
 }



Home | Main Index | Thread Index | Old Index