Module Name:    src
Committed By:   rillig
Date:           Sat Aug 28 15:01:43 UTC 2021

Modified Files:
        src/usr.bin/xlint/lint1: lex.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/usr.bin/xlint/lint1/lex.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/lint1/lex.c
diff -u src/usr.bin/xlint/lint1/lex.c:1.73 src/usr.bin/xlint/lint1/lex.c:1.74
--- src/usr.bin/xlint/lint1/lex.c:1.73	Sat Aug 28 13:29:26 2021
+++ src/usr.bin/xlint/lint1/lex.c	Sat Aug 28 15:01:43 2021
@@ -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 @@ lex_character_constant(void)
 		/* 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;

Reply via email to