CVS commit: src/usr.bin/xlint/lint1

2021-08-17 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Aug 17 22:29:11 UTC 2021

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

Log Message:
lint: extract suppress_messages from main

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/usr.bin/xlint/lint1/main1.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/main1.c
diff -u src/usr.bin/xlint/lint1/main1.c:1.55 src/usr.bin/xlint/lint1/main1.c:1.56
--- src/usr.bin/xlint/lint1/main1.c:1.55	Tue Aug 17 21:19:02 2021
+++ src/usr.bin/xlint/lint1/main1.c	Tue Aug 17 22:29:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: main1.c,v 1.55 2021/08/17 21:19:02 rillig Exp $	*/
+/*	$NetBSD: main1.c,v 1.56 2021/08/17 22:29:11 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: main1.c,v 1.55 2021/08/17 21:19:02 rillig Exp $");
+__RCSID("$NetBSD: main1.c,v 1.56 2021/08/17 22:29:11 rillig Exp $");
 #endif
 
 #include 
@@ -168,11 +168,28 @@ sigfpe(int s)
 	fpe = 1;
 }
 
+static void
+suppress_messages(char *ids)
+{
+	char *ptr, *end;
+	long id;
+
+	for (ptr = strtok(ids, ","); ptr != NULL; ptr = strtok(NULL, ",")) {
+		errno = 0;
+		id = strtol(ptr, &end, 0);
+		if ((id == TARG_LONG_MIN || id == TARG_LONG_MAX) &&
+		errno == ERANGE)
+			err(1, "invalid error message id '%s'", ptr);
+		if (*end != '\0' || ptr == end || id < 0 || id >= ERR_SETSIZE)
+			errx(1, "invalid error message id '%s'", ptr);
+		ERR_SET(id, &msgset);
+	}
+}
+
 int
 main(int argc, char *argv[])
 {
-	int	c;
-	char	*ptr;
+	int c;
 
 	setprogname(argv[0]);
 
@@ -217,23 +234,7 @@ main(int argc, char *argv[])
 			break;
 
 		case 'X':
-			for (ptr = strtok(optarg, ","); ptr != NULL;
-			ptr = strtok(NULL, ",")) {
-char *eptr;
-long msg;
-
-errno = 0;
-msg = strtol(ptr, &eptr, 0);
-if ((msg == TARG_LONG_MIN || msg == TARG_LONG_MAX) &&
-errno == ERANGE)
-err(1, "invalid error message id '%s'",
-	ptr);
-if (*eptr != '\0' || ptr == eptr || msg < 0 ||
-msg >= ERR_SETSIZE)
-	errx(1, "invalid error message id '%s'",
-	ptr);
-ERR_SET(msg, &msgset);
-			}
+			suppress_messages(optarg);
 			break;
 		default:
 			usage();



CVS commit: src/usr.bin/xlint/lint1

2021-08-17 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Aug 17 21:19:02 UTC 2021

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

Log Message:
lint: sync usage message with reality


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/usr.bin/xlint/lint1/main1.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/main1.c
diff -u src/usr.bin/xlint/lint1/main1.c:1.54 src/usr.bin/xlint/lint1/main1.c:1.55
--- src/usr.bin/xlint/lint1/main1.c:1.54	Tue Aug 17 21:05:34 2021
+++ src/usr.bin/xlint/lint1/main1.c	Tue Aug 17 21:19:02 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: main1.c,v 1.54 2021/08/17 21:05:34 rillig Exp $	*/
+/*	$NetBSD: main1.c,v 1.55 2021/08/17 21:19:02 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: main1.c,v 1.54 2021/08/17 21:05:34 rillig Exp $");
+__RCSID("$NetBSD: main1.c,v 1.55 2021/08/17 21:19:02 rillig Exp $");
 #endif
 
 #include 
@@ -290,9 +290,9 @@ static void __attribute__((noreturn))
 usage(void)
 {
 	(void)fprintf(stderr,
-	"usage: %s [-abcdeghmprstuvwyzFST] [-Ac11] [-X [,]... "
-	"src dest\n",
-	getprogname());
+	"usage: %s [-abceghmprstuvwyzFPST] [-Ac11] [-R old=new]\n"
+	"   %*s [-X [,]...] src dest\n",
+	getprogname(), (int)strlen(getprogname()), "");
 	exit(1);
 }
 



CVS commit: src/usr.bin/xlint/lint1

2021-08-17 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Aug 17 21:05:34 UTC 2021

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

Log Message:
lint: move GCC builtins into gcc_builtins

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/usr.bin/xlint/lint1/main1.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/main1.c
diff -u src/usr.bin/xlint/lint1/main1.c:1.53 src/usr.bin/xlint/lint1/main1.c:1.54
--- src/usr.bin/xlint/lint1/main1.c:1.53	Sun Aug  1 19:11:54 2021
+++ src/usr.bin/xlint/lint1/main1.c	Tue Aug 17 21:05:34 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: main1.c,v 1.53 2021/08/01 19:11:54 rillig Exp $	*/
+/*	$NetBSD: main1.c,v 1.54 2021/08/17 21:05:34 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: main1.c,v 1.53 2021/08/01 19:11:54 rillig Exp $");
+__RCSID("$NetBSD: main1.c,v 1.54 2021/08/17 21:05:34 rillig Exp $");
 #endif
 
 #include 
@@ -130,16 +130,15 @@ sig_atomic_t fpe;
 
 static	void	usage(void);
 
-static const char builtins[] =
-"int __builtin_isinf(long double);\n"
-"int __builtin_isnan(long double);\n"
-"int __builtin_copysign(long double, long double);\n"
-;
-static const size_t builtinlen = sizeof(builtins) - 1;
-
 static FILE *
 gcc_builtins(void)
 {
+	static const char builtins[] =
+	"int __builtin_isinf(long double);\n"
+	"int __builtin_isnan(long double);\n"
+	"int __builtin_copysign(long double, long double);\n";
+	size_t builtins_len = sizeof(builtins) - 1;
+
 #if HAVE_NBTOOL_CONFIG_H
 	char template[] = "/tmp/lint.XX";
 	int fd;
@@ -151,14 +150,14 @@ gcc_builtins(void)
 		close(fd);
 		return NULL;
 	}
-	if (fwrite(builtins, 1, builtinlen, fp) != builtinlen) {
+	if (fwrite(builtins, 1, builtins_len, fp) != builtins_len) {
 		fclose(fp);
 		return NULL;
 	}
 	rewind(fp);
 	return fp;
 #else
-	return fmemopen(__UNCONST(builtins), builtinlen, "r");
+	return fmemopen(__UNCONST(builtins), builtins_len, "r");
 #endif
 }
 



CVS commit: src/tests/usr.bin/xlint/lint1

2021-08-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Aug 16 20:27:31 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: expr_promote.c expr_promote.exp-ln
expr_promote_trad.c expr_promote_trad.exp-ln

Log Message:
tests/lint: test default argument promotion with enum


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/expr_promote.c \
src/tests/usr.bin/xlint/lint1/expr_promote.exp-ln \
src/tests/usr.bin/xlint/lint1/expr_promote_trad.c \
src/tests/usr.bin/xlint/lint1/expr_promote_trad.exp-ln

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/expr_promote.c
diff -u src/tests/usr.bin/xlint/lint1/expr_promote.c:1.1 src/tests/usr.bin/xlint/lint1/expr_promote.c:1.2
--- src/tests/usr.bin/xlint/lint1/expr_promote.c:1.1	Mon Aug 16 20:11:03 2021
+++ src/tests/usr.bin/xlint/lint1/expr_promote.c	Mon Aug 16 20:27:31 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: expr_promote.c,v 1.1 2021/08/16 20:11:03 rillig Exp $	*/
+/*	$NetBSD: expr_promote.c,v 1.2 2021/08/16 20:27:31 rillig Exp $	*/
 # 3 "expr_promote.c"
 
 /*
@@ -28,6 +28,9 @@ struct arithmetic_types {
 	float _Complex float_complex;
 	double _Complex double_complex;
 	long double _Complex long_double_complex;
+	enum {
+		E
+	} enumerator;
 };
 
 void
@@ -51,7 +54,15 @@ caller(struct arithmetic_types *arg)
 	arg->long_floating,
 	arg->float_complex,
 	arg->double_complex,
-	arg->long_double_complex);
+	arg->long_double_complex,
+	arg->enumerator);
 }
 
-/* XXX: _Bool is not promoted but should. */
+/*
+ * XXX: _Bool should be promoted to 'int', C99 6.3.1.1p2 "If an int can
+ * represent ...".
+ */
+/*
+ * XXX: Enumerations may need be promoted to 'int', at least C99 6.3.1.1p2
+ * suggests that: "If an int can represent ...".
+ */
Index: src/tests/usr.bin/xlint/lint1/expr_promote.exp-ln
diff -u src/tests/usr.bin/xlint/lint1/expr_promote.exp-ln:1.1 src/tests/usr.bin/xlint/lint1/expr_promote.exp-ln:1.2
--- src/tests/usr.bin/xlint/lint1/expr_promote.exp-ln:1.1	Mon Aug 16 20:11:03 2021
+++ src/tests/usr.bin/xlint/lint1/expr_promote.exp-ln	Mon Aug 16 20:27:31 2021
@@ -1,5 +1,5 @@
 0sexpr_promote.c
 Sexpr_promote.c
 10d0.10e4sinkF2PcCEV
-54c0.54i4sinkf19PcCBIIuILuLQuQDDlDsXXlXV
-34d0.34d6callerF1PsT116arithmetic_typesV
+58c0.58i4sinkf20PcCBIIuILuLQuQDDlDsXXlXeT331.0.0V
+37d0.37d6callerF1PsT116arithmetic_typesV
Index: src/tests/usr.bin/xlint/lint1/expr_promote_trad.c
diff -u src/tests/usr.bin/xlint/lint1/expr_promote_trad.c:1.1 src/tests/usr.bin/xlint/lint1/expr_promote_trad.c:1.2
--- src/tests/usr.bin/xlint/lint1/expr_promote_trad.c:1.1	Mon Aug 16 20:11:03 2021
+++ src/tests/usr.bin/xlint/lint1/expr_promote_trad.c	Mon Aug 16 20:27:31 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: expr_promote_trad.c,v 1.1 2021/08/16 20:11:03 rillig Exp $	*/
+/*	$NetBSD: expr_promote_trad.c,v 1.2 2021/08/16 20:27:31 rillig Exp $	*/
 # 3 "expr_promote_trad.c"
 
 /*
@@ -27,6 +27,9 @@ struct arithmetic_types {
 	double double_floating;
 	/* long double is not available in traditional C */
 	/* _Complex is not available in traditional C */
+	enum {
+		E
+	} enumerator;
 };
 
 caller(arg)
@@ -42,5 +45,11 @@ caller(arg)
 	arg->signed_long,
 	arg->unsigned_long,
 	arg->single_floating,	/* gets promoted to 'double' */
-	arg->double_floating);
+	arg->double_floating,
+	arg->enumerator);
 }
+
+/*
+ * XXX: Enumerations may need be promoted to 'int', at least C99 6.3.1.1p2
+ * suggests that: "If an int can represent ...".
+ */
Index: src/tests/usr.bin/xlint/lint1/expr_promote_trad.exp-ln
diff -u src/tests/usr.bin/xlint/lint1/expr_promote_trad.exp-ln:1.1 src/tests/usr.bin/xlint/lint1/expr_promote_trad.exp-ln:1.2
--- src/tests/usr.bin/xlint/lint1/expr_promote_trad.exp-ln:1.1	Mon Aug 16 20:11:03 2021
+++ src/tests/usr.bin/xlint/lint1/expr_promote_trad.exp-ln	Mon Aug 16 20:27:31 2021
@@ -1,5 +1,5 @@
 0sexpr_promote_trad.c
 Sexpr_promote_trad.c
 10d0.10e4sinkFI
-45c0.45s1""i4sinkf11PCIuIIuIIuILuLDDI
-32d0.32do6callerf1PsT116arithmetic_typesI
+49c0.49s1""i4sinkf12PCIuIIuIIuILuLDDeT330.0.0I
+35d0.35do6callerf1PsT116arithmetic_typesI



CVS commit: src

2021-08-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Aug 16 20:11:03 UTC 2021

Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/usr.bin/xlint/lint1: Makefile msg_241.c msg_277.c msg_277.exp
Added Files:
src/tests/usr.bin/xlint/lint1: expr_promote.c expr_promote.exp-ln
expr_promote_trad.c expr_promote_trad.exp-ln

Log Message:
tests/lint: test arithmetic promotions and enums


To generate a diff of this commit:
cvs rdiff -u -r1. -r1.1112 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.103 -r1.104 src/tests/usr.bin/xlint/lint1/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint1/expr_promote.c \
src/tests/usr.bin/xlint/lint1/expr_promote.exp-ln \
src/tests/usr.bin/xlint/lint1/expr_promote_trad.c \
src/tests/usr.bin/xlint/lint1/expr_promote_trad.exp-ln
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_241.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_277.c
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_277.exp

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1. src/distrib/sets/lists/tests/mi:1.1112
--- src/distrib/sets/lists/tests/mi:1.	Thu Aug 12 15:06:39 2021
+++ src/distrib/sets/lists/tests/mi	Mon Aug 16 20:11:03 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1. 2021/08/12 15:06:39 martin Exp $
+# $NetBSD: mi,v 1.1112 2021/08/16 20:11:03 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -6249,6 +6249,10 @@
 ./usr/tests/usr.bin/xlint/lint1/expr_cast.exp			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/expr_precedence.c		tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/expr_precedence.exp		tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/expr_promote.c			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/expr_promote.exp-ln		tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/expr_promote_trad.c		tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/expr_promote_trad.exp-ln	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/expr_range.c			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/expr_range.exp			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/feat_stacktrace.c		tests-usr.bin-tests	compattestfile,atf

Index: src/tests/usr.bin/xlint/lint1/Makefile
diff -u src/tests/usr.bin/xlint/lint1/Makefile:1.103 src/tests/usr.bin/xlint/lint1/Makefile:1.104
--- src/tests/usr.bin/xlint/lint1/Makefile:1.103	Mon Aug  9 20:07:24 2021
+++ src/tests/usr.bin/xlint/lint1/Makefile	Mon Aug 16 20:11:03 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.103 2021/08/09 20:07:24 rillig Exp $
+# $NetBSD: Makefile,v 1.104 2021/08/16 20:11:03 rillig Exp $
 
 NOMAN=		# defined
 MAX_MESSAGE=	346		# see lint1/err.c
@@ -141,6 +141,10 @@ FILES+=		expr_cast.c
 FILES+=		expr_cast.exp
 FILES+=		expr_precedence.c
 FILES+=		expr_precedence.exp
+FILES+=		expr_promote.c
+FILES+=		expr_promote.exp-ln
+FILES+=		expr_promote_trad.c
+FILES+=		expr_promote_trad.exp-ln
 FILES+=		expr_range.c
 FILES+=		expr_range.exp
 FILES+=		feat_stacktrace.c

Index: src/tests/usr.bin/xlint/lint1/msg_241.c
diff -u src/tests/usr.bin/xlint/lint1/msg_241.c:1.5 src/tests/usr.bin/xlint/lint1/msg_241.c:1.6
--- src/tests/usr.bin/xlint/lint1/msg_241.c:1.5	Mon Aug 16 18:51:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_241.c	Mon Aug 16 20:11:03 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_241.c,v 1.5 2021/08/16 18:51:58 rillig Exp $	*/
+/*	$NetBSD: msg_241.c,v 1.6 2021/08/16 20:11:03 rillig Exp $	*/
 # 3 "msg_241.c"
 
 // Test for message: dubious operation on enum, op %s [241]
@@ -82,3 +82,15 @@ cover_typeok_enum(enum color c, int i)
 	if (c * i > 5)
 		return;
 }
+
+const char *
+color_name(enum color c)
+{
+	static const char *name[] = { "red", "green", "blue" };
+
+	if (c == RED)
+		return *(c + name); /* unusual but allowed */
+	if (c == GREEN)
+		return c[name]; /* even more unusual */
+	return name[c];
+}

Index: src/tests/usr.bin/xlint/lint1/msg_277.c
diff -u src/tests/usr.bin/xlint/lint1/msg_277.c:1.4 src/tests/usr.bin/xlint/lint1/msg_277.c:1.5
--- src/tests/usr.bin/xlint/lint1/msg_277.c:1.4	Sat Feb 27 18:01:29 2021
+++ src/tests/usr.bin/xlint/lint1/msg_277.c	Mon Aug 16 20:11:03 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_277.c,v 1.4 2021/02/27 18:01:29 rillig Exp $	*/
+/*	$NetBSD: msg_277.c,v 1.5 2021/08/16 20:11:03 rillig Exp $	*/
 # 3 "msg_277.c"
 
 // Test for message: initialization of '%s' with '%s' [277]
@@ -24,4 +24,8 @@ example(enum E e, int i)
 	sink_enum(e3);
 	sink_int(i2);
 	sink_int(i3);
+
+	enum E init_0 = 0;
+	/* expect+1: warning: initialization of 'enum E' with 'int' [277] */
+	enum E init_1 = 1;
 }

Index: src/tests/usr.bin/xlint/lint1/msg_277.exp
d

CVS commit: src/tests/usr.bin/xlint/lint1

2021-08-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Aug 16 18:51:58 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_123.c msg_123.exp msg_182.c
msg_182.exp msg_211.c msg_211.exp msg_241.c msg_241.exp msg_303.c
msg_303.exp msg_304.c msg_304.exp msg_305.c msg_305.exp msg_346.c
msg_346.exp

Log Message:
tests/lint: add tests for several messages about type mismatch


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_123.c \
src/tests/usr.bin/xlint/lint1/msg_182.c \
src/tests/usr.bin/xlint/lint1/msg_182.exp \
src/tests/usr.bin/xlint/lint1/msg_211.c \
src/tests/usr.bin/xlint/lint1/msg_211.exp \
src/tests/usr.bin/xlint/lint1/msg_303.c \
src/tests/usr.bin/xlint/lint1/msg_303.exp \
src/tests/usr.bin/xlint/lint1/msg_304.c \
src/tests/usr.bin/xlint/lint1/msg_304.exp \
src/tests/usr.bin/xlint/lint1/msg_305.c \
src/tests/usr.bin/xlint/lint1/msg_305.exp
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_123.exp \
src/tests/usr.bin/xlint/lint1/msg_241.exp \
src/tests/usr.bin/xlint/lint1/msg_346.c \
src/tests/usr.bin/xlint/lint1/msg_346.exp
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_241.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_123.c
diff -u src/tests/usr.bin/xlint/lint1/msg_123.c:1.2 src/tests/usr.bin/xlint/lint1/msg_123.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_123.c:1.2	Sun Jan 17 16:00:16 2021
+++ src/tests/usr.bin/xlint/lint1/msg_123.c	Mon Aug 16 18:51:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_123.c,v 1.2 2021/01/17 16:00:16 rillig Exp $	*/
+/*	$NetBSD: msg_123.c,v 1.3 2021/08/16 18:51:58 rillig Exp $	*/
 # 3 "msg_123.c"
 
 // Test for message: illegal combination of %s (%s) and %s (%s), op %s [123]
@@ -26,3 +26,12 @@ compare(_Bool b, int i, double d, const 
 	bad(p < d);		/* expect: 107 */
 	ok(p < p);
 }
+
+void
+cover_check_assign_types_compatible(int *int_pointer, int i)
+{
+	/* expect+1: warning: illegal combination of pointer (pointer to int) and integer (int), op = [123] */
+	int_pointer = i;
+	/* expect+1: warning: illegal combination of integer (int) and pointer (pointer to int), op = [123] */
+	i = int_pointer;
+}
Index: src/tests/usr.bin/xlint/lint1/msg_182.c
diff -u src/tests/usr.bin/xlint/lint1/msg_182.c:1.2 src/tests/usr.bin/xlint/lint1/msg_182.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_182.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_182.c	Mon Aug 16 18:51:58 2021
@@ -1,7 +1,18 @@
-/*	$NetBSD: msg_182.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_182.c,v 1.3 2021/08/16 18:51:58 rillig Exp $	*/
 # 3 "msg_182.c"
 
 // Test for message: incompatible pointer types (%s != %s) [182]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+void *
+return_discarding_volatile(volatile void *arg)
+{
+	/* expect+1: warning: incompatible pointer types (void != volatile void) [182] */
+	return arg;
+}
+
+void
+init_discarding_volatile(volatile void *arg)
+{
+	/* expect+1: warning: incompatible pointer types (void != volatile void) [182] */
+	void *array[] = { arg };
+}
Index: src/tests/usr.bin/xlint/lint1/msg_182.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_182.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_182.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_182.exp:1.2	Sun Mar 21 20:45:00 2021
+++ src/tests/usr.bin/xlint/lint1/msg_182.exp	Mon Aug 16 18:51:58 2021
@@ -1 +1,2 @@
-msg_182.c(6): error: syntax error ':' [249]
+msg_182.c(10): warning: incompatible pointer types (void != volatile void) [182]
+msg_182.c(17): warning: incompatible pointer types (void != volatile void) [182]
Index: src/tests/usr.bin/xlint/lint1/msg_211.c
diff -u src/tests/usr.bin/xlint/lint1/msg_211.c:1.2 src/tests/usr.bin/xlint/lint1/msg_211.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_211.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_211.c	Mon Aug 16 18:51:58 2021
@@ -1,7 +1,22 @@
-/*	$NetBSD: msg_211.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_211.c,v 1.3 2021/08/16 18:51:58 rillig Exp $	*/
 # 3 "msg_211.c"
 
 // Test for message: return value type mismatch (%s) and (%s) [211]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+struct str {
+	int member;
+};
+
+int
+return_int(double dbl, void *ptr, struct str str)
+{
+	if (dbl > 0.0)
+		return dbl;
+	if (ptr != (void *)0)
+		/* expect+1: warning: illegal combination of integer (int) and pointer (pointer to void) [183] */
+		return ptr;
+	if (str.member > 0)
+		/* expect+1: error: return value type mismatch (int) and (struct str) [211 */
+		return str;
+	return 3;
+}
Index: src/tests/usr.bin/xlint/lint1/msg_211.exp
diff -

CVS commit: src/usr.bin/xlint/lint1

2021-08-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Aug 16 18:51:03 UTC 2021

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

Log Message:
lint: remove dead code from check_bad_enum_operation

There is a single caller of that function, and it checks the exact same
condition beforehand.


To generate a diff of this commit:
cvs rdiff -u -r1.336 -r1.337 src/usr.bin/xlint/lint1/tree.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/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.336 src/usr.bin/xlint/lint1/tree.c:1.337
--- src/usr.bin/xlint/lint1/tree.c:1.336	Sun Aug 15 14:26:39 2021
+++ src/usr.bin/xlint/lint1/tree.c	Mon Aug 16 18:51:03 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.336 2021/08/15 14:26:39 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.337 2021/08/16 18:51:03 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.336 2021/08/15 14:26:39 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.337 2021/08/16 18:51:03 rillig Exp $");
 #endif
 
 #include 
@@ -1587,11 +1587,6 @@ check_bad_enum_operation(op_t op, const 
 	if (!eflag)
 		return;
 
-	if (!(ln->tn_type->t_is_enum ||
-	  (modtab[op].m_binary && rn->tn_type->t_is_enum))) {
-		return;
-	}
-
 	/*
 	 * Enum as offset to a pointer is an exception (otherwise enums
 	 * could not be used as array indices).
@@ -1604,7 +1599,6 @@ check_bad_enum_operation(op_t op, const 
 
 	/* dubious operation on enum, op %s */
 	warning(241, op_name(op));
-
 }
 
 /*



CVS commit: src/tests/usr.bin/xlint/lint1

2021-08-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Aug 16 16:19:47 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_115.c msg_115.exp

Log Message:
tests/lint: document history of initialization of const members


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/xlint/lint1/msg_115.c
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/msg_115.exp

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_115.c
diff -u src/tests/usr.bin/xlint/lint1/msg_115.c:1.8 src/tests/usr.bin/xlint/lint1/msg_115.c:1.9
--- src/tests/usr.bin/xlint/lint1/msg_115.c:1.8	Sat Aug 14 12:46:24 2021
+++ src/tests/usr.bin/xlint/lint1/msg_115.c	Mon Aug 16 16:19:47 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_115.c,v 1.8 2021/08/14 12:46:24 rillig Exp $	*/
+/*	$NetBSD: msg_115.c,v 1.9 2021/08/16 16:19:47 rillig Exp $	*/
 # 3 "msg_115.c"
 
 // Test for message: %soperand of '%s' must be modifiable lvalue [115]
@@ -14,6 +14,10 @@ example(const int *const_ptr)
 	*const_ptr /= 5;	/* expect: 115 */
 	*const_ptr %= 9;	/* expect: 115 */
 	(*const_ptr)++;		/* expect: 115 */
+
+	/* In the next example, the left operand is not an lvalue at all. */
+	/* expect+1: error: left operand of '=' must be lvalue [114] */
+	(const_ptr + 3) = const_ptr;
 }
 
 typedef struct {
@@ -22,7 +26,15 @@ typedef struct {
 
 void take_const_member(const_member);
 
-/* see typeok_assign, has_constant_member */
+/*
+ * Before init.c 1.208 from 2021-08-14 and decl.c 1.221 from 2021-08-10,
+ * lint issued a wrong "warning: left operand of '%s' must be modifiable
+ * lvalue", even in cases where the left operand was being initialized
+ * instead of overwritten.
+ *
+ * See initialization_expr_using_op, typeok_assign, has_constant_member.
+ * See C99 6.2.5p25.
+ */
 const_member
 initialize_const_struct_member(void)
 {

Index: src/tests/usr.bin/xlint/lint1/msg_115.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_115.exp:1.7 src/tests/usr.bin/xlint/lint1/msg_115.exp:1.8
--- src/tests/usr.bin/xlint/lint1/msg_115.exp:1.7	Sat Aug 14 12:46:24 2021
+++ src/tests/usr.bin/xlint/lint1/msg_115.exp	Mon Aug 16 16:19:47 2021
@@ -5,3 +5,4 @@ msg_115.c(13): warning: left operand of 
 msg_115.c(14): warning: left operand of '/=' must be modifiable lvalue [115]
 msg_115.c(15): warning: left operand of '%=' must be modifiable lvalue [115]
 msg_115.c(16): warning: operand of 'x++' must be modifiable lvalue [115]
+msg_115.c(20): error: left operand of '=' must be lvalue [114]



CVS commit: src

2021-08-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Aug 16 06:49:57 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_046.c msg_046.exp msg_260.c
msg_260.exp
src/usr.bin/xlint/lint1: decl.c err.c

Log Message:
lint: add more details to message about redeclared tag


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_046.c \
src/tests/usr.bin/xlint/lint1/msg_046.exp \
src/tests/usr.bin/xlint/lint1/msg_260.c \
src/tests/usr.bin/xlint/lint1/msg_260.exp
cvs rdiff -u -r1.221 -r1.222 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.136 -r1.137 src/usr.bin/xlint/lint1/err.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_046.c
diff -u src/tests/usr.bin/xlint/lint1/msg_046.c:1.3 src/tests/usr.bin/xlint/lint1/msg_046.c:1.4
--- src/tests/usr.bin/xlint/lint1/msg_046.c:1.3	Mon Aug 16 06:30:43 2021
+++ src/tests/usr.bin/xlint/lint1/msg_046.c	Mon Aug 16 06:49:57 2021
@@ -1,36 +1,36 @@
-/*	$NetBSD: msg_046.c,v 1.3 2021/08/16 06:30:43 rillig Exp $	*/
+/*	$NetBSD: msg_046.c,v 1.4 2021/08/16 06:49:57 rillig Exp $	*/
 # 3 "msg_046.c"
 
-// Test for message: (%s) tag redeclared [46]
+// Test for message: %s tag '%s' redeclared as %s [46]
 
 /* expect+1: warning: struct tag1 never defined [233] */
 struct tag1;
-/* expect+2: error: (struct) tag redeclared [46] */
+/* expect+2: error: struct tag 'tag1' redeclared as union [46] */
 /* expect+1: warning: union tag1 never defined [234] */
 union tag1;
 
 /* expect+1: warning: union tag2 never defined [234] */
 union tag2;
-/* expect+2: error: (union) tag redeclared [46] */
+/* expect+2: error: union tag 'tag2' redeclared as enum [46] */
 /* expect+1: warning: enum tag2 never defined [235] */
 enum tag2;
 
 /* expect+1: warning: enum tag3 never defined [235] */
 enum tag3;
-/* expect+2: error: (enum) tag redeclared [46] */
+/* expect+2: error: enum tag 'tag3' redeclared as struct [46] */
 /* expect+1: warning: struct tag3 never defined [233] */
 struct tag3;
 
-/* expect+2: error: (union) tag redeclared [46] */
+/* expect+2: error: union tag 'tag1' redeclared as struct [46] */
 /* expect+1: warning: struct tag1 never defined [233] */
 struct tag1 *use_tag1(void);
-/* expect+2: error: (enum) tag redeclared [46] */
+/* expect+2: error: enum tag 'tag2' redeclared as union [46] */
 /* expect+1: warning: union tag2 never defined [234] */
 union tag2 *use_tag2(void);
-/* expect+2: error: (struct) tag redeclared [46] */
+/* expect+2: error: struct tag 'tag3' redeclared as enum [46] */
 /* expect+1: warning: enum tag3 never defined [235] */
 enum tag3 *use_tag3(void);
 
-/* expect+2: error: (struct) tag redeclared [46] */
+/* expect+2: error: struct tag 'tag1' redeclared as union [46] */
 /* expect+1: warning: union tag1 never defined [234] */
 union tag1 *mismatch_tag1(void);
Index: src/tests/usr.bin/xlint/lint1/msg_046.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_046.exp:1.3 src/tests/usr.bin/xlint/lint1/msg_046.exp:1.4
--- src/tests/usr.bin/xlint/lint1/msg_046.exp:1.3	Mon Aug 16 06:30:43 2021
+++ src/tests/usr.bin/xlint/lint1/msg_046.exp	Mon Aug 16 06:49:57 2021
@@ -1,10 +1,10 @@
-msg_046.c(10): error: (struct) tag redeclared [46]
-msg_046.c(16): error: (union) tag redeclared [46]
-msg_046.c(22): error: (enum) tag redeclared [46]
-msg_046.c(26): error: (union) tag redeclared [46]
-msg_046.c(29): error: (enum) tag redeclared [46]
-msg_046.c(32): error: (struct) tag redeclared [46]
-msg_046.c(36): error: (struct) tag redeclared [46]
+msg_046.c(10): error: struct tag 'tag1' redeclared as union [46]
+msg_046.c(16): error: union tag 'tag2' redeclared as enum [46]
+msg_046.c(22): error: enum tag 'tag3' redeclared as struct [46]
+msg_046.c(26): error: union tag 'tag1' redeclared as struct [46]
+msg_046.c(29): error: enum tag 'tag2' redeclared as union [46]
+msg_046.c(32): error: struct tag 'tag3' redeclared as enum [46]
+msg_046.c(36): error: struct tag 'tag1' redeclared as union [46]
 msg_046.c(7): warning: struct tag1 never defined [233]
 msg_046.c(10): warning: union tag1 never defined [234]
 msg_046.c(13): warning: union tag2 never defined [234]
Index: src/tests/usr.bin/xlint/lint1/msg_260.c
diff -u src/tests/usr.bin/xlint/lint1/msg_260.c:1.3 src/tests/usr.bin/xlint/lint1/msg_260.c:1.4
--- src/tests/usr.bin/xlint/lint1/msg_260.c:1.3	Sun Apr 18 07:31:47 2021
+++ src/tests/usr.bin/xlint/lint1/msg_260.c	Mon Aug 16 06:49:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_260.c,v 1.3 2021/04/18 07:31:47 rillig Exp $	*/
+/*	$NetBSD: msg_260.c,v 1.4 2021/08/16 06:49:57 rillig Exp $	*/
 # 3 "msg_260.c"
 
 // Test for message: previous declaration of %s [260]
@@ -6,22 +6,26 @@
 /* lint1-extra-flags: -r */
 
 # 100 "header.h" 1
-struct s {		/* expect: 260 */
+/* expect+1: previous declaration of s [260] */
+struct s {
 int member;
 };
-# 13 "msg_260.c" 2
+# 14 "msg_260.c" 2
 
 # 20

CVS commit: src/tests/usr.bin/xlint/lint1

2021-08-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Aug 16 06:30:43 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_046.c msg_046.exp

Log Message:
tests/lint: test message for redeclared tags


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_046.c \
src/tests/usr.bin/xlint/lint1/msg_046.exp

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_046.c
diff -u src/tests/usr.bin/xlint/lint1/msg_046.c:1.2 src/tests/usr.bin/xlint/lint1/msg_046.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_046.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_046.c	Mon Aug 16 06:30:43 2021
@@ -1,7 +1,36 @@
-/*	$NetBSD: msg_046.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_046.c,v 1.3 2021/08/16 06:30:43 rillig Exp $	*/
 # 3 "msg_046.c"
 
 // Test for message: (%s) tag redeclared [46]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* expect+1: warning: struct tag1 never defined [233] */
+struct tag1;
+/* expect+2: error: (struct) tag redeclared [46] */
+/* expect+1: warning: union tag1 never defined [234] */
+union tag1;
+
+/* expect+1: warning: union tag2 never defined [234] */
+union tag2;
+/* expect+2: error: (union) tag redeclared [46] */
+/* expect+1: warning: enum tag2 never defined [235] */
+enum tag2;
+
+/* expect+1: warning: enum tag3 never defined [235] */
+enum tag3;
+/* expect+2: error: (enum) tag redeclared [46] */
+/* expect+1: warning: struct tag3 never defined [233] */
+struct tag3;
+
+/* expect+2: error: (union) tag redeclared [46] */
+/* expect+1: warning: struct tag1 never defined [233] */
+struct tag1 *use_tag1(void);
+/* expect+2: error: (enum) tag redeclared [46] */
+/* expect+1: warning: union tag2 never defined [234] */
+union tag2 *use_tag2(void);
+/* expect+2: error: (struct) tag redeclared [46] */
+/* expect+1: warning: enum tag3 never defined [235] */
+enum tag3 *use_tag3(void);
+
+/* expect+2: error: (struct) tag redeclared [46] */
+/* expect+1: warning: union tag1 never defined [234] */
+union tag1 *mismatch_tag1(void);
Index: src/tests/usr.bin/xlint/lint1/msg_046.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_046.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_046.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_046.exp:1.2	Sun Mar 21 20:44:59 2021
+++ src/tests/usr.bin/xlint/lint1/msg_046.exp	Mon Aug 16 06:30:43 2021
@@ -1 +1,17 @@
-msg_046.c(6): error: syntax error ':' [249]
+msg_046.c(10): error: (struct) tag redeclared [46]
+msg_046.c(16): error: (union) tag redeclared [46]
+msg_046.c(22): error: (enum) tag redeclared [46]
+msg_046.c(26): error: (union) tag redeclared [46]
+msg_046.c(29): error: (enum) tag redeclared [46]
+msg_046.c(32): error: (struct) tag redeclared [46]
+msg_046.c(36): error: (struct) tag redeclared [46]
+msg_046.c(7): warning: struct tag1 never defined [233]
+msg_046.c(10): warning: union tag1 never defined [234]
+msg_046.c(13): warning: union tag2 never defined [234]
+msg_046.c(16): warning: enum tag2 never defined [235]
+msg_046.c(19): warning: enum tag3 never defined [235]
+msg_046.c(22): warning: struct tag3 never defined [233]
+msg_046.c(26): warning: struct tag1 never defined [233]
+msg_046.c(29): warning: union tag2 never defined [234]
+msg_046.c(32): warning: enum tag3 never defined [235]
+msg_046.c(36): warning: union tag1 never defined [234]



CVS commit: src/tests/usr.bin/xlint/lint1

2021-08-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Aug 16 06:24:37 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: accept.sh

Log Message:
tests/lint: remove unintended debugging output


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/accept.sh

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/accept.sh
diff -u src/tests/usr.bin/xlint/lint1/accept.sh:1.6 src/tests/usr.bin/xlint/lint1/accept.sh:1.7
--- src/tests/usr.bin/xlint/lint1/accept.sh:1.6	Mon Aug 16 06:15:51 2021
+++ src/tests/usr.bin/xlint/lint1/accept.sh	Mon Aug 16 06:24:37 2021
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: accept.sh,v 1.6 2021/08/16 06:15:51 rillig Exp $
+# $NetBSD: accept.sh,v 1.7 2021/08/16 06:24:37 rillig Exp $
 #
 # Copyright (c) 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -85,7 +85,6 @@ for pattern in "$@"; do
 msgid=${msgid#msg_0}
 msgid=${msgid#msg_}
 msgid=${msgid%%_*}
-echo "msgid for $base is $msgid"
 if ! grep "\\[$msgid\\]" "$expfile" >/dev/null; then
 	echo "$base should trigger the message '$msgid'"
 fi



CVS commit: src/tests/usr.bin/xlint/lint1

2021-08-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Aug 16 06:15:51 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: accept.sh

Log Message:
tests/lint: fix check for expected message in msg tests


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/accept.sh

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/accept.sh
diff -u src/tests/usr.bin/xlint/lint1/accept.sh:1.5 src/tests/usr.bin/xlint/lint1/accept.sh:1.6
--- src/tests/usr.bin/xlint/lint1/accept.sh:1.5	Sun Aug  8 13:19:51 2021
+++ src/tests/usr.bin/xlint/lint1/accept.sh	Mon Aug 16 06:15:51 2021
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: accept.sh,v 1.5 2021/08/08 13:19:51 rillig Exp $
+# $NetBSD: accept.sh,v 1.6 2021/08/16 06:15:51 rillig Exp $
 #
 # Copyright (c) 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -84,7 +84,8 @@ for pattern in "$@"; do
 msgid=${msgid#msg_00}
 msgid=${msgid#msg_0}
 msgid=${msgid#msg_}
-msgid=${msgid%_*}
+msgid=${msgid%%_*}
+echo "msgid for $base is $msgid"
 if ! grep "\\[$msgid\\]" "$expfile" >/dev/null; then
 	echo "$base should trigger the message '$msgid'"
 fi



CVS commit: src/lib/libedit

2021-08-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug 15 22:22:52 UTC 2021

Modified Files:
src/lib/libedit: readline.c

Log Message:
libedit: simplify calls to macro ADD_STRING

The lint comments CONSTCOND and LINTED were not necessary.  It is
simpler to just specify what to free.  GCC optimizes free(NULL) to be a
no-op.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.161 -r1.162 src/lib/libedit/readline.c

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

Modified files:

Index: src/lib/libedit/readline.c
diff -u src/lib/libedit/readline.c:1.161 src/lib/libedit/readline.c:1.162
--- src/lib/libedit/readline.c:1.161	Sun Aug 15 22:14:45 2021
+++ src/lib/libedit/readline.c	Sun Aug 15 22:22:52 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: readline.c,v 1.161 2021/08/15 22:14:45 rillig Exp $	*/
+/*	$NetBSD: readline.c,v 1.162 2021/08/15 22:22:52 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include "config.h"
 #if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: readline.c,v 1.161 2021/08/15 22:14:45 rillig Exp $");
+__RCSID("$NetBSD: readline.c,v 1.162 2021/08/15 22:22:52 rillig Exp $");
 #endif /* not lint && not SCCSID */
 
 #include 
@@ -951,10 +951,7 @@ history_expand(char *str, char **output)
 			(size += len + 1) * sizeof(*nresult));	\
 			if (nresult == NULL) {\
 el_free(*output);			\
-if (/*CONSTCOND*/fr) {			\
-	/*LINTED*/			\
-	el_free(tmp);			\
-}	\
+el_free(fr);\
 return 0;\
 			}		\
 			result = nresult;\
@@ -1004,11 +1001,11 @@ loop:
 			goto loop;
 		}
 		len = i - start;
-		ADD_STRING(&str[start], len, 0);
+		ADD_STRING(&str[start], len, NULL);
 
 		if (str[i] == '\0' || str[i] != history_expansion_char) {
 			len = j - i;
-			ADD_STRING(&str[i], len, 0);
+			ADD_STRING(&str[i], len, NULL);
 			if (start == 0)
 ret = 0;
 			else
@@ -1018,7 +1015,7 @@ loop:
 		ret = _history_expand_command (str, i, (j - i), &tmp);
 		if (ret > 0 && tmp) {
 			len = strlen(tmp);
-			ADD_STRING(tmp, len, 1);
+			ADD_STRING(tmp, len, tmp);
 		}
 		if (tmp) {
 			el_free(tmp);



CVS commit: src/lib/libedit

2021-08-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug 15 22:14:45 UTC 2021

Modified Files:
src/lib/libedit: readline.c

Log Message:
readline: fix lint warning about effective unconst cast

Calling strchr to avoid the syntactical unconst cast is not necessary
here.  A simple pointer assignment is enough.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.160 -r1.161 src/lib/libedit/readline.c

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

Modified files:

Index: src/lib/libedit/readline.c
diff -u src/lib/libedit/readline.c:1.160 src/lib/libedit/readline.c:1.161
--- src/lib/libedit/readline.c:1.160	Sun Aug 15 10:06:32 2021
+++ src/lib/libedit/readline.c	Sun Aug 15 22:14:45 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: readline.c,v 1.160 2021/08/15 10:06:32 christos Exp $	*/
+/*	$NetBSD: readline.c,v 1.161 2021/08/15 22:14:45 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include "config.h"
 #if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: readline.c,v 1.160 2021/08/15 10:06:32 christos Exp $");
+__RCSID("$NetBSD: readline.c,v 1.161 2021/08/15 22:14:45 rillig Exp $");
 #endif /* not lint && not SCCSID */
 
 #include 
@@ -208,11 +208,10 @@ static void
 _resize_fun(EditLine *el, void *a)
 {
 	const LineInfo *li;
-	char **ap = a;
+	const char **ap = a;
 
 	li = el_line(el);
-	/* a cheesy way to get rid of const cast. */
-	*ap = memchr(li->buffer, *li->buffer, (size_t)1);
+	*ap = li->buffer;
 }
 
 static const char *



CVS commit: src/tests/usr.bin/xlint/lint1

2021-08-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug 15 21:51:56 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_193.c msg_193.exp

Log Message:
tests/lint: correct interpretation of NOTREACHED

The branch is unconditionally taken, therefore any later code is
unreachable as well.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/tests/usr.bin/xlint/lint1/msg_193.c \
src/tests/usr.bin/xlint/lint1/msg_193.exp

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_193.c
diff -u src/tests/usr.bin/xlint/lint1/msg_193.c:1.13 src/tests/usr.bin/xlint/lint1/msg_193.c:1.14
--- src/tests/usr.bin/xlint/lint1/msg_193.c:1.13	Sun Aug 15 21:21:13 2021
+++ src/tests/usr.bin/xlint/lint1/msg_193.c	Sun Aug 15 21:51:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_193.c,v 1.13 2021/08/15 21:21:13 rillig Exp $	*/
+/*	$NetBSD: msg_193.c,v 1.14 2021/08/15 21:51:56 rillig Exp $	*/
 # 3 "msg_193.c"
 
 // Test for message: statement not reached [193]
@@ -645,7 +645,12 @@ lint_annotation_NOTREACHED(void)
 		suppressed();
 	}
 
-	/* FIXME: The 'if' statement _is_ reached. */
+	/*
+	 * Since the condition in the 'if' statement is constant, lint knows
+	 * that the branch is unconditionally taken.  The annotation comment
+	 * marks that branch as not reached, which means that any following
+	 * statement cannot be reached as well.
+	 */
 	/* expect+1: warning: statement not reached [193] */
 	if (1)
 		/* NOTREACHED */
Index: src/tests/usr.bin/xlint/lint1/msg_193.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_193.exp:1.13 src/tests/usr.bin/xlint/lint1/msg_193.exp:1.14
--- src/tests/usr.bin/xlint/lint1/msg_193.exp:1.13	Sun Aug 15 21:21:13 2021
+++ src/tests/usr.bin/xlint/lint1/msg_193.exp	Sun Aug 15 21:51:56 2021
@@ -86,4 +86,4 @@ msg_193.c(580): warning: label 'six' unu
 msg_193.c(597): warning: statement not reached [193]
 msg_193.c(606): warning: statement not reached [193]
 msg_193.c(627): warning: statement not reached [193]
-msg_193.c(650): warning: statement not reached [193]
+msg_193.c(655): warning: statement not reached [193]



CVS commit: src/tests/usr.bin/xlint/lint1

2021-08-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug 15 21:21:14 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_193.c msg_193.exp

Log Message:
tests/lint: test how NOTREACHED affects the unreachable warning

Inspired by lib/libedit/readline.c 1.159 from 2021-08-15.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/tests/usr.bin/xlint/lint1/msg_193.c \
src/tests/usr.bin/xlint/lint1/msg_193.exp

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_193.c
diff -u src/tests/usr.bin/xlint/lint1/msg_193.c:1.12 src/tests/usr.bin/xlint/lint1/msg_193.c:1.13
--- src/tests/usr.bin/xlint/lint1/msg_193.c:1.12	Sun Jul 11 19:30:56 2021
+++ src/tests/usr.bin/xlint/lint1/msg_193.c	Sun Aug 15 21:21:13 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_193.c,v 1.12 2021/07/11 19:30:56 rillig Exp $	*/
+/*	$NetBSD: msg_193.c,v 1.13 2021/08/15 21:21:13 rillig Exp $	*/
 # 3 "msg_193.c"
 
 // Test for message: statement not reached [193]
@@ -616,3 +616,38 @@ reachable:
 /* TODO: switch */
 
 /* TODO: system-dependent constant expression (see tn_system_dependent) */
+
+void suppressed(void);
+
+void
+lint_annotation_NOTREACHED(void)
+{
+	if (0) {
+		/* expect+1: warning: statement not reached [193] */
+		unreachable();
+	}
+
+	if (0) {
+		/* NOTREACHED */
+		suppressed();
+	}
+
+	if (0)
+		/* NOTREACHED */
+		suppressed();
+
+	if (1) {
+		reachable();
+	}
+
+	if (1) {
+		/* NOTREACHED */
+		suppressed();
+	}
+
+	/* FIXME: The 'if' statement _is_ reached. */
+	/* expect+1: warning: statement not reached [193] */
+	if (1)
+		/* NOTREACHED */
+		suppressed();
+}
Index: src/tests/usr.bin/xlint/lint1/msg_193.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_193.exp:1.12 src/tests/usr.bin/xlint/lint1/msg_193.exp:1.13
--- src/tests/usr.bin/xlint/lint1/msg_193.exp:1.12	Sun Jul 11 19:30:56 2021
+++ src/tests/usr.bin/xlint/lint1/msg_193.exp	Sun Aug 15 21:21:13 2021
@@ -85,3 +85,5 @@ msg_193.c(540): warning: statement not r
 msg_193.c(580): warning: label 'six' unused in function 'test_goto_numbers_alphabetically' [232]
 msg_193.c(597): warning: statement not reached [193]
 msg_193.c(606): warning: statement not reached [193]
+msg_193.c(627): warning: statement not reached [193]
+msg_193.c(650): warning: statement not reached [193]



CVS commit: src/lib/libcurses

2021-08-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug 15 15:12:36 UTC 2021

Modified Files:
src/lib/libcurses: get_wstr.c getstr.c in_wchstr.c inchstr.c instr.c
inwstr.c

Log Message:
libcurses: fix usage of __warn_references

Since that macro can expand to an empty token list, it adds its own
semicolon as needed.  Removing the extra semicolon fixes the lint
warnings about empty declarations.  These empty declarations are a GCC
extension.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/lib/libcurses/get_wstr.c \
src/lib/libcurses/in_wchstr.c src/lib/libcurses/inwstr.c
cvs rdiff -u -r1.27 -r1.28 src/lib/libcurses/getstr.c
cvs rdiff -u -r1.10 -r1.11 src/lib/libcurses/inchstr.c
cvs rdiff -u -r1.7 -r1.8 src/lib/libcurses/instr.c

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

Modified files:

Index: src/lib/libcurses/get_wstr.c
diff -u src/lib/libcurses/get_wstr.c:1.8 src/lib/libcurses/get_wstr.c:1.9
--- src/lib/libcurses/get_wstr.c:1.8	Sun Jun  9 07:40:14 2019
+++ src/lib/libcurses/get_wstr.c	Sun Aug 15 15:12:36 2021
@@ -1,4 +1,4 @@
-/*   $NetBSD: get_wstr.c,v 1.8 2019/06/09 07:40:14 blymn Exp $ */
+/*   $NetBSD: get_wstr.c,v 1.9 2021/08/15 15:12:36 rillig Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,7 +36,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: get_wstr.c,v 1.8 2019/06/09 07:40:14 blymn Exp $");
+__RCSID("$NetBSD: get_wstr.c,v 1.9 2021/08/15 15:12:36 rillig Exp $");
 #endif		  /* not lint */
 
 #include "curses.h"
@@ -61,7 +61,7 @@ getn_wstr(wchar_t *wstr, int n)
  *	Get a string from stdscr starting at (cury, curx).
  */
 __warn_references(get_wstr,
-	"warning: this program uses get_wstr(), which is unsafe.");
+	"warning: this program uses get_wstr(), which is unsafe.")
 int
 get_wstr(wchar_t *wstr)
 {
@@ -83,7 +83,7 @@ mvgetn_wstr(int y, int x, wchar_t *wstr,
  *	  Get a string from stdscr starting at (y, x).
  */
 __warn_references(mvget_wstr,
-	"warning: this program uses mvget_wstr(), which is unsafe.");
+	"warning: this program uses mvget_wstr(), which is unsafe.")
 int
 mvget_wstr(int y, int x, wchar_t *wstr)
 {
@@ -109,7 +109,7 @@ mvwgetn_wstr(WINDOW *win, int y, int x, 
  *	  Get a string from the given window starting at (y, x).
  */
 __warn_references(mvget_wstr,
-	"warning: this program uses mvget_wstr(), which is unsafe.");
+	"warning: this program uses mvget_wstr(), which is unsafe.")
 int
 mvwget_wstr(WINDOW *win, int y, int x, wchar_t *wstr)
 {
@@ -124,7 +124,7 @@ mvwget_wstr(WINDOW *win, int y, int x, w
  *	Get a string starting at (cury, curx).
  */
 __warn_references(wget_wstr,
-	"warning: this program uses wget_wstr(), which is unsafe.");
+	"warning: this program uses wget_wstr(), which is unsafe.")
 int
 wget_wstr(WINDOW *win, wchar_t *wstr)
 {
Index: src/lib/libcurses/in_wchstr.c
diff -u src/lib/libcurses/in_wchstr.c:1.8 src/lib/libcurses/in_wchstr.c:1.9
--- src/lib/libcurses/in_wchstr.c:1.8	Sun Jun  9 07:40:14 2019
+++ src/lib/libcurses/in_wchstr.c	Sun Aug 15 15:12:36 2021
@@ -1,4 +1,4 @@
-/*   $NetBSD: in_wchstr.c,v 1.8 2019/06/09 07:40:14 blymn Exp $ */
+/*   $NetBSD: in_wchstr.c,v 1.9 2021/08/15 15:12:36 rillig Exp $ */
 
 /*
  * Copyright (c) 2005 The NetBSD Foundation Inc.
@@ -36,7 +36,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: in_wchstr.c,v 1.8 2019/06/09 07:40:14 blymn Exp $");
+__RCSID("$NetBSD: in_wchstr.c,v 1.9 2021/08/15 15:12:36 rillig Exp $");
 #endif		  /* not lint */
 
 #include "curses.h"
@@ -47,7 +47,7 @@ __RCSID("$NetBSD: in_wchstr.c,v 1.8 2019
  *	Return an array of wide characters at cursor position from stdscr.
  */
 __warn_references(in_wchstr,
-	"warning: this program uses in_wchstr(), which is unsafe.");
+	"warning: this program uses in_wchstr(), which is unsafe.")
 int
 in_wchstr(cchar_t *wchstr)
 {
@@ -65,7 +65,7 @@ in_wchnstr(cchar_t *wchstr, int n)
  *  Return an array of wide characters at position (y, x) from stdscr.
  */
 __warn_references(mvin_wchstr,
-	"warning: this program uses mvin_wchstr(), which is unsafe.");
+	"warning: this program uses mvin_wchstr(), which is unsafe.")
 int
 mvin_wchstr(int y, int x, cchar_t *wchstr)
 {
@@ -83,7 +83,7 @@ mvin_wchnstr(int y, int x, cchar_t *wchs
  *  Return an array wide characters at position (y, x) from the given window.
  */
 __warn_references(mvwin_wchstr,
-	"warning: this program uses mvwin_wchstr(), which is unsafe.");
+	"warning: this program uses mvwin_wchstr(), which is unsafe.")
 int
 mvwin_wchstr(WINDOW *win, int y, int x, cchar_t *wchstr)
 {
@@ -107,7 +107,7 @@ mvwin_wchnstr(WINDOW *win, int y, int x,
  *	Return an array of characters at cursor position.
  */
 __warn_references(win_wchstr,
-	"warning: this program uses win_wchstr(), which is unsafe.");
+	"warning: this program uses win_wchstr(), which is unsafe.")
 int
 win_wchstr(WINDOW *win, cchar_t *wchstr)
 {
Index: src/lib/libcurses/inwstr.c
diff -u src/lib/libcurses/inwstr.c

CVS commit: src

2021-08-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug 15 14:26:40 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_346.c msg_346.exp
src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: extend check for unconst functions

The functions memchr, strpbrk, strrchr and strstr effectively remove the
const qualifier of their first argument, just like strchr.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_346.c \
src/tests/usr.bin/xlint/lint1/msg_346.exp
cvs rdiff -u -r1.335 -r1.336 src/usr.bin/xlint/lint1/tree.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_346.c
diff -u src/tests/usr.bin/xlint/lint1/msg_346.c:1.2 src/tests/usr.bin/xlint/lint1/msg_346.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_346.c:1.2	Sun Aug 15 14:00:27 2021
+++ src/tests/usr.bin/xlint/lint1/msg_346.c	Sun Aug 15 14:26:39 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_346.c,v 1.2 2021/08/15 14:00:27 rillig Exp $	*/
+/*	$NetBSD: msg_346.c,v 1.3 2021/08/15 14:26:39 rillig Exp $	*/
 # 3 "msg_346.c"
 
 // Test for message: call to '%s' effectively discards 'const' from argument [346]
@@ -40,14 +40,14 @@ example(void)
 void
 all_functions(void)
 {
-	/* TODO: expect+1: warning: call to 'memchr' effectively discards 'const' from argument [346] */
+	/* expect+1: warning: call to 'memchr' effectively discards 'const' from argument [346] */
 	take_char_ptr(memchr("string", 'c', 7));
 	/* expect+1: warning: call to 'strchr' effectively discards 'const' from argument [346] */
 	take_char_ptr(strchr("string", 'c'));
-	/* TODO: expect+1: warning: call to 'strpbrk' effectively discards 'const' from argument [346] */
+	/* expect+1: warning: call to 'strpbrk' effectively discards 'const' from argument [346] */
 	take_char_ptr(strpbrk("string", "c"));
-	/* TODO: expect+1: warning: call to 'strrchr' effectively discards 'const' from argument [346] */
+	/* expect+1: warning: call to 'strrchr' effectively discards 'const' from argument [346] */
 	take_char_ptr(strrchr("string", 'c'));
-	/* TODO: expect+1: warning: call to 'strstr' effectively discards 'const' from argument [346] */
+	/* expect+1: warning: call to 'strstr' effectively discards 'const' from argument [346] */
 	take_char_ptr(strstr("string", "c"));
 }
Index: src/tests/usr.bin/xlint/lint1/msg_346.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_346.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_346.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_346.exp:1.2	Sun Aug 15 14:00:27 2021
+++ src/tests/usr.bin/xlint/lint1/msg_346.exp	Sun Aug 15 14:26:39 2021
@@ -1,4 +1,8 @@
 msg_346.c(26): warning: call to 'strchr' effectively discards 'const' from argument [346]
 msg_346.c(32): warning: call to 'strchr' effectively discards 'const' from argument [346]
 msg_346.c(37): warning: call to 'strchr' effectively discards 'const' from argument [346]
+msg_346.c(44): warning: call to 'memchr' effectively discards 'const' from argument [346]
 msg_346.c(46): warning: call to 'strchr' effectively discards 'const' from argument [346]
+msg_346.c(48): warning: call to 'strpbrk' effectively discards 'const' from argument [346]
+msg_346.c(50): warning: call to 'strrchr' effectively discards 'const' from argument [346]
+msg_346.c(52): warning: call to 'strstr' effectively discards 'const' from argument [346]

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.335 src/usr.bin/xlint/lint1/tree.c:1.336
--- src/usr.bin/xlint/lint1/tree.c:1.335	Sun Aug 15 13:08:19 2021
+++ src/usr.bin/xlint/lint1/tree.c	Sun Aug 15 14:26:39 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.335 2021/08/15 13:08:19 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.336 2021/08/15 14:26:39 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.335 2021/08/15 13:08:19 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.336 2021/08/15 14:26:39 rillig Exp $");
 #endif
 
 #include 
@@ -1349,12 +1349,27 @@ check_pointer_comparison(op_t op, const 
 }
 
 static bool
-is_direct_function_call(const tnode_t *tn, const char *name)
+is_direct_function_call(const tnode_t *tn, const char **out_name)
 {
-	return tn->tn_op == CALL &&
-	   tn->tn_left->tn_op == ADDR &&
-	   tn->tn_left->tn_left->tn_op == NAME &&
-	   strcmp(tn->tn_left->tn_left->tn_sym->s_name, name) == 0;
+
+	if (!(tn->tn_op == CALL &&
+	  tn->tn_left->tn_op == ADDR &&
+	  tn->tn_left->tn_left->tn_op == NAME))
+		return false;
+
+	*out_name = tn->tn_left->tn_left->tn_sym->s_name;
+	return true;
+}
+
+static bool
+is_unconst_function(const char *name)
+{
+
+	return strcmp(name, "memchr") == 0 ||
+	   strcmp(name, "strchr") == 0 ||
+	   strcmp(name, "strpbrk") == 0 ||
+	   strcmp(name, "strrchr") == 0 ||
+	   strcmp(name, "strstr") == 0;
 }
 
 static bool
@@ -

CVS commit: src/tests/usr.bin/xlint/lint1

2021-08-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug 15 14:00:27 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_346.c msg_346.exp

Log Message:
tests/lint: add tests for more unconst functions


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_346.c \
src/tests/usr.bin/xlint/lint1/msg_346.exp

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_346.c
diff -u src/tests/usr.bin/xlint/lint1/msg_346.c:1.1 src/tests/usr.bin/xlint/lint1/msg_346.c:1.2
--- src/tests/usr.bin/xlint/lint1/msg_346.c:1.1	Mon Aug  9 20:07:24 2021
+++ src/tests/usr.bin/xlint/lint1/msg_346.c	Sun Aug 15 14:00:27 2021
@@ -1,9 +1,15 @@
-/*	$NetBSD: msg_346.c,v 1.1 2021/08/09 20:07:24 rillig Exp $	*/
+/*	$NetBSD: msg_346.c,v 1.2 2021/08/15 14:00:27 rillig Exp $	*/
 # 3 "msg_346.c"
 
 // Test for message: call to '%s' effectively discards 'const' from argument [346]
 
-char *strchr(const char *, int);
+typedef unsigned long size_t;
+
+void* memchr(const void *, int, size_t);		/* C99 7.21.5.1 */
+char *strchr(const char *, int);			/* C99 7.21.5.2 */
+char* strpbrk(const char *, const char *);		/* C99 7.21.5.4 */
+char* strrchr(const char *, int);			/* C99 7.21.5.5 */
+char* strstr(const char *, const char *);		/* C99 7.21.5.7 */
 
 void take_const_char_ptr(const char *);
 void take_char_ptr(char *);
@@ -30,3 +36,18 @@ example(void)
 	/* expect+1: warning: call to 'strchr' effectively discards 'const' from argument [346] */
 	take_char_ptr(strchr("literal", 'c'));
 }
+
+void
+all_functions(void)
+{
+	/* TODO: expect+1: warning: call to 'memchr' effectively discards 'const' from argument [346] */
+	take_char_ptr(memchr("string", 'c', 7));
+	/* expect+1: warning: call to 'strchr' effectively discards 'const' from argument [346] */
+	take_char_ptr(strchr("string", 'c'));
+	/* TODO: expect+1: warning: call to 'strpbrk' effectively discards 'const' from argument [346] */
+	take_char_ptr(strpbrk("string", "c"));
+	/* TODO: expect+1: warning: call to 'strrchr' effectively discards 'const' from argument [346] */
+	take_char_ptr(strrchr("string", 'c'));
+	/* TODO: expect+1: warning: call to 'strstr' effectively discards 'const' from argument [346] */
+	take_char_ptr(strstr("string", "c"));
+}
Index: src/tests/usr.bin/xlint/lint1/msg_346.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_346.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_346.exp:1.2
--- src/tests/usr.bin/xlint/lint1/msg_346.exp:1.1	Mon Aug  9 20:07:24 2021
+++ src/tests/usr.bin/xlint/lint1/msg_346.exp	Sun Aug 15 14:00:27 2021
@@ -1,3 +1,4 @@
-msg_346.c(20): warning: call to 'strchr' effectively discards 'const' from argument [346]
 msg_346.c(26): warning: call to 'strchr' effectively discards 'const' from argument [346]
-msg_346.c(31): warning: call to 'strchr' effectively discards 'const' from argument [346]
+msg_346.c(32): warning: call to 'strchr' effectively discards 'const' from argument [346]
+msg_346.c(37): warning: call to 'strchr' effectively discards 'const' from argument [346]
+msg_346.c(46): warning: call to 'strchr' effectively discards 'const' from argument [346]



CVS commit: src/crypto/external/bsd/openssl/lib/libcrypto

2021-08-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug 15 13:32:44 UTC 2021

Modified Files:
src/crypto/external/bsd/openssl/lib/libcrypto: bn.inc

Log Message:
libcrypto: suppress irrelevant lint warnings

The conversion from 'unsigned long' to 'int' in line 805 is due to the
laziness of declaring a carry flag as BN_ULONG, to save an extra
line of declaration.

The constants in conditional context come from the macro 'bn_cp_32'.

The unconst cast is used for initializing local BIGNUM constants; the
struct member is declared as non-const pointer.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/crypto/external/bsd/openssl/lib/libcrypto/bn.inc

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

Modified files:

Index: src/crypto/external/bsd/openssl/lib/libcrypto/bn.inc
diff -u src/crypto/external/bsd/openssl/lib/libcrypto/bn.inc:1.5 src/crypto/external/bsd/openssl/lib/libcrypto/bn.inc:1.6
--- src/crypto/external/bsd/openssl/lib/libcrypto/bn.inc:1.5	Fri Feb  9 13:35:45 2018
+++ src/crypto/external/bsd/openssl/lib/libcrypto/bn.inc	Sun Aug 15 13:32:43 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: bn.inc,v 1.5 2018/02/09 13:35:45 christos Exp $
+#	$NetBSD: bn.inc,v 1.6 2021/08/15 13:32:43 rillig Exp $
 #
 #	@(#) Copyright (c) 1995 Simon J. Gerraty
 #
@@ -47,3 +47,7 @@ SRCS += ${BN_SRCS}
 .for cryptosrc in ${BN_SRCS}
 CPPFLAGS.${cryptosrc} = -I${OPENSSLSRC}/crypto/bn ${BNCPPFLAGS}
 .endfor
+
+LINTFLAGS.bn_nist.c+=	-X 132	# conversion from 'unsigned long' to 'int'
+LINTFLAGS.bn_nist.c+=	-X 161	# constant in conditional context
+LINTFLAGS.bn_nist.c+=	-X 275	# cast discards 'const' from type 'pointer to const unsigned long'



CVS commit: src

2021-08-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug 15 13:08:20 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_117.c msg_117.exp
src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: fix wrong warning about 'unsigned char >> constant'


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_117.c
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_117.exp
cvs rdiff -u -r1.334 -r1.335 src/usr.bin/xlint/lint1/tree.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_117.c
diff -u src/tests/usr.bin/xlint/lint1/msg_117.c:1.6 src/tests/usr.bin/xlint/lint1/msg_117.c:1.7
--- src/tests/usr.bin/xlint/lint1/msg_117.c:1.6	Sun Aug 15 13:02:20 2021
+++ src/tests/usr.bin/xlint/lint1/msg_117.c	Sun Aug 15 13:08:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_117.c,v 1.6 2021/08/15 13:02:20 rillig Exp $	*/
+/*	$NetBSD: msg_117.c,v 1.7 2021/08/15 13:08:20 rillig Exp $	*/
 # 3 "msg_117.c"
 
 // Test for message: bitwise '%s' on signed value possibly nonportable [117]
@@ -38,7 +38,10 @@ shr_rhs_constant_negative(int a)
 unsigned int
 shr_unsigned_char(unsigned char uc)
 {
-	/* FIXME: This value cannot actually be negative. */
-	/* expect+1: warning: bitwise '>>' on signed value possibly nonportable [117] */
+	/*
+	 * Even though 'uc' is promoted to 'int', it cannot be negative.
+	 * Before tree.c 1.335 from 2021-08-15, lint wrongly warned that
+	 * 'uc >> 4' might be a bitwise '>>' on signed value.
+	 */
 	return uc >> 4;
 }

Index: src/tests/usr.bin/xlint/lint1/msg_117.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_117.exp:1.5 src/tests/usr.bin/xlint/lint1/msg_117.exp:1.6
--- src/tests/usr.bin/xlint/lint1/msg_117.exp:1.5	Sun Aug 15 13:02:20 2021
+++ src/tests/usr.bin/xlint/lint1/msg_117.exp	Sun Aug 15 13:08:20 2021
@@ -4,4 +4,3 @@ msg_117.c(29): warning: bitwise '>>' on 
 msg_117.c(29): warning: shift amount 4660 is greater than bit-size 32 of 'int' [122]
 msg_117.c(35): warning: bitwise '>>' on signed value possibly nonportable [117]
 msg_117.c(35): warning: negative shift [121]
-msg_117.c(43): warning: bitwise '>>' on signed value possibly nonportable [117]

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.334 src/usr.bin/xlint/lint1/tree.c:1.335
--- src/usr.bin/xlint/lint1/tree.c:1.334	Sat Aug 14 13:00:55 2021
+++ src/usr.bin/xlint/lint1/tree.c	Sun Aug 15 13:08:19 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.334 2021/08/14 13:00:55 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.335 2021/08/15 13:08:19 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.334 2021/08/14 13:00:55 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.335 2021/08/15 13:08:19 rillig Exp $");
 #endif
 
 #include 
@@ -849,7 +849,7 @@ typeok_shr(const mod_t *mp,
 	ort = before_conversion(rn)->tn_type->t_tspec;
 
 	/* operands have integer types (checked above) */
-	if (pflag && !is_uinteger(lt)) {
+	if (pflag && !is_uinteger(olt)) {
 		/*
 		 * The left operand is signed. This means that
 		 * the operation is (possibly) nonportable.



CVS commit: src/tests/usr.bin/xlint/lint1

2021-08-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug 15 13:02:20 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_117.c msg_117.exp

Log Message:
tests/lint: demonstrate wrong warning about signed '>>'

Seen in libdes/ostr2key.c(81).


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_117.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_117.exp

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_117.c
diff -u src/tests/usr.bin/xlint/lint1/msg_117.c:1.5 src/tests/usr.bin/xlint/lint1/msg_117.c:1.6
--- src/tests/usr.bin/xlint/lint1/msg_117.c:1.5	Mon Apr  5 01:35:34 2021
+++ src/tests/usr.bin/xlint/lint1/msg_117.c	Sun Aug 15 13:02:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_117.c,v 1.5 2021/04/05 01:35:34 rillig Exp $	*/
+/*	$NetBSD: msg_117.c,v 1.6 2021/08/15 13:02:20 rillig Exp $	*/
 # 3 "msg_117.c"
 
 // Test for message: bitwise '%s' on signed value possibly nonportable [117]
@@ -34,3 +34,11 @@ shr_rhs_constant_negative(int a)
 {
 	return a >> -0x1234;		/* expect: 117 *//* expect: 121 */
 }
+
+unsigned int
+shr_unsigned_char(unsigned char uc)
+{
+	/* FIXME: This value cannot actually be negative. */
+	/* expect+1: warning: bitwise '>>' on signed value possibly nonportable [117] */
+	return uc >> 4;
+}

Index: src/tests/usr.bin/xlint/lint1/msg_117.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_117.exp:1.4 src/tests/usr.bin/xlint/lint1/msg_117.exp:1.5
--- src/tests/usr.bin/xlint/lint1/msg_117.exp:1.4	Tue Apr  6 21:32:57 2021
+++ src/tests/usr.bin/xlint/lint1/msg_117.exp	Sun Aug 15 13:02:20 2021
@@ -4,3 +4,4 @@ msg_117.c(29): warning: bitwise '>>' on 
 msg_117.c(29): warning: shift amount 4660 is greater than bit-size 32 of 'int' [122]
 msg_117.c(35): warning: bitwise '>>' on signed value possibly nonportable [117]
 msg_117.c(35): warning: negative shift [121]
+msg_117.c(43): warning: bitwise '>>' on signed value possibly nonportable [117]



CVS commit: src/crypto/external/bsd/openssl/lib/libdes

2021-08-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug 15 12:58:02 UTC 2021

Modified Files:
src/crypto/external/bsd/openssl/lib/libdes: Makefile

Log Message:
libdes: suppress some selected lint warnings

The type widths are handled carefully, so even if there is some
conversion from 64-bit long to uint32_t, no value bits get lost.

The fallthrough case statements are a variant of Duff's Device.

The bitwise '>>' on signed value is actually on a value of type
'unsigned char', and since all platforms supported by lint have
sizeof(int) == 4, the behavior is well defined.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/crypto/external/bsd/openssl/lib/libdes/Makefile

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

Modified files:

Index: src/crypto/external/bsd/openssl/lib/libdes/Makefile
diff -u src/crypto/external/bsd/openssl/lib/libdes/Makefile:1.3 src/crypto/external/bsd/openssl/lib/libdes/Makefile:1.4
--- src/crypto/external/bsd/openssl/lib/libdes/Makefile:1.3	Thu Mar 15 18:40:16 2018
+++ src/crypto/external/bsd/openssl/lib/libdes/Makefile	Sun Aug 15 12:58:01 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.3 2018/03/15 18:40:16 christos Exp $
+#	$NetBSD: Makefile,v 1.4 2021/08/15 12:58:01 rillig Exp $
 
 .include 
 
@@ -16,6 +16,9 @@ SRCS+=	ornd_keys.c
 
 CPPFLAGS+=-DOPENSSL_VERSION_PTEXT="\" based on OpenSSL 0.9.6j 10 Apr 2003\""
 CPPFLAGS+=-DOPENSSL_cleanse=bzero -DOPENSSL_malloc=malloc
+LINTFLAGS+=	-X 117	# bitwise '>>' on signed value possibly nonportable
+LINTFLAGS+=	-X 132	# conversion from 'long' to 'unsigned int'
+LINTFLAGS+=	-X 220	# fallthrough on case statement
 
 INCS=	des.h
 INCSDIR=/usr/include



CVS commit: src/external/bsd/jemalloc/lib

2021-08-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug 15 12:41:40 UTC 2021

Modified Files:
src/external/bsd/jemalloc/lib: Makefile.inc

Log Message:
jemalloc: suppress two irrelevant lint warnings


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/external/bsd/jemalloc/lib/Makefile.inc

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

Modified files:

Index: src/external/bsd/jemalloc/lib/Makefile.inc
diff -u src/external/bsd/jemalloc/lib/Makefile.inc:1.14 src/external/bsd/jemalloc/lib/Makefile.inc:1.15
--- src/external/bsd/jemalloc/lib/Makefile.inc:1.14	Tue Jul  6 12:40:24 2021
+++ src/external/bsd/jemalloc/lib/Makefile.inc	Sun Aug 15 12:41:40 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.14 2021/07/06 12:40:24 thorpej Exp $
+#	$NetBSD: Makefile.inc,v 1.15 2021/08/15 12:41:40 rillig Exp $
 
 JEMALLOC:=${.PARSEDIR}/..
 
@@ -44,6 +44,8 @@ witness.c
 CPPFLAGS.${i}+=-I${JEMALLOC}/include -DJEMALLOC_PROTECT_NOSTD
 COPTS.${i}+= -fvisibility=hidden -funroll-loops
 COPTS.${i}+= ${${ACTIVE_CC} == "clang":? -Wno-atomic-alignment :}
+LINTFLAGS.${i}+=	-X 231	# argument unused
+LINTFLAGS.${i}+=	-X 220	# fallthrough on case statement
 .endfor
 
 COPTS.background_thread.c+=-Wno-error=stack-protector



CVS commit: src/usr.bin/make

2021-08-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 14 14:43:30 UTC 2021

Modified Files:
src/usr.bin/make: arch.c

Log Message:
make: add ARGSUSED for lint


To generate a diff of this commit:
cvs rdiff -u -r1.201 -r1.202 src/usr.bin/make/arch.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/make/arch.c
diff -u src/usr.bin/make/arch.c:1.201 src/usr.bin/make/arch.c:1.202
--- src/usr.bin/make/arch.c:1.201	Sat Aug 14 13:26:07 2021
+++ src/usr.bin/make/arch.c	Sat Aug 14 14:43:30 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.201 2021/08/14 13:26:07 rillig Exp $	*/
+/*	$NetBSD: arch.c,v 1.202 2021/08/14 14:43:30 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -126,7 +126,7 @@
 #include "config.h"
 
 /*	"@(#)arch.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: arch.c,v 1.201 2021/08/14 13:26:07 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.202 2021/08/14 14:43:30 rillig Exp $");
 
 typedef struct List ArchList;
 typedef struct ListNode ArchListNode;
@@ -988,6 +988,7 @@ Arch_FindLib(GNode *gn, SearchPath *path
 #endif
 }
 
+/* ARGSUSED */
 static bool
 RanlibOODate(const GNode *gn MAKE_ATTR_UNUSED)
 {



CVS commit: src/tests/usr.bin/xlint/lint2

2021-08-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 14 14:25:51 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint2: msg_008.exp msg_008.ln msg_009.exp
msg_009.ln msg_010.exp msg_010.ln

Log Message:
tests/lint: add tests for messages 8, 9 and 10


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint2/msg_008.exp \
src/tests/usr.bin/xlint/lint2/msg_008.ln \
src/tests/usr.bin/xlint/lint2/msg_009.exp \
src/tests/usr.bin/xlint/lint2/msg_009.ln \
src/tests/usr.bin/xlint/lint2/msg_010.exp \
src/tests/usr.bin/xlint/lint2/msg_010.ln

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

Modified files:

Index: src/tests/usr.bin/xlint/lint2/msg_008.exp
diff -u src/tests/usr.bin/xlint/lint2/msg_008.exp:1.1 src/tests/usr.bin/xlint/lint2/msg_008.exp:1.2
--- src/tests/usr.bin/xlint/lint2/msg_008.exp:1.1	Thu Aug  5 22:36:08 2021
+++ src/tests/usr.bin/xlint/lint2/msg_008.exp	Sat Aug 14 14:25:51 2021
@@ -0,0 +1 @@
+func returns value which is always ignored
Index: src/tests/usr.bin/xlint/lint2/msg_008.ln
diff -u src/tests/usr.bin/xlint/lint2/msg_008.ln:1.1 src/tests/usr.bin/xlint/lint2/msg_008.ln:1.2
--- src/tests/usr.bin/xlint/lint2/msg_008.ln:1.1	Thu Aug  5 22:36:08 2021
+++ src/tests/usr.bin/xlint/lint2/msg_008.ln	Sat Aug 14 14:25:51 2021
@@ -1,6 +1,16 @@
-# $NetBSD: msg_008.ln,v 1.1 2021/08/05 22:36:08 rillig Exp $
+# $NetBSD: msg_008.ln,v 1.2 2021/08/14 14:25:51 rillig Exp $
 #
 # Test data for message 8 of lint2:
 #	%s returns value which is always ignored
 #
-# TODO: add actual test data
+
+0smsg_008.c
+Smsg_008.c
+
+# 100: bool func(void) { return true }
+100 d 0.100 drs 4func F0 B
+
+# 110: func();
+110 c 0.110 i 4func f0 B
+# 111: func();
+111 c 0.111 i 4func f0 B
Index: src/tests/usr.bin/xlint/lint2/msg_009.exp
diff -u src/tests/usr.bin/xlint/lint2/msg_009.exp:1.1 src/tests/usr.bin/xlint/lint2/msg_009.exp:1.2
--- src/tests/usr.bin/xlint/lint2/msg_009.exp:1.1	Thu Aug  5 22:36:08 2021
+++ src/tests/usr.bin/xlint/lint2/msg_009.exp	Sat Aug 14 14:25:51 2021
@@ -0,0 +1 @@
+func returns value which is sometimes ignored
Index: src/tests/usr.bin/xlint/lint2/msg_009.ln
diff -u src/tests/usr.bin/xlint/lint2/msg_009.ln:1.1 src/tests/usr.bin/xlint/lint2/msg_009.ln:1.2
--- src/tests/usr.bin/xlint/lint2/msg_009.ln:1.1	Thu Aug  5 22:36:08 2021
+++ src/tests/usr.bin/xlint/lint2/msg_009.ln	Sat Aug 14 14:25:51 2021
@@ -1,6 +1,16 @@
-# $NetBSD: msg_009.ln,v 1.1 2021/08/05 22:36:08 rillig Exp $
+# $NetBSD: msg_009.ln,v 1.2 2021/08/14 14:25:51 rillig Exp $
 #
 # Test data for message 9 of lint2:
 #	%s returns value which is sometimes ignored
 #
-# TODO: add actual test data
+
+0smsg_009.c
+Smsg_009.c
+
+# 100: bool func(void) { return true }
+100 d 0.100 drs 4func F0 B
+
+# 110: var = func();
+110 c 0.110 u 4func f0 B
+# 111: func();
+111 c 0.111 i 4func f0 B
Index: src/tests/usr.bin/xlint/lint2/msg_010.exp
diff -u src/tests/usr.bin/xlint/lint2/msg_010.exp:1.1 src/tests/usr.bin/xlint/lint2/msg_010.exp:1.2
--- src/tests/usr.bin/xlint/lint2/msg_010.exp:1.1	Thu Aug  5 22:36:08 2021
+++ src/tests/usr.bin/xlint/lint2/msg_010.exp	Sat Aug 14 14:25:51 2021
@@ -0,0 +1 @@
+func value is used( msg_010.c?(30) ), but none returned
Index: src/tests/usr.bin/xlint/lint2/msg_010.ln
diff -u src/tests/usr.bin/xlint/lint2/msg_010.ln:1.1 src/tests/usr.bin/xlint/lint2/msg_010.ln:1.2
--- src/tests/usr.bin/xlint/lint2/msg_010.ln:1.1	Thu Aug  5 22:36:08 2021
+++ src/tests/usr.bin/xlint/lint2/msg_010.ln	Sat Aug 14 14:25:51 2021
@@ -1,6 +1,17 @@
-# $NetBSD: msg_010.ln,v 1.1 2021/08/05 22:36:08 rillig Exp $
+# $NetBSD: msg_010.ln,v 1.2 2021/08/14 14:25:51 rillig Exp $
 #
 # Test data for message 10 of lint2:
 #	%s value is used( %s ), but none returned
 #
-# TODO: add actual test data
+
+0 s msg_010.c
+S msg_010.c
+1 s msg_010_use.c
+
+# msg_010.c:10: func() {}
+10 d 0.10 d o 4func f0I
+
+# msg_010_use.c:20: func();
+20 d 1.20 e 4func F I
+# msg_010_use.c:30: use() { return func(); }
+30 c 1.30 u 4func f 0 I



CVS commit: src/usr.bin/make

2021-08-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 14 13:39:43 UTC 2021

Modified Files:
src/usr.bin/make: parse.c

Log Message:
make: fix spelling of CVS and RCS in error message


To generate a diff of this commit:
cvs rdiff -u -r1.562 -r1.563 src/usr.bin/make/parse.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/make/parse.c
diff -u src/usr.bin/make/parse.c:1.562 src/usr.bin/make/parse.c:1.563
--- src/usr.bin/make/parse.c:1.562	Sat Aug 14 13:37:55 2021
+++ src/usr.bin/make/parse.c	Sat Aug 14 13:39:43 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.562 2021/08/14 13:37:55 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.563 2021/08/14 13:39:43 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.562 2021/08/14 13:37:55 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.563 2021/08/14 13:39:43 rillig Exp $");
 
 /* types and constants */
 
@@ -1004,7 +1004,7 @@ ParseErrorNoDependency(const char *lstar
 	(strncmp(lstart, "==", 6) == 0) ||
 	(strncmp(lstart, ">>", 6) == 0))
 		Parse_Error(PARSE_FATAL,
-		"Makefile appears to contain unresolved cvs/rcs/??? merge conflicts");
+		"Makefile appears to contain unresolved CVS/RCS/??? merge conflicts");
 	else if (lstart[0] == '.') {
 		const char *dirstart = lstart + 1;
 		const char *dirend;



CVS commit: src/usr.bin/make

2021-08-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 14 13:37:56 UTC 2021

Modified Files:
src/usr.bin/make: parse.c

Log Message:
make: rename ParseMark to be more expressive

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.561 -r1.562 src/usr.bin/make/parse.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/make/parse.c
diff -u src/usr.bin/make/parse.c:1.561 src/usr.bin/make/parse.c:1.562
--- src/usr.bin/make/parse.c:1.561	Sat Aug 14 13:32:12 2021
+++ src/usr.bin/make/parse.c	Sat Aug 14 13:37:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.561 2021/08/14 13:32:12 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.562 2021/08/14 13:37:55 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.561 2021/08/14 13:32:12 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.562 2021/08/14 13:37:55 rillig Exp $");
 
 /* types and constants */
 
@@ -530,7 +530,7 @@ ParseIsEscaped(const char *line, const c
  * was first defined.
  */
 static void
-ParseMark(GNode *gn)
+RememberLocation(GNode *gn)
 {
 	IFile *curFile = CurFile();
 	gn->fname = curFile->fname;
@@ -782,7 +782,7 @@ TryApplyDependencyOperator(GNode *gn, GN
 
 		cohort = Targ_NewInternalNode(gn->name);
 		if (doing_depend)
-			ParseMark(cohort);
+			RememberLocation(cohort);
 		/*
 		 * Make the cohort invisible as well to avoid duplicating it
 		 * into other variables. True, parents of this target won't
@@ -837,7 +837,7 @@ ParseDependencySourceWait(bool isSpecial
 	snprintf(wait_src, sizeof wait_src, ".WAIT_%u", ++wait_number);
 	gn = Targ_NewInternalNode(wait_src);
 	if (doing_depend)
-		ParseMark(gn);
+		RememberLocation(gn);
 	gn->type = OP_WAIT | OP_PHONY | OP_DEPENDS | OP_NOTMAIN;
 	LinkToTargets(gn, isSpecial);
 
@@ -897,7 +897,7 @@ ParseDependencySourceOrder(const char *s
 	 */
 	gn = Targ_GetNode(src);
 	if (doing_depend)
-		ParseMark(gn);
+		RememberLocation(gn);
 	if (order_pred != NULL) {
 		Lst_Append(&order_pred->order_succ, gn);
 		Lst_Append(&gn->order_pred, order_pred);
@@ -934,7 +934,7 @@ ParseDependencySourceOther(const char *s
 	/* Find/create the 'src' node and attach to all targets */
 	gn = Targ_GetNode(src);
 	if (doing_depend)
-		ParseMark(gn);
+		RememberLocation(gn);
 	if (tOp != OP_NONE)
 		gn->type |= tOp;
 	else
@@ -1085,7 +1085,7 @@ ParseDependencyTargetSpecial(ParseSpecia
 	case SP_INTERRUPT: {
 		GNode *gn = Targ_GetNode(targetName);
 		if (doing_depend)
-			ParseMark(gn);
+			RememberLocation(gn);
 		gn->type |= OP_NOTMAIN | OP_SPECIAL;
 		Lst_Append(targets, gn);
 		break;
@@ -1215,7 +1215,7 @@ ParseDependencyTargetMundane(char *targe
 		? Suff_AddTransform(targName)
 		: Targ_GetNode(targName);
 		if (doing_depend)
-			ParseMark(gn);
+			RememberLocation(gn);
 
 		Lst_Append(targets, gn);
 	}
@@ -2084,7 +2084,7 @@ ParseAddCmd(GNode *gn, char *cmd)
 		Lst_Append(&gn->commands, cmd);
 		if (MaybeSubMake(cmd))
 			gn->type |= OP_SUBMAKE;
-		ParseMark(gn);
+		RememberLocation(gn);
 	} else {
 #if 0
 		/* XXX: We cannot do this until we fix the tree */



CVS commit: src/usr.bin/make

2021-08-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 14 13:32:12 UTC 2021

Modified Files:
src/usr.bin/make: main.c nonints.h parse.c

Log Message:
make: rename variable and function for handling parse errors

The word 'fatals' was an unnecessary abbreviation.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.540 -r1.541 src/usr.bin/make/main.c
cvs rdiff -u -r1.213 -r1.214 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.560 -r1.561 src/usr.bin/make/parse.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/make/main.c
diff -u src/usr.bin/make/main.c:1.540 src/usr.bin/make/main.c:1.541
--- src/usr.bin/make/main.c:1.540	Fri Jun 18 12:54:17 2021
+++ src/usr.bin/make/main.c	Sat Aug 14 13:32:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.540 2021/06/18 12:54:17 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.541 2021/08/14 13:32:12 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -111,7 +111,7 @@
 #include "trace.h"
 
 /*	"@(#)main.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: main.c,v 1.540 2021/06/18 12:54:17 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.541 2021/08/14 13:32:12 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	"The Regents of the University of California.  "
@@ -1658,7 +1658,7 @@ main_CleanUp(void)
 static int
 main_Exit(bool outOfDate)
 {
-	if (opts.strict && (main_errors > 0 || Parse_GetFatals() > 0))
+	if (opts.strict && (main_errors > 0 || Parse_NumErrors() > 0))
 		return 2;	/* Not 1 so -q can distinguish error */
 	return outOfDate ? 1 : 0;
 }

Index: src/usr.bin/make/nonints.h
diff -u src/usr.bin/make/nonints.h:1.213 src/usr.bin/make/nonints.h:1.214
--- src/usr.bin/make/nonints.h:1.213	Sun Apr 11 13:35:56 2021
+++ src/usr.bin/make/nonints.h	Sat Aug 14 13:32:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: nonints.h,v 1.213 2021/04/11 13:35:56 rillig Exp $	*/
+/*	$NetBSD: nonints.h,v 1.214 2021/08/14 13:32:12 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -164,7 +164,7 @@ void Parse_AddIncludeDir(const char *);
 void Parse_File(const char *, int);
 void Parse_SetInput(const char *, int, int, ReadMoreProc, void *);
 void Parse_MainName(GNodeList *);
-int Parse_GetFatals(void);
+int Parse_NumErrors(void);
 
 
 /* suff.c */

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.560 src/usr.bin/make/parse.c:1.561
--- src/usr.bin/make/parse.c:1.560	Mon Jun 21 10:42:06 2021
+++ src/usr.bin/make/parse.c	Sat Aug 14 13:32:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.560 2021/06/21 10:42:06 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.561 2021/08/14 13:32:12 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.560 2021/06/21 10:42:06 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.561 2021/08/14 13:32:12 rillig Exp $");
 
 /* types and constants */
 
@@ -218,7 +218,7 @@ static GNode *order_pred;
 /* parser state */
 
 /* number of fatal errors */
-static int fatals = 0;
+static int parseErrors = 0;
 
 /*
  * Variables for doing includes
@@ -613,7 +613,7 @@ ParseVErrorInternal(FILE *f, const char 
 		goto print_stack_trace;
 	if (type == PARSE_WARNING && !opts.parseWarnFatal)
 		goto print_stack_trace;
-	fatals++;
+	parseErrors++;
 	if (type == PARSE_WARNING && !fatal_warning_error_printed) {
 		Error("parsing warnings being treated as errors");
 		fatal_warning_error_printed = true;
@@ -3250,7 +3250,7 @@ Parse_File(const char *name, int fd)
 
 	FinishDependencyGroup();
 
-	if (fatals != 0) {
+	if (parseErrors != 0) {
 		(void)fflush(stdout);
 		(void)fprintf(stderr,
 		"%s: Fatal errors encountered -- cannot continue",
@@ -3305,7 +3305,7 @@ Parse_MainName(GNodeList *mainList)
 }
 
 int
-Parse_GetFatals(void)
+Parse_NumErrors(void)
 {
-	return fatals;
+	return parseErrors;
 }



CVS commit: src/usr.bin/make

2021-08-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 14 13:26:07 UTC 2021

Modified Files:
src/usr.bin/make: arch.c

Log Message:
make: extract RanlibOODate into separate function

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.200 -r1.201 src/usr.bin/make/arch.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/make/arch.c
diff -u src/usr.bin/make/arch.c:1.200 src/usr.bin/make/arch.c:1.201
--- src/usr.bin/make/arch.c:1.200	Sun May 30 21:16:54 2021
+++ src/usr.bin/make/arch.c	Sat Aug 14 13:26:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.200 2021/05/30 21:16:54 rillig Exp $	*/
+/*	$NetBSD: arch.c,v 1.201 2021/08/14 13:26:07 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -126,7 +126,7 @@
 #include "config.h"
 
 /*	"@(#)arch.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: arch.c,v 1.200 2021/05/30 21:16:54 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.201 2021/08/14 13:26:07 rillig Exp $");
 
 typedef struct List ArchList;
 typedef struct ListNode ArchListNode;
@@ -988,6 +988,34 @@ Arch_FindLib(GNode *gn, SearchPath *path
 #endif
 }
 
+static bool
+RanlibOODate(const GNode *gn MAKE_ATTR_UNUSED)
+{
+#ifdef RANLIBMAG
+	struct ar_hdr *arh;	/* Header for __.SYMDEF */
+	int tocModTime;		/* The table-of-contents' mod time */
+
+	arh = ArchStatMember(gn->path, RANLIBMAG, false);
+
+	if (arh == NULL) {
+		/* A library without a table of contents is out-of-date. */
+		if (DEBUG(ARCH) || DEBUG(MAKE))
+			debug_printf("no toc...");
+		return true;
+	}
+
+	tocModTime = (int)strtol(arh->ar_date, NULL, 10);
+
+	if (DEBUG(ARCH) || DEBUG(MAKE))
+		debug_printf("%s modified %s...",
+		RANLIBMAG, Targ_FmtTime(tocModTime));
+	return gn->youngestChild == NULL ||
+	   gn->youngestChild->mtime > tocModTime;
+#else
+	return false;
+#endif
+}
+
 /*
  * Decide if a node with the OP_LIB attribute is out-of-date. Called from
  * GNode_IsOODate to make its life easier.
@@ -1021,46 +1049,19 @@ Arch_FindLib(GNode *gn, SearchPath *path
 bool
 Arch_LibOODate(GNode *gn)
 {
-	bool oodate;
 
 	if (gn->type & OP_PHONY) {
-		oodate = true;
+		return true;
 	} else if (!GNode_IsTarget(gn) && Lst_IsEmpty(&gn->children)) {
-		oodate = false;
+		return false;
 	} else if ((!Lst_IsEmpty(&gn->children) && gn->youngestChild == NULL) ||
 		   (gn->mtime > now) ||
 		   (gn->youngestChild != NULL &&
 		gn->mtime < gn->youngestChild->mtime)) {
-		oodate = true;
+		return true;
 	} else {
-#ifdef RANLIBMAG
-		struct ar_hdr *arh;	/* Header for __.SYMDEF */
-		int modTimeTOC;		/* The table-of-contents' mod time */
-
-		arh = ArchStatMember(gn->path, RANLIBMAG, false);
-
-		if (arh != NULL) {
-			modTimeTOC = (int)strtol(arh->ar_date, NULL, 10);
-
-			if (DEBUG(ARCH) || DEBUG(MAKE))
-debug_printf("%s modified %s...",
-	 RANLIBMAG,
-	 Targ_FmtTime(modTimeTOC));
-			oodate = gn->youngestChild == NULL ||
- gn->youngestChild->mtime > modTimeTOC;
-		} else {
-			/*
-			 * A library without a table of contents is out-of-date.
-			 */
-			if (DEBUG(ARCH) || DEBUG(MAKE))
-debug_printf("no toc...");
-			oodate = true;
-		}
-#else
-		oodate = false;
-#endif
+		return RanlibOODate(gn);
 	}
-	return oodate;
 }
 
 /* Initialize the archives module. */



CVS commit: src/usr.bin/make

2021-08-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 14 13:11:33 UTC 2021

Modified Files:
src/usr.bin/make: var.c

Log Message:
make: remove workaround for initialization bug in lint

The bug has been fixed in init.c 1.208 from 2021-08-14.


To generate a diff of this commit:
cvs rdiff -u -r1.946 -r1.947 src/usr.bin/make/var.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/make/var.c
diff -u src/usr.bin/make/var.c:1.946 src/usr.bin/make/var.c:1.947
--- src/usr.bin/make/var.c:1.946	Sun Aug  8 12:00:30 2021
+++ src/usr.bin/make/var.c	Sat Aug 14 13:11:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.946 2021/08/08 12:00:30 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.947 2021/08/14 13:11:33 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.946 2021/08/08 12:00:30 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.947 2021/08/14 13:11:33 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -4019,8 +4019,6 @@ ApplyModifiers(
 char endc		/* ')' or '}'; or '\0' for indirect modifiers */
 )
 {
-	/* LINTED 115 *//* warning: left operand of '=' must be modifiable lvalue */
-	/* That's a bug in lint; see tests/usr.bin/xlint/lint1/msg_115.c. */
 	ModChain ch = ModChain_Literal(expr, startc, endc, ' ', false);
 	const char *p;
 	const char *mod;



CVS commit: src/usr.bin/make

2021-08-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 14 13:04:00 UTC 2021

Modified Files:
src/usr.bin/make: meta.c

Log Message:
make: fix lint warning about strchr removing 'const'

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.181 -r1.182 src/usr.bin/make/meta.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/make/meta.c
diff -u src/usr.bin/make/meta.c:1.181 src/usr.bin/make/meta.c:1.182
--- src/usr.bin/make/meta.c:1.181	Sun Apr  4 10:05:08 2021
+++ src/usr.bin/make/meta.c	Sat Aug 14 13:04:00 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: meta.c,v 1.181 2021/04/04 10:05:08 rillig Exp $ */
+/*  $NetBSD: meta.c,v 1.182 2021/08/14 13:04:00 rillig Exp $ */
 
 /*
  * Implement 'meta' mode.
@@ -321,8 +321,7 @@ is_submake(const char *cmd, GNode *gn)
 static const char *p_make = NULL;
 static size_t p_len;
 char *mp = NULL;
-char *cp;
-char *cp2;
+const char *cp, *cp2;
 bool rc = false;
 
 if (p_make == NULL) {



CVS commit: src

2021-08-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 14 13:00:55 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: d_init_array_using_string.c
d_init_array_using_string.exp d_long_double_int.exp msg_124.c
msg_124.exp msg_184.c msg_184.exp
src/usr.bin/xlint/lint1: err.c tree.c

Log Message:
lint: use standard quoting style for messages 124 and 184


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/tests/usr.bin/xlint/lint1/d_init_array_using_string.c \
src/tests/usr.bin/xlint/lint1/d_long_double_int.exp
cvs rdiff -u -r1.5 -r1.6 \
src/tests/usr.bin/xlint/lint1/d_init_array_using_string.exp
cvs rdiff -u -r1.10 -r1.11 src/tests/usr.bin/xlint/lint1/msg_124.c \
src/tests/usr.bin/xlint/lint1/msg_124.exp
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_184.c
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_184.exp
cvs rdiff -u -r1.135 -r1.136 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.333 -r1.334 src/usr.bin/xlint/lint1/tree.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/d_init_array_using_string.c
diff -u src/tests/usr.bin/xlint/lint1/d_init_array_using_string.c:1.4 src/tests/usr.bin/xlint/lint1/d_init_array_using_string.c:1.5
--- src/tests/usr.bin/xlint/lint1/d_init_array_using_string.c:1.4	Fri Apr  9 23:03:26 2021
+++ src/tests/usr.bin/xlint/lint1/d_init_array_using_string.c	Sat Aug 14 13:00:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: d_init_array_using_string.c,v 1.4 2021/04/09 23:03:26 rillig Exp $	*/
+/*	$NetBSD: d_init_array_using_string.c,v 1.5 2021/08/14 13:00:55 rillig Exp $	*/
 # 3 "d_init_array_using_string.c"
 
 /*
@@ -13,8 +13,10 @@ test_assignment_initialization(void)
 	const char *cs_match = "";
 	const int *ws_match = L"";
 
-	const char *cs_mismatch = L"";	/* expect: illegal pointer combination */
-	const int *ws_mismatch = "";	/* expect: illegal pointer combination */
+	/* expect+1: warning: illegal combination of 'pointer to const char' and 'pointer to int', op 'init' [124] */
+	const char *cs_mismatch = L"";
+	/* expect+1: warning: illegal combination of 'pointer to const int' and 'pointer to char', op 'init' [124] */
+	const int *ws_mismatch = "";
 }
 
 void
@@ -31,8 +33,10 @@ test_pointer_initialization_in_struct(vo
 	};
 
 	struct cs_ws type_mismatch = {
-		L"",		/* expect: illegal pointer combination */
-		"",		/* expect: illegal pointer combination */
+		/* expect+1: warning: illegal combination of 'pointer to const char' and 'pointer to int', op 'init' [124] */
+		L"",
+		/* expect+1: warning: illegal combination of 'pointer to const int' and 'pointer to char', op 'init' [124] */
+		"",
 	};
 
 	struct cs_ws extra_braces = {
Index: src/tests/usr.bin/xlint/lint1/d_long_double_int.exp
diff -u src/tests/usr.bin/xlint/lint1/d_long_double_int.exp:1.4 src/tests/usr.bin/xlint/lint1/d_long_double_int.exp:1.5
--- src/tests/usr.bin/xlint/lint1/d_long_double_int.exp:1.4	Sun Jan 31 14:39:31 2021
+++ src/tests/usr.bin/xlint/lint1/d_long_double_int.exp	Sat Aug 14 13:00:55 2021
@@ -1 +1 @@
-d_long_double_int.c(9): warning: illegal pointer combination (pointer to long double) and (pointer to long), op == [124]
+d_long_double_int.c(9): warning: illegal combination of 'pointer to long double' and 'pointer to long', op '==' [124]

Index: src/tests/usr.bin/xlint/lint1/d_init_array_using_string.exp
diff -u src/tests/usr.bin/xlint/lint1/d_init_array_using_string.exp:1.5 src/tests/usr.bin/xlint/lint1/d_init_array_using_string.exp:1.6
--- src/tests/usr.bin/xlint/lint1/d_init_array_using_string.exp:1.5	Sat Aug 14 12:46:24 2021
+++ src/tests/usr.bin/xlint/lint1/d_init_array_using_string.exp	Sat Aug 14 13:00:55 2021
@@ -1,8 +1,8 @@
-d_init_array_using_string.c(16): warning: illegal pointer combination (pointer to const char) and (pointer to int), op init [124]
-d_init_array_using_string.c(17): warning: illegal pointer combination (pointer to const int) and (pointer to char), op init [124]
-d_init_array_using_string.c(34): warning: illegal pointer combination (pointer to const char) and (pointer to int), op init [124]
-d_init_array_using_string.c(35): warning: illegal pointer combination (pointer to const int) and (pointer to char), op init [124]
-d_init_array_using_string.c(59): error: cannot initialize 'array[10] of const char' from 'pointer to int' [185]
-d_init_array_using_string.c(60): error: cannot initialize 'array[10] of const int' from 'pointer to char' [185]
-d_init_array_using_string.c(69): warning: non-null byte ignored in string initializer [187]
-d_init_array_using_string.c(70): warning: non-null byte ignored in string initializer [187]
+d_init_array_using_string.c(17): warning: illegal combination of 'pointer to const char' and 'pointer to int', op 'init' [124]
+d_init_array_using_string.c(19): warning: illegal combination of 'pointer to const int' and

CVS commit: src

2021-08-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 14 12:46:24 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: d_c99_bool_strict.exp
d_c99_bool_strict_syshdr.exp d_init_array_using_string.exp
msg_115.c msg_115.exp msg_124.exp msg_164.c msg_164.exp msg_242.c
msg_242.exp
src/usr.bin/xlint/lint1: init.c ops.def tree.c

Log Message:
lint: allow initialization of struct with constant member

The operator INIT, just like RETURN and FARG, initializes an object with
an expression.  The target object of such an initialization may be a
struct with constant members.

The operator ASSIGN, on the other hand, is entirely different.  It
overwrites the existing value of the object, and this is not allowed for
structs that have a constant member.  Therefore it was wrong to use the
operator ASSIGN for initialization.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 \
src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp
cvs rdiff -u -r1.10 -r1.11 \
src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp
cvs rdiff -u -r1.4 -r1.5 \
src/tests/usr.bin/xlint/lint1/d_init_array_using_string.exp
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/msg_115.c
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_115.exp
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/xlint/lint1/msg_124.exp
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_164.c \
src/tests/usr.bin/xlint/lint1/msg_242.c
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_164.exp \
src/tests/usr.bin/xlint/lint1/msg_242.exp
cvs rdiff -u -r1.207 -r1.208 src/usr.bin/xlint/lint1/init.c
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/xlint/lint1/ops.def
cvs rdiff -u -r1.332 -r1.333 src/usr.bin/xlint/lint1/tree.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp
diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp:1.27 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp:1.28
--- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp:1.27	Sun Jul  4 07:09:39 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp	Sat Aug 14 12:46:24 2021
@@ -144,10 +144,10 @@ d_c99_bool_strict.c(582): error: operand
 d_c99_bool_strict.c(583): error: operands of ':' have incompatible types (unsigned int != _Bool) [107]
 d_c99_bool_strict.c(589): warning: expression has null effect [129]
 d_c99_bool_strict.c(590): warning: expression has null effect [129]
-d_c99_bool_strict.c(603): error: operands of '=' have incompatible types (char != _Bool) [107]
-d_c99_bool_strict.c(604): error: operands of '=' have incompatible types (int != _Bool) [107]
-d_c99_bool_strict.c(605): error: operands of '=' have incompatible types (double != _Bool) [107]
-d_c99_bool_strict.c(606): error: operands of '=' have incompatible types (pointer != _Bool) [107]
+d_c99_bool_strict.c(603): error: operands of 'init' have incompatible types (char != _Bool) [107]
+d_c99_bool_strict.c(604): error: operands of 'init' have incompatible types (int != _Bool) [107]
+d_c99_bool_strict.c(605): error: operands of 'init' have incompatible types (double != _Bool) [107]
+d_c99_bool_strict.c(606): error: operands of 'init' have incompatible types (pointer != _Bool) [107]
 d_c99_bool_strict.c(623): error: operands of '=' have incompatible types (int != _Bool) [107]
 d_c99_bool_strict.c(624): error: operands of '=' have incompatible types (int != _Bool) [107]
 d_c99_bool_strict.c(625): error: operands of '=' have incompatible types (int != _Bool) [107]

Index: src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp
diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp:1.10 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp:1.11
--- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp:1.10	Tue Aug  3 18:44:33 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp	Sat Aug 14 12:46:24 2021
@@ -1,6 +1,6 @@
 d_c99_bool_strict_syshdr.c(43): error: controlling expression must be bool, not 'int' [333]
 d_c99_bool_strict_syshdr.c(53): error: controlling expression must be bool, not 'int' [333]
-d_c99_bool_strict_syshdr.c(87): error: operands of '=' have incompatible types (_Bool != int) [107]
+d_c99_bool_strict_syshdr.c(87): error: operands of 'init' have incompatible types (_Bool != int) [107]
 d_c99_bool_strict_syshdr.c(162): error: return value type mismatch (_Bool) and (int) [211]
 d_c99_bool_strict_syshdr.c(175): error: operand of '!' must be bool, not 'int' [330]
 d_c99_bool_strict_syshdr.c(175): warning: function 'str_equal_bad' expects to return value [214]

Index: src/tests/usr.bin/xlint/lint1/d_init_array_using_string.exp
diff -u src/tests/usr.bin/xlint/lint1/d_init_array_using_string.exp:1.4 src/tests/usr.bin/xlint/lint1/d_init_array_using_string.exp:1.5
--- src/tests/usr.bin/xlint/lint1/d_init_array_using_string.exp:1.4	Fri Ap

CVS commit: src/usr.bin/mkdep

2021-08-11 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Aug 11 20:48:16 UTC 2021

Modified Files:
src/usr.bin/mkdep: findcc.c

Log Message:
mkdep: document possible undefined behavior

If findcc is called with a constant string, as its prototype suggests,
the process crashes with a segmentation fault.  Luckily, neither mkdep
nor lint do that, but the function prototype is nevertheless confusing.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/mkdep/findcc.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/mkdep/findcc.c
diff -u src/usr.bin/mkdep/findcc.c:1.6 src/usr.bin/mkdep/findcc.c:1.7
--- src/usr.bin/mkdep/findcc.c:1.6	Sun Sep  4 20:30:06 2011
+++ src/usr.bin/mkdep/findcc.c	Wed Aug 11 20:48:16 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: findcc.c,v 1.6 2011/09/04 20:30:06 joerg Exp $ */
+/* $NetBSD: findcc.c,v 1.7 2021/08/11 20:48:16 rillig Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 #if !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1999 The NetBSD Foundation, Inc.\
  All rights reserved.");
-__RCSID("$NetBSD: findcc.c,v 1.6 2011/09/04 20:30:06 joerg Exp $");
+__RCSID("$NetBSD: findcc.c,v 1.7 2021/08/11 20:48:16 rillig Exp $");
 #endif /* not lint */
 
 #include 
@@ -55,6 +55,11 @@ findcc(const char *progname)
 	char   buffer[MAXPATHLEN];
 
 	if ((next = strchr(progname, ' ')) != NULL) {
+		/*
+		 * FIXME: writing to a 'const char *' invokes undefined
+		 * behavior.  The call to 'strchr' subtly hides the unconst
+		 * cast from the compiler.
+		 */
 		*next = '\0';
 	}
 



CVS commit: src

2021-08-11 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Aug 11 20:42:26 UTC 2021

Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/usr.bin/mkdep: Makefile
Added Files:
src/tests/usr.bin/mkdep: h_findcc.c t_findcc.sh

Log Message:
tests/mkdep: test findcc

This function is used by both mkdep and lint.


To generate a diff of this commit:
cvs rdiff -u -r1.1109 -r1.1110 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/mkdep/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/mkdep/h_findcc.c \
src/tests/usr.bin/mkdep/t_findcc.sh

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1109 src/distrib/sets/lists/tests/mi:1.1110
--- src/distrib/sets/lists/tests/mi:1.1109	Mon Aug  9 20:07:23 2021
+++ src/distrib/sets/lists/tests/mi	Wed Aug 11 20:42:26 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1109 2021/08/09 20:07:23 rillig Exp $
+# $NetBSD: mi,v 1.1110 2021/08/11 20:42:26 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -5972,6 +5972,8 @@
 ./usr/tests/usr.bin/mkdeptests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/mkdep/Atffile			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/mkdep/Kyuafile			tests-usr.bin-tests	compattestfile,atf,kyua
+./usr/tests/usr.bin/mkdep/h_findcc			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/mkdep/t_findcc			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/mkdep/t_mkdep			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/nbperftests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/nbperf/Atffile			tests-usr.bin-tests	compattestfile,atf

Index: src/tests/usr.bin/mkdep/Makefile
diff -u src/tests/usr.bin/mkdep/Makefile:1.1 src/tests/usr.bin/mkdep/Makefile:1.2
--- src/tests/usr.bin/mkdep/Makefile:1.1	Mon May 30 18:14:11 2011
+++ src/tests/usr.bin/mkdep/Makefile	Wed Aug 11 20:42:26 2021
@@ -1,9 +1,17 @@
-# $NetBSD: Makefile,v 1.1 2011/05/30 18:14:11 njoly Exp $
+# $NetBSD: Makefile,v 1.2 2021/08/11 20:42:26 rillig Exp $
 
 .include 
 
 TESTSDIR=	${TESTSBASE}/usr.bin/mkdep
 
-TESTS_SH=	t_mkdep
+TESTS_SH=	t_findcc
+TESTS_SH+=	t_mkdep
+
+BINDIR=		${TESTSDIR}
+PROG=		h_findcc
+.PATH:  	${NETBSDSRCDIR}/usr.bin/mkdep
+SRCS=		h_findcc.c findcc.c
+CPPFLAGS+=	-I${NETBSDSRCDIR}/usr.bin/mkdep
+MAN.h_findcc=	# none
 
 .include 

Added files:

Index: src/tests/usr.bin/mkdep/h_findcc.c
diff -u /dev/null src/tests/usr.bin/mkdep/h_findcc.c:1.1
--- /dev/null	Wed Aug 11 20:42:26 2021
+++ src/tests/usr.bin/mkdep/h_findcc.c	Wed Aug 11 20:42:26 2021
@@ -0,0 +1,16 @@
+/*	$NetBSD: h_findcc.c,v 1.1 2021/08/11 20:42:26 rillig Exp $	*/
+
+#include 
+#include 
+
+#include "findcc.h"
+
+int
+main(int argc, char **argv)
+{
+	const char *cc;
+
+	assert(argc == 2);
+	cc = findcc(argv[1]);
+	printf("%s\n", cc != NULL ? cc : "(not found)");
+}
Index: src/tests/usr.bin/mkdep/t_findcc.sh
diff -u /dev/null src/tests/usr.bin/mkdep/t_findcc.sh:1.1
--- /dev/null	Wed Aug 11 20:42:26 2021
+++ src/tests/usr.bin/mkdep/t_findcc.sh	Wed Aug 11 20:42:26 2021
@@ -0,0 +1,117 @@
+# $NetBSD: t_findcc.sh,v 1.1 2021/08/11 20:42:26 rillig Exp $
+#
+# Copyright (c) 2021 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Roland Illig.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#notice, this list of conditions and the following disclaimer in the
+#documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+n='
+'
+
+# A plain program name is searched in the PATH.  Since in this case, the
+# environment is empty, nothing is found.
+#
+atf_test_ca

CVS commit: src/usr.bin/xlint/lint2

2021-08-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Aug 11 05:37:45 UTC 2021

Modified Files:
src/usr.bin/xlint/lint2: main2.c

Log Message:
lint: add reminder to sort the output of lint2


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/xlint/lint2/main2.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/lint2/main2.c
diff -u src/usr.bin/xlint/lint2/main2.c:1.17 src/usr.bin/xlint/lint2/main2.c:1.18
--- src/usr.bin/xlint/lint2/main2.c:1.17	Sun Apr 18 22:51:24 2021
+++ src/usr.bin/xlint/lint2/main2.c	Wed Aug 11 05:37:45 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: main2.c,v 1.17 2021/04/18 22:51:24 rillig Exp $	*/
+/*	$NetBSD: main2.c,v 1.18 2021/08/11 05:37:45 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: main2.c,v 1.17 2021/04/18 22:51:24 rillig Exp $");
+__RCSID("$NetBSD: main2.c,v 1.18 2021/08/11 05:37:45 rillig Exp $");
 #endif
 
 #include 
@@ -181,6 +181,7 @@ main(int argc, char *argv[])
 	mainused();
 
 	/* perform all tests */
+	/* TODO: sort the names; hashcode order looks chaotic. */
 	forall(chkname);
 
 	exit(0);



CVS commit: src/lib/libpam/libpam

2021-08-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Aug 11 05:23:05 UTC 2021

Modified Files:
src/lib/libpam/libpam: Makefile

Log Message:
libpam: clean up LINTFLAGS

Warning 346 is new, the other suppressions are not needed anymore.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/lib/libpam/libpam/Makefile

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

Modified files:

Index: src/lib/libpam/libpam/Makefile
diff -u src/lib/libpam/libpam/Makefile:1.26 src/lib/libpam/libpam/Makefile:1.27
--- src/lib/libpam/libpam/Makefile:1.26	Sat May 23 00:43:33 2020
+++ src/lib/libpam/libpam/Makefile	Wed Aug 11 05:23:05 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.26 2020/05/23 00:43:33 rin Exp $
+# $NetBSD: Makefile,v 1.27 2021/08/11 05:23:05 rillig Exp $
 #-
 # Copyright (c) 1998 Juniper Networks, Inc.
 # All rights reserved.
@@ -51,12 +51,11 @@ MKPICLIB=yes
 DIST=   ${NETBSDSRCDIR}/external/bsd/openpam/dist
 LIB=	pam
 NOPROFILE=
-# XXX: returns no value
-#LINTFLAGS+= -X 217 -X 284
 
-WARNS=	6
-# 233: Struct/union never defined
-LINTFLAGS+= -Sw -X 233
+WARNS=		6
+LINTFLAGS+=	-w
+# warning: call to 'strchr' effectively discards 'const' from argument
+LINTFLAGS.pam_putenv.c+= -X 346
 
 CPPFLAGS+= -DLIB_MAJ=${SHLIB_MAJOR} -DHAVE_CONFIG_H -I${.CURDIR}
 #CPPFLAGS+= -DOPENPAM_DEBUG



CVS commit: src

2021-08-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Aug 11 05:19:33 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: gcc_attribute_var.c
gcc_attribute_var.exp
src/usr.bin/xlint/lint1: cgram.y

Log Message:
lint: allow GCC __attribute__ after array brackets

GCC accepts this, so should lint.  Seen in pam_lastlog.c:115.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/gcc_attribute_var.c \
src/tests/usr.bin/xlint/lint1/gcc_attribute_var.exp
cvs rdiff -u -r1.354 -r1.355 src/usr.bin/xlint/lint1/cgram.y

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/gcc_attribute_var.c
diff -u src/tests/usr.bin/xlint/lint1/gcc_attribute_var.c:1.4 src/tests/usr.bin/xlint/lint1/gcc_attribute_var.c:1.5
--- src/tests/usr.bin/xlint/lint1/gcc_attribute_var.c:1.4	Wed Aug 11 05:08:35 2021
+++ src/tests/usr.bin/xlint/lint1/gcc_attribute_var.c	Wed Aug 11 05:19:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: gcc_attribute_var.c,v 1.4 2021/08/11 05:08:35 rillig Exp $	*/
+/*	$NetBSD: gcc_attribute_var.c,v 1.5 2021/08/11 05:19:33 rillig Exp $	*/
 # 3 "gcc_attribute_var.c"
 
 /*
@@ -65,8 +65,6 @@ ambiguity_for_attribute(void)
 
 void
 attribute_after_array_brackets(
-/* FIXME: GCC accepts this */
-/* expect+1: error: syntax error '__attribute__' [249] */
 const char *argv[] __attribute__((__unused__))
 )
 {
Index: src/tests/usr.bin/xlint/lint1/gcc_attribute_var.exp
diff -u src/tests/usr.bin/xlint/lint1/gcc_attribute_var.exp:1.4 src/tests/usr.bin/xlint/lint1/gcc_attribute_var.exp:1.5
--- src/tests/usr.bin/xlint/lint1/gcc_attribute_var.exp:1.4	Wed Aug 11 05:08:35 2021
+++ src/tests/usr.bin/xlint/lint1/gcc_attribute_var.exp	Wed Aug 11 05:19:33 2021
@@ -1,3 +1,2 @@
 gcc_attribute_var.c(59): warning: 'var2' unused in function 'ambiguity_for_attribute' [192]
-gcc_attribute_var.c(70): error: syntax error '__attribute__' [249]
-gcc_attribute_var.c(77): error: syntax error 'syntax_error' [249]
+gcc_attribute_var.c(75): error: syntax error 'syntax_error' [249]

Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.354 src/usr.bin/xlint/lint1/cgram.y:1.355
--- src/usr.bin/xlint/lint1/cgram.y:1.354	Sun Aug  1 19:18:10 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Wed Aug 11 05:19:32 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.354 2021/08/01 19:18:10 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.355 2021/08/11 05:19:32 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.354 2021/08/01 19:18:10 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.355 2021/08/11 05:19:32 rillig Exp $");
 #endif
 
 #include 
@@ -1292,10 +1292,11 @@ direct_param_declarator:
 	| T_LPAREN notype_param_declarator T_RPAREN {
 		$$ = $2;
 	  }
-	| direct_param_declarator T_LBRACK T_RBRACK {
+	| direct_param_declarator T_LBRACK T_RBRACK gcc_attribute_list_opt {
 		$$ = add_array($1, false, 0);
 	  }
-	| direct_param_declarator T_LBRACK array_size T_RBRACK {
+	| direct_param_declarator T_LBRACK array_size T_RBRACK
+	gcc_attribute_list_opt {
 		$$ = add_array($1, true, to_int_constant($3, false));
 	  }
 	| direct_param_declarator param_list asm_or_symbolrename_opt {



CVS commit: src/tests/usr.bin/xlint/lint1

2021-08-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Aug 11 05:08:35 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: gcc_attribute_var.c
gcc_attribute_var.exp

Log Message:
tests/lint: demonstrate wrong 'syntax error' for unused argument

Seen in pam_chroot.c:60.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/gcc_attribute_var.c \
src/tests/usr.bin/xlint/lint1/gcc_attribute_var.exp

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/gcc_attribute_var.c
diff -u src/tests/usr.bin/xlint/lint1/gcc_attribute_var.c:1.3 src/tests/usr.bin/xlint/lint1/gcc_attribute_var.c:1.4
--- src/tests/usr.bin/xlint/lint1/gcc_attribute_var.c:1.3	Sun Jul 11 15:07:39 2021
+++ src/tests/usr.bin/xlint/lint1/gcc_attribute_var.c	Wed Aug 11 05:08:35 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: gcc_attribute_var.c,v 1.3 2021/07/11 15:07:39 rillig Exp $	*/
+/*	$NetBSD: gcc_attribute_var.c,v 1.4 2021/08/11 05:08:35 rillig Exp $	*/
 # 3 "gcc_attribute_var.c"
 
 /*
@@ -63,6 +63,15 @@ ambiguity_for_attribute(void)
 	}
 }
 
+void
+attribute_after_array_brackets(
+/* FIXME: GCC accepts this */
+/* expect+1: error: syntax error '__attribute__' [249] */
+const char *argv[] __attribute__((__unused__))
+)
+{
+}
+
 /* just to trigger _some_ error, to keep the .exp file */
 /* expect+1: error: syntax error 'syntax_error' [249] */
 __attribute__((syntax_error));
Index: src/tests/usr.bin/xlint/lint1/gcc_attribute_var.exp
diff -u src/tests/usr.bin/xlint/lint1/gcc_attribute_var.exp:1.3 src/tests/usr.bin/xlint/lint1/gcc_attribute_var.exp:1.4
--- src/tests/usr.bin/xlint/lint1/gcc_attribute_var.exp:1.3	Sun Jul 11 15:07:39 2021
+++ src/tests/usr.bin/xlint/lint1/gcc_attribute_var.exp	Wed Aug 11 05:08:35 2021
@@ -1,2 +1,3 @@
 gcc_attribute_var.c(59): warning: 'var2' unused in function 'ambiguity_for_attribute' [192]
-gcc_attribute_var.c(68): error: syntax error 'syntax_error' [249]
+gcc_attribute_var.c(70): error: syntax error '__attribute__' [249]
+gcc_attribute_var.c(77): error: syntax error 'syntax_error' [249]



CVS commit: src

2021-08-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Aug 10 20:43:13 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_115.c msg_115.exp
src/usr.bin/xlint/lint1: decl.c init.c tree.c

Log Message:
lint: fix 3 of the 4 wrong messages about lvalue in initial assignment


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_115.c
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_115.exp
cvs rdiff -u -r1.220 -r1.221 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.206 -r1.207 src/usr.bin/xlint/lint1/init.c
cvs rdiff -u -r1.331 -r1.332 src/usr.bin/xlint/lint1/tree.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_115.c
diff -u src/tests/usr.bin/xlint/lint1/msg_115.c:1.6 src/tests/usr.bin/xlint/lint1/msg_115.c:1.7
--- src/tests/usr.bin/xlint/lint1/msg_115.c:1.6	Sat Jul 31 10:09:03 2021
+++ src/tests/usr.bin/xlint/lint1/msg_115.c	Tue Aug 10 20:43:13 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_115.c,v 1.6 2021/07/31 10:09:03 rillig Exp $	*/
+/*	$NetBSD: msg_115.c,v 1.7 2021/08/10 20:43:13 rillig Exp $	*/
 # 3 "msg_115.c"
 
 // Test for message: %soperand of '%s' must be modifiable lvalue [115]
@@ -30,21 +30,18 @@ initialize_const_struct_member(void)
 	/* expect+1: warning: left operand of '=' must be modifiable lvalue [115] */
 	const_member cm1 = (const_member) { 12345 };
 	if (cm1.member != 0)
-		/* FIXME: In a function call, const members can be assigned. */
-		/* expect+1: warning: left operand of 'farg' must be modifiable lvalue [115] */
+		/* In a function call, const members can be assigned. */
 		take_const_member(cm1);
 
 	struct {
 		const_member member;
 	} cm2 = {
-	/* FIXME: In an initialization, const members can be assigned. */
-	/* expect+1: warning: left operand of 'init' must be modifiable lvalue [115] */
+	/* In an initialization, const members can be assigned. */
 	cm1,
 	};
 	if (cm2.member.member != 0) {
 	}
 
-	/* FIXME: In a return statement, const members can be assigned. */
-	/* expect+1: warning: left operand of 'return' must be modifiable lvalue [115] */
+	/* In a return statement, const members can be assigned. */
 	return cm1;
 }

Index: src/tests/usr.bin/xlint/lint1/msg_115.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_115.exp:1.5 src/tests/usr.bin/xlint/lint1/msg_115.exp:1.6
--- src/tests/usr.bin/xlint/lint1/msg_115.exp:1.5	Sat Jul 31 10:09:03 2021
+++ src/tests/usr.bin/xlint/lint1/msg_115.exp	Tue Aug 10 20:43:13 2021
@@ -6,6 +6,3 @@ msg_115.c(14): warning: left operand of 
 msg_115.c(15): warning: left operand of '%=' must be modifiable lvalue [115]
 msg_115.c(16): warning: operand of 'x++' must be modifiable lvalue [115]
 msg_115.c(31): warning: left operand of '=' must be modifiable lvalue [115]
-msg_115.c(35): warning: left operand of 'farg' must be modifiable lvalue [115]
-msg_115.c(42): warning: left operand of 'init' must be modifiable lvalue [115]
-msg_115.c(49): warning: left operand of 'return' must be modifiable lvalue [115]

Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.220 src/usr.bin/xlint/lint1/decl.c:1.221
--- src/usr.bin/xlint/lint1/decl.c:1.220	Tue Aug 10 19:52:14 2021
+++ src/usr.bin/xlint/lint1/decl.c	Tue Aug 10 20:43:12 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.220 2021/08/10 19:52:14 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.221 2021/08/10 20:43:12 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.220 2021/08/10 19:52:14 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.221 2021/08/10 20:43:12 rillig Exp $");
 #endif
 
 #include 
@@ -209,7 +209,13 @@ expr_unqualified_type(const type_t *tp)
 	ntp->t_const = false;
 	ntp->t_volatile = false;
 
-	/* TODO: deep-copy struct/union members; see msg_115.c */
+	/*
+	 * In case of a struct or union type, the members should lose their
+	 * qualifiers as well, but that would require a deep copy of the
+	 * struct or union type.  This in turn would defeat the type
+	 * comparison in eqtype, which simply tests whether tp1->t_str ==
+	 * tp2->t_str.
+	 */
 
 	return ntp;
 }

Index: src/usr.bin/xlint/lint1/init.c
diff -u src/usr.bin/xlint/lint1/init.c:1.206 src/usr.bin/xlint/lint1/init.c:1.207
--- src/usr.bin/xlint/lint1/init.c:1.206	Sat Jul 31 19:07:52 2021
+++ src/usr.bin/xlint/lint1/init.c	Tue Aug 10 20:43:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: init.c,v 1.206 2021/07/31 19:07:52 rillig Exp $	*/
+/*	$NetBSD: init.c,v 1.207 2021/08/10 20:43:12 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: init.c,v 1.206 2021/07/31 19:07:52 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.207 2021/08/10 20:43:12 rillig Exp $");
 #endif
 
 #include 
@@ -833,6

CVS commit: src/usr.bin/xlint/lint1

2021-08-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Aug 10 19:52:14 UTC 2021

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

Log Message:
lint: remove redundant test for negative bit-field size

A bit-field can never have negative size.  Its type is an unsigned
integer.

Strangely, GCC 10.3.0 only complains about this if the extra struct
level lint1_type.t_b is removed.  Clang 12.0.1 does not complain at all.


To generate a diff of this commit:
cvs rdiff -u -r1.219 -r1.220 src/usr.bin/xlint/lint1/decl.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/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.219 src/usr.bin/xlint/lint1/decl.c:1.220
--- src/usr.bin/xlint/lint1/decl.c:1.219	Tue Aug  3 21:18:24 2021
+++ src/usr.bin/xlint/lint1/decl.c	Tue Aug 10 19:52:14 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.219 2021/08/03 21:18:24 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.220 2021/08/10 19:52:14 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.219 2021/08/03 21:18:24 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.220 2021/08/10 19:52:14 rillig Exp $");
 #endif
 
 #include 
@@ -1151,7 +1151,7 @@ declare_bit_field(sym_t *dsym, tspec_t *
 
 	type_t *const tp = *inout_tp;
 	tspec_t const t = *inout_t;
-	if (tp->t_flen < 0 || tp->t_flen > (ssize_t)size_in_bits(t)) {
+	if (tp->t_flen > size_in_bits(t)) {
 		/* illegal bit-field size: %d */
 		error(36, tp->t_flen);
 		tp->t_flen = size_in_bits(t);



CVS commit: src/usr.bin/xlint/lint1

2021-08-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Aug 10 17:57:16 UTC 2021

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

Log Message:
lint: remove redundant function prototypes


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/usr.bin/xlint/lint1/mem1.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/mem1.c
diff -u src/usr.bin/xlint/lint1/mem1.c:1.48 src/usr.bin/xlint/lint1/mem1.c:1.49
--- src/usr.bin/xlint/lint1/mem1.c:1.48	Tue Aug 10 17:31:44 2021
+++ src/usr.bin/xlint/lint1/mem1.c	Tue Aug 10 17:57:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mem1.c,v 1.48 2021/08/10 17:31:44 rillig Exp $	*/
+/*	$NetBSD: mem1.c,v 1.49 2021/08/10 17:57:16 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: mem1.c,v 1.48 2021/08/10 17:31:44 rillig Exp $");
+__RCSID("$NetBSD: mem1.c,v 1.49 2021/08/10 17:57:16 rillig Exp $");
 #endif
 
 #include 
@@ -205,9 +205,6 @@ static	memory_block	*frmblks;
 /* length of new allocated memory blocks */
 static	size_t	mblklen;
 
-static	void	*xgetblk(memory_block **, size_t);
-static	void	xfreeblk(memory_block **);
-static	memory_block *xnewblk(void);
 
 static memory_block *
 xnewblk(void)



CVS commit: src/usr.bin/xlint

2021-08-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Aug 10 17:31:44 UTC 2021

Modified Files:
src/usr.bin/xlint/common: lint.h
src/usr.bin/xlint/lint1: mem1.c
src/usr.bin/xlint/lint2: externs2.h

Log Message:
lint: clean up comments


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/usr.bin/xlint/common/lint.h
cvs rdiff -u -r1.47 -r1.48 src/usr.bin/xlint/lint1/mem1.c
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/xlint/lint2/externs2.h

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/common/lint.h
diff -u src/usr.bin/xlint/common/lint.h:1.27 src/usr.bin/xlint/common/lint.h:1.28
--- src/usr.bin/xlint/common/lint.h:1.27	Sat Apr 10 18:36:27 2021
+++ src/usr.bin/xlint/common/lint.h	Tue Aug 10 17:31:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lint.h,v 1.27 2021/04/10 18:36:27 rillig Exp $	*/
+/*	$NetBSD: lint.h,v 1.28 2021/08/10 17:31:44 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -80,7 +80,7 @@ typedef enum {
 	PTR,		/* pointer */
 	ARRAY,		/* array */
 	FUNC,		/* function */
-	COMPLEX,	/* _Complex */
+	COMPLEX,	/* keyword "_Complex", only used in the parser */
 	FCOMPLEX,	/* float _Complex */
 	DCOMPLEX,	/* double _Complex */
 	LCOMPLEX	/* long double _Complex */

Index: src/usr.bin/xlint/lint1/mem1.c
diff -u src/usr.bin/xlint/lint1/mem1.c:1.47 src/usr.bin/xlint/lint1/mem1.c:1.48
--- src/usr.bin/xlint/lint1/mem1.c:1.47	Sun Aug  1 18:07:35 2021
+++ src/usr.bin/xlint/lint1/mem1.c	Tue Aug 10 17:31:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mem1.c,v 1.47 2021/08/01 18:07:35 rillig Exp $	*/
+/*	$NetBSD: mem1.c,v 1.48 2021/08/10 17:31:44 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: mem1.c,v 1.47 2021/08/01 18:07:35 rillig Exp $");
+__RCSID("$NetBSD: mem1.c,v 1.48 2021/08/10 17:31:44 rillig Exp $");
 #endif
 
 #include 
@@ -297,7 +297,7 @@ initmem(void)
 }
 
 
-/* Allocate memory associated with level l. */
+/* Allocate memory associated with level l, initialized with zero. */
 void *
 getlblk(size_t l, size_t s)
 {
@@ -310,6 +310,10 @@ getlblk(size_t l, size_t s)
 	return xgetblk(&mblks[l], s);
 }
 
+/*
+ * Return allocated memory for the current mem_block_level, initialized with
+ * zero.
+ */
 void *
 getblk(size_t s)
 {

Index: src/usr.bin/xlint/lint2/externs2.h
diff -u src/usr.bin/xlint/lint2/externs2.h:1.9 src/usr.bin/xlint/lint2/externs2.h:1.10
--- src/usr.bin/xlint/lint2/externs2.h:1.9	Sat Jan 16 02:40:02 2021
+++ src/usr.bin/xlint/lint2/externs2.h	Tue Aug 10 17:31:44 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: externs2.h,v 1.9 2021/01/16 02:40:02 rillig Exp $ */
+/* $NetBSD: externs2.h,v 1.10 2021/08/10 17:31:44 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -33,7 +33,7 @@
  */
 
 /*
- * main.c
+ * main2.c
  */
 extern	bool	xflag;
 extern	bool	uflag;



CVS commit: src/usr.bin/xlint/lint1

2021-08-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Aug 10 16:59:28 UTC 2021

Modified Files:
src/usr.bin/xlint/lint1: ops.def

Log Message:
lint: fix documentation of FARG and PUSH


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/xlint/lint1/ops.def

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/ops.def
diff -u src/usr.bin/xlint/lint1/ops.def:1.22 src/usr.bin/xlint/lint1/ops.def:1.23
--- src/usr.bin/xlint/lint1/ops.def:1.22	Tue Aug 10 07:02:00 2021
+++ src/usr.bin/xlint/lint1/ops.def	Tue Aug 10 16:59:28 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ops.def,v 1.22 2021/08/10 07:02:00 rillig Exp $ */
+/*	$NetBSD: ops.def,v 1.23 2021/08/10 16:59:28 rillig Exp $ */
 
 begin_ops()
 
@@ -93,6 +93,12 @@ op(	COMMA,	",",		1,-,1,-,-,-,-,-,-,-,-,-
 op(	CVT,	"convert",	-,-,-,-,-,-,-,-,-,1,-,-,-,-,-,-,-,-,-,-)
 op(	ICALL,	"icall",	1,-,-,-,-,-,-,-,-,-,-,-,1,-,-,-,-,-,-,-)
 op(	LOAD,	"load",		-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-)
+/*
+ * PUSH is a virtual node that is used to concatenate arguments in a function
+ * call expression.  The PUSH nodes are ordered from right to left.  For
+ * example, the function call f(17, 23) is represented as
+ * CALL(f, PUSH(23, PUSH(17, NULL))).
+ */
 op(	PUSH,	"push",		-,-,-,-,-,-,-,-,-,1,-,-,-,-,-,-,-,-,-,-)
 op(	RETURN,	"return",	1,-,1,-,-,-,-,-,-,-,-,-,1,-,-,-,-,1,-,-)
 op(	REAL,	"real",		-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-)
@@ -102,17 +108,11 @@ op(	IMAG,	"imag",		-,-,-,-,-,-,-,-,-,-,-
 /*	name	repr		b l b B i c a s f v t b s l r p c e e = */
 op(	INIT,	"init",		1,-,1,-,-,-,-,-,-,-,-,-,-,-,-,-,-,1,-,-)
 op(	CASE,	"case",		-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-)
-op(	FARG,	"farg",		1,-,1,-,-,-,-,-,-,-,-,-,-,-,-,-,-,1,-,-)
-
 /*
- * Both FARG and PUSH represent function arguments.  FARG is used in the
- * early phase of analysis, when the node is not yet part of a function call
- * expression (CALL or ICALL).  Later, build_function_argument builds a
- * function call expression out of the FARG nodes, where they become PUSH.
- * In a function call expression, the PUSH nodes are ordered from right to
- * left, that is, the function call f(17, 23) is represented as
- * CALL(f, PUSH(23, PUSH(17, NULL))).
+ * FARG is only used temporarily in check_prototype_argument to check type
+ * compatibility and conversion for function arguments.
  */
+op(	FARG,	"farg",		1,-,1,-,-,-,-,-,-,-,-,-,-,-,-,-,-,1,-,-)
 
 end_ops()
 



CVS commit: src/usr.bin/xlint/lint1

2021-08-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Aug 10 07:02:00 UTC 2021

Modified Files:
src/usr.bin/xlint/lint1: ops.def

Log Message:
lint: document the difference between FARG and PUSH


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/xlint/lint1/ops.def

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/ops.def
diff -u src/usr.bin/xlint/lint1/ops.def:1.21 src/usr.bin/xlint/lint1/ops.def:1.22
--- src/usr.bin/xlint/lint1/ops.def:1.21	Tue Aug 10 06:31:16 2021
+++ src/usr.bin/xlint/lint1/ops.def	Tue Aug 10 07:02:00 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ops.def,v 1.21 2021/08/10 06:31:16 rillig Exp $ */
+/*	$NetBSD: ops.def,v 1.22 2021/08/10 07:02:00 rillig Exp $ */
 
 begin_ops()
 
@@ -104,6 +104,16 @@ op(	INIT,	"init",		1,-,1,-,-,-,-,-,-,-,-
 op(	CASE,	"case",		-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-)
 op(	FARG,	"farg",		1,-,1,-,-,-,-,-,-,-,-,-,-,-,-,-,-,1,-,-)
 
+/*
+ * Both FARG and PUSH represent function arguments.  FARG is used in the
+ * early phase of analysis, when the node is not yet part of a function call
+ * expression (CALL or ICALL).  Later, build_function_argument builds a
+ * function call expression out of the FARG nodes, where they become PUSH.
+ * In a function call expression, the PUSH nodes are ordered from right to
+ * left, that is, the function call f(17, 23) is represented as
+ * CALL(f, PUSH(23, PUSH(17, NULL))).
+ */
+
 end_ops()
 
 #ifndef NOPS



CVS commit: src/usr.bin/xlint/lint1

2021-08-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Aug 10 06:31:16 UTC 2021

Modified Files:
src/usr.bin/xlint/lint1: ops.def

Log Message:
lint: document operator properties directly at the definition


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/xlint/lint1/ops.def

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/ops.def
diff -u src/usr.bin/xlint/lint1/ops.def:1.20 src/usr.bin/xlint/lint1/ops.def:1.21
--- src/usr.bin/xlint/lint1/ops.def:1.20	Thu Apr  1 14:59:21 2021
+++ src/usr.bin/xlint/lint1/ops.def	Tue Aug 10 06:31:16 2021
@@ -1,9 +1,31 @@
-/*	$NetBSD: ops.def,v 1.20 2021/04/01 14:59:21 rillig Exp $ */
+/*	$NetBSD: ops.def,v 1.21 2021/08/10 06:31:16 rillig Exp $ */
 
 begin_ops()
 
-/* See mod_t in op.h for the definition of the table columns. */
-
+/*
+ * Operator properties; see mod_t in op.h.
+ *
+ * 	warn if operand '='	  x
+ *	bad on enum		x
+ *	valid on enum		  x
+ *	comparison		- - - - - - - - - - - - - - - - x
+ *	possible precedence confusion			  x	|
+ *	warn if right operand unsigned			x	|
+ *	warn if left operand unsigned			  x	|
+ *	has side effects	- - - - - - - - - - - - x	|
+ *	balance operands			  x	|	|
+ *	left test context			x	|	|
+ *	left value context			  x	|	|
+ *	fold constant operands	- - - - - - - - x	|	|
+ *	requires scalar			  x	|	|	|
+ *	requires arithmetic		x	|	|	|
+ *	requires integer or complex	  x	|	|	|
+ *	requires integer	- - - - x	|	|	|
+ *	requires _Bool		  x	|	|	|	|
+ *	takes _Bool		x	|	|	|	|
+ *	logical			  x	|	|	|	|
+ *	binary			x	|	|	|	|
+ */
 /*	name	repr		b l b B i c a s f v t b s l r p c e e =	*/
 op(	NOOP,	"no-op",	-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-)
 op(	ARROW,	"->",		1,-,1,-,-,-,-,-,-,1,-,-,-,-,-,-,-,-,-,-)



CVS commit: src/usr.bin/xlint/xlint

2021-08-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Aug  9 21:27:20 UTC 2021

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

Log Message:
lint: remove commented-out preprocessor options

These have been commented out since 2002.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/usr.bin/xlint/xlint/xlint.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/xlint/xlint.c
diff -u src/usr.bin/xlint/xlint/xlint.c:1.71 src/usr.bin/xlint/xlint/xlint.c:1.72
--- src/usr.bin/xlint/xlint/xlint.c:1.71	Sun Aug  8 16:19:18 2021
+++ src/usr.bin/xlint/xlint/xlint.c	Mon Aug  9 21:27:20 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: xlint.c,v 1.71 2021/08/08 16:19:18 rillig Exp $ */
+/* $NetBSD: xlint.c,v 1.72 2021/08/09 21:27:20 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: xlint.c,v 1.71 2021/08/08 16:19:18 rillig Exp $");
+__RCSID("$NetBSD: xlint.c,v 1.72 2021/08/09 21:27:20 rillig Exp $");
 #endif
 
 #include 
@@ -341,18 +341,10 @@ main(int argc, char *argv[])
 	pass_to_cpp("-E");
 	pass_to_cpp("-x");
 	pass_to_cpp("c");
-#if 0
-	pass_to_cpp("-D__attribute__(x)=");
-	pass_to_cpp("-D__extension__(x)=/*NOSTRICT*/0");
-#else
 	pass_to_cpp("-U__GNUC__");
 	pass_to_cpp("-U__PCC__");
 	pass_to_cpp("-U__SSE__");
 	pass_to_cpp("-U__SSE4_1__");
-#endif
-#if 0
-	pass_to_cpp("-Wp,-$");
-#endif
 	pass_to_cpp("-Wp,-CC");
 	pass_to_cpp("-Wcomment");
 	pass_to_cpp("-D__LINT__");



CVS commit: src/usr.bin/xlint/xlint

2021-08-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Aug  9 20:52:24 UTC 2021

Modified Files:
src/usr.bin/xlint/xlint: pathnames.h

Log Message:
lint: remove unused pathname


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/xlint/xlint/pathnames.h

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/xlint/pathnames.h
diff -u src/usr.bin/xlint/xlint/pathnames.h:1.6 src/usr.bin/xlint/xlint/pathnames.h:1.7
--- src/usr.bin/xlint/xlint/pathnames.h:1.6	Sun Jan 24 16:55:09 2021
+++ src/usr.bin/xlint/xlint/pathnames.h	Mon Aug  9 20:52:24 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pathnames.h,v 1.6 2021/01/24 16:55:09 rillig Exp $	*/
+/*	$NetBSD: pathnames.h,v 1.7 2021/08/09 20:52:24 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -36,9 +36,6 @@
 #define	PATH_LIBEXEC		"/usr/libexec"
 #endif
 
-/* directory where cc(1) resides */
-#define	PATH_USRBIN		"/usr/bin"
-
 /* default library search path */
 #ifndef PATH_LINTLIB
 #define PATH_LINTLIB		"/usr/libdata/lint"



CVS commit: src

2021-08-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Aug  9 20:07:24 UTC 2021

Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/usr.bin/xlint/lint1: Makefile
src/usr.bin/xlint/lint1: err.c tree.c
Added Files:
src/tests/usr.bin/xlint/lint1: msg_346.c msg_346.exp

Log Message:
lint: warn about 'char * = strchr(const char *, int)'

Found in findcc.c, there are about 25 other instances of this
incongruency in the whole source tree.

For more examples of functions from the C Standard Library that
implicitly remove the 'const' qualifier from an argument, see the C++
include file 'cstring'.


To generate a diff of this commit:
cvs rdiff -u -r1.1108 -r1.1109 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.102 -r1.103 src/tests/usr.bin/xlint/lint1/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint1/msg_346.c \
src/tests/usr.bin/xlint/lint1/msg_346.exp
cvs rdiff -u -r1.134 -r1.135 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.330 -r1.331 src/usr.bin/xlint/lint1/tree.c

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1108 src/distrib/sets/lists/tests/mi:1.1109
--- src/distrib/sets/lists/tests/mi:1.1108	Sun Aug  8 00:02:02 2021
+++ src/distrib/sets/lists/tests/mi	Mon Aug  9 20:07:23 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1108 2021/08/08 00:02:02 rillig Exp $
+# $NetBSD: mi,v 1.1109 2021/08/09 20:07:23 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -7004,6 +7004,8 @@
 ./usr/tests/usr.bin/xlint/lint1/msg_344.exp			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_345.c			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/msg_345.exp			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_346.c			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_346.exp			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/op_colon.c			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/op_colon.exp			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/op_shl_lp64.c			tests-usr.bin-tests	compattestfile,atf

Index: src/tests/usr.bin/xlint/lint1/Makefile
diff -u src/tests/usr.bin/xlint/lint1/Makefile:1.102 src/tests/usr.bin/xlint/lint1/Makefile:1.103
--- src/tests/usr.bin/xlint/lint1/Makefile:1.102	Thu Aug  5 06:34:43 2021
+++ src/tests/usr.bin/xlint/lint1/Makefile	Mon Aug  9 20:07:24 2021
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.102 2021/08/05 06:34:43 rillig Exp $
+# $NetBSD: Makefile,v 1.103 2021/08/09 20:07:24 rillig Exp $
 
 NOMAN=		# defined
-MAX_MESSAGE=	345		# see lint1/err.c
+MAX_MESSAGE=	346		# see lint1/err.c
 
 .include 
 

Index: src/usr.bin/xlint/lint1/err.c
diff -u src/usr.bin/xlint/lint1/err.c:1.134 src/usr.bin/xlint/lint1/err.c:1.135
--- src/usr.bin/xlint/lint1/err.c:1.134	Tue Aug  3 20:57:06 2021
+++ src/usr.bin/xlint/lint1/err.c	Mon Aug  9 20:07:23 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: err.c,v 1.134 2021/08/03 20:57:06 rillig Exp $	*/
+/*	$NetBSD: err.c,v 1.135 2021/08/09 20:07:23 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.134 2021/08/03 20:57:06 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.135 2021/08/09 20:07:23 rillig Exp $");
 #endif
 
 #include 
@@ -400,6 +400,7 @@ const char *const msgs[] = {
 	"static array size is a C11 extension",			  /* 343 */
 	"bit-field of type plain 'int' has implementation-defined signedness", /* 344 */
 	"generic selection requires C11 or later",		  /* 345 */
+	"call to '%s' effectively discards 'const' from argument",/* 346 */
 };
 
 static struct include_level {

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.330 src/usr.bin/xlint/lint1/tree.c:1.331
--- src/usr.bin/xlint/lint1/tree.c:1.330	Tue Aug  3 21:09:26 2021
+++ src/usr.bin/xlint/lint1/tree.c	Mon Aug  9 20:07:23 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.330 2021/08/03 21:09:26 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.331 2021/08/09 20:07:23 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.330 2021/08/03 21:09:26 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.331 2021/08/09 20:07:23 rillig Exp $");
 #endif
 
 #include 
@@ -1346,6 +1346,63 @@ check_pointer_comparison(op_t op, const 
 	}
 }
 
+static bool
+is_direct_function_call(const tnode_t *tn, const char *name)
+{
+	return tn->tn_op == CALL &&
+	   tn->tn_left->tn_op == ADDR &&
+	   tn->tn_left->tn_left->tn_op == NAME &&
+	   strcmp(tn->tn_left->tn_left->tn_sym->s_name, name) == 0;
+}
+
+static bool
+is_const_char_pointer(const tnode_t *tn)
+{
+	const type_t *tp;
+
+	/

CVS commit: src/tests/usr.bin/xlint/lint2

2021-08-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  8 16:35:15 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint2: Makefile t_lint2.sh

Log Message:
tests/lint: include but don't run read_lp64 on 32-bit platforms

The lint1 tests are all in the machine-independent file list, which
makes it easier to manage them.  At run time, some of them are skipped
based on platform characteristics.  Do the same for the lint2 tests.

Having the lint2 test named read_lp64 as the only machine-dependent test
would complicate things.

The build for i386 had failed because the files for read_lp64 were
listed in distrib/sets/lists/tests/mi but were not actually installed.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint2/Makefile
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint2/t_lint2.sh

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

Modified files:

Index: src/tests/usr.bin/xlint/lint2/Makefile
diff -u src/tests/usr.bin/xlint/lint2/Makefile:1.5 src/tests/usr.bin/xlint/lint2/Makefile:1.6
--- src/tests/usr.bin/xlint/lint2/Makefile:1.5	Sun Aug  8 13:22:22 2021
+++ src/tests/usr.bin/xlint/lint2/Makefile	Sun Aug  8 16:35:15 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.5 2021/08/08 13:22:22 rillig Exp $
+# $NetBSD: Makefile,v 1.6 2021/08/08 16:35:15 rillig Exp $
 
 NOMAN=		yes
 
@@ -6,7 +6,7 @@ NOMAN=		yes
 
 TESTSDIR=	${TESTSBASE}/usr.bin/xlint/lint2
 
-TESTS_SH=		t_lint2
+TESTS_SH=	t_lint2
 
 FILESDIR=	${TESTSDIR}
 
@@ -16,9 +16,7 @@ FILESDIR=	${TESTSDIR}
 TESTS+=		msg_${msg}
 .endfor
 TESTS+=		read
-.if ${MACHINE_ARCH:M*64} && !${MACHINE_ARCH:Mmips64*}
-TESTS+=		read_lp64	# only on 64-bit platforms
-.endif
+TESTS+=		read_lp64
 TESTS+=		read_printf
 
 FILES+=		${TESTS:=.ln} ${TESTS:=.exp}

Index: src/tests/usr.bin/xlint/lint2/t_lint2.sh
diff -u src/tests/usr.bin/xlint/lint2/t_lint2.sh:1.4 src/tests/usr.bin/xlint/lint2/t_lint2.sh:1.5
--- src/tests/usr.bin/xlint/lint2/t_lint2.sh:1.4	Sun Aug  8 00:02:02 2021
+++ src/tests/usr.bin/xlint/lint2/t_lint2.sh	Sun Aug  8 16:35:15 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_lint2.sh,v 1.4 2021/08/08 00:02:02 rillig Exp $
+# $NetBSD: t_lint2.sh,v 1.5 2021/08/08 16:35:15 rillig Exp $
 #
 # Copyright (c) 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -51,6 +51,15 @@ atf_init_test_cases()
 	# shellcheck disable=SC2013
 	for i in $(cd "$(atf_get_srcdir)" && echo *.ln); do
 		i=${i%.ln}
+
+		case "$i" in
+		*lp64*)
+			case "$(uname -p)" in
+			*64) ;;
+			*) continue
+			esac
+		esac
+
 		eval "${i}_head() { std_head; }"
 		eval "${i}_body() { std_body '$i'; }"
 		atf_add_test_case "$i"



CVS commit: src/usr.bin/xlint/xlint

2021-08-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  8 16:19:18 UTC 2021

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

Log Message:
lint: group global variables by the subprocess

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/usr.bin/xlint/xlint/xlint.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/xlint/xlint.c
diff -u src/usr.bin/xlint/xlint/xlint.c:1.70 src/usr.bin/xlint/xlint/xlint.c:1.71
--- src/usr.bin/xlint/xlint/xlint.c:1.70	Sun Aug  8 16:11:08 2021
+++ src/usr.bin/xlint/xlint/xlint.c	Sun Aug  8 16:19:18 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: xlint.c,v 1.70 2021/08/08 16:11:08 rillig Exp $ */
+/* $NetBSD: xlint.c,v 1.71 2021/08/08 16:19:18 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: xlint.c,v 1.70 2021/08/08 16:11:08 rillig Exp $");
+__RCSID("$NetBSD: xlint.c,v 1.71 2021/08/08 16:19:18 rillig Exp $");
 #endif
 
 #include 
@@ -61,38 +61,30 @@ __RCSID("$NetBSD: xlint.c,v 1.70 2021/08
 
 #define DEFAULT_PATH		_PATH_DEFPATH
 
-/* directory for temporary files */
-static	const	char *tmpdir;
-
-/* path name for cpp output */
-static	char	*cppout;
-
-/* file descriptor for cpp output */
-static	int	cppoutfd = -1;
-
-/* files created by 1st pass */
-static	char	**p1out;
-
-/* input files for 2nd pass (without libraries) */
-static	char	**p2in;
-
-/* library which will be created by 2nd pass */
-static	char	*p2out;
+/* Parameters for the C preprocessor. */
+static struct {
+	char	**flags;	/* flags always passed */
+	char	**lcflags;	/* flags, controlled by sflag/tflag */
+	char	*outfile;	/* path name for preprocessed C source */
+	int	outfd;		/* file descriptor for outfile */
+} cpp = { NULL, NULL, NULL, -1 };
+
+/* Parameters for lint1, which checks an isolated translation unit. */
+static struct {
+	char	**flags;
+	char	**outfiles;
+} lint1;
+
+/* Parameters for lint2, which performs cross-translation-unit checks. */
+static struct {
+	char	**flags;
+	char	**infiles;	/* input files (without libraries) */
+	char	**inlibs;	/* input libraries */
+	char	*outlib;	/* output library that will be created */
+} lint2;
 
-/* flags always passed to cc(1) */
-static	char	**cflags;
-
-/* flags for cc(1), controlled by sflag/tflag */
-static	char	**lcflags;
-
-/* flags for lint1 */
-static	char	**l1flags;
-
-/* flags for lint2 */
-static	char	**l2flags;
-
-/* libraries for lint2 */
-static	char	**l2libs;
+/* directory for temporary files */
+static	const char *tmpdir;
 
 /* default libraries */
 static	char	**deflibs;
@@ -136,7 +128,7 @@ static	void	fname(const char *);
 static	void	runchild(const char *, char *const *, const char *, int);
 static	void	findlibs(char *const *);
 static	bool	rdok(const char *);
-static	void	lint2(void);
+static	void	run_lint2(void);
 static	void	cat(char *const *, const char *);
 
 static char **
@@ -207,21 +199,21 @@ static void
 pass_to_lint1(const char *opt)
 {
 
-	list_add_copy(&l1flags, opt);
+	list_add_copy(&lint1.flags, opt);
 }
 
 static void
 pass_to_lint2(const char *opt)
 {
 
-	list_add_copy(&l2flags, opt);
+	list_add_copy(&lint2.flags, opt);
 }
 
 static void
 pass_to_cpp(const char *opt)
 {
 
-	list_add_copy(&cflags, opt);
+	list_add_copy(&cpp.flags, opt);
 }
 
 static char *
@@ -244,23 +236,23 @@ terminate(int signo)
 {
 	int	i;
 
-	if (cppoutfd != -1)
-		(void)close(cppoutfd);
-	if (cppout != NULL) {
+	if (cpp.outfd != -1)
+		(void)close(cpp.outfd);
+	if (cpp.outfile != NULL) {
 		if (signo != 0 && getenv("LINT_KEEP_CPPOUT_ON_ERROR") != NULL)
 			printf("lint: preprocessor output kept in %s\n",
-			cppout);
+			cpp.outfile);
 		else
-			(void)remove(cppout);
+			(void)remove(cpp.outfile);
 	}
 
-	if (p1out != NULL) {
-		for (i = 0; p1out[i] != NULL; i++)
-			(void)remove(p1out[i]);
+	if (lint1.outfiles != NULL) {
+		for (i = 0; lint1.outfiles[i] != NULL; i++)
+			(void)remove(lint1.outfiles[i]);
 	}
 
-	if (p2out != NULL)
-		(void)remove(p2out);
+	if (lint2.outlib != NULL)
+		(void)remove(lint2.outlib);
 
 	if (currfn != NULL)
 		(void)remove(currfn);
@@ -328,20 +320,20 @@ main(int argc, char *argv[])
 		tmpdir = concat2(tmp, tmp[len - 1] == '/' ? "" : "/");
 	}
 
-	cppout = concat2(tmpdir, "lint0.XX");
-	cppoutfd = mkstemp(cppout);
-	if (cppoutfd == -1) {
+	cpp.outfile = concat2(tmpdir, "lint0.XX");
+	cpp.outfd = mkstemp(cpp.outfile);
+	if (cpp.outfd == -1) {
 		warn("can't make temp");
 		terminate(-1);
 	}
 
-	p1out = list_new();
-	p2in = list_new();
-	cflags = list_new();
-	lcflags = list_new();
-	l1flags = list_new();
-	l2flags = list_new();
-	l2libs = list_new();
+	lint1.outfiles = list_new();
+	lint2.infiles = list_new();
+	cpp.flags = list_new();
+	cpp.lcflags = list_new();
+	lint1.flags = list_new();
+	lint2.flags = list_new();
+	lint2.inli

CVS commit: src/usr.bin/xlint/xlint

2021-08-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  8 16:11:08 UTC 2021

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

Log Message:
lint: rename list_free to list_clear

The previous name suggested that the function would free the list
itself, which it doesn't.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/usr.bin/xlint/xlint/xlint.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/xlint/xlint.c
diff -u src/usr.bin/xlint/xlint/xlint.c:1.69 src/usr.bin/xlint/xlint/xlint.c:1.70
--- src/usr.bin/xlint/xlint/xlint.c:1.69	Sun Aug  8 15:29:24 2021
+++ src/usr.bin/xlint/xlint/xlint.c	Sun Aug  8 16:11:08 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: xlint.c,v 1.69 2021/08/08 15:29:24 rillig Exp $ */
+/* $NetBSD: xlint.c,v 1.70 2021/08/08 16:11:08 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: xlint.c,v 1.69 2021/08/08 15:29:24 rillig Exp $");
+__RCSID("$NetBSD: xlint.c,v 1.70 2021/08/08 16:11:08 rillig Exp $");
 #endif
 
 #include 
@@ -189,7 +189,7 @@ list_add_all(char ***destp, char *const 
 }
 
 static void
-list_free(char ***lstp)
+list_clear(char ***lstp)
 {
 	char	*s;
 	int	i;
@@ -420,14 +420,14 @@ main(int argc, char *argv[])
 			break;
 
 		case 'n':
-			list_free(&deflibs);
+			list_clear(&deflibs);
 			break;
 
 		case 'p':
 			pass_to_lint1("-p");
 			pass_to_lint2("-p");
 			if (*deflibs != NULL) {
-list_free(&deflibs);
+list_clear(&deflibs);
 list_add_copy(&deflibs, "c");
 			}
 			break;
@@ -443,7 +443,7 @@ main(int argc, char *argv[])
 		case 's':
 			if (tflag)
 usage();
-			list_free(&lcflags);
+			list_clear(&lcflags);
 			list_add_copy(&lcflags, "-trigraphs");
 			list_add_copy(&lcflags, "-Wtrigraphs");
 			list_add_copy(&lcflags, "-pedantic");
@@ -471,7 +471,7 @@ main(int argc, char *argv[])
 		case 't':
 			if (sflag)
 usage();
-			list_free(&lcflags);
+			list_clear(&lcflags);
 			list_add_copy(&lcflags, "-traditional");
 			list_add_copy(&lcflags, "-Wtraditional");
 			list_add(&lcflags, concat2("-D", MACHINE));
@@ -492,7 +492,7 @@ main(int argc, char *argv[])
 			Cflag = true;
 			list_add(&l2flags, concat2("-C", optarg));
 			p2out = xasprintf("llib-l%s.ln", optarg);
-			list_free(&deflibs);
+			list_clear(&deflibs);
 			break;
 
 		case 'd':
@@ -705,7 +705,7 @@ fname(const char *name)
 
 	runchild(pathname, args, cppout, cppoutfd);
 	free(pathname);
-	list_free(&args);
+	list_clear(&args);
 
 	/* run lint1 */
 
@@ -727,7 +727,7 @@ fname(const char *name)
 
 	runchild(pathname, args, ofn, -1);
 	free(pathname);
-	list_free(&args);
+	list_clear(&args);
 
 	list_add_copy(&p2in, ofn);
 	free(ofn);
@@ -864,7 +864,7 @@ lint2(void)
 
 	runchild(path, args, p2out, -1);
 	free(path);
-	list_free(&args);
+	list_clear(&args);
 	free(args);
 }
 



CVS commit: src/usr.bin/xlint/xlint

2021-08-08 Thread Roland Illig
lects of C.
+Attempt to check portability of code to other platforms of C.
 .It Fl R Ar old=new
 Remap
 .Ar old
@@ -341,16 +340,15 @@ directory prefixes to
 .Ar new
 for reproducible builds.
 .It Fl r
-In case of redeclarations report the position of the
-previous declaration.
+In case of redeclarations, report the position of the previous declaration.
 .It Fl S
 C9X mode.
 Currently not fully implemented.
 .It Fl s
-Strict ANSI C mode.
-Issue warnings and errors required by ANSI C.
+Strict ANSI C89/ISO C90 mode.
+Issue warnings and errors required by ISO C90, as opposed to traditional C.
 Also do not produce warnings for constructs which behave
-differently in traditional C and ANSI C.
+differently in traditional C and ISO C90.
 With the
 .Fl s
 flag,
@@ -592,6 +590,9 @@ temporaries
 .Xr lint 7
 .Sh AUTHORS
 .An Jochen Pohl
+(1995)
+.An Roland Illig
+(2021)
 .Sh BUGS
 The routines
 .Xr exit 3 ,



CVS commit: src/usr.bin/xlint/xlint

2021-08-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  8 15:29:24 UTC 2021

Modified Files:
src/usr.bin/xlint/xlint: lint.1 xlint.c

Log Message:
lint: remove dead code for reading from stdin

Since xlint.c 1.27 from 2002-01-31, it has not been possible to read
from stdin anymore.  Apparently nobody missed this feature in the last
19 years.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/usr.bin/xlint/xlint/lint.1
cvs rdiff -u -r1.68 -r1.69 src/usr.bin/xlint/xlint/xlint.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/xlint/lint.1
diff -u src/usr.bin/xlint/xlint/lint.1:1.44 src/usr.bin/xlint/xlint/lint.1:1.45
--- src/usr.bin/xlint/xlint/lint.1:1.44	Sun May  2 21:05:42 2021
+++ src/usr.bin/xlint/xlint/lint.1	Sun Aug  8 15:29:24 2021
@@ -1,4 +1,4 @@
-.\" $NetBSD: lint.1,v 1.44 2021/05/02 21:05:42 rillig Exp $
+.\" $NetBSD: lint.1,v 1.45 2021/08/08 15:29:24 rillig Exp $
 .\"
 .\" Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
 .\" Copyright (c) 1994, 1995 Jochen Pohl
@@ -167,22 +167,6 @@ At this point, if a complaint stems not 
 but from one of its included files, the source filename will be
 printed followed by a question mark.
 .Pp
-The special input file name
-.Dq Pa -
-causes
-.Nm
-to take input from standard input (until end of file) and process
-it as if it were a
-.Pa \&.c
-file.
-If the
-.Fl i
-flag is given and
-.Dq Pa -
-is named as one of the input files, the
-.Fl o
-flag must also be specified to provide an output file name.
-.Pp
 .Sy Options
 .Bl -tag -width XoXoutputfileXXX
 .It Fl Ac11

Index: src/usr.bin/xlint/xlint/xlint.c
diff -u src/usr.bin/xlint/xlint/xlint.c:1.68 src/usr.bin/xlint/xlint/xlint.c:1.69
--- src/usr.bin/xlint/xlint/xlint.c:1.68	Sun Aug  8 15:06:44 2021
+++ src/usr.bin/xlint/xlint/xlint.c	Sun Aug  8 15:29:24 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: xlint.c,v 1.68 2021/08/08 15:06:44 rillig Exp $ */
+/* $NetBSD: xlint.c,v 1.69 2021/08/08 15:29:24 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: xlint.c,v 1.68 2021/08/08 15:06:44 rillig Exp $");
+__RCSID("$NetBSD: xlint.c,v 1.69 2021/08/08 15:29:24 rillig Exp $");
 #endif
 
 #include 
@@ -634,10 +634,8 @@ fname(const char *name)
 	char	**args, *ofn, *pathname;
 	const char *CC;
 	size_t	len;
-	bool	is_stdin;
 	int	fd;
 
-	is_stdin = strcmp(name, "-") == 0;
 	bn = lbasename(name, '/');
 	suff = lbasename(bn, '.');
 
@@ -648,15 +646,14 @@ fname(const char *name)
 		return;
 	}
 
-	if (!is_stdin && strcmp(suff, "c") != 0 &&
+	if (strcmp(suff, "c") != 0 &&
 	(strncmp(bn, "llib-l", 6) != 0 || bn != suff)) {
 		warnx("unknown file type: %s", name);
 		return;
 	}
 
 	if (!iflag || !first)
-		(void)printf("%s:\n",
-		is_stdin ? "{standard input}" : Fflag ? name : bn);
+		(void)printf("%s:\n", Fflag ? name : bn);
 
 	/* build the name of the output file of lint1 */
 	if (oflag) {
@@ -664,10 +661,6 @@ fname(const char *name)
 		outputfn = NULL;
 		oflag = false;
 	} else if (iflag) {
-		if (is_stdin) {
-			warnx("-i not supported without -o for standard input");
-			return;
-		}
 		len = bn == suff ? strlen(bn) : (size_t)((suff - 1) - bn);
 		ofn = xasprintf("%.*s.ln", (int)len, bn);
 	} else {



CVS commit: src/usr.bin/xlint/xlint

2021-08-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  8 15:06:44 UTC 2021

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

Log Message:
lint: inline list_add_defines

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/usr.bin/xlint/xlint/xlint.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/xlint/xlint.c
diff -u src/usr.bin/xlint/xlint/xlint.c:1.67 src/usr.bin/xlint/xlint/xlint.c:1.68
--- src/usr.bin/xlint/xlint/xlint.c:1.67	Sun Aug  8 15:03:47 2021
+++ src/usr.bin/xlint/xlint/xlint.c	Sun Aug  8 15:06:44 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: xlint.c,v 1.67 2021/08/08 15:03:47 rillig Exp $ */
+/* $NetBSD: xlint.c,v 1.68 2021/08/08 15:06:44 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: xlint.c,v 1.67 2021/08/08 15:03:47 rillig Exp $");
+__RCSID("$NetBSD: xlint.c,v 1.68 2021/08/08 15:06:44 rillig Exp $");
 #endif
 
 #include 
@@ -129,7 +129,6 @@ static	const	char *currfn;
 static const char target_prefix[] = TARGET_PREFIX;
 
 static	char	*concat2(const char *, const char *);
-static	char	*concat3(const char *, const char *, const char *);
 static	void	terminate(int) __attribute__((__noreturn__));
 static	const	char *lbasename(const char *, int);
 static	void	usage(void);
@@ -190,14 +189,6 @@ list_add_all(char ***destp, char *const 
 }
 
 static void
-list_add_defines(char ***lstp, const char *def)
-{
-
-	list_add(lstp, concat2("-D__", def));
-	list_add(lstp, concat3("-D__", def, "__"));
-}
-
-static void
 list_free(char ***lstp)
 {
 	char	*s;
@@ -245,19 +236,6 @@ concat2(const char *s1, const char *s2)
 	return s;
 }
 
-static char *
-concat3(const char *s1, const char *s2, const char *s3)
-{
-	char	*s;
-
-	s = xmalloc(strlen(s1) + strlen(s2) + strlen(s3) + 1);
-	(void)strcpy(s, s1);
-	(void)strcat(s, s2);
-	(void)strcat(s, s3);
-
-	return s;
-}
-
 /*
  * Clean up after a signal.
  */
@@ -387,8 +365,8 @@ main(int argc, char *argv[])
 	pass_to_cpp("-Wcomment");
 	pass_to_cpp("-D__LINT__");
 	pass_to_cpp("-Dlint");		/* XXX don't def. with -s */
-
-	list_add_defines(&cflags, "lint");
+	pass_to_cpp("-D__lint");
+	pass_to_cpp("-D__lint__");
 
 	list_add_copy(&deflibs, "c");
 



CVS commit: src/usr.bin/xlint/xlint

2021-08-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  8 15:03:48 UTC 2021

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

Log Message:
lint: rename functions for handling string lists

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/usr.bin/xlint/xlint/xlint.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/xlint/xlint.c
diff -u src/usr.bin/xlint/xlint/xlint.c:1.66 src/usr.bin/xlint/xlint/xlint.c:1.67
--- src/usr.bin/xlint/xlint/xlint.c:1.66	Sun Aug  8 14:05:33 2021
+++ src/usr.bin/xlint/xlint/xlint.c	Sun Aug  8 15:03:47 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: xlint.c,v 1.66 2021/08/08 14:05:33 rillig Exp $ */
+/* $NetBSD: xlint.c,v 1.67 2021/08/08 15:03:47 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: xlint.c,v 1.66 2021/08/08 14:05:33 rillig Exp $");
+__RCSID("$NetBSD: xlint.c,v 1.67 2021/08/08 15:03:47 rillig Exp $");
 #endif
 
 #include 
@@ -128,15 +128,10 @@ static	const	char *currfn;
 #endif
 static const char target_prefix[] = TARGET_PREFIX;
 
-static	void	appstrg(char ***, char *);
-static	void	appcstrg(char ***, const char *);
-static	void	applst(char ***, char *const *);
-static	void	freelst(char ***);
 static	char	*concat2(const char *, const char *);
 static	char	*concat3(const char *, const char *, const char *);
 static	void	terminate(int) __attribute__((__noreturn__));
 static	const	char *lbasename(const char *, int);
-static	void	appdef(char ***, const char *);
 static	void	usage(void);
 static	void	fname(const char *);
 static	void	runchild(const char *, char *const *, const char *, int);
@@ -145,12 +140,17 @@ static	bool	rdok(const char *);
 static	void	lint2(void);
 static	void	cat(char *const *, const char *);
 
-/*
- * Some functions to deal with lists of strings.
- * Take care that we get no surprises in case of asynchronous signals.
- */
+static char **
+list_new(void)
+{
+	char **list;
+
+	list = xcalloc(1, sizeof(*list));
+	return list;
+}
+
 static void
-appstrg(char ***lstp, char *s)
+list_add(char ***lstp, char *s)
 {
 	char	**lst, **olst;
 	int	i;
@@ -165,14 +165,14 @@ appstrg(char ***lstp, char *s)
 }
 
 static void
-appcstrg(char ***lstp, const char *s)
+list_add_copy(char ***lstp, const char *s)
 {
 
-	appstrg(lstp, xstrdup(s));
+	list_add(lstp, xstrdup(s));
 }
 
 static void
-applst(char ***destp, char *const *src)
+list_add_all(char ***destp, char *const *src)
 {
 	int	i, k;
 	char	**dest, **odest;
@@ -190,7 +190,15 @@ applst(char ***destp, char *const *src)
 }
 
 static void
-freelst(char ***lstp)
+list_add_defines(char ***lstp, const char *def)
+{
+
+	list_add(lstp, concat2("-D__", def));
+	list_add(lstp, concat3("-D__", def, "__"));
+}
+
+static void
+list_free(char ***lstp)
 {
 	char	*s;
 	int	i;
@@ -208,21 +216,21 @@ static void
 pass_to_lint1(const char *opt)
 {
 
-	appcstrg(&l1flags, opt);
+	list_add_copy(&l1flags, opt);
 }
 
 static void
 pass_to_lint2(const char *opt)
 {
 
-	appcstrg(&l2flags, opt);
+	list_add_copy(&l2flags, opt);
 }
 
 static void
 pass_to_cpp(const char *opt)
 {
 
-	appcstrg(&cflags, opt);
+	list_add_copy(&cflags, opt);
 }
 
 static char *
@@ -303,14 +311,6 @@ lbasename(const char *strg, int delim)
 	return *cp1 == '\0' ? cp2 : cp1;
 }
 
-static void
-appdef(char ***lstp, const char *def)
-{
-
-	appstrg(lstp, concat2("-D__", def));
-	appstrg(lstp, concat3("-D__", def, "__"));
-}
-
 static void __attribute__((noreturn))
 usage(void)
 {
@@ -357,16 +357,16 @@ main(int argc, char *argv[])
 		terminate(-1);
 	}
 
-	p1out = xcalloc(1, sizeof(*p1out));
-	p2in = xcalloc(1, sizeof(*p2in));
-	cflags = xcalloc(1, sizeof(*cflags));
-	lcflags = xcalloc(1, sizeof(*lcflags));
-	l1flags = xcalloc(1, sizeof(*l1flags));
-	l2flags = xcalloc(1, sizeof(*l2flags));
-	l2libs = xcalloc(1, sizeof(*l2libs));
-	deflibs = xcalloc(1, sizeof(*deflibs));
-	libs = xcalloc(1, sizeof(*libs));
-	libsrchpath = xcalloc(1, sizeof(*libsrchpath));
+	p1out = list_new();
+	p2in = list_new();
+	cflags = list_new();
+	lcflags = list_new();
+	l1flags = list_new();
+	l2flags = list_new();
+	l2libs = list_new();
+	deflibs = list_new();
+	libs = list_new();
+	libsrchpath = list_new();
 
 	pass_to_cpp("-E");
 	pass_to_cpp("-x");
@@ -388,9 +388,9 @@ main(int argc, char *argv[])
 	pass_to_cpp("-D__LINT__");
 	pass_to_cpp("-Dlint");		/* XXX don't def. with -s */
 
-	appdef(&cflags, "lint");
+	list_add_defines(&cflags, "lint");
 
-	appcstrg(&deflibs, "c");
+	list_add_copy(&deflibs, "c");
 
 	if (signal(SIGHUP, terminate) == SIG_IGN)
 		(void)signal(SIGHUP, SIG_IGN);
@@ -442,15 +442,15 @@ main(int argc, char *argv[])
 			break;
 
 		case 'n':
-			freelst(&deflibs);
+			list_free(&deflibs);
 			break;
 
 		case 'p':
 			pass_to_lint1("-p");
 			pass_to_lint2("-p");
 			if (*deflibs != NULL) {
-fr

CVS commit: src/usr.bin/xlint/xlint

2021-08-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  8 14:05:33 UTC 2021

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

Log Message:
lint: make data flow in findlibs simpler

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/usr.bin/xlint/xlint/xlint.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/xlint/xlint.c
diff -u src/usr.bin/xlint/xlint/xlint.c:1.65 src/usr.bin/xlint/xlint/xlint.c:1.66
--- src/usr.bin/xlint/xlint/xlint.c:1.65	Sun Aug  8 13:34:57 2021
+++ src/usr.bin/xlint/xlint/xlint.c	Sun Aug  8 14:05:33 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: xlint.c,v 1.65 2021/08/08 13:34:57 rillig Exp $ */
+/* $NetBSD: xlint.c,v 1.66 2021/08/08 14:05:33 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: xlint.c,v 1.65 2021/08/08 13:34:57 rillig Exp $");
+__RCSID("$NetBSD: xlint.c,v 1.66 2021/08/08 14:05:33 rillig Exp $");
 #endif
 
 #include 
@@ -821,37 +821,40 @@ runchild(const char *path, char *const *
 }
 
 static void
-findlibs(char *const *liblst)
+findlib(const char *lib)
 {
-	int	i, k;
-	const	char *lib, *path;
-	char	*lfn;
-	size_t	len;
+	char *const *dir;
+	char *lfn;
 
-	lfn = NULL;
+	for (dir = libsrchpath; *dir != NULL; dir++) {
+		lfn = xasprintf("%s/llib-l%s.ln", *dir, lib);
+		if (rdok(lfn))
+			goto found;
+		free(lfn);
 
-	for (i = 0; (lib = liblst[i]) != NULL; i++) {
-		for (k = 0; (path = libsrchpath[k]) != NULL; k++) {
-			len = strlen(path) + strlen(lib);
-			lfn = xrealloc(lfn, len + sizeof("/llib-l.ln"));
-			(void)sprintf(lfn, "%s/llib-l%s.ln", path, lib);
-			if (rdok(lfn))
-break;
-			lfn = xrealloc(lfn, len + sizeof("/lint/llib-l.ln"));
-			(void)sprintf(lfn, "%s/lint/llib-l%s.ln", path, lib);
-			if (rdok(lfn))
-break;
-		}
-		if (path != NULL) {
-			appstrg(&l2libs, concat2("-l", lfn));
-		} else {
-			warnx("cannot find llib-l%s.ln", lib);
-		}
+		lfn = xasprintf("%s/lint/llib-l%s.ln", *dir, lib);
+		if (rdok(lfn))
+			goto found;
+		free(lfn);
 	}
 
+	warnx("cannot find llib-l%s.ln", lib);
+	return;
+
+found:
+	appstrg(&l2libs, concat2("-l", lfn));
 	free(lfn);
 }
 
+static void
+findlibs(char *const *liblst)
+{
+	char *const *p;
+
+	for (p = liblst; *p != NULL; p++)
+		findlib(*p);
+}
+
 static bool
 rdok(const char *path)
 {



CVS commit: src/usr.bin/xlint/xlint

2021-08-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  8 13:34:57 UTC 2021

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

Log Message:
lint: make memory management in xlint simpler

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/usr.bin/xlint/xlint/xlint.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/xlint/xlint.c
diff -u src/usr.bin/xlint/xlint/xlint.c:1.64 src/usr.bin/xlint/xlint/xlint.c:1.65
--- src/usr.bin/xlint/xlint/xlint.c:1.64	Sun Aug  1 18:13:53 2021
+++ src/usr.bin/xlint/xlint/xlint.c	Sun Aug  8 13:34:57 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: xlint.c,v 1.64 2021/08/01 18:13:53 rillig Exp $ */
+/* $NetBSD: xlint.c,v 1.65 2021/08/08 13:34:57 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: xlint.c,v 1.64 2021/08/01 18:13:53 rillig Exp $");
+__RCSID("$NetBSD: xlint.c,v 1.65 2021/08/08 13:34:57 rillig Exp $");
 #endif
 
 #include 
@@ -347,13 +347,10 @@ main(int argc, char *argv[])
 	if ((tmp = getenv("TMPDIR")) == NULL || (len = strlen(tmp)) == 0) {
 		tmpdir = xstrdup(_PATH_TMP);
 	} else {
-		char *p = xmalloc(len + 2);
-		(void)sprintf(p, "%s%s", tmp, tmp[len - 1] == '/' ? "" : "/");
-		tmpdir = p;
+		tmpdir = concat2(tmp, tmp[len - 1] == '/' ? "" : "/");
 	}
 
-	cppout = xmalloc(strlen(tmpdir) + sizeof("lint0.XX"));
-	(void)sprintf(cppout, "%slint0.XX", tmpdir);
+	cppout = concat2(tmpdir, "lint0.XX");
 	cppoutfd = mkstemp(cppout);
 	if (cppoutfd == -1) {
 		warn("can't make temp");
@@ -516,8 +513,7 @@ main(int argc, char *argv[])
 usage();
 			Cflag = true;
 			appstrg(&l2flags, concat2("-C", optarg));
-			p2out = xmalloc(sizeof("llib-l.ln") + strlen(optarg));
-			(void)sprintf(p2out, "llib-l%s.ln", optarg);
+			p2out = xasprintf("llib-l%s.ln", optarg);
 			freelst(&deflibs);
 			break;
 
@@ -534,8 +530,7 @@ main(int argc, char *argv[])
 		case 'I':
 		case 'M':
 		case 'U':
-			(void)sprintf(flgbuf, "-%c", c);
-			appstrg(&cflags, concat2(flgbuf, optarg));
+			appstrg(&cflags, xasprintf("-%c%s", c, optarg));
 			break;
 
 		case 'l':
@@ -744,17 +739,14 @@ fname(const char *name)
 	/* run lint1 */
 
 	if (!Bflag) {
-		pathname = xmalloc(strlen(PATH_LIBEXEC) + sizeof("/lint1") +
-		strlen(target_prefix));
-		(void)sprintf(pathname, "%s/%slint1", PATH_LIBEXEC,
-		target_prefix);
+		pathname = xasprintf("%s/%slint1",
+		PATH_LIBEXEC, target_prefix);
 	} else {
 		/*
 		 * XXX Unclear whether we should be using target_prefix
 		 * XXX here.  --thor...@wasabisystems.com
 		 */
-		pathname = xmalloc(strlen(libexec_path) + sizeof("/lint1"));
-		(void)sprintf(pathname, "%s/lint1", libexec_path);
+		pathname = concat2(libexec_path, "/lint1");
 	}
 
 	appcstrg(&args, pathname);
@@ -882,17 +874,13 @@ lint2(void)
 	args = xcalloc(1, sizeof(*args));
 
 	if (!Bflag) {
-		path = xmalloc(strlen(PATH_LIBEXEC) + sizeof("/lint2") +
-		strlen(target_prefix));
-		(void)sprintf(path, "%s/%slint2", PATH_LIBEXEC,
-		target_prefix);
+		path = xasprintf("%s/%slint2", PATH_LIBEXEC, target_prefix);
 	} else {
 		/*
 		 * XXX Unclear whether we should be using target_prefix
 		 * XXX here.  --thor...@wasabisystems.com
 		 */
-		path = xmalloc(strlen(libexec_path) + sizeof("/lint2"));
-		(void)sprintf(path, "%s/lint2", libexec_path);
+		path = concat2(libexec_path, "/lint2");
 	}
 
 	appcstrg(&args, path);



CVS commit: src/tests/usr.bin/xlint/lint2

2021-08-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  8 13:22:22 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint2: Makefile

Log Message:
tests/lint: mips64 is not a 64-bit platform

See usr.bin/xlint/arch/mips64/targparam.h.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint2/Makefile

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

Modified files:

Index: src/tests/usr.bin/xlint/lint2/Makefile
diff -u src/tests/usr.bin/xlint/lint2/Makefile:1.4 src/tests/usr.bin/xlint/lint2/Makefile:1.5
--- src/tests/usr.bin/xlint/lint2/Makefile:1.4	Sun Aug  8 00:02:02 2021
+++ src/tests/usr.bin/xlint/lint2/Makefile	Sun Aug  8 13:22:22 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.4 2021/08/08 00:02:02 rillig Exp $
+# $NetBSD: Makefile,v 1.5 2021/08/08 13:22:22 rillig Exp $
 
 NOMAN=		yes
 
@@ -16,8 +16,8 @@ FILESDIR=	${TESTSDIR}
 TESTS+=		msg_${msg}
 .endfor
 TESTS+=		read
-.if ${MACHINE_ARCH:M*64}	# close enough to "is a 64-bit platform"
-TESTS+=		read_lp64
+.if ${MACHINE_ARCH:M*64} && !${MACHINE_ARCH:Mmips64*}
+TESTS+=		read_lp64	# only on 64-bit platforms
 .endif
 TESTS+=		read_printf
 



CVS commit: src/tests/usr.bin/xlint/lint1

2021-08-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  8 13:19:51 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: accept.sh c99_bool_strict_suppressed.c

Log Message:
tests/lint: clean up accept.sh, document test for removed assertion


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/accept.sh
cvs rdiff -u -r1.3 -r1.4 \
src/tests/usr.bin/xlint/lint1/c99_bool_strict_suppressed.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/accept.sh
diff -u src/tests/usr.bin/xlint/lint1/accept.sh:1.4 src/tests/usr.bin/xlint/lint1/accept.sh:1.5
--- src/tests/usr.bin/xlint/lint1/accept.sh:1.4	Thu Aug  5 06:34:43 2021
+++ src/tests/usr.bin/xlint/lint1/accept.sh	Sun Aug  8 13:19:51 2021
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: accept.sh,v 1.4 2021/08/05 06:34:43 rillig Exp $
+# $NetBSD: accept.sh,v 1.5 2021/08/08 13:19:51 rillig Exp $
 #
 # Copyright (c) 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -36,6 +36,7 @@ set -eu
 . './t_integration.sh'
 
 for pattern in "$@"; do
+	# shellcheck disable=SC2231
 	for test in *$pattern*.c; do
 		base=${test%.*}
 		cfile="$base.c"
@@ -45,7 +46,7 @@ for pattern in "$@"; do
 
 		configure_test_case "$cfile"
 		# shellcheck disable=SC2154
-		if [ $skip = yes ]; then
+		if [ "$skip" = yes ]; then
 			continue
 		fi
 
@@ -93,4 +94,5 @@ for pattern in "$@"; do
 	done
 done
 
+# shellcheck disable=SC2035
 lua '../check-expect.lua' *.c

Index: src/tests/usr.bin/xlint/lint1/c99_bool_strict_suppressed.c
diff -u src/tests/usr.bin/xlint/lint1/c99_bool_strict_suppressed.c:1.3 src/tests/usr.bin/xlint/lint1/c99_bool_strict_suppressed.c:1.4
--- src/tests/usr.bin/xlint/lint1/c99_bool_strict_suppressed.c:1.3	Mon Jul  5 19:02:14 2021
+++ src/tests/usr.bin/xlint/lint1/c99_bool_strict_suppressed.c	Sun Aug  8 13:19:51 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: c99_bool_strict_suppressed.c,v 1.3 2021/07/05 19:02:14 rillig Exp $	*/
+/*	$NetBSD: c99_bool_strict_suppressed.c,v 1.4 2021/08/08 13:19:51 rillig Exp $	*/
 # 3 "c99_bool_strict_suppressed.c"
 
 /*
@@ -9,12 +9,13 @@
  * This can result in assertion failures later.  One such assertion has been
  * there since at least 1995, at the beginning of expr(), ensuring that the
  * expression is either non-null or an error message has been _printed_.
- * In 1995 it was not possible to suppress error messages, which means that
+ * In 1995, it was not possible to suppress error messages, which means that
  * the number of printed errors equaled the number of occurred errors.
  *
  * In err.c 1.12 from 2000-07-06, the option -X was added, allowing to
  * suppress individual error messages.  That commit did not mention any
- * interaction with the assertion in expr().
+ * interaction with the assertion in expr().  The assertion was removed in
+ * tree.c 1.305 from 2021-07-04.
  */
 
 /* lint1-extra-flags: -T -X 107,330,331,332,333 */



CVS commit: src/usr.bin/make

2021-08-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  8 12:00:30 UTC 2021

Modified Files:
src/usr.bin/make: var.c

Log Message:
make: remove redundant initialization in ApplyModifier_Order

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.945 -r1.946 src/usr.bin/make/var.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/make/var.c
diff -u src/usr.bin/make/var.c:1.945 src/usr.bin/make/var.c:1.946
--- src/usr.bin/make/var.c:1.945	Sat Jul 31 09:30:17 2021
+++ src/usr.bin/make/var.c	Sun Aug  8 12:00:30 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.945 2021/07/31 09:30:17 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.946 2021/08/08 12:00:30 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.945 2021/07/31 09:30:17 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.946 2021/08/08 12:00:30 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -3355,7 +3355,7 @@ ApplyModifier_Order(const char **pp, Mod
 {
 	const char *mod = *pp;
 	Words words;
-	int (*cmp)(const void *, const void *) = NULL;
+	int (*cmp)(const void *, const void *);
 
 	if (IsDelimiter(mod[1], ch) || mod[1] == '\0') {
 		cmp = str_cmp_asc;



CVS commit: src/usr.bin/xlint/lint2

2021-08-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  8 11:56:36 UTC 2021

Modified Files:
src/usr.bin/xlint/lint2: Makefile chk.c read.c

Log Message:
lint: force strict bool mode

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/xlint/lint2/Makefile
cvs rdiff -u -r1.42 -r1.43 src/usr.bin/xlint/lint2/chk.c
cvs rdiff -u -r1.48 -r1.49 src/usr.bin/xlint/lint2/read.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/lint2/Makefile
diff -u src/usr.bin/xlint/lint2/Makefile:1.20 src/usr.bin/xlint/lint2/Makefile:1.21
--- src/usr.bin/xlint/lint2/Makefile:1.20	Sun Apr 18 22:51:24 2021
+++ src/usr.bin/xlint/lint2/Makefile	Sun Aug  8 11:56:35 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.20 2021/04/18 22:51:24 rillig Exp $
+#	$NetBSD: Makefile,v 1.21 2021/08/08 11:56:35 rillig Exp $
 
 NOMAN=		# defined
 
@@ -7,6 +7,7 @@ SRCS=		main2.c hash.c read.c mem.c mem2.
 		inittyp.c tyname.c
 BINDIR=		/usr/libexec
 CPPFLAGS+=	-I${.CURDIR}
+LINTFLAGS+=	-T		# strict bool mode
 
 COPTS.msg.c+=	${${ACTIVE_CC} == "clang":? -Wno-format-nonliteral :}
 

Index: src/usr.bin/xlint/lint2/chk.c
diff -u src/usr.bin/xlint/lint2/chk.c:1.42 src/usr.bin/xlint/lint2/chk.c:1.43
--- src/usr.bin/xlint/lint2/chk.c:1.42	Fri Apr  2 12:16:50 2021
+++ src/usr.bin/xlint/lint2/chk.c	Sun Aug  8 11:56:35 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: chk.c,v 1.42 2021/04/02 12:16:50 rillig Exp $ */
+/* $NetBSD: chk.c,v 1.43 2021/08/08 11:56:35 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: chk.c,v 1.42 2021/04/02 12:16:50 rillig Exp $");
+__RCSID("$NetBSD: chk.c,v 1.43 2021/08/08 11:56:35 rillig Exp $");
 #endif
 
 #include 
@@ -1085,9 +1085,9 @@ chkrvu(hte_t *hte, sym_t *def)
 		 * but for now I don't want to be bothered by this warnings
 		 * which are almost always useless.
 		 */
-		if (hflag == 0)
+		if (!hflag)
 			return;
-		if (hflag == 1 && bsearch(hte->h_name, ignorelist,
+		if (hflag && bsearch(hte->h_name, ignorelist,
 		__arraycount(ignorelist), sizeof(ignorelist[0]),
 		(int (*)(const void *, const void *))strcmp) != NULL)
 			return;
@@ -1340,7 +1340,7 @@ eqargs(type_t *tp1, type_t *tp2, bool *d
 
 	while (*a1 != NULL && *a2 != NULL) {
 
-		if (eqtype(*a1, *a2, true, false, false, dowarn) == 0)
+		if (!eqtype(*a1, *a2, true, false, false, dowarn))
 			return false;
 
 		a1++;

Index: src/usr.bin/xlint/lint2/read.c
diff -u src/usr.bin/xlint/lint2/read.c:1.48 src/usr.bin/xlint/lint2/read.c:1.49
--- src/usr.bin/xlint/lint2/read.c:1.48	Thu Aug  5 06:54:16 2021
+++ src/usr.bin/xlint/lint2/read.c	Sun Aug  8 11:56:35 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: read.c,v 1.48 2021/08/05 06:54:16 rillig Exp $ */
+/* $NetBSD: read.c,v 1.49 2021/08/08 11:56:35 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: read.c,v 1.48 2021/08/05 06:54:16 rillig Exp $");
+__RCSID("$NetBSD: read.c,v 1.49 2021/08/08 11:56:35 rillig Exp $");
 #endif
 
 #include 
@@ -402,7 +402,7 @@ decldef(pos_t *posp, const char *cp)
 			sym.s_def = DECL;
 			break;
 		case 'i':
-			if (sym.s_inline != NODECL)
+			if (sym.s_inline)
 inperr("inline %c", c);
 			sym.s_inline = true;
 			break;



CVS commit: src/tests/usr.bin/xlint

2021-08-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  8 11:07:20 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: emit.c emit.exp-ln
src/tests/usr.bin/xlint/lint2: read_printf.ln

Log Message:
tests/lint: test passing of printf-like strings between lint1 and lint2


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/emit.c \
src/tests/usr.bin/xlint/lint1/emit.exp-ln
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint2/read_printf.ln

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/emit.c
diff -u src/tests/usr.bin/xlint/lint1/emit.c:1.1 src/tests/usr.bin/xlint/lint1/emit.c:1.2
--- src/tests/usr.bin/xlint/lint1/emit.c:1.1	Sun Apr 18 20:02:56 2021
+++ src/tests/usr.bin/xlint/lint1/emit.c	Sun Aug  8 11:07:19 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: emit.c,v 1.1 2021/04/18 20:02:56 rillig Exp $	*/
+/*	$NetBSD: emit.c,v 1.2 2021/08/08 11:07:19 rillig Exp $	*/
 # 3 "emit.c"
 
 /*
@@ -144,3 +144,22 @@ void taking_varargs(const char *, ...);
  * it.
  */
 static int static_function(void);			/* expect: declared */
+
+void my_printf(const char *, ...);
+
+/*
+ * String literals that occur in function calls are written to the .ln file,
+ * just in case they are related to a printf-like or scanf-like function.
+ *
+ * In this example, the various strings are not format strings, they just
+ * serve to cover the code that escapes character literals (outqchar in
+ * lint1) and reads them back into characters (inpqstrg in lint2).
+ */
+void
+cover_outqchar(void)
+{
+	my_printf("%s", "%");
+	my_printf("%s", "%s");
+	my_printf("%s", "%%");
+	my_printf("%s", "%\a %\b %\f %\n %\r %\t %\v %\177");
+}
Index: src/tests/usr.bin/xlint/lint1/emit.exp-ln
diff -u src/tests/usr.bin/xlint/lint1/emit.exp-ln:1.1 src/tests/usr.bin/xlint/lint1/emit.exp-ln:1.2
--- src/tests/usr.bin/xlint/lint1/emit.exp-ln:1.1	Sun Jun 27 09:22:31 2021
+++ src/tests/usr.bin/xlint/lint1/emit.exp-ln	Sun Aug  8 11:07:19 2021
@@ -50,3 +50,9 @@ Semit.c
 136d0.135e33taking_struct_union_enum_typedefsF3sT214struct_typedefuT213union_typedefeT212enum_typedefV
 138d0.138e14taking_varargsF2PcCEV
 146d0.146es15static_functionF0I
+148d0.148e9my_printfF2PcCEV
+161c0.161s2"%"i9my_printff2PcCPCV
+162c0.162s2"%s"i9my_printff2PcCPCV
+163c0.163s2"%%"i9my_printff2PcCPCV
+164c0.164s2"%\a%\b%\f%\n%\r%\t%\v%\177"i9my_printff2PcCPCV
+159d0.159d14cover_outqcharF0V

Index: src/tests/usr.bin/xlint/lint2/read_printf.ln
diff -u src/tests/usr.bin/xlint/lint2/read_printf.ln:1.1 src/tests/usr.bin/xlint/lint2/read_printf.ln:1.2
--- src/tests/usr.bin/xlint/lint2/read_printf.ln:1.1	Sat Aug  7 23:52:32 2021
+++ src/tests/usr.bin/xlint/lint2/read_printf.ln	Sun Aug  8 11:07:19 2021
@@ -1,4 +1,4 @@
-# $NetBSD: read_printf.ln,v 1.1 2021/08/07 23:52:32 rillig Exp $
+# $NetBSD: read_printf.ln,v 1.2 2021/08/08 11:07:19 rillig Exp $
 #
 # Test reading of declarations and usage of printf-like functions.
 
@@ -33,3 +33,9 @@ Sprintf-use.c
 # Argument 3 is a negative integer.
 # Argument 4 has no further interesting properties.
 13c0.13 s2"" n3 i 9my_printf f4 PcC PC I PcV V
+
+# See tests/lint1/emit.c, function cover_outqchar.
+161c0.161 s2"%" i 9my_printf f2 PcC PC V
+162c0.162 s2"%s"i 9my_printf f2 PcC PC V
+163c0.163 s2"%%" i 9my_printf f2 PcC PC V
+164c0.164 s2"%\a%\b%\f%\n%\r%\t%\v%\177" i 9my_printf f2 PcC PC V



CVS commit: src/usr.bin/xlint/lint1

2021-08-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  8 10:41:34 UTC 2021

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

Log Message:
lint: condense code for writing the .ln files

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/usr.bin/xlint/lint1/emit1.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/emit1.c
diff -u src/usr.bin/xlint/lint1/emit1.c:1.47 src/usr.bin/xlint/lint1/emit1.c:1.48
--- src/usr.bin/xlint/lint1/emit1.c:1.47	Sat Jul 31 19:52:44 2021
+++ src/usr.bin/xlint/lint1/emit1.c	Sun Aug  8 10:41:34 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: emit1.c,v 1.47 2021/07/31 19:52:44 rillig Exp $ */
+/* $NetBSD: emit1.c,v 1.48 2021/08/08 10:41:34 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: emit1.c,v 1.47 2021/07/31 19:52:44 rillig Exp $");
+__RCSID("$NetBSD: emit1.c,v 1.48 2021/08/08 10:41:34 rillig Exp $");
 #endif
 
 #include "lint1.h"
@@ -227,26 +227,19 @@ outsym(const sym_t *sym, scl_t sc, def_t
 
 	/* flags */
 
-	switch (def) {
-	case DEF:
-		/* defined */
-		outchar('d');
-		break;
-	case TDEF:
-		/* tentative defined */
-		outchar('t');
-		break;
-	case DECL:
-		/* declared */
-		outchar('e');
-		break;
-	default:
-		lint_assert(/*CONSTCOND*/false);
+	if (def == DEF)
+		outchar('d');	/* defined */
+	else if (def == TDEF)
+		outchar('t');	/* tentative defined */
+	else {
+		lint_assert(def == DECL);
+		outchar('e');	/* declared */
 	}
+
 	if (llibflg && def != DECL) {
 		/*
-		 * mark it as used so we get no warnings from lint2 about
-		 * unused symbols in libraries.
+		 * mark it as used so lint2 does not complain about
+		 * unused symbols in libraries
 		 */
 		outchar('u');
 	}
@@ -327,8 +320,7 @@ outfdef(const sym_t *fsym, const pos_t *
 	outchar('d');
 
 	if (rval)
-		/* has return value */
-		outchar('r');
+		outchar('r');	/* has return value */
 
 	if (llibflg)
 		/*
@@ -338,8 +330,7 @@ outfdef(const sym_t *fsym, const pos_t *
 		outchar('u');
 
 	if (osdef)
-		/* old style function definition */
-		outchar('o');
+		outchar('o');	/* old style function definition */
 
 	if (fsym->s_inline)
 		outchar('i');



CVS commit: src

2021-08-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  8 00:02:03 UTC 2021

Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/usr.bin/xlint/lint2: Makefile t_lint2.sh

Log Message:
tests/lint: make list of tests simpler

Since the file /usr/tests/usr.bin/xlint/lint2/tests has only been in the
file set for a few minutes, it is not marked as obsolete but simply
removed.


To generate a diff of this commit:
cvs rdiff -u -r1.1107 -r1.1108 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint2/Makefile \
src/tests/usr.bin/xlint/lint2/t_lint2.sh

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1107 src/distrib/sets/lists/tests/mi:1.1108
--- src/distrib/sets/lists/tests/mi:1.1107	Sat Aug  7 23:52:32 2021
+++ src/distrib/sets/lists/tests/mi	Sun Aug  8 00:02:02 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1107 2021/08/07 23:52:32 rillig Exp $
+# $NetBSD: mi,v 1.1108 2021/08/08 00:02:02 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -7071,7 +7071,6 @@
 ./usr/tests/usr.bin/xlint/lint2/read_printf.exp			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint2/read_printf.ln			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint2/t_lint2tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/xlint/lint2/teststests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/ztesttests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/ztest/Atffile			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/ztest/Kyuafile			tests-usr.bin-tests	compattestfile,atf,kyua

Index: src/tests/usr.bin/xlint/lint2/Makefile
diff -u src/tests/usr.bin/xlint/lint2/Makefile:1.3 src/tests/usr.bin/xlint/lint2/Makefile:1.4
--- src/tests/usr.bin/xlint/lint2/Makefile:1.3	Sat Aug  7 23:52:32 2021
+++ src/tests/usr.bin/xlint/lint2/Makefile	Sun Aug  8 00:02:02 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.3 2021/08/07 23:52:32 rillig Exp $
+# $NetBSD: Makefile,v 1.4 2021/08/08 00:02:02 rillig Exp $
 
 NOMAN=		yes
 
@@ -22,11 +22,6 @@ TESTS+=		read_lp64
 TESTS+=		read_printf
 
 FILES+=		${TESTS:=.ln} ${TESTS:=.exp}
-FILES+=		tests
-
-realall: tests
-tests:
-	printf '%s\n' ${TESTS} > ${.TARGET}
 
 # Note: only works for adding tests.
 # To remove a test, the $$mi file must be edited manually.
Index: src/tests/usr.bin/xlint/lint2/t_lint2.sh
diff -u src/tests/usr.bin/xlint/lint2/t_lint2.sh:1.3 src/tests/usr.bin/xlint/lint2/t_lint2.sh:1.4
--- src/tests/usr.bin/xlint/lint2/t_lint2.sh:1.3	Sat Aug  7 23:52:32 2021
+++ src/tests/usr.bin/xlint/lint2/t_lint2.sh	Sun Aug  8 00:02:02 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_lint2.sh,v 1.3 2021/08/07 23:52:32 rillig Exp $
+# $NetBSD: t_lint2.sh,v 1.4 2021/08/08 00:02:02 rillig Exp $
 #
 # Copyright (c) 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -49,7 +49,8 @@ std_body()
 atf_init_test_cases()
 {
 	# shellcheck disable=SC2013
-	for i in $(cat "$(atf_get_srcdir)/tests"); do
+	for i in $(cd "$(atf_get_srcdir)" && echo *.ln); do
+		i=${i%.ln}
 		eval "${i}_head() { std_head; }"
 		eval "${i}_body() { std_body '$i'; }"
 		atf_add_test_case "$i"



CVS commit: src

2021-08-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  7 23:52:32 UTC 2021

Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/usr.bin/xlint/lint2: Makefile t_lint2.sh
Added Files:
src/tests/usr.bin/xlint/lint2: read_lp64.exp read_lp64.ln
read_printf.exp read_printf.ln

Log Message:
tests/lint: test reading of 128-bit integer types and printf


To generate a diff of this commit:
cvs rdiff -u -r1.1106 -r1.1107 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint2/Makefile \
src/tests/usr.bin/xlint/lint2/t_lint2.sh
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint2/read_lp64.exp \
src/tests/usr.bin/xlint/lint2/read_lp64.ln \
src/tests/usr.bin/xlint/lint2/read_printf.exp \
src/tests/usr.bin/xlint/lint2/read_printf.ln

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1106 src/distrib/sets/lists/tests/mi:1.1107
--- src/distrib/sets/lists/tests/mi:1.1106	Sat Aug  7 21:24:13 2021
+++ src/distrib/sets/lists/tests/mi	Sat Aug  7 23:52:32 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1106 2021/08/07 21:24:13 rillig Exp $
+# $NetBSD: mi,v 1.1107 2021/08/07 23:52:32 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -7066,7 +7066,12 @@
 ./usr/tests/usr.bin/xlint/lint2/msg_018.ln			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint2/read.exp			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint2/read.lntests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint2/read_lp64.exp			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint2/read_lp64.ln			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint2/read_printf.exp			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint2/read_printf.ln			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint2/t_lint2tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint2/teststests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/ztesttests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/ztest/Atffile			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/ztest/Kyuafile			tests-usr.bin-tests	compattestfile,atf,kyua

Index: src/tests/usr.bin/xlint/lint2/Makefile
diff -u src/tests/usr.bin/xlint/lint2/Makefile:1.2 src/tests/usr.bin/xlint/lint2/Makefile:1.3
--- src/tests/usr.bin/xlint/lint2/Makefile:1.2	Sat Aug  7 21:24:14 2021
+++ src/tests/usr.bin/xlint/lint2/Makefile	Sat Aug  7 23:52:32 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.2 2021/08/07 21:24:14 rillig Exp $
+# $NetBSD: Makefile,v 1.3 2021/08/07 23:52:32 rillig Exp $
 
 NOMAN=		yes
 
@@ -13,9 +13,20 @@ FILESDIR=	${TESTSDIR}
 .for msg in \
 000 001 002 003 004 005 006 007 008 009 \
 010 011 012 013 014 015 016 017 018
-FILES+=		msg_${msg}.exp	msg_${msg}.ln
+TESTS+=		msg_${msg}
 .endfor
-FILES+=		read.exp	read.ln
+TESTS+=		read
+.if ${MACHINE_ARCH:M*64}	# close enough to "is a 64-bit platform"
+TESTS+=		read_lp64
+.endif
+TESTS+=		read_printf
+
+FILES+=		${TESTS:=.ln} ${TESTS:=.exp}
+FILES+=		tests
+
+realall: tests
+tests:
+	printf '%s\n' ${TESTS} > ${.TARGET}
 
 # Note: only works for adding tests.
 # To remove a test, the $$mi file must be edited manually.
Index: src/tests/usr.bin/xlint/lint2/t_lint2.sh
diff -u src/tests/usr.bin/xlint/lint2/t_lint2.sh:1.2 src/tests/usr.bin/xlint/lint2/t_lint2.sh:1.3
--- src/tests/usr.bin/xlint/lint2/t_lint2.sh:1.2	Sat Aug  7 21:24:14 2021
+++ src/tests/usr.bin/xlint/lint2/t_lint2.sh	Sat Aug  7 23:52:32 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_lint2.sh,v 1.2 2021/08/07 21:24:14 rillig Exp $
+# $NetBSD: t_lint2.sh,v 1.3 2021/08/07 23:52:32 rillig Exp $
 #
 # Copyright (c) 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -37,8 +37,8 @@ std_body()
 	# shellcheck disable=SC2155
 	local srcdir="$(atf_get_srcdir)"
 
-	# remove comments and empty lines from the .ln file
-	sed -e '/^#/d' -e '/^$/d' -e 's,[[:space:]]*#.*,,' \
+	# remove comments and whitespace from the .ln file
+	sed -e '/^#/d' -e '/^$/d' -e 's,#.*,,' -e 's,[[:space:]],,g' \
 	< "$srcdir/$1.ln" \
 	> "$1.ln"
 
@@ -48,7 +48,8 @@ std_body()
 
 atf_init_test_cases()
 {
-	for i in $(printf 'msg_%03d\n' $(seq 0 18)) "read"; do
+	# shellcheck disable=SC2013
+	for i in $(cat "$(atf_get_srcdir)/tests"); do
 		eval "${i}_head() { std_head; }"
 		eval "${i}_body() { std_body '$i'; }"
 		atf_add_test_case "$i"

Added files:

Index: src/tests/usr.bin/xlint/lint2/read_lp64.ln
diff -u /dev/null src/tests/usr.bin/xlint/lint2/read_lp64.ln:1.1
--- /dev/null	Sat Aug  7 23:52:32 2021
+++ src/tests/usr.bin/xlint/lint2/read_lp64.ln	Sat Aug  7 23:52:32 2021
@@ -0,0 +1,10 @@
+# $NetBSD: read_lp64.ln,v 1.1 2021/08/07 23:52:32 rillig Exp $
+#
+# Cover reading of 128-bit inte

CVS commit: src

2021-08-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  7 21:24:14 UTC 2021

Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/usr.bin/xlint/lint2: Makefile t_lint2.sh
Added Files:
src/tests/usr.bin/xlint/lint2: read.exp read.ln

Log Message:
tests/lint: add test for reading the lint1 output


To generate a diff of this commit:
cvs rdiff -u -r1.1105 -r1.1106 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint2/Makefile \
src/tests/usr.bin/xlint/lint2/t_lint2.sh
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint2/read.exp \
src/tests/usr.bin/xlint/lint2/read.ln

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1105 src/distrib/sets/lists/tests/mi:1.1106
--- src/distrib/sets/lists/tests/mi:1.1105	Fri Aug  6 08:44:31 2021
+++ src/distrib/sets/lists/tests/mi	Sat Aug  7 21:24:13 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1105 2021/08/06 08:44:31 martin Exp $
+# $NetBSD: mi,v 1.1106 2021/08/07 21:24:13 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -7064,6 +7064,8 @@
 ./usr/tests/usr.bin/xlint/lint2/msg_017.ln			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint2/msg_018.exp			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint2/msg_018.ln			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint2/read.exp			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint2/read.lntests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint2/t_lint2tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/ztesttests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/ztest/Atffile			tests-usr.bin-tests	compattestfile,atf

Index: src/tests/usr.bin/xlint/lint2/Makefile
diff -u src/tests/usr.bin/xlint/lint2/Makefile:1.1 src/tests/usr.bin/xlint/lint2/Makefile:1.2
--- src/tests/usr.bin/xlint/lint2/Makefile:1.1	Thu Aug  5 22:36:08 2021
+++ src/tests/usr.bin/xlint/lint2/Makefile	Sat Aug  7 21:24:14 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.1 2021/08/05 22:36:08 rillig Exp $
+# $NetBSD: Makefile,v 1.2 2021/08/07 21:24:14 rillig Exp $
 
 NOMAN=		yes
 
@@ -13,8 +13,9 @@ FILESDIR=	${TESTSDIR}
 .for msg in \
 000 001 002 003 004 005 006 007 008 009 \
 010 011 012 013 014 015 016 017 018
-FILES+=		msg_${msg}.exp msg_${msg}.ln
+FILES+=		msg_${msg}.exp	msg_${msg}.ln
 .endfor
+FILES+=		read.exp	read.ln
 
 # Note: only works for adding tests.
 # To remove a test, the $$mi file must be edited manually.
Index: src/tests/usr.bin/xlint/lint2/t_lint2.sh
diff -u src/tests/usr.bin/xlint/lint2/t_lint2.sh:1.1 src/tests/usr.bin/xlint/lint2/t_lint2.sh:1.2
--- src/tests/usr.bin/xlint/lint2/t_lint2.sh:1.1	Thu Aug  5 22:36:08 2021
+++ src/tests/usr.bin/xlint/lint2/t_lint2.sh	Sat Aug  7 21:24:14 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_lint2.sh,v 1.1 2021/08/05 22:36:08 rillig Exp $
+# $NetBSD: t_lint2.sh,v 1.2 2021/08/07 21:24:14 rillig Exp $
 #
 # Copyright (c) 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -27,28 +27,30 @@
 
 lint2=/usr/libexec/lint2
 
-do_msg_head()
+std_head()
 {
 	atf_set 'require.progs' "$lint2"
 }
 
-do_msg_body()
+std_body()
 {
 	# shellcheck disable=SC2155
 	local srcdir="$(atf_get_srcdir)"
 
 	# remove comments and empty lines from the .ln file
-	sed -e '/^#/d' -e '/^$/d' < "$srcdir/msg_$1.ln" > "msg_$1.ln"
+	sed -e '/^#/d' -e '/^$/d' -e 's,[[:space:]]*#.*,,' \
+	< "$srcdir/$1.ln" \
+	> "$1.ln"
 
-	atf_check -o "file:$srcdir/msg_$1.exp" \
-	"$lint2" -h -p -x "msg_$1.ln"
+	atf_check -o "file:$srcdir/$1.exp" \
+	"$lint2" -h -p -x "$1.ln"
 }
 
 atf_init_test_cases()
 {
-	for i in $(printf '%03d\n' $(seq 0 18)); do
-		eval "msg_${i}_head() { do_msg_head; }"
-		eval "msg_${i}_body() { do_msg_body '$i'; }"
-		atf_add_test_case "msg_$i"
+	for i in $(printf 'msg_%03d\n' $(seq 0 18)) "read"; do
+		eval "${i}_head() { std_head; }"
+		eval "${i}_body() { std_body '$i'; }"
+		atf_add_test_case "$i"
 	done
 }

Added files:

Index: src/tests/usr.bin/xlint/lint2/read.exp
diff -u /dev/null src/tests/usr.bin/xlint/lint2/read.exp:1.1
--- /dev/null	Sat Aug  7 21:24:14 2021
+++ src/tests/usr.bin/xlint/lint2/read.exp	Sat Aug  7 21:24:14 2021
@@ -0,0 +1 @@
+a125 declared( read.c(125) ), but never used or defined
Index: src/tests/usr.bin/xlint/lint2/read.ln
diff -u /dev/null src/tests/usr.bin/xlint/lint2/read.ln:1.1
--- /dev/null	Sat Aug  7 21:24:14 2021
+++ src/tests/usr.bin/xlint/lint2/read.ln	Sat Aug  7 21:24:14 2021
@@ -0,0 +1,64 @@
+# $NetBSD: read.ln,v 1.1 2021/08/07 21:24:14 rillig Exp $
+#
+# Cover each path of reading declarations, definitions and usages.
+
+0sread.c
+Sread.c
+
+# Cover all tspec_t constants, in declaration order.
+#
+# The line numbers correspond to the constant values of tspec_t,
+# with the 128-bit typ

CVS commit: src/tests/usr.bin/xlint/lint2

2021-08-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  7 19:07:03 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint2: msg_001.exp msg_001.ln msg_003.exp
msg_003.ln msg_004.exp msg_004.ln msg_005.exp msg_005.ln
msg_006.exp msg_006.ln msg_011.exp msg_011.ln msg_012.exp
msg_012.ln

Log Message:
tests/lint: add more tests for lint2


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint2/msg_001.exp \
src/tests/usr.bin/xlint/lint2/msg_001.ln
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint2/msg_003.exp \
src/tests/usr.bin/xlint/lint2/msg_003.ln \
src/tests/usr.bin/xlint/lint2/msg_004.exp \
src/tests/usr.bin/xlint/lint2/msg_004.ln \
src/tests/usr.bin/xlint/lint2/msg_005.exp \
src/tests/usr.bin/xlint/lint2/msg_005.ln \
src/tests/usr.bin/xlint/lint2/msg_006.exp \
src/tests/usr.bin/xlint/lint2/msg_006.ln \
src/tests/usr.bin/xlint/lint2/msg_011.exp \
src/tests/usr.bin/xlint/lint2/msg_011.ln \
src/tests/usr.bin/xlint/lint2/msg_012.exp \
src/tests/usr.bin/xlint/lint2/msg_012.ln

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

Modified files:

Index: src/tests/usr.bin/xlint/lint2/msg_001.exp
diff -u src/tests/usr.bin/xlint/lint2/msg_001.exp:1.2 src/tests/usr.bin/xlint/lint2/msg_001.exp:1.3
--- src/tests/usr.bin/xlint/lint2/msg_001.exp:1.2	Fri Aug  6 16:21:00 2021
+++ src/tests/usr.bin/xlint/lint2/msg_001.exp	Sat Aug  7 19:07:03 2021
@@ -1,2 +1,2 @@
-defined_not_used defined( msg_000.c(2) ), but never used
-used_not_defined used( msg_000.c(3) ), but not defined
+defined_not_used defined( msg_001.c(2) ), but never used
+used_not_defined used( msg_001.c(3) ), but not defined
Index: src/tests/usr.bin/xlint/lint2/msg_001.ln
diff -u src/tests/usr.bin/xlint/lint2/msg_001.ln:1.2 src/tests/usr.bin/xlint/lint2/msg_001.ln:1.3
--- src/tests/usr.bin/xlint/lint2/msg_001.ln:1.2	Fri Aug  6 16:21:00 2021
+++ src/tests/usr.bin/xlint/lint2/msg_001.ln	Sat Aug  7 19:07:03 2021
@@ -1,11 +1,25 @@
-# $NetBSD: msg_001.ln,v 1.2 2021/08/06 16:21:00 rillig Exp $
+# $NetBSD: msg_001.ln,v 1.3 2021/08/07 19:07:03 rillig Exp $
 #
 # Test data for message 1 of lint2:
 #	%s defined( %s ), but never used
 #
 
-0smsg_000.c
-Smsg_000.c
+0smsg_001.c
+Smsg_001.c
 
 3c0.3p1i16used_not_definedf2IDI
 2d0.2do16defined_not_usedf0I
+
+# The function 'main' always counts as used.
+# int main(void) {}
+10d0.10d4mainF0I
+# extern main() {}
+12d0.12e4mainFI
+
+# If a function is declared once in old style and once with prototype,
+# the prototype definition is preferred; see chkname.
+#
+# extern merge_old_style_and_prototype();
+20d0.20e29merge_old_style_and_prototypeFI
+# extern int merge_old_style_and_prototype(char *);
+21d0.21e29merge_old_style_and_prototypeF1PCI

Index: src/tests/usr.bin/xlint/lint2/msg_003.exp
diff -u src/tests/usr.bin/xlint/lint2/msg_003.exp:1.1 src/tests/usr.bin/xlint/lint2/msg_003.exp:1.2
--- src/tests/usr.bin/xlint/lint2/msg_003.exp:1.1	Thu Aug  5 22:36:08 2021
+++ src/tests/usr.bin/xlint/lint2/msg_003.exp	Sat Aug  7 19:07:03 2021
@@ -0,0 +1,2 @@
+function defined( msg_003_a.c(10) ), but never used
+function multiply defined  	msg_003_a.c(10)  ::  msg_003_b.c(10)
Index: src/tests/usr.bin/xlint/lint2/msg_003.ln
diff -u src/tests/usr.bin/xlint/lint2/msg_003.ln:1.1 src/tests/usr.bin/xlint/lint2/msg_003.ln:1.2
--- src/tests/usr.bin/xlint/lint2/msg_003.ln:1.1	Thu Aug  5 22:36:08 2021
+++ src/tests/usr.bin/xlint/lint2/msg_003.ln	Sat Aug  7 19:07:03 2021
@@ -1,6 +1,14 @@
-# $NetBSD: msg_003.ln,v 1.1 2021/08/05 22:36:08 rillig Exp $
+# $NetBSD: msg_003.ln,v 1.2 2021/08/07 19:07:03 rillig Exp $
 #
 # Test data for message 3 of lint2:
 #	%s multiply defined  	%s  ::  %s
-#
-# TODO: add actual test data
+
+0smsg_003_a.c
+Smsg_003_a.c
+# msg_003_a.c:10: int function(void);
+10d0.10d8functionF0I
+
+0smsg_003_b.c
+Smsg_003_b.c
+# msg_003_b.c:10: int function(void);
+10d0.10d8functionF0I
Index: src/tests/usr.bin/xlint/lint2/msg_004.exp
diff -u src/tests/usr.bin/xlint/lint2/msg_004.exp:1.1 src/tests/usr.bin/xlint/lint2/msg_004.exp:1.2
--- src/tests/usr.bin/xlint/lint2/msg_004.exp:1.1	Thu Aug  5 22:36:08 2021
+++ src/tests/usr.bin/xlint/lint2/msg_004.exp	Sat Aug  7 19:07:03 2021
@@ -0,0 +1,6 @@
+add value used inconsistently  	msg_004_define.c(2)  ::  msg_004_call.c(4)
+add value declared inconsistently (double != int) 	msg_004_define.c(2)  ::  msg_004_call.c(2)
+add, arg 1 used inconsistently  	msg_004_define.c(2)[double]  ::  msg_004_call.c(4)[int]
+add, arg 2 used inconsistently  	msg_004_define.c(2)[double]  ::  msg_004_call.c(4)[int]
+add, arg 1 declared inconsistently (double != int)	msg_004_define.c(2) :: msg_004_call.c(2)
+add, arg 2 declared inconsistently (double != int)	msg_004_define.c(2) :: msg_004_call.c(2)
Index: src/tests/usr.bin/xlint/lint2/msg_004.ln
diff -u src/tests/usr.bin/xlint/lint2/msg_004.ln:1.1 src/tests/usr.bin/xlint/l

CVS commit: src/usr.bin/xlint

2021-08-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug  7 17:38:41 UTC 2021

Modified Files:
src/usr.bin/xlint: Makefile.inc
src/usr.bin/xlint/lint1: Makefile

Log Message:
lint: clean gcov files for lint2 and xlint as well


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/xlint/Makefile.inc
cvs rdiff -u -r1.82 -r1.83 src/usr.bin/xlint/lint1/Makefile

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/Makefile.inc
diff -u src/usr.bin/xlint/Makefile.inc:1.14 src/usr.bin/xlint/Makefile.inc:1.15
--- src/usr.bin/xlint/Makefile.inc:1.14	Sun Apr 18 22:51:24 2021
+++ src/usr.bin/xlint/Makefile.inc	Sat Aug  7 17:38:41 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.14 2021/04/18 22:51:24 rillig Exp $
+#	$NetBSD: Makefile.inc,v 1.15 2021/08/07 17:38:41 rillig Exp $
 
 .include 
 
@@ -17,6 +17,8 @@ ARCHSUBDIR=	${MACHINE_CPU}
 CPPFLAGS+=	-I${.CURDIR}/../arch/${ARCHSUBDIR}
 CPPFLAGS+=	-I${.CURDIR}/../common
 
+CLEANFILES+=	*.gcno *.gcda *.gcov
+
 .if exists(${.CURDIR}/../../Makefile.inc)
 .include "${.CURDIR}/../../Makefile.inc"
 .endif

Index: src/usr.bin/xlint/lint1/Makefile
diff -u src/usr.bin/xlint/lint1/Makefile:1.82 src/usr.bin/xlint/lint1/Makefile:1.83
--- src/usr.bin/xlint/lint1/Makefile:1.82	Sat Jul 31 18:16:42 2021
+++ src/usr.bin/xlint/lint1/Makefile	Sat Aug  7 17:38:41 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.82 2021/07/31 18:16:42 rillig Exp $
+#	$NetBSD: Makefile,v 1.83 2021/08/07 17:38:41 rillig Exp $
 
 .include 
 
@@ -29,7 +29,6 @@ COPTS.err.c+=	${${ACTIVE_CC} == "clang":
 BINDIR=		/usr/libexec
 
 CLEANFILES+=	${MAN}
-CLEANFILES+=	*.gcno *.gcda *.gcov
 
 .if ${USETOOLS} == "yes"
 LINT1=		${TOOLDIR}/libexec/${MACHINE_GNU_PLATFORM}-lint1



CVS commit: src/tests/usr.bin/xlint/lint2

2021-08-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Aug  6 16:21:00 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint2: msg_001.exp msg_001.ln msg_002.exp
msg_002.ln

Log Message:
tests/lint: add tests for declared but unused variables


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint2/msg_001.exp \
src/tests/usr.bin/xlint/lint2/msg_001.ln \
src/tests/usr.bin/xlint/lint2/msg_002.exp \
src/tests/usr.bin/xlint/lint2/msg_002.ln

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

Modified files:

Index: src/tests/usr.bin/xlint/lint2/msg_001.exp
diff -u src/tests/usr.bin/xlint/lint2/msg_001.exp:1.1 src/tests/usr.bin/xlint/lint2/msg_001.exp:1.2
--- src/tests/usr.bin/xlint/lint2/msg_001.exp:1.1	Thu Aug  5 22:36:08 2021
+++ src/tests/usr.bin/xlint/lint2/msg_001.exp	Fri Aug  6 16:21:00 2021
@@ -0,0 +1,2 @@
+defined_not_used defined( msg_000.c(2) ), but never used
+used_not_defined used( msg_000.c(3) ), but not defined
Index: src/tests/usr.bin/xlint/lint2/msg_001.ln
diff -u src/tests/usr.bin/xlint/lint2/msg_001.ln:1.1 src/tests/usr.bin/xlint/lint2/msg_001.ln:1.2
--- src/tests/usr.bin/xlint/lint2/msg_001.ln:1.1	Thu Aug  5 22:36:08 2021
+++ src/tests/usr.bin/xlint/lint2/msg_001.ln	Fri Aug  6 16:21:00 2021
@@ -1,6 +1,11 @@
-# $NetBSD: msg_001.ln,v 1.1 2021/08/05 22:36:08 rillig Exp $
+# $NetBSD: msg_001.ln,v 1.2 2021/08/06 16:21:00 rillig Exp $
 #
 # Test data for message 1 of lint2:
 #	%s defined( %s ), but never used
 #
-# TODO: add actual test data
+
+0smsg_000.c
+Smsg_000.c
+
+3c0.3p1i16used_not_definedf2IDI
+2d0.2do16defined_not_usedf0I
Index: src/tests/usr.bin/xlint/lint2/msg_002.exp
diff -u src/tests/usr.bin/xlint/lint2/msg_002.exp:1.1 src/tests/usr.bin/xlint/lint2/msg_002.exp:1.2
--- src/tests/usr.bin/xlint/lint2/msg_002.exp:1.1	Thu Aug  5 22:36:08 2021
+++ src/tests/usr.bin/xlint/lint2/msg_002.exp	Fri Aug  6 16:21:00 2021
@@ -0,0 +1,2 @@
+defined defined( msg_002.c(3) ), but never used
+only_declared declared( msg_002.c(2) ), but never used or defined
Index: src/tests/usr.bin/xlint/lint2/msg_002.ln
diff -u src/tests/usr.bin/xlint/lint2/msg_002.ln:1.1 src/tests/usr.bin/xlint/lint2/msg_002.ln:1.2
--- src/tests/usr.bin/xlint/lint2/msg_002.ln:1.1	Thu Aug  5 22:36:08 2021
+++ src/tests/usr.bin/xlint/lint2/msg_002.ln	Fri Aug  6 16:21:00 2021
@@ -1,6 +1,14 @@
-# $NetBSD: msg_002.ln,v 1.1 2021/08/05 22:36:08 rillig Exp $
+# $NetBSD: msg_002.ln,v 1.2 2021/08/06 16:21:00 rillig Exp $
 #
 # Test data for message 2 of lint2:
 #	%s declared( %s ), but never used or defined
 #
-# TODO: add actual test data
+
+0smsg_002.c
+Smsg_002.c
+
+# extern int only_declared;
+2d0.2e13only_declaredI
+
+# int defined;
+3d0.3t7definedI



CVS commit: src

2021-08-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Aug  5 22:36:08 UTC 2021

Modified Files:
src/distrib/sets/lists/tests: mi
src/etc/mtree: NetBSD.dist.tests
src/tests/usr.bin/xlint: Makefile
Added Files:
src/tests/usr.bin/xlint/lint2: Makefile msg_000.exp msg_000.ln
msg_001.exp msg_001.ln msg_002.exp msg_002.ln msg_003.exp
msg_003.ln msg_004.exp msg_004.ln msg_005.exp msg_005.ln
msg_006.exp msg_006.ln msg_007.exp msg_007.ln msg_008.exp
msg_008.ln msg_009.exp msg_009.ln msg_010.exp msg_010.ln
msg_011.exp msg_011.ln msg_012.exp msg_012.ln msg_013.exp
msg_013.ln msg_014.exp msg_014.ln msg_015.exp msg_015.ln
msg_016.exp msg_016.ln msg_017.exp msg_017.ln msg_018.exp
msg_018.ln t_lint2.sh

Log Message:
tests/lint: add test skeletons for messages from lint2


To generate a diff of this commit:
cvs rdiff -u -r1.1103 -r1.1104 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.185 -r1.186 src/etc/mtree/NetBSD.dist.tests
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint2/Makefile \
src/tests/usr.bin/xlint/lint2/msg_000.exp \
src/tests/usr.bin/xlint/lint2/msg_000.ln \
src/tests/usr.bin/xlint/lint2/msg_001.exp \
src/tests/usr.bin/xlint/lint2/msg_001.ln \
src/tests/usr.bin/xlint/lint2/msg_002.exp \
src/tests/usr.bin/xlint/lint2/msg_002.ln \
src/tests/usr.bin/xlint/lint2/msg_003.exp \
src/tests/usr.bin/xlint/lint2/msg_003.ln \
src/tests/usr.bin/xlint/lint2/msg_004.exp \
src/tests/usr.bin/xlint/lint2/msg_004.ln \
src/tests/usr.bin/xlint/lint2/msg_005.exp \
src/tests/usr.bin/xlint/lint2/msg_005.ln \
src/tests/usr.bin/xlint/lint2/msg_006.exp \
src/tests/usr.bin/xlint/lint2/msg_006.ln \
src/tests/usr.bin/xlint/lint2/msg_007.exp \
src/tests/usr.bin/xlint/lint2/msg_007.ln \
src/tests/usr.bin/xlint/lint2/msg_008.exp \
src/tests/usr.bin/xlint/lint2/msg_008.ln \
src/tests/usr.bin/xlint/lint2/msg_009.exp \
src/tests/usr.bin/xlint/lint2/msg_009.ln \
src/tests/usr.bin/xlint/lint2/msg_010.exp \
src/tests/usr.bin/xlint/lint2/msg_010.ln \
src/tests/usr.bin/xlint/lint2/msg_011.exp \
src/tests/usr.bin/xlint/lint2/msg_011.ln \
src/tests/usr.bin/xlint/lint2/msg_012.exp \
src/tests/usr.bin/xlint/lint2/msg_012.ln \
src/tests/usr.bin/xlint/lint2/msg_013.exp \
src/tests/usr.bin/xlint/lint2/msg_013.ln \
src/tests/usr.bin/xlint/lint2/msg_014.exp \
src/tests/usr.bin/xlint/lint2/msg_014.ln \
src/tests/usr.bin/xlint/lint2/msg_015.exp \
src/tests/usr.bin/xlint/lint2/msg_015.ln \
src/tests/usr.bin/xlint/lint2/msg_016.exp \
src/tests/usr.bin/xlint/lint2/msg_016.ln \
src/tests/usr.bin/xlint/lint2/msg_017.exp \
src/tests/usr.bin/xlint/lint2/msg_017.ln \
src/tests/usr.bin/xlint/lint2/msg_018.exp \
src/tests/usr.bin/xlint/lint2/msg_018.ln \
src/tests/usr.bin/xlint/lint2/t_lint2.sh

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1103 src/distrib/sets/lists/tests/mi:1.1104
--- src/distrib/sets/lists/tests/mi:1.1103	Thu Aug  5 06:34:42 2021
+++ src/distrib/sets/lists/tests/mi	Thu Aug  5 22:36:07 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1103 2021/08/05 06:34:42 rillig Exp $
+# $NetBSD: mi,v 1.1104 2021/08/05 22:36:07 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -7023,6 +7023,48 @@
 ./usr/tests/usr.bin/xlint/lint1/stmt_if.c			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/stmt_if.exp			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/t_integration			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint2	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint2/Atffiletests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint2/Kyuafile			tests-usr.bin-tests	compattestfile,atf,kyua
+./usr/tests/usr.bin/xlint/lint2/msg_000.exp			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint2/msg_000.ln			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint2/msg_001.exp			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint2/msg_001.ln			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint2/msg_002.exp			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint2/msg_002.ln			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint2/msg_003.exp			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint2/msg_003.ln			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint2/msg_004.exp			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint2/msg_004.ln			tests-usr.bin-tests	comp

CVS commit: src/usr.bin/xlint/lint2

2021-08-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Aug  5 06:54:16 UTC 2021

Modified Files:
src/usr.bin/xlint/lint2: read.c

Log Message:
lint: fix type of local variable in inpqstrg

Noted by Clang-Tidy.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/usr.bin/xlint/lint2/read.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/lint2/read.c
diff -u src/usr.bin/xlint/lint2/read.c:1.47 src/usr.bin/xlint/lint2/read.c:1.48
--- src/usr.bin/xlint/lint2/read.c:1.47	Thu Aug  5 06:45:37 2021
+++ src/usr.bin/xlint/lint2/read.c	Thu Aug  5 06:54:16 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: read.c,v 1.47 2021/08/05 06:45:37 rillig Exp $ */
+/* $NetBSD: read.c,v 1.48 2021/08/05 06:54:16 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: read.c,v 1.47 2021/08/05 06:45:37 rillig Exp $");
+__RCSID("$NetBSD: read.c,v 1.48 2021/08/05 06:54:16 rillig Exp $");
 #endif
 
 #include 
@@ -1057,7 +1057,7 @@ inpqstrg(const char *src, const char **e
 {
 	char	*strg, *dst;
 	size_t	slen;
-	int	c;
+	char	c;
 	int	v;
 
 	dst = strg = xmalloc(slen = 32);
@@ -1110,7 +1110,7 @@ inpqstrg(const char *src, const char **e
 if ((c = *src++) < '0' || c > '7')
 	inperr("not octal: %c", c);
 v |= c - '0';
-c = (u_char)v;
+c = (char)v;
 break;
 			default:
 inperr("bad \\ escape: %c", c);
@@ -1122,7 +1122,7 @@ inpqstrg(const char *src, const char **e
 			dst = strg + (slen - 1);
 			slen *= 2;
 		}
-		*dst++ = (char)c;
+		*dst++ = c;
 		if ((c = *src++) == '\0')
 			inperr("missing closing quote");
 	}



CVS commit: src/usr.bin/xlint/lint2

2021-08-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Aug  5 06:45:37 UTC 2021

Modified Files:
src/usr.bin/xlint/lint2: read.c

Log Message:
lint: fix handling of __int128_t/__uint128_t in lint2

Previously, lint exited with "bad type: J u".


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/usr.bin/xlint/lint2/read.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/lint2/read.c
diff -u src/usr.bin/xlint/lint2/read.c:1.46 src/usr.bin/xlint/lint2/read.c:1.47
--- src/usr.bin/xlint/lint2/read.c:1.46	Sat Jul 31 19:52:44 2021
+++ src/usr.bin/xlint/lint2/read.c	Thu Aug  5 06:45:37 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: read.c,v 1.46 2021/07/31 19:52:44 rillig Exp $ */
+/* $NetBSD: read.c,v 1.47 2021/08/05 06:45:37 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: read.c,v 1.46 2021/07/31 19:52:44 rillig Exp $");
+__RCSID("$NetBSD: read.c,v 1.47 2021/08/05 06:45:37 rillig Exp $");
 #endif
 
 #include 
@@ -838,6 +838,15 @@ gettlen(const char *cp, const char **epp
 			t = QUAD;
 		}
 		break;
+#ifdef INT128_SIZE
+	case 'J':
+		if (s == 'u') {
+			t = UINT128;
+		} else if (s == '\0') {
+			t = INT128;
+		}
+		break;
+#endif
 	case 'D':
 		if (s == 's') {
 			t = FLOAT;



CVS commit: src

2021-08-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Aug  5 06:34:43 UTC 2021

Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/usr.bin/xlint/lint1: Makefile accept.sh
Added Files:
src/tests/usr.bin/xlint/lint1: emit_lp64.c emit_lp64.exp-ln

Log Message:
tests/lint: test emitting 128-bit integer types for lint2


To generate a diff of this commit:
cvs rdiff -u -r1.1102 -r1.1103 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.101 -r1.102 src/tests/usr.bin/xlint/lint1/Makefile
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/accept.sh
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint1/emit_lp64.c \
src/tests/usr.bin/xlint/lint1/emit_lp64.exp-ln

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1102 src/distrib/sets/lists/tests/mi:1.1103
--- src/distrib/sets/lists/tests/mi:1.1102	Tue Aug  3 20:34:23 2021
+++ src/distrib/sets/lists/tests/mi	Thu Aug  5 06:34:42 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1102 2021/08/03 20:34:23 rillig Exp $
+# $NetBSD: mi,v 1.1103 2021/08/05 06:34:42 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -6236,6 +6236,8 @@
 ./usr/tests/usr.bin/xlint/lint1/emit.exp			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/emit.exp-ln			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/emit.lntests-obsolete		obsolete
+./usr/tests/usr.bin/xlint/lint1/emit_lp64.c			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/emit_lp64.exp-ln		tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/expr_binary.c			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/expr_binary.exp			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/expr_binary_trad.c		tests-usr.bin-tests	compattestfile,atf

Index: src/tests/usr.bin/xlint/lint1/Makefile
diff -u src/tests/usr.bin/xlint/lint1/Makefile:1.101 src/tests/usr.bin/xlint/lint1/Makefile:1.102
--- src/tests/usr.bin/xlint/lint1/Makefile:1.101	Tue Aug  3 20:34:23 2021
+++ src/tests/usr.bin/xlint/lint1/Makefile	Thu Aug  5 06:34:43 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.101 2021/08/03 20:34:23 rillig Exp $
+# $NetBSD: Makefile,v 1.102 2021/08/05 06:34:43 rillig Exp $
 
 NOMAN=		# defined
 MAX_MESSAGE=	345		# see lint1/err.c
@@ -131,6 +131,8 @@ FILES+=		decl_struct_member.exp
 FILES+=		emit.c
 FILES+=		emit.exp
 FILES+=		emit.exp-ln
+FILES+=		emit_lp64.c
+FILES+=		emit_lp64.exp-ln
 FILES+=		expr_binary.c
 FILES+=		expr_binary.exp
 FILES+=		expr_binary_trad.c

Index: src/tests/usr.bin/xlint/lint1/accept.sh
diff -u src/tests/usr.bin/xlint/lint1/accept.sh:1.3 src/tests/usr.bin/xlint/lint1/accept.sh:1.4
--- src/tests/usr.bin/xlint/lint1/accept.sh:1.3	Sun Jul 11 14:43:57 2021
+++ src/tests/usr.bin/xlint/lint1/accept.sh	Thu Aug  5 06:34:43 2021
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: accept.sh,v 1.3 2021/07/11 14:43:57 rillig Exp $
+# $NetBSD: accept.sh,v 1.4 2021/08/05 06:34:43 rillig Exp $
 #
 # Copyright (c) 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -41,7 +41,7 @@ for pattern in "$@"; do
 		cfile="$base.c"
 		expfile="$base.exp"
 		tmpfile="$base.exp.tmp"
-		ln_file="$base.ln"
+		ln_file="$base.exp-ln"
 
 		configure_test_case "$cfile"
 		# shellcheck disable=SC2154

Added files:

Index: src/tests/usr.bin/xlint/lint1/emit_lp64.c
diff -u /dev/null src/tests/usr.bin/xlint/lint1/emit_lp64.c:1.1
--- /dev/null	Thu Aug  5 06:34:43 2021
+++ src/tests/usr.bin/xlint/lint1/emit_lp64.c	Thu Aug  5 06:34:43 2021
@@ -0,0 +1,19 @@
+/*	$NetBSD: emit_lp64.c,v 1.1 2021/08/05 06:34:43 rillig Exp $	*/
+# 3 "emit_lp64.c"
+
+/*
+ * Test the symbol information that lint1 writes to a .ln file.  Using this
+ * symbol information, lint2 later checks that the symbols are used
+ * consistently across different translation units.
+ *
+ * This test covers large integer types that are only supported on LP64
+ * platforms.
+ */
+
+// omit the option '-g' to avoid having the GCC builtins in the .ln file.
+/* lint1-flags: -Sw */
+
+/* lint1-only-if: lp64 */
+
+__int128_t int128(__int128_t);
+__uint128_t uint128(__uint128_t);
Index: src/tests/usr.bin/xlint/lint1/emit_lp64.exp-ln
diff -u /dev/null src/tests/usr.bin/xlint/lint1/emit_lp64.exp-ln:1.1
--- /dev/null	Thu Aug  5 06:34:43 2021
+++ src/tests/usr.bin/xlint/lint1/emit_lp64.exp-ln	Thu Aug  5 06:34:43 2021
@@ -0,0 +1,4 @@
+0semit_lp64.c
+Semit_lp64.c
+18d0.18e6int128F1JJ
+19d0.19e7uint128F1uJuJ



CVS commit: src

2021-08-03 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Aug  3 21:18:24 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: gcc_cast_union.c gcc_cast_union.exp
src/usr.bin/xlint/lint1: decl.c

Log Message:
lint: in strict enum mode, error out on enum type mismatch in union cast


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/gcc_cast_union.c \
src/tests/usr.bin/xlint/lint1/gcc_cast_union.exp
cvs rdiff -u -r1.218 -r1.219 src/usr.bin/xlint/lint1/decl.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/gcc_cast_union.c
diff -u src/tests/usr.bin/xlint/lint1/gcc_cast_union.c:1.2 src/tests/usr.bin/xlint/lint1/gcc_cast_union.c:1.3
--- src/tests/usr.bin/xlint/lint1/gcc_cast_union.c:1.2	Tue Aug  3 21:09:26 2021
+++ src/tests/usr.bin/xlint/lint1/gcc_cast_union.c	Tue Aug  3 21:18:24 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: gcc_cast_union.c,v 1.2 2021/08/03 21:09:26 rillig Exp $	*/
+/*	$NetBSD: gcc_cast_union.c,v 1.3 2021/08/03 21:18:24 rillig Exp $	*/
 # 3 "gcc_cast_union.c"
 
 /*
@@ -81,7 +81,7 @@ test(void)
 	any = (union anything)E1;
 	any = (union anything)E2;
 	/* GCC allows enum mismatch even with -Wenum-conversion */
-	/* XXX: Lint should warn about enum type mismatch */
+	/* expect+1: error: type 'enum other_enum' is not a member of 'union anything' [329] */
 	any = (union anything)OTHER;
 	/* expect+1: error: type 'pointer to char' is not a member of 'union anything' [329] */
 	any = (union anything)"char *";
Index: src/tests/usr.bin/xlint/lint1/gcc_cast_union.exp
diff -u src/tests/usr.bin/xlint/lint1/gcc_cast_union.exp:1.2 src/tests/usr.bin/xlint/lint1/gcc_cast_union.exp:1.3
--- src/tests/usr.bin/xlint/lint1/gcc_cast_union.exp:1.2	Tue Aug  3 21:09:26 2021
+++ src/tests/usr.bin/xlint/lint1/gcc_cast_union.exp	Tue Aug  3 21:18:24 2021
@@ -1,3 +1,4 @@
+gcc_cast_union.c(85): error: type 'enum other_enum' is not a member of 'union anything' [329]
 gcc_cast_union.c(87): error: type 'pointer to char' is not a member of 'union anything' [329]
 gcc_cast_union.c(90): error: type 'pointer to double' is not a member of 'union anything' [329]
 gcc_cast_union.c(92): error: type 'pointer to double' is not a member of 'union anything' [329]

Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.218 src/usr.bin/xlint/lint1/decl.c:1.219
--- src/usr.bin/xlint/lint1/decl.c:1.218	Tue Aug  3 18:38:02 2021
+++ src/usr.bin/xlint/lint1/decl.c	Tue Aug  3 21:18:24 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.218 2021/08/03 18:38:02 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.219 2021/08/03 21:18:24 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.218 2021/08/03 18:38:02 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.219 2021/08/03 21:18:24 rillig Exp $");
 #endif
 
 #include 
@@ -2225,6 +2225,9 @@ eqtype(const type_t *tp1, const type_t *
 		if (t == STRUCT || t == UNION)
 			return tp1->t_str == tp2->t_str;
 
+		if (t == ENUM && eflag)
+			return tp1->t_enum == tp2->t_enum;
+
 		if (t == ARRAY && tp1->t_dim != tp2->t_dim) {
 			if (tp1->t_dim != 0 && tp2->t_dim != 0)
 return false;



CVS commit: src

2021-08-03 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Aug  3 21:09:26 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: gcc_cast_union.c gcc_cast_union.exp
src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: merge almost duplicate code from 'sametype' into 'eqtype'

In 'sametype', the branch for comparing array types was unreachable
since it requires both tspecs to be the same, but t2 underwent the
array-to-pointer conversion.

Previously, lint warned about enum type mismatches, even without -e for
strict enum mode.  Instead, it got the case for 'char *' wrong, which is
now fixed.  Now lint behaves like GCC 10.3.0 in this regard.  The
warning about enum mismatch is useful though, so it may be re-added in a
future commit.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/gcc_cast_union.c \
src/tests/usr.bin/xlint/lint1/gcc_cast_union.exp
cvs rdiff -u -r1.329 -r1.330 src/usr.bin/xlint/lint1/tree.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/gcc_cast_union.c
diff -u src/tests/usr.bin/xlint/lint1/gcc_cast_union.c:1.1 src/tests/usr.bin/xlint/lint1/gcc_cast_union.c:1.2
--- src/tests/usr.bin/xlint/lint1/gcc_cast_union.c:1.1	Tue Aug  3 20:34:23 2021
+++ src/tests/usr.bin/xlint/lint1/gcc_cast_union.c	Tue Aug  3 21:09:26 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: gcc_cast_union.c,v 1.1 2021/08/03 20:34:23 rillig Exp $	*/
+/*	$NetBSD: gcc_cast_union.c,v 1.2 2021/08/03 21:09:26 rillig Exp $	*/
 # 3 "gcc_cast_union.c"
 
 /*
@@ -11,6 +11,8 @@
  * https://gcc.gnu.org/onlinedocs/gcc/Cast-to-Union.html
  */
 
+/* lint1-extra-flags: -e */
+
 union anything {
 	_Bool m_bool;
 	char m_char;
@@ -79,9 +81,9 @@ test(void)
 	any = (union anything)E1;
 	any = (union anything)E2;
 	/* GCC allows enum mismatch even with -Wenum-conversion */
-	/* expect+1: error: type 'enum other_enum' is not a member of 'union anything' [329] */
+	/* XXX: Lint should warn about enum type mismatch */
 	any = (union anything)OTHER;
-	/* GCC strictly complains that 'char *' is not in the union. */
+	/* expect+1: error: type 'pointer to char' is not a member of 'union anything' [329] */
 	any = (union anything)"char *";
 	any = (union anything)(const char *)"char *";
 	/* expect+1: error: type 'pointer to double' is not a member of 'union anything' [329] */
Index: src/tests/usr.bin/xlint/lint1/gcc_cast_union.exp
diff -u src/tests/usr.bin/xlint/lint1/gcc_cast_union.exp:1.1 src/tests/usr.bin/xlint/lint1/gcc_cast_union.exp:1.2
--- src/tests/usr.bin/xlint/lint1/gcc_cast_union.exp:1.1	Tue Aug  3 20:34:23 2021
+++ src/tests/usr.bin/xlint/lint1/gcc_cast_union.exp	Tue Aug  3 21:09:26 2021
@@ -1,4 +1,4 @@
-gcc_cast_union.c(83): error: type 'enum other_enum' is not a member of 'union anything' [329]
-gcc_cast_union.c(88): error: type 'pointer to double' is not a member of 'union anything' [329]
+gcc_cast_union.c(87): error: type 'pointer to char' is not a member of 'union anything' [329]
 gcc_cast_union.c(90): error: type 'pointer to double' is not a member of 'union anything' [329]
-gcc_cast_union.c(92): error: type 'pointer to int' is not a member of 'union anything' [329]
+gcc_cast_union.c(92): error: type 'pointer to double' is not a member of 'union anything' [329]
+gcc_cast_union.c(94): error: type 'pointer to int' is not a member of 'union anything' [329]

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.329 src/usr.bin/xlint/lint1/tree.c:1.330
--- src/usr.bin/xlint/lint1/tree.c:1.329	Tue Aug  3 20:57:06 2021
+++ src/usr.bin/xlint/lint1/tree.c	Tue Aug  3 21:09:26 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.329 2021/08/03 20:57:06 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.330 2021/08/03 21:09:26 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.329 2021/08/03 20:57:06 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.330 2021/08/03 21:09:26 rillig Exp $");
 #endif
 
 #include 
@@ -102,36 +102,6 @@ op_name(op_t op)
 	return modtab[op].m_name;
 }
 
-static bool
-sametype(const type_t *t1, const type_t *t2)
-{
-
-	/* Maybe this can be merged into 'eqtype'. */
-
-	if (t1->t_tspec != t2->t_tspec)
-		return false;
-
-	/* Ignore const/volatile */
-
-	switch (t1->t_tspec) {
-	case ARRAY:
-		if (t1->t_dim != t2->t_dim)
-			return false;
-		/*FALLTHROUGH*/
-	case PTR:
-		return sametype(t1->t_subt, t2->t_subt);
-	case ENUM:
-		return strcmp(t1->t_enum->en_tag->s_name,
-		t2->t_enum->en_tag->s_name) == 0;
-	case STRUCT:
-	case UNION:
-		return strcmp(t1->t_str->sou_tag->s_name,
-		t2->t_str->sou_tag->s_name) == 0;
-	default:
-		return true;
-	}
-}
-
 /* Build 'pointer to tp', 'array of tp' or 'function returning tp'. */
 type_t *
 derive_type(type_t *tp, tspec_t t)
@@ -3401,7 +3371,8 @@ cast(tnode_t *tn, type_t *tp)
 			return NULL;
 	

CVS commit: src

2021-08-03 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Aug  3 20:57:06 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: d_c99_union_cast.c d_c99_union_cast.exp
msg_328.c msg_328.exp msg_329.c msg_329.exp
src/usr.bin/xlint/lint1: err.c tree.c

Log Message:
lint: union casts are only available as a GCC extension, not in C99


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/d_c99_union_cast.c
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/d_c99_union_cast.exp
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_328.c \
src/tests/usr.bin/xlint/lint1/msg_328.exp \
src/tests/usr.bin/xlint/lint1/msg_329.c
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_329.exp
cvs rdiff -u -r1.133 -r1.134 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.328 -r1.329 src/usr.bin/xlint/lint1/tree.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/d_c99_union_cast.c
diff -u src/tests/usr.bin/xlint/lint1/d_c99_union_cast.c:1.6 src/tests/usr.bin/xlint/lint1/d_c99_union_cast.c:1.7
--- src/tests/usr.bin/xlint/lint1/d_c99_union_cast.c:1.6	Tue Aug  3 20:46:10 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_union_cast.c	Tue Aug  3 20:57:06 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: d_c99_union_cast.c,v 1.6 2021/08/03 20:46:10 rillig Exp $	*/
+/*	$NetBSD: d_c99_union_cast.c,v 1.7 2021/08/03 20:57:06 rillig Exp $	*/
 # 3 "d_c99_union_cast.c"
 
 /* C99 does not define union cast, it is a GCC extension. */
@@ -18,9 +18,9 @@ union foo {
 void
 foo(struct bar *a)
 {
-	/* TODO: warn about union casts in general */
+	/* expect+1: error: union cast is a GCC extension [328] */
 	a = ((union foo)a).a;
-	/* expect+1: error: type 'pointer to char' is not a member of 'union foo' [329] */
+	/* expect+1: error: union cast is a GCC extension [328] */
 	a = ((union foo)"string");
 	a->a++;
 }

Index: src/tests/usr.bin/xlint/lint1/d_c99_union_cast.exp
diff -u src/tests/usr.bin/xlint/lint1/d_c99_union_cast.exp:1.5 src/tests/usr.bin/xlint/lint1/d_c99_union_cast.exp:1.6
--- src/tests/usr.bin/xlint/lint1/d_c99_union_cast.exp:1.5	Tue Aug  3 20:46:10 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_union_cast.exp	Tue Aug  3 20:57:06 2021
@@ -1 +1,2 @@
-d_c99_union_cast.c(24): error: type 'pointer to char' is not a member of 'union foo' [329]
+d_c99_union_cast.c(22): error: union cast is a GCC extension [328]
+d_c99_union_cast.c(24): error: union cast is a GCC extension [328]

Index: src/tests/usr.bin/xlint/lint1/msg_328.c
diff -u src/tests/usr.bin/xlint/lint1/msg_328.c:1.2 src/tests/usr.bin/xlint/lint1/msg_328.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_328.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_328.c	Tue Aug  3 20:57:06 2021
@@ -1,7 +1,19 @@
-/*	$NetBSD: msg_328.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_328.c,v 1.3 2021/08/03 20:57:06 rillig Exp $	*/
 # 3 "msg_328.c"
 
-// Test for message: union cast is a C9X feature [328]
+// Test for message: union cast is a GCC extension [328]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* lint1-flags: -Sw */
+
+union target {
+	int b;
+};
+
+void
+foo(void)
+{
+	union target arg = { 123 };
+	/* expect+1: error: union cast is a GCC extension [328] */
+	arg = (union target)3;
+	arg.b++;
+}
Index: src/tests/usr.bin/xlint/lint1/msg_328.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_328.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_328.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_328.exp:1.2	Sun Mar 21 20:45:00 2021
+++ src/tests/usr.bin/xlint/lint1/msg_328.exp	Tue Aug  3 20:57:06 2021
@@ -1 +1 @@
-msg_328.c(6): error: syntax error ':' [249]
+msg_328.c(17): error: union cast is a GCC extension [328]
Index: src/tests/usr.bin/xlint/lint1/msg_329.c
diff -u src/tests/usr.bin/xlint/lint1/msg_329.c:1.2 src/tests/usr.bin/xlint/lint1/msg_329.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_329.c:1.2	Sun Jan 24 17:44:37 2021
+++ src/tests/usr.bin/xlint/lint1/msg_329.c	Tue Aug  3 20:57:06 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_329.c,v 1.2 2021/01/24 17:44:37 rillig Exp $	*/
+/*	$NetBSD: msg_329.c,v 1.3 2021/08/03 20:57:06 rillig Exp $	*/
 # 3 "msg_329.c"
 
 // Test for message: type '%s' is not a member of '%s' [329]
@@ -30,9 +30,6 @@ example(void)
 	 *
 	 * This is a GCC extension.
 	 * See https://gcc.gnu.org/onlinedocs/gcc/Cast-to-Union.html.
-	 *
-	 * FIXME: lint says in message 328 that "union cast is a C9X feature",
-	 *  but that is wrong.  It is a GCC feature.
 	 */
 	union u u_i1 = (union u)3;
 	union u u_vp = (union u)(void *)0;

Index: src/tests/usr.bin/xlint/lint1/msg_329.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_329.exp:1.3 src/tests/usr.bin/xlint/lint1/msg_329.exp:1.4
--- src/tests/usr.bin/xlint/lint1/msg_329.exp:1.3	Sun Mar 21 20:45:00 2021
+++ src/tests/usr.bin/xlint/

CVS commit: src/tests/usr.bin/xlint/lint1

2021-08-03 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Aug  3 20:46:10 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: d_c99_union_cast.c d_c99_union_cast.exp

Log Message:
tests/lint: prepare non-GCC test for union casts


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/d_c99_union_cast.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/d_c99_union_cast.exp

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/d_c99_union_cast.c
diff -u src/tests/usr.bin/xlint/lint1/d_c99_union_cast.c:1.5 src/tests/usr.bin/xlint/lint1/d_c99_union_cast.c:1.6
--- src/tests/usr.bin/xlint/lint1/d_c99_union_cast.c:1.5	Tue Aug  3 20:34:23 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_union_cast.c	Tue Aug  3 20:46:10 2021
@@ -1,8 +1,10 @@
-/*	$NetBSD: d_c99_union_cast.c,v 1.5 2021/08/03 20:34:23 rillig Exp $	*/
+/*	$NetBSD: d_c99_union_cast.c,v 1.6 2021/08/03 20:46:10 rillig Exp $	*/
 # 3 "d_c99_union_cast.c"
 
 /* C99 does not define union cast, it is a GCC extension. */
 
+/* lint1-flags: -Sw */
+
 struct bar {
 	int a;
 	int b;
@@ -14,9 +16,11 @@ union foo {
 };
 
 void
-foo(void)
+foo(struct bar *a)
 {
-	struct bar *a;		/* expect: 192 */
-
-	((union foo)a).a;
+	/* TODO: warn about union casts in general */
+	a = ((union foo)a).a;
+	/* expect+1: error: type 'pointer to char' is not a member of 'union foo' [329] */
+	a = ((union foo)"string");
+	a->a++;
 }

Index: src/tests/usr.bin/xlint/lint1/d_c99_union_cast.exp
diff -u src/tests/usr.bin/xlint/lint1/d_c99_union_cast.exp:1.4 src/tests/usr.bin/xlint/lint1/d_c99_union_cast.exp:1.5
--- src/tests/usr.bin/xlint/lint1/d_c99_union_cast.exp:1.4	Fri Apr  9 20:12:00 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_union_cast.exp	Tue Aug  3 20:46:10 2021
@@ -1 +1 @@
-d_c99_union_cast.c(19): warning: 'a' unused in function 'foo' [192]
+d_c99_union_cast.c(24): error: type 'pointer to char' is not a member of 'union foo' [329]



CVS commit: src

2021-08-03 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Aug  3 20:34:23 UTC 2021

Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/usr.bin/xlint/lint1: Makefile d_c99_union_cast.c
Added Files:
src/tests/usr.bin/xlint/lint1: gcc_cast_union.c gcc_cast_union.exp

Log Message:
tests/lint: test GCC extension for casting to union type


To generate a diff of this commit:
cvs rdiff -u -r1.1101 -r1.1102 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.100 -r1.101 src/tests/usr.bin/xlint/lint1/Makefile
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/d_c99_union_cast.c
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint1/gcc_cast_union.c \
src/tests/usr.bin/xlint/lint1/gcc_cast_union.exp

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1101 src/distrib/sets/lists/tests/mi:1.1102
--- src/distrib/sets/lists/tests/mi:1.1101	Tue Aug  3 18:03:54 2021
+++ src/distrib/sets/lists/tests/mi	Tue Aug  3 20:34:23 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1101 2021/08/03 18:03:54 rillig Exp $
+# $NetBSD: mi,v 1.1102 2021/08/03 20:34:23 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -6266,6 +6266,8 @@
 ./usr/tests/usr.bin/xlint/lint1/gcc_attribute_var.exp		tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/gcc_bit_field_types.c		tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/gcc_bit_field_types.exp		tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/gcc_cast_union.c		tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/gcc_cast_union.exp		tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/gcc_init_compound_literal.c	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/gcc_init_compound_literal.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/gcc_stmt_asm.c			tests-usr.bin-tests	compattestfile,atf

Index: src/tests/usr.bin/xlint/lint1/Makefile
diff -u src/tests/usr.bin/xlint/lint1/Makefile:1.100 src/tests/usr.bin/xlint/lint1/Makefile:1.101
--- src/tests/usr.bin/xlint/lint1/Makefile:1.100	Tue Aug  3 18:03:54 2021
+++ src/tests/usr.bin/xlint/lint1/Makefile	Tue Aug  3 20:34:23 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.100 2021/08/03 18:03:54 rillig Exp $
+# $NetBSD: Makefile,v 1.101 2021/08/03 20:34:23 rillig Exp $
 
 NOMAN=		# defined
 MAX_MESSAGE=	345		# see lint1/err.c
@@ -160,6 +160,8 @@ FILES+=		gcc_attribute_var.c
 FILES+=		gcc_attribute_var.exp
 FILES+=		gcc_bit_field_types.c
 FILES+=		gcc_bit_field_types.exp
+FILES+=		gcc_cast_union.c
+FILES+=		gcc_cast_union.exp
 FILES+=		gcc_init_compound_literal.c
 FILES+=		gcc_init_compound_literal.exp
 FILES+=		gcc_stmt_asm.c

Index: src/tests/usr.bin/xlint/lint1/d_c99_union_cast.c
diff -u src/tests/usr.bin/xlint/lint1/d_c99_union_cast.c:1.4 src/tests/usr.bin/xlint/lint1/d_c99_union_cast.c:1.5
--- src/tests/usr.bin/xlint/lint1/d_c99_union_cast.c:1.4	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_union_cast.c	Tue Aug  3 20:34:23 2021
@@ -1,7 +1,7 @@
-/*	$NetBSD: d_c99_union_cast.c,v 1.4 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: d_c99_union_cast.c,v 1.5 2021/08/03 20:34:23 rillig Exp $	*/
 # 3 "d_c99_union_cast.c"
 
-/* union cast */
+/* C99 does not define union cast, it is a GCC extension. */
 
 struct bar {
 	int a;

Added files:

Index: src/tests/usr.bin/xlint/lint1/gcc_cast_union.c
diff -u /dev/null src/tests/usr.bin/xlint/lint1/gcc_cast_union.c:1.1
--- /dev/null	Tue Aug  3 20:34:23 2021
+++ src/tests/usr.bin/xlint/lint1/gcc_cast_union.c	Tue Aug  3 20:34:23 2021
@@ -0,0 +1,98 @@
+/*	$NetBSD: gcc_cast_union.c,v 1.1 2021/08/03 20:34:23 rillig Exp $	*/
+# 3 "gcc_cast_union.c"
+
+/*
+ * Test the GCC extension for casting to a union type.
+ *
+ * As of GCC 10.3.0, GCC only prints a generic warning without any details:
+ *	error: cast to union type from type not present in union
+ * No idea why it neither mentions the union type nor the actual type.
+ *
+ * https://gcc.gnu.org/onlinedocs/gcc/Cast-to-Union.html
+ */
+
+union anything {
+	_Bool m_bool;
+	char m_char;
+	signed char m_signed_char;
+	unsigned char m_unsigned_char;
+	short m_short;
+	unsigned short m_unsigned_short;
+	int m_int;
+	unsigned int m_unsigned_int;
+	long m_long;
+	unsigned long m_unsigned_long;
+	long long m_long_long;
+	unsigned long long m_unsigned_long_long;
+	/* skip __int128_t and __uint128_t for now */
+	float m_float;
+	double m_double;
+	long double m_long_double;
+
+	struct m_struct {
+		int member;
+	} m_struct;
+	union m_union {
+		int member;
+	} m_union;
+	enum m_enum1 {
+		E1
+	} m_enum1;
+	enum m_enum2 {
+		E2
+	} m_enum2;
+	const char *m_const_char_pointer;
+	double m_double_array[5];
+	void (*m_function)(void *);
+	void (*m_function_varargs)(void *, ...);
+	float _Co

CVS commit: src

2021-08-03 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Aug  3 18:44:33 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: c11_generic_expression.exp
d_c99_bool_strict_syshdr.exp d_fold_test.exp expr_cast.c
expr_cast.exp msg_096.exp msg_109.exp msg_126.exp msg_170.exp
msg_204.exp msg_214.c msg_214.exp msg_343.exp
src/usr.bin/xlint/lint1: err.c func.c

Log Message:
lint: add quotes around placeholder in message 214

function '%s' expects to return value


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 \
src/tests/usr.bin/xlint/lint1/c11_generic_expression.exp
cvs rdiff -u -r1.9 -r1.10 \
src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/d_fold_test.exp \
src/tests/usr.bin/xlint/lint1/msg_096.exp \
src/tests/usr.bin/xlint/lint1/msg_109.exp \
src/tests/usr.bin/xlint/lint1/msg_170.exp \
src/tests/usr.bin/xlint/lint1/msg_343.exp
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/expr_cast.c \
src/tests/usr.bin/xlint/lint1/expr_cast.exp
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_126.exp \
src/tests/usr.bin/xlint/lint1/msg_204.exp
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_214.c \
src/tests/usr.bin/xlint/lint1/msg_214.exp
cvs rdiff -u -r1.132 -r1.133 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.118 -r1.119 src/usr.bin/xlint/lint1/func.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/c11_generic_expression.exp
diff -u src/tests/usr.bin/xlint/lint1/c11_generic_expression.exp:1.7 src/tests/usr.bin/xlint/lint1/c11_generic_expression.exp:1.8
--- src/tests/usr.bin/xlint/lint1/c11_generic_expression.exp:1.7	Sun Jul 11 20:37:21 2021
+++ src/tests/usr.bin/xlint/lint1/c11_generic_expression.exp	Tue Aug  3 18:44:33 2021
@@ -1,4 +1,4 @@
-c11_generic_expression.c(29): warning: function classify_type_without_default expects to return value [214]
+c11_generic_expression.c(29): warning: function 'classify_type_without_default' expects to return value [214]
 c11_generic_expression.c(21): warning: argument 'var' unused in function 'classify_type_without_default' [231]
 c11_generic_expression.c(37): warning: argument 'var' unused in function 'classify_type_with_default' [231]
 c11_generic_expression.c(53): warning: argument 'c' unused in function 'classify_char' [231]

Index: src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp
diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp:1.9 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp:1.10
--- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp:1.9	Sun Mar 21 20:44:59 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict_syshdr.exp	Tue Aug  3 18:44:33 2021
@@ -3,4 +3,4 @@ d_c99_bool_strict_syshdr.c(53): error: c
 d_c99_bool_strict_syshdr.c(87): error: operands of '=' have incompatible types (_Bool != int) [107]
 d_c99_bool_strict_syshdr.c(162): error: return value type mismatch (_Bool) and (int) [211]
 d_c99_bool_strict_syshdr.c(175): error: operand of '!' must be bool, not 'int' [330]
-d_c99_bool_strict_syshdr.c(175): warning: function str_equal_bad expects to return value [214]
+d_c99_bool_strict_syshdr.c(175): warning: function 'str_equal_bad' expects to return value [214]

Index: src/tests/usr.bin/xlint/lint1/d_fold_test.exp
diff -u src/tests/usr.bin/xlint/lint1/d_fold_test.exp:1.4 src/tests/usr.bin/xlint/lint1/d_fold_test.exp:1.5
--- src/tests/usr.bin/xlint/lint1/d_fold_test.exp:1.4	Fri Apr  9 20:12:00 2021
+++ src/tests/usr.bin/xlint/lint1/d_fold_test.exp	Tue Aug  3 18:44:33 2021
@@ -10,5 +10,5 @@ d_fold_test.c(66): warning: argument 's'
 d_fold_test.c(67): error: controlling expressions must have scalar type [204]
 d_fold_test.c(67): warning: argument 's' unused in function 'do_while_struct' [231]
 d_fold_test.c(70): error: first operand must have scalar type, op ? : [170]
-d_fold_test.c(70): warning: function conditional_struct expects to return value [214]
+d_fold_test.c(70): warning: function 'conditional_struct' expects to return value [214]
 d_fold_test.c(70): warning: argument 's' unused in function 'conditional_struct' [231]
Index: src/tests/usr.bin/xlint/lint1/msg_096.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_096.exp:1.4 src/tests/usr.bin/xlint/lint1/msg_096.exp:1.5
--- src/tests/usr.bin/xlint/lint1/msg_096.exp:1.4	Fri Apr  9 20:12:01 2021
+++ src/tests/usr.bin/xlint/lint1/msg_096.exp	Tue Aug  3 18:44:33 2021
@@ -1,3 +1,3 @@
 msg_096.c(21): error: cannot dereference non-pointer type [96]
-msg_096.c(21): warning: function unary_asterisk expects to return value [214]
+msg_096.c(21): warning: function 'unary_asterisk' expects to return value [214]
 msg_096.c(19): warning: argument 'i' unused in function 'unary_asterisk' [231]
Index: src/tests/usr.bin/xlint/lint1/msg_109.exp
diff -u src/tests/usr.bin/x

CVS commit: src

2021-08-03 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Aug  3 18:38:02 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: expr_cast.c expr_cast.exp msg_214.c
msg_214.exp
src/usr.bin/xlint/lint1: decl.c tree.c

Log Message:
lint: casting to a struct is not allowed in C99, only with GCC


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/expr_cast.c \
src/tests/usr.bin/xlint/lint1/expr_cast.exp
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_214.c \
src/tests/usr.bin/xlint/lint1/msg_214.exp
cvs rdiff -u -r1.217 -r1.218 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.327 -r1.328 src/usr.bin/xlint/lint1/tree.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/expr_cast.c
diff -u src/tests/usr.bin/xlint/lint1/expr_cast.c:1.1 src/tests/usr.bin/xlint/lint1/expr_cast.c:1.2
--- src/tests/usr.bin/xlint/lint1/expr_cast.c:1.1	Tue Aug  3 18:03:54 2021
+++ src/tests/usr.bin/xlint/lint1/expr_cast.c	Tue Aug  3 18:38:02 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: expr_cast.c,v 1.1 2021/08/03 18:03:54 rillig Exp $	*/
+/*	$NetBSD: expr_cast.c,v 1.2 2021/08/03 18:38:02 rillig Exp $	*/
 # 3 "expr_cast.c"
 
 /*
@@ -6,8 +6,14 @@
  *
  * K&R C does not mention any restrictions on the target type.
  * C90 requires both the source type and the target type to be scalar.
+ *
+ * GCC allows casting to a struct type but there is no documentation about
+ * it at https://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html.  See
+ * c-typeck.c, function build_c_cast, RECORD_OR_UNION_TYPE_P.
  */
 
+/* lint1-flags: -Sw */
+
 struct S {
 	int member;
 };
@@ -20,14 +26,8 @@ cast(void)
 	} local = {
 		0.0
 	};
-	/* expect-3: warning: 'local' set but not used in function 'cast' [191] */
-	/*
-	 * ^^ XXX: The variable _is_ used, but only in a semantically wrong
-	 * expression.  Lint should rather warn about the invalid cast in the
-	 * 'return' statement, but since all C compilers since C90 are
-	 * required to detect this already, there is no point in duplicating
-	 * that work.
-	 */
 
+	/* expect+2: error: invalid cast from 'struct S' to 'struct S' [147] */
+	/* expect+1: warning: function cast expects to return value [214] */
 	return (struct S)local;
 }
Index: src/tests/usr.bin/xlint/lint1/expr_cast.exp
diff -u src/tests/usr.bin/xlint/lint1/expr_cast.exp:1.1 src/tests/usr.bin/xlint/lint1/expr_cast.exp:1.2
--- src/tests/usr.bin/xlint/lint1/expr_cast.exp:1.1	Tue Aug  3 18:03:54 2021
+++ src/tests/usr.bin/xlint/lint1/expr_cast.exp	Tue Aug  3 18:38:02 2021
@@ -1 +1,2 @@
-expr_cast.c(20): warning: 'local' set but not used in function 'cast' [191]
+expr_cast.c(32): error: invalid cast from 'struct S' to 'struct S' [147]
+expr_cast.c(32): warning: function cast expects to return value [214]

Index: src/tests/usr.bin/xlint/lint1/msg_214.c
diff -u src/tests/usr.bin/xlint/lint1/msg_214.c:1.2 src/tests/usr.bin/xlint/lint1/msg_214.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_214.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_214.c	Tue Aug  3 18:38:02 2021
@@ -1,7 +1,12 @@
-/*	$NetBSD: msg_214.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_214.c,v 1.3 2021/08/03 18:38:02 rillig Exp $	*/
 # 3 "msg_214.c"
 
 // Test for message: function %s expects to return value [214]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+int
+int_function(void)
+{
+	/* TODO: add quotes around '%s' */
+	/* expect+1: warning: function int_function expects to return value [214] */
+	return;
+}
Index: src/tests/usr.bin/xlint/lint1/msg_214.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_214.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_214.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_214.exp:1.2	Sun Mar 21 20:45:00 2021
+++ src/tests/usr.bin/xlint/lint1/msg_214.exp	Tue Aug  3 18:38:02 2021
@@ -1 +1 @@
-msg_214.c(6): error: syntax error ':' [249]
+msg_214.c(11): warning: function int_function expects to return value [214]

Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.217 src/usr.bin/xlint/lint1/decl.c:1.218
--- src/usr.bin/xlint/lint1/decl.c:1.217	Sun Aug  1 18:37:29 2021
+++ src/usr.bin/xlint/lint1/decl.c	Tue Aug  3 18:38:02 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.217 2021/08/01 18:37:29 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.218 2021/08/03 18:38:02 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.217 2021/08/01 18:37:29 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.218 2021/08/03 18:38:02 rillig Exp $");
 #endif
 
 #include 
@@ -2230,7 +2230,7 @@ eqtype(const type_t *tp1, const type_t *
 return false;
 		}
 
-		/* dont check prototypes for traditional */
+		/* don't ch

CVS commit: src

2021-08-03 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Aug  3 18:03:54 UTC 2021

Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/usr.bin/xlint/lint1: Makefile
Added Files:
src/tests/usr.bin/xlint/lint1: expr_cast.c expr_cast.exp

Log Message:
tests/lint: test casting a struct to another struct


To generate a diff of this commit:
cvs rdiff -u -r1.1100 -r1.1101 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.99 -r1.100 src/tests/usr.bin/xlint/lint1/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint1/expr_cast.c \
src/tests/usr.bin/xlint/lint1/expr_cast.exp

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1100 src/distrib/sets/lists/tests/mi:1.1101
--- src/distrib/sets/lists/tests/mi:1.1100	Sun Aug  1 16:29:28 2021
+++ src/distrib/sets/lists/tests/mi	Tue Aug  3 18:03:54 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1100 2021/08/01 16:29:28 rillig Exp $
+# $NetBSD: mi,v 1.1101 2021/08/03 18:03:54 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -6240,6 +6240,8 @@
 ./usr/tests/usr.bin/xlint/lint1/expr_binary.exp			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/expr_binary_trad.c		tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/expr_binary_trad.exp		tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/expr_cast.c			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/expr_cast.exp			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/expr_precedence.c		tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/expr_precedence.exp		tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/expr_range.c			tests-usr.bin-tests	compattestfile,atf

Index: src/tests/usr.bin/xlint/lint1/Makefile
diff -u src/tests/usr.bin/xlint/lint1/Makefile:1.99 src/tests/usr.bin/xlint/lint1/Makefile:1.100
--- src/tests/usr.bin/xlint/lint1/Makefile:1.99	Sun Aug  1 16:29:28 2021
+++ src/tests/usr.bin/xlint/lint1/Makefile	Tue Aug  3 18:03:54 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.99 2021/08/01 16:29:28 rillig Exp $
+# $NetBSD: Makefile,v 1.100 2021/08/03 18:03:54 rillig Exp $
 
 NOMAN=		# defined
 MAX_MESSAGE=	345		# see lint1/err.c
@@ -135,6 +135,8 @@ FILES+=		expr_binary.c
 FILES+=		expr_binary.exp
 FILES+=		expr_binary_trad.c
 FILES+=		expr_binary_trad.exp
+FILES+=		expr_cast.c
+FILES+=		expr_cast.exp
 FILES+=		expr_precedence.c
 FILES+=		expr_precedence.exp
 FILES+=		expr_range.c

Added files:

Index: src/tests/usr.bin/xlint/lint1/expr_cast.c
diff -u /dev/null src/tests/usr.bin/xlint/lint1/expr_cast.c:1.1
--- /dev/null	Tue Aug  3 18:03:54 2021
+++ src/tests/usr.bin/xlint/lint1/expr_cast.c	Tue Aug  3 18:03:54 2021
@@ -0,0 +1,33 @@
+/*	$NetBSD: expr_cast.c,v 1.1 2021/08/03 18:03:54 rillig Exp $	*/
+# 3 "expr_cast.c"
+
+/*
+ * Tests for value conversion using a cast-expression.
+ *
+ * K&R C does not mention any restrictions on the target type.
+ * C90 requires both the source type and the target type to be scalar.
+ */
+
+struct S {
+	int member;
+};
+
+struct S
+cast(void)
+{
+	struct S {
+		double incompatible;
+	} local = {
+		0.0
+	};
+	/* expect-3: warning: 'local' set but not used in function 'cast' [191] */
+	/*
+	 * ^^ XXX: The variable _is_ used, but only in a semantically wrong
+	 * expression.  Lint should rather warn about the invalid cast in the
+	 * 'return' statement, but since all C compilers since C90 are
+	 * required to detect this already, there is no point in duplicating
+	 * that work.
+	 */
+
+	return (struct S)local;
+}
Index: src/tests/usr.bin/xlint/lint1/expr_cast.exp
diff -u /dev/null src/tests/usr.bin/xlint/lint1/expr_cast.exp:1.1
--- /dev/null	Tue Aug  3 18:03:54 2021
+++ src/tests/usr.bin/xlint/lint1/expr_cast.exp	Tue Aug  3 18:03:54 2021
@@ -0,0 +1 @@
+expr_cast.c(20): warning: 'local' set but not used in function 'cast' [191]



CVS commit: src/usr.bin/xlint

2021-08-03 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Aug  3 17:44:59 UTC 2021

Modified Files:
src/usr.bin/xlint/common: emit.c externs.h tyname.c
src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: clean up and move 'sametype'

This function is only used by lint1.  That's good since the lint2 code
was completely broken, as it would regard any two struct types as being
the same.

Remove the large switch statement since it is unlikely that there will
be new type derivations in C anytime soon.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/xlint/common/emit.c
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/xlint/common/externs.h
cvs rdiff -u -r1.43 -r1.44 src/usr.bin/xlint/common/tyname.c
cvs rdiff -u -r1.326 -r1.327 src/usr.bin/xlint/lint1/tree.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/common/emit.c
diff -u src/usr.bin/xlint/common/emit.c:1.11 src/usr.bin/xlint/common/emit.c:1.12
--- src/usr.bin/xlint/common/emit.c:1.11	Sat Mar 27 11:08:00 2021
+++ src/usr.bin/xlint/common/emit.c	Tue Aug  3 17:44:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: emit.c,v 1.11 2021/03/27 11:08:00 rillig Exp $	*/
+/*	$NetBSD: emit.c,v 1.12 2021/08/03 17:44:58 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,10 +37,9 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: emit.c,v 1.11 2021/03/27 11:08:00 rillig Exp $");
+__RCSID("$NetBSD: emit.c,v 1.12 2021/08/03 17:44:58 rillig Exp $");
 #endif
 
-#include 
 #include 
 #include 
 

Index: src/usr.bin/xlint/common/externs.h
diff -u src/usr.bin/xlint/common/externs.h:1.17 src/usr.bin/xlint/common/externs.h:1.18
--- src/usr.bin/xlint/common/externs.h:1.17	Sun Aug  1 18:13:53 2021
+++ src/usr.bin/xlint/common/externs.h	Tue Aug  3 17:44:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: externs.h,v 1.17 2021/08/01 18:13:53 rillig Exp $	*/
+/*	$NetBSD: externs.h,v 1.18 2021/08/03 17:44:58 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -47,7 +47,6 @@ extern	void	inittyp(void);
  * tyname.c
  */
 extern	const char *type_name(const type_t *);
-extern	bool	sametype(const type_t *, const type_t *);
 extern	const	char *tspec_name(tspec_t);
 
 /*

Index: src/usr.bin/xlint/common/tyname.c
diff -u src/usr.bin/xlint/common/tyname.c:1.43 src/usr.bin/xlint/common/tyname.c:1.44
--- src/usr.bin/xlint/common/tyname.c:1.43	Fri Jul  2 18:22:09 2021
+++ src/usr.bin/xlint/common/tyname.c	Tue Aug  3 17:44:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tyname.c,v 1.43 2021/07/02 18:22:09 rillig Exp $	*/
+/*	$NetBSD: tyname.c,v 1.44 2021/08/03 17:44:58 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tyname.c,v 1.43 2021/07/02 18:22:09 rillig Exp $");
+__RCSID("$NetBSD: tyname.c,v 1.44 2021/08/03 17:44:58 rillig Exp $");
 #endif
 
 #include 
@@ -59,7 +59,7 @@ __RCSID("$NetBSD: tyname.c,v 1.43 2021/0
 
 /* A tree of strings. */
 typedef struct name_tree_node {
-	char *ntn_name;
+	const char *ntn_name;
 	struct name_tree_node *ntn_less;
 	struct name_tree_node *ntn_greater;
 } name_tree_node;
@@ -85,7 +85,7 @@ new_name_tree_node(const char *name)
 	return n;
 }
 
-/* Return the canonical instance of the string, with unlimited life time. */
+/* Return the canonical instance of the string, with unlimited lifetime. */
 static const char *
 intern(const char *name)
 {
@@ -189,70 +189,6 @@ tspec_name(tspec_t t)
 	}
 }
 
-bool
-sametype(const type_t *t1, const type_t *t2)
-{
-	tspec_t	t;
-
-	if (t1->t_tspec != t2->t_tspec)
-		return false;
-
-	/* Ignore const/volatile */
-
-	switch (t = t1->t_tspec) {
-	case BOOL:
-	case CHAR:
-	case UCHAR:
-	case SCHAR:
-	case SHORT:
-	case USHORT:
-	case INT:
-	case UINT:
-	case LONG:
-	case ULONG:
-	case QUAD:
-	case UQUAD:
-#ifdef INT128_SIZE
-	case INT128:
-	case UINT128:
-#endif
-	case FLOAT:
-	case DOUBLE:
-	case LDOUBLE:
-	case VOID:
-	case FUNC:
-	case COMPLEX:
-	case FCOMPLEX:
-	case DCOMPLEX:
-	case LCOMPLEX:
-		return true;
-	case ARRAY:
-		if (t1->t_dim != t2->t_dim)
-			return false;
-		/*FALLTHROUGH*/
-	case PTR:
-		return sametype(t1->t_subt, t2->t_subt);
-	case ENUM:
-#ifdef t_enum
-		return strcmp(t1->t_enum->en_tag->s_name,
-		t2->t_enum->en_tag->s_name) == 0;
-#else
-		return true;
-#endif
-	case STRUCT:
-	case UNION:
-#ifdef t_str
-		return strcmp(t1->t_str->sou_tag->s_name,
-		t2->t_str->sou_tag->s_name) == 0;
-#else
-		return true;
-#endif
-	default:
-		INTERNAL_ERROR("tyname(%d)", t);
-		return false;
-	}
-}
-
 static void
 type_name_of_function(buffer *buf, const type_t *tp)
 {

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.326 src/usr.bin/xlint/lint1/tree.c:1.327
--- src/usr.bin/xlint/lint1/tree.c:1.326	Sun Aug  1 19:11:54 2021
+++ src/usr.bin/xlint/lint1/tree.c	Tue Aug  3 17:44:59 2021
@@ -1,4 +

CVS commit: src/usr.bin/xlint/common

2021-08-03 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Aug  3 17:27:48 UTC 2021

Modified Files:
src/usr.bin/xlint/common: param.h

Log Message:
lint: reduce number of negations in preprocessor condition

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/xlint/common/param.h

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/common/param.h
diff -u src/usr.bin/xlint/common/param.h:1.8 src/usr.bin/xlint/common/param.h:1.9
--- src/usr.bin/xlint/common/param.h:1.8	Wed Dec 30 11:43:13 2020
+++ src/usr.bin/xlint/common/param.h	Tue Aug  3 17:27:48 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.8 2020/12/30 11:43:13 rillig Exp $	*/
+/*	$NetBSD: param.h,v 1.9 2021/08/03 17:27:48 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -63,7 +63,7 @@
 /*
  * The sparc64 long double code generation is broken in old gcc.
  */
-#if !defined(__sparc64__) || !defined(__GNUC__) || __GNUC__ > 2
+#if !(defined(__sparc64__) && defined(__GNUC__) && __GNUC__ <= 2)
 typedef	long double ldbl_t;
 #else
 typedef	double	ldbl_t;



CVS commit: src/usr.bin/xlint/common

2021-08-03 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Aug  3 17:20:02 UTC 2021

Modified Files:
src/usr.bin/xlint/common: mem.c

Log Message:
lint: make memory management code easier to read

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/xlint/common/mem.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/common/mem.c
diff -u src/usr.bin/xlint/common/mem.c:1.15 src/usr.bin/xlint/common/mem.c:1.16
--- src/usr.bin/xlint/common/mem.c:1.15	Sun Aug  1 18:13:53 2021
+++ src/usr.bin/xlint/common/mem.c	Tue Aug  3 17:20:02 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mem.c,v 1.15 2021/08/01 18:13:53 rillig Exp $	*/
+/*	$NetBSD: mem.c,v 1.16 2021/08/03 17:20:02 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: mem.c,v 1.15 2021/08/01 18:13:53 rillig Exp $");
+__RCSID("$NetBSD: mem.c,v 1.16 2021/08/03 17:20:02 rillig Exp $");
 #endif
 
 #include 
@@ -46,53 +46,41 @@ __RCSID("$NetBSD: mem.c,v 1.15 2021/08/0
 
 #include "lint.h"
 
-static void __attribute__((noreturn))
-nomem(void)
+static void *
+not_null(void *ptr)
 {
 
-	errx(1, "virtual memory exhausted");
+	if (ptr == NULL)
+		errx(1, "virtual memory exhausted");
+	return ptr;
 }
 
 void *
 xmalloc(size_t s)
 {
-	void	*p;
 
-	if ((p = malloc(s)) == NULL)
-		nomem();
-	return p;
+	return not_null(malloc(s));
 }
 
 void *
 xcalloc(size_t n, size_t s)
 {
-	void	*p;
 
-	if ((p = calloc(n, s)) == NULL)
-		nomem();
-	return p;
+	return not_null(calloc(n, s));
 }
 
 void *
 xrealloc(void *p, size_t s)
 {
-	void *n;
 
-	if ((n = realloc(p, s)) == NULL) {
-		free(p);
-		nomem();
-	}
-	return n;
+	return not_null(realloc(p, s));
 }
 
 char *
 xstrdup(const char *s)
 {
-	char	*s2;
 
-	if ((s2 = strdup(s)) == NULL)
-		nomem();
-	return s2;
+	return not_null(strdup(s));
 }
 
 char *
@@ -106,6 +94,6 @@ xasprintf(const char *fmt, ...)
 	e = vasprintf(&str, fmt, ap);
 	va_end(ap);
 	if (e < 0)
-		nomem();
+		not_null(NULL);
 	return str;
 }



CVS commit: src/usr.bin/make/unit-tests

2021-08-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Aug  3 04:46:49 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: varmod-order-numeric.mk
varmod-order-reverse.mk varmod-order-shuffle.mk
varmod-order-string.mk varmod-order.exp varmod-order.mk

Log Message:
tests/make: fix test for the variable modifier ':On'

The variable modifier ':On' sorts words numerically.  If these words are
not numeric at all, they get assigned the numeric value 0.  Internally,
':On' uses qsort for sorting the words.  Since qsort is not specified to
use a stable sorting algorithm, the test data must only use words that
either are written in the same way or that are numerically different.

The test varmod-order failed this requirement by trying to numerically
sort a list of non-numeric words.  This led to different results on BSD
and Ubuntu, as could be expected.

To fix the tests, distinguish between words and numbers in the tests.
While here, clean up the tests for all variants of the variable modifier
':O'.

Found by sjg on Ubuntu.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-order-numeric.mk \
src/usr.bin/make/unit-tests/varmod-order-reverse.mk \
src/usr.bin/make/unit-tests/varmod-order.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varmod-order-shuffle.mk \
src/usr.bin/make/unit-tests/varmod-order.mk
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/varmod-order-string.mk

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/make/unit-tests/varmod-order-numeric.mk
diff -u src/usr.bin/make/unit-tests/varmod-order-numeric.mk:1.4 src/usr.bin/make/unit-tests/varmod-order-numeric.mk:1.5
--- src/usr.bin/make/unit-tests/varmod-order-numeric.mk:1.4	Sat Jul 31 20:55:46 2021
+++ src/usr.bin/make/unit-tests/varmod-order-numeric.mk	Tue Aug  3 04:46:49 2021
@@ -1,11 +1,17 @@
-# $NetBSD: varmod-order-numeric.mk,v 1.4 2021/07/31 20:55:46 rillig Exp $
+# $NetBSD: varmod-order-numeric.mk,v 1.5 2021/08/03 04:46:49 rillig Exp $
 #
-# Tests for the :On variable modifier, which returns the words, sorted in
-# ascending numeric order.
+# Tests for the variable modifiers ':On', which returns the words, sorted in
+# ascending numeric order, and for ':Orn' and ':Onr', which additionally
+# reverse the order.
+#
+# The variable modifiers ':On', ':Onr' and ':Orn' were added in var.c 1.939
+# from 2021-07-30.
 
 # This list contains only 32-bit numbers since the make code needs to conform
 # to C90, which does not provide integer types larger than 32 bit.  It uses
-# 'long long' by default, but that type is overridable if necessary.
+# 'long long' by default, but that type is overridable if necessary to support
+# older environments.
+#
 # To get 53-bit integers even in C90, it would be possible to switch to
 # 'double' instead, but that would allow floating-point numbers as well, which
 # is out of scope for this variable modifier.
@@ -24,6 +30,14 @@ NUMBERS=	3 5 7 1 42 -42 5K -3m 1M 1k -2G
 .  error ${NUMBERS:Onr}
 .endif
 
+# Duplicate numbers are preserved in the output.  In this case the
+# equal-valued numbers are spelled the same, so they are indistinguishable in
+# the output.
+DUPLICATES=	3 1 2 2 1 1	# https://oeis.org/A034002
+.if ${DUPLICATES:On} != "1 1 1 2 2 3"
+.  error ${DUPLICATES:On}
+.endif
+
 # If there are several numbers that have the same integer value, they are
 # returned in unspecified order.
 SAME_VALUE:=	${:U 79 80 0x0050 81 :On}
@@ -32,9 +46,9 @@ SAME_VALUE:=	${:U 79 80 0x0050 81 :On}
 .endif
 
 # Hexadecimal and octal numbers are supported as well.
-OCTAL=		0 010 0x7 9
-.if ${OCTAL:On} != "0 0x7 010 9"
-.  error ${OCTAL:On}
+MIXED_BASE=	0 010 0x7 9
+.if ${MIXED_BASE:On} != "0 0x7 010 9"
+.  error ${MIXED_BASE:On}
 .endif
 
 all:
Index: src/usr.bin/make/unit-tests/varmod-order-reverse.mk
diff -u src/usr.bin/make/unit-tests/varmod-order-reverse.mk:1.4 src/usr.bin/make/unit-tests/varmod-order-reverse.mk:1.5
--- src/usr.bin/make/unit-tests/varmod-order-reverse.mk:1.4	Sat Oct 24 08:46:08 2020
+++ src/usr.bin/make/unit-tests/varmod-order-reverse.mk	Tue Aug  3 04:46:49 2021
@@ -1,13 +1,12 @@
-# $NetBSD: varmod-order-reverse.mk,v 1.4 2020/10/24 08:46:08 rillig Exp $
+# $NetBSD: varmod-order-reverse.mk,v 1.5 2021/08/03 04:46:49 rillig Exp $
 #
 # Tests for the :Or variable modifier, which returns the words, sorted in
 # descending order.
 
-NUMBERS=	one two three four five six seven eight nine ten
+WORDS=		one two three four five six seven eight nine ten
 
-.if ${NUMBERS:Or} != "two three ten six seven one nine four five eight"
-.  error ${NUMBERS:Or}
+.if ${WORDS:Or} != "two three ten six seven one nine four five eight"
+.  error ${WORDS:Or}
 .endif
 
 all:
-	@:;
Index: src/usr.bin/make/unit-tests/varmod-order.exp
diff -u src/usr.bin/make/unit-tests/varmod-order.exp:1.4 src/usr.bin/make/unit-tests/varmod-order.exp:1.

CVS commit: src/usr.bin/xlint/lint1

2021-08-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Aug  2 20:58:39 UTC 2021

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

Log Message:
lint: expand abbreviations in definitions of operator properties

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/xlint/lint1/oper.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/oper.c
diff -u src/usr.bin/xlint/lint1/oper.c:1.9 src/usr.bin/xlint/lint1/oper.c:1.10
--- src/usr.bin/xlint/lint1/oper.c:1.9	Sat Mar 20 20:56:58 2021
+++ src/usr.bin/xlint/lint1/oper.c	Mon Aug  2 20:58:39 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: oper.c,v 1.9 2021/03/20 20:56:58 rillig Exp $	*/
+/*	$NetBSD: oper.c,v 1.10 2021/08/02 20:58:39 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -36,17 +36,23 @@
 const mod_t modtab[NOPS] =
 #define begin_ops() {
 #define op(name, repr, \
-		bi, lo, tb, rb, \
-		in, ic, ar, sc, \
-		fo, va, ts, ba, \
-		se, lu, ru, pc, \
-		cm, ve, de, ew) \
+		is_binary, is_logical, takes_bool, requires_bool, \
+		is_integer, is_complex, is_arithmetic, is_scalar, \
+		can_fold, is_value, is_test, balances_operands, \
+		side_effects, left_unsigned, right_unsigned, \
+		precedence_confusion, is_comparison, \
+		valid_on_enum, bad_on_enum, warn_if_eq) \
 	{ \
-		bi + 0 > 0, lo + 0 > 0, tb + 0 > 0, rb + 0 > 0, \
-		in + 0 > 0, ic + 0 > 0, ar + 0 > 0, sc + 0 > 0, \
-		fo + 0 > 0, va + 0 > 0, ts + 0 > 0, ba + 0 > 0, \
-		se + 0 > 0, lu + 0 > 0, ru + 0 > 0, pc + 0 > 0, \
-		cm + 0 > 0, ve + 0 > 0, de + 0 > 0, ew + 0 > 0, \
+		is_binary	+ 0 > 0, is_logical		+ 0 > 0, \
+		takes_bool	+ 0 > 0, requires_bool		+ 0 > 0, \
+		is_integer	+ 0 > 0, is_complex		+ 0 > 0, \
+		is_arithmetic	+ 0 > 0, is_scalar		+ 0 > 0, \
+		can_fold	+ 0 > 0, is_value		+ 0 > 0, \
+		is_test		+ 0 > 0, balances_operands	+ 0 > 0, \
+		side_effects	+ 0 > 0, left_unsigned		+ 0 > 0, \
+		right_unsigned	+ 0 > 0, precedence_confusion	+ 0 > 0, \
+		is_comparison	+ 0 > 0, valid_on_enum		+ 0 > 0, \
+		bad_on_enum	+ 0 > 0, warn_if_eq		+ 0 > 0, \
 		repr, \
 	},
 #define end_ops(n) };



CVS commit: src/tests/usr.bin/xlint/lint1

2021-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  1 21:12:32 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: c11_generic_expression.c

Log Message:
tests/lint: fix test c11_generic_expression on ILP32

These platforms don't provide __uint128_t, at least not in lint.

The exact data type does not matter in this test, it just has to be
different from 'int'.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 \
src/tests/usr.bin/xlint/lint1/c11_generic_expression.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/c11_generic_expression.c
diff -u src/tests/usr.bin/xlint/lint1/c11_generic_expression.c:1.9 src/tests/usr.bin/xlint/lint1/c11_generic_expression.c:1.10
--- src/tests/usr.bin/xlint/lint1/c11_generic_expression.c:1.9	Sun Aug  1 13:09:38 2021
+++ src/tests/usr.bin/xlint/lint1/c11_generic_expression.c	Sun Aug  1 21:12:31 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: c11_generic_expression.c,v 1.9 2021/08/01 13:09:38 rillig Exp $	*/
+/*	$NetBSD: c11_generic_expression.c,v 1.10 2021/08/01 21:12:31 rillig Exp $	*/
 # 3 "c11_generic_expression.c"
 
 /*
@@ -101,6 +101,6 @@ primary_expression(void)
  * covered by the compilers, so there is no need for lint to double-check it.
  */
 const char *x = _Generic(
-(__uint128_t)1 + 1.0f,
+1ULL + 1.0f,
 int: 1
 );



CVS commit: src/usr.bin/xlint/lint1

2021-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  1 19:18:10 UTC 2021

Modified Files:
src/usr.bin/xlint/lint1: cgram.y

Log Message:
lint: clean up debug logging in the C grammar


To generate a diff of this commit:
cvs rdiff -u -r1.353 -r1.354 src/usr.bin/xlint/lint1/cgram.y

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/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.353 src/usr.bin/xlint/lint1/cgram.y:1.354
--- src/usr.bin/xlint/lint1/cgram.y:1.353	Sun Aug  1 06:40:37 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Sun Aug  1 19:18:10 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.353 2021/08/01 06:40:37 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.354 2021/08/01 19:18:10 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.353 2021/08/01 06:40:37 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.354 2021/08/01 19:18:10 rillig Exp $");
 #endif
 
 #include 
@@ -75,7 +75,7 @@ static	sym_t	*symbolrename(sym_t *, sbuf
 static void
 CLEAR_WARN_FLAGS(const char *file, size_t line)
 {
-	printf("%s:%zu: clearing flags\n", file, line);
+	debug_step("%s:%zu: clearing flags", file, line);
 	clear_warn_flags();
 	olwarn = LWARN_BAD;
 }
@@ -84,7 +84,7 @@ static void
 SAVE_WARN_FLAGS(const char *file, size_t line)
 {
 	lint_assert(olwarn == LWARN_BAD);
-	printf("%s:%zu: saving flags %d\n", file, line, lwarn);
+	debug_step("%s:%zu: saving flags %d", file, line, lwarn);
 	olwarn = lwarn;
 }
 
@@ -93,18 +93,16 @@ RESTORE_WARN_FLAGS(const char *file, siz
 {
 	if (olwarn != LWARN_BAD) {
 		lwarn = olwarn;
-		printf("%s:%zu: restoring flags %d\n", file, line, lwarn);
+		debug_step("%s:%zu: restoring flags %d", file, line, lwarn);
 		olwarn = LWARN_BAD;
 	} else
 		CLEAR_WARN_FLAGS(file, line);
 }
-#define cgram_debug(fmt, args...) printf("cgram_debug: " fmt "\n", ##args)
 #else
 #define CLEAR_WARN_FLAGS(f, l)	clear_warn_flags(), olwarn = LWARN_BAD
 #define SAVE_WARN_FLAGS(f, l)	olwarn = lwarn
 #define RESTORE_WARN_FLAGS(f, l) \
 	(void)(olwarn == LWARN_BAD ? (clear_warn_flags(), 0) : (lwarn = olwarn))
-#define cgram_debug(fmt, args...) do { } while (false)
 #endif
 
 #define clear_warning_flags()	CLEAR_WARN_FLAGS(__FILE__, __LINE__)
@@ -383,11 +381,11 @@ identifier_sym:			/* helper for struct/u
 /* K&R ???, C90 ???, C99 6.4.2.1, C11 ??? */
 identifier:
 	  T_NAME {
-		cgram_debug("name '%s'", $1->sb_name);
+		debug_printf("cgram: name '%s'", $1->sb_name);
 		$$ = $1;
 	  }
 	| T_TYPENAME {
-		cgram_debug("typename '%s'", $1->sb_name);
+		debug_printf("cgram: typename '%s'", $1->sb_name);
 		$$ = $1;
 	  }
 	;



CVS commit: src/usr.bin/xlint/lint1

2021-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  1 19:11:54 UTC 2021

Modified Files:
src/usr.bin/xlint/lint1: debug.c externs1.h main1.c tree.c

Log Message:
lint: merge duplicate debugging code

The functions 'debug_node' and 'display_expression' were similar enough
to be merged.

Migrate debug_node to use the existing debug logging functions.

Remove the now unused option 'd' from the options string.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/xlint/lint1/debug.c
cvs rdiff -u -r1.127 -r1.128 src/usr.bin/xlint/lint1/externs1.h
cvs rdiff -u -r1.52 -r1.53 src/usr.bin/xlint/lint1/main1.c
cvs rdiff -u -r1.325 -r1.326 src/usr.bin/xlint/lint1/tree.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/debug.c
diff -u src/usr.bin/xlint/lint1/debug.c:1.1 src/usr.bin/xlint/lint1/debug.c:1.2
--- src/usr.bin/xlint/lint1/debug.c:1.1	Sat Jul 31 18:16:42 2021
+++ src/usr.bin/xlint/lint1/debug.c	Sun Aug  1 19:11:54 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: debug.c,v 1.1 2021/07/31 18:16:42 rillig Exp $ */
+/* $NetBSD: debug.c,v 1.2 2021/08/01 19:11:54 rillig Exp $ */
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -35,9 +35,11 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: debug.c,v 1.1 2021/07/31 18:16:42 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.2 2021/08/01 19:11:54 rillig Exp $");
 #endif
 
+#include 
+
 #include "lint1.h"
 
 
@@ -104,40 +106,54 @@ void
 }
 
 void
-debug_node(const tnode_t *tn, int indent)
+debug_node(const tnode_t *tn)
 {
 	op_t op;
 
 	if (tn == NULL) {
-		printf("%*s" "null\n", indent, "");
+		debug_step("null");
 		return;
 	}
 
 	op = tn->tn_op;
-	printf("%*s%s with type '%s'%s%s",
-	2 * indent, "",
+	debug_indent();
+	debug_printf("'%s' with type '%s'%s%s",
 	op == CVT && !tn->tn_cast ? "convert" : modtab[op].m_name,
 	type_name(tn->tn_type), tn->tn_lvalue ? ", lvalue" : "",
 	tn->tn_parenthesized ? ", parenthesized" : "");
 
 	if (op == NAME)
-		printf(" %s\n", tn->tn_sym->s_name);
+		debug_printf(" %s %s\n", tn->tn_sym->s_name,
+		storage_class_name(tn->tn_sym->s_scl));
 	else if (op == CON && is_floating(tn->tn_type->t_tspec))
-		printf(", value %Lg", tn->tn_val->v_ldbl);
+		debug_printf(", value %Lg", tn->tn_val->v_ldbl);
 	else if (op == CON && is_uinteger(tn->tn_type->t_tspec))
-		printf(", value %llu\n", (unsigned long long)tn->tn_val->v_quad);
+		debug_printf(", value %llu\n", (unsigned long long)tn->tn_val->v_quad);
 	else if (op == CON && is_integer(tn->tn_type->t_tspec))
-		printf(", value %lld\n", (long long)tn->tn_val->v_quad);
+		debug_printf(", value %lld\n", (long long)tn->tn_val->v_quad);
 	else if (op == CON)
-		printf(", unknown value\n");
-	else if (op == STRING)
-		printf(", length %zu\n", tn->tn_string->st_len);
-	else {
-		printf("\n");
+		debug_printf(", unknown value\n");
+	else if (op == STRING && tn->tn_string->st_tspec == CHAR)
+		debug_printf(", length %zu, \"%s\"\n",
+		tn->tn_string->st_len, tn->tn_string->st_cp);
+	else if (op == STRING && tn->tn_string->st_tspec == WCHAR) {
+		char *s;
+		size_t n;
+		n = MB_CUR_MAX * (tn->tn_string->st_len + 1);
+		s = xmalloc(n);
+		(void)wcstombs(s, tn->tn_string->st_wcp, n);
+		debug_printf(", length %zu, L\"%s\"",
+		tn->tn_string->st_len, s);
+		free(s);
+
+	} else {
+		debug_printf("\n");
 
-		debug_node(tn->tn_left, indent + 1);
+		debug_indent_inc();
+		debug_node(tn->tn_left);
 		if (modtab[op].m_binary || tn->tn_right != NULL)
-			debug_node(tn->tn_right, indent + 1);
+			debug_node(tn->tn_right);
+		debug_indent_dec();
 	}
 }
 

Index: src/usr.bin/xlint/lint1/externs1.h
diff -u src/usr.bin/xlint/lint1/externs1.h:1.127 src/usr.bin/xlint/lint1/externs1.h:1.128
--- src/usr.bin/xlint/lint1/externs1.h:1.127	Sun Aug  1 18:37:29 2021
+++ src/usr.bin/xlint/lint1/externs1.h	Sun Aug  1 19:11:54 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: externs1.h,v 1.127 2021/08/01 18:37:29 rillig Exp $	*/
+/*	$NetBSD: externs1.h,v 1.128 2021/08/01 19:11:54 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -115,7 +115,7 @@ extern	void	expr_restore_memory(struct m
  */
 
 #ifdef DEBUG
-void	debug_node(const tnode_t *, int);
+void	debug_node(const tnode_t *);
 void	debug_printf(const char *fmt, ...) __printflike(1, 2);
 void	debug_indent(void);
 void	debug_indent_inc(void);
@@ -127,7 +127,7 @@ void	debug_leave(const char *);
 #define	debug_leave()		(debug_leave)(__func__)
 #else
 #define	debug_noop()		do { } while (false)
-#define	debug_node(tn, indent)	debug_noop()
+#define	debug_node(tn)		debug_noop()
 #define	debug_printf(...)	debug_noop()
 #define	debug_indent()		debug_noop()
 #define	debug_step(...)		debug_noop()

Index: src/usr.bin/xlint/lint1/main1.c
diff -u src/usr.bin/xlint/lint1/main1.c:1.52 src/usr.bin/xlint/lint1/main1.c:1.53
--- src/usr.bin/xlint/lint1/main1.c:1.52	Sun Aug  1 18:37:29 2021
+++ sr

CVS commit: src/usr.bin/xlint/lint1

2021-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  1 18:37:29 UTC 2021

Modified Files:
src/usr.bin/xlint/lint1: decl.c externs1.h main1.c tree.c

Log Message:
lint: remove option -d, clean up debug logging

The command line option -d was not used by /usr/bin/lint, and it only
triggered a handful of debug messages.  Move this debug logging over to
the compile-time -DDEBUG setting.

Move display_expression further up to avoid the forward declaration.


To generate a diff of this commit:
cvs rdiff -u -r1.216 -r1.217 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.126 -r1.127 src/usr.bin/xlint/lint1/externs1.h
cvs rdiff -u -r1.51 -r1.52 src/usr.bin/xlint/lint1/main1.c
cvs rdiff -u -r1.324 -r1.325 src/usr.bin/xlint/lint1/tree.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/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.216 src/usr.bin/xlint/lint1/decl.c:1.217
--- src/usr.bin/xlint/lint1/decl.c:1.216	Sun Aug  1 06:40:37 2021
+++ src/usr.bin/xlint/lint1/decl.c	Sun Aug  1 18:37:29 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.216 2021/08/01 06:40:37 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.217 2021/08/01 18:37:29 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.216 2021/08/01 06:40:37 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.217 2021/08/01 18:37:29 rillig Exp $");
 #endif
 
 #include 
@@ -649,8 +649,7 @@ begin_declaration_level(scl_t sc)
 	dcs = di;
 	di->d_ctx = sc;
 	di->d_ldlsym = &di->d_dlsyms;
-	if (dflag)
-		(void)printf("%s(%p %s)\n", __func__, dcs, scl_name(sc));
+	debug_step("%s(%p %s)", __func__, dcs, scl_name(sc));
 }
 
 /*
@@ -661,9 +660,7 @@ end_declaration_level(void)
 {
 	dinfo_t	*di;
 
-	if (dflag)
-		(void)printf("%s(%p %s)\n",
-		__func__, dcs, scl_name(dcs->d_ctx));
+	debug_step("%s(%p %s)", __func__, dcs, scl_name(dcs->d_ctx));
 
 	lint_assert(dcs->d_next != NULL);
 	di = dcs;

Index: src/usr.bin/xlint/lint1/externs1.h
diff -u src/usr.bin/xlint/lint1/externs1.h:1.126 src/usr.bin/xlint/lint1/externs1.h:1.127
--- src/usr.bin/xlint/lint1/externs1.h:1.126	Sat Jul 31 19:12:35 2021
+++ src/usr.bin/xlint/lint1/externs1.h	Sun Aug  1 18:37:29 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: externs1.h,v 1.126 2021/07/31 19:12:35 rillig Exp $	*/
+/*	$NetBSD: externs1.h,v 1.127 2021/08/01 18:37:29 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -38,7 +38,6 @@ extern	int	aflag;
 extern	bool	bflag;
 extern	bool	cflag;
 extern	bool	c11flag;
-extern	bool	dflag;
 extern	bool	eflag;
 extern	bool	Fflag;
 extern	bool	gflag;

Index: src/usr.bin/xlint/lint1/main1.c
diff -u src/usr.bin/xlint/lint1/main1.c:1.51 src/usr.bin/xlint/lint1/main1.c:1.52
--- src/usr.bin/xlint/lint1/main1.c:1.51	Sun Aug  1 06:40:37 2021
+++ src/usr.bin/xlint/lint1/main1.c	Sun Aug  1 18:37:29 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: main1.c,v 1.51 2021/08/01 06:40:37 rillig Exp $	*/
+/*	$NetBSD: main1.c,v 1.52 2021/08/01 18:37:29 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: main1.c,v 1.51 2021/08/01 06:40:37 rillig Exp $");
+__RCSID("$NetBSD: main1.c,v 1.52 2021/08/01 18:37:29 rillig Exp $");
 #endif
 
 #include 
@@ -71,9 +71,6 @@ bool	cflag;
 /* Allow features from C11, C99 and C90. */
 bool	c11flag;
 
-/* Print various debug information. */
-bool	dflag;
-
 /* Perform stricter checking of enum types and operations on enum types. */
 bool	eflag;
 
@@ -186,7 +183,6 @@ main(int argc, char *argv[])
 		case 'a':	aflag++;	break;
 		case 'b':	bflag = true;	break;
 		case 'c':	cflag = true;	break;
-		case 'd':	dflag = true;	break;
 		case 'e':	eflag = true;	break;
 		case 'F':	Fflag = true;	break;
 		case 'g':	gflag = true;	break;
@@ -257,8 +253,6 @@ main(int argc, char *argv[])
 #ifdef DEBUG
 	setvbuf(stdout, NULL, _IONBF, 0);
 #endif
-	if (dflag)
-		setvbuf(stdout, NULL, _IONBF, 0);
 #ifdef YYDEBUG
 	if (yflag)
 		yydebug = 1;

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.324 src/usr.bin/xlint/lint1/tree.c:1.325
--- src/usr.bin/xlint/lint1/tree.c:1.324	Sun Aug  1 14:45:39 2021
+++ src/usr.bin/xlint/lint1/tree.c	Sun Aug  1 18:37:29 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.324 2021/08/01 14:45:39 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.325 2021/08/01 18:37:29 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.324 2021/08/01 14:45:39 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.325 2021/08/01 18:37:29 rillig Exp $");
 #endif
 
 #include 
@@ -90,7 +90,6 @@ static	tnode_t	*fold_float(tnode_t *);
 static	tnode_t	*check_function_arguments(type_t *, tnode_t *);
 static	tnode_t	*check_prototype_argument(int, type_t *

CVS commit: src/usr.bin/xlint

2021-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  1 18:13:54 UTC 2021

Modified Files:
src/usr.bin/xlint/common: externs.h mem.c
src/usr.bin/xlint/xlint: xlint.c

Log Message:
lint: make xasprintf simpler

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/xlint/common/externs.h
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/xlint/common/mem.c
cvs rdiff -u -r1.63 -r1.64 src/usr.bin/xlint/xlint/xlint.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/common/externs.h
diff -u src/usr.bin/xlint/common/externs.h:1.16 src/usr.bin/xlint/common/externs.h:1.17
--- src/usr.bin/xlint/common/externs.h:1.16	Sun Aug  1 18:07:35 2021
+++ src/usr.bin/xlint/common/externs.h	Sun Aug  1 18:13:53 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: externs.h,v 1.16 2021/08/01 18:07:35 rillig Exp $	*/
+/*	$NetBSD: externs.h,v 1.17 2021/08/01 18:13:53 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -57,7 +57,7 @@ extern	void	*xmalloc(size_t);
 extern	void	*xcalloc(size_t, size_t);
 extern	void	*xrealloc(void *, size_t);
 extern	char	*xstrdup(const char *);
-extern  void	xasprintf(char **, const char *, ...) __printflike(2, 3);
+extern  char	*xasprintf(const char *, ...) __printflike(1, 2);
 
 /*
  * emit.c

Index: src/usr.bin/xlint/common/mem.c
diff -u src/usr.bin/xlint/common/mem.c:1.14 src/usr.bin/xlint/common/mem.c:1.15
--- src/usr.bin/xlint/common/mem.c:1.14	Sun Aug  1 18:07:35 2021
+++ src/usr.bin/xlint/common/mem.c	Sun Aug  1 18:13:53 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mem.c,v 1.14 2021/08/01 18:07:35 rillig Exp $	*/
+/*	$NetBSD: mem.c,v 1.15 2021/08/01 18:13:53 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: mem.c,v 1.14 2021/08/01 18:07:35 rillig Exp $");
+__RCSID("$NetBSD: mem.c,v 1.15 2021/08/01 18:13:53 rillig Exp $");
 #endif
 
 #include 
@@ -82,8 +82,7 @@ xrealloc(void *p, size_t s)
 		free(p);
 		nomem();
 	}
-	p = n;
-	return p;
+	return n;
 }
 
 char *
@@ -96,15 +95,17 @@ xstrdup(const char *s)
 	return s2;
 }
 
-void
-xasprintf(char **buf, const char *fmt, ...)
+char *
+xasprintf(const char *fmt, ...)
 {
+	char *str;
 	int e;
 	va_list ap;
 
 	va_start(ap, fmt);
-	e = vasprintf(buf, fmt, ap);
+	e = vasprintf(&str, fmt, ap);
 	va_end(ap);
 	if (e < 0)
 		nomem();
+	return str;
 }

Index: src/usr.bin/xlint/xlint/xlint.c
diff -u src/usr.bin/xlint/xlint/xlint.c:1.63 src/usr.bin/xlint/xlint/xlint.c:1.64
--- src/usr.bin/xlint/xlint/xlint.c:1.63	Sun May  2 21:05:42 2021
+++ src/usr.bin/xlint/xlint/xlint.c	Sun Aug  1 18:13:53 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: xlint.c,v 1.63 2021/05/02 21:05:42 rillig Exp $ */
+/* $NetBSD: xlint.c,v 1.64 2021/08/01 18:13:53 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: xlint.c,v 1.63 2021/05/02 21:05:42 rillig Exp $");
+__RCSID("$NetBSD: xlint.c,v 1.64 2021/08/01 18:13:53 rillig Exp $");
 #endif
 
 #include 
@@ -696,9 +696,9 @@ fname(const char *name)
 			return;
 		}
 		len = bn == suff ? strlen(bn) : (size_t)((suff - 1) - bn);
-		xasprintf(&ofn, "%.*s.ln", (int)len, bn);
+		ofn = xasprintf("%.*s.ln", (int)len, bn);
 	} else {
-		xasprintf(&ofn, "%slint1.XX", tmpdir);
+		ofn = xasprintf("%slint1.XX", tmpdir);
 		fd = mkstemp(ofn);
 		if (fd == -1) {
 			warn("can't make temp");



CVS commit: src/usr.bin/xlint

2021-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  1 18:07:35 UTC 2021

Modified Files:
src/usr.bin/xlint/common: externs.h mem.c
src/usr.bin/xlint/lint1: mem1.c

Log Message:
lint: unexport nomem

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/xlint/common/externs.h
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/xlint/common/mem.c
cvs rdiff -u -r1.46 -r1.47 src/usr.bin/xlint/lint1/mem1.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/common/externs.h
diff -u src/usr.bin/xlint/common/externs.h:1.15 src/usr.bin/xlint/common/externs.h:1.16
--- src/usr.bin/xlint/common/externs.h:1.15	Sun Aug  1 17:59:47 2021
+++ src/usr.bin/xlint/common/externs.h	Sun Aug  1 18:07:35 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: externs.h,v 1.15 2021/08/01 17:59:47 rillig Exp $	*/
+/*	$NetBSD: externs.h,v 1.16 2021/08/01 18:07:35 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -57,7 +57,6 @@ extern	void	*xmalloc(size_t);
 extern	void	*xcalloc(size_t, size_t);
 extern	void	*xrealloc(void *, size_t);
 extern	char	*xstrdup(const char *);
-extern	void	nomem(void);
 extern  void	xasprintf(char **, const char *, ...) __printflike(2, 3);
 
 /*

Index: src/usr.bin/xlint/common/mem.c
diff -u src/usr.bin/xlint/common/mem.c:1.13 src/usr.bin/xlint/common/mem.c:1.14
--- src/usr.bin/xlint/common/mem.c:1.13	Sun Aug  1 17:59:47 2021
+++ src/usr.bin/xlint/common/mem.c	Sun Aug  1 18:07:35 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mem.c,v 1.13 2021/08/01 17:59:47 rillig Exp $	*/
+/*	$NetBSD: mem.c,v 1.14 2021/08/01 18:07:35 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,18 +37,22 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: mem.c,v 1.13 2021/08/01 17:59:47 rillig Exp $");
+__RCSID("$NetBSD: mem.c,v 1.14 2021/08/01 18:07:35 rillig Exp $");
 #endif
 
-#include 
-#include 
-#include 
 #include 
 #include 
 #include 
 
 #include "lint.h"
 
+static void __attribute__((noreturn))
+nomem(void)
+{
+
+	errx(1, "virtual memory exhausted");
+}
+
 void *
 xmalloc(size_t s)
 {
@@ -92,13 +96,6 @@ xstrdup(const char *s)
 	return s2;
 }
 
-void __attribute__((noreturn))
-nomem(void)
-{
-
-	errx(1, "virtual memory exhausted");
-}
-
 void
 xasprintf(char **buf, const char *fmt, ...)
 {

Index: src/usr.bin/xlint/lint1/mem1.c
diff -u src/usr.bin/xlint/lint1/mem1.c:1.46 src/usr.bin/xlint/lint1/mem1.c:1.47
--- src/usr.bin/xlint/lint1/mem1.c:1.46	Sun Aug  1 17:59:47 2021
+++ src/usr.bin/xlint/lint1/mem1.c	Sun Aug  1 18:07:35 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mem1.c,v 1.46 2021/08/01 17:59:47 rillig Exp $	*/
+/*	$NetBSD: mem1.c,v 1.47 2021/08/01 18:07:35 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: mem1.c,v 1.46 2021/08/01 17:59:47 rillig Exp $");
+__RCSID("$NetBSD: mem1.c,v 1.47 2021/08/01 18:07:35 rillig Exp $");
 #endif
 
 #include 
@@ -398,8 +398,8 @@ expr_save_memory(void)
 }
 
 /*
- * Free all memory used for the current expression and the memory used
- * be a previous expression and saved by expr_save_memory(). The next call to
+ * Free all memory used for the current expression and restore the memory used
+ * by a previous expression and saved by expr_save_memory(). The next call to
  * expr_free_all() frees the restored memory.
  */
 void



CVS commit: src/usr.bin/xlint

2021-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  1 17:59:47 UTC 2021

Modified Files:
src/usr.bin/xlint/common: externs.h mem.c
src/usr.bin/xlint/lint1: mem1.c
src/usr.bin/xlint/lint2: mem2.c

Log Message:
lint: remove xmapalloc

Just trust the standard malloc to be smart enough.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/xlint/common/externs.h
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/xlint/common/mem.c
cvs rdiff -u -r1.45 -r1.46 src/usr.bin/xlint/lint1/mem1.c
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/xlint/lint2/mem2.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/common/externs.h
diff -u src/usr.bin/xlint/common/externs.h:1.14 src/usr.bin/xlint/common/externs.h:1.15
--- src/usr.bin/xlint/common/externs.h:1.14	Sat Jan 16 02:40:02 2021
+++ src/usr.bin/xlint/common/externs.h	Sun Aug  1 17:59:47 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: externs.h,v 1.14 2021/01/16 02:40:02 rillig Exp $	*/
+/*	$NetBSD: externs.h,v 1.15 2021/08/01 17:59:47 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -58,7 +58,6 @@ extern	void	*xcalloc(size_t, size_t);
 extern	void	*xrealloc(void *, size_t);
 extern	char	*xstrdup(const char *);
 extern	void	nomem(void);
-extern	void	*xmapalloc(size_t);
 extern  void	xasprintf(char **, const char *, ...) __printflike(2, 3);
 
 /*

Index: src/usr.bin/xlint/common/mem.c
diff -u src/usr.bin/xlint/common/mem.c:1.12 src/usr.bin/xlint/common/mem.c:1.13
--- src/usr.bin/xlint/common/mem.c:1.12	Sun Apr 18 22:51:24 2021
+++ src/usr.bin/xlint/common/mem.c	Sun Aug  1 17:59:47 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mem.c,v 1.12 2021/04/18 22:51:24 rillig Exp $	*/
+/*	$NetBSD: mem.c,v 1.13 2021/08/01 17:59:47 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: mem.c,v 1.12 2021/04/18 22:51:24 rillig Exp $");
+__RCSID("$NetBSD: mem.c,v 1.13 2021/08/01 17:59:47 rillig Exp $");
 #endif
 
 #include 
@@ -111,29 +111,3 @@ xasprintf(char **buf, const char *fmt, .
 	if (e < 0)
 		nomem();
 }
-
-#if defined(MAP_ANONYMOUS) && !defined(MAP_ANON)
-#define	MAP_ANON	MAP_ANONYMOUS
-#endif
-
-void *
-xmapalloc(size_t len)
-{
-	static const int prot = PROT_READ | PROT_WRITE;
-	static int fd = -1;
-	void *p;
-#ifdef MAP_ANON
-	static const int flags = MAP_ANON | MAP_PRIVATE;
-#else
-	static const int flags = MAP_PRIVATE;
-
-	if (fd == -1) {
-		if ((fd = open("/dev/zero", O_RDWR)) == -1)
-			err(1, "Cannot open `/dev/zero'");
-	}
-#endif
-	p = mmap(NULL, len, prot, flags, fd, (off_t)0);
-	if (p == (void *)-1)
-		err(1, "Cannot map memory for %lu bytes", (unsigned long)len);
-	return p;
-}

Index: src/usr.bin/xlint/lint1/mem1.c
diff -u src/usr.bin/xlint/lint1/mem1.c:1.45 src/usr.bin/xlint/lint1/mem1.c:1.46
--- src/usr.bin/xlint/lint1/mem1.c:1.45	Sun Jul  4 09:13:59 2021
+++ src/usr.bin/xlint/lint1/mem1.c	Sun Aug  1 17:59:47 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mem1.c,v 1.45 2021/07/04 09:13:59 rillig Exp $	*/
+/*	$NetBSD: mem1.c,v 1.46 2021/08/01 17:59:47 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: mem1.c,v 1.45 2021/07/04 09:13:59 rillig Exp $");
+__RCSID("$NetBSD: mem1.c,v 1.46 2021/08/01 17:59:47 rillig Exp $");
 #endif
 
 #include 
@@ -214,8 +214,7 @@ xnewblk(void)
 {
 	memory_block	*mb = xmalloc(sizeof(*mb));
 
-	/* use mmap instead of malloc to avoid malloc's size overhead */
-	mb->start = xmapalloc(mblklen);
+	mb->start = xmalloc(mblklen);
 	mb->size = mblklen;
 
 	return mb;

Index: src/usr.bin/xlint/lint2/mem2.c
diff -u src/usr.bin/xlint/lint2/mem2.c:1.11 src/usr.bin/xlint/lint2/mem2.c:1.12
--- src/usr.bin/xlint/lint2/mem2.c:1.11	Tue Dec 29 11:35:11 2020
+++ src/usr.bin/xlint/lint2/mem2.c	Sun Aug  1 17:59:47 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mem2.c,v 1.11 2020/12/29 11:35:11 rillig Exp $	*/
+/*	$NetBSD: mem2.c,v 1.12 2021/08/01 17:59:47 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: mem2.c,v 1.11 2020/12/29 11:35:11 rillig Exp $");
+__RCSID("$NetBSD: mem2.c,v 1.12 2021/08/01 17:59:47 rillig Exp $");
 #endif
 
 #include 
@@ -80,8 +80,7 @@ xalloc(size_t sz)
 	/* Align to at least 8 bytes. */
 	sz = (sz + 7) & ~7L;
 	if (nxtfree + sz > mblklen) {
-		/* use mmap() instead of malloc() to avoid malloc overhead. */
-		mbuf = xmapalloc(mblklen);
+		mbuf = xmalloc(mblklen);
 		(void)memset(mbuf, 0, mblklen);
 		nxtfree = 0;
 	}



CVS commit: src

2021-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  1 16:29:28 UTC 2021

Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/usr.bin/xlint/lint1: Makefile
Added Files:
src/tests/usr.bin/xlint/lint1: expr_binary_trad.c expr_binary_trad.exp

Log Message:
tests/lint: test the usual arithmetic conversions in traditional C


To generate a diff of this commit:
cvs rdiff -u -r1.1099 -r1.1100 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.98 -r1.99 src/tests/usr.bin/xlint/lint1/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint1/expr_binary_trad.c \
src/tests/usr.bin/xlint/lint1/expr_binary_trad.exp

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1099 src/distrib/sets/lists/tests/mi:1.1100
--- src/distrib/sets/lists/tests/mi:1.1099	Sun Aug  1 13:31:48 2021
+++ src/distrib/sets/lists/tests/mi	Sun Aug  1 16:29:28 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1099 2021/08/01 13:31:48 rillig Exp $
+# $NetBSD: mi,v 1.1100 2021/08/01 16:29:28 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -6238,6 +6238,8 @@
 ./usr/tests/usr.bin/xlint/lint1/emit.lntests-obsolete		obsolete
 ./usr/tests/usr.bin/xlint/lint1/expr_binary.c			tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/expr_binary.exp			tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/expr_binary_trad.c		tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/expr_binary_trad.exp		tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/expr_precedence.c		tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/expr_precedence.exp		tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/expr_range.c			tests-usr.bin-tests	compattestfile,atf

Index: src/tests/usr.bin/xlint/lint1/Makefile
diff -u src/tests/usr.bin/xlint/lint1/Makefile:1.98 src/tests/usr.bin/xlint/lint1/Makefile:1.99
--- src/tests/usr.bin/xlint/lint1/Makefile:1.98	Sun Aug  1 13:31:49 2021
+++ src/tests/usr.bin/xlint/lint1/Makefile	Sun Aug  1 16:29:28 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.98 2021/08/01 13:31:49 rillig Exp $
+# $NetBSD: Makefile,v 1.99 2021/08/01 16:29:28 rillig Exp $
 
 NOMAN=		# defined
 MAX_MESSAGE=	345		# see lint1/err.c
@@ -133,6 +133,8 @@ FILES+=		emit.exp
 FILES+=		emit.exp-ln
 FILES+=		expr_binary.c
 FILES+=		expr_binary.exp
+FILES+=		expr_binary_trad.c
+FILES+=		expr_binary_trad.exp
 FILES+=		expr_precedence.c
 FILES+=		expr_precedence.exp
 FILES+=		expr_range.c

Added files:

Index: src/tests/usr.bin/xlint/lint1/expr_binary_trad.c
diff -u /dev/null src/tests/usr.bin/xlint/lint1/expr_binary_trad.c:1.1
--- /dev/null	Sun Aug  1 16:29:28 2021
+++ src/tests/usr.bin/xlint/lint1/expr_binary_trad.c	Sun Aug  1 16:29:28 2021
@@ -0,0 +1,67 @@
+/*	$NetBSD: expr_binary_trad.c,v 1.1 2021/08/01 16:29:28 rillig Exp $	*/
+# 3 "expr_binary_trad.c"
+
+/*
+ * Test binary operators in traditional C.
+ */
+
+/* lint1-flags: -tw */
+
+struct incompatible {		/* just to generate the error message */
+	int member;
+};
+struct incompatible sink;
+
+/*
+ * Test the usual arithmetic conversions.
+ *
+ * C99 6.3.1.8 "Usual arithmetic conversions"
+ */
+void
+cover_balance()
+{
+
+	/* expect+1: 'pointer to char' */
+	sink = (char *)0 + 0;
+
+	/* expect+1: 'pointer to char' */
+	sink = 0 + (char *)0;
+
+	/* expect+1: 'int' */
+	sink = 1 + 1;
+
+	/* expect+1: 'double' */
+	sink = 0.0 + 0;
+	/* expect+1: 'double' */
+	sink = 0 + 0.0;
+	/* expect+1: 'double' */
+	sink = 0.0 + (float)0.0;
+	/* expect+1: 'double' */
+	sink = (float)0.0 + 0.0;
+
+	/*
+	 * In traditional C, 'float' gets promoted to 'double' before
+	 * applying the usual arithmetic conversions; see 'promote'.
+	 */
+	/* expect+1: 'double' */
+	sink = (float)0.0 + 0;
+	/* expect+1: 'double' */
+	sink = 0 + (float)0.0;
+
+	/* expect+1: 'unsigned long' */
+	sink = (unsigned long)0 + 0;
+	/* expect+1: 'unsigned long' */
+	sink = 0 + (unsigned long)0;
+
+	/* expect+1: 'unsigned long' */
+	sink = (unsigned long)0 + (long)0;
+	/* expect+1: 'unsigned long' */
+	sink = (long)0 + (unsigned long)0;
+
+	/*
+	 * In traditional C, if one of the operands is unsigned, the result
+	 * is unsigned as well.
+	 */
+	/* expect+1: 'unsigned long' */
+	sink = (unsigned)0 + (long)0;
+}
Index: src/tests/usr.bin/xlint/lint1/expr_binary_trad.exp
diff -u /dev/null src/tests/usr.bin/xlint/lint1/expr_binary_trad.exp:1.1
--- /dev/null	Sun Aug  1 16:29:28 2021
+++ src/tests/usr.bin/xlint/lint1/expr_binary_trad.exp	Sun Aug  1 16:29:28 2021
@@ -0,0 +1,14 @@
+expr_binary_trad.c(25): error: cannot assign to 'struct incompatible' from 'pointer to char' [171]
+expr_binary_trad.c(28): error: cannot assign to 'struct incompatible' from 'pointer to char' [171]
+expr_binary_trad.c(31): error: cannot assign to 'stru

CVS commit: src/tests/usr.bin/xlint/lint1

2021-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  1 14:51:41 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: expr_binary.c expr_binary.exp

Log Message:
tests/lint: re-add the test for __uint128_t


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/expr_binary.c \
src/tests/usr.bin/xlint/lint1/expr_binary.exp

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/expr_binary.c
diff -u src/tests/usr.bin/xlint/lint1/expr_binary.c:1.4 src/tests/usr.bin/xlint/lint1/expr_binary.c:1.5
--- src/tests/usr.bin/xlint/lint1/expr_binary.c:1.4	Sun Aug  1 14:42:21 2021
+++ src/tests/usr.bin/xlint/lint1/expr_binary.c	Sun Aug  1 14:51:41 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: expr_binary.c,v 1.4 2021/08/01 14:42:21 rillig Exp $	*/
+/*	$NetBSD: expr_binary.c,v 1.5 2021/08/01 14:51:41 rillig Exp $	*/
 # 3 "expr_binary.c"
 
 /*
@@ -117,4 +117,13 @@ cover_balance(void)
 	sink(0UL + 0LL);
 	/* expect+1: 'unsigned long long' */
 	sink(0LL + 0UL);
+
+	/*
+	 * Ensure that __int128_t is listed in the integer ranks.  This table
+	 * only becomes relevant when both operands have the same width.
+	 */
+	/* expect+1: '__uint128_t' */
+	sink((__uint128_t)1 + (__int128_t)1);
+	/* expect+1: '__uint128_t' */
+	sink((__int128_t)1 + (__uint128_t)1);
 }
Index: src/tests/usr.bin/xlint/lint1/expr_binary.exp
diff -u src/tests/usr.bin/xlint/lint1/expr_binary.exp:1.4 src/tests/usr.bin/xlint/lint1/expr_binary.exp:1.5
--- src/tests/usr.bin/xlint/lint1/expr_binary.exp:1.4	Sun Aug  1 14:42:21 2021
+++ src/tests/usr.bin/xlint/lint1/expr_binary.exp	Sun Aug  1 14:51:41 2021
@@ -35,3 +35,5 @@ expr_binary.c(111): warning: passing 'un
 expr_binary.c(113): warning: passing 'unsigned long long' to incompatible 'struct incompatible', arg #1 [155]
 expr_binary.c(117): warning: passing 'unsigned long long' to incompatible 'struct incompatible', arg #1 [155]
 expr_binary.c(119): warning: passing 'unsigned long long' to incompatible 'struct incompatible', arg #1 [155]
+expr_binary.c(126): warning: passing '__uint128_t' to incompatible 'struct incompatible', arg #1 [155]
+expr_binary.c(128): warning: passing '__uint128_t' to incompatible 'struct incompatible', arg #1 [155]



CVS commit: src/usr.bin/xlint/lint1

2021-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  1 14:45:40 UTC 2021

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

Log Message:
lint: remove unreachable code from usual arithmetic conversions


To generate a diff of this commit:
cvs rdiff -u -r1.323 -r1.324 src/usr.bin/xlint/lint1/tree.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/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.323 src/usr.bin/xlint/lint1/tree.c:1.324
--- src/usr.bin/xlint/lint1/tree.c:1.323	Sun Aug  1 13:49:17 2021
+++ src/usr.bin/xlint/lint1/tree.c	Sun Aug  1 14:45:39 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.323 2021/08/01 13:49:17 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.324 2021/08/01 14:45:39 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.323 2021/08/01 13:49:17 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.324 2021/08/01 14:45:39 rillig Exp $");
 #endif
 
 #include 
@@ -1782,8 +1782,6 @@ balance(op_t op, tnode_t **lnp, tnode_t 
 			t = LCOMPLEX;
 		} else if (lt == DCOMPLEX || rt == DCOMPLEX) {
 			t = DCOMPLEX;
-		} else if (lt == COMPLEX || rt == COMPLEX) {
-			t = COMPLEX;
 		} else if (lt == FCOMPLEX || rt == FCOMPLEX) {
 			t = FCOMPLEX;
 		} else if (lt == LDOUBLE || rt == LDOUBLE) {



CVS commit: src/tests/usr.bin/xlint/lint1

2021-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  1 14:42:21 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: expr_binary.c expr_binary.exp

Log Message:
tests/lint: fully cover the usual arithmetic conversions


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/expr_binary.c \
src/tests/usr.bin/xlint/lint1/expr_binary.exp

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/expr_binary.c
diff -u src/tests/usr.bin/xlint/lint1/expr_binary.c:1.3 src/tests/usr.bin/xlint/lint1/expr_binary.c:1.4
--- src/tests/usr.bin/xlint/lint1/expr_binary.c:1.3	Sun Aug  1 13:49:17 2021
+++ src/tests/usr.bin/xlint/lint1/expr_binary.c	Sun Aug  1 14:42:21 2021
@@ -1,13 +1,10 @@
-/*	$NetBSD: expr_binary.c,v 1.3 2021/08/01 13:49:17 rillig Exp $	*/
+/*	$NetBSD: expr_binary.c,v 1.4 2021/08/01 14:42:21 rillig Exp $	*/
 # 3 "expr_binary.c"
 
 /*
- * Test binary operators, in particular the usual arithmetic conversions.
- *
- * C99 6.3.1.8 "Usual arithmetic conversions"
+ * Test binary operators.
  */
 
-/* lint1-extra-flags: -Ac11 */
 /* lint1-only-if: lp64 */
 
 struct incompatible {		/* just to generate the error message */
@@ -15,39 +12,109 @@ struct incompatible {		/* just to genera
 };
 void sink(struct incompatible);
 
+/*
+ * Test the usual arithmetic conversions.
+ *
+ * C99 6.3.1.8 "Usual arithmetic conversions"
+ */
 void
 cover_balance(void)
 {
-	/* expect+1: 'int' */
-	sink(1 + '\0');
+	/* expect+1: 'pointer to void' */
+	sink((void *)0 + 0);
+
+	/* expect+1: 'pointer to void' */
+	sink(0 + (void *)0);
 
 	/* expect+1: 'int' */
-	sink((char)'\0' + (char)'\0');
+	sink(1 + 1);
 
-	/* expect+1: 'float' */
-	sink(1 + 1.0f);
+	/* expect+1: 'const int' */
+	sink((const int)1 + (volatile int)1);
+
+	/* expect+1: 'volatile int' */
+	sink((volatile int)1 + (const int)1);
 
+	long double _Complex cldbl = 0.0;
+	double _Complex cdbl = 0.0;
+	float _Complex cflt = 0.0f;
+	/* expect+1: error: invalid type for _Complex [308] */
+	_Complex invalid = 0.0;
+
+	/* expect+1: 'long double _Complex' */
+	sink(cldbl + 0);
+	/* expect+1: 'long double _Complex' */
+	sink(0 + cldbl);
+	/* expect+1: 'long double _Complex' */
+	sink(cldbl + cdbl);
+	/* expect+1: 'long double _Complex' */
+	sink(cdbl + cldbl);
+
+	/* expect+1: 'double _Complex' */
+	sink(cdbl + 0);
+	/* expect+1: 'double _Complex' */
+	sink(0 + cdbl);
+	/* expect+1: 'double _Complex' */
+	sink(cdbl + cflt);
+	/* expect+1: 'double _Complex' */
+	sink(cflt + cdbl);
+
+	/* expect+1: 'float _Complex' */
+	sink(cflt + 0);
+	/* expect+1: 'float _Complex' */
+	sink(0 + cflt);
+	/* expect+1: 'float _Complex' */
+	sink(cflt + (__uint128_t)0);
+	/* expect+1: 'float _Complex' */
+	sink((__uint128_t)0 + cflt);
+
+	/*
+	 * The type specifier '_Complex' is only used during parsing, it does
+	 * not make it to the expression.
+	 */
+	/* expect+1: 'double _Complex' */
+	sink(invalid + 0);
+
+	/* expect+1: 'long double' */
+	sink(0.0L + 0);
+	/* expect+1: 'long double' */
+	sink(0 + 0.0L);
+	/* expect+1: 'long double' */
+	sink(0.0L + 0.0);
+	/* expect+1: 'long double' */
+	sink(0.0 + 0.0L);
+
+	/* expect+1: 'double' */
+	sink(0.0 + 0);
+	/* expect+1: 'double' */
+	sink(0 + 0.0);
 	/* expect+1: 'double' */
-	sink(1 + 1.0);
+	sink(0.0 + 0.0f);
+	/* expect+1: 'double' */
+	sink(0.0f + 0.0);
 
 	/* expect+1: 'float' */
-	sink((long long)1 + 1.0f);
-
+	sink(0.0f + 0);
 	/* expect+1: 'float' */
-	sink((long long)1 + 1.0f);
-
+	sink(0 + 0.0f);
 	/* expect+1: 'float' */
-	sink((__uint128_t)1 + 1.0f);
-
-	/* expect+1: '__uint128_t' */
-	sink((__uint128_t)1 + 1);
-
-	/* expect+1: '__int128_t' */
-	sink((__int128_t)1 + 1);
-
-	/* expect+1: '__uint128_t' */
-	sink((__uint128_t)1 + (__int128_t)1);
+	sink(0.0f + (__uint128_t)0);
+	/* expect+1: 'float' */
+	sink((__uint128_t)0 + 0.0f);
 
-	/* expect+1: '__uint128_t' */
-	sink((__int128_t)1 + (__uint128_t)1);
+	/* expect+1: 'unsigned long long' */
+	sink(0ULL + 0);
+	/* expect+1: 'unsigned long long' */
+	sink(0 + 0ULL);
+
+	/* expect+1: 'unsigned long long' */
+	sink(0ULL + 0LL);
+	/* expect+1: 'unsigned long long' */
+	sink(0LL + 0ULL);
+
+	/* If the bit-width is the same, prefer the unsigned variant. */
+	/* expect+1: 'unsigned long long' */
+	sink(0UL + 0LL);
+	/* expect+1: 'unsigned long long' */
+	sink(0LL + 0UL);
 }
Index: src/tests/usr.bin/xlint/lint1/expr_binary.exp
diff -u src/tests/usr.bin/xlint/lint1/expr_binary.exp:1.3 src/tests/usr.bin/xlint/lint1/expr_binary.exp:1.4
--- src/tests/usr.bin/xlint/lint1/expr_binary.exp:1.3	Sun Aug  1 13:49:17 2021
+++ src/tests/usr.bin/xlint/lint1/expr_binary.exp	Sun Aug  1 14:42:21 2021
@@ -1,11 +1,37 @@
-expr_binary.c(22): warning: passing 'int' to incompatible 'struct incompatible', arg #1 [155]
-expr_binary.c(25): warning: passing 'int' to incompatible 'struct incompatible', arg #1 [155]
-expr_binary.c(28): warning: passing 'flo

CVS commit: src

2021-08-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Aug  1 13:49:17 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: expr_binary.c expr_binary.exp
src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: fix usual arithmetic conversions for 128-bit integer types


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/expr_binary.c \
src/tests/usr.bin/xlint/lint1/expr_binary.exp
cvs rdiff -u -r1.322 -r1.323 src/usr.bin/xlint/lint1/tree.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/expr_binary.c
diff -u src/tests/usr.bin/xlint/lint1/expr_binary.c:1.2 src/tests/usr.bin/xlint/lint1/expr_binary.c:1.3
--- src/tests/usr.bin/xlint/lint1/expr_binary.c:1.2	Sun Aug  1 13:45:14 2021
+++ src/tests/usr.bin/xlint/lint1/expr_binary.c	Sun Aug  1 13:49:17 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: expr_binary.c,v 1.2 2021/08/01 13:45:14 rillig Exp $	*/
+/*	$NetBSD: expr_binary.c,v 1.3 2021/08/01 13:49:17 rillig Exp $	*/
 # 3 "expr_binary.c"
 
 /*
@@ -45,9 +45,9 @@ cover_balance(void)
 	/* expect+1: '__int128_t' */
 	sink((__int128_t)1 + 1);
 
-	/* expect+1: 'unsigned int' *//* FIXME */
+	/* expect+1: '__uint128_t' */
 	sink((__uint128_t)1 + (__int128_t)1);
 
-	/* expect+1: 'unsigned int' *//* FIXME */
+	/* expect+1: '__uint128_t' */
 	sink((__int128_t)1 + (__uint128_t)1);
 }
Index: src/tests/usr.bin/xlint/lint1/expr_binary.exp
diff -u src/tests/usr.bin/xlint/lint1/expr_binary.exp:1.2 src/tests/usr.bin/xlint/lint1/expr_binary.exp:1.3
--- src/tests/usr.bin/xlint/lint1/expr_binary.exp:1.2	Sun Aug  1 13:45:14 2021
+++ src/tests/usr.bin/xlint/lint1/expr_binary.exp	Sun Aug  1 13:49:17 2021
@@ -7,5 +7,5 @@ expr_binary.c(37): warning: passing 'flo
 expr_binary.c(40): warning: passing 'float' to incompatible 'struct incompatible', arg #1 [155]
 expr_binary.c(43): warning: passing '__uint128_t' to incompatible 'struct incompatible', arg #1 [155]
 expr_binary.c(46): warning: passing '__int128_t' to incompatible 'struct incompatible', arg #1 [155]
-expr_binary.c(49): warning: passing 'unsigned int' to incompatible 'struct incompatible', arg #1 [155]
-expr_binary.c(52): warning: passing 'unsigned int' to incompatible 'struct incompatible', arg #1 [155]
+expr_binary.c(49): warning: passing '__uint128_t' to incompatible 'struct incompatible', arg #1 [155]
+expr_binary.c(52): warning: passing '__uint128_t' to incompatible 'struct incompatible', arg #1 [155]

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.322 src/usr.bin/xlint/lint1/tree.c:1.323
--- src/usr.bin/xlint/lint1/tree.c:1.322	Sat Jul 31 18:16:42 2021
+++ src/usr.bin/xlint/lint1/tree.c	Sun Aug  1 13:49:17 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.322 2021/07/31 18:16:42 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.323 2021/08/01 13:49:17 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.322 2021/07/31 18:16:42 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.323 2021/08/01 13:49:17 rillig Exp $");
 #endif
 
 #include 
@@ -1760,7 +1760,13 @@ balance(op_t op, tnode_t **lnp, tnode_t 
 	bool	u;
 	type_t	*ntp;
 	static const tspec_t tl[] = {
-		LDOUBLE, DOUBLE, FLOAT, UQUAD, QUAD, ULONG, LONG, UINT, INT,
+		LDOUBLE, DOUBLE, FLOAT,
+#ifdef INT128_SIZE
+		UINT128, INT128,
+#endif
+		UQUAD, QUAD,
+		ULONG, LONG,
+		UINT, INT,
 	};
 
 	lt = (*lnp)->tn_type->t_tspec;



  1   2   3   4   5   6   7   8   9   10   >