Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make(1): allow compilation with Boolean impleme...



details:   https://anonhg.NetBSD.org/src/rev/918c2ec03e25
branches:  trunk
changeset: 956177:918c2ec03e25
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Oct 23 17:59:25 2020 +0000

description:
make(1): allow compilation with Boolean implemented as char

diffstat:

 usr.bin/make/make.h           |  8 +++++++-
 usr.bin/make/test-variants.sh |  6 +++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diffs (43 lines):

diff -r 42c5186c019a -r 918c2ec03e25 usr.bin/make/make.h
--- a/usr.bin/make/make.h       Fri Oct 23 17:53:07 2020 +0000
+++ b/usr.bin/make/make.h       Fri Oct 23 17:59:25 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: make.h,v 1.160 2020/10/19 23:43:55 rillig Exp $        */
+/*     $NetBSD: make.h,v 1.161 2020/10/23 17:59:25 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -144,6 +144,12 @@
 typedef unsigned char Boolean;
 #define TRUE ((unsigned char)0xFF)
 #define FALSE ((unsigned char)0x00)
+#elif defined(USE_CHAR_BOOLEAN)
+/* During development, to find code that uses a boolean as array index, via
+ * -Wchar-subscripts. */
+typedef char Boolean;
+#define TRUE ((char)-1)
+#define FALSE ((char)0x00)
 #elif defined(USE_ENUM_BOOLEAN)
 typedef enum Boolean { FALSE, TRUE } Boolean;
 #else
diff -r 42c5186c019a -r 918c2ec03e25 usr.bin/make/test-variants.sh
--- a/usr.bin/make/test-variants.sh     Fri Oct 23 17:53:07 2020 +0000
+++ b/usr.bin/make/test-variants.sh     Fri Oct 23 17:59:25 2020 +0000
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: test-variants.sh,v 1.4 2020/09/21 04:20:35 rillig Exp $
+# $NetBSD: test-variants.sh,v 1.5 2020/10/23 17:59:25 rillig Exp $
 #
 # Build several variants of make and run the tests on them.
 #
@@ -43,6 +43,10 @@
 #
 testcase USER_CPPFLAGS="-DUSE_UCHAR_BOOLEAN"
 
+# Ensure that variables of type Boolean are not used as array index.
+#
+testcase USER_CPPFLAGS="-DUSE_CHAR_BOOLEAN"
+
 # Try a different compiler, with slightly different warnings and error
 # messages.  One feature that is missing from GCC is a little stricter
 # checks for enums.



Home | Main Index | Thread Index | Old Index