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

2021-03-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Mar 17 02:24:06 UTC 2021

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

Log Message:
lint: clean up documentation of dinfo_t

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 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.72 src/usr.bin/xlint/lint1/lint1.h:1.73
--- src/usr.bin/xlint/lint1/lint1.h:1.72	Wed Mar 17 02:18:03 2021
+++ src/usr.bin/xlint/lint1/lint1.h	Wed Mar 17 02:24:06 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.72 2021/03/17 02:18:03 rillig Exp $ */
+/* $NetBSD: lint1.h,v 1.73 2021/03/17 02:24:06 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -312,7 +312,7 @@ typedef	struct tnode {
  * needed for the current level. dcs points to the top element of this
  * stack.
  *
- * ctx describes the context of the current declaration. Its value is
+ * 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
@@ -342,7 +342,7 @@ typedef	struct dinfo {
 	bool	d_mscl : 1;	/* multiple storage classes */
 	bool	d_terr : 1;	/* invalid type combination */
 	bool	d_nedecl : 1;	/* if at least one tag is declared */
-	bool	d_vararg : 1;	/* ... in in current function decl. */
+	bool	d_vararg : 1;	/* ... in the current function decl. */
 	bool	d_proto : 1;	/* current function decl. is prototype */
 	bool	d_notyp : 1;	/* set if no type specifier was present */
 	bool	d_asm : 1;	/* set if d_ctx == AUTO and asm() present */



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

2021-03-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Mar 17 02:18:03 UTC 2021

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

Log Message:
lint: rename dinfo_t members to be more expressive

While here, sync redundant but diverging comments, split
multi-assignments and initialize the members in declaration order.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.146 -r1.147 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.71 -r1.72 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/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.146 src/usr.bin/xlint/lint1/decl.c:1.147
--- src/usr.bin/xlint/lint1/decl.c:1.146	Wed Mar 17 01:53:21 2021
+++ src/usr.bin/xlint/lint1/decl.c	Wed Mar 17 02:18:03 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.146 2021/03/17 01:53:21 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.147 2021/03/17 02:18:03 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.146 2021/03/17 01:53:21 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.147 2021/03/17 02:18:03 rillig Exp $");
 #endif
 
 #include 
@@ -222,8 +222,8 @@ add_storage_class(scl_t sc)
 		dcs->d_inline = true;
 		return;
 	}
-	if (dcs->d_type != NULL || dcs->d_atyp != NOTSPEC ||
-	dcs->d_smod != NOTSPEC || dcs->d_lmod != NOTSPEC) {
+	if (dcs->d_type != NULL || dcs->d_abstract_type != NOTSPEC ||
+	dcs->d_sign_mod != NOTSPEC || dcs->d_rank_mod != NOTSPEC) {
 		/* storage class after type is obsolescent */
 		warning(83);
 	}
@@ -261,9 +261,9 @@ add_type(type_t *tp)
 		 * This should not happen with current grammar.
 		 */
 		lint_assert(dcs->d_type == NULL);
-		lint_assert(dcs->d_atyp == NOTSPEC);
-		lint_assert(dcs->d_lmod == NOTSPEC);
-		lint_assert(dcs->d_smod == NOTSPEC);
+		lint_assert(dcs->d_abstract_type == NOTSPEC);
+		lint_assert(dcs->d_sign_mod == NOTSPEC);
+		lint_assert(dcs->d_rank_mod == NOTSPEC);
 
 		dcs->d_type = tp;
 		return;
@@ -276,14 +276,16 @@ add_type(type_t *tp)
 		 * something like "int struct a ..."
 		 * struct/union/enum with anything else is not allowed
 		 */
-		if (dcs->d_type != NULL || dcs->d_atyp != NOTSPEC ||
-		dcs->d_lmod != NOTSPEC || dcs->d_smod != NOTSPEC) {
+		if (dcs->d_type != NULL || dcs->d_abstract_type != NOTSPEC ||
+		dcs->d_rank_mod != NOTSPEC || dcs->d_sign_mod != NOTSPEC) {
 			/*
 			 * remember that an error must be reported in
 			 * deftyp().
 			 */
 			dcs->d_terr = true;
-			dcs->d_atyp = dcs->d_lmod = dcs->d_smod = NOTSPEC;
+			dcs->d_abstract_type = NOTSPEC;
+			dcs->d_sign_mod = NOTSPEC;
+			dcs->d_rank_mod = NOTSPEC;
 		}
 		dcs->d_type = tp;
 		return;
@@ -299,22 +301,22 @@ add_type(type_t *tp)
 	}
 
 	if (t == COMPLEX) {
-		if (dcs->d_cmod == FLOAT)
+		if (dcs->d_complex_mod == FLOAT)
 			t = FCOMPLEX;
-		else if (dcs->d_cmod == DOUBLE)
+		else if (dcs->d_complex_mod == DOUBLE)
 			t = DCOMPLEX;
 		else {
 			/* invalid type for _Complex */
 			error(308);
 			t = DCOMPLEX; /* just as a fallback */
 		}
-		dcs->d_cmod = NOTSPEC;
+		dcs->d_complex_mod = NOTSPEC;
 	}
 
-	if (t == LONG && dcs->d_lmod == LONG) {
+	if (t == LONG && dcs->d_rank_mod == LONG) {
 		/* "long long" or "long ... long" */
 		t = QUAD;
-		dcs->d_lmod = NOTSPEC;
+		dcs->d_rank_mod = NOTSPEC;
 		if (!quadflg)
 			/* %s C does not support 'long long' */
 			c99ism(265, tflag ? "traditional" : "c89");
@@ -328,45 +330,48 @@ add_type(type_t *tp)
 
 	/* now it can be only a combination of arithmetic types and void */
 	if (t == SIGNED || t == UNSIGN) {
-		/* remember specifiers "signed" & "unsigned" in dcs->d_smod */
-		if (dcs->d_smod != NOTSPEC)
+		/*
+		 * remember specifiers "signed" & "unsigned" in
+		 * dcs->d_sign_mod
+		 */
+		if (dcs->d_sign_mod != NOTSPEC)
 			/*
 			 * more than one "signed" and/or "unsigned"; print
 			 * an error in deftyp()
 			 */
 			dcs->d_terr = true;
-		dcs->d_smod = t;
+		dcs->d_sign_mod = t;
 	} else if (t == SHORT || t == LONG || t == QUAD) {
 		/*
 		 * remember specifiers "short", "long" and "long long" in
-		 * dcs->d_lmod
+		 * dcs->d_rank_mod
 		 */
-		if (dcs->d_lmod != NOTSPEC)
+		if (dcs->d_rank_mod != NOTSPEC)
 			/* more than one, print error in deftyp() */
 			dcs->d_terr = true;
-		dcs->d_lmod = t;
+		dcs->d_rank_mod = t;
 	} else if (t == FLOAT || t == DOUBLE) {
-		if (dcs->d_lmod == NOTSPEC || dcs->d_lmod == LONG) {
-			if (dcs->d_cmod != NOTSPEC
-			|| (t == FLOAT && dcs->d_lmod == LONG))
+		if (dcs->d_rank_mod == NOTSPEC || dcs->d_rank_mod == LONG) {
+			if (dcs->d_complex_mod != NOTSPEC
+			|| (t == FLOAT && dcs->d_rank_mod == LONG))
 dcs->d_terr = true;
-			dcs->d_cmod = t;
+			dcs->d_complex_mod = t;
 		} else {
-			if (dcs->d_atyp != NOTSPEC)
+			if (dcs->d_abstract_type != NOTSPEC)
 dcs->d_terr = true;

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

2021-03-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Mar 17 01:53:21 UTC 2021

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

Log Message:
lint: move to_int_constant from the grammar to decl.c

This way, the code is covered by running 'make lint'.  The code from the
grammar is not covered, therefore it still uses int instead of bool in a
few places.

Inline the comparison functions for uint64_t.  These functions didn't
add any clarity to the code.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.174 -r1.175 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.145 -r1.146 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.74 -r1.75 src/usr.bin/xlint/lint1/externs1.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/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.174 src/usr.bin/xlint/lint1/cgram.y:1.175
--- src/usr.bin/xlint/lint1/cgram.y:1.174	Wed Mar 17 01:38:31 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Wed Mar 17 01:53:21 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.174 2021/03/17 01:38:31 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.175 2021/03/17 01:53:21 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.174 2021/03/17 01:38:31 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.175 2021/03/17 01:53:21 rillig Exp $");
 #endif
 
 #include 
@@ -66,7 +66,6 @@ int	mem_block_level;
  */
 static int olwarn = LWARN_BAD;
 
-static	int	to_int_constant(tnode_t *, int);
 static	void	cgram_declare(sym_t *, bool, sbuf_t *);
 static	void	ignore_up_to_rparen(void);
 static	sym_t	*symbolrename(sym_t *, sbuf_t *);
@@ -873,12 +872,12 @@ notype_member_decl:
 		$$ = $1;
 	  }
 	| notype_decl T_COLON constant_expr {		/* C99 6.7.2.1 */
-		$$ = bitfield($1, to_int_constant($3, 1));
+		$$ = bitfield($1, to_int_constant($3, true));
 	  }
 	| {
 		symtyp = FVFT;
 	  } T_COLON constant_expr {			/* C99 6.7.2.1 */
-		$$ = bitfield(NULL, to_int_constant($3, 1));
+		$$ = bitfield(NULL, to_int_constant($3, true));
 	  }
 	;
 
@@ -887,12 +886,12 @@ type_member_decl:
 		$$ = $1;
 	  }
 	| type_decl T_COLON constant_expr {
-		$$ = bitfield($1, to_int_constant($3, 1));
+		$$ = bitfield($1, to_int_constant($3, true));
 	  }
 	| {
 		symtyp = FVFT;
 	  } T_COLON constant_expr {
-		$$ = bitfield(NULL, to_int_constant($3, 1));
+		$$ = bitfield(NULL, to_int_constant($3, true));
 	  }
 	;
 
@@ -975,7 +974,7 @@ enumerator:
 		$$ = enumeration_constant($1, enumval, 1);
 	  }
 	| enumeration_constant T_ASSIGN constant_expr {
-		$$ = enumeration_constant($1, to_int_constant($3, 1), 0);
+		$$ = enumeration_constant($1, to_int_constant($3, true), 0);
 	  }
 	;
 
@@ -1043,7 +1042,7 @@ notype_direct_decl:
 		$$ = add_array($1, 0, 0);
 	  }
 	| notype_direct_decl T_LBRACK constant_expr T_RBRACK {
-		$$ = add_array($1, 1, to_int_constant($3, 0));
+		$$ = add_array($1, 1, to_int_constant($3, false));
 	  }
 	| notype_direct_decl param_list opt_asm_or_symbolrename {
 		$$ = add_function(symbolrename($1, $3), $2);
@@ -1076,7 +1075,7 @@ type_direct_decl:
 		$$ = add_array($1, 0, 0);
 	  }
 	| type_direct_decl T_LBRACK constant_expr T_RBRACK {
-		$$ = add_array($1, 1, to_int_constant($3, 0));
+		$$ = add_array($1, 1, to_int_constant($3, false));
 	  }
 	| type_direct_decl param_list opt_asm_or_symbolrename {
 		$$ = add_function(symbolrename($1, $3), $2);
@@ -1116,7 +1115,7 @@ direct_param_decl:
 		$$ = add_array($1, 0, 0);
 	  }
 	| direct_param_decl T_LBRACK constant_expr T_RBRACK {
-		$$ = add_array($1, 1, to_int_constant($3, 0));
+		$$ = add_array($1, 1, to_int_constant($3, false));
 	  }
 	| direct_param_decl param_list opt_asm_or_symbolrename {
 		$$ = add_function(symbolrename($1, $3), $2);
@@ -1145,7 +1144,7 @@ direct_notype_param_decl:
 		$$ = add_array($1, 0, 0);
 	  }
 	| direct_notype_param_decl T_LBRACK constant_expr T_RBRACK {
-		$$ = add_array($1, 1, to_int_constant($3, 0));
+		$$ = add_array($1, 1, to_int_constant($3, false));
 	  }
 	| direct_notype_param_decl param_list opt_asm_or_symbolrename {
 		$$ = add_function(symbolrename($1, $3), $2);
@@ -1347,12 +1346,12 @@ init_expr_list:
 
 range:
 	  constant_expr {
-		$$.lo = to_int_constant($1, 1);
+		$$.lo = to_int_constant($1, true);
 		$$.hi = $$.lo;
 	  }
 	| constant_expr T_ELLIPSIS constant_expr {
-		$$.lo = to_int_constant($1, 1);
-		$$.hi = to_int_constant($3, 1);
+		$$.lo = to_int_constant($1, true);
+		$$.hi = to_int_constant($3, true);
 		/* initialization with '[a...b]' is a GNU extension */
 		gnuism(340);
 	  }
@@ -1445,7 +1444,7 @@ direct_abstract_decl:
 		$$ = add_array(abstract_name(), 0, 0);
 	  }
 	| T_LBRACK constant_expr T_RBRACK {
-		$$ = add_array(abstract_name(), 1, to_int_constant($2, 0));
+		$$ = add_array(abstract_name(), 1, to_int_constant($2, false));
 	  }

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

2021-03-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Mar 17 01:38:31 UTC 2021

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

Log Message:
lint: move main part of idecl over to decl.c and rename it

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.173 -r1.174 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.144 -r1.145 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.73 -r1.74 src/usr.bin/xlint/lint1/externs1.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/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.173 src/usr.bin/xlint/lint1/cgram.y:1.174
--- src/usr.bin/xlint/lint1/cgram.y:1.173	Wed Mar 17 01:22:55 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Wed Mar 17 01:38:31 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.173 2021/03/17 01:22:55 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.174 2021/03/17 01:38:31 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.173 2021/03/17 01:22:55 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.174 2021/03/17 01:38:31 rillig Exp $");
 #endif
 
 #include 
@@ -67,7 +67,7 @@ int	mem_block_level;
 static int olwarn = LWARN_BAD;
 
 static	int	to_int_constant(tnode_t *, int);
-static	void	idecl(sym_t *, int, sbuf_t *);
+static	void	cgram_declare(sym_t *, bool, sbuf_t *);
 static	void	ignore_up_to_rparen(void);
 static	sym_t	*symbolrename(sym_t *, sbuf_t *);
 
@@ -998,11 +998,11 @@ type_init_decls:
 
 notype_init_decl:
 	  notype_decl opt_asm_or_symbolrename {
-		idecl($1, 0, $2);
+		cgram_declare($1, false, $2);
 		check_size($1);
 	  }
 	| notype_decl opt_asm_or_symbolrename {
-		idecl($1, 1, $2);
+		cgram_declare($1, true, $2);
 	  } T_ASSIGN initializer {
 		check_size($1);
 	  }
@@ -1010,11 +1010,11 @@ notype_init_decl:
 
 type_init_decl:
 	  type_decl opt_asm_or_symbolrename {
-		idecl($1, 0, $2);
+		cgram_declare($1, false, $2);
 		check_size($1);
 	  }
 	| type_decl opt_asm_or_symbolrename {
-		idecl($1, 1, $2);
+		cgram_declare($1, true, $2);
 	  } T_ASSIGN initializer {
 		check_size($1);
 	  }
@@ -1975,7 +1975,7 @@ term:
 	  }
 	| T_LPAREN type_name T_RPAREN			%prec T_UNARY {
 		sym_t *tmp = mktempsym($2);
-		idecl(tmp, 1, NULL);
+		cgram_declare(tmp, true, NULL);
 	  } init_lbrace init_expr_list init_rbrace {
 		if (!Sflag)
 			 /* compound literals are a C9X/GCC extension */
@@ -2134,48 +2134,11 @@ done:
 }
 
 static void
-idecl(sym_t *decl, int initflg, sbuf_t *renaming)
+cgram_declare(sym_t *decl, bool initflg, sbuf_t *renaming)
 {
-	char *s;
-
-	initerr = false;
-	initsym = decl;
-
-	switch (dcs->d_ctx) {
-	case EXTERN:
-		if (renaming != NULL) {
-			lint_assert(decl->s_rename == NULL);
-
-			s = getlblk(1, renaming->sb_len + 1);
-	(void)memcpy(s, renaming->sb_name, renaming->sb_len + 1);
-			decl->s_rename = s;
-			freeyyv(, T_NAME);
-		}
-		decl1ext(decl, initflg);
-		break;
-	case ARG:
-		if (renaming != NULL) {
-			/* symbol renaming can't be used on function arguments */
-			error(310);
-			freeyyv(, T_NAME);
-			break;
-		}
-		(void)declare_argument(decl, initflg);
-		break;
-	default:
-		lint_assert(dcs->d_ctx == AUTO);
-		if (renaming != NULL) {
-			/* symbol renaming can't be used on automatic variables */
-			error(311);
-			freeyyv(, T_NAME);
-			break;
-		}
-		declare_local(decl, initflg);
-		break;
-	}
-
-	if (initflg && !initerr)
-		initstack_init();
+	declare(decl, initflg, renaming);
+	if (renaming != NULL)
+		freeyyv(, T_NAME);
 }
 
 /*

Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.144 src/usr.bin/xlint/lint1/decl.c:1.145
--- src/usr.bin/xlint/lint1/decl.c:1.144	Wed Mar 17 01:15:31 2021
+++ src/usr.bin/xlint/lint1/decl.c	Wed Mar 17 01:38:31 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.144 2021/03/17 01:15:31 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.145 2021/03/17 01:38: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.144 2021/03/17 01:15:31 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.145 2021/03/17 01:38:31 rillig Exp $");
 #endif
 
 #include 
@@ -1881,6 +1881,48 @@ enumeration_constant(sym_t *sym, int val
 	return sym;
 }
 
+void
+declare(sym_t *decl, bool initflg, sbuf_t *renaming)
+{
+	char *s;
+
+	initerr = false;
+	initsym = decl;
+
+	switch (dcs->d_ctx) {
+	case EXTERN:
+		if (renaming != NULL) {
+			lint_assert(decl->s_rename == NULL);
+
+			s = getlblk(1, renaming->sb_len + 1);
+			(void)memcpy(s, renaming->sb_name, renaming->sb_len + 1);
+			decl->s_rename = s;
+		}
+		decl1ext(decl, initflg);
+		break;
+	case ARG:
+		if (renaming != NULL) {
+			/* symbol renaming can't be used on function arguments */
+			error(310);
+			break;

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

2021-03-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Mar 17 01:22:55 UTC 2021

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

Log Message:
lint: replace a call to LERROR with lint_assert

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.172 -r1.173 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.172 src/usr.bin/xlint/lint1/cgram.y:1.173
--- src/usr.bin/xlint/lint1/cgram.y:1.172	Wed Mar 17 01:19:50 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Wed Mar 17 01:22:55 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.172 2021/03/17 01:19:50 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.173 2021/03/17 01:22:55 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.172 2021/03/17 01:19:50 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.173 2021/03/17 01:22:55 rillig Exp $");
 #endif
 
 #include 
@@ -2162,7 +2162,8 @@ idecl(sym_t *decl, int initflg, sbuf_t *
 		}
 		(void)declare_argument(decl, initflg);
 		break;
-	case AUTO:
+	default:
+		lint_assert(dcs->d_ctx == AUTO);
 		if (renaming != NULL) {
 			/* symbol renaming can't be used on automatic variables */
 			error(311);
@@ -2171,8 +2172,6 @@ idecl(sym_t *decl, int initflg, sbuf_t *
 		}
 		declare_local(decl, initflg);
 		break;
-	default:
-		LERROR("idecl(%d)", dcs->d_ctx);
 	}
 
 	if (initflg && !initerr)



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

2021-03-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Mar 17 01:19:50 UTC 2021

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

Log Message:
lint: rename 'toicon' to 'to_int_constant'

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.171 -r1.172 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.171 src/usr.bin/xlint/lint1/cgram.y:1.172
--- src/usr.bin/xlint/lint1/cgram.y:1.171	Wed Mar 17 01:15:31 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Wed Mar 17 01:19:50 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.171 2021/03/17 01:15:31 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.172 2021/03/17 01:19: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.171 2021/03/17 01:15:31 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.172 2021/03/17 01:19:50 rillig Exp $");
 #endif
 
 #include 
@@ -66,7 +66,7 @@ int	mem_block_level;
  */
 static int olwarn = LWARN_BAD;
 
-static	int	toicon(tnode_t *, int);
+static	int	to_int_constant(tnode_t *, int);
 static	void	idecl(sym_t *, int, sbuf_t *);
 static	void	ignore_up_to_rparen(void);
 static	sym_t	*symbolrename(sym_t *, sbuf_t *);
@@ -873,12 +873,12 @@ notype_member_decl:
 		$$ = $1;
 	  }
 	| notype_decl T_COLON constant_expr {		/* C99 6.7.2.1 */
-		$$ = bitfield($1, toicon($3, 1));
+		$$ = bitfield($1, to_int_constant($3, 1));
 	  }
 	| {
 		symtyp = FVFT;
 	  } T_COLON constant_expr {			/* C99 6.7.2.1 */
-		$$ = bitfield(NULL, toicon($3, 1));
+		$$ = bitfield(NULL, to_int_constant($3, 1));
 	  }
 	;
 
@@ -887,12 +887,12 @@ type_member_decl:
 		$$ = $1;
 	  }
 	| type_decl T_COLON constant_expr {
-		$$ = bitfield($1, toicon($3, 1));
+		$$ = bitfield($1, to_int_constant($3, 1));
 	  }
 	| {
 		symtyp = FVFT;
 	  } T_COLON constant_expr {
-		$$ = bitfield(NULL, toicon($3, 1));
+		$$ = bitfield(NULL, to_int_constant($3, 1));
 	  }
 	;
 
@@ -975,7 +975,7 @@ enumerator:
 		$$ = enumeration_constant($1, enumval, 1);
 	  }
 	| enumeration_constant T_ASSIGN constant_expr {
-		$$ = enumeration_constant($1, toicon($3, 1), 0);
+		$$ = enumeration_constant($1, to_int_constant($3, 1), 0);
 	  }
 	;
 
@@ -1043,7 +1043,7 @@ notype_direct_decl:
 		$$ = add_array($1, 0, 0);
 	  }
 	| notype_direct_decl T_LBRACK constant_expr T_RBRACK {
-		$$ = add_array($1, 1, toicon($3, 0));
+		$$ = add_array($1, 1, to_int_constant($3, 0));
 	  }
 	| notype_direct_decl param_list opt_asm_or_symbolrename {
 		$$ = add_function(symbolrename($1, $3), $2);
@@ -1076,7 +1076,7 @@ type_direct_decl:
 		$$ = add_array($1, 0, 0);
 	  }
 	| type_direct_decl T_LBRACK constant_expr T_RBRACK {
-		$$ = add_array($1, 1, toicon($3, 0));
+		$$ = add_array($1, 1, to_int_constant($3, 0));
 	  }
 	| type_direct_decl param_list opt_asm_or_symbolrename {
 		$$ = add_function(symbolrename($1, $3), $2);
@@ -1116,7 +1116,7 @@ direct_param_decl:
 		$$ = add_array($1, 0, 0);
 	  }
 	| direct_param_decl T_LBRACK constant_expr T_RBRACK {
-		$$ = add_array($1, 1, toicon($3, 0));
+		$$ = add_array($1, 1, to_int_constant($3, 0));
 	  }
 	| direct_param_decl param_list opt_asm_or_symbolrename {
 		$$ = add_function(symbolrename($1, $3), $2);
@@ -1145,7 +1145,7 @@ direct_notype_param_decl:
 		$$ = add_array($1, 0, 0);
 	  }
 	| direct_notype_param_decl T_LBRACK constant_expr T_RBRACK {
-		$$ = add_array($1, 1, toicon($3, 0));
+		$$ = add_array($1, 1, to_int_constant($3, 0));
 	  }
 	| direct_notype_param_decl param_list opt_asm_or_symbolrename {
 		$$ = add_function(symbolrename($1, $3), $2);
@@ -1347,12 +1347,12 @@ init_expr_list:
 
 range:
 	  constant_expr {
-		$$.lo = toicon($1, 1);
+		$$.lo = to_int_constant($1, 1);
 		$$.hi = $$.lo;
 	  }
 	| constant_expr T_ELLIPSIS constant_expr {
-		$$.lo = toicon($1, 1);
-		$$.hi = toicon($3, 1);
+		$$.lo = to_int_constant($1, 1);
+		$$.hi = to_int_constant($3, 1);
 		/* initialization with '[a...b]' is a GNU extension */
 		gnuism(340);
 	  }
@@ -1445,7 +1445,7 @@ direct_abstract_decl:
 		$$ = add_array(abstract_name(), 0, 0);
 	  }
 	| T_LBRACK constant_expr T_RBRACK {
-		$$ = add_array(abstract_name(), 1, toicon($2, 0));
+		$$ = add_array(abstract_name(), 1, to_int_constant($2, 0));
 	  }
 	| type_attribute direct_abstract_decl {
 		$$ = $2;
@@ -1454,7 +1454,7 @@ direct_abstract_decl:
 		$$ = add_array($1, 0, 0);
 	  }
 	| direct_abstract_decl T_LBRACK constant_expr T_RBRACK {
-		$$ = add_array($1, 1, toicon($3, 0));
+		$$ = add_array($1, 1, to_int_constant($3, 0));
 	  }
 	| abstract_decl_param_list opt_asm_or_symbolrename {
 		$$ = add_function(symbolrename(abstract_name(), $2), $1);
@@ -2081,11 +2081,11 @@ q_gt(int64_t a, int64_t b)
  * If the node is not constant or too large for int or of type float,
  * a warning 

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

2021-03-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Mar 17 01:15:31 UTC 2021

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

Log Message:
lint: rename 'blklev' to 'block_level'

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.170 -r1.171 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.143 -r1.144 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.72 -r1.73 src/usr.bin/xlint/lint1/externs1.h
cvs rdiff -u -r1.76 -r1.77 src/usr.bin/xlint/lint1/func.c
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/xlint/lint1/lex.c
cvs rdiff -u -r1.70 -r1.71 src/usr.bin/xlint/lint1/lint1.h
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/xlint/lint1/mem1.c
cvs rdiff -u -r1.232 -r1.233 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/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.170 src/usr.bin/xlint/lint1/cgram.y:1.171
--- src/usr.bin/xlint/lint1/cgram.y:1.170	Wed Mar 17 01:07:33 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Wed Mar 17 01:15:31 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.170 2021/03/17 01:07:33 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.171 2021/03/17 01:15:31 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.170 2021/03/17 01:07:33 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.171 2021/03/17 01:15:31 rillig Exp $");
 #endif
 
 #include 
@@ -50,15 +50,15 @@ extern char *yytext;
  * Contains the level of current declaration, used for symbol table entries.
  * 0 is the top-level, > 0 is inside a function body.
  */
-int	blklev;
+int	block_level;
 
 /*
- * level for memory allocation. Normally the same as blklev.
+ * level for memory allocation. Normally the same as block_level.
  * An exception is the declaration of arguments in prototypes. Memory
  * for these can't be freed after the declaration, but symbols must
  * be removed from the symbol table after the declaration.
  */
-int	mblklev;
+int	mem_block_level;
 
 /*
  * Save the no-warns state and restore it to avoid the problem where
@@ -423,13 +423,13 @@ function_definition:		/* C99 6.9.1 */
 			YYERROR;
 		}
 		funcdef($1);
-		blklev++;
+		block_level++;
 		pushdecl(ARG);
 		if (lwarn == LWARN_NONE)
 			$1->s_used = true;
 	  } arg_declaration_list_opt {
 		popdecl();
-		blklev--;
+		block_level--;
 		check_func_lint_directives();
 		check_func_old_style_arguments();
 		pushctrl(0);
@@ -1048,7 +1048,7 @@ notype_direct_decl:
 	| notype_direct_decl param_list opt_asm_or_symbolrename {
 		$$ = add_function(symbolrename($1, $3), $2);
 		popdecl();
-		blklev--;
+		block_level--;
 	  }
 	| notype_direct_decl type_attribute_list
 	;
@@ -1081,7 +1081,7 @@ type_direct_decl:
 	| type_direct_decl param_list opt_asm_or_symbolrename {
 		$$ = add_function(symbolrename($1, $3), $2);
 		popdecl();
-		blklev--;
+		block_level--;
 	  }
 	| type_direct_decl type_attribute_list
 	;
@@ -1121,7 +1121,7 @@ direct_param_decl:
 	| direct_param_decl param_list opt_asm_or_symbolrename {
 		$$ = add_function(symbolrename($1, $3), $2);
 		popdecl();
-		blklev--;
+		block_level--;
 	  }
 	;
 
@@ -1150,7 +1150,7 @@ direct_notype_param_decl:
 	| direct_notype_param_decl param_list opt_asm_or_symbolrename {
 		$$ = add_function(symbolrename($1, $3), $2);
 		popdecl();
-		blklev--;
+		block_level--;
 	  }
 	;
 
@@ -1210,7 +1210,7 @@ param_list:
 
 id_list_lparen:
 	  T_LPAREN {
-		blklev++;
+		block_level++;
 		pushdecl(PROTO_ARG);
 	  }
 	;
@@ -1242,7 +1242,7 @@ abstract_decl_param_list:
 
 abstract_decl_lparen:
 	  T_LPAREN {
-		blklev++;
+		block_level++;
 		pushdecl(PROTO_ARG);
 	  }
 	;
@@ -1459,12 +1459,12 @@ direct_abstract_decl:
 	| abstract_decl_param_list opt_asm_or_symbolrename {
 		$$ = add_function(symbolrename(abstract_name(), $2), $1);
 		popdecl();
-		blklev--;
+		block_level--;
 	  }
 	| direct_abstract_decl abstract_decl_param_list opt_asm_or_symbolrename {
 		$$ = add_function(symbolrename($1, $3), $2);
 		popdecl();
-		blklev--;
+		block_level--;
 	  }
 	| direct_abstract_decl type_attribute_list
 	;
@@ -1527,8 +1527,8 @@ compound_statement:		/* C99 6.8.2 */
 
 compound_statement_lbrace:
 	  T_LBRACE {
-		blklev++;
-		mblklev++;
+		block_level++;
+		mem_block_level++;
 		pushdecl(AUTO);
 	  }
 	;
@@ -1537,8 +1537,8 @@ compound_statement_rbrace:
 	  T_RBRACE {
 		popdecl();
 		freeblk();
-		mblklev--;
-		blklev--;
+		mem_block_level--;
+		block_level--;
 		ftflg = false;
 	  }
 	;
@@ -1677,13 +1677,13 @@ iteration_statement:		/* C99 6.8.5 */
 		CLEAR_WARN_FLAGS(__FILE__, __LINE__);
 		for2();
 		popdecl();
-		blklev--;
+		block_level--;
 	  }
 	| for_exprs error {
 		CLEAR_WARN_FLAGS(__FILE__, __LINE__);
 		for2();
 		popdecl();
-		blklev--;
+		block_level--;
 	  }
 	;
 
@@ -1709,7 

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

2021-03-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Mar 17 01:07:33 UTC 2021

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

Log Message:
lint: rename 'parn' to 'paren' in the grammar

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.169 -r1.170 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.169 src/usr.bin/xlint/lint1/cgram.y:1.170
--- src/usr.bin/xlint/lint1/cgram.y:1.169	Sun Mar  7 20:06:48 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Wed Mar 17 01:07:33 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.169 2021/03/07 20:06:48 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.170 2021/03/17 01:07:33 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.169 2021/03/07 20:06:48 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.170 2021/03/17 01:07:33 rillig Exp $");
 #endif
 
 #include 
@@ -1200,7 +1200,7 @@ type_qualifier:
 	;
 
 param_list:
-	  id_list_lparn identifier_list T_RPAREN {
+	  id_list_lparen identifier_list T_RPAREN {
 		$$ = $2;
 	  }
 	| abstract_decl_param_list {
@@ -1208,7 +1208,7 @@ param_list:
 	  }
 	;
 
-id_list_lparn:
+id_list_lparen:
 	  T_LPAREN {
 		blklev++;
 		pushdecl(PROTO_ARG);
@@ -1228,19 +1228,19 @@ identifier_list:
 	;
 
 abstract_decl_param_list:
-	  abstract_decl_lparn T_RPAREN {
+	  abstract_decl_lparen T_RPAREN {
 		$$ = NULL;
 	  }
-	| abstract_decl_lparn vararg_parameter_type_list T_RPAREN {
+	| abstract_decl_lparen vararg_parameter_type_list T_RPAREN {
 		dcs->d_proto = true;
 		$$ = $2;
 	  }
-	| abstract_decl_lparn error T_RPAREN {
+	| abstract_decl_lparen error T_RPAREN {
 		$$ = NULL;
 	  }
 	;
 
-abstract_decl_lparn:
+abstract_decl_lparen:
 	  T_LPAREN {
 		blklev++;
 		pushdecl(PROTO_ARG);
@@ -1763,16 +1763,16 @@ goto:
 	;
 
 asm_statement:
-	  T_ASM T_LPAREN read_until_rparn T_SEMI {
+	  T_ASM T_LPAREN read_until_rparen T_SEMI {
 		setasm();
 	  }
-	| T_ASM T_QUAL T_LPAREN read_until_rparn T_SEMI {
+	| T_ASM T_QUAL T_LPAREN read_until_rparen T_SEMI {
 		setasm();
 	  }
 	| T_ASM error
 	;
 
-read_until_rparn:
+read_until_rparen:
 	  /* empty */ {
 		ignore_up_to_rparen();
 	  }



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

2021-03-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Mar 16 23:39:41 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: msg_031.c msg_031.exp msg_151.c
msg_151.exp msg_152.c msg_152.exp msg_154.c msg_154.exp msg_157.c
msg_157.exp msg_158.c msg_158.exp

Log Message:
tests/lint: add tests for a few more messages


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_031.c
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_031.exp \
src/tests/usr.bin/xlint/lint1/msg_151.c \
src/tests/usr.bin/xlint/lint1/msg_152.c \
src/tests/usr.bin/xlint/lint1/msg_154.c \
src/tests/usr.bin/xlint/lint1/msg_157.c \
src/tests/usr.bin/xlint/lint1/msg_158.c
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_151.exp \
src/tests/usr.bin/xlint/lint1/msg_152.exp \
src/tests/usr.bin/xlint/lint1/msg_154.exp \
src/tests/usr.bin/xlint/lint1/msg_157.exp \
src/tests/usr.bin/xlint/lint1/msg_158.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_031.c
diff -u src/tests/usr.bin/xlint/lint1/msg_031.c:1.3 src/tests/usr.bin/xlint/lint1/msg_031.c:1.4
--- src/tests/usr.bin/xlint/lint1/msg_031.c:1.3	Sun Jan 31 11:12:07 2021
+++ src/tests/usr.bin/xlint/lint1/msg_031.c	Tue Mar 16 23:39:41 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_031.c,v 1.3 2021/01/31 11:12:07 rillig Exp $	*/
+/*	$NetBSD: msg_031.c,v 1.4 2021/03/16 23:39:41 rillig Exp $	*/
 # 3 "msg_031.c"
 
 // Test for message: incomplete structure or union %s: %s [31]
@@ -13,3 +13,6 @@ struct incomplete;			/* expect: 233 */
 struct complete complete_var;
 
 struct incomplete incomplete_var;	/* expect: 31 */
+
+/* XXX: the 'incomplete: ' in the diagnostic looks strange */
+void function(struct incomplete);	/* expect: incomplete:  [31] */

Index: src/tests/usr.bin/xlint/lint1/msg_031.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_031.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_031.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_031.exp:1.2	Sun Jan  3 15:35:00 2021
+++ src/tests/usr.bin/xlint/lint1/msg_031.exp	Tue Mar 16 23:39:41 2021
@@ -1,2 +1,3 @@
+msg_031.c(18): incomplete structure or union incomplete:  [31]
 msg_031.c(10): warning: struct incomplete never defined [233]
 msg_031.c(15): incomplete structure or union incomplete: incomplete_var [31]
Index: src/tests/usr.bin/xlint/lint1/msg_151.c
diff -u src/tests/usr.bin/xlint/lint1/msg_151.c:1.2 src/tests/usr.bin/xlint/lint1/msg_151.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_151.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_151.c	Tue Mar 16 23:39:41 2021
@@ -1,7 +1,13 @@
-/*	$NetBSD: msg_151.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_151.c,v 1.3 2021/03/16 23:39:41 rillig Exp $	*/
 # 3 "msg_151.c"
 
 // Test for message: void expressions may not be arguments, arg #%d [151]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+void sink_int(int);
+
+void
+example(int i)
+{
+	sink_int((void)i);	/* expect: 151 */
+	sink_int(i);
+}
Index: src/tests/usr.bin/xlint/lint1/msg_152.c
diff -u src/tests/usr.bin/xlint/lint1/msg_152.c:1.2 src/tests/usr.bin/xlint/lint1/msg_152.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_152.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_152.c	Tue Mar 16 23:39:41 2021
@@ -1,7 +1,15 @@
-/*	$NetBSD: msg_152.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_152.c,v 1.3 2021/03/16 23:39:41 rillig Exp $	*/
 # 3 "msg_152.c"
 
 // Test for message: argument cannot have unknown size, arg #%d [152]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+struct incomplete;			/* expect: 233 */
+
+void callee(struct incomplete);		/* expect: 31 */
+
+void
+caller(void)
+{
+	struct incomplete local_var;	/* expect: 31 */
+	callee(local_var);		/* expect: 152 */
+}
Index: src/tests/usr.bin/xlint/lint1/msg_154.c
diff -u src/tests/usr.bin/xlint/lint1/msg_154.c:1.2 src/tests/usr.bin/xlint/lint1/msg_154.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_154.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_154.c	Tue Mar 16 23:39:41 2021
@@ -1,7 +1,12 @@
-/*	$NetBSD: msg_154.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_154.c,v 1.3 2021/03/16 23:39:41 rillig Exp $	*/
 # 3 "msg_154.c"
 
 // Test for message: illegal combination of %s (%s) and %s (%s), arg #%d [154]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+void sink_int(int);
+
+void
+example(int *ptr)
+{
+	sink_int(ptr);		/* expect: 154 */
+}
Index: src/tests/usr.bin/xlint/lint1/msg_157.c
diff -u src/tests/usr.bin/xlint/lint1/msg_157.c:1.2 

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

2021-03-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Mar 16 23:18:49 UTC 2021

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

Log Message:
tests/lint: add test for message 139 about division by zero


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_139.c
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_139.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_139.c
diff -u src/tests/usr.bin/xlint/lint1/msg_139.c:1.2 src/tests/usr.bin/xlint/lint1/msg_139.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_139.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_139.c	Tue Mar 16 23:18:49 2021
@@ -1,7 +1,24 @@
-/*	$NetBSD: msg_139.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_139.c,v 1.3 2021/03/16 23:18:49 rillig Exp $	*/
 # 3 "msg_139.c"
 
 // Test for message: division by 0 [139]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+void sink_int(int);
+void sink_double(double);
+
+void
+example(int i)
+{
+	enum {
+		zero = 0
+	};
+
+	sink_int(i / 0);	/* only triggers in constant expressions */
+	sink_int(i / zero);	/* only triggers in constant expressions */
+	sink_double(i / 0.0);
+
+	sink_int(13 / 0);	/* expect: 139 */
+	sink_int(13 / zero);	/* expect: 139 */
+	sink_double(13 / 0.0);	/* expect: 139 *//* XXX: Clang doesn't warn */
+	sink_double(13 / -0.0);	/* expect: 139 *//* XXX: Clang doesn't warn */
+}

Index: src/tests/usr.bin/xlint/lint1/msg_139.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_139.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_139.exp:1.2
--- src/tests/usr.bin/xlint/lint1/msg_139.exp:1.1	Sat Jan  2 10:22:43 2021
+++ src/tests/usr.bin/xlint/lint1/msg_139.exp	Tue Mar 16 23:18:49 2021
@@ -1 +1,4 @@
-msg_139.c(6): syntax error ':' [249]
+msg_139.c(20): division by 0 [139]
+msg_139.c(21): division by 0 [139]
+msg_139.c(22): division by 0 [139]
+msg_139.c(23): division by 0 [139]



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

2021-03-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Mar 16 23:12:30 UTC 2021

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

Log Message:
tests/lint: add test for message 128 about incompatible pointers


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_128.c
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_128.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_128.c
diff -u src/tests/usr.bin/xlint/lint1/msg_128.c:1.2 src/tests/usr.bin/xlint/lint1/msg_128.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_128.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_128.c	Tue Mar 16 23:12:30 2021
@@ -1,7 +1,11 @@
-/*	$NetBSD: msg_128.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_128.c,v 1.3 2021/03/16 23:12:30 rillig Exp $	*/
 # 3 "msg_128.c"
 
 // Test for message: operands have incompatible pointer types, op %s (%s != %s) [128]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+void
+conversion_to_unconst(const char *cstr)
+{
+	char *str;
+	str = cstr;		/* expect: 128 */
+}

Index: src/tests/usr.bin/xlint/lint1/msg_128.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_128.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_128.exp:1.2
--- src/tests/usr.bin/xlint/lint1/msg_128.exp:1.1	Sat Jan  2 10:22:43 2021
+++ src/tests/usr.bin/xlint/lint1/msg_128.exp	Tue Mar 16 23:12:30 2021
@@ -1 +1 @@
-msg_128.c(6): syntax error ':' [249]
+msg_128.c(10): warning: operands have incompatible pointer types, op = (char != const char) [128]



CVS commit: src/sys/arch/sparc64/doc

2021-03-16 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Tue Mar 16 20:11:30 UTC 2021

Modified Files:
src/sys/arch/sparc64/doc: TODO

Log Message:
sun4v: update TODO - update status after hacking on ldom virtual network 
interfaces


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/sparc64/doc/TODO

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/sparc64/doc/TODO
diff -u src/sys/arch/sparc64/doc/TODO:1.37 src/sys/arch/sparc64/doc/TODO:1.38
--- src/sys/arch/sparc64/doc/TODO:1.37	Thu Mar  4 20:00:51 2021
+++ src/sys/arch/sparc64/doc/TODO	Tue Mar 16 20:11:30 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: TODO,v 1.37 2021/03/04 20:00:51 palle Exp $ */
+/* $NetBSD: TODO,v 1.38 2021/03/16 20:11:30 palle Exp $ */
 
 Things to be done:
 
@@ -13,11 +13,12 @@ sun4u:
 sun4v:
  - current status
  T5 ldom with 2 VCPU and 4GB:
-   The kernel boots and starts userland when booting miniroot.fs.
-   The sysinst tool starts properly and is functional.
-	   Installation is not possible, since no driver currently exists
-	   for the ldom network interfaces, but openbsd vnet and vsw drivers are
-	   possible to integrate and this work is progressing.
+   - kernel boots from miniroot.fs via ldom fisk (vdsk)
+	   - ldom virtual network interface (vnet) is working
+	 (verified by exiting sysinst and issuing a ping command)
+	   - the sysinst tool starts, disk setup is working,
+	 but the process crashes when selecting network installtion method
+		 (probably due to trashing of user proces registers)
 	 T2000 ldom with 8 VCPU and 4GB:
 	   On this platform it crashes in /sbin/init doing an access() call where %o0 is corrupted (zero)
 - idle handling - call hypervisor trap (openbsd code...??)	   



CVS commit: src/usr.bin/make

2021-03-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Mar 16 16:21:27 UTC 2021

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

Log Message:
make: fix documentation for ModChain

The outer ModChain can be interrupted by an inner ModChain, but it
continues to exist.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.891 -r1.892 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.891 src/usr.bin/make/var.c:1.892
--- src/usr.bin/make/var.c:1.891	Mon Mar 15 20:00:50 2021
+++ src/usr.bin/make/var.c	Tue Mar 16 16:21:27 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.891 2021/03/15 20:00:50 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.892 2021/03/16 16:21:27 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.891 2021/03/15 20:00:50 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.892 2021/03/16 16:21:27 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -2062,17 +2062,22 @@ typedef struct Expr {
  * The status of applying a chain of modifiers to an expression.
  *
  * The modifiers of an expression are broken into chains of modifiers,
- * starting a new chain whenever an indirect modifier starts or ends.
+ * starting a new nested chain whenever an indirect modifier starts.  There
+ * are at most 2 nesting levels: the outer one for the direct modifiers, and
+ * the inner one for the indirect modifiers.
  *
- * For example, the expression ${VAR:M*:${IND1}:${IND2}:O:u} has 4 chains of
+ * For example, the expression ${VAR:M*:${IND1}:${IND2}:O:u} has 3 chains of
  * modifiers:
  *
- *	Chain 1 is ':M*', consisting of the single modifier ':M*'.
- *	Chain 2 is all modifiers from the value of the variable named 'IND1'.
- *	Chain 3 is all modifiers from the value of the variable named 'IND2'.
- *	Chain 4 is ':O:u', consisting of the 2 modifiers ':O' and ':u'.
+ *	Chain 1 starts with the single modifier ':M*'.
+ *	  Chain 2 starts with all modifiers from ${IND1}.
+ *	  Chain 2 ends at the ':' between ${IND1} and ${IND2}.
+ *	  Chain 3 starts with all modifiers from ${IND1}.
+ *	  Chain 2 ends at the ':' after ${IND2}.
+ *	Chain 1 continues with the the 2 modifiers ':O' and ':u'.
+ *	Chain 1 ends at the final '}' of the expression.
  *
- * After such a chain has finished, its properties no longer have any effect.
+ * After such a chain ends, its properties no longer have any effect.
  *
  * It may or may not have been intended that 'defined' has scope Expr while
  * 'sep' and 'oneBigWord' have smaller scope.



CVS commit: src/sys/arch/evbppc/explora/dev

2021-03-16 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Mar 16 08:16:53 UTC 2021

Modified Files:
src/sys/arch/evbppc/explora/dev: com_elb.c

Log Message:
Style. No binary changes.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/evbppc/explora/dev/com_elb.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/evbppc/explora/dev/com_elb.c
diff -u src/sys/arch/evbppc/explora/dev/com_elb.c:1.11 src/sys/arch/evbppc/explora/dev/com_elb.c:1.12
--- src/sys/arch/evbppc/explora/dev/com_elb.c:1.11	Tue Mar  2 12:01:02 2021
+++ src/sys/arch/evbppc/explora/dev/com_elb.c	Tue Mar 16 08:16:53 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: com_elb.c,v 1.11 2021/03/02 12:01:02 rin Exp $	*/
+/*	$NetBSD: com_elb.c,v 1.12 2021/03/16 08:16:53 rin Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: com_elb.c,v 1.11 2021/03/02 12:01:02 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: com_elb.c,v 1.12 2021/03/16 08:16:53 rin Exp $");
 
 #include 
 #include 
@@ -59,12 +59,12 @@ CFATTACH_DECL_NEW(com_elb, sizeof(struct
 int
 com_elb_probe(device_t parent, cfdata_t cf, void *aux)
 {
-	struct elb_attach_args *oaa = aux;
+	struct elb_attach_args *eaa = aux;
 
-	if (strcmp(oaa->elb_name, cf->cf_name) != 0)
+	if (strcmp(eaa->elb_name, cf->cf_name) != 0)
 		return 0;
 
-	return (1);
+	return 1;
 }
 
 void



CVS commit: src/sys/arch/mips/mips

2021-03-16 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Tue Mar 16 07:34:44 UTC 2021

Modified Files:
src/sys/arch/mips/mips: db_disasm.c

Log Message:
Disassemble TEQ correctly.

XXX: May be others that use this format?


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/mips/mips/db_disasm.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/mips/mips/db_disasm.c
diff -u src/sys/arch/mips/mips/db_disasm.c:1.33 src/sys/arch/mips/mips/db_disasm.c:1.34
--- src/sys/arch/mips/mips/db_disasm.c:1.33	Mon Aug 17 03:14:08 2020
+++ src/sys/arch/mips/mips/db_disasm.c	Tue Mar 16 07:34:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_disasm.c,v 1.33 2020/08/17 03:14:08 mrg Exp $	*/
+/*	$NetBSD: db_disasm.c,v 1.34 2021/03/16 07:34:44 simonb Exp $	*/
 
 /*-
  * Copyright (c) 1991, 1993
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.33 2020/08/17 03:14:08 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.34 2021/03/16 07:34:44 simonb Exp $");
 
 #include 
 #include 
@@ -365,6 +365,13 @@ db_disasm_insn(int insn, db_addr_t loc, 
 			db_printf("\t%d", (i.RType.rs << 5) | i.RType.rt);
 			break;
 
+		case OP_TEQ:
+			db_printf("\t%s,%s,%#x",
+			reg_name[i.RType.rs],
+			reg_name[i.RType.rt],
+			(i.RType.rd << 5) | i.RType.shamt);
+			break;
+
 		default:
 			db_printf("\t%s,%s,%s",
 			reg_name[i.RType.rd],



CVS commit: src/sys/net

2021-03-16 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Tue Mar 16 07:00:38 UTC 2021

Modified Files:
src/sys/net: if_l2tp.h

Log Message:
Fix l2tp(4) ioctl type. Pointed out by yamaguchi@n.o, thanks.

XXX pullup-[89]


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/net/if_l2tp.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/net/if_l2tp.h
diff -u src/sys/net/if_l2tp.h:1.9 src/sys/net/if_l2tp.h:1.10
--- src/sys/net/if_l2tp.h:1.9	Sat Feb  1 02:58:05 2020
+++ src/sys/net/if_l2tp.h	Tue Mar 16 07:00:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_l2tp.h,v 1.9 2020/02/01 02:58:05 riastradh Exp $	*/
+/*	$NetBSD: if_l2tp.h,v 1.10 2021/03/16 07:00:38 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -44,11 +44,11 @@
 #include 
 #include 
 
-#define	SIOCSL2TPSESSION	_IOW('i', 151, struct l2tp_req)
-#define	SIOCDL2TPSESSION	_IOW('i', 152, struct l2tp_req)
-#define	SIOCSL2TPCOOKIE		_IOW('i', 153, struct l2tp_req)
-#define	SIOCDL2TPCOOKIE		_IOW('i', 154, struct l2tp_req)
-#define	SIOCSL2TPSTATE		_IOW('i', 155, struct l2tp_req)
+#define	SIOCSL2TPSESSION	_IOW('i', 151, struct ifreq)
+#define	SIOCDL2TPSESSION	_IOW('i', 152, struct ifreq)
+#define	SIOCSL2TPCOOKIE		_IOW('i', 153, struct ifreq)
+#define	SIOCDL2TPCOOKIE		_IOW('i', 154, struct ifreq)
+#define	SIOCSL2TPSTATE		_IOW('i', 155, struct ifreq)
 #define	SIOCGL2TP		SIOCGIFGENERIC
 
 struct l2tp_req {