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: fix lexing of character constants



details:   https://anonhg.NetBSD.org/src/rev/4a79e01a446c
branches:  trunk
changeset: 985493:4a79e01a446c
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Aug 28 15:01:43 2021 +0000

description:
lint: fix lexing of character constants

The final value of the character constant must be determined by the
target platform, not the host platform.

This allows to run the tests for a target platform with different
signedness of characters, by editing targparam.h and t_integration.

Lint is not completely cross-compileable though.  64-bit host platforms
can run lint for 32-bit platforms, but not vice versa, since 32-bit GCC
does not provide 128-bit integer types.

diffstat:

 usr.bin/xlint/lint1/lex.c |  14 ++++----------
 1 files changed, 4 insertions(+), 10 deletions(-)

diffs (35 lines):

diff -r 216b49577387 -r 4a79e01a446c usr.bin/xlint/lint1/lex.c
--- a/usr.bin/xlint/lint1/lex.c Sat Aug 28 14:45:19 2021 +0000
+++ b/usr.bin/xlint/lint1/lex.c Sat Aug 28 15:01:43 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.73 2021/08/28 13:29:26 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.74 2021/08/28 15:01:43 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.73 2021/08/28 13:29:26 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.74 2021/08/28 15:01:43 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -816,14 +816,8 @@
                /* empty character constant */
                error(73);
        }
-       if (n == 1) {
-               /*
-                * XXX: use the target platform's 'char' instead of the
-                *  'char' from the execution environment, to be able to
-                *  run lint for powerpc on x86_64.
-                */
-               val = (char)val;
-       }
+       if (n == 1)
+               val = (int)convert_integer(val, CHAR, CHAR_SIZE);
 
        yylval.y_val = xcalloc(1, sizeof(*yylval.y_val));
        yylval.y_val->v_tspec = INT;



Home | Main Index | Thread Index | Old Index