Fri Oct 23 17:59:25 2020 UTC ()
make(1): allow compilation with Boolean implemented as char


(rillig)
diff -r1.160 -r1.161 src/usr.bin/make/make.h
diff -r1.4 -r1.5 src/usr.bin/make/test-variants.sh

cvs diff -r1.160 -r1.161 src/usr.bin/make/make.h (expand / switch to unified diff)

--- src/usr.bin/make/make.h 2020/10/19 23:43:55 1.160
+++ src/usr.bin/make/make.h 2020/10/23 17:59:25 1.161
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: make.h,v 1.160 2020/10/19 23:43:55 rillig Exp $ */ 1/* $NetBSD: make.h,v 1.161 2020/10/23 17:59:25 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1988, 1989, 1990, 1993 4 * Copyright (c) 1988, 1989, 1990, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Adam de Boor. 8 * Adam de Boor.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -134,26 +134,32 @@ @@ -134,26 +134,32 @@
134 * A boolean type is defined as an integer, not an enum, for historic reasons. 134 * A boolean type is defined as an integer, not an enum, for historic reasons.
135 * The only allowed values are the constants TRUE and FALSE (1 and 0). 135 * The only allowed values are the constants TRUE and FALSE (1 and 0).
136 */ 136 */
137 137
138#ifdef USE_DOUBLE_BOOLEAN 138#ifdef USE_DOUBLE_BOOLEAN
139/* During development, to find type mismatches in function declarations. */ 139/* During development, to find type mismatches in function declarations. */
140typedef double Boolean; 140typedef double Boolean;
141#elif defined(USE_UCHAR_BOOLEAN) 141#elif defined(USE_UCHAR_BOOLEAN)
142/* During development, to find code that depends on the exact value of TRUE or 142/* During development, to find code that depends on the exact value of TRUE or
143 * that stores other values in Boolean variables. */ 143 * that stores other values in Boolean variables. */
144typedef unsigned char Boolean; 144typedef unsigned char Boolean;
145#define TRUE ((unsigned char)0xFF) 145#define TRUE ((unsigned char)0xFF)
146#define FALSE ((unsigned char)0x00) 146#define FALSE ((unsigned char)0x00)
 147#elif defined(USE_CHAR_BOOLEAN)
 148/* During development, to find code that uses a boolean as array index, via
 149 * -Wchar-subscripts. */
 150typedef char Boolean;
 151#define TRUE ((char)-1)
 152#define FALSE ((char)0x00)
147#elif defined(USE_ENUM_BOOLEAN) 153#elif defined(USE_ENUM_BOOLEAN)
148typedef enum Boolean { FALSE, TRUE } Boolean; 154typedef enum Boolean { FALSE, TRUE } Boolean;
149#else 155#else
150typedef int Boolean; 156typedef int Boolean;
151#endif 157#endif
152#ifndef TRUE 158#ifndef TRUE
153#define TRUE 1 159#define TRUE 1
154#endif 160#endif
155#ifndef FALSE 161#ifndef FALSE
156#define FALSE 0 162#define FALSE 0
157#endif 163#endif
158 164
159#include "lst.h" 165#include "lst.h"

cvs diff -r1.4 -r1.5 src/usr.bin/make/Attic/test-variants.sh (expand / switch to unified diff)

--- src/usr.bin/make/Attic/test-variants.sh 2020/09/21 04:20:35 1.4
+++ src/usr.bin/make/Attic/test-variants.sh 2020/10/23 17:59:25 1.5
@@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
1#! /bin/sh 1#! /bin/sh
2# $NetBSD: test-variants.sh,v 1.4 2020/09/21 04:20:35 rillig Exp $ 2# $NetBSD: test-variants.sh,v 1.5 2020/10/23 17:59:25 rillig Exp $
3# 3#
4# Build several variants of make and run the tests on them. 4# Build several variants of make and run the tests on them.
5# 5#
6# The output of this test suite must be inspected manuelly to see the 6# The output of this test suite must be inspected manuelly to see the
7# interesting details. The main purpose is to list the available build 7# interesting details. The main purpose is to list the available build
8# options. 8# options.
9 9
10set -eu 10set -eu
11 11
12failed="no" 12failed="no"
13 13
14fail() { 14fail() {
15 echo "failed" 15 echo "failed"
@@ -33,26 +33,30 @@ testcase() { @@ -33,26 +33,30 @@ testcase() {
33testcase # just the plain default options 33testcase # just the plain default options
34 34
35# See whether the Boolean type is only used as a single-bit type. 35# See whether the Boolean type is only used as a single-bit type.
36# By default it is aliased to int, and int is already used for any other 36# By default it is aliased to int, and int is already used for any other
37# purpose. 37# purpose.
38# 38#
39testcase USER_CPPFLAGS="-DUSE_DOUBLE_BOOLEAN" 39testcase USER_CPPFLAGS="-DUSE_DOUBLE_BOOLEAN"
40 40
41# Ensure that variables of type Boolean are not assigned integers. 41# Ensure that variables of type Boolean are not assigned integers.
42# The only valid values are TRUE and FALSE. 42# The only valid values are TRUE and FALSE.
43# 43#
44testcase USER_CPPFLAGS="-DUSE_UCHAR_BOOLEAN" 44testcase USER_CPPFLAGS="-DUSE_UCHAR_BOOLEAN"
45 45
 46# Ensure that variables of type Boolean are not used as array index.
 47#
 48testcase USER_CPPFLAGS="-DUSE_CHAR_BOOLEAN"
 49
46# Try a different compiler, with slightly different warnings and error 50# Try a different compiler, with slightly different warnings and error
47# messages. One feature that is missing from GCC is a little stricter 51# messages. One feature that is missing from GCC is a little stricter
48# checks for enums. 52# checks for enums.
49# 53#
50testcase HAVE_LLVM="yes" 54testcase HAVE_LLVM="yes"
51 55
52testcase USE_GCC8="yes" 56testcase USE_GCC8="yes"
53 57
54testcase USE_GCC9="yes" 58testcase USE_GCC9="yes"
55 59
56testcase USE_GCC10="yes" GCC10BASE="$HOME/pkg/gcc10" 60testcase USE_GCC10="yes" GCC10BASE="$HOME/pkg/gcc10"
57 61
58# for selecting emalloc 62# for selecting emalloc