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: rename xsign to convert_integer



details:   https://anonhg.NetBSD.org/src/rev/fe35277e8052
branches:  trunk
changeset: 379980:fe35277e8052
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Jun 29 21:16:54 2021 +0000

description:
lint: rename xsign to convert_integer

The term sign-extend was too specific, the function actually does a
broader conversion.

No functional change.

diffstat:

 usr.bin/xlint/lint1/externs1.h |   4 ++--
 usr.bin/xlint/lint1/lex.c      |  10 +++++-----
 usr.bin/xlint/lint1/tree.c     |  15 +++++----------
 3 files changed, 12 insertions(+), 17 deletions(-)

diffs (109 lines):

diff -r fe6f91531eb4 -r fe35277e8052 usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h    Tue Jun 29 21:05:32 2021 +0000
+++ b/usr.bin/xlint/lint1/externs1.h    Tue Jun 29 21:16:54 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: externs1.h,v 1.113 2021/06/28 08:52:55 rillig Exp $    */
+/*     $NetBSD: externs1.h,v 1.114 2021/06/29 21:16:54 rillig Exp $    */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -78,7 +78,7 @@ extern        FILE    *yyin;
 
 extern void    initscan(void);
 extern int     msb(int64_t, tspec_t, int);
-extern int64_t xsign(int64_t, tspec_t, int);
+extern int64_t convert_integer(int64_t, tspec_t, int);
 extern void    clear_warn_flags(void);
 extern sym_t   *getsym(sbuf_t *);
 extern void    cleanup(void);
diff -r fe6f91531eb4 -r fe35277e8052 usr.bin/xlint/lint1/lex.c
--- a/usr.bin/xlint/lint1/lex.c Tue Jun 29 21:05:32 2021 +0000
+++ b/usr.bin/xlint/lint1/lex.c Tue Jun 29 21:16:54 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.48 2021/06/29 13:48:24 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.49 2021/06/29 21:16:54 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: lex.c,v 1.48 2021/06/29 13:48:24 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.49 2021/06/29 21:16:54 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -668,7 +668,7 @@ lex_integer_constant(const char *yytext,
                break;
        }
 
-       uq = (uint64_t)xsign((int64_t)uq, typ, -1);
+       uq = (uint64_t)convert_integer((int64_t)uq, typ, -1);
 
        yylval.y_val = xcalloc(1, sizeof(*yylval.y_val));
        yylval.y_val->v_tspec = typ;
@@ -703,10 +703,10 @@ msb(int64_t q, tspec_t t, int len)
 }
 
 /*
- * Extends the sign of q.
+ * Extend or truncate q to match t.  If t is signed, sign-extend.
  */
 int64_t
-xsign(int64_t q, tspec_t t, int len)
+convert_integer(int64_t q, tspec_t t, int len)
 {
        uint64_t vbits;
 
diff -r fe6f91531eb4 -r fe35277e8052 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c        Tue Jun 29 21:05:32 2021 +0000
+++ b/usr.bin/xlint/lint1/tree.c        Tue Jun 29 21:16:54 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tree.c,v 1.297 2021/06/29 20:44:38 rillig Exp $        */
+/*     $NetBSD: tree.c,v 1.298 2021/06/29 21:16:54 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.297 2021/06/29 20:44:38 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.298 2021/06/29 21:16:54 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -2402,13 +2402,8 @@ convert_constant(op_t op, int arg, const
        }
 
        if (is_integer(nt)) {
-               /*
-                * FIXME: There must be no sign extension when converting
-                *  from int to char on a platform where char == unsigned
-                *  char.  See test lex_char_uchar.c.
-                */
                sz = tp->t_bitfield ? tp->t_flen : size_in_bits(nt);
-               nv->v_quad = xsign(nv->v_quad, nt, sz);
+               nv->v_quad = convert_integer(nv->v_quad, nt, sz);
        }
 
        if (range_check && op != CVT)
@@ -3027,7 +3022,7 @@ fold(tnode_t *tn)
                 * shifts of signed values are implementation dependent.
                 */
                q = ul >> sr;
-               q = xsign(q, t, size_in_bits(t) - (int)sr);
+               q = convert_integer(q, t, size_in_bits(t) - (int)sr);
                break;
        case LT:
                q = (utyp ? ul < ur : sl < sr) ? 1 : 0;
@@ -3068,7 +3063,7 @@ fold(tnode_t *tn)
                        warning(141, op_name(tn->tn_op));
        }
 
-       v->v_quad = xsign(q, t, -1);
+       v->v_quad = convert_integer(q, t, -1);
 
        cn = expr_new_constant(tn->tn_type, v);
        if (tn->tn_left->tn_system_dependent)



Home | Main Index | Thread Index | Old Index