CVS commit: [thorpej-cfargs] src/sys/arch/cobalt/conf

2021-03-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Mar 20 23:50:16 UTC 2021

Modified Files:
src/sys/arch/cobalt/conf [thorpej-cfargs]: files.cobalt

Log Message:
There is no need to have the "pcibus" interface attribute on mainbus;
PCI bus instances to not attach there.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.41.16.1 src/sys/arch/cobalt/conf/files.cobalt

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

Modified files:

Index: src/sys/arch/cobalt/conf/files.cobalt
diff -u src/sys/arch/cobalt/conf/files.cobalt:1.41 src/sys/arch/cobalt/conf/files.cobalt:1.41.16.1
--- src/sys/arch/cobalt/conf/files.cobalt:1.41	Mon Apr  9 20:16:16 2018
+++ src/sys/arch/cobalt/conf/files.cobalt	Sat Mar 20 23:50:16 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: files.cobalt,v 1.41 2018/04/09 20:16:16 christos Exp $
+#	$NetBSD: files.cobalt,v 1.41.16.1 2021/03/20 23:50:16 thorpej Exp $
 
 maxpartitions 16
 
@@ -7,7 +7,7 @@ maxusers 2 8 64
 file arch/mips/mips/mips3_clock.c
 file arch/mips/mips/mips3_clockintr.c
 
-device mainbus {[addr = -1], [level = -1], [irq = -1]}: pcibus
+device mainbus {[addr = -1], [level = -1], [irq = -1]}
 attach mainbus at root
 file arch/cobalt/cobalt/mainbus.c	mainbus
 



CVS commit: src/usr.bin/seq

2021-03-20 Thread Aleksey Cheusov
Module Name:src
Committed By:   cheusov
Date:   Sat Mar 20 22:10:17 UTC 2021

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

Log Message:
seq.c: replace non-standard `\e` with standard compliant `\x1B`


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/seq/seq.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/seq/seq.c
diff -u src/usr.bin/seq/seq.c:1.11 src/usr.bin/seq/seq.c:1.12
--- src/usr.bin/seq/seq.c:1.11	Mon Dec 17 20:10:51 2018
+++ src/usr.bin/seq/seq.c	Sat Mar 20 22:10:17 2021
@@ -31,7 +31,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 2005\
  The NetBSD Foundation, Inc.  All rights reserved.");
-__RCSID("$NetBSD: seq.c,v 1.11 2018/12/17 20:10:51 christos Exp $");
+__RCSID("$NetBSD: seq.c,v 1.12 2021/03/20 22:10:17 cheusov Exp $");
 #endif /* not lint */
 
 #include 
@@ -308,7 +308,7 @@ unescape(char *orig)
 			*orig = '\b';
 			continue;
 		case 'e':	/* escape */
-			*orig = '\e';
+			*orig = '\x1B';
 			continue;
 		case 'f':	/* formfeed */
 			*orig = '\f';



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

2021-03-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 20 21:08:10 UTC 2021

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

Log Message:
lint: clean up new_name_node

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.241 -r1.242 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.241 src/usr.bin/xlint/lint1/tree.c:1.242
--- src/usr.bin/xlint/lint1/tree.c:1.241	Sat Mar 20 20:56:58 2021
+++ src/usr.bin/xlint/lint1/tree.c	Sat Mar 20 21:08:09 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.241 2021/03/20 20:56:58 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.242 2021/03/20 21:08:09 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.241 2021/03/20 20:56:58 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.242 2021/03/20 21:08:09 rillig Exp $");
 #endif
 
 #include 
@@ -251,17 +251,17 @@ fallback_symbol(sym_t *sym)
 
 /*
  * Create a node for a name (symbol table entry).
- * ntok is the token which follows the name.
+ * follow_token is the token which follows the name.
  */
 tnode_t *
-new_name_node(sym_t *sym, int ntok)
+new_name_node(sym_t *sym, int follow_token)
 {
 	tnode_t	*n;
 
 	if (sym->s_scl == NOSCL) {
 		sym->s_scl = EXTERN;
 		sym->s_def = DECL;
-		if (ntok == T_LPAREN) {
+		if (follow_token == T_LPAREN) {
 			if (sflag) {
 /* function implicitly declared to ... */
 warning(215);
@@ -276,8 +276,7 @@ new_name_node(sym_t *sym, int ntok)
 		}
 	}
 
-	if (sym->s_kind != FVFT && sym->s_kind != FMEMBER)
-		LERROR("new_name_node(%d)", sym->s_kind);
+	lint_assert(sym->s_kind == FVFT || sym->s_kind == FMEMBER);
 
 	n = getnode();
 	n->tn_type = sym->s_type;



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

2021-03-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 20 20:56:58 UTC 2021

Modified Files:
src/usr.bin/xlint/lint1: op.h oper.c print.c tree.c

Log Message:
lint: move getopname over to tree.c

Except for the one use in print_tnode, the name of the operator is only
used in tree.c.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/xlint/lint1/op.h
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/xlint/lint1/oper.c
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/xlint/lint1/print.c
cvs rdiff -u -r1.240 -r1.241 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/op.h
diff -u src/usr.bin/xlint/lint1/op.h:1.15 src/usr.bin/xlint/lint1/op.h:1.16
--- src/usr.bin/xlint/lint1/op.h:1.15	Sat Mar 20 20:39:35 2021
+++ src/usr.bin/xlint/lint1/op.h	Sat Mar 20 20:56:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: op.h,v 1.15 2021/03/20 20:39:35 rillig Exp $	*/
+/*	$NetBSD: op.h,v 1.16 2021/03/20 20:56:58 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -72,5 +72,3 @@ extern const mod_t modtab[];
 	name,
 #define end_ops() } op_t;
 #include "ops.def"
-
-const char *getopname(op_t);

Index: src/usr.bin/xlint/lint1/oper.c
diff -u src/usr.bin/xlint/lint1/oper.c:1.8 src/usr.bin/xlint/lint1/oper.c:1.9
--- src/usr.bin/xlint/lint1/oper.c:1.8	Sat Mar 20 20:39:35 2021
+++ src/usr.bin/xlint/lint1/oper.c	Sat Mar 20 20:56:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: oper.c,v 1.8 2021/03/20 20:39:35 rillig Exp $	*/
+/*	$NetBSD: oper.c,v 1.9 2021/03/20 20:56:58 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -51,9 +51,3 @@ const mod_t modtab[NOPS] =
 	},
 #define end_ops(n) };
 #include "ops.def"
-
-const char *
-getopname(op_t op)
-{
-	return modtab[op].m_name;
-}

Index: src/usr.bin/xlint/lint1/print.c
diff -u src/usr.bin/xlint/lint1/print.c:1.10 src/usr.bin/xlint/lint1/print.c:1.11
--- src/usr.bin/xlint/lint1/print.c:1.10	Tue Jan  5 23:20:53 2021
+++ src/usr.bin/xlint/lint1/print.c	Sat Mar 20 20:56:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: print.c,v 1.10 2021/01/05 23:20:53 rillig Exp $	*/
+/*	$NetBSD: print.c,v 1.11 2021/03/20 20:56:58 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: print.c,v 1.10 2021/01/05 23:20:53 rillig Exp $");
+__RCSID("$NetBSD: print.c,v 1.11 2021/03/20 20:56:58 rillig Exp $");
 #endif
 
 #include 
@@ -82,7 +82,7 @@ print_tnode(char *buf, size_t bufsiz, co
 		}
 		break;
 	default:
-		(void)snprintf(buf, bufsiz, "%s", getopname(tn->tn_op));
+		(void)snprintf(buf, bufsiz, "%s", modtab[tn->tn_op].m_name);
 		break;
 	}
 	return buf;

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.240 src/usr.bin/xlint/lint1/tree.c:1.241
--- src/usr.bin/xlint/lint1/tree.c:1.240	Sat Mar 20 20:39:35 2021
+++ src/usr.bin/xlint/lint1/tree.c	Sat Mar 20 20:56:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.240 2021/03/20 20:39:35 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.241 2021/03/20 20:56:58 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.240 2021/03/20 20:39:35 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.241 2021/03/20 20:56:58 rillig Exp $");
 #endif
 
 #include 
@@ -97,6 +97,12 @@ static	void	check_precedence_confusion(t
 
 extern sig_atomic_t fpe;
 
+static const char *
+getopname(op_t op)
+{
+	return modtab[op].m_name;
+}
+
 #ifdef DEBUG
 void
 debug_node(const tnode_t *tn, int indent)
@@ -472,7 +478,7 @@ struct_or_union_member(tnode_t *tn, op_t
 			error(105, op == POINT ? "object" : "pointer");
 		} else {
 			/* unacceptable operand of '%s' */
-			error(111, modtab[op].m_name);
+			error(111, getopname(op));
 		}
 	}
 
@@ -1781,7 +1787,7 @@ check_enum_int_mismatch(op_t op, int arg
 	default:
 		/* combination of '%s' and '%s', op %s */
 		warning(242, type_name(ln->tn_type), type_name(rn->tn_type),
-		modtab[op].m_name);
+		getopname(op));
 		break;
 	}
 }
@@ -2414,7 +2420,7 @@ convert_constant(op_t op, int arg, type_
 			 */
 			if (nsz < osz && (v->v_quad & xmask) != 0) {
 /* constant truncated by conv., op %s */
-warning(306, modtab[op].m_name);
+warning(306, getopname(op));
 			}
 		} else if (op == ANDASS || op == BITAND) {
 			/*
@@ -2427,12 +2433,12 @@ convert_constant(op_t op, int arg, type_
 			(nv->v_quad & xmask) != xmask) {
 /* extra bits set to 0 in conv. of '%s' ... */
 warning(309, type_name(gettyp(ot)),
-type_name(tp), modtab[op].m_name);
+type_name(tp), getopname(op));
 			} else if (nsz < osz &&
    (v->v_quad & xmask) != xmask &&
    (v->v_quad & xmask) != 0) {
 /* constant truncated by conv., op %s */
-warning(306, modtab[op].m_name);
+warning(306, getopname(op));
 			}
 		} else if ((nt != PTR 

CVS commit: [thorpej-cfargs] src/sys/arch

2021-03-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Mar 20 20:49:43 UTC 2021

Modified Files:
src/sys/arch/hpcmips/dev [thorpej-cfargs]: plum.c plumiobus.c ucb1200.c
src/sys/arch/hpcmips/tx [thorpej-cfargs]: tx39sib.c tx39spi.c
tx39uart.c txcsbus.c txsim.c
src/sys/arch/hpcmips/vr [thorpej-cfargs]: vrc4173bcu.c vrip.c
src/sys/arch/mips/rmi [thorpej-cfargs]: rmixl_mainbus.c

Log Message:
Don't pass the autoconfig print routine as the aux pointer to the
indirect search routine.  That argument slot is meant for "attach
args" structures, not function pointers.  Besides, no one actually
used it anyway.


To generate a diff of this commit:
cvs rdiff -u -r1.18.2.1 -r1.18.2.2 src/sys/arch/hpcmips/dev/plum.c
cvs rdiff -u -r1.16.2.1 -r1.16.2.2 src/sys/arch/hpcmips/dev/plumiobus.c
cvs rdiff -u -r1.19.52.1 -r1.19.52.2 src/sys/arch/hpcmips/dev/ucb1200.c
cvs rdiff -u -r1.21.52.1 -r1.21.52.2 src/sys/arch/hpcmips/tx/tx39sib.c
cvs rdiff -u -r1.5.52.1 -r1.5.52.2 src/sys/arch/hpcmips/tx/tx39spi.c
cvs rdiff -u -r1.15.52.1 -r1.15.52.2 src/sys/arch/hpcmips/tx/tx39uart.c
cvs rdiff -u -r1.22.52.1 -r1.22.52.2 src/sys/arch/hpcmips/tx/txcsbus.c
cvs rdiff -u -r1.17.52.1 -r1.17.52.2 src/sys/arch/hpcmips/tx/txsim.c
cvs rdiff -u -r1.24.28.1 -r1.24.28.2 src/sys/arch/hpcmips/vr/vrc4173bcu.c
cvs rdiff -u -r1.37.52.1 -r1.37.52.2 src/sys/arch/hpcmips/vr/vrip.c
cvs rdiff -u -r1.4.68.1 -r1.4.68.2 src/sys/arch/mips/rmi/rmixl_mainbus.c

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

Modified files:

Index: src/sys/arch/hpcmips/dev/plum.c
diff -u src/sys/arch/hpcmips/dev/plum.c:1.18.2.1 src/sys/arch/hpcmips/dev/plum.c:1.18.2.2
--- src/sys/arch/hpcmips/dev/plum.c:1.18.2.1	Sat Mar 20 19:33:35 2021
+++ src/sys/arch/hpcmips/dev/plum.c	Sat Mar 20 20:49:43 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: plum.c,v 1.18.2.1 2021/03/20 19:33:35 thorpej Exp $ */
+/*	$NetBSD: plum.c,v 1.18.2.2 2021/03/20 20:49:43 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: plum.c,v 1.18.2.1 2021/03/20 19:33:35 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plum.c,v 1.18.2.2 2021/03/20 20:49:43 thorpej Exp $");
 
 #include 
 #include 
@@ -112,7 +112,7 @@ plum_attach(device_t parent, device_t se
 	 * attach first.
 	 */
 	sc->sc_pri = 2;
-	config_search(self, plum_print,
+	config_search(self, NULL,
 	CFARG_SUBMATCH, plum_search,
 	CFARG_IATTR, "plumif",
 	CFARG_EOL);
@@ -121,7 +121,7 @@ plum_attach(device_t parent, device_t se
 	 * Other plum module.
 	 */
 	sc->sc_pri = 1;
-	config_search(self, plum_print,
+	config_search(self, NULL,
 	CFARG_SUBMATCH, plum_search,
 	CFARG_IATTR, "plumif",
 	CFARG_EOL);

Index: src/sys/arch/hpcmips/dev/plumiobus.c
diff -u src/sys/arch/hpcmips/dev/plumiobus.c:1.16.2.1 src/sys/arch/hpcmips/dev/plumiobus.c:1.16.2.2
--- src/sys/arch/hpcmips/dev/plumiobus.c:1.16.2.1	Sat Mar 20 19:33:35 2021
+++ src/sys/arch/hpcmips/dev/plumiobus.c	Sat Mar 20 20:49:43 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: plumiobus.c,v 1.16.2.1 2021/03/20 19:33:35 thorpej Exp $ */
+/*	$NetBSD: plumiobus.c,v 1.16.2.2 2021/03/20 20:49:43 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: plumiobus.c,v 1.16.2.1 2021/03/20 19:33:35 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plumiobus.c,v 1.16.2.2 2021/03/20 20:49:43 thorpej Exp $");
 
 #define PLUMIOBUSDEBUG
 
@@ -163,7 +163,7 @@ plumiobus_attach(device_t parent, device
 	plumiobus_dump(sc);
 #endif
 
-	config_search(self, plumiobus_print,
+	config_search(self, NULL,
 	CFARG_SUBMATCH, plumiobus_search,
 	CFARG_IATTR, "plumiobusif",
 	CFARG_EOL);

Index: src/sys/arch/hpcmips/dev/ucb1200.c
diff -u src/sys/arch/hpcmips/dev/ucb1200.c:1.19.52.1 src/sys/arch/hpcmips/dev/ucb1200.c:1.19.52.2
--- src/sys/arch/hpcmips/dev/ucb1200.c:1.19.52.1	Sat Mar 20 19:33:35 2021
+++ src/sys/arch/hpcmips/dev/ucb1200.c	Sat Mar 20 20:49:43 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ucb1200.c,v 1.19.52.1 2021/03/20 19:33:35 thorpej Exp $ */
+/*	$NetBSD: ucb1200.c,v 1.19.52.2 2021/03/20 20:49:43 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ucb1200.c,v 1.19.52.1 2021/03/20 19:33:35 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ucb1200.c,v 1.19.52.2 2021/03/20 20:49:43 thorpej Exp $");
 
 #include 
 #include 
@@ -133,7 +133,7 @@ ucb1200_attach(device_t parent, device_t
 	(void)ucb1200_check_id(reg, 1);
 	printf("\n");
 
-	config_search(self, ucb1200_print,
+	config_search(self, NULL,
 	CFARG_SUBMATCH, ucb1200_search,
 	CFARG_IATTR, "ucbif",
 	CFARG_EOL);

Index: src/sys/arch/hpcmips/tx/tx39sib.c
diff -u src/sys/arch/hpcmips/tx/tx39sib.c:1.21.52.1 src/sys/arch/hpcmips/tx/tx39sib.c:1.21.52.2
--- src/sys/arch/hpcmips/tx/tx39sib.c:1.21.52.1	Sat Mar 

CVS commit: [thorpej-cfargs] src/sys

2021-03-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Mar 20 20:47:53 UTC 2021

Modified Files:
src/sys/arch/arm/xscale [thorpej-cfargs]: pxa2x0.c
src/sys/arch/zaurus/dev [thorpej-cfargs]: zssp.c
src/sys/dev/gpio [thorpej-cfargs]: gpio.c

Log Message:
No need to pass the parent softc down to the indirect submatch routine;
it's available from the parent device_t there.


To generate a diff of this commit:
cvs rdiff -u -r1.22.52.1 -r1.22.52.2 src/sys/arch/arm/xscale/pxa2x0.c
cvs rdiff -u -r1.13.62.1 -r1.13.62.2 src/sys/arch/zaurus/dev/zssp.c
cvs rdiff -u -r1.64.10.1 -r1.64.10.2 src/sys/dev/gpio/gpio.c

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

Modified files:

Index: src/sys/arch/arm/xscale/pxa2x0.c
diff -u src/sys/arch/arm/xscale/pxa2x0.c:1.22.52.1 src/sys/arch/arm/xscale/pxa2x0.c:1.22.52.2
--- src/sys/arch/arm/xscale/pxa2x0.c:1.22.52.1	Sat Mar 20 19:33:32 2021
+++ src/sys/arch/arm/xscale/pxa2x0.c	Sat Mar 20 20:47:53 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pxa2x0.c,v 1.22.52.1 2021/03/20 19:33:32 thorpej Exp $ */
+/*	$NetBSD: pxa2x0.c,v 1.22.52.2 2021/03/20 20:47:53 thorpej Exp $ */
 
 /*
  * Copyright (c) 2002, 2005  Genetec Corporation.  All rights reserved.
@@ -99,7 +99,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pxa2x0.c,v 1.22.52.1 2021/03/20 19:33:32 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pxa2x0.c,v 1.22.52.2 2021/03/20 20:47:53 thorpej Exp $");
 
 #include "pxaintc.h"
 #include "pxagpio.h"
@@ -230,7 +230,7 @@ pxaip_attach(device_t parent, device_t s
 	/*
 	 * Attach all other devices
 	 */
-	config_search(self, sc,
+	config_search(self, NULL,
 	CFARG_SUBMATCH, pxaip_search,
 	CFARG_IATTR, "pxaip",
 	CFARG_EOL);
@@ -239,7 +239,7 @@ pxaip_attach(device_t parent, device_t s
 static int
 pxaip_search(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
 {
-	struct pxaip_softc *sc = aux;
+	struct pxaip_softc *sc = device_private(parent);
 	struct pxaip_attach_args aa;
 
 	aa.pxa_iot = sc->sc_bust;

Index: src/sys/arch/zaurus/dev/zssp.c
diff -u src/sys/arch/zaurus/dev/zssp.c:1.13.62.1 src/sys/arch/zaurus/dev/zssp.c:1.13.62.2
--- src/sys/arch/zaurus/dev/zssp.c:1.13.62.1	Sat Mar 20 19:33:39 2021
+++ src/sys/arch/zaurus/dev/zssp.c	Sat Mar 20 20:47:53 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: zssp.c,v 1.13.62.1 2021/03/20 19:33:39 thorpej Exp $	*/
+/*	$NetBSD: zssp.c,v 1.13.62.2 2021/03/20 20:47:53 thorpej Exp $	*/
 /*	$OpenBSD: zaurus_ssp.c,v 1.6 2005/04/08 21:58:49 uwe Exp $	*/
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: zssp.c,v 1.13.62.1 2021/03/20 19:33:39 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zssp.c,v 1.13.62.2 2021/03/20 20:47:53 thorpej Exp $");
 
 #include 
 #include 
@@ -144,7 +144,7 @@ zssp_attach(device_t parent, device_t se
 	zssp_init();
 
 	/* Attach all devices */
-	config_search(self, sc,
+	config_search(self, NULL,
 	CFARG_SUBMATCH, zssp_search,
 	CFARG_IATTR, "zssp",
 	CFARG_EOL);

Index: src/sys/dev/gpio/gpio.c
diff -u src/sys/dev/gpio/gpio.c:1.64.10.1 src/sys/dev/gpio/gpio.c:1.64.10.2
--- src/sys/dev/gpio/gpio.c:1.64.10.1	Sat Mar 20 19:33:40 2021
+++ src/sys/dev/gpio/gpio.c	Sat Mar 20 20:47:53 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: gpio.c,v 1.64.10.1 2021/03/20 19:33:40 thorpej Exp $ */
+/* $NetBSD: gpio.c,v 1.64.10.2 2021/03/20 20:47:53 thorpej Exp $ */
 /*	$OpenBSD: gpio.c,v 1.6 2006/01/14 12:33:49 grange Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gpio.c,v 1.64.10.1 2021/03/20 19:33:40 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gpio.c,v 1.64.10.2 2021/03/20 20:47:53 thorpej Exp $");
 
 /*
  * General Purpose Input/Output framework.
@@ -191,7 +191,7 @@ gpio_rescan(device_t self, const char *i
 {
 	struct gpio_softc *sc = device_private(self);
 
-	config_search(self, sc,
+	config_search(self, NULL,
 	CFARG_SUBMATCH, gpio_search,
 	CFARG_IATTR, ifattr,
 	CFARG_LOCATORS, locators,
@@ -272,7 +272,7 @@ gpio_search(device_t parent, cfdata_t cf
 	struct gpio_attach_args ga;
 	size_t namlen;
 
-	ga.ga_gpio = aux;
+	ga.ga_gpio = device_private(parent);
 	ga.ga_offset = cf->cf_loc[GPIOCF_OFFSET];
 	ga.ga_mask = cf->cf_loc[GPIOCF_MASK];
 	ga.ga_flags = cf->cf_loc[GPIOCF_FLAG];



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

2021-03-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 20 20:39:35 UTC 2021

Modified Files:
src/usr.bin/xlint/lint1: main1.c op.h oper.c ops.def tree.c

Log Message:
lint: remove redundant operator properties table

It's enough to have modtab, which describes the properties of the
various operators.  There is no need to have a second table imods that
holds the same content.  Rather make modtab constant as well.

The only possible functional change is that the names of the internal
operators 'no-op', '++', '--', 'real', 'imag' and 'case' may appear in
diagnostics, where previously lint invoked undefined behavior by passing
a null pointer for a '%s' conversion specifier.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/usr.bin/xlint/lint1/main1.c
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/xlint/lint1/op.h
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/xlint/lint1/oper.c
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/xlint/lint1/ops.def
cvs rdiff -u -r1.239 -r1.240 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/main1.c
diff -u src/usr.bin/xlint/lint1/main1.c:1.37 src/usr.bin/xlint/lint1/main1.c:1.38
--- src/usr.bin/xlint/lint1/main1.c:1.37	Sat Jan 16 16:53:23 2021
+++ src/usr.bin/xlint/lint1/main1.c	Sat Mar 20 20:39:35 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: main1.c,v 1.37 2021/01/16 16:53:23 rillig Exp $	*/
+/*	$NetBSD: main1.c,v 1.38 2021/03/20 20:39:35 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: main1.c,v 1.37 2021/01/16 16:53:23 rillig Exp $");
+__RCSID("$NetBSD: main1.c,v 1.38 2021/03/20 20:39:35 rillig Exp $");
 #endif
 
 #include 
@@ -253,7 +253,6 @@ main(int argc, char *argv[])
 	initmem();
 	initdecl();
 	initscan();
-	initmtab();
 
 	if ((yyin = bltin()) == NULL)
 		err(1, "cannot open builtins");

Index: src/usr.bin/xlint/lint1/op.h
diff -u src/usr.bin/xlint/lint1/op.h:1.14 src/usr.bin/xlint/lint1/op.h:1.15
--- src/usr.bin/xlint/lint1/op.h:1.14	Sat Mar 20 20:15:37 2021
+++ src/usr.bin/xlint/lint1/op.h	Sat Mar 20 20:39:35 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: op.h,v 1.14 2021/03/20 20:15:37 rillig Exp $	*/
+/*	$NetBSD: op.h,v 1.15 2021/03/20 20:39:35 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -60,7 +60,7 @@ typedef	struct {
 	const char *m_name;
 } mod_t;
 
-extern mod_t   modtab[];
+extern const mod_t modtab[];
 
 #define begin_ops() typedef enum {
 #define op(name, repr, \
@@ -68,11 +68,9 @@ extern mod_t   modtab[];
 		in, ic, ar, sc, \
 		fo, va, ts, ba, \
 		se, lu, ru, pc, \
-		cm, ve, de, ew, \
-		active) \
+		cm, ve, de, ew) \
 	name,
 #define end_ops() } op_t;
 #include "ops.def"
 
 const char *getopname(op_t);
-void initmtab(void);

Index: src/usr.bin/xlint/lint1/oper.c
diff -u src/usr.bin/xlint/lint1/oper.c:1.7 src/usr.bin/xlint/lint1/oper.c:1.8
--- src/usr.bin/xlint/lint1/oper.c:1.7	Sat Mar 20 20:15:37 2021
+++ src/usr.bin/xlint/lint1/oper.c	Sat Mar 20 20:39:35 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: oper.c,v 1.7 2021/03/20 20:15:37 rillig Exp $	*/
+/*	$NetBSD: oper.c,v 1.8 2021/03/20 20:39:35 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -33,27 +33,21 @@
 #include "op.h"
 #include "param.h"
 
-mod_t modtab[NOPS];
-
-static const struct {
-	mod_t	m;
-	bool	ok;
-} imods[] =
+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, \
-		active) \
-	{ { \
+		cm, ve, de, ew) \
+	{ \
 		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, \
-		repr }, (active) > 0 \
+		repr, \
 	},
 #define end_ops(n) };
 #include "ops.def"
@@ -61,15 +55,5 @@ static const struct {
 const char *
 getopname(op_t op)
 {
-	return imods[op].m.m_name;
-}
-
-void
-initmtab(void)
-{
-	size_t i;
-
-	for (i = 0; i < sizeof imods / sizeof imods[0]; i++)
-		if (imods[i].ok)
-			modtab[i] = imods[i].m;
+	return modtab[op].m_name;
 }

Index: src/usr.bin/xlint/lint1/ops.def
diff -u src/usr.bin/xlint/lint1/ops.def:1.18 src/usr.bin/xlint/lint1/ops.def:1.19
--- src/usr.bin/xlint/lint1/ops.def:1.18	Sat Mar 20 20:15:37 2021
+++ src/usr.bin/xlint/lint1/ops.def	Sat Mar 20 20:39:35 2021
@@ -1,86 +1,86 @@
-/*	$NetBSD: ops.def,v 1.18 2021/03/20 20:15:37 rillig Exp $ */
+/*	$NetBSD: ops.def,v 1.19 2021/03/20 20:39:35 rillig Exp $ */
 
 begin_ops()
 
 /* See mod_t in op.h for the definition of the table columns. */
 
-/*	name	repr		b l b B i c a s f v t b s l r p c e e =	act */
-op(	NOOP,	"no-op",	 , , , , , , , , , , , , , , , , , , , ,0)
-op(	ARROW,	"->",		1, ,1, , , , , , ,1, , , , , , , , , , ,1)
-op(	

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

2021-03-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 20 20:15:37 UTC 2021

Modified Files:
src/usr.bin/xlint/lint1: op.h oper.c ops.def

Log Message:
lint: fix argument names and table headings for operator definitions

The abbreviations in the table of operator properties had been wrong
since ops.def 1.10 from 2021-01-12, when strict bool mode was added.  In
an earlier working draft, I had named that column 'takes_others' instead
of 'requires_bool', that's where the 'o' came from.

The names of the macro arguments had been wrong since op.h 1.11 from
2021-01-09, when the order of the columns changed and the macros were
not adjusted accordingly.  Since all the properties of the operator
table are uniform, this didn't result in any bugs, it was just confusing
for human readers.

Clang-tidy suggests to enclose the macro arguments in oper.c in
parentheses but that is not possible since the arguments are either
empty or 1, and the syntactical ambiguity of the '+ 0' being either a
unary or a binary operator is needed here.

No change to the resulting binary.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/xlint/lint1/op.h
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/xlint/lint1/oper.c
cvs rdiff -u -r1.17 -r1.18 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/op.h
diff -u src/usr.bin/xlint/lint1/op.h:1.13 src/usr.bin/xlint/lint1/op.h:1.14
--- src/usr.bin/xlint/lint1/op.h:1.13	Sun Jan 17 12:23:01 2021
+++ src/usr.bin/xlint/lint1/op.h	Sat Mar 20 20:15:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: op.h,v 1.13 2021/01/17 12:23:01 rillig Exp $	*/
+/*	$NetBSD: op.h,v 1.14 2021/03/20 20:15:37 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -64,8 +64,12 @@ extern mod_t   modtab[];
 
 #define begin_ops() typedef enum {
 #define op(name, repr, \
-		bi, lo, tb, to, in, sc, ar, fo, va, ts, ba, se, \
-		lu, ru, pc, cm, ve, de, ew, ic, active) \
+		bi, lo, tb, rb, \
+		in, ic, ar, sc, \
+		fo, va, ts, ba, \
+		se, lu, ru, pc, \
+		cm, ve, de, ew, \
+		active) \
 	name,
 #define end_ops() } op_t;
 #include "ops.def"

Index: src/usr.bin/xlint/lint1/oper.c
diff -u src/usr.bin/xlint/lint1/oper.c:1.6 src/usr.bin/xlint/lint1/oper.c:1.7
--- src/usr.bin/xlint/lint1/oper.c:1.6	Sat Mar 20 19:33:25 2021
+++ src/usr.bin/xlint/lint1/oper.c	Sat Mar 20 20:15:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: oper.c,v 1.6 2021/03/20 19:33:25 rillig Exp $	*/
+/*	$NetBSD: oper.c,v 1.7 2021/03/20 20:15:37 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -41,15 +41,19 @@ static const struct {
 } imods[] =
 #define begin_ops() {
 #define op(name, repr, \
-		bi, lo, tb, to, in, sc, ar, fo, va, ts, ba, se, \
-		lu, ru, pc, cm, ve, de, ew, ic, active) \
+		bi, lo, tb, rb, \
+		in, ic, ar, sc, \
+		fo, va, ts, ba, \
+		se, lu, ru, pc, \
+		cm, ve, de, ew, \
+		active) \
 	{ { \
-		bi + 0 > 0, lo + 0 > 0, tb + 0 > 0, to + 0 > 0, \
-		in + 0 > 0, sc + 0 > 0, ar + 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, ic + 0 > 0, \
-		repr }, active > 0 \
+		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, \
+		repr }, (active) > 0 \
 	},
 #define end_ops(n) };
 #include "ops.def"

Index: src/usr.bin/xlint/lint1/ops.def
diff -u src/usr.bin/xlint/lint1/ops.def:1.17 src/usr.bin/xlint/lint1/ops.def:1.18
--- src/usr.bin/xlint/lint1/ops.def:1.17	Thu Mar 18 21:56:34 2021
+++ src/usr.bin/xlint/lint1/ops.def	Sat Mar 20 20:15:37 2021
@@ -1,10 +1,10 @@
-/*	$NetBSD: ops.def,v 1.17 2021/03/18 21:56:34 rillig Exp $ */
+/*	$NetBSD: ops.def,v 1.18 2021/03/20 20:15:37 rillig Exp $ */
 
 begin_ops()
 
 /* See mod_t in op.h for the definition of the table columns. */
 
-/*	name	repr		b l b o i c a s f v t b s l r p c e e =	act */
+/*	name	repr		b l b B i c a s f v t b s l r p c e e =	act */
 op(	NOOP,	"no-op",	 , , , , , , , , , , , , , , , , , , , ,0)
 op(	ARROW,	"->",		1, ,1, , , , , , ,1, , , , , , , , , , ,1)
 op(	POINT,	".",		1, ,1, , , , , , , , , , , , , , , , , ,1)
@@ -22,7 +22,7 @@ op(	INDIR,	"*",		 , , , , , , , , ,1, , 
 op(	ADDR,	"&",		 , ,1, , , , , , , , , , , , , , , , , ,1)
 /* the operator 'arr[ind]' is translated to '*(arr + ind)' during parsing. */
 
-/*	name	repr		b l b o i c a s f v t b s l r p c e e =	act */
+/*	name	repr		b l b B i c a s f v t b s l r p c e e =	act */
 op(	MULT,	"*",		1, , , , , ,1, ,1,1, ,1, , ,1, , , ,1,1,1)
 op(	DIV,	"/",		1, , , , , ,1, ,1,1, ,1, ,1,1, , , ,1,1,1)
 op(	MOD,	"%",		1, , , ,1, , , ,1,1, ,1, ,1,1, , , ,1,1,1)
@@ -31,7 +31,7 @@ op(	MINUS,	"-",		1, , , , , , ,1,1,1, ,1
 op(	SHL,	"<<",		1, , , 

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

2021-03-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 20 19:33:25 UTC 2021

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

Log Message:
lint: make lint's own code pass the strict bool mode

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/usr.bin/xlint/lint1/Makefile
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/xlint/lint1/lex.c
cvs rdiff -u -r1.5 -r1.6 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/Makefile
diff -u src/usr.bin/xlint/lint1/Makefile:1.62 src/usr.bin/xlint/lint1/Makefile:1.63
--- src/usr.bin/xlint/lint1/Makefile:1.62	Sat Feb 20 18:10:22 2021
+++ src/usr.bin/xlint/lint1/Makefile	Sat Mar 20 19:33:25 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.62 2021/02/20 18:10:22 rillig Exp $
+#	$NetBSD: Makefile,v 1.63 2021/03/20 19:33:25 rillig Exp $
 
 .include 
 
@@ -15,6 +15,7 @@ YHEADER=
 #LFLAGS+=-d
 
 CWARNFLAGS.clang+=	-Wno-error=implicit-int-float-conversion
+LINTFLAGS+=		-T
 
 CPPFLAGS+=	-I${.CURDIR} -I. -DPASS=\"${PROG}.h\"
 CPPFLAGS+=	${DEBUG:D-DDEBUG}

Index: src/usr.bin/xlint/lint1/lex.c
diff -u src/usr.bin/xlint/lint1/lex.c:1.13 src/usr.bin/xlint/lint1/lex.c:1.14
--- src/usr.bin/xlint/lint1/lex.c:1.13	Sat Mar 20 19:24:56 2021
+++ src/usr.bin/xlint/lint1/lex.c	Sat Mar 20 19:33:25 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.13 2021/03/20 19:24:56 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.14 2021/03/20 19:33:25 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: lex.c,v 1.13 2021/03/20 19:24:56 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.14 2021/03/20 19:33:25 rillig Exp $");
 #endif
 
 #include 
@@ -264,7 +264,7 @@ add_keyword(struct kwtab *kw, int deco)
 	char buf[256];
 	const char *name;
 
-	if (!(kw->kw_deco & deco))
+	if ((kw->kw_deco & deco) == 0)
 		return;
 
 	switch (deco) {

Index: src/usr.bin/xlint/lint1/oper.c
diff -u src/usr.bin/xlint/lint1/oper.c:1.5 src/usr.bin/xlint/lint1/oper.c:1.6
--- src/usr.bin/xlint/lint1/oper.c:1.5	Mon Jan 18 20:02:34 2021
+++ src/usr.bin/xlint/lint1/oper.c	Sat Mar 20 19:33:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: oper.c,v 1.5 2021/01/18 20:02:34 rillig Exp $	*/
+/*	$NetBSD: oper.c,v 1.6 2021/03/20 19:33:25 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -43,10 +43,14 @@ static const struct {
 #define op(name, repr, \
 		bi, lo, tb, to, in, sc, ar, fo, va, ts, ba, se, \
 		lu, ru, pc, cm, ve, de, ew, ic, active) \
-	{ { bi + 0, lo + 0, tb + 0, to + 0, in + 0, sc + 0, ar + 0, \
-	fo + 0, va + 0, ts + 0, ba + 0, se + 0, \
-	lu + 0, ru + 0, pc + 0, cm + 0, ve + 0, \
-	de + 0, ew + 0, ic + 0, repr }, active },
+	{ { \
+		bi + 0 > 0, lo + 0 > 0, tb + 0 > 0, to + 0 > 0, \
+		in + 0 > 0, sc + 0 > 0, ar + 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, ic + 0 > 0, \
+		repr }, active > 0 \
+	},
 #define end_ops(n) };
 #include "ops.def"
 



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

2021-03-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 20 19:24:57 UTC 2021

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

Log Message:
lint: use macro for initializing keywords table

Since today, lint's strict bool mode requires initializers to have the
correct type.  The flags in kwtab are of type bool and were initialized
with an int, for brevity.  Keep the brevity and do the conversion from
int to bool in a macro.

By defining several macros for the different kinds of keywords, reduce
the clutter of having 2 additional zeroes per line.  The macros also
remove the redundancy and thereby the possible inconsistency of filling
the wrong fields since these depend on the token type.

No functional change.  The only change to the binary is due to the
changed line numbers in the calls to lint_assert.


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

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

Modified files:

Index: src/usr.bin/xlint/lint1/lex.c
diff -u src/usr.bin/xlint/lint1/lex.c:1.12 src/usr.bin/xlint/lint1/lex.c:1.13
--- src/usr.bin/xlint/lint1/lex.c:1.12	Wed Mar 17 01:15:31 2021
+++ src/usr.bin/xlint/lint1/lex.c	Sat Mar 20 19:24:56 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.12 2021/03/17 01:15:31 rillig Exp $ */
+/* $NetBSD: lex.c,v 1.13 2021/03/20 19:24:56 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: lex.c,v 1.12 2021/03/17 01:15:31 rillig Exp $");
+__RCSID("$NetBSD: lex.c,v 1.13 2021/03/20 19:24:56 rillig Exp $");
 #endif
 
 #include 
@@ -99,6 +99,20 @@ lex_unknown_character(int c)
 	error(250, c);
 }
 
+#define kwdef(name, token, scl, tspec, tqual,	c89, c99, gcc, attr, deco) \
+	{ \
+		name, token, scl, tspec, tqual, \
+		(c89) > 0, (c99) > 0, (gcc) > 0, (attr) > 0, deco, \
+	}
+#define kwdef_token(name, token,		c89, c99, gcc, attr, deco) \
+	kwdef(name, token, 0, 0, 0,		c89, c99, gcc, attr, deco)
+#define kwdef_sclass(name, sclass,		c89, c99, gcc, attr, deco) \
+	kwdef(name, T_SCLASS, sclass, 0, 0,	c89, c99, gcc, attr, deco)
+#define kwdef_type(name, tspec,			c89, c99, gcc, attr, deco) \
+	kwdef(name, T_TYPE, 0, tspec, 0,	c89, c99, gcc, attr, deco)
+#define kwdef_tqual(name, tqual,		c89, c99, gcc, attr, deco) \
+	kwdef(name, T_QUAL, 0, 0, tqual,	c89, c99, gcc, attr, deco)
+
 /*
  * Keywords.
  * During initialization they are written to the symbol table.
@@ -109,7 +123,7 @@ static	struct	kwtab {
 	scl_t	kw_scl;		/* storage class if kw_token T_SCLASS */
 	tspec_t	kw_tspec;	/* type spec. if kw_token
  * T_TYPE or T_STRUCT_OR_UNION */
-	tqual_t	kw_tqual;	/* type qual. fi kw_token T_QUAL */
+	tqual_t	kw_tqual;	/* type qual. if kw_token T_QUAL */
 	bool	kw_c89 : 1;	/* C89 keyword */
 	bool	kw_c99 : 1;	/* C99 keyword */
 	bool	kw_gcc : 1;	/* GCC keyword */
@@ -117,105 +131,110 @@ static	struct	kwtab {
 	u_int	kw_deco : 3;	/* 1 = name, 2 = __name, 4 = __name__ */
 } kwtab[] = {
 #ifdef INT128_SIZE
-	{ "__int128_t",	T_TYPE,		0,	INT128,	0,	  0,1,0,0,1 },
-	{ "__uint128_t",T_TYPE,		0,	UINT128,0,	  0,1,0,0,1 },
+	kwdef_type(	"__int128_t",	INT128,			0,1,0,0,1),
+	kwdef_type(	"__uint128_t",	UINT128,		0,1,0,0,1),
 #endif
-	{ "__thread",	T_QUAL,		0,	0,	THREAD,	  0,0,1,0,1 },
-	{ "_Alignof",	T_ALIGNOF,	0,	0,	0,	  0,0,0,0,1 },
-	{ "_Bool",	T_TYPE,		0,	BOOL,	0,	  0,1,0,0,1 },
-	{ "_Complex",	T_TYPE,		0,	COMPLEX,0,	  0,1,0,0,1 },
-	{ "_Generic",	T_GENERIC,	0,	0,	0,	  0,1,0,0,1 },
-	{ "_Noreturn",	T_NORETURN,	0,	0,	0,	  0,1,0,0,1 },
-	{ "_Thread_local",T_QUAL,	0,	0,	THREAD,	  0,1,0,0,1 },
-	{ "alias",	T_AT_ALIAS,	0,	0,	0,	  0,0,1,1,5 },
-	{ "aligned",	T_AT_ALIGNED,	0,	0,	0,	  0,0,1,1,5 },
-	{ "alignof",	T_ALIGNOF,	0,	0,	0,	  0,0,0,0,4 },
-	{ "alloc_size",	T_AT_ALLOC_SIZE,0,	0,	0,	  0,0,1,1,5 },
-	{ "always_inline", T_AT_ALWAYS_INLINE, 0,0,	0,	  0,0,1,1,5 },
-	{ "asm",	T_ASM,		0,	0,	0,	  0,0,1,0,7 },
-	{ "attribute",	T_ATTRIBUTE,	0,	0,	0,	  0,0,1,0,6 },
-	{ "auto",	T_SCLASS,	AUTO,	0,	0,	  0,0,0,0,1 },
-	{ "bounded",	T_AT_BOUNDED,	0,	0,	0,	  0,0,1,1,5 },
-	{ "break",	T_BREAK,	0,	0,	0,	  0,0,0,0,1 },
-	{ "buffer",	T_AT_BUFFER,	0,	0,	0,	  0,0,1,1,5 },
-	{ "builtin_offsetof", T_BUILTIN_OFFSETOF, 0, 0, 0,	  0,0,1,0,2 },
-	{ "case",	T_CASE,		0,	0,	0,	  0,0,0,0,1 },
-	{ "char",	T_TYPE,		0,	CHAR,	0,	  0,0,0,0,1 },
-	{ "cold",	T_AT_COLD,	0,	0,	0,	  0,0,1,1,5 },
-	{ "const",	T_QUAL,		0,	0,	CONST,	  1,0,0,0,7 },
-	{ "constructor",T_AT_CONSTRUCTOR,0,	0,	0,	  0,0,1,1,5 },
-	{ "continue",	T_CONTINUE,	0,	0,	0,	  0,0,0,0,1 },
-	{ "default",	T_DEFAULT,	0,	0,	0,	  0,0,0,0,1 },
-	{ "deprecated",	T_AT_DEPRECATED,0,	0,	0,	  0,0,1,1,5 },
-	{ "destructor",	T_AT_DESTRUCTOR,0,	0,	0,	  0,0,1,1,5 },
-	{ "do",		T_DO,		0,	0,	0,	  0,0,0,0,1 },
-	{ "double",	T_TYPE,		0,	DOUBLE,	0,	  0,0,0,0,1 },
-	{ "else",	T_ELSE,		0,	0,	0,	  0,0,0,0,1 },
-	{ "enum",	T_ENUM,		0,	0,	0,	  

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

2021-03-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 20 18:59:00 UTC 2021

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

Log Message:
lint: use macro for encoding type information

In lint's strict bool mode, initialization must be of the correct type.
This affects the bool fields in ttab_t, which are initialized with int.
To keep the code brief, preserve these ints and let a macro do the
actual work of converting them to bool.

No change to the generated binary.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/xlint/common/inittyp.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/inittyp.c
diff -u src/usr.bin/xlint/common/inittyp.c:1.20 src/usr.bin/xlint/common/inittyp.c:1.21
--- src/usr.bin/xlint/common/inittyp.c:1.20	Sun Feb 28 18:51:51 2021
+++ src/usr.bin/xlint/common/inittyp.c	Sat Mar 20 18:59:00 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: inittyp.c,v 1.20 2021/02/28 18:51:51 rillig Exp $	*/
+/*	$NetBSD: inittyp.c,v 1.21 2021/03/20 18:59:00 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: inittyp.c,v 1.20 2021/02/28 18:51:51 rillig Exp $");
+__RCSID("$NetBSD: inittyp.c,v 1.21 2021/03/20 18:59:00 rillig Exp $");
 #endif
 
 #include 
@@ -58,101 +58,85 @@ inittyp(void)
 		tspec_t	it_tspec;
 		ttab_t	it_ttab;
 	} ittab[NTSPEC] = {
-		{ SIGNED,   { 0, 0,
-  SIGNED, UNSIGN,
-  0, 0, 0, 0, 0, 0, "signed" } },
-		{ UNSIGN,   { 0, 0,
-  SIGNED, UNSIGN,
-  0, 0, 0, 0, 0, 0, "unsigned" } },
-		{ BOOL,	{ CHAR_SIZE, 1,
-  BOOL, BOOL,
-  1, 1, 0, 1, 1, 0, "_Bool" } },
-		{ CHAR,	{ CHAR_SIZE, 8,
-  SCHAR, UCHAR,
-  1, 0, 0, 1, 1, 0, "char" } },
-		{ SCHAR,{ CHAR_SIZE, 8,
-  SCHAR, UCHAR,
-  1, 0, 0, 1, 1, 0, "signed char" } },
-		{ UCHAR,{ CHAR_SIZE, 8,
-  SCHAR, UCHAR,
-  1, 1, 0, 1, 1, 0, "unsigned char" } },
-		{ SHORT,{ SHORT_SIZE, 16,
-  SHORT, USHORT,
-  1, 0, 0, 1, 1, 0, "short" } },
-		{ USHORT,   { SHORT_SIZE, 16,
-  SHORT, USHORT,
-  1, 1, 0, 1, 1, 0, "unsigned short" } },
-		{ INT,  { INT_SIZE, INT_RSIZE * 8,
-  INT, UINT,
-  1, 0, 0, 1, 1, 0, "int" } },
-		{ UINT, { INT_SIZE, INT_RSIZE * 8,
-  INT, UINT,
-  1, 1, 0, 1, 1, 0, "unsigned int" } },
-		{ LONG, { LONG_SIZE, 32,
-  LONG, ULONG,
-  1, 0, 0, 1, 1, 0, "long" } },
-		{ ULONG,{ LONG_SIZE, 32,
-  LONG, ULONG,
-  1, 1, 0, 1, 1, 0, "unsigned long" } },
-		{ QUAD, { QUAD_SIZE, 64,
-  QUAD, UQUAD,
-  1, 0, 0, 1, 1, 0, "long long" } },
-		{ UQUAD,{ QUAD_SIZE, 64,
-  QUAD, UQUAD,
-  1, 1, 0, 1, 1, 0, "unsigned long long" } },
+#define typeinfo( \
+	tspec, signed_type, unsigned_type, \
+	size_in_bits, portable_size_in_bits, \
+	in, un, fl, ar, sc, co, name) \
+	{ \
+	tspec, { \
+		size_in_bits, portable_size_in_bits, \
+		signed_type, unsigned_type, \
+		(in) > 0, (un) > 0, (fl) > 0, (ar) > 0, (sc) > 0, (co) > 0, \
+		name, \
+	} \
+	}
+		typeinfo(SIGNED, SIGNED, UNSIGN, 0, 0,
+		0, 0, 0, 0, 0, 0, "signed"),
+		typeinfo(UNSIGN, SIGNED, UNSIGN, 0, 0,
+		0, 0, 0, 0, 0, 0, "unsigned"),
+		typeinfo(BOOL, BOOL, BOOL, CHAR_SIZE, 1,
+		1, 1, 0, 1, 1, 0, "_Bool"),
+		typeinfo(CHAR, SCHAR, UCHAR, CHAR_SIZE, 8,
+		1, 0, 0, 1, 1, 0, "char"),
+		typeinfo(SCHAR, SCHAR, UCHAR, CHAR_SIZE, 8,
+		1, 0, 0, 1, 1, 0, "signed char"),
+		typeinfo(UCHAR, SCHAR, UCHAR, CHAR_SIZE, 8,
+		1, 1, 0, 1, 1, 0, "unsigned char"),
+		typeinfo(SHORT, SHORT, USHORT, SHORT_SIZE, 16,
+		1, 0, 0, 1, 1, 0, "short"),
+		typeinfo(USHORT, SHORT, USHORT, SHORT_SIZE, 16,
+		1, 1, 0, 1, 1, 0, "unsigned short"),
+		typeinfo(INT, INT, UINT, INT_SIZE, INT_RSIZE * 8,
+		1, 0, 0, 1, 1, 0, "int"),
+		typeinfo(UINT, INT, UINT, INT_SIZE, INT_RSIZE * 8,
+		1, 1, 0, 1, 1, 0, "unsigned int"),
+		typeinfo(LONG, LONG, ULONG, LONG_SIZE, 32,
+		1, 0, 0, 1, 1, 0, "long"),
+		typeinfo(ULONG, LONG, ULONG, LONG_SIZE, 32,
+		1, 1, 0, 1, 1, 0, "unsigned long"),
+		typeinfo(QUAD, QUAD, UQUAD, QUAD_SIZE, 64,
+		1, 0, 0, 1, 1, 0, "long long"),
+		typeinfo(UQUAD, QUAD, UQUAD, QUAD_SIZE, 64,
+		1, 1, 0, 1, 1, 0, "unsigned long long"),
 #ifdef INT128_SIZE
-		{ INT128,   { INT128_SIZE, 128,
-  INT128, UINT128,
-  1, 0, 0, 1, 1, 0, "__int128_t" } },
-		{ UINT128,  { INT128_SIZE, 128,
-  INT128, UINT128,
-  1, 1, 0, 1, 1, 0, "__uint128_t" } },
+		typeinfo(INT128, INT128, UINT128, INT128_SIZE, 128,
+		1, 0, 0, 1, 1, 0, "__int128_t"),
+		typeinfo(UINT128, INT128, UINT128, INT128_SIZE, 128,
+		1, 1, 0, 1, 1, 0, "__uint128_t"),
 #endif
-
-		{ FLOAT,{ FLOAT_SIZE, 32,
-  FLOAT, FLOAT,
-			

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

2021-03-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 20 18:38:25 UTC 2021

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

Log Message:
lint: inline access to type properties in check_bad_enum_operation

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.238 -r1.239 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.238 src/usr.bin/xlint/lint1/tree.c:1.239
--- src/usr.bin/xlint/lint1/tree.c:1.238	Sat Mar 20 17:18:50 2021
+++ src/usr.bin/xlint/lint1/tree.c	Sat Mar 20 18:38:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.238 2021/03/20 17:18:50 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.239 2021/03/20 18:38:25 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.238 2021/03/20 17:18:50 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.239 2021/03/20 18:38:25 rillig Exp $");
 #endif
 
 #include 
@@ -1683,15 +1683,12 @@ check_assign_types_compatible(op_t op, i
 static void
 check_bad_enum_operation(op_t op, const tnode_t *ln, const tnode_t *rn)
 {
-	mod_t	*mp;
 
 	if (!eflag)
 		return;
 
-	mp = [op];
-
 	if (!(ln->tn_type->t_is_enum ||
-	  (mp->m_binary && rn->tn_type->t_is_enum))) {
+	  (modtab[op].m_binary && rn->tn_type->t_is_enum))) {
 		return;
 	}
 
@@ -1706,7 +1703,7 @@ check_bad_enum_operation(op_t op, const 
 	}
 
 	/* dubious operation on enum, op %s */
-	warning(241, mp->m_name);
+	warning(241, getopname(op));
 
 }
 



CVS commit: src

2021-03-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 20 17:18:50 UTC 2021

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

Log Message:
lint: in strict bool mode, check initialization as well

C99 6.7.8p11 says for initialization that "the same type constraints and
conversions as for simple assignments apply", so actually apply them.
(I had just forgotten this "operator" when I first implemented strict
bool mode.)


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c
cvs rdiff -u -r1.19 -r1.20 \
src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp
cvs rdiff -u -r1.237 -r1.238 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.c
diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c:1.23 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c:1.24
--- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c:1.23	Sat Mar 20 17:08:08 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c	Sat Mar 20 17:18:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: d_c99_bool_strict.c,v 1.23 2021/03/20 17:08:08 rillig Exp $	*/
+/*	$NetBSD: d_c99_bool_strict.c,v 1.24 2021/03/20 17:18:50 rillig Exp $	*/
 # 3 "d_c99_bool_strict.c"
 
 /*
@@ -218,7 +218,7 @@ strict_bool_bit_fields_operand_conversio
 		bool bit_field: 1;
 	};
 
-	struct s s = { 0 };
+	struct s s = { 0 > 0 };
 
 	s.ordinary = s.ordinary | s.ordinary;
 	s.bit_field = s.bit_field | s.bit_field;
@@ -765,7 +765,7 @@ initialization(void)
 	} var[] = {
 	{ __lint_false },
 	{ __lint_true },
-	{ 0 },		/* FIXME: type mismatch */
-	{ 1 },		/* FIXME: type mismatch */
+	{ 0 },		/* expect: 107 */
+	{ 1 },		/* expect: 107 */
 	};
 }

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.19 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp:1.20
--- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp:1.19	Sat Feb 20 18:55:10 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp	Sat Mar 20 17:18:50 2021
@@ -163,3 +163,5 @@ d_c99_bool_strict.c(716): operands of '=
 d_c99_bool_strict.c(728): warning: expression has null effect [129]
 d_c99_bool_strict.c(740): right operand of '+' must not be bool [337]
 d_c99_bool_strict.c(757): warning: constant in conditional context [161]
+d_c99_bool_strict.c(768): operands of 'init' have incompatible types (_Bool != int) [107]
+d_c99_bool_strict.c(769): operands of 'init' have incompatible types (_Bool != int) [107]

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.237 src/usr.bin/xlint/lint1/tree.c:1.238
--- src/usr.bin/xlint/lint1/tree.c:1.237	Fri Mar 19 08:21:26 2021
+++ src/usr.bin/xlint/lint1/tree.c	Sat Mar 20 17:18:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.237 2021/03/19 08:21:26 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.238 2021/03/20 17:18:50 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.237 2021/03/19 08:21:26 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.238 2021/03/20 17:18:50 rillig Exp $");
 #endif
 
 #include 
@@ -1112,7 +1112,7 @@ is_assignment_bool_or_other(op_t op)
 {
 	return op == ASSIGN ||
 	   op == ANDASS || op == XORASS || op == ORASS ||
-	   op == RETURN || op == FARG;
+	   op == RETURN || op == INIT || op == FARG;
 }
 
 static bool



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

2021-03-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 20 17:08:08 UTC 2021

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

Log Message:
tests/lint: test initialization in strict bool mode

I somehow forgot to list INIT as one of the operators in
is_assignment_bool_or_other.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.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.c
diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c:1.22 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c:1.23
--- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c:1.22	Sat Feb 27 17:16:48 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c	Sat Mar 20 17:08:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: d_c99_bool_strict.c,v 1.22 2021/02/27 17:16:48 rillig Exp $	*/
+/*	$NetBSD: d_c99_bool_strict.c,v 1.23 2021/03/20 17:08:08 rillig Exp $	*/
 # 3 "d_c99_bool_strict.c"
 
 /*
@@ -756,3 +756,16 @@ do_while_true(void)
 
 	} while (__lint_true);	/* expect: 161 */
 }
+
+void
+initialization(void)
+{
+	struct {
+		_Bool b;
+	} var[] = {
+	{ __lint_false },
+	{ __lint_true },
+	{ 0 },		/* FIXME: type mismatch */
+	{ 1 },		/* FIXME: type mismatch */
+	};
+}



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

2021-03-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 20 16:16:32 UTC 2021

Modified Files:
src/usr.bin/xlint/lint1: cgram.y externs1.h func.c

Log Message:
lint: rename ftflg to seen_fallthrough

One less abbreviation to remember when reading the code.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.187 -r1.188 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.79 -r1.80 src/usr.bin/xlint/lint1/externs1.h
cvs rdiff -u -r1.77 -r1.78 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/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.187 src/usr.bin/xlint/lint1/cgram.y:1.188
--- src/usr.bin/xlint/lint1/cgram.y:1.187	Sat Mar 20 16:11:12 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Sat Mar 20 16:16:32 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.187 2021/03/20 16:11:12 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.188 2021/03/20 16:16: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.187 2021/03/20 16:11:12 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.188 2021/03/20 16:16:32 rillig Exp $");
 #endif
 
 #include 
@@ -1484,7 +1484,7 @@ non_expr_statement:
 	| selection_statement
 	| iteration_statement
 	| jump_statement {
-		ftflg = false;
+		seen_fallthrough = false;
 	  }
 	| asm_statement
 
@@ -1504,16 +1504,16 @@ label:
 	  }
 	| T_CASE constant_expr T_COLON {
 		case_label($2);
-		ftflg = true;
+		seen_fallthrough = true;
 	  }
 	| T_CASE constant_expr T_ELLIPSIS constant_expr T_COLON {
 		/* XXX: We don't fill all cases */
 		case_label($2);
-		ftflg = true;
+		seen_fallthrough = true;
 	  }
 	| T_DEFAULT T_COLON {
 		default_label();
-		ftflg = true;
+		seen_fallthrough = true;
 	  }
 	;
 
@@ -1536,7 +1536,7 @@ compound_statement_rbrace:
 		freeblk();
 		mem_block_level--;
 		block_level--;
-		ftflg = false;
+		seen_fallthrough = false;
 	  }
 	;
 
@@ -1563,10 +1563,10 @@ block_item:
 expr_statement:
 	  expr T_SEMI {
 		expr($1, false, false, false, false);
-		ftflg = false;
+		seen_fallthrough = false;
 	  }
 	| T_SEMI {
-		ftflg = false;
+		seen_fallthrough = false;
 	  }
 	;
 
@@ -1582,7 +1582,7 @@ expr_statement_val:
 			$1->tn_sym->s_used = true;
 		$$ = $1;
 		expr($1, false, false, false, false);
-		ftflg = false;
+		seen_fallthrough = false;
 	  }
 	| non_expr_statement {
 		$$ = getnode();
@@ -1676,7 +1676,7 @@ iteration_statement:		/* C99 6.8.5 */
 	  }
 	| do_statement do_while_expr {
 		do2($2);
-		ftflg = false;
+		seen_fallthrough = false;
 	  }
 	| do error {
 		clear_warning_flags();

Index: src/usr.bin/xlint/lint1/externs1.h
diff -u src/usr.bin/xlint/lint1/externs1.h:1.79 src/usr.bin/xlint/lint1/externs1.h:1.80
--- src/usr.bin/xlint/lint1/externs1.h:1.79	Fri Mar 19 08:23:39 2021
+++ src/usr.bin/xlint/lint1/externs1.h	Sat Mar 20 16:16:32 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: externs1.h,v 1.79 2021/03/19 08:23:39 rillig Exp $	*/
+/*	$NetBSD: externs1.h,v 1.80 2021/03/20 16:16:32 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -236,7 +236,7 @@ extern	void	debug_node(const tnode_t *, 
 extern	sym_t	*funcsym;
 extern	bool	reached;
 extern	bool	rchflg;
-extern	bool	ftflg;
+extern	bool	seen_fallthrough;
 extern	int	nargusg;
 extern	pos_t	argsused_pos;
 extern	int	nvararg;

Index: src/usr.bin/xlint/lint1/func.c
diff -u src/usr.bin/xlint/lint1/func.c:1.77 src/usr.bin/xlint/lint1/func.c:1.78
--- src/usr.bin/xlint/lint1/func.c:1.77	Wed Mar 17 01:15:31 2021
+++ src/usr.bin/xlint/lint1/func.c	Sat Mar 20 16:16:32 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: func.c,v 1.77 2021/03/17 01:15:31 rillig Exp $	*/
+/*	$NetBSD: func.c,v 1.78 2021/03/20 16:16:32 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: func.c,v 1.77 2021/03/17 01:15:31 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.78 2021/03/20 16:16:32 rillig Exp $");
 #endif
 
 #include 
@@ -67,13 +67,13 @@ bool	rchflg;
  * Reset by each statement and set by FALLTHROUGH, switch (switch1())
  * and case (label()).
  *
- * Control statements if, for, while and switch do not reset ftflg because
- * this must be done by the controlled statement. At least for if this is
- * important because ** FALLTHROUGH ** after "if (expr) statement" is
+ * Control statements if, for, while and switch do not reset seen_fallthrough
+ * because this must be done by the controlled statement. At least for if this
+ * is important because ** FALLTHROUGH ** after "if (expr) statement" is
  * evaluated before the following token, which causes reduction of above.
  * This means that ** FALLTHROUGH ** after "if ..." would always be ignored.
  */
-bool	ftflg;
+bool	seen_fallthrough;
 
 /* The innermost control statement */
 cstk_t	*cstmt;
@@ 

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

2021-03-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 20 16:11:12 UTC 2021

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

Log Message:
lint: make the calls to clear_warning_flags stand out less

Even though clear_warning_flags and its companions are implemented as
macros, they act like ordinary functions.  Do not distract the reader by
using uppercase names for them.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.186 -r1.187 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.186 src/usr.bin/xlint/lint1/cgram.y:1.187
--- src/usr.bin/xlint/lint1/cgram.y:1.186	Sat Mar 20 15:30:58 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Sat Mar 20 16:11:12 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.186 2021/03/20 15:30:58 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.187 2021/03/20 16:11:12 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.186 2021/03/20 15:30:58 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.187 2021/03/20 16:11:12 rillig Exp $");
 #endif
 
 #include 
@@ -110,6 +110,10 @@ RESTORE_WARN_FLAGS(const char *file, siz
 #define cgram_debug(fmt, args...) do { } while (false)
 #endif
 
+#define clear_warning_flags() CLEAR_WARN_FLAGS(__FILE__, __LINE__)
+#define save_warning_flags() SAVE_WARN_FLAGS(__FILE__, __LINE__)
+#define restore_warning_flags() RESTORE_WARN_FLAGS(__FILE__, __LINE__)
+
 /* unbind the anonymous struct members from the struct */
 static void
 anonymize(sym_t *s)
@@ -357,11 +361,11 @@ external_declaration:		/* C99 6.9 */
 	  asm_statement
 	| function_definition {
 		global_clean_up_decl(false);
-		CLEAR_WARN_FLAGS(__FILE__, __LINE__);
+		clear_warning_flags();
 	  }
 	| data_def {
 		global_clean_up_decl(false);
-		CLEAR_WARN_FLAGS(__FILE__, __LINE__);
+		clear_warning_flags();
 	  }
 	;
 
@@ -1548,12 +1552,11 @@ block_item_list:
 block_item:
 	  statement {
 		$$ = true;
-		RESTORE_WARN_FLAGS(__FILE__, __LINE__);
+		restore_warning_flags();
 	  }
 	| declaration {
-	/*fprintf(stderr, "block_item.declaration: %d\n", $$);*/
 		$$ = false;
-		RESTORE_WARN_FLAGS(__FILE__, __LINE__);
+		restore_warning_flags();
 	  }
 	;
 
@@ -1596,27 +1599,27 @@ expr_statement_list:
 
 selection_statement:		/* C99 6.8.4 */
 	  if_without_else {
-		SAVE_WARN_FLAGS(__FILE__, __LINE__);
+		save_warning_flags();
 		if2();
 		if3(false);
 	  }
 	| if_without_else T_ELSE {
-		SAVE_WARN_FLAGS(__FILE__, __LINE__);
+		save_warning_flags();
 		if2();
 	  } statement {
-		CLEAR_WARN_FLAGS(__FILE__, __LINE__);
+		clear_warning_flags();
 		if3(true);
 	  }
 	| if_without_else T_ELSE error {
-		CLEAR_WARN_FLAGS(__FILE__, __LINE__);
+		clear_warning_flags();
 		if3(false);
 	  }
 	| switch_expr statement {
-		CLEAR_WARN_FLAGS(__FILE__, __LINE__);
+		clear_warning_flags();
 		switch2();
 	  }
 	| switch_expr error {
-		CLEAR_WARN_FLAGS(__FILE__, __LINE__);
+		clear_warning_flags();
 		switch2();
 	  }
 	;
@@ -1629,14 +1632,14 @@ if_without_else:
 if_expr:
 	  T_IF T_LPAREN expr T_RPAREN {
 		if1($3);
-		CLEAR_WARN_FLAGS(__FILE__, __LINE__);
+		clear_warning_flags();
 	  }
 	;
 
 switch_expr:
 	  T_SWITCH T_LPAREN expr T_RPAREN {
 		switch1($3);
-		CLEAR_WARN_FLAGS(__FILE__, __LINE__);
+		clear_warning_flags();
 	  }
 	;
 
@@ -1658,17 +1661,17 @@ generic_expr:
 
 do_statement:
 	  do statement {
-		CLEAR_WARN_FLAGS(__FILE__, __LINE__);
+		clear_warning_flags();
 	  }
 	;
 
 iteration_statement:		/* C99 6.8.5 */
 	  while_expr statement {
-		CLEAR_WARN_FLAGS(__FILE__, __LINE__);
+		clear_warning_flags();
 		while2();
 	  }
 	| while_expr error {
-		CLEAR_WARN_FLAGS(__FILE__, __LINE__);
+		clear_warning_flags();
 		while2();
 	  }
 	| do_statement do_while_expr {
@@ -1676,17 +1679,17 @@ iteration_statement:		/* C99 6.8.5 */
 		ftflg = false;
 	  }
 	| do error {
-		CLEAR_WARN_FLAGS(__FILE__, __LINE__);
+		clear_warning_flags();
 		do2(NULL);
 	  }
 	| for_exprs statement {
-		CLEAR_WARN_FLAGS(__FILE__, __LINE__);
+		clear_warning_flags();
 		for2();
 		popdecl();
 		block_level--;
 	  }
 	| for_exprs error {
-		CLEAR_WARN_FLAGS(__FILE__, __LINE__);
+		clear_warning_flags();
 		for2();
 		popdecl();
 		block_level--;
@@ -1696,7 +1699,7 @@ iteration_statement:		/* C99 6.8.5 */
 while_expr:
 	  T_WHILE T_LPAREN expr T_RPAREN {
 		while1($3);
-		CLEAR_WARN_FLAGS(__FILE__, __LINE__);
+		clear_warning_flags();
 	  }
 	;
 
@@ -1724,11 +1727,11 @@ for_exprs:
 		/* variable declaration in for loop */
 		c99ism(325);
 		for1(NULL, $6, $8);
-		CLEAR_WARN_FLAGS(__FILE__, __LINE__);
+		clear_warning_flags();
 	}
 	  | for_start opt_expr T_SEMI opt_expr T_SEMI opt_expr T_RPAREN {
 		for1($2, $4, $6);
-		CLEAR_WARN_FLAGS(__FILE__, __LINE__);
+		

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

2021-03-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 20 15:30:58 UTC 2021

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

Log Message:
lint: clean up grammar for declaration after statement

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.185 -r1.186 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.185 src/usr.bin/xlint/lint1/cgram.y:1.186
--- src/usr.bin/xlint/lint1/cgram.y:1.185	Sat Mar 20 15:28:07 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Sat Mar 20 15:30:58 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.185 2021/03/20 15:28:07 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.186 2021/03/20 15:30:58 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.185 2021/03/20 15:28:07 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.186 2021/03/20 15:30:58 rillig Exp $");
 #endif
 
 #include 
@@ -329,8 +329,6 @@ anonymize(sym_t *s)
 %type		string2
 %type			opt_asm_or_symbolrename
 %type		range
-%type	 block
-%type	 block_begin
 %type	 block_item_list
 %type	 block_item
 
@@ -1517,7 +1515,7 @@ label:
 
 compound_statement:		/* C99 6.8.2 */
 	  compound_statement_lbrace compound_statement_rbrace
-	| compound_statement_lbrace block compound_statement_rbrace
+	| compound_statement_lbrace block_item_list compound_statement_rbrace
 	;
 
 compound_statement_lbrace:
@@ -1538,16 +1536,6 @@ compound_statement_rbrace:
 	  }
 	;
 
-block:
-	  block_begin block_item_list
-	;
-
-block_begin:
-	  /* empty */ {
-		$$ = false;
-	  }
-	;
-
 block_item_list:
 	  block_item
 	| block_item_list block_item {



CVS commit: src

2021-03-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 20 15:28:07 UTC 2021

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

Log Message:
lint: fix check for declaration after statement in pre-C99 mode

The new code may not be the most beautiful, but it fixes all bugs that
occurred while testing message 327.  The grammar rules are taken from
C99 6.8.2, so it's no surprise they work well.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_327.c
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_327.exp
cvs rdiff -u -r1.184 -r1.185 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/msg_327.c
diff -u src/tests/usr.bin/xlint/lint1/msg_327.c:1.4 src/tests/usr.bin/xlint/lint1/msg_327.c:1.5
--- src/tests/usr.bin/xlint/lint1/msg_327.c:1.4	Sat Mar 20 14:17:56 2021
+++ src/tests/usr.bin/xlint/lint1/msg_327.c	Sat Mar 20 15:28:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_327.c,v 1.4 2021/03/20 14:17:56 rillig Exp $	*/
+/*	$NetBSD: msg_327.c,v 1.5 2021/03/20 15:28:07 rillig Exp $	*/
 # 3 "msg_327.c"
 
 /* Test for message: declarations after statements is a C99 feature [327] */
@@ -12,11 +12,9 @@ void
 example(void)
 {
 	statement();
-	int declaration_1;	/* FIXME: expect 327 */
+	int declaration_1;	/* expect: 327 */
 	statement();
 	int declaration_2;	/* expect: 327 */
 	statement();
 	int declaration_3;	/* expect: 327 */
-}/*FIXME*//* expect: syntax error '}' */
-
-/*FIXME*//* expect+1: cannot recover */
+}

Index: src/tests/usr.bin/xlint/lint1/msg_327.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_327.exp:1.3 src/tests/usr.bin/xlint/lint1/msg_327.exp:1.4
--- src/tests/usr.bin/xlint/lint1/msg_327.exp:1.3	Sat Mar 20 14:17:56 2021
+++ src/tests/usr.bin/xlint/lint1/msg_327.exp	Sat Mar 20 15:28:07 2021
@@ -1,4 +1,3 @@
+msg_327.c(15): warning: declarations after statements is a C99 feature [327]
 msg_327.c(17): warning: declarations after statements is a C99 feature [327]
 msg_327.c(19): warning: declarations after statements is a C99 feature [327]
-msg_327.c(20): syntax error '}' [249]
-msg_327.c(23): cannot recover from previous errors [224]

Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.184 src/usr.bin/xlint/lint1/cgram.y:1.185
--- src/usr.bin/xlint/lint1/cgram.y:1.184	Sat Mar 20 14:17:56 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Sat Mar 20 15:28:07 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.184 2021/03/20 14:17:56 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.185 2021/03/20 15:28:07 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.184 2021/03/20 14:17:56 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.185 2021/03/20 15:28:07 rillig Exp $");
 #endif
 
 #include 
@@ -119,7 +119,7 @@ anonymize(sym_t *s)
 }
 %}
 
-%expect 136
+%expect 134
 
 %union {
 	int	y_int;
@@ -135,6 +135,7 @@ anonymize(sym_t *s)
 	range_t	y_range;
 	strg_t	*y_string;
 	pqinf_t	*y_pqinf;
+	int	y_seen_statement;
 };
 
 %token			T_LBRACE T_RBRACE T_LBRACK T_RBRACK T_LPAREN T_RPAREN
@@ -328,6 +329,10 @@ anonymize(sym_t *s)
 %type		string2
 %type			opt_asm_or_symbolrename
 %type		range
+%type	 block
+%type	 block_begin
+%type	 block_item_list
+%type	 block_item
 
 
 %%
@@ -1510,21 +1515,9 @@ label:
 	  }
 	;
 
-statement_d_list:
-	  statement_list
-	| statement_d_list declaration_list statement_list {
-		if (!Sflag)
-			/* declarations after statements is a C99 feature */
-			c99ism(327);
-	  }
-	;
-
 compound_statement:		/* C99 6.8.2 */
 	  compound_statement_lbrace compound_statement_rbrace
-	| compound_statement_lbrace statement_d_list compound_statement_rbrace
-	| compound_statement_lbrace declaration_list compound_statement_rbrace
-	| compound_statement_lbrace declaration_list statement_d_list
-	compound_statement_rbrace
+	| compound_statement_lbrace block compound_statement_rbrace
 	;
 
 compound_statement_lbrace:
@@ -1545,12 +1538,35 @@ compound_statement_rbrace:
 	  }
 	;
 
-statement_list:
-	  statement
-	| statement_list statement {
+block:
+	  block_begin block_item_list
+	;
+
+block_begin:
+	  /* empty */ {
+		$$ = false;
+	  }
+	;
+
+block_item_list:
+	  block_item
+	| block_item_list block_item {
+		if (!Sflag && $1 && !$2)
+			/* declarations after statements is a C99 feature */
+			c99ism(327);
+	}
+	;
+
+block_item:
+	  statement {
+		$$ = true;
+		RESTORE_WARN_FLAGS(__FILE__, __LINE__);
+	  }
+	| declaration {
+	/*fprintf(stderr, "block_item.declaration: %d\n", $$);*/
+		$$ = false;
 		RESTORE_WARN_FLAGS(__FILE__, __LINE__);
 	  }
-	| statement_list error T_SEMI
 	;
 
 expr_statement:



CVS commit: src/sys/arch/aarch64

2021-03-20 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Mar 20 14:30:50 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64: locore.S pmapboot.c
src/sys/arch/aarch64/include: pmap.h

Log Message:
Make pmapboot_enter panic if anything goes wrong and any mappings overlap
rather than only doing it in locore.S


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/arch/aarch64/aarch64/locore.S
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/aarch64/aarch64/pmapboot.c
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/aarch64/include/pmap.h

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

Modified files:

Index: src/sys/arch/aarch64/aarch64/locore.S
diff -u src/sys/arch/aarch64/aarch64/locore.S:1.76 src/sys/arch/aarch64/aarch64/locore.S:1.77
--- src/sys/arch/aarch64/aarch64/locore.S:1.76	Sat Jan  9 15:07:42 2021
+++ src/sys/arch/aarch64/aarch64/locore.S	Sat Mar 20 14:30:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.76 2021/01/09 15:07:42 jmcneill Exp $	*/
+/*	$NetBSD: locore.S,v 1.77 2021/03/20 14:30:50 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -38,7 +38,7 @@
 #include 
 #include "assym.h"
 
-RCSID("$NetBSD: locore.S,v 1.76 2021/01/09 15:07:42 jmcneill Exp $")
+RCSID("$NetBSD: locore.S,v 1.77 2021/03/20 14:30:50 skrll Exp $")
 
 #ifdef AARCH64_DEVICE_MEM_STRONGLY_ORDERED
 #define	MAIR_DEVICE_MEM		MAIR_DEVICE_nGnRnE
@@ -832,7 +832,7 @@ init_mmutable:
 #endif
 
 	/*
-	 * int
+	 * void
 	 * pmapboot_enter(
 	 * x0: vaddr_t va,
 	 * x1: paddr_t pa,
@@ -853,7 +853,6 @@ init_mmutable:
 	orr	x4, x4, #LX_BLKPAG_UXN | LX_BLKPAG_PXN	/* attr */
 	mov	x5, x26/* pr func */
 	bl	pmapboot_enter
-	cbnz	x0, init_mmutable_error
 #endif
 
 	/* identity mapping for kernel image */
@@ -869,7 +868,6 @@ init_mmutable:
 	orr	x4, x4, #LX_BLKPAG_UXN
 	mov	x5, x26/* pr func */
 	bl	pmapboot_enter
-	cbnz	x0, init_mmutable_error
 
 #ifdef FDT
 	VPRINT("Creating identity mapping for FDT\n")
@@ -884,7 +882,6 @@ init_mmutable:
 	orr	x4, x4, #LX_BLKPAG_UXN | LX_BLKPAG_PXN	/* attr */
 	mov	x5, x26/* pr func */
 	bl	pmapboot_enter
-	cbnz	x0, init_mmutable_error
 #endif
 
 	VPRINT("Creating KVA=PA tables\n")
@@ -897,7 +894,6 @@ init_mmutable:
 	orr	x4, x4, #LX_BLKPAG_UXN
 	mov	x5, x26/* pr func */
 	bl	pmapboot_enter
-	cbnz	x0, init_mmutable_error
 
 	VPRINT("OK\n");
 	mov	x0, xzr

Index: src/sys/arch/aarch64/aarch64/pmapboot.c
diff -u src/sys/arch/aarch64/aarch64/pmapboot.c:1.15 src/sys/arch/aarch64/aarch64/pmapboot.c:1.16
--- src/sys/arch/aarch64/aarch64/pmapboot.c:1.15	Sat Jan  9 13:42:25 2021
+++ src/sys/arch/aarch64/aarch64/pmapboot.c	Sat Mar 20 14:30:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmapboot.c,v 1.15 2021/01/09 13:42:25 jmcneill Exp $	*/
+/*	$NetBSD: pmapboot.c,v 1.16 2021/03/20 14:30:50 skrll Exp $	*/
 
 /*
  * Copyright (c) 2018 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmapboot.c,v 1.15 2021/01/09 13:42:25 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmapboot.c,v 1.16 2021/03/20 14:30:50 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_ddb.h"
@@ -207,7 +207,7 @@ tlb_contiguous_p(vaddr_t va, paddr_t pa,
  * pmapboot_enter() accesses pagetables by physical address.
  * this should be called while identity mapping (VA=PA) available.
  */
-int
+void
 pmapboot_enter(vaddr_t va, paddr_t pa, psize_t size, psize_t blocksize,
 pt_entry_t attr, void (*pr)(const char *, ...) __printflike(1, 2))
 {
@@ -232,7 +232,7 @@ pmapboot_enter(vaddr_t va, paddr_t pa, p
 		level = 3;
 		break;
 	default:
-		return -1;
+		panic("%s: bad blocksize (%" PRIxPSIZE ")", __func__, blocksize);
 	}
 
 	VPRINTF("pmapboot_enter: va=0x%lx, pa=0x%lx, size=0x%lx, "
@@ -260,7 +260,8 @@ pmapboot_enter(vaddr_t va, paddr_t pa, p
 		ttbr = 1;
 		break;
 	default:
-		return -1;
+		panic("%s: unknown address space (%d/%" PRIxVADDR ")", __func__,
+		aarch64_addressspace(va), va);
 	}
 
 	while (va < va_end) {
@@ -275,7 +276,7 @@ pmapboot_enter(vaddr_t va, paddr_t pa, p
 			if (l1 == NULL) {
 VPRINTF("pmapboot_enter: "
 "cannot allocate L1 page\n");
-return -1;
+panic("%s: can't allocate memory", __func__);
 			}
 
 			pte = (uint64_t)l1 | L0_TABLE;
@@ -320,7 +321,7 @@ pmapboot_enter(vaddr_t va, paddr_t pa, p
 			if (l2 == NULL) {
 VPRINTF("pmapboot_enter: "
 "cannot allocate L2 page\n");
-return -1;
+panic("%s: can't allocate memory", __func__);
 			}
 
 			pte = (uint64_t)l2 | L1_TABLE;
@@ -364,7 +365,7 @@ pmapboot_enter(vaddr_t va, paddr_t pa, p
 			if (l3 == NULL) {
 VPRINTF("pmapboot_enter: "
 "cannot allocate L3 page\n");
-return -1;
+panic("%s: can't allocate memory", __func__);
 			}
 
 			pte = (uint64_t)l3 | L2_TABLE;
@@ -440,7 +441,8 @@ pmapboot_enter(vaddr_t va, paddr_t pa, p
 
 	dsb(ish);
 
-	return nskip;
+	if (nskip != 0)
+		panic("%s: overlapping/incompatible mappings (%d)", __func__, nskip);
 }
 
 paddr_t 

CVS commit: src/usr.bin/cmp

2021-03-20 Thread Aleksey Cheusov
Module Name:src
Committed By:   cheusov
Date:   Sat Mar 20 14:27:47 UTC 2021

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

Log Message:
cmp.c: use C99 strtoll(3) instead of legacy strtoq(3)


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/cmp/cmp.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/cmp/cmp.c
diff -u src/usr.bin/cmp/cmp.c:1.20 src/usr.bin/cmp/cmp.c:1.21
--- src/usr.bin/cmp/cmp.c:1.20	Sun Oct 30 19:33:49 2016
+++ src/usr.bin/cmp/cmp.c	Sat Mar 20 14:27:47 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cmp.c,v 1.20 2016/10/30 19:33:49 christos Exp $	*/
+/*	$NetBSD: cmp.c,v 1.21 2021/03/20 14:27:47 cheusov Exp $	*/
 
 /*
  * Copyright (c) 1987, 1990, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19
 #if 0
 static char sccsid[] = "@(#)cmp.c	8.3 (Berkeley) 4/2/94";
 #else
-__RCSID("$NetBSD: cmp.c,v 1.20 2016/10/30 19:33:49 christos Exp $");
+__RCSID("$NetBSD: cmp.c,v 1.21 2021/03/20 14:27:47 cheusov Exp $");
 #endif
 #endif /* not lint */
 
@@ -125,12 +125,12 @@ main(int argc, char *argv[])
 		char *ep;
 
 		errno = 0;
-		skip1 = strtoq(argv[2], , 0);
+		skip1 = (off_t)strtoll(argv[2], , 0);
 		if (errno || ep == argv[2])
 			usage();
 
 		if (argc == 4) {
-			skip2 = strtoq(argv[3], , 0);
+			skip2 = (off_t)strtoll(argv[3], , 0);
 			if (errno || ep == argv[3])
 usage();
 		}



CVS commit: src

2021-03-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 20 14:17:56 UTC 2021

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

Log Message:
lint: properly name C99 in message about declaration after statement

Now that C99 has been released and published, there is no reason anymore
to refer to it as C9X.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_327.c
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_327.exp
cvs rdiff -u -r1.183 -r1.184 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.88 -r1.89 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_327.c
diff -u src/tests/usr.bin/xlint/lint1/msg_327.c:1.3 src/tests/usr.bin/xlint/lint1/msg_327.c:1.4
--- src/tests/usr.bin/xlint/lint1/msg_327.c:1.3	Sat Mar 20 14:13:51 2021
+++ src/tests/usr.bin/xlint/lint1/msg_327.c	Sat Mar 20 14:17:56 2021
@@ -1,7 +1,7 @@
-/*	$NetBSD: msg_327.c,v 1.3 2021/03/20 14:13:51 rillig Exp $	*/
+/*	$NetBSD: msg_327.c,v 1.4 2021/03/20 14:17:56 rillig Exp $	*/
 # 3 "msg_327.c"
 
-/* Test for message: declarations after statements is a C9X feature [327] */
+/* Test for message: declarations after statements is a C99 feature [327] */
 
 /* lint1-flags: -w */
 

Index: src/tests/usr.bin/xlint/lint1/msg_327.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_327.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_327.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_327.exp:1.2	Sat Mar 20 14:13:51 2021
+++ src/tests/usr.bin/xlint/lint1/msg_327.exp	Sat Mar 20 14:17:56 2021
@@ -1,4 +1,4 @@
-msg_327.c(17): warning: declarations after statements is a C9X feature [327]
-msg_327.c(19): warning: declarations after statements is a C9X feature [327]
+msg_327.c(17): warning: declarations after statements is a C99 feature [327]
+msg_327.c(19): warning: declarations after statements is a C99 feature [327]
 msg_327.c(20): syntax error '}' [249]
 msg_327.c(23): cannot recover from previous errors [224]

Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.183 src/usr.bin/xlint/lint1/cgram.y:1.184
--- src/usr.bin/xlint/lint1/cgram.y:1.183	Sat Mar 20 13:53:28 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Sat Mar 20 14:17:56 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.183 2021/03/20 13:53:28 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.184 2021/03/20 14:17:56 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.183 2021/03/20 13:53:28 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.184 2021/03/20 14:17:56 rillig Exp $");
 #endif
 
 #include 
@@ -1514,7 +1514,7 @@ statement_d_list:
 	  statement_list
 	| statement_d_list declaration_list statement_list {
 		if (!Sflag)
-			/* declarations after statements is a C9X feature */
+			/* declarations after statements is a C99 feature */
 			c99ism(327);
 	  }
 	;

Index: src/usr.bin/xlint/lint1/err.c
diff -u src/usr.bin/xlint/lint1/err.c:1.88 src/usr.bin/xlint/lint1/err.c:1.89
--- src/usr.bin/xlint/lint1/err.c:1.88	Thu Mar 18 21:26:56 2021
+++ src/usr.bin/xlint/lint1/err.c	Sat Mar 20 14:17:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: err.c,v 1.88 2021/03/18 21:26:56 rillig Exp $	*/
+/*	$NetBSD: err.c,v 1.89 2021/03/20 14:17:56 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.88 2021/03/18 21:26:56 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.89 2021/03/20 14:17:56 rillig Exp $");
 #endif
 
 #include 
@@ -386,7 +386,7 @@ const	char *msgs[] = {
 	"suggest cast from '%s' to '%s' on op %s to avoid overflow",  /* 324 */
 	"variable declaration in for loop",			  /* 325 */
 	"%s attribute ignored for %s",  /* 326 */
-	"declarations after statements is a C9X feature",	  /* 327 */
+	"declarations after statements is a C99 feature",	  /* 327 */
 	"union cast is a C9X feature",  /* 328 */
 	"type '%s' is not a member of '%s'",			  /* 329 */
 	"operand of '%s' must be bool, not '%s'",		  /* 330 */



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

2021-03-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 20 14:13:51 UTC 2021

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

Log Message:
tests/lint: add test for declaration after statement


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_327.c
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_327.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_327.c
diff -u src/tests/usr.bin/xlint/lint1/msg_327.c:1.2 src/tests/usr.bin/xlint/lint1/msg_327.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_327.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_327.c	Sat Mar 20 14:13:51 2021
@@ -1,7 +1,22 @@
-/*	$NetBSD: msg_327.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_327.c,v 1.3 2021/03/20 14:13:51 rillig Exp $	*/
 # 3 "msg_327.c"
 
-// Test for message: declarations after statements is a C9X feature [327]
+/* Test for message: declarations after statements is a C9X feature [327] */
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* lint1-flags: -w */
+
+void statement(void);
+
+/*ARGSUSED*/
+void
+example(void)
+{
+	statement();
+	int declaration_1;	/* FIXME: expect 327 */
+	statement();
+	int declaration_2;	/* expect: 327 */
+	statement();
+	int declaration_3;	/* expect: 327 */
+}/*FIXME*//* expect: syntax error '}' */
+
+/*FIXME*//* expect+1: cannot recover */

Index: src/tests/usr.bin/xlint/lint1/msg_327.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_327.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_327.exp:1.2
--- src/tests/usr.bin/xlint/lint1/msg_327.exp:1.1	Sat Jan  2 10:22:44 2021
+++ src/tests/usr.bin/xlint/lint1/msg_327.exp	Sat Mar 20 14:13:51 2021
@@ -1 +1,4 @@
-msg_327.c(6): syntax error ':' [249]
+msg_327.c(17): warning: declarations after statements is a C9X feature [327]
+msg_327.c(19): warning: declarations after statements is a C9X feature [327]
+msg_327.c(20): syntax error '}' [249]
+msg_327.c(23): cannot recover from previous errors [224]



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

2021-03-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 20 13:53:28 UTC 2021

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

Log Message:
lint: use proper boolean literals instead of 0/1

The code in the C grammar is generated by yacc and is not checked by
lint's strict bool mode, therefore the replacement was done manually.

No change to the resulting change.


To generate a diff of this commit:
cvs rdiff -u -r1.182 -r1.183 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.182 src/usr.bin/xlint/lint1/cgram.y:1.183
--- src/usr.bin/xlint/lint1/cgram.y:1.182	Sat Mar 20 11:33:50 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Sat Mar 20 13:53:28 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.182 2021/03/20 11:33:50 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.183 2021/03/20 13:53:28 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.182 2021/03/20 11:33:50 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.183 2021/03/20 13:53:28 rillig Exp $");
 #endif
 
 #include 
@@ -353,11 +353,11 @@ translation_unit:		/* C99 6.9 */
 external_declaration:		/* C99 6.9 */
 	  asm_statement
 	| function_definition {
-		global_clean_up_decl(0);
+		global_clean_up_decl(false);
 		CLEAR_WARN_FLAGS(__FILE__, __LINE__);
 	  }
 	| data_def {
-		global_clean_up_decl(0);
+		global_clean_up_decl(false);
 		CLEAR_WARN_FLAGS(__FILE__, __LINE__);
 	  }
 	;
@@ -699,15 +699,15 @@ struct_spec:
 		 * yychar is valid because otherwise the parser would not
 		 * have been able to decide if it must shift or reduce
 		 */
-		$$ = mktag($2, $1, 0, yychar == T_SEMI);
+		$$ = mktag($2, $1, false, yychar == T_SEMI);
 	  }
 	| struct struct_tag {
-		dcs->d_tagtyp = mktag($2, $1, 1, 0);
+		dcs->d_tagtyp = mktag($2, $1, true, false);
 	  } struct_declaration {
 		$$ = complete_tag_struct_or_union(dcs->d_tagtyp, $4);
 	  }
 	| struct {
-		dcs->d_tagtyp = mktag(NULL, $1, 1, 0);
+		dcs->d_tagtyp = mktag(NULL, $1, true, false);
 	  } struct_declaration {
 		$$ = complete_tag_struct_or_union(dcs->d_tagtyp, $3);
 	  }
@@ -897,15 +897,15 @@ type_member_decl:
 
 enum_spec:
 	  enum enum_tag {
-		$$ = mktag($2, ENUM, 0, 0);
+		$$ = mktag($2, ENUM, false, false);
 	  }
 	| enum enum_tag {
-		dcs->d_tagtyp = mktag($2, ENUM, 1, 0);
+		dcs->d_tagtyp = mktag($2, ENUM, true, false);
 	  } enum_declaration {
 		$$ = complete_tag_enum(dcs->d_tagtyp, $4);
 	  }
 	| enum {
-		dcs->d_tagtyp = mktag(NULL, ENUM, 1, 0);
+		dcs->d_tagtyp = mktag(NULL, ENUM, true, false);
 	  } enum_declaration {
 		$$ = complete_tag_enum(dcs->d_tagtyp, $3);
 	  }
@@ -971,10 +971,10 @@ enums:
 
 enumerator:
 	  enumeration_constant {
-		$$ = enumeration_constant($1, enumval, 1);
+		$$ = enumeration_constant($1, enumval, true);
 	  }
 	| enumeration_constant T_ASSIGN constant_expr {
-		$$ = enumeration_constant($1, to_int_constant($3, true), 0);
+		$$ = enumeration_constant($1, to_int_constant($3, true), false);
 	  }
 	;
 
@@ -1039,10 +1039,10 @@ notype_direct_decl:
 		$$ = $2;
 	  }
 	| notype_direct_decl T_LBRACK T_RBRACK {
-		$$ = add_array($1, 0, 0);
+		$$ = add_array($1, false, 0);
 	  }
 	| notype_direct_decl T_LBRACK constant_expr T_RBRACK {
-		$$ = add_array($1, 1, to_int_constant($3, false));
+		$$ = add_array($1, true, to_int_constant($3, false));
 	  }
 	| notype_direct_decl param_list opt_asm_or_symbolrename {
 		$$ = add_function(symbolrename($1, $3), $2);
@@ -1072,10 +1072,10 @@ type_direct_decl:
 		$$ = $2;
 	  }
 	| type_direct_decl T_LBRACK T_RBRACK {
-		$$ = add_array($1, 0, 0);
+		$$ = add_array($1, false, 0);
 	  }
 	| type_direct_decl T_LBRACK constant_expr T_RBRACK {
-		$$ = add_array($1, 1, to_int_constant($3, false));
+		$$ = add_array($1, true, to_int_constant($3, false));
 	  }
 	| type_direct_decl param_list opt_asm_or_symbolrename {
 		$$ = add_function(symbolrename($1, $3), $2);
@@ -1112,10 +1112,10 @@ direct_param_decl:
 		$$ = $2;
 	  }
 	| direct_param_decl T_LBRACK T_RBRACK {
-		$$ = add_array($1, 0, 0);
+		$$ = add_array($1, false, 0);
 	  }
 	| direct_param_decl T_LBRACK constant_expr T_RBRACK {
-		$$ = add_array($1, 1, to_int_constant($3, false));
+		$$ = add_array($1, true, to_int_constant($3, false));
 	  }
 	| direct_param_decl param_list opt_asm_or_symbolrename {
 		$$ = add_function(symbolrename($1, $3), $2);
@@ -1141,10 +1141,10 @@ direct_notype_param_decl:
 		$$ = $2;
 	  }
 	| direct_notype_param_decl T_LBRACK T_RBRACK {
-		$$ = add_array($1, 0, 0);
+		$$ = add_array($1, false, 0);
 	  }
 	| direct_notype_param_decl T_LBRACK constant_expr T_RBRACK {
-		$$ = add_array($1, 1, to_int_constant($3, false));
+		$$ = add_array($1, true, to_int_constant($3, false));
 	  }
 	| direct_notype_param_decl param_list 

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

2021-03-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 20 13:25:31 UTC 2021

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

Log Message:
lint: update comment on setasm for C99

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.151 -r1.152 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.151 src/usr.bin/xlint/lint1/decl.c:1.152
--- src/usr.bin/xlint/lint1/decl.c:1.151	Sat Mar 20 13:22:06 2021
+++ src/usr.bin/xlint/lint1/decl.c	Sat Mar 20 13:25:31 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.151 2021/03/20 13:22:06 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.152 2021/03/20 13:25:31 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.151 2021/03/20 13:22:06 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.152 2021/03/20 13:25:31 rillig Exp $");
 #endif
 
 #include 
@@ -684,8 +684,8 @@ popdecl(void)
  * There is no need to clear d_asm in dinfo structs with context AUTO,
  * because these structs are freed at the end of the compound statement.
  * But it must be cleared in the outermost dinfo struct, which has
- * context EXTERN. This could be done in clrtyp() and would work for
- * C, but not for C++ (due to mixed statements and declarations). Thus
+ * context EXTERN. This could be done in clrtyp() and would work for C90,
+ * but not for C99 or C++ (due to mixed statements and declarations). Thus
  * we clear it in global_clean_up_decl(), which is used to do some cleanup
  * after global declarations/definitions.
  */



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

2021-03-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 20 13:22:06 UTC 2021

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

Log Message:
lint: reduce indentation and braces in merge_type_specifiers

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.150 -r1.151 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.150 src/usr.bin/xlint/lint1/decl.c:1.151
--- src/usr.bin/xlint/lint1/decl.c:1.150	Sat Mar 20 13:06:05 2021
+++ src/usr.bin/xlint/lint1/decl.c	Sat Mar 20 13:22:06 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.150 2021/03/20 13:06:05 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.151 2021/03/20 13:22:06 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.150 2021/03/20 13:06:05 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.151 2021/03/20 13:22:06 rillig Exp $");
 #endif
 
 #include 
@@ -870,20 +870,19 @@ static tspec_t
 merge_type_specifiers(tspec_t t, tspec_t s)
 {
 
-	if (s == SIGNED || s == UNSIGN) {
-		if (t == CHAR) {
-			t = s == SIGNED ? SCHAR : UCHAR;
-		} else if (t == SHORT) {
-			t = s == SIGNED ? SHORT : USHORT;
-		} else if (t == INT) {
-			t = s == SIGNED ? INT : UINT;
-		} else if (t == LONG) {
-			t = s == SIGNED ? LONG : ULONG;
-		} else if (t == QUAD) {
-			t = s == SIGNED ? QUAD : UQUAD;
-		}
-	}
+	if (s != SIGNED && s != UNSIGN)
+		return t;
 
+	if (t == CHAR)
+		return s == SIGNED ? SCHAR : UCHAR;
+	if (t == SHORT)
+		return s == SIGNED ? SHORT : USHORT;
+	if (t == INT)
+		return s == SIGNED ? INT : UINT;
+	if (t == LONG)
+		return s == SIGNED ? LONG : ULONG;
+	if (t == QUAD)
+		return s == SIGNED ? QUAD : UQUAD;
 	return t;
 }
 



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

2021-03-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 20 13:06:05 UTC 2021

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

Log Message:
lint: extract adjusting of the storage class into separate function

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.149 -r1.150 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.149 src/usr.bin/xlint/lint1/decl.c:1.150
--- src/usr.bin/xlint/lint1/decl.c:1.149	Fri Mar 19 08:21:26 2021
+++ src/usr.bin/xlint/lint1/decl.c	Sat Mar 20 13:06:05 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.149 2021/03/19 08:21:26 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.150 2021/03/20 13:06:05 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.149 2021/03/19 08:21:26 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.150 2021/03/20 13:06:05 rillig Exp $");
 #endif
 
 #include 
@@ -721,6 +721,24 @@ clrtyp(void)
 	dcs->d_notyp = false;
 }
 
+static void
+dcs_adjust_storage_class(void)
+{
+	if (dcs->d_ctx == EXTERN) {
+		if (dcs->d_scl == REG || dcs->d_scl == AUTO) {
+			/* illegal storage class */
+			error(8);
+			dcs->d_scl = NOSCL;
+		}
+	} else if (dcs->d_ctx == ARG || dcs->d_ctx == PROTO_ARG) {
+		if (dcs->d_scl != NOSCL && dcs->d_scl != REG) {
+			/* only register valid as formal parameter storage... */
+			error(9);
+			dcs->d_scl = NOSCL;
+		}
+	}
+}
+
 /*
  * Create a type structure from the information gathered in
  * the declaration stack.
@@ -732,14 +750,12 @@ deftyp(void)
 {
 	tspec_t	t, s, l, c;
 	type_t	*tp;
-	scl_t	scl;
 
 	t = dcs->d_abstract_type; /* VOID, BOOL, CHAR, INT or COMPLEX */
 	c = dcs->d_complex_mod;	/* FLOAT or DOUBLE */
 	s = dcs->d_sign_mod;	/* SIGNED or UNSIGN */
 	l = dcs->d_rank_mod;	/* SHORT, LONG or QUAD */
 	tp = dcs->d_type;
-	scl = dcs->d_scl;
 
 #ifdef DEBUG
 	printf("%s: %s\n", __func__, type_name(tp));
@@ -827,21 +843,7 @@ deftyp(void)
 		error(4);
 	}
 
-	if (dcs->d_ctx == EXTERN) {
-		if (scl == REG || scl == AUTO) {
-			/* illegal storage class */
-			error(8);
-			scl = NOSCL;
-		}
-	} else if (dcs->d_ctx == ARG || dcs->d_ctx == PROTO_ARG) {
-		if (scl != NOSCL && scl != REG) {
-			/* only register valid as formal parameter storage... */
-			error(9);
-			scl = NOSCL;
-		}
-	}
-
-	dcs->d_scl = scl;
+	dcs_adjust_storage_class();
 
 	if (dcs->d_const && dcs->d_type->t_const) {
 		lint_assert(dcs->d_type->t_typedef);



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

2021-03-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 20 13:00:43 UTC 2021

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

Log Message:
lint: document the struct for declarations more precisely

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/usr.bin/xlint/lint1/lint1.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/lint1/lint1.h
diff -u src/usr.bin/xlint/lint1/lint1.h:1.75 src/usr.bin/xlint/lint1/lint1.h:1.76
--- src/usr.bin/xlint/lint1/lint1.h:1.75	Fri Mar 19 08:21:26 2021
+++ src/usr.bin/xlint/lint1/lint1.h	Sat Mar 20 13:00:43 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.75 2021/03/19 08:21:26 rillig Exp $ */
+/* $NetBSD: lint1.h,v 1.76 2021/03/20 13:00:43 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -309,15 +309,15 @@ typedef	struct tnode {
 
 /*
  * For nested declarations a stack exists, which holds all information
- * needed for the current level. dcs points to the top element of this
+ * needed for the current level. dcs points to the innermost element of this
  * stack.
  *
  * d_ctx describes the context of the current declaration. Its value is
  * one of
  *	EXTERN		global declarations
  *	MOS or MOU	declarations of struct or union members
- *	CTCONST		declarations of enums
- *	ARG		declaration of arguments in old style function
+ *	CTCONST		declarations of enums or boolean constants
+ *	ARG		declaration of arguments in old-style function
  *			definitions
  *	PROTO_ARG	declaration of arguments in function prototypes
  *	AUTO		declaration of local symbols



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

2021-03-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 20 11:33:50 UTC 2021

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

Log Message:
lint: remove unnecessary '%prec T_COMMA' from grammar

My previous commit message was wrong in saying that the '%prec' was
necessary.  It is not necessary.

Most probably I misspelled the name of the grammar rule as opt_comma
instead of comma_opt, which would lead to the same number of conflicts
in the grammar plus a warning, but no build failure.


To generate a diff of this commit:
cvs rdiff -u -r1.181 -r1.182 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.181 src/usr.bin/xlint/lint1/cgram.y:1.182
--- src/usr.bin/xlint/lint1/cgram.y:1.181	Sat Mar 20 11:24:49 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Sat Mar 20 11:33:50 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.181 2021/03/20 11:24:49 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.182 2021/03/20 11:33:50 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.181 2021/03/20 11:24:49 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.182 2021/03/20 11:33:50 rillig Exp $");
 #endif
 
 #include 
@@ -1332,7 +1332,7 @@ initializer:			/* C99 6.7.8 "Initializat
 	| init_lbrace init_rbrace {
 		/* XXX: Empty braces are not covered by C99 6.7.8. */
 	  }
-	| init_lbrace initializer_list %prec T_COMMA comma_opt init_rbrace
+	| init_lbrace initializer_list comma_opt init_rbrace
 	| error
 	;
 



CVS commit: src

2021-03-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 20 11:24:49 UTC 2021

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

Log Message:
lint: join grammar rules for initialization

The '%prec T_COMMA' is necessary to avoid lots of parse errors in the
lint1 unit tests.  Curiously, further down in the grammar, for compound
literals, the '%prec T_COMMA' is not necessary, even though the context
looks very similar.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/tests/usr.bin/xlint/lint1/d_c99_compound_literal_comma.c
cvs rdiff -u -r1.180 -r1.181 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/d_c99_compound_literal_comma.c
diff -u src/tests/usr.bin/xlint/lint1/d_c99_compound_literal_comma.c:1.2 src/tests/usr.bin/xlint/lint1/d_c99_compound_literal_comma.c:1.3
--- src/tests/usr.bin/xlint/lint1/d_c99_compound_literal_comma.c:1.2	Sun Jan 31 14:39:31 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_compound_literal_comma.c	Sat Mar 20 11:24:49 2021
@@ -1,17 +1,33 @@
-/*	$NetBSD: d_c99_compound_literal_comma.c,v 1.2 2021/01/31 14:39:31 rillig Exp $	*/
+/*	$NetBSD: d_c99_compound_literal_comma.c,v 1.3 2021/03/20 11:24:49 rillig Exp $	*/
 # 3 "d_c99_compound_literal_comma.c"
 
-struct bintime {
-	unsigned long long sec;
-	unsigned long long frac;
+/*-
+ * Ensure that compound literals can be parsed.
+ *
+ * C99 6.5.2 "Postfix operators" for the syntax.
+ * C99 6.5.2.5 "Compound literals" for the semantics.
+ */
+
+struct point {
+	int x;
+	int y;
 };
 
-struct bintime
-us2bintime(unsigned long long us)
+struct point
+point_abs(struct point point)
 {
+	/* No designators, no trailing comma. */
+	if (point.x >= 0 && point.y >= 0)
+		return (struct point){ point.x, point.y };
+
+	/* Designators, no trailing comma. */
+	if (point.x >= 0)
+		return (struct point){ .x = point.x, .y = -point.y };
+
+	/* No designators, trailing comma. */
+	if (point.y >= 0)
+		return (struct point){ point.x, point.y, };
 
-	return (struct bintime) {
-		.sec = us / 100U,
-		.frac = (((us % 100U) >> 32)/100U) >> 32,
-	};
+	/* Designators, trailing comma. */
+	return (struct point){ .x = point.x, .y = -point.y, };
 }

Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.180 src/usr.bin/xlint/lint1/cgram.y:1.181
--- src/usr.bin/xlint/lint1/cgram.y:1.180	Sat Mar 20 11:05:16 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Sat Mar 20 11:24:49 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.180 2021/03/20 11:05:16 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.181 2021/03/20 11:24:49 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.180 2021/03/20 11:05:16 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.181 2021/03/20 11:24:49 rillig Exp $");
 #endif
 
 #include 
@@ -1332,8 +1332,7 @@ initializer:			/* C99 6.7.8 "Initializat
 	| init_lbrace init_rbrace {
 		/* XXX: Empty braces are not covered by C99 6.7.8. */
 	  }
-	| init_lbrace initializer_list init_rbrace
-	| init_lbrace initializer_list T_COMMA init_rbrace
+	| init_lbrace initializer_list %prec T_COMMA comma_opt init_rbrace
 	| error
 	;
 



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

2021-03-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 20 11:05:16 UTC 2021

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

Log Message:
lint: fix grammar for initialization

Previously, the grammar syntactically accepted the following code:

int var = .member = 12345;

The designation '.member =' can only be used with brace-enclosed
initializers.


To generate a diff of this commit:
cvs rdiff -u -r1.179 -r1.180 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.179 src/usr.bin/xlint/lint1/cgram.y:1.180
--- src/usr.bin/xlint/lint1/cgram.y:1.179	Sat Mar 20 10:32:43 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Sat Mar 20 11:05:16 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.179 2021/03/20 10:32:43 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.180 2021/03/20 11:05:16 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.179 2021/03/20 10:32:43 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.180 2021/03/20 11:05:16 rillig Exp $");
 #endif
 
 #include 
@@ -119,7 +119,7 @@ anonymize(sym_t *s)
 }
 %}
 
-%expect 138
+%expect 136
 
 %union {
 	int	y_int;
@@ -1326,10 +1326,6 @@ outermost_initializer:
 	;
 
 initializer:			/* C99 6.7.8 "Initialization" */
-	| designation init_base_expr	%prec T_COMMA
-	| init_base_expr
-
-init_base_expr:
 	  expr%prec T_COMMA {
 		init_using_expr($1);
 	  }
@@ -1342,8 +1338,13 @@ init_base_expr:
 	;
 
 initializer_list:		/* C99 6.7.8 "Initialization" */
-	  initializer		%prec T_COMMA
-	| initializer_list T_COMMA initializer
+	  initializer_list_item		%prec T_COMMA
+	| initializer_list T_COMMA initializer_list_item
+	;
+
+initializer_list_item:
+	  designation initializer
+	| initializer
 	;
 
 range:
@@ -1978,7 +1979,7 @@ term:
 	| T_LPAREN type_name T_RPAREN			%prec T_UNARY {
 		sym_t *tmp = mktempsym($2);
 		cgram_declare(tmp, true, NULL);
-	  } init_lbrace initializer_list init_rbrace {
+	  } init_lbrace initializer_list comma_opt init_rbrace {
 		if (!Sflag)
 			 /* compound literals are a C9X/GCC extension */
 			 gnuism(319);
@@ -2044,6 +2045,10 @@ identifier:			/* C99 6.4.2.1 */
 	  }
 	;
 
+comma_opt:
+	  T_COMMA
+	| /* empty */
+	;
 %%
 
 /* ARGSUSED */



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

2021-03-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 20 10:32:43 UTC 2021

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

Log Message:
lint: align rule names in grammar with C99

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.178 -r1.179 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.178 src/usr.bin/xlint/lint1/cgram.y:1.179
--- src/usr.bin/xlint/lint1/cgram.y:1.178	Fri Mar 19 07:54:13 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Sat Mar 20 10:32:43 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.178 2021/03/19 07:54:13 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.179 2021/03/20 10:32:43 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.178 2021/03/19 07:54:13 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.179 2021/03/20 10:32:43 rillig Exp $");
 #endif
 
 #include 
@@ -1002,7 +1002,7 @@ notype_init_decl:
 	  }
 	| notype_decl opt_asm_or_symbolrename {
 		cgram_declare($1, true, $2);
-	  } T_ASSIGN initializer {
+	  } T_ASSIGN outermost_initializer {
 		check_size($1);
 	  }
 	;
@@ -1014,7 +1014,7 @@ type_init_decl:
 	  }
 	| type_decl opt_asm_or_symbolrename {
 		cgram_declare($1, true, $2);
-	  } T_ASSIGN initializer {
+	  } T_ASSIGN outermost_initializer {
 		check_size($1);
 	  }
 	;
@@ -1317,16 +1317,16 @@ opt_asm_or_symbolrename:		/* expect only
 	  }
 	;
 
-initializer:
+outermost_initializer:
 	  {
-		cgram_debug("begin initializer");
-	  } init_assign_expr {
-		cgram_debug("end initializer");
+		cgram_debug("begin initialization");
+	  } initializer {
+		cgram_debug("end initialization");
 	  }
 	;
 
-init_assign_expr:
-	| init_by_name init_base_expr	%prec T_COMMA
+initializer:			/* C99 6.7.8 "Initialization" */
+	| designation init_base_expr	%prec T_COMMA
 	| init_base_expr
 
 init_base_expr:
@@ -1336,14 +1336,14 @@ init_base_expr:
 	| init_lbrace init_rbrace {
 		/* XXX: Empty braces are not covered by C99 6.7.8. */
 	  }
-	| init_lbrace init_expr_list init_rbrace
-	| init_lbrace init_expr_list T_COMMA init_rbrace
+	| init_lbrace initializer_list init_rbrace
+	| init_lbrace initializer_list T_COMMA init_rbrace
 	| error
 	;
 
-init_expr_list:
-	  init_assign_expr		%prec T_COMMA
-	| init_expr_list T_COMMA init_assign_expr
+initializer_list:		/* C99 6.7.8 "Initialization" */
+	  initializer		%prec T_COMMA
+	| initializer_list T_COMMA initializer
 	;
 
 range:
@@ -1379,7 +1379,7 @@ designator_list:		/* C99 6.7.8 "Initiali
 	| designator_list designator
 	;
 
-init_by_name:
+designation:			/* C99 6.7.8 "Initialization" */
 	  designator_list T_ASSIGN
 	| identifier T_COLON {
 		/* GCC style struct or union member name in initializer */
@@ -1978,7 +1978,7 @@ term:
 	| T_LPAREN type_name T_RPAREN			%prec T_UNARY {
 		sym_t *tmp = mktempsym($2);
 		cgram_declare(tmp, true, NULL);
-	  } init_lbrace init_expr_list init_rbrace {
+	  } init_lbrace initializer_list init_rbrace {
 		if (!Sflag)
 			 /* compound literals are a C9X/GCC extension */
 			 gnuism(319);



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

2021-03-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 20 08:59:46 UTC 2021

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

Log Message:
tests/lint: add more tests for initialization, based on C99 6.7.8


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/tests/usr.bin/xlint/lint1/d_c99_init.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_init.c
diff -u src/tests/usr.bin/xlint/lint1/d_c99_init.c:1.11 src/tests/usr.bin/xlint/lint1/d_c99_init.c:1.12
--- src/tests/usr.bin/xlint/lint1/d_c99_init.c:1.11	Sat Mar 20 08:54:27 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_init.c	Sat Mar 20 08:59:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: d_c99_init.c,v 1.11 2021/03/20 08:54:27 rillig Exp $	*/
+/*	$NetBSD: d_c99_init.c,v 1.12 2021/03/20 08:59:46 rillig Exp $	*/
 # 3 "d_c99_init.c"
 
 /*
@@ -144,4 +144,37 @@ struct point scalar_with_several_braces 
 	4,
 };
 
+struct rectangle {
+	struct point top_left;
+	struct point bottom_right;
+};
+
+/* C99 6.7.8p18 */
+struct rectangle screen = {
+	.bottom_right = {
+		1920,
+		1080,
+	}
+};
+
+/*
+ * C99 6.7.8p22 says: At the _end_ of its initializer list, the array no
+ * longer has incomplete type.
+ */
+struct point points[] = {
+	{
+		/*
+		 * At this point, the size of the object 'points' is not known
+		 * yet since its type is still incomplete.  Lint could warn
+		 * about this, but GCC and Clang already do.
+		 *
+		 * This test case demonstrates that in
+		 * extend_if_array_of_unknown_size, setcomplete is called too
+		 * early.
+		 */
+		sizeof points,
+		4
+	}
+};
+
 // See d_struct_init_nested.c for a more complicated example.



CVS commit: src

2021-03-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 20 08:54:27 UTC 2021

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

Log Message:
lint: fix assertion failure after error in designation

In d_c99_init.c, the initialization of array_with_designator failed.
The designator '.member' from that initialization was not cleaned up
before starting the next initialization.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/tests/usr.bin/xlint/lint1/d_c99_init.c
cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/xlint/lint1/d_c99_init.exp
cvs rdiff -u -r1.107 -r1.108 src/usr.bin/xlint/lint1/init.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_init.c
diff -u src/tests/usr.bin/xlint/lint1/d_c99_init.c:1.10 src/tests/usr.bin/xlint/lint1/d_c99_init.c:1.11
--- src/tests/usr.bin/xlint/lint1/d_c99_init.c:1.10	Sat Mar 20 08:16:30 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_init.c	Sat Mar 20 08:54:27 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: d_c99_init.c,v 1.10 2021/03/20 08:16:30 rillig Exp $	*/
+/*	$NetBSD: d_c99_init.c,v 1.11 2021/03/20 08:54:27 rillig Exp $	*/
 # 3 "d_c99_init.c"
 
 /*
@@ -139,7 +139,9 @@ int array_with_designator[] = {
  * mean the "outermost initializer".  Both GCC 10 and Clang 8 already warn
  * about this, so there is no extra work for lint to do.
  */
-// FIXME: assertion failure 'istk->i_type != NULL'
-// struct point scalar_with_several_braces = {};
+struct point scalar_with_several_braces = {
+	{{{3}}},		/*FIXME*//* expect: invalid initializer type int */
+	4,
+};
 
 // See d_struct_init_nested.c for a more complicated example.

Index: src/tests/usr.bin/xlint/lint1/d_c99_init.exp
diff -u src/tests/usr.bin/xlint/lint1/d_c99_init.exp:1.8 src/tests/usr.bin/xlint/lint1/d_c99_init.exp:1.9
--- src/tests/usr.bin/xlint/lint1/d_c99_init.exp:1.8	Fri Mar 19 01:02:52 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_init.exp	Sat Mar 20 08:54:27 2021
@@ -3,3 +3,4 @@ d_c99_init.c(23): too many initializers 
 d_c99_init.c(49): cannot initialize 'pointer to const void' from 'struct any' [185]
 d_c99_init.c(66): too many array initializers, expected 3 [173]
 d_c99_init.c(131): syntax error 'named member must only be used with struct/union' [249]
+d_c99_init.c(143): invalid initializer type int [176]

Index: src/usr.bin/xlint/lint1/init.c
diff -u src/usr.bin/xlint/lint1/init.c:1.107 src/usr.bin/xlint/lint1/init.c:1.108
--- src/usr.bin/xlint/lint1/init.c:1.107	Sat Mar 20 08:16:30 2021
+++ src/usr.bin/xlint/lint1/init.c	Sat Mar 20 08:54:27 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: init.c,v 1.107 2021/03/20 08:16:30 rillig Exp $	*/
+/*	$NetBSD: init.c,v 1.108 2021/03/20 08:54:27 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: init.c,v 1.107 2021/03/20 08:16:30 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.108 2021/03/20 08:54:27 rillig Exp $");
 #endif
 
 #include 
@@ -411,6 +411,8 @@ initstack_init(void)
 		initstk = istk->i_enclosing;
 		free(istk);
 	}
+	while (namedmem != NULL)
+		designator_shift_name();
 
 	debug_enter();
 



CVS commit: src

2021-03-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 20 08:16:30 UTC 2021

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

Log Message:
lint: replace segmentation fault with assertion failure


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/xlint/lint1/d_c99_init.c
cvs rdiff -u -r1.106 -r1.107 src/usr.bin/xlint/lint1/init.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_init.c
diff -u src/tests/usr.bin/xlint/lint1/d_c99_init.c:1.9 src/tests/usr.bin/xlint/lint1/d_c99_init.c:1.10
--- src/tests/usr.bin/xlint/lint1/d_c99_init.c:1.9	Fri Mar 19 01:02:52 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_init.c	Sat Mar 20 08:16:30 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: d_c99_init.c,v 1.9 2021/03/19 01:02:52 rillig Exp $	*/
+/*	$NetBSD: d_c99_init.c,v 1.10 2021/03/20 08:16:30 rillig Exp $	*/
 # 3 "d_c99_init.c"
 
 /*
@@ -132,4 +132,14 @@ int array_with_designator[] = {
 	333,
 };
 
+/*
+ * C99 6.7.8p11 says that the initializer of a scalar can be "optionally
+ * enclosed in braces".  It does not explicitly set an upper limit on the
+ * number of braces.  It also doesn't restrict the term "initializer" to only
+ * mean the "outermost initializer".  Both GCC 10 and Clang 8 already warn
+ * about this, so there is no extra work for lint to do.
+ */
+// FIXME: assertion failure 'istk->i_type != NULL'
+// struct point scalar_with_several_braces = {};
+
 // See d_struct_init_nested.c for a more complicated example.

Index: src/usr.bin/xlint/lint1/init.c
diff -u src/usr.bin/xlint/lint1/init.c:1.106 src/usr.bin/xlint/lint1/init.c:1.107
--- src/usr.bin/xlint/lint1/init.c:1.106	Fri Mar 19 18:17:46 2021
+++ src/usr.bin/xlint/lint1/init.c	Sat Mar 20 08:16:30 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: init.c,v 1.106 2021/03/19 18:17:46 rillig Exp $	*/
+/*	$NetBSD: init.c,v 1.107 2021/03/20 08:16:30 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: init.c,v 1.106 2021/03/19 18:17:46 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.107 2021/03/20 08:16:30 rillig Exp $");
 #endif
 
 #include 
@@ -696,6 +696,7 @@ again:
 	istk = initstk;
 
 	debug_step("expecting type '%s'", type_name(istk->i_type));
+	lint_assert(istk->i_type != NULL);
 	switch (istk->i_type->t_tspec) {
 	case ARRAY:
 		if (namedmem != NULL) {



CVS commit: src/sys/arch/aarch64/aarch64

2021-03-20 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Mar 20 06:48:23 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64: efi_machdep.c

Log Message:
Don't mark EFI runtime pages LX_BLKPAG_OS_READ | LX_BLKPAG_OS_WRITE as
these bits are only used by the current pmap fault code and these are
wired pages which will never fault.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/aarch64/aarch64/efi_machdep.c

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

Modified files:

Index: src/sys/arch/aarch64/aarch64/efi_machdep.c
diff -u src/sys/arch/aarch64/aarch64/efi_machdep.c:1.8 src/sys/arch/aarch64/aarch64/efi_machdep.c:1.9
--- src/sys/arch/aarch64/aarch64/efi_machdep.c:1.8	Thu Oct 22 07:31:15 2020
+++ src/sys/arch/aarch64/aarch64/efi_machdep.c	Sat Mar 20 06:48:23 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: efi_machdep.c,v 1.8 2020/10/22 07:31:15 skrll Exp $ */
+/* $NetBSD: efi_machdep.c,v 1.9 2021/03/20 06:48:23 skrll Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: efi_machdep.c,v 1.8 2020/10/22 07:31:15 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: efi_machdep.c,v 1.9 2021/03/20 06:48:23 skrll Exp $");
 
 #include 
 #include 
@@ -53,18 +53,15 @@ arm_efirt_md_map_range(vaddr_t va, paddr
 
 	switch (type) {
 	case ARM_EFIRT_MEM_CODE:
-		attr = LX_BLKPAG_OS_READ | LX_BLKPAG_OS_WRITE |
-		   LX_BLKPAG_AF | LX_BLKPAG_AP_RW | LX_BLKPAG_UXN |
+		attr = LX_BLKPAG_AF | LX_BLKPAG_AP_RW | LX_BLKPAG_UXN |
 		   LX_BLKPAG_ATTR_NORMAL_WB;
 		break;
 	case ARM_EFIRT_MEM_DATA:
-		attr = LX_BLKPAG_OS_READ | LX_BLKPAG_OS_WRITE |
-		   LX_BLKPAG_AF | LX_BLKPAG_AP_RW | LX_BLKPAG_UXN | LX_BLKPAG_PXN |
+		attr = LX_BLKPAG_AF | LX_BLKPAG_AP_RW | LX_BLKPAG_UXN | LX_BLKPAG_PXN |
 		   LX_BLKPAG_ATTR_NORMAL_WB;
 		break;
 	case ARM_EFIRT_MEM_MMIO:
-		attr = LX_BLKPAG_OS_READ | LX_BLKPAG_OS_WRITE |
-		   LX_BLKPAG_AF | LX_BLKPAG_AP_RW | LX_BLKPAG_UXN | LX_BLKPAG_PXN |
+		attr = LX_BLKPAG_AF | LX_BLKPAG_AP_RW | LX_BLKPAG_UXN | LX_BLKPAG_PXN |
 		   LX_BLKPAG_ATTR_DEVICE_MEM;
 		break;
 	default: