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

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

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

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


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

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

Modified files:

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



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

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

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

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


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

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

Modified files:

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

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

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

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

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


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

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

Modified files:

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

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



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

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

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

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


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

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

Modified files:

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



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

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

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

Log Message:
tests/lint: remove unintended debugging output


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

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

Modified files:

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



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

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

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

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


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

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

Modified files:

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



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

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

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

Log Message:
tests/lint: correct interpretation of NOTREACHED

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


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

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

Modified files:

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



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

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

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

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

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


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

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

Modified files:

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



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

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

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

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


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

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

Modified files:

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



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

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

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

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

Seen in libdes/ostr2key.c(81).


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

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

Modified files:

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

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



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

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

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

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


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

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

Modified files:

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



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

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

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

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

Seen in pam_chroot.c:60.


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

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

Modified files:

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



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

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

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

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

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

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

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


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

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

Modified files:

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

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



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

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

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

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

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


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

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

Modified files:

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



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

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

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

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


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

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

Modified files:

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

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



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

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

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

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


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

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

Modified files:

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

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



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

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

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

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


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

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

Modified files:

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

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

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

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

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

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


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

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

Modified files:

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



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

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

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

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


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

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

Modified files:

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

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



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

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

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

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

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

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


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

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

Modified files:

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



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

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

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

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


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

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

Modified files:

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



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

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

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

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


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

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

Modified files:

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

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

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

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

Log Message:
lint: demonstrate wrong integer conversion for __uint128_t


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

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

Modified files:

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



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

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

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

Log Message:
tests/lint: document why lint does not check _Generic selections


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

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/c11_generic_expression.c
diff -u src/tests/usr.bin/xlint/lint1/c11_generic_expression.c:1.8 src/tests/usr.bin/xlint/lint1/c11_generic_expression.c:1.9
--- src/tests/usr.bin/xlint/lint1/c11_generic_expression.c:1.8	Sun Jul 11 20:37:21 2021
+++ src/tests/usr.bin/xlint/lint1/c11_generic_expression.c	Sun Aug  1 13:09:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: c11_generic_expression.c,v 1.8 2021/07/11 20:37:21 rillig Exp $	*/
+/*	$NetBSD: c11_generic_expression.c,v 1.9 2021/08/01 13:09:38 rillig Exp $	*/
 # 3 "c11_generic_expression.c"
 
 /*
@@ -94,3 +94,13 @@ primary_expression(void)
 {
 	return _Generic(0, int: assignment_expression)(0, 0);
 }
+
+/*
+ * The types don't match, therefore build_generic_selection returns NULL,
+ * which is then silently ignored by init_expr.  This situation is already
+ * covered by the compilers, so there is no need for lint to double-check it.
+ */
+const char *x = _Generic(
+(__uint128_t)1 + 1.0f,
+int: 1
+);



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

2021-07-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jul 31 10:09:03 UTC 2021

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

Log Message:
tests/lint: demonstrate more wrong warnings for const struct members

The code 't_const = false' occurs 4 times in the lint code, each
corresponding to one of the wrong warnings in the test.

This bug has been existing at least since 2001.  Back then, the lint
output was:

2001.12.24.20.52.09
| (23): lint error: popctrl() 1
| (15): syntax error [249]
| (19): warning: left operand of 'FARG' must be modifiable lvalue [115]
| (21): syntax error [249]
| (23): warning: function initialize_const_struct_member falls off bottom 
without returning value [217]
| exit status 1

from 2002.12.06.03.27.39
| (23): lint error: func.c, 168: popctrl()
| (15): warning: left operand of '=' must be modifiable lvalue [115]
| (19): warning: left operand of 'FARG' must be modifiable lvalue [115]
| (21): syntax error [249]
| (23): warning: function initialize_const_struct_member falls off bottom 
without returning value [217]
| exit status 1
until 2003.10.27.00.12.44


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

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_115.c
diff -u src/tests/usr.bin/xlint/lint1/msg_115.c:1.5 src/tests/usr.bin/xlint/lint1/msg_115.c:1.6
--- src/tests/usr.bin/xlint/lint1/msg_115.c:1.5	Sat Jul 31 09:14:47 2021
+++ src/tests/usr.bin/xlint/lint1/msg_115.c	Sat Jul 31 10:09:03 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_115.c,v 1.5 2021/07/31 09:14:47 rillig Exp $	*/
+/*	$NetBSD: msg_115.c,v 1.6 2021/07/31 10:09:03 rillig Exp $	*/
 # 3 "msg_115.c"
 
 // Test for message: %soperand of '%s' must be modifiable lvalue [115]
@@ -16,20 +16,35 @@ example(const int *const_ptr)
 	(*const_ptr)++;		/* expect: 115 */
 }
 
-void
+typedef struct {
+	int const member;
+} const_member;
+
+void take_const_member(const_member);
+
+/* see typeok_assign, has_constant_member */
+const_member
 initialize_const_struct_member(void)
 {
-	struct S {
-		int const member;
-	};
-
 	/* FIXME: In an initialization, const members can be assigned. */
 	/* expect+1: warning: left operand of '=' must be modifiable lvalue [115] */
-	struct S s1 = (struct S) { 12345 };
-	if (s1.member != 0)
-		return;
-
-	struct S s2 = { 12345 };
-	if (s2.member != 0)
-		return;
+	const_member cm1 = (const_member) { 12345 };
+	if (cm1.member != 0)
+		/* FIXME: In a function call, const members can be assigned. */
+		/* expect+1: warning: left operand of 'farg' must be modifiable lvalue [115] */
+		take_const_member(cm1);
+
+	struct {
+		const_member member;
+	} cm2 = {
+	/* FIXME: In an initialization, const members can be assigned. */
+	/* expect+1: warning: left operand of 'init' must be modifiable lvalue [115] */
+	cm1,
+	};
+	if (cm2.member.member != 0) {
+	}
+
+	/* FIXME: In a return statement, const members can be assigned. */
+	/* expect+1: warning: left operand of 'return' must be modifiable lvalue [115] */
+	return cm1;
 }

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



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

2021-07-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jul 31 09:14:47 UTC 2021

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

Log Message:
tests/lint: demonstrate wrong error message for initialization

Seen in usr.bin/make/var.c:4022 in C99 mode, where a ModChain variable
is initialized and two of the members are const-qualified.


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

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_115.c
diff -u src/tests/usr.bin/xlint/lint1/msg_115.c:1.4 src/tests/usr.bin/xlint/lint1/msg_115.c:1.5
--- src/tests/usr.bin/xlint/lint1/msg_115.c:1.4	Sun Jan 31 11:12:07 2021
+++ src/tests/usr.bin/xlint/lint1/msg_115.c	Sat Jul 31 09:14:47 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_115.c,v 1.4 2021/01/31 11:12:07 rillig Exp $	*/
+/*	$NetBSD: msg_115.c,v 1.5 2021/07/31 09:14:47 rillig Exp $	*/
 # 3 "msg_115.c"
 
 // Test for message: %soperand of '%s' must be modifiable lvalue [115]
@@ -15,3 +15,21 @@ example(const int *const_ptr)
 	*const_ptr %= 9;	/* expect: 115 */
 	(*const_ptr)++;		/* expect: 115 */
 }
+
+void
+initialize_const_struct_member(void)
+{
+	struct S {
+		int const member;
+	};
+
+	/* FIXME: In an initialization, const members can be assigned. */
+	/* expect+1: warning: left operand of '=' must be modifiable lvalue [115] */
+	struct S s1 = (struct S) { 12345 };
+	if (s1.member != 0)
+		return;
+
+	struct S s2 = { 12345 };
+	if (s2.member != 0)
+		return;
+}

Index: src/tests/usr.bin/xlint/lint1/msg_115.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_115.exp:1.3 src/tests/usr.bin/xlint/lint1/msg_115.exp:1.4
--- src/tests/usr.bin/xlint/lint1/msg_115.exp:1.3	Sun Jan 17 16:19:54 2021
+++ src/tests/usr.bin/xlint/lint1/msg_115.exp	Sat Jul 31 09:14:47 2021
@@ -5,3 +5,4 @@ msg_115.c(13): warning: left operand of 
 msg_115.c(14): warning: left operand of '/=' must be modifiable lvalue [115]
 msg_115.c(15): warning: left operand of '%=' must be modifiable lvalue [115]
 msg_115.c(16): warning: operand of 'x++' must be modifiable lvalue [115]
+msg_115.c(28): warning: left operand of '=' must be modifiable lvalue [115]



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

2021-07-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jul 26 18:06:43 UTC 2021

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

Log Message:
tests/lint: show bug in conditional expression (since 2021-07-15)

Since cgram.y 1.325 from 2021-07-15, conditional expressions did not
accept a comma-expression in the then-branch anymore.  In practice, this
is an edge case though since comma expressions are rare.


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

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/expr_precedence.c
diff -u src/tests/usr.bin/xlint/lint1/expr_precedence.c:1.5 src/tests/usr.bin/xlint/lint1/expr_precedence.c:1.6
--- src/tests/usr.bin/xlint/lint1/expr_precedence.c:1.5	Mon Jul 26 17:27:22 2021
+++ src/tests/usr.bin/xlint/lint1/expr_precedence.c	Mon Jul 26 18:06:43 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: expr_precedence.c,v 1.5 2021/07/26 17:27:22 rillig Exp $	*/
+/*	$NetBSD: expr_precedence.c,v 1.6 2021/07/26 18:06:43 rillig Exp $	*/
 # 3 "expr_precedence.c"
 
 /*
@@ -51,3 +51,27 @@ assignment_associativity(int arg)
 
 	left = arg;
 }
+
+void
+conditional_associativity(_Bool cond1, _Bool cond2, int a, int b, int c)
+{
+	/* The then-expression can be an arbitrary expression. */
+	var = cond1 ? cond2 ? a : b : c;
+	var = cond1 ? (cond2 ? a : b) : c;
+
+	/* The then-expression can even be a comma-expression. */
+	/* expect+1: error: syntax error ',' [249] *//* FIXME */
+	var = cond1 ? cond2 ? a, b : (b, a) : c;
+
+	var = cond1 ? a : cond2 ? b : c;
+	/*
+	 * In almost all programming languages, '?:' is right-associative,
+	 * which allows for easy chaining.
+	 */
+	var = cond1 ? a : (cond2 ? b : c);
+	/*
+	 * In PHP, '?:' is left-associative, which is rather surprising and
+	 * requires more parentheses to get the desired effect.
+	 */
+	var = (cond1 ? a : cond2) ? b : c;
+}
Index: src/tests/usr.bin/xlint/lint1/expr_precedence.exp
diff -u src/tests/usr.bin/xlint/lint1/expr_precedence.exp:1.5 src/tests/usr.bin/xlint/lint1/expr_precedence.exp:1.6
--- src/tests/usr.bin/xlint/lint1/expr_precedence.exp:1.5	Mon Jul 26 17:27:22 2021
+++ src/tests/usr.bin/xlint/lint1/expr_precedence.exp	Mon Jul 26 18:06:43 2021
@@ -2,3 +2,4 @@ expr_precedence.c(15): error: syntax err
 expr_precedence.c(18): error: non-constant initializer [177]
 expr_precedence.c(35): error: 'var' undefined [99]
 expr_precedence.c(35): error: syntax error '=' [249]
+expr_precedence.c(64): error: syntax error ',' [249]



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

2021-07-26 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jul 26 17:09:46 UTC 2021

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

Log Message:
tests/lint: demonstrate bug in chained assignment (since 2021-07-15)

Since cgram.y 1.325 from 2021-07-15, lint has been parsing assignment
expressions correctly.  It got the associativity wrong.


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

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/expr_precedence.c
diff -u src/tests/usr.bin/xlint/lint1/expr_precedence.c:1.3 src/tests/usr.bin/xlint/lint1/expr_precedence.c:1.4
--- src/tests/usr.bin/xlint/lint1/expr_precedence.c:1.3	Thu Jul 15 17:48:10 2021
+++ src/tests/usr.bin/xlint/lint1/expr_precedence.c	Mon Jul 26 17:09:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: expr_precedence.c,v 1.3 2021/07/15 17:48:10 rillig Exp $	*/
+/*	$NetBSD: expr_precedence.c,v 1.4 2021/07/26 17:09:46 rillig Exp $	*/
 # 3 "expr_precedence.c"
 
 /*
@@ -36,3 +36,15 @@ void __attribute__((format(printf,
 /* Syntactically ok, must be a constant expression though. */
 var > 0 ? 2 : 1)))
 my_printf(const char *, ...);
+
+void
+assignment_associativity(int arg)
+{
+	int left, right;
+
+	/* FIXME */
+	/* expect+1: error: left operand of '=' must be lvalue [114] */
+	left = right = arg;
+
+	left = arg;
+}
Index: src/tests/usr.bin/xlint/lint1/expr_precedence.exp
diff -u src/tests/usr.bin/xlint/lint1/expr_precedence.exp:1.3 src/tests/usr.bin/xlint/lint1/expr_precedence.exp:1.4
--- src/tests/usr.bin/xlint/lint1/expr_precedence.exp:1.3	Thu Jul 15 17:48:10 2021
+++ src/tests/usr.bin/xlint/lint1/expr_precedence.exp	Mon Jul 26 17:09:46 2021
@@ -2,3 +2,4 @@ expr_precedence.c(15): error: syntax err
 expr_precedence.c(18): error: non-constant initializer [177]
 expr_precedence.c(35): error: 'var' undefined [99]
 expr_precedence.c(35): error: syntax error '=' [249]
+expr_precedence.c(47): error: left operand of '=' must be lvalue [114]



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

2021-07-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 25 22:31:22 UTC 2021

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

Log Message:
tests/lint: cover code in ckctype.c


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_342.c \
src/tests/usr.bin/xlint/lint1/msg_342.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_342.c
diff -u src/tests/usr.bin/xlint/lint1/msg_342.c:1.1 src/tests/usr.bin/xlint/lint1/msg_342.c:1.2
--- src/tests/usr.bin/xlint/lint1/msg_342.c:1.1	Mon Apr  5 02:05:47 2021
+++ src/tests/usr.bin/xlint/lint1/msg_342.c	Sun Jul 25 22:31:22 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_342.c,v 1.1 2021/04/05 02:05:47 rillig Exp $	*/
+/*	$NetBSD: msg_342.c,v 1.2 2021/07/25 22:31:22 rillig Exp $	*/
 # 3 "msg_341.c"
 
 // Test for message: argument to '%s' must be cast to 'unsigned char', not to '%s' [342]
@@ -12,11 +12,57 @@
 extern const unsigned short *_ctype_tab_;
 extern const short *_tolower_tab_;
 extern const short *_toupper_tab_;
+int isalnum(int);
+int isalpha(int);
+int isblank(int);
+int iscntrl(int);
+int isdigit(int);
+int isgraph(int);
+int islower(int);
+int isprint(int);
+int ispunct(int);
 int isspace(int);
+int isupper(int);
+int isxdigit(int);
+int tolower(int);
+int toupper(int);
 
 void sink(int);
 
 void
+cover_is_ctype_function(char c)
+{
+	/* expect+1: warning: argument to 'isalnum' must be 'unsigned char' or EOF, not 'char' [341] */
+	isalnum(c);
+	/* expect+1: warning: argument to 'isalpha' must be 'unsigned char' or EOF, not 'char' [341] */
+	isalpha(c);
+	/* expect+1: warning: argument to 'isblank' must be 'unsigned char' or EOF, not 'char' [341] */
+	isblank(c);
+	/* expect+1: warning: argument to 'iscntrl' must be 'unsigned char' or EOF, not 'char' [341] */
+	iscntrl(c);
+	/* expect+1: warning: argument to 'isdigit' must be 'unsigned char' or EOF, not 'char' [341] */
+	isdigit(c);
+	/* expect+1: warning: argument to 'isgraph' must be 'unsigned char' or EOF, not 'char' [341] */
+	isgraph(c);
+	/* expect+1: warning: argument to 'islower' must be 'unsigned char' or EOF, not 'char' [341] */
+	islower(c);
+	/* expect+1: warning: argument to 'isprint' must be 'unsigned char' or EOF, not 'char' [341] */
+	isprint(c);
+	/* expect+1: warning: argument to 'ispunct' must be 'unsigned char' or EOF, not 'char' [341] */
+	ispunct(c);
+	/* expect+1: warning: argument to 'isspace' must be 'unsigned char' or EOF, not 'char' [341] */
+	isspace(c);
+	/* expect+1: warning: argument to 'isupper' must be 'unsigned char' or EOF, not 'char' [341] */
+	isupper(c);
+	/* expect+1: warning: argument to 'isxdigit' must be 'unsigned char' or EOF, not 'char' [341] */
+	isxdigit(c);
+	/* expect+1: warning: argument to 'tolower' must be 'unsigned char' or EOF, not 'char' [341] */
+	tolower(c);
+	/* expect+1: warning: argument to 'toupper' must be 'unsigned char' or EOF, not 'char' [341] */
+	toupper(c);
+}
+
+void
 function_call_char(char c)
 {
 
Index: src/tests/usr.bin/xlint/lint1/msg_342.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_342.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_342.exp:1.2
--- src/tests/usr.bin/xlint/lint1/msg_342.exp:1.1	Mon Apr  5 02:05:47 2021
+++ src/tests/usr.bin/xlint/lint1/msg_342.exp	Sun Jul 25 22:31:22 2021
@@ -1,6 +1,20 @@
-msg_341.c(24): warning: argument to 'isspace' must be 'unsigned char' or EOF, not 'char' [341]
-msg_341.c(33): warning: argument to 'isspace' must be cast to 'unsigned char', not to 'int' [342]
-msg_341.c(36): warning: argument to 'isspace' must be cast to 'unsigned char', not to 'unsigned int' [342]
-msg_341.c(67): warning: argument to 'function from ' must be 'unsigned char' or EOF, not 'char' [341]
-msg_341.c(73): warning: argument to 'function from ' must be cast to 'unsigned char', not to 'int' [342]
-msg_341.c(76): warning: argument to 'function from ' must be cast to 'unsigned char', not to 'unsigned int' [342]
+msg_341.c(36): warning: argument to 'isalnum' must be 'unsigned char' or EOF, not 'char' [341]
+msg_341.c(38): warning: argument to 'isalpha' must be 'unsigned char' or EOF, not 'char' [341]
+msg_341.c(40): warning: argument to 'isblank' must be 'unsigned char' or EOF, not 'char' [341]
+msg_341.c(42): warning: argument to 'iscntrl' must be 'unsigned char' or EOF, not 'char' [341]
+msg_341.c(44): warning: argument to 'isdigit' must be 'unsigned char' or EOF, not 'char' [341]
+msg_341.c(46): warning: argument to 'isgraph' must be 'unsigned char' or EOF, not 'char' [341]
+msg_341.c(48): warning: argument to 'islower' must be 'unsigned char' or EOF, not 'char' [341]
+msg_341.c(50): warning: argument to 'isprint' must be 'unsigned char' or EOF, not 'char' [341]
+msg_341.c(52): warning: argument to 'ispunct' must be 'unsigned char' or EOF, not 'char' [341]
+msg_341.c(54): warning: argument to 'isspace' must be 'unsigned char' or EOF, 

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

2021-07-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 25 19:41:33 UTC 2021

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

Log Message:
tests/lint: explain where the second __attribute__ comes from


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/parse_type_name.c \
src/tests/usr.bin/xlint/lint1/parse_type_name.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/parse_type_name.c
diff -u src/tests/usr.bin/xlint/lint1/parse_type_name.c:1.5 src/tests/usr.bin/xlint/lint1/parse_type_name.c:1.6
--- src/tests/usr.bin/xlint/lint1/parse_type_name.c:1.5	Sun Jul 25 19:22:08 2021
+++ src/tests/usr.bin/xlint/lint1/parse_type_name.c	Sun Jul 25 19:41:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse_type_name.c,v 1.5 2021/07/25 19:22:08 rillig Exp $	*/
+/*	$NetBSD: parse_type_name.c,v 1.6 2021/07/25 19:41:33 rillig Exp $	*/
 # 3 "parse_type_name.c"
 
 /*
@@ -101,16 +101,15 @@ cover_abstract_decl_param_list(void)
 	sink(sizeof(void (*)() __attribute__((;
 	/*
 	 * XXX: The grammar allows only a single type_attribute_opt.
-	 * Where does the second type_attribute go?
+	 * All following __attribute__ come from direct_abstract_declarator.
 	 */
-	sink(sizeof(
-	void (*)() __attribute__(()) __attribute__((;
+	sink(sizeof(void (*)() __attribute__(()) __attribute__((;
 
 	/* cover 'abstract_decl_lparen vararg_parameter_type_list T_RPAREN type_attribute_opt' */
 	sink(sizeof(void (*)(void) __attribute__((;
 	/*
 	 * XXX: The grammar allows only a single type_attribute_opt.
-	 * Where does the second type_attribute go?
+	 * All following __attribute__ come from direct_abstract_declarator.
 	 */
 	sink(sizeof(void (*)(void) __attribute__(()) __attribute__((;
 
@@ -121,7 +120,7 @@ cover_abstract_decl_param_list(void)
 	sink(sizeof(void (*)(goto) __attribute__((;
 	/*
 	 * XXX: The grammar allows only a single type_attribute_opt.
-	 * Where does the second type_attribute go?
+	 * All following __attribute__ come from direct_abstract_declarator.
 	 */
 	/* expect+1: syntax error 'goto' [249] */
 	sink(sizeof(void (*)(goto) __attribute__(()) __attribute__((;
Index: src/tests/usr.bin/xlint/lint1/parse_type_name.exp
diff -u src/tests/usr.bin/xlint/lint1/parse_type_name.exp:1.5 src/tests/usr.bin/xlint/lint1/parse_type_name.exp:1.6
--- src/tests/usr.bin/xlint/lint1/parse_type_name.exp:1.5	Sun Jul 25 19:22:08 2021
+++ src/tests/usr.bin/xlint/lint1/parse_type_name.exp	Sun Jul 25 19:41:33 2021
@@ -1,7 +1,7 @@
 parse_type_name.c(52): error: cannot take size/alignment of function [144]
 parse_type_name.c(72): error: null dimension [17]
 parse_type_name.c(76): error: null dimension [17]
-parse_type_name.c(119): error: syntax error 'goto' [249]
-parse_type_name.c(121): error: syntax error 'goto' [249]
-parse_type_name.c(127): error: syntax error 'goto' [249]
-parse_type_name.c(141): warning: ANSI C requires formal parameter before '...' [84]
+parse_type_name.c(118): error: syntax error 'goto' [249]
+parse_type_name.c(120): error: syntax error 'goto' [249]
+parse_type_name.c(126): error: syntax error 'goto' [249]
+parse_type_name.c(140): warning: ANSI C requires formal parameter before '...' [84]



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

2021-07-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 25 19:22:08 UTC 2021

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

Log Message:
tests/lint: fix unintended line breaks


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/parse_type_name.c \
src/tests/usr.bin/xlint/lint1/parse_type_name.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/parse_type_name.c
diff -u src/tests/usr.bin/xlint/lint1/parse_type_name.c:1.4 src/tests/usr.bin/xlint/lint1/parse_type_name.c:1.5
--- src/tests/usr.bin/xlint/lint1/parse_type_name.c:1.4	Sun Jul 25 15:48:58 2021
+++ src/tests/usr.bin/xlint/lint1/parse_type_name.c	Sun Jul 25 19:22:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse_type_name.c,v 1.4 2021/07/25 15:48:58 rillig Exp $	*/
+/*	$NetBSD: parse_type_name.c,v 1.5 2021/07/25 19:22:08 rillig Exp $	*/
 # 3 "parse_type_name.c"
 
 /*
@@ -80,29 +80,17 @@ cover_direct_abstract_declarator(void)
 
 	/* cover 'abstract_decl_param_list asm_or_symbolrename_opt' */
 	sink(sizeof(int(double)));
-	sink(sizeof(
-	int(
-	double) __asm("anything")));
-	sink(sizeof(
-	int(
-	double) __symbolrename(alias)));
+	sink(sizeof(int(double) __asm("anything")));
+	sink(sizeof(int(double) __symbolrename(alias)));
 
 	/* cover 'direct_abstract_declarator abstract_decl_param_list asm_or_symbolrename_opt' */
 	sink(sizeof(int (*)(double)));
-	sink(sizeof(
-	int(*)(double) __asm("anything")));
-	sink(sizeof(
-	int(*)
-	(double)__symbolrename(alias)));
+	sink(sizeof(int (*)(double) __asm("anything")));
+	sink(sizeof(int (*)(double)__symbolrename(alias)));
 
 	/* cover 'direct_abstract_declarator type_attribute_list' */
-	sink(sizeof(
-	int(*)
-	__attribute__((;
-	sink(sizeof(
-	int(*)
-	__attribute__(())
-	__attribute__((;
+	sink(sizeof(int (*) __attribute__((;
+	sink(sizeof(int (*) __attribute__(()) __attribute__((;
 }
 
 void
@@ -110,32 +98,21 @@ cover_abstract_decl_param_list(void)
 {
 	/* cover 'abstract_decl_lparen T_RPAREN type_attribute_opt' */
 	sink(sizeof(void (*)()));
-	sink(sizeof(
-	void (*)
-	()
-	__attribute__((;
+	sink(sizeof(void (*)() __attribute__((;
 	/*
 	 * XXX: The grammar allows only a single type_attribute_opt.
 	 * Where does the second type_attribute go?
 	 */
 	sink(sizeof(
-	void (*)
-	()
-	__attribute__(())
-	__attribute__((;
+	void (*)() __attribute__(()) __attribute__((;
 
 	/* cover 'abstract_decl_lparen vararg_parameter_type_list T_RPAREN type_attribute_opt' */
-	sink(sizeof(
-	void (*)
-	(void)__attribute__((;
+	sink(sizeof(void (*)(void) __attribute__((;
 	/*
 	 * XXX: The grammar allows only a single type_attribute_opt.
 	 * Where does the second type_attribute go?
 	 */
-	sink(sizeof(
-	void (*)
-	(void)__attribute__(())
-	__attribute__((;
+	sink(sizeof(void (*)(void) __attribute__(()) __attribute__((;
 
 	/* cover 'abstract_decl_lparen error T_RPAREN type_attribute_opt' */
 	/* expect+1: syntax error 'goto' [249] */
@@ -193,8 +170,7 @@ cover_parameter_declaration(void)
 
 	/* cover 'begin_type_declmods end_type abstract_declarator' */
 	/* GCC 11 warns: type defaults to 'int' in type name */
-	sink(sizeof(
-	void (*)(int, const *)));
+	sink(sizeof(void (*)(int, const *)));
 
 	/* cover 'begin_type_declaration_specifiers end_type abstract_declarator' */
 	sink(sizeof(void (*)(int, double *)));
Index: src/tests/usr.bin/xlint/lint1/parse_type_name.exp
diff -u src/tests/usr.bin/xlint/lint1/parse_type_name.exp:1.4 src/tests/usr.bin/xlint/lint1/parse_type_name.exp:1.5
--- src/tests/usr.bin/xlint/lint1/parse_type_name.exp:1.4	Sun Jul 25 15:48:58 2021
+++ src/tests/usr.bin/xlint/lint1/parse_type_name.exp	Sun Jul 25 19:22:08 2021
@@ -1,7 +1,7 @@
 parse_type_name.c(52): error: cannot take size/alignment of function [144]
 parse_type_name.c(72): error: null dimension [17]
 parse_type_name.c(76): error: null dimension [17]
-parse_type_name.c(142): error: syntax error 'goto' [249]
-parse_type_name.c(144): error: syntax error 'goto' [249]
-parse_type_name.c(150): error: syntax error 'goto' [249]
-parse_type_name.c(164): warning: ANSI C requires formal parameter before '...' [84]
+parse_type_name.c(119): error: syntax error 'goto' [249]
+parse_type_name.c(121): error: syntax error 'goto' [249]
+parse_type_name.c(127): error: syntax error 'goto' [249]
+parse_type_name.c(141): warning: ANSI C requires formal parameter before '...' [84]



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

2021-07-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 25 18:34:44 UTC 2021

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

Log Message:
tests/lint: test __attribute__ with enum


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

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/gcc_attribute_enum.c
diff -u src/tests/usr.bin/xlint/lint1/gcc_attribute_enum.c:1.1 src/tests/usr.bin/xlint/lint1/gcc_attribute_enum.c:1.2
--- src/tests/usr.bin/xlint/lint1/gcc_attribute_enum.c:1.1	Tue Jul  6 17:33:07 2021
+++ src/tests/usr.bin/xlint/lint1/gcc_attribute_enum.c	Sun Jul 25 18:34:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: gcc_attribute_enum.c,v 1.1 2021/07/06 17:33:07 rillig Exp $	*/
+/*	$NetBSD: gcc_attribute_enum.c,v 1.2 2021/07/25 18:34:44 rillig Exp $	*/
 # 3 "gcc_attribute_enum.c"
 
 /*
@@ -7,16 +7,41 @@
  * https://gcc.gnu.org/onlinedocs/gcc/Enumerator-Attributes.html
  */
 
-enum Planet {
-	Mercury,
-	Venus,
-	Earth,
-	Mars,
-	Jupiter,
-	Saturn,
-	Uranus,
-	Neptune,
-	/* https://en.wikipedia.org/wiki/Pluto_(planet) */
-	/*FIXME*//* expect+1: error: syntax error '__attribute__' [249] */
-	Pluto __attribute__((__deprecated__ /* since August 2006 */))
+/*
+ * Attributes in enum-specifier.
+ *
+ * See GCC, c-parser.c, function c_parser_enum_specifier.
+ */
+
+/* expect+1: syntax error '__attribute__' [249] */
+enum __attribute__(()) tag;
+
+/* expect+2: syntax error '__attribute__' [249] */
+/* expect+1: syntax error '{' [249] */
+enum __attribute__(()) tag_with_declaration {
+	TAG_WITH_DECL
+} __attribute__(());
+/* expect-1: syntax error ';' [249] */
+
+/* expect+1: syntax error '{' [249] */
+enum __attribute__(()) {
+	ONLY_DECL
+} __attribute__(());
+/* expect-1: syntax error ';' [249] */
+/* expect-2: error: cannot recover from previous errors [224] */
+
+/*
+ * Attributes in enumerator.
+ *
+ * See GCC, c-parser.c, function c_parser_enum_specifier.
+ */
+
+enum {
+	NO_INIT_FIRST __attribute__(()),
+	NO_INIT__LAST __attribute__(())
+};
+
+enum {
+	INIT_FIRST __attribute__(()) = 1,
+	INIT__LAST __attribute__(()) = 2
 };
Index: src/tests/usr.bin/xlint/lint1/gcc_attribute_enum.exp
diff -u src/tests/usr.bin/xlint/lint1/gcc_attribute_enum.exp:1.1 src/tests/usr.bin/xlint/lint1/gcc_attribute_enum.exp:1.2
--- src/tests/usr.bin/xlint/lint1/gcc_attribute_enum.exp:1.1	Tue Jul  6 17:33:07 2021
+++ src/tests/usr.bin/xlint/lint1/gcc_attribute_enum.exp	Sun Jul 25 18:34:44 2021
@@ -1 +1,7 @@
+gcc_attribute_enum.c(17): error: syntax error '__attribute__' [249]
 gcc_attribute_enum.c(21): error: syntax error '__attribute__' [249]
+gcc_attribute_enum.c(21): error: syntax error '{' [249]
+gcc_attribute_enum.c(23): error: syntax error ';' [249]
+gcc_attribute_enum.c(27): error: syntax error '{' [249]
+gcc_attribute_enum.c(29): error: syntax error ';' [249]
+gcc_attribute_enum.c(29): error: cannot recover from previous errors [224]



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

2021-07-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 25 11:19:51 UTC 2021

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

Log Message:
tests/lint: document parse error for GCC typeof


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

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/gcc_typeof.c
diff -u src/tests/usr.bin/xlint/lint1/gcc_typeof.c:1.1 src/tests/usr.bin/xlint/lint1/gcc_typeof.c:1.2
--- src/tests/usr.bin/xlint/lint1/gcc_typeof.c:1.1	Sun Jul 25 10:57:38 2021
+++ src/tests/usr.bin/xlint/lint1/gcc_typeof.c	Sun Jul 25 11:19:51 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: gcc_typeof.c,v 1.1 2021/07/25 10:57:38 rillig Exp $	*/
+/*	$NetBSD: gcc_typeof.c,v 1.2 2021/07/25 11:19:51 rillig Exp $	*/
 # 3 "gcc_typeof.c"
 
 /*
@@ -10,6 +10,13 @@
 void take_double(typeof(0.0));
 
 void take_function_double_returning_double(
+/*
+ * FIXME: lint's grammar uses 'typeof cast_expression', while GCC's
+ *  c_parser_typeof_specifier uses 'typeof ( expression )'.  The crucial
+ *  difference is that lint parses the following expression as 'typeof
+ *  ((0.0)(typeof(0.0))', that is, it tries to call the function 0.0,
+ *  which of course is nonsense.
+ */
 typeof(0.0)(
 	/* FIXME: GCC can parse this */
 	/* expect+1: error: syntax error 'typeof' [249] */
Index: src/tests/usr.bin/xlint/lint1/gcc_typeof.exp
diff -u src/tests/usr.bin/xlint/lint1/gcc_typeof.exp:1.1 src/tests/usr.bin/xlint/lint1/gcc_typeof.exp:1.2
--- src/tests/usr.bin/xlint/lint1/gcc_typeof.exp:1.1	Sun Jul 25 10:57:38 2021
+++ src/tests/usr.bin/xlint/lint1/gcc_typeof.exp	Sun Jul 25 11:19:51 2021
@@ -1,2 +1,2 @@
-gcc_typeof.c(16): error: syntax error 'typeof' [249]
-gcc_typeof.c(26): warning: passing 'pointer to function(double) returning double' to incompatible 'double', arg #1 [155]
+gcc_typeof.c(23): error: syntax error 'typeof' [249]
+gcc_typeof.c(33): warning: passing 'pointer to function(double) returning double' to incompatible 'double', arg #1 [155]



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

2021-07-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 25 10:26:46 UTC 2021

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

Log Message:
tests/lint: test function types and pointer arithmetic


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_110.c \
src/tests/usr.bin/xlint/lint1/msg_110.exp \
src/tests/usr.bin/xlint/lint1/msg_147.c \
src/tests/usr.bin/xlint/lint1/msg_147.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_110.c
diff -u src/tests/usr.bin/xlint/lint1/msg_110.c:1.2 src/tests/usr.bin/xlint/lint1/msg_110.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_110.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_110.c	Sun Jul 25 10:26:46 2021
@@ -1,7 +1,15 @@
-/*	$NetBSD: msg_110.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_110.c,v 1.3 2021/07/25 10:26:46 rillig Exp $	*/
 # 3 "msg_110.c"
 
 // Test for message: pointer to function is not allowed here [110]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* ARGSUSED */
+void
+call_take(int (*ptr)(int))
+{
+	/* expect+1: error: pointer to function is not allowed here [110] */
+	ptr++;
+
+	/* expect+1: error: pointer to function is not allowed here [110] */
+	ptr + 1;
+}
Index: src/tests/usr.bin/xlint/lint1/msg_110.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_110.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_110.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_110.exp:1.2	Sun Mar 21 20:44:59 2021
+++ src/tests/usr.bin/xlint/lint1/msg_110.exp	Sun Jul 25 10:26:46 2021
@@ -1 +1,2 @@
-msg_110.c(6): error: syntax error ':' [249]
+msg_110.c(11): error: pointer to function is not allowed here [110]
+msg_110.c(14): error: pointer to function is not allowed here [110]
Index: src/tests/usr.bin/xlint/lint1/msg_147.c
diff -u src/tests/usr.bin/xlint/lint1/msg_147.c:1.2 src/tests/usr.bin/xlint/lint1/msg_147.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_147.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_147.c	Sun Jul 25 10:26:46 2021
@@ -1,7 +1,16 @@
-/*	$NetBSD: msg_147.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_147.c,v 1.3 2021/07/25 10:26:46 rillig Exp $	*/
 # 3 "msg_147.c"
 
 // Test for message: invalid cast expression [147]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+// The type name 'int(int)' is a 'function(int) returning int'.
+void take(int(int));
+
+/* ARGSUSED */
+void
+call_take(int (*ptr)(int))
+{
+	/* XXX: That's a little too unspecific. */
+	/* expect+1: error: invalid cast expression [147] */
+	take((int(int))ptr);
+}
Index: src/tests/usr.bin/xlint/lint1/msg_147.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_147.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_147.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_147.exp:1.2	Sun Mar 21 20:44:59 2021
+++ src/tests/usr.bin/xlint/lint1/msg_147.exp	Sun Jul 25 10:26:46 2021
@@ -1 +1 @@
-msg_147.c(6): error: syntax error ':' [249]
+msg_147.c(15): error: invalid cast expression [147]



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

2021-07-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 25 09:53:01 UTC 2021

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

Log Message:
tests/lint: try harder to reduce 'abstract_declarator: T_TYPEOF'

At the top level of a type_name, declaration-specifiers take precedence,
but these cannot look inside the parentheses of a
direct-abstract-declarator.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/parse_type_name.c \
src/tests/usr.bin/xlint/lint1/parse_type_name.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/parse_type_name.c
diff -u src/tests/usr.bin/xlint/lint1/parse_type_name.c:1.2 src/tests/usr.bin/xlint/lint1/parse_type_name.c:1.3
--- src/tests/usr.bin/xlint/lint1/parse_type_name.c:1.2	Sun Jul 25 09:47:08 2021
+++ src/tests/usr.bin/xlint/lint1/parse_type_name.c	Sun Jul 25 09:53:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse_type_name.c,v 1.2 2021/07/25 09:47:08 rillig Exp $	*/
+/*	$NetBSD: parse_type_name.c,v 1.3 2021/07/25 09:53:01 rillig Exp $	*/
 # 3 "parse_type_name.c"
 
 /*
@@ -48,15 +48,7 @@ cover_abstract_declarator(void)
 	sink(sizeof(int **[3]));
 
 	/* cover 'T_TYPEOF cast_expression' */
-	sink(sizeof(typeof(12345)));
-	/* expect+1: error: illegal type combination [4] */
-	sink(sizeof(typeof(12345) typeof(12345)));
-	/*
-	 * TODO: Remove this grammar rule.  No matter how often typeof occurs
-	 * in the expression, it is already covered by abstract_declaration >
-	 * begin_type_specifier_qualifier_list > begin_type_typespec >
-	 * notype_type_specifier > T_TYPEOF.  It can never reduce this rule.
-	 */
+	sink(sizeof(int(typeof(12345;
 }
 
 void
Index: src/tests/usr.bin/xlint/lint1/parse_type_name.exp
diff -u src/tests/usr.bin/xlint/lint1/parse_type_name.exp:1.2 src/tests/usr.bin/xlint/lint1/parse_type_name.exp:1.3
--- src/tests/usr.bin/xlint/lint1/parse_type_name.exp:1.2	Sun Jul 25 09:47:08 2021
+++ src/tests/usr.bin/xlint/lint1/parse_type_name.exp	Sun Jul 25 09:53:01 2021
@@ -1,7 +1,6 @@
-parse_type_name.c(53): error: illegal type combination [4]
-parse_type_name.c(79): error: null dimension [17]
-parse_type_name.c(83): error: null dimension [17]
+parse_type_name.c(71): error: null dimension [17]
+parse_type_name.c(75): error: null dimension [17]
+parse_type_name.c(141): error: syntax error 'goto' [249]
+parse_type_name.c(143): error: syntax error 'goto' [249]
 parse_type_name.c(149): error: syntax error 'goto' [249]
-parse_type_name.c(151): error: syntax error 'goto' [249]
-parse_type_name.c(157): error: syntax error 'goto' [249]
-parse_type_name.c(171): warning: ANSI C requires formal parameter before '...' [84]
+parse_type_name.c(163): warning: ANSI C requires formal parameter before '...' [84]



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

2021-07-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 25 09:47:08 UTC 2021

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

Log Message:
tests/lint: document unreachable 'abstract_declarator: T_TYPEOF'


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/parse_type_name.c \
src/tests/usr.bin/xlint/lint1/parse_type_name.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/parse_type_name.c
diff -u src/tests/usr.bin/xlint/lint1/parse_type_name.c:1.1 src/tests/usr.bin/xlint/lint1/parse_type_name.c:1.2
--- src/tests/usr.bin/xlint/lint1/parse_type_name.c:1.1	Sun Jul 25 08:42:28 2021
+++ src/tests/usr.bin/xlint/lint1/parse_type_name.c	Sun Jul 25 09:47:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse_type_name.c,v 1.1 2021/07/25 08:42:28 rillig Exp $	*/
+/*	$NetBSD: parse_type_name.c,v 1.2 2021/07/25 09:47:08 rillig Exp $	*/
 # 3 "parse_type_name.c"
 
 /*
@@ -48,7 +48,15 @@ cover_abstract_declarator(void)
 	sink(sizeof(int **[3]));
 
 	/* cover 'T_TYPEOF cast_expression' */
-	/* TODO */
+	sink(sizeof(typeof(12345)));
+	/* expect+1: error: illegal type combination [4] */
+	sink(sizeof(typeof(12345) typeof(12345)));
+	/*
+	 * TODO: Remove this grammar rule.  No matter how often typeof occurs
+	 * in the expression, it is already covered by abstract_declaration >
+	 * begin_type_specifier_qualifier_list > begin_type_typespec >
+	 * notype_type_specifier > T_TYPEOF.  It can never reduce this rule.
+	 */
 }
 
 void
Index: src/tests/usr.bin/xlint/lint1/parse_type_name.exp
diff -u src/tests/usr.bin/xlint/lint1/parse_type_name.exp:1.1 src/tests/usr.bin/xlint/lint1/parse_type_name.exp:1.2
--- src/tests/usr.bin/xlint/lint1/parse_type_name.exp:1.1	Sun Jul 25 08:42:28 2021
+++ src/tests/usr.bin/xlint/lint1/parse_type_name.exp	Sun Jul 25 09:47:08 2021
@@ -1,6 +1,7 @@
-parse_type_name.c(71): error: null dimension [17]
-parse_type_name.c(75): error: null dimension [17]
-parse_type_name.c(141): error: syntax error 'goto' [249]
-parse_type_name.c(143): error: syntax error 'goto' [249]
+parse_type_name.c(53): error: illegal type combination [4]
+parse_type_name.c(79): error: null dimension [17]
+parse_type_name.c(83): error: null dimension [17]
 parse_type_name.c(149): error: syntax error 'goto' [249]
-parse_type_name.c(163): warning: ANSI C requires formal parameter before '...' [84]
+parse_type_name.c(151): error: syntax error 'goto' [249]
+parse_type_name.c(157): error: syntax error 'goto' [249]
+parse_type_name.c(171): warning: ANSI C requires formal parameter before '...' [84]



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

2021-07-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 25 06:04:40 UTC 2021

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

Log Message:
tests/lint: demonstrate internal error in parsing a declaration


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/decl_arg.c
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/decl_arg.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/decl_arg.c
diff -u src/tests/usr.bin/xlint/lint1/decl_arg.c:1.5 src/tests/usr.bin/xlint/lint1/decl_arg.c:1.6
--- src/tests/usr.bin/xlint/lint1/decl_arg.c:1.5	Sat Jul 10 09:24:27 2021
+++ src/tests/usr.bin/xlint/lint1/decl_arg.c	Sun Jul 25 06:04:40 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: decl_arg.c,v 1.5 2021/07/10 09:24:27 rillig Exp $	*/
+/*	$NetBSD: decl_arg.c,v 1.6 2021/07/25 06:04:40 rillig Exp $	*/
 # 3 "decl_arg.c"
 
 /*
@@ -55,7 +55,8 @@ struct a_struct { int member; } a_struct
 }
 
 /*
- * Just some unrealistic coverage for the grammar rule 'notype_direct_decl'.
+ * Just some unrealistic coverage for the grammar rule
+ * 'notype_direct_declarator'.
  */
 extern int
 cover_notype_direct_decl(arg)
@@ -129,3 +130,6 @@ void cover_asm_or_symbolrename_asm(void)
 
 void cover_asm_or_symbolrename_symbolrename(void)
 __symbolrename(alternate_name);
+
+// FIXME: internal error in decl.c:906 near decl_arg.c:134: length(0)
+//void cover_abstract_declarator_typeof(void (*)(typeof(no_args)));

Index: src/tests/usr.bin/xlint/lint1/decl_arg.exp
diff -u src/tests/usr.bin/xlint/lint1/decl_arg.exp:1.2 src/tests/usr.bin/xlint/lint1/decl_arg.exp:1.3
--- src/tests/usr.bin/xlint/lint1/decl_arg.exp:1.2	Sat Jul 10 08:40:36 2021
+++ src/tests/usr.bin/xlint/lint1/decl_arg.exp	Sun Jul 25 06:04:40 2021
@@ -14,15 +14,15 @@ decl_arg.c(30): warning: argument 'a_con
 decl_arg.c(30): warning: argument 'a_number' unused in function 'old_style' [231]
 decl_arg.c(30): warning: argument 'a_function' unused in function 'old_style' [231]
 decl_arg.c(30): warning: argument 'a_struct' unused in function 'old_style' [231]
-decl_arg.c(64): error: declared argument name is missing [53]
-decl_arg.c(66): error: declared argument parenthesized_name is missing [53]
-decl_arg.c(68): error: declared argument array is missing [53]
-decl_arg.c(70): error: declared argument array_size is missing [53]
-decl_arg.c(73): error: null dimension [17]
-decl_arg.c(73): error: declared argument multi_array is missing [53]
-decl_arg.c(75): error: declared argument function is missing [53]
-decl_arg.c(77): error: declared argument prefix_attribute is missing [53]
-decl_arg.c(79): error: declared argument postfix_attribute is missing [53]
-decl_arg.c(81): error: declared argument infix_attribute is missing [53]
-decl_arg.c(90): error: declared argument pointer_prefix_attribute is missing [53]
-decl_arg.c(119): error: only register valid as formal parameter storage class [9]
+decl_arg.c(65): error: declared argument name is missing [53]
+decl_arg.c(67): error: declared argument parenthesized_name is missing [53]
+decl_arg.c(69): error: declared argument array is missing [53]
+decl_arg.c(71): error: declared argument array_size is missing [53]
+decl_arg.c(74): error: null dimension [17]
+decl_arg.c(74): error: declared argument multi_array is missing [53]
+decl_arg.c(76): error: declared argument function is missing [53]
+decl_arg.c(78): error: declared argument prefix_attribute is missing [53]
+decl_arg.c(80): error: declared argument postfix_attribute is missing [53]
+decl_arg.c(82): error: declared argument infix_attribute is missing [53]
+decl_arg.c(91): error: declared argument pointer_prefix_attribute is missing [53]
+decl_arg.c(120): error: only register valid as formal parameter storage class [9]



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

2021-07-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jul 23 15:21:47 UTC 2021

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

Log Message:
tests/lint: test lexer for the GCC extension __thread


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/decl.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/decl.c
diff -u src/tests/usr.bin/xlint/lint1/decl.c:1.9 src/tests/usr.bin/xlint/lint1/decl.c:1.10
--- src/tests/usr.bin/xlint/lint1/decl.c:1.9	Thu Jul 15 23:07:05 2021
+++ src/tests/usr.bin/xlint/lint1/decl.c	Fri Jul 23 15:21:47 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: decl.c,v 1.9 2021/07/15 23:07:05 rillig Exp $	*/
+/*	$NetBSD: decl.c,v 1.10 2021/07/23 15:21:47 rillig Exp $	*/
 # 3 "decl.c"
 
 /*
@@ -165,3 +165,9 @@ unsigned long sizes =
 sizeof(const typeof(signed_long)) +
 sizeof(const typeof(unsigned_long)) +
 sizeof(const typeof(unnamed_struct));
+
+/* expect+1: syntax error 'int' [249] */
+thread int thread_int;
+__thread int thread_int;
+/* expect+1: syntax error 'int' [249] */
+__thread__ int thread_int;

Index: src/tests/usr.bin/xlint/lint1/decl.exp
diff -u src/tests/usr.bin/xlint/lint1/decl.exp:1.5 src/tests/usr.bin/xlint/lint1/decl.exp:1.6
--- src/tests/usr.bin/xlint/lint1/decl.exp:1.5	Wed Jul 14 20:39:13 2021
+++ src/tests/usr.bin/xlint/lint1/decl.exp	Fri Jul 23 15:21:47 2021
@@ -9,4 +9,6 @@ decl.c(68): warning: converting 'pointer
 decl.c(70): warning: illegal combination of pointer (pointer to double) and integer (char), arg #1 [154]
 decl.c(72): warning: converting 'pointer to pointer to char' to incompatible 'pointer to double' for argument 1 [153]
 decl.c(80): error: syntax error '"' [249]
+decl.c(170): error: syntax error 'int' [249]
+decl.c(173): error: syntax error 'int' [249]
 decl.c(114): warning: static function unused unused [236]



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

2021-07-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jul 15 21:34:11 UTC 2021

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

Log Message:
tests/lint: cover abstract_declaration, discover internal error


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

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/decl.c
diff -u src/tests/usr.bin/xlint/lint1/decl.c:1.6 src/tests/usr.bin/xlint/lint1/decl.c:1.7
--- src/tests/usr.bin/xlint/lint1/decl.c:1.6	Thu Jul 15 21:00:05 2021
+++ src/tests/usr.bin/xlint/lint1/decl.c	Thu Jul 15 21:34:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: decl.c,v 1.6 2021/07/15 21:00:05 rillig Exp $	*/
+/*	$NetBSD: decl.c,v 1.7 2021/07/15 21:34:11 rillig Exp $	*/
 # 3 "decl.c"
 
 /*
@@ -127,3 +127,11 @@ unused_linted(void)
 
 /* covers 'type_qualifier_list: type_qualifier_list type_qualifier' */
 int *const volatile cover_type_qualifier_list;
+
+unsigned long cover_abstract_declaration_declmods = sizeof(const);
+unsigned long cover_abstract_declaration_declmods_abstract_declarator =
+sizeof(const *);
+// FIXME:
+// lint: internal error in decl.c:833 near decl.c:135: end_type(unsigned long)
+//unsigned long cover_abstract_declarator_typeof =
+//sizeof(const typeof(cover_abstract_declaration_declmods));



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

2021-07-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jul 15 21:12:46 UTC 2021

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

Log Message:
tests/lint: demonstrate questionable warnings for pointer casts


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/msg_135.c
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_135.exp
cvs rdiff -u -r1.14 -r1.15 src/tests/usr.bin/xlint/lint1/msg_247.c
cvs rdiff -u -r1.10 -r1.11 src/tests/usr.bin/xlint/lint1/msg_247.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_135.c
diff -u src/tests/usr.bin/xlint/lint1/msg_135.c:1.7 src/tests/usr.bin/xlint/lint1/msg_135.c:1.8
--- src/tests/usr.bin/xlint/lint1/msg_135.c:1.7	Sat Apr 17 16:58:04 2021
+++ src/tests/usr.bin/xlint/lint1/msg_135.c	Thu Jul 15 21:12:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_135.c,v 1.7 2021/04/17 16:58:04 rillig Exp $	*/
+/*	$NetBSD: msg_135.c,v 1.8 2021/07/15 21:12:46 rillig Exp $	*/
 # 3 "msg_135.c"
 
 // Test for message: converting '%s' to '%s' may cause alignment problem [135]
@@ -42,3 +42,25 @@ pointer_to_structs(struct incomplete *in
 	complete = (struct complete *)incomplete;
 	sink(complete);
 }
+
+void
+unsigned_char_to_unsigned_type(unsigned char *ucp)
+{
+	unsigned short *usp;
+
+	/* FIXME */
+	/* expect+1: warning: converting 'pointer to unsigned char' to 'pointer to unsigned short' may cause alignment problem [135] */
+	usp = (unsigned short *)ucp;
+	sink(usp);
+}
+
+void
+plain_char_to_unsigned_type(char *cp)
+{
+	unsigned short *usp;
+
+	/* FIXME */
+	/* expect+1: warning: converting 'pointer to char' to 'pointer to unsigned short' may cause alignment problem [135] */
+	usp = (unsigned short *)cp;
+	sink(usp);
+}

Index: src/tests/usr.bin/xlint/lint1/msg_135.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_135.exp:1.5 src/tests/usr.bin/xlint/lint1/msg_135.exp:1.6
--- src/tests/usr.bin/xlint/lint1/msg_135.exp:1.5	Sat Apr 17 16:58:04 2021
+++ src/tests/usr.bin/xlint/lint1/msg_135.exp	Thu Jul 15 21:12:46 2021
@@ -1,2 +1,4 @@
 msg_135.c(15): warning: converting 'pointer to const unsigned char' to 'pointer to const unsigned int' may cause alignment problem [135]
+msg_135.c(53): warning: converting 'pointer to unsigned char' to 'pointer to unsigned short' may cause alignment problem [135]
+msg_135.c(64): warning: converting 'pointer to char' to 'pointer to unsigned short' may cause alignment problem [135]
 msg_135.c(20): warning: struct incomplete never defined [233]

Index: src/tests/usr.bin/xlint/lint1/msg_247.c
diff -u src/tests/usr.bin/xlint/lint1/msg_247.c:1.14 src/tests/usr.bin/xlint/lint1/msg_247.c:1.15
--- src/tests/usr.bin/xlint/lint1/msg_247.c:1.14	Sat Jul 10 17:35:54 2021
+++ src/tests/usr.bin/xlint/lint1/msg_247.c	Thu Jul 15 21:12:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_247.c,v 1.14 2021/07/10 17:35:54 rillig Exp $	*/
+/*	$NetBSD: msg_247.c,v 1.15 2021/07/15 21:12:46 rillig Exp $	*/
 # 3 "msg_247.c"
 
 // Test for message: pointer cast from '%s' to '%s' may be troublesome [247]
@@ -154,3 +154,27 @@ lh_OPENSSL_STRING_new(void)
 	return (struct lhash_st_OPENSSL_STRING *)OPENSSL_LH_new();
 }
 # 157 "msg_247.c" 2
+
+void sink(const void *);
+
+void
+unsigned_char_to_unsigned_type(unsigned char *ucp)
+{
+	unsigned short *usp;
+
+	/* FIXME */
+	/* expect+1: warning: pointer cast from 'pointer to unsigned char' to 'pointer to unsigned short' may be troublesome [247] */
+	usp = (unsigned short *)ucp;
+	sink(usp);
+}
+
+void
+plain_char_to_unsigned_type(char *cp)
+{
+	unsigned short *usp;
+
+	/* FIXME */
+	/* expect+1: warning: pointer cast from 'pointer to char' to 'pointer to unsigned short' may be troublesome [247] */
+	usp = (unsigned short *)cp;
+	sink(usp);
+}

Index: src/tests/usr.bin/xlint/lint1/msg_247.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_247.exp:1.10 src/tests/usr.bin/xlint/lint1/msg_247.exp:1.11
--- src/tests/usr.bin/xlint/lint1/msg_247.exp:1.10	Fri Apr  9 20:00:07 2021
+++ src/tests/usr.bin/xlint/lint1/msg_247.exp	Thu Jul 15 21:12:46 2021
@@ -1,3 +1,5 @@
 msg_247.c(31): warning: pointer cast from 'pointer to struct Other' to 'pointer to struct ' may be troublesome [247]
 msg_247.c(70): warning: pointer cast from 'pointer to struct Other' to 'pointer to signed char' may be troublesome [247]
+msg_247.c(167): warning: pointer cast from 'pointer to unsigned char' to 'pointer to unsigned short' may be troublesome [247]
+msg_247.c(178): warning: pointer cast from 'pointer to char' to 'pointer to unsigned short' may be troublesome [247]
 msg_247.c(134): warning: struct lhash_st never defined [233]



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

2021-07-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jul 15 17:48:10 UTC 2021

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

Log Message:
tests/lint: explain global variables in __attribute__


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

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/expr_precedence.c
diff -u src/tests/usr.bin/xlint/lint1/expr_precedence.c:1.2 src/tests/usr.bin/xlint/lint1/expr_precedence.c:1.3
--- src/tests/usr.bin/xlint/lint1/expr_precedence.c:1.2	Thu Jul 15 17:20:58 2021
+++ src/tests/usr.bin/xlint/lint1/expr_precedence.c	Thu Jul 15 17:48:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: expr_precedence.c,v 1.2 2021/07/15 17:20:58 rillig Exp $	*/
+/*	$NetBSD: expr_precedence.c,v 1.3 2021/07/15 17:48:10 rillig Exp $	*/
 # 3 "expr_precedence.c"
 
 /*
@@ -22,7 +22,15 @@ int init_syntactically_ok = var = 1 ? 2 
  * don't make sense at that point.
  */
 void __attribute__((format(printf,
-/* expect+2: error: 'var' undefined [99] */ /* XXX: why? */
+/*
+ * Inside of __attribute__((...)), symbol lookup works differently.  For
+ * example, 'printf' is a keyword, and since all arguments to
+ * __attribute__ are constant expressions, looking up global variables
+ * would not make sense.  Therefore, 'var' is undefined.
+ *
+ * See lex.c, function 'search', keyword 'attron'.
+ */
+/* expect+2: error: 'var' undefined [99] */
 /* expect+1: syntax error '=' [249] */
 var = 1,
 /* Syntactically ok, must be a constant expression though. */
Index: src/tests/usr.bin/xlint/lint1/expr_precedence.exp
diff -u src/tests/usr.bin/xlint/lint1/expr_precedence.exp:1.2 src/tests/usr.bin/xlint/lint1/expr_precedence.exp:1.3
--- src/tests/usr.bin/xlint/lint1/expr_precedence.exp:1.2	Thu Jul 15 17:20:58 2021
+++ src/tests/usr.bin/xlint/lint1/expr_precedence.exp	Thu Jul 15 17:48:10 2021
@@ -1,4 +1,4 @@
 expr_precedence.c(15): error: syntax error '4' [249]
 expr_precedence.c(18): error: non-constant initializer [177]
-expr_precedence.c(27): error: 'var' undefined [99]
-expr_precedence.c(27): error: syntax error '=' [249]
+expr_precedence.c(35): error: 'var' undefined [99]
+expr_precedence.c(35): error: syntax error '=' [249]



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

2021-07-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jul 13 21:50:05 UTC 2021

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

Log Message:
tests/lint: add tests for empty and incomplete structs


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_065.c \
src/tests/usr.bin/xlint/lint1/msg_065.exp \
src/tests/usr.bin/xlint/lint1/msg_067.c \
src/tests/usr.bin/xlint/lint1/msg_067.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_065.c
diff -u src/tests/usr.bin/xlint/lint1/msg_065.c:1.2 src/tests/usr.bin/xlint/lint1/msg_065.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_065.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_065.c	Tue Jul 13 21:50:05 2021
@@ -1,7 +1,18 @@
-/*	$NetBSD: msg_065.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_065.c,v 1.3 2021/07/13 21:50:05 rillig Exp $	*/
 # 3 "msg_065.c"
 
 // Test for message: %s has no named members [65]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+struct ok {
+	int member;
+};
+
+/* XXX: should generate a warning as well. */
+struct empty {
+};
+
+struct only_unnamed_members {
+	unsigned int :14;
+	unsigned int :0;
+};
+/* expect-1: warning: structure has no named members [65] */
Index: src/tests/usr.bin/xlint/lint1/msg_065.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_065.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_065.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_065.exp:1.2	Sun Mar 21 20:44:59 2021
+++ src/tests/usr.bin/xlint/lint1/msg_065.exp	Tue Jul 13 21:50:05 2021
@@ -1 +1 @@
-msg_065.c(6): error: syntax error ':' [249]
+msg_065.c(17): warning: structure has no named members [65]
Index: src/tests/usr.bin/xlint/lint1/msg_067.c
diff -u src/tests/usr.bin/xlint/lint1/msg_067.c:1.2 src/tests/usr.bin/xlint/lint1/msg_067.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_067.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_067.c	Tue Jul 13 21:50:05 2021
@@ -1,7 +1,21 @@
-/*	$NetBSD: msg_067.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_067.c,v 1.3 2021/07/13 21:50:05 rillig Exp $	*/
 # 3 "msg_067.c"
 
 // Test for message: cannot return incomplete type [67]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* expect+1: warning: struct incomplete never defined [233] */
+struct incomplete;
+
+struct incomplete function_declaration(void);
+
+struct incomplete
+function_definition(void)
+/* expect+1: error: cannot return incomplete type [67] */
+{
+	/* FIXME: 'r' is not an argument. */
+	/* expect+1: error: argument 'r' has type 'incomplete struct incomplete' [31] */
+	struct incomplete r;
+
+	/* expect+1: error: cannot return incomplete type [212] */
+	return r;
+}
Index: src/tests/usr.bin/xlint/lint1/msg_067.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_067.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_067.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_067.exp:1.2	Sun Mar 21 20:44:59 2021
+++ src/tests/usr.bin/xlint/lint1/msg_067.exp	Tue Jul 13 21:50:05 2021
@@ -1 +1,4 @@
-msg_067.c(6): error: syntax error ':' [249]
+msg_067.c(14): error: cannot return incomplete type [67]
+msg_067.c(17): error: argument 'r' has type 'incomplete struct incomplete' [31]
+msg_067.c(20): error: cannot return incomplete type [212]
+msg_067.c(7): warning: struct incomplete never defined [233]



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

2021-07-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jul 13 19:11:35 UTC 2021

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

Log Message:
tests/lint: skip test for floating point overflow on alpha

On alpha and a few other platforms (see t_integration.sh), 'long double'
has 128 bit, which under IEEE 754 rules means a decimal exponent of up
to 4932.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_142.c
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_142.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_142.c
diff -u src/tests/usr.bin/xlint/lint1/msg_142.c:1.4 src/tests/usr.bin/xlint/lint1/msg_142.c:1.5
--- src/tests/usr.bin/xlint/lint1/msg_142.c:1.4	Mon Apr  5 01:35:34 2021
+++ src/tests/usr.bin/xlint/lint1/msg_142.c	Tue Jul 13 19:11:35 2021
@@ -1,6 +1,14 @@
-/*	$NetBSD: msg_142.c,v 1.4 2021/04/05 01:35:34 rillig Exp $	*/
+/*	$NetBSD: msg_142.c,v 1.5 2021/07/13 19:11:35 rillig Exp $	*/
 # 3 "msg_142.c"
 
 // Test for message: floating point overflow detected, op %s [142]
 
-double dbl = 1e100 * 1e100 * 1e100 * 1e100 * 1e100;	/* expect: 142 *//* expect: 142 */
+/* lint1-only-if ldbl-64 */
+/*
+ * For 96-bit and 128-bit floating point numbers, a different number of
+ * multipliers is needed to produce an overflow.
+ */
+
+/* expect+2: warning: floating point overflow detected, op * [142] */
+/* expect+1: warning: floating point overflow detected, op * [142] */
+double dbl = 1e100 * 1e100 * 1e100 * 1e100 * 1e100;

Index: src/tests/usr.bin/xlint/lint1/msg_142.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_142.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_142.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_142.exp:1.2	Fri Jan  8 21:25:03 2021
+++ src/tests/usr.bin/xlint/lint1/msg_142.exp	Tue Jul 13 19:11:35 2021
@@ -1,2 +1,2 @@
-msg_142.c(6): warning: floating point overflow detected, op * [142]
-msg_142.c(6): warning: floating point overflow detected, op * [142]
+msg_142.c(14): warning: floating point overflow detected, op * [142]
+msg_142.c(14): warning: floating point overflow detected, op * [142]



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

2021-07-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jul 13 18:50:16 UTC 2021

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

Log Message:
tests/lint: take archsubdir from usr.bin/xlint/Makefile.inc

This fixes the tests on the various ARM platforms where the platform
name does not correspond to MACHINE_ARCH, such as earmv7hf.


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/tests/usr.bin/xlint/lint1/Makefile
cvs rdiff -u -r1.67 -r1.68 src/tests/usr.bin/xlint/lint1/t_integration.sh

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/Makefile
diff -u src/tests/usr.bin/xlint/lint1/Makefile:1.86 src/tests/usr.bin/xlint/lint1/Makefile:1.87
--- src/tests/usr.bin/xlint/lint1/Makefile:1.86	Sun Jul 11 19:24:42 2021
+++ src/tests/usr.bin/xlint/lint1/Makefile	Tue Jul 13 18:50:16 2021
@@ -1,13 +1,19 @@
-# $NetBSD: Makefile,v 1.86 2021/07/11 19:24:42 rillig Exp $
+# $NetBSD: Makefile,v 1.87 2021/07/13 18:50:16 rillig Exp $
 
 NOMAN=		# defined
 MAX_MESSAGE=	345		# see lint1/err.c
 
 .include 
 
+ARCHSUBDIR!=	cd ${NETBSDSRCDIR}/usr.bin/xlint/lint1 && ${MAKE} -v ARCHSUBDIR
+
 TESTSDIR=	${TESTSBASE}/usr.bin/xlint/lint1
 
 TESTS_SH=	t_integration
+TESTS_SH_SRC_t_integration=	archsubdir.sh t_integration.sh
+
+archsubdir.sh:
+	@echo archsubdir=${ARCHSUBDIR} >${.TARGET}
 
 FILESDIR=	${TESTSDIR}
 FILES+=		c11_generic_expression.c
@@ -198,6 +204,6 @@ sync-mi: .PHONY
 	cvs diff "$$mi" || true
 
 accept: .PHONY
-	@sh ./accept.sh ''
+	@archsubdir=${ARCHSUBDIR:Q} sh ./accept.sh ''
 
 .include 

Index: src/tests/usr.bin/xlint/lint1/t_integration.sh
diff -u src/tests/usr.bin/xlint/lint1/t_integration.sh:1.67 src/tests/usr.bin/xlint/lint1/t_integration.sh:1.68
--- src/tests/usr.bin/xlint/lint1/t_integration.sh:1.67	Sun Jul 11 22:41:36 2021
+++ src/tests/usr.bin/xlint/lint1/t_integration.sh	Tue Jul 13 18:50:16 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.67 2021/07/11 22:41:36 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.68 2021/07/13 18:50:16 rillig Exp $
 #
 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -26,8 +26,7 @@
 #
 
 lint1=/usr/libexec/lint1
-
-: "${machine_arch:="$(sysctl -n hw.machine_arch)"}"
+: "${archsubdir:=archsubdir_must_be_set}"
 
 
 configure_test_case()
@@ -37,7 +36,7 @@ configure_test_case()
 	# shellcheck disable=SC2016
 	awk='
 		BEGIN {
-			# see usr.bin/xlint/arch/.../targparam.h
+			# see usr.bin/xlint/arch/*/targparam.h
 			platform["aarch64"]	= "schar lp64  long ldbl-128"
 			platform["alpha"]	= "schar lp64  long ldbl-64"
 			platform["arm"]		= "uchar ilp32 long ldbl-64"
@@ -68,15 +67,15 @@ configure_test_case()
 printf("bad property '\''%s'\''\n", prop) > "/dev/stderr"
 exit(1)
 			}
-			if (platform[machine_arch] == "") {
-printf("bad machine_arch '\''%s'\''\n", machine_arch) > "/dev/stderr"
+			if (platform[archsubdir] == "") {
+printf("bad archsubdir '\''%s'\''\n", archsubdir) > "/dev/stderr"
 exit(1)
 			}
-			return match(" " platform[machine_arch] " ", " " prop " ")
+			return match(" " platform[archsubdir] " ", " " prop " ")
 		}
 
 		BEGIN {
-			machine_arch = "'"$machine_arch"'"
+			archsubdir = "'"$archsubdir"'"
 			flags = "-g -S -w"
 			skip = "no"
 		}



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

2021-07-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jul 12 18:00:36 UTC 2021

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

Log Message:
tests/lint: test trying to define a ()-less function


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_064.c \
src/tests/usr.bin/xlint/lint1/msg_064.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_064.c
diff -u src/tests/usr.bin/xlint/lint1/msg_064.c:1.2 src/tests/usr.bin/xlint/lint1/msg_064.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_064.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_064.c	Mon Jul 12 18:00:36 2021
@@ -1,7 +1,16 @@
-/*	$NetBSD: msg_064.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_064.c,v 1.3 2021/07/12 18:00:36 rillig Exp $	*/
 # 3 "msg_064.c"
 
 // Test for message: ()-less function definition [64]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+typedef int (function)(void);
+
+/*
+ * Even though typedef_function has type function, this construction is not
+ * allowed.  A function definition must always look like a function
+ * definition, and that includes the parentheses for the arguments or
+ * parameters.
+ */
+function typedef_function {
+	/* expect-1: error: ()-less function definition [64] */
+}
Index: src/tests/usr.bin/xlint/lint1/msg_064.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_064.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_064.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_064.exp:1.2	Sun Mar 21 20:44:59 2021
+++ src/tests/usr.bin/xlint/lint1/msg_064.exp	Mon Jul 12 18:00:36 2021
@@ -1 +1 @@
-msg_064.c(6): error: syntax error ':' [249]
+msg_064.c(14): error: ()-less function definition [64]



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

2021-07-11 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 11 22:41:36 UTC 2021

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

Log Message:
tests/lint: rework ATF test driver

To skip tests that work only on particular platforms, a simple 'eval'
from the shell does not work since it does not exit on failure.  Fix
this by storing the commands in a local variable first.

Remove configuration knobs 'lint1-only-if-arch' and 'lint1-skip-if-arch'
since they are unused.

When skipping a test, actually mark it as skipped in the ATF statistics.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/tests/usr.bin/xlint/lint1/t_integration.sh

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/t_integration.sh
diff -u src/tests/usr.bin/xlint/lint1/t_integration.sh:1.66 src/tests/usr.bin/xlint/lint1/t_integration.sh:1.67
--- src/tests/usr.bin/xlint/lint1/t_integration.sh:1.66	Tue Jun 29 13:58:13 2021
+++ src/tests/usr.bin/xlint/lint1/t_integration.sh	Sun Jul 11 22:41:36 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.66 2021/06/29 13:58:13 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.67 2021/07/11 22:41:36 rillig Exp $
 #
 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -65,12 +65,12 @@ configure_test_case()
 
 		function platform_has(prop) {
 			if (!match(prop, /^(schar|uchar|ilp32|lp64|int|long|ldbl-64|ldbl-96|ldbl-128)$/)) {
-printf("bad property '\''%s'\''\n", prop) > "/dev/stderr";
-exit(1);
+printf("bad property '\''%s'\''\n", prop) > "/dev/stderr"
+exit(1)
 			}
 			if (platform[machine_arch] == "") {
-printf("bad machine_arch '\''%s'\''\n", machine_arch) > "/dev/stderr";
-exit(1);
+printf("bad machine_arch '\''%s'\''\n", machine_arch) > "/dev/stderr"
+exit(1)
 			}
 			return match(" " platform[machine_arch] " ", " " prop " ")
 		}
@@ -78,9 +78,7 @@ configure_test_case()
 		BEGIN {
 			machine_arch = "'"$machine_arch"'"
 			flags = "-g -S -w"
-			seen_only_on_arch = 0
-			match_only_on_arch = 0
-			skip = 0
+			skip = "no"
 		}
 		$1 == "/*" && $2 ~ /^lint1-/ && $NF == "*/" {
 			if ($2 == "lint1-flags:" || $2 == "lint1-extra-flags:") {
@@ -89,29 +87,21 @@ configure_test_case()
 for (i = 3; i < NF; i++)
 	flags = flags " " $i
 			}
-			if ($2 == "lint1-only-if-arch") {
-seen_only_on_arch = 1
-if ($3 == machine_arch)
-	match_only_on_arch = 1
-			}
-			if ($2 == "lint1-skip-if-arch" && $3 == machine_arch)
-skip = 1
 			if ($2 == "lint1-only-if" && !platform_has($3))
-skip = 1
+skip = "yes"
 			if ($2 == "lint1-skip-if" && platform_has($3))
-skip = 1
+skip = "yes"
 		}
 
 		END {
-			if (seen_only_on_arch && !match_only_on_arch)
-skip = 1
-
 			printf("flags='\''%s'\''\n", flags)
-			printf("skip=%s\n", skip ? "yes" : "no")
+			printf("skip=%s\n", skip)
 		}
 	'
 
-	eval "$(awk "$awk" "$1")"
+	local config
+	config="$(awk "$awk" "$1")" || exit 1
+	eval "$config"
 }
 
 # shellcheck disable=SC2155
@@ -129,11 +119,10 @@ check_lint1()
 		wrk_ln='/dev/null'
 	fi
 
-	configure_test_case "$src"
+	configure_test_case "$src"	# sets 'skip' and 'flags'
 
 	if [ "$skip" = "yes" ]; then
-		atf_check -o 'ignore' echo 'skipped'
-		return
+		atf_skip "unsuitable platform"
 	fi
 
 	if [ -f "$exp" ]; then



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

2021-07-11 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 11 20:34:05 UTC 2021

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

Log Message:
tests/lint: demonstrate that _Generic must be a primary_expression


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 \
src/tests/usr.bin/xlint/lint1/c11_generic_expression.c
cvs rdiff -u -r1.5 -r1.6 \
src/tests/usr.bin/xlint/lint1/c11_generic_expression.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/c11_generic_expression.c
diff -u src/tests/usr.bin/xlint/lint1/c11_generic_expression.c:1.6 src/tests/usr.bin/xlint/lint1/c11_generic_expression.c:1.7
--- src/tests/usr.bin/xlint/lint1/c11_generic_expression.c:1.6	Mon Jun 28 07:55:05 2021
+++ src/tests/usr.bin/xlint/lint1/c11_generic_expression.c	Sun Jul 11 20:34:05 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: c11_generic_expression.c,v 1.6 2021/06/28 07:55:05 rillig Exp $	*/
+/*	$NetBSD: c11_generic_expression.c,v 1.7 2021/07/11 20:34:05 rillig Exp $	*/
 # 3 "c11_generic_expression.c"
 
 /*
@@ -88,3 +88,11 @@ assignment_expression(int first, int sec
 	int: second = first
 	);
 }
+
+int
+primary_expression(void)
+{
+	/*FIXME*//* expect+1: syntax error '(' [249] */
+	return _Generic(0, int: assignment_expression)(0, 0);
+}
+/* expect-1: falls off */

Index: src/tests/usr.bin/xlint/lint1/c11_generic_expression.exp
diff -u src/tests/usr.bin/xlint/lint1/c11_generic_expression.exp:1.5 src/tests/usr.bin/xlint/lint1/c11_generic_expression.exp:1.6
--- src/tests/usr.bin/xlint/lint1/c11_generic_expression.exp:1.5	Sun Jun 27 21:30:46 2021
+++ src/tests/usr.bin/xlint/lint1/c11_generic_expression.exp	Sun Jul 11 20:34:05 2021
@@ -4,3 +4,5 @@ c11_generic_expression.c(37): warning: a
 c11_generic_expression.c(53): warning: argument 'c' unused in function 'classify_char' [231]
 c11_generic_expression.c(72): error: syntax error 'second' [249]
 c11_generic_expression.c(77): warning: function comma_expression falls off bottom without returning value [217]
+c11_generic_expression.c(96): error: syntax error '(' [249]
+c11_generic_expression.c(97): warning: function primary_expression falls off bottom without returning value [217]



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

2021-07-11 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 11 19:39:00 UTC 2021

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

Log Message:
tests/lint: test precedence of __real__ and cast_expression


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/d_c99_complex_split.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_complex_split.c
diff -u src/tests/usr.bin/xlint/lint1/d_c99_complex_split.c:1.7 src/tests/usr.bin/xlint/lint1/d_c99_complex_split.c:1.8
--- src/tests/usr.bin/xlint/lint1/d_c99_complex_split.c:1.7	Fri Apr  9 21:42:12 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_complex_split.c	Sun Jul 11 19:39:00 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: d_c99_complex_split.c,v 1.7 2021/04/09 21:42:12 rillig Exp $	*/
+/*	$NetBSD: d_c99_complex_split.c,v 1.8 2021/07/11 19:39:00 rillig Exp $	*/
 # 3 "d_c99_complex_split.c"
 
 /*
@@ -81,3 +81,13 @@ trigger_warning(double _Complex c)
 	c += 1.0;
 	return c | c;		/* expect: incompatible types */
 }
+
+void
+precedence_cast_expression(void)
+{
+	double _Complex z = 0;
+	if (b(__real__(double _Complex)z) && b(__imag__(double _Complex)z))
+		return;
+	if (b(__real__(z)) && b(__imag__(z)))
+		return;
+}



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

2021-07-11 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 11 14:43:57 UTC 2021

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

Log Message:
tests/lint: when accepting test results, skip crashes


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

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/accept.sh
diff -u src/tests/usr.bin/xlint/lint1/accept.sh:1.2 src/tests/usr.bin/xlint/lint1/accept.sh:1.3
--- src/tests/usr.bin/xlint/lint1/accept.sh:1.2	Sun Jul 11 12:07:14 2021
+++ src/tests/usr.bin/xlint/lint1/accept.sh	Sun Jul 11 14:43:57 2021
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: accept.sh,v 1.2 2021/07/11 12:07:14 rillig Exp $
+# $NetBSD: accept.sh,v 1.3 2021/07/11 14:43:57 rillig Exp $
 #
 # Copyright (c) 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -61,6 +61,9 @@ for pattern in "$@"; do
 sed 's,^,| ,' "$tmpfile"
 			fi
 			rm -f "$expfile" "$tmpfile"
+		elif [ $? -ge 128 ]; then
+			echo "$base crashed"
+			continue
 		else
 			if [ -f "$tmpfile" ] && cmp -s "$tmpfile" "$expfile"; then
 rm "$tmpfile"



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

2021-07-11 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 11 13:32:06 UTC 2021

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

Log Message:
tests/lint: analyze yesterday's bug for parsing declarations


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

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/gcc_attribute_var.c
diff -u src/tests/usr.bin/xlint/lint1/gcc_attribute_var.c:1.1 src/tests/usr.bin/xlint/lint1/gcc_attribute_var.c:1.2
--- src/tests/usr.bin/xlint/lint1/gcc_attribute_var.c:1.1	Tue Jul  6 17:33:07 2021
+++ src/tests/usr.bin/xlint/lint1/gcc_attribute_var.c	Sun Jul 11 13:32:06 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: gcc_attribute_var.c,v 1.1 2021/07/06 17:33:07 rillig Exp $	*/
+/*	$NetBSD: gcc_attribute_var.c,v 1.2 2021/07/11 13:32:06 rillig Exp $	*/
 # 3 "gcc_attribute_var.c"
 
 /*
@@ -23,6 +23,47 @@ placement(
 int after __attribute__((__deprecated__))
 );
 
+void println(void);
+
+/*
+ * Since cgram.y 1.294 from 2021-07-10, lint did not accept declarations that
+ * started with __attribute__, due to a newly and accidentally introduced
+ * shift/reduce conflict in the grammar.
+ *
+ * A GCC extension allows statement of the form __attribute__((fallthrough)),
+ * thus starting with __attribute__.  This is the 'shift' in the conflict.
+ * The 'reduce' in the conflict was begin_type.
+ *
+ * Before cgram 1.294, the gcc_attribute was placed outside the pair of
+ * begin_type/end_type, exactly to resolve this conflict.
+ *
+ * Conceptually, it made sense to put the __attribute__((unused)) between
+ * begin_type and end_type, to make it part of the declaration-specifiers.
+ * This change introduced the hidden conflict though.
+ *
+ * Interestingly, the number of shift/reduce conflicts did not change in
+ * cgram 1.294, the conflicts were just resolved differently than before.
+ *
+ * To prevent this from happening again, make sure that declarations as well
+ * as statements can start with gcc_attribute.
+ */
+void
+ambiguity_for_attribute(void)
+{
+	/*FIXME*//* expect+1: error: syntax error '_Bool' [249] */
+	__attribute__((unused)) _Bool var1;
+
+	switch (1) {
+	case 1:
+		println();
+		/*FIXME*//* expect+1: error: syntax error '_Bool' [249] */
+		__attribute__((unused)) _Bool var2;
+		__attribute__((fallthrough));
+		case 2:
+			println();
+	}
+}
+
 /* just to trigger _some_ error, to keep the .exp file */
 /* expect+1: error: syntax error 'syntax_error' [249] */
 __attribute__((syntax_error));
Index: src/tests/usr.bin/xlint/lint1/gcc_attribute_var.exp
diff -u src/tests/usr.bin/xlint/lint1/gcc_attribute_var.exp:1.1 src/tests/usr.bin/xlint/lint1/gcc_attribute_var.exp:1.2
--- src/tests/usr.bin/xlint/lint1/gcc_attribute_var.exp:1.1	Tue Jul  6 17:33:07 2021
+++ src/tests/usr.bin/xlint/lint1/gcc_attribute_var.exp	Sun Jul 11 13:32:06 2021
@@ -1 +1,3 @@
-gcc_attribute_var.c(28): error: syntax error 'syntax_error' [249]
+gcc_attribute_var.c(54): error: syntax error '_Bool' [249]
+gcc_attribute_var.c(60): error: syntax error '_Bool' [249]
+gcc_attribute_var.c(69): error: syntax error 'syntax_error' [249]



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

2021-07-11 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 11 12:12:30 UTC 2021

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

Log Message:
tests/lint: parse error for unused variable (since 2021-07-10)

Since cgram.y 1.294 from 2021-07-10.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/decl.c \
src/tests/usr.bin/xlint/lint1/decl.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/decl.c
diff -u src/tests/usr.bin/xlint/lint1/decl.c:1.2 src/tests/usr.bin/xlint/lint1/decl.c:1.3
--- src/tests/usr.bin/xlint/lint1/decl.c:1.2	Sat Jul 10 19:30:19 2021
+++ src/tests/usr.bin/xlint/lint1/decl.c	Sun Jul 11 12:12:30 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: decl.c,v 1.2 2021/07/10 19:30:19 rillig Exp $	*/
+/*	$NetBSD: decl.c,v 1.3 2021/07/11 12:12:30 rillig Exp $	*/
 # 3 "decl.c"
 
 /*
@@ -86,3 +86,15 @@ enum_error_handling(void)
 
 	return x == B;
 }
+
+void
+unused_local_variable(void)
+{
+	/*FIXME*//* expect+1: syntax error '_Bool' [249] */
+	__attribute__((unused)) _Bool unused_var;
+
+	__attribute__((unused))
+	/*FIXME*//* expect+2: syntax error '__attribute__' [249] */
+	/*FIXME*//* expect+1: cannot recover from previous errors [224] */
+	__attribute__((unused)) _Bool unused_twice;
+}
Index: src/tests/usr.bin/xlint/lint1/decl.exp
diff -u src/tests/usr.bin/xlint/lint1/decl.exp:1.2 src/tests/usr.bin/xlint/lint1/decl.exp:1.3
--- src/tests/usr.bin/xlint/lint1/decl.exp:1.2	Sat Jul 10 19:30:19 2021
+++ src/tests/usr.bin/xlint/lint1/decl.exp	Sun Jul 11 12:12:30 2021
@@ -9,3 +9,6 @@ decl.c(68): warning: converting 'pointer
 decl.c(70): warning: illegal combination of pointer (pointer to double) and integer (char), arg #1 [154]
 decl.c(72): warning: converting 'pointer to pointer to char' to incompatible 'pointer to double' for argument 1 [153]
 decl.c(80): error: syntax error '"' [249]
+decl.c(94): error: syntax error '_Bool' [249]
+decl.c(99): error: syntax error '__attribute__' [249]
+decl.c(99): error: cannot recover from previous errors [224]



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

2021-07-11 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul 11 12:07:15 UTC 2021

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

Log Message:
tests/lint: suppress ShellCheck warnings for intentional violations

The undeclared variables are generated by the AWK program.
The variable 'flags' must be split into words at exactly this point.


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

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/accept.sh
diff -u src/tests/usr.bin/xlint/lint1/accept.sh:1.1 src/tests/usr.bin/xlint/lint1/accept.sh:1.2
--- src/tests/usr.bin/xlint/lint1/accept.sh:1.1	Tue Jun 29 09:44:25 2021
+++ src/tests/usr.bin/xlint/lint1/accept.sh	Sun Jul 11 12:07:14 2021
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: accept.sh,v 1.1 2021/06/29 09:44:25 rillig Exp $
+# $NetBSD: accept.sh,v 1.2 2021/07/11 12:07:14 rillig Exp $
 #
 # Copyright (c) 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -44,6 +44,7 @@ for pattern in "$@"; do
 		ln_file="$base.ln"
 
 		configure_test_case "$cfile"
+		# shellcheck disable=SC2154
 		if [ $skip = yes ]; then
 			continue
 		fi
@@ -52,6 +53,8 @@ for pattern in "$@"; do
 			ln_file='/dev/null'
 		fi
 
+		# shellcheck disable=SC2154
+		# shellcheck disable=SC2086
 		if "$lint1" $flags "$base.c" "$ln_file" > "$tmpfile"; then
 			if [ -s "$tmpfile" ]; then
 echo "$base produces output but exits successfully"



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

2021-07-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jul 10 22:34:02 UTC 2021

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

Log Message:
tests/lint: demonstrate parse error for __attribute__ member


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/decl_struct_member.c
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/decl_struct_member.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/decl_struct_member.c
diff -u src/tests/usr.bin/xlint/lint1/decl_struct_member.c:1.3 src/tests/usr.bin/xlint/lint1/decl_struct_member.c:1.4
--- src/tests/usr.bin/xlint/lint1/decl_struct_member.c:1.3	Sat Jul 10 17:35:54 2021
+++ src/tests/usr.bin/xlint/lint1/decl_struct_member.c	Sat Jul 10 22:34:02 2021
@@ -1,12 +1,19 @@
-/*	$NetBSD: decl_struct_member.c,v 1.3 2021/07/10 17:35:54 rillig Exp $	*/
+/*	$NetBSD: decl_struct_member.c,v 1.4 2021/07/10 22:34:02 rillig Exp $	*/
 # 3 "decl_struct_member.c"
 
+struct multi_attributes {
+	__attribute__((deprecated))
+	/* expect+1: error: syntax error '__attribute__' [249] */
+	__attribute__((deprecated))
+	__attribute__((deprecated))
+	int deprecated;
+};
+
 /*
  * Before cgram.y 1.228 from 2021-06-19, lint ran into an assertion failure:
  *
  * "is_struct_or_union(dcs->d_type->t_tspec)" at cgram.y:846
  */
-
 struct {
 	char;			/* expect: syntax error 'unnamed member' */
 };

Index: src/tests/usr.bin/xlint/lint1/decl_struct_member.exp
diff -u src/tests/usr.bin/xlint/lint1/decl_struct_member.exp:1.2 src/tests/usr.bin/xlint/lint1/decl_struct_member.exp:1.3
--- src/tests/usr.bin/xlint/lint1/decl_struct_member.exp:1.2	Sun Jun 20 11:24:32 2021
+++ src/tests/usr.bin/xlint/lint1/decl_struct_member.exp	Sat Jul 10 22:34:02 2021
@@ -1,4 +1,5 @@
-decl_struct_member.c(11): error: syntax error 'unnamed member' [249]
-decl_struct_member.c(18): error: syntax error '0' [249]
-decl_struct_member.c(19): warning: syntax requires ';' after last struct/union member [66]
-decl_struct_member.c(26): error: cannot recover from previous errors [224]
+decl_struct_member.c(7): error: syntax error '__attribute__' [249]
+decl_struct_member.c(18): error: syntax error 'unnamed member' [249]
+decl_struct_member.c(25): error: syntax error '0' [249]
+decl_struct_member.c(26): warning: syntax requires ';' after last struct/union member [66]
+decl_struct_member.c(33): error: cannot recover from previous errors [224]



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

2021-07-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jul 10 19:30:19 UTC 2021

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

Log Message:
tests/lint: test error handling in enum-specifier


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/decl.c \
src/tests/usr.bin/xlint/lint1/decl.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/decl.c
diff -u src/tests/usr.bin/xlint/lint1/decl.c:1.1 src/tests/usr.bin/xlint/lint1/decl.c:1.2
--- src/tests/usr.bin/xlint/lint1/decl.c:1.1	Sat Jul 10 18:25:57 2021
+++ src/tests/usr.bin/xlint/lint1/decl.c	Sat Jul 10 19:30:19 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: decl.c,v 1.1 2021/07/10 18:25:57 rillig Exp $	*/
+/*	$NetBSD: decl.c,v 1.2 2021/07/10 19:30:19 rillig Exp $	*/
 # 3 "decl.c"
 
 /*
@@ -71,3 +71,18 @@ declarators(void)
 	/* expect+1: converting 'pointer to pointer to char' to incompatible 'pointer to double' */
 	sink(ppc);
 }
+
+_Bool
+enum_error_handling(void)
+{
+	enum {
+		/* expect+1: syntax error '"' [249] */
+		"error 1"
+		:		/* still the same error */
+		,		/* back on track */
+		A,
+		B
+	} x = A;
+
+	return x == B;
+}
Index: src/tests/usr.bin/xlint/lint1/decl.exp
diff -u src/tests/usr.bin/xlint/lint1/decl.exp:1.1 src/tests/usr.bin/xlint/lint1/decl.exp:1.2
--- src/tests/usr.bin/xlint/lint1/decl.exp:1.1	Sat Jul 10 18:25:57 2021
+++ src/tests/usr.bin/xlint/lint1/decl.exp	Sat Jul 10 19:30:19 2021
@@ -8,3 +8,4 @@ decl.c(54): error: syntax error 'const' 
 decl.c(68): warning: converting 'pointer to char' to incompatible 'pointer to double' for argument 1 [153]
 decl.c(70): warning: illegal combination of pointer (pointer to double) and integer (char), arg #1 [154]
 decl.c(72): warning: converting 'pointer to pointer to char' to incompatible 'pointer to double' for argument 1 [153]
+decl.c(80): error: syntax error '"' [249]



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

2021-07-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jul 10 18:42:28 UTC 2021

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

Log Message:
tests/lint: test lexing of integer suffixes


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/lex_integer.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/lex_integer.c
diff -u src/tests/usr.bin/xlint/lint1/lex_integer.c:1.4 src/tests/usr.bin/xlint/lint1/lex_integer.c:1.5
--- src/tests/usr.bin/xlint/lint1/lex_integer.c:1.4	Tue Jun 29 13:58:13 2021
+++ src/tests/usr.bin/xlint/lint1/lex_integer.c	Sat Jul 10 18:42:28 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lex_integer.c,v 1.4 2021/06/29 13:58:13 rillig Exp $	*/
+/*	$NetBSD: lex_integer.c,v 1.5 2021/07/10 18:42:28 rillig Exp $	*/
 # 3 "lex_integer.c"
 
 /*
@@ -43,3 +43,19 @@ test_unsigned_int(void)
 	/* expect+1: conversion of 'unsigned long' to 'unsigned int' is out of range */
 	sinku(4294967296U);
 }
+
+void sinkull(unsigned long long);
+
+void
+suffixes(void)
+{
+	sinkull(3u);
+	sinkull(3ll);
+	sinkull(3llu);
+	sinkull(3Ull);
+
+	/* The 'LL' must not be split. Checked by the compiler. */
+	sinkull(3lul);
+	/* The 'Ll' must not used mixed case. Checked by the compiler. */
+	sinkull(3ULl);
+}



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

2021-07-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jul 10 18:34:03 UTC 2021

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

Log Message:
tests/lint: add another example for storage class in declaration


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_083.c
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_083.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_083.c
diff -u src/tests/usr.bin/xlint/lint1/msg_083.c:1.3 src/tests/usr.bin/xlint/lint1/msg_083.c:1.4
--- src/tests/usr.bin/xlint/lint1/msg_083.c:1.3	Sun Jan 31 11:12:07 2021
+++ src/tests/usr.bin/xlint/lint1/msg_083.c	Sat Jul 10 18:34:03 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_083.c,v 1.3 2021/01/31 11:12:07 rillig Exp $	*/
+/*	$NetBSD: msg_083.c,v 1.4 2021/07/10 18:34:03 rillig Exp $	*/
 # 3 "msg_083.c"
 
 // Test for message: storage class after type is obsolescent [83]
@@ -8,3 +8,8 @@ example(void)
 {
 	int register x;		/* expect: 83 */
 }
+
+struct {
+	int member;
+} typedef s;
+/* expect-1: warning: storage class after type is obsolescent [83] */

Index: src/tests/usr.bin/xlint/lint1/msg_083.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_083.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_083.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_083.exp:1.2	Fri Jan  8 21:25:03 2021
+++ src/tests/usr.bin/xlint/lint1/msg_083.exp	Sat Jul 10 18:34:03 2021
@@ -1 +1,2 @@
 msg_083.c(9): warning: storage class after type is obsolescent [83]
+msg_083.c(14): warning: storage class after type is obsolescent [83]



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

2021-07-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jul 10 08:40:36 UTC 2021

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

Log Message:
tests/lint: add code coverage for grammar rule parameter_declaration


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/decl_arg.c
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/decl_arg.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/decl_arg.c
diff -u src/tests/usr.bin/xlint/lint1/decl_arg.c:1.3 src/tests/usr.bin/xlint/lint1/decl_arg.c:1.4
--- src/tests/usr.bin/xlint/lint1/decl_arg.c:1.3	Sat Jul 10 08:01:11 2021
+++ src/tests/usr.bin/xlint/lint1/decl_arg.c	Sat Jul 10 08:40:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: decl_arg.c,v 1.3 2021/07/10 08:01:11 rillig Exp $	*/
+/*	$NetBSD: decl_arg.c,v 1.4 2021/07/10 08:40:36 rillig Exp $	*/
 # 3 "decl_arg.c"
 
 /*
@@ -102,9 +102,24 @@ void test_varargs_attribute(
  *  need to be enclosed by one more pair of parentheses than usual.
  */
 void cover_direct_notype_param_decl(
-double (f1),
+double (identifier),
 double ((parenthesized)),
 double (array[]),
 double (array_size[3]),
 double (*)(void (function()))
 );
+
+/*
+ * Just some unrealistic code to cover the grammar rule parameter_declaration.
+ */
+/* expect+4: error: only register valid as formal parameter storage class [9] */
+void cover_parameter_declaration(
+volatile,			/* 1 */
+double,			/* 2 */
+static storage_class,	/* 3.1 */
+const type_qualifier,	/* 3.2 */
+double (identifier),	/* 4 */
+const (*),			/* 5 */
+double *const,		/* 6 */
+...
+);

Index: src/tests/usr.bin/xlint/lint1/decl_arg.exp
diff -u src/tests/usr.bin/xlint/lint1/decl_arg.exp:1.1 src/tests/usr.bin/xlint/lint1/decl_arg.exp:1.2
--- src/tests/usr.bin/xlint/lint1/decl_arg.exp:1.1	Fri Jul  9 20:20:03 2021
+++ src/tests/usr.bin/xlint/lint1/decl_arg.exp	Sat Jul 10 08:40:36 2021
@@ -25,3 +25,4 @@ decl_arg.c(77): error: declared argument
 decl_arg.c(79): error: declared argument postfix_attribute is missing [53]
 decl_arg.c(81): error: declared argument infix_attribute is missing [53]
 decl_arg.c(90): error: declared argument pointer_prefix_attribute is missing [53]
+decl_arg.c(119): error: only register valid as formal parameter storage class [9]



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

2021-07-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jul 10 08:01:11 UTC 2021

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

Log Message:
lint: add code coverage for grammar rule direct_notype_param_decl


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/decl_arg.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/decl_arg.c
diff -u src/tests/usr.bin/xlint/lint1/decl_arg.c:1.2 src/tests/usr.bin/xlint/lint1/decl_arg.c:1.3
--- src/tests/usr.bin/xlint/lint1/decl_arg.c:1.2	Sat Jul 10 06:01:41 2021
+++ src/tests/usr.bin/xlint/lint1/decl_arg.c	Sat Jul 10 08:01:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: decl_arg.c,v 1.2 2021/07/10 06:01:41 rillig Exp $	*/
+/*	$NetBSD: decl_arg.c,v 1.3 2021/07/10 08:01:11 rillig Exp $	*/
 # 3 "decl_arg.c"
 
 /*
@@ -96,3 +96,15 @@ void test_varargs_attribute(
 void (*pr)(const char *, ...)
 	__attribute__((__format__(__printf__, 1, 2)))
 );
+
+/*
+ * XXX: To cover the grammar rule 'direct_notype_param_decl', the parameters
+ *  need to be enclosed by one more pair of parentheses than usual.
+ */
+void cover_direct_notype_param_decl(
+double (f1),
+double ((parenthesized)),
+double (array[]),
+double (array_size[3]),
+double (*)(void (function()))
+);



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

2021-07-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jul 10 06:01:41 UTC 2021

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

Log Message:
tests/lint: move test for __attribute__ out of msg_124.c

That test case didn't belong there since there was no chance of getting
an 'illegal pointer combination' by applying an operator.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/decl_arg.c
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/xlint/lint1/msg_124.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/decl_arg.c
diff -u src/tests/usr.bin/xlint/lint1/decl_arg.c:1.1 src/tests/usr.bin/xlint/lint1/decl_arg.c:1.2
--- src/tests/usr.bin/xlint/lint1/decl_arg.c:1.1	Fri Jul  9 20:20:03 2021
+++ src/tests/usr.bin/xlint/lint1/decl_arg.c	Sat Jul 10 06:01:41 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: decl_arg.c,v 1.1 2021/07/09 20:20:03 rillig Exp $	*/
+/*	$NetBSD: decl_arg.c,v 1.2 2021/07/10 06:01:41 rillig Exp $	*/
 # 3 "decl_arg.c"
 
 /*
@@ -91,3 +91,8 @@ const
 {
 	return arg;
 }
+
+void test_varargs_attribute(
+void (*pr)(const char *, ...)
+	__attribute__((__format__(__printf__, 1, 2)))
+);

Index: src/tests/usr.bin/xlint/lint1/msg_124.c
diff -u src/tests/usr.bin/xlint/lint1/msg_124.c:1.9 src/tests/usr.bin/xlint/lint1/msg_124.c:1.10
--- src/tests/usr.bin/xlint/lint1/msg_124.c:1.9	Tue Apr 13 22:21:19 2021
+++ src/tests/usr.bin/xlint/lint1/msg_124.c	Sat Jul 10 06:01:41 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_124.c,v 1.9 2021/04/13 22:21:19 christos Exp $	*/
+/*	$NetBSD: msg_124.c,v 1.10 2021/07/10 06:01:41 rillig Exp $	*/
 # 3 "msg_124.c"
 
 // Test for message: illegal pointer combination (%s) and (%s), op %s [124]
@@ -49,6 +49,3 @@ compare_pointers(const void *vp, const c
 	ok(ip == 0L);
 	ok(fp == 0L);
 }
-
-void	test_varargs_attribute(void (*pr)(const char *, ...) __attribute__((__format__(__printf__, 1, 2;
-



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

2021-07-09 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jul  9 18:55:28 UTC 2021

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

Log Message:
tests/lint: ensure that GCC __attribute__ can be parsed


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

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/gcc_attribute.c
diff -u src/tests/usr.bin/xlint/lint1/gcc_attribute.c:1.8 src/tests/usr.bin/xlint/lint1/gcc_attribute.c:1.9
--- src/tests/usr.bin/xlint/lint1/gcc_attribute.c:1.8	Tue Jul  6 18:43:27 2021
+++ src/tests/usr.bin/xlint/lint1/gcc_attribute.c	Fri Jul  9 18:55:28 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: gcc_attribute.c,v 1.8 2021/07/06 18:43:27 rillig Exp $	*/
+/*	$NetBSD: gcc_attribute.c,v 1.9 2021/07/09 18:55:28 rillig Exp $	*/
 # 3 "gcc_attribute.c"
 
 /*
@@ -84,3 +84,36 @@ void one_empty_attribute(void)
  */
 void two_empty_attributes(void)
 __attribute__((/* none */, /* still none */));
+
+/*
+ * Ensure that __attribute__ can be specified everywhere in a declaration.
+ * This is the simplest possible requirement that covers all valid code.
+ * It accepts invalid code as well, but these cases are covered by GCC and
+ * Clang already.
+ *
+ * Since lint only parses the attributes but doesn't really relate them to
+ * identifiers or other entities, ensuring that valid code can be parsed is
+ * enough for now.
+ *
+ * To really associate __attribute__ with the corresponding entity, the
+ * grammar needs to be rewritten, see the example with __noreturn__ above.
+ */
+__attribute__((deprecated("d1")))
+const
+__attribute__((deprecated("d2")))
+int
+__attribute__((deprecated("d3")))
+*
+// The below line would produce a syntax error.
+// __attribute__((deprecated("d3")))
+const
+__attribute__((deprecated("d4")))
+identifier
+__attribute__((deprecated("d5")))
+(
+__attribute__((deprecated("d6")))
+void
+__attribute__((deprecated("d7")))
+)
+__attribute__((deprecated("d8")))
+;



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

2021-07-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jul  8 20:11:15 UTC 2021

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

Log Message:
tests/lint: test error recovery of the parser


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_249.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_249.c
diff -u src/tests/usr.bin/xlint/lint1/msg_249.c:1.4 src/tests/usr.bin/xlint/lint1/msg_249.c:1.5
--- src/tests/usr.bin/xlint/lint1/msg_249.c:1.4	Thu Jul  8 18:02:22 2021
+++ src/tests/usr.bin/xlint/lint1/msg_249.c	Thu Jul  8 20:11:15 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_249.c,v 1.4 2021/07/08 18:02:22 rillig Exp $	*/
+/*	$NetBSD: msg_249.c,v 1.5 2021/07/08 20:11:15 rillig Exp $	*/
 # 3 "msg_249.c"
 
 // Test for message: syntax error '%s' [249]
@@ -33,5 +33,15 @@ function(void)
 	);			/* expect: syntax error ')' */
 }
 
+/* XXX: It is unexpected that this error is not detected. */
+"This syntax error is not detected.";
+
 /* XXX: This is necessary to recover the yacc parser. */
-int recover_from_rparen;
+double recover_from_rparen;
+
+/* Ensure that the declaration after the syntax error is processed. */
+double *
+access_declaration_after_syntax_error(void)
+{
+	return _from_rparen;
+}



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

2021-07-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Jul  8 18:02:22 UTC 2021

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

Log Message:
tests/lint: add test coverage for some parse errors


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_249.c \
src/tests/usr.bin/xlint/lint1/msg_249.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_249.c
diff -u src/tests/usr.bin/xlint/lint1/msg_249.c:1.3 src/tests/usr.bin/xlint/lint1/msg_249.c:1.4
--- src/tests/usr.bin/xlint/lint1/msg_249.c:1.3	Sat Jun 19 16:05:07 2021
+++ src/tests/usr.bin/xlint/lint1/msg_249.c	Thu Jul  8 18:02:22 2021
@@ -1,9 +1,27 @@
-/*	$NetBSD: msg_249.c,v 1.3 2021/06/19 16:05:07 rillig Exp $	*/
+/*	$NetBSD: msg_249.c,v 1.4 2021/07/08 18:02:22 rillig Exp $	*/
 # 3 "msg_249.c"
 
 // Test for message: syntax error '%s' [249]
 
 /*
+ * Cover the grammar rule 'top_level_declaration: error T_SEMI'.
+ */
+/* expect+1: syntax error '"' [249] */
+"syntax error in top_level_declaration";
+
+/* XXX: This is necessary to recover the yacc parser. */
+int recover_from_semi;
+
+/*
+ * Cover the grammar rule 'top_level_declaration: error T_RBRACE'.
+ */
+/* expect+1: syntax error '"' [249] */
+"syntax error in top_level_declaration"}
+
+/* XXX: This is necessary to recover the yacc parser. */
+int recover_from_rbrace;
+
+/*
  * Before func.c 1.110 from 2021-06-19, lint ran into this:
  * assertion "cstmt->c_kind == kind" failed in end_control_statement
  */
@@ -14,3 +32,6 @@ function(void)
 		;
 	);			/* expect: syntax error ')' */
 }
+
+/* XXX: This is necessary to recover the yacc parser. */
+int recover_from_rparen;
Index: src/tests/usr.bin/xlint/lint1/msg_249.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_249.exp:1.3 src/tests/usr.bin/xlint/lint1/msg_249.exp:1.4
--- src/tests/usr.bin/xlint/lint1/msg_249.exp:1.3	Sat Jun 19 16:05:07 2021
+++ src/tests/usr.bin/xlint/lint1/msg_249.exp	Thu Jul  8 18:02:22 2021
@@ -1 +1,3 @@
-msg_249.c(15): error: syntax error ')' [249]
+msg_249.c(10): error: syntax error '"' [249]
+msg_249.c(19): error: syntax error '"' [249]
+msg_249.c(33): error: syntax error ')' [249]



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

2021-07-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jul  6 18:43:27 UTC 2021

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

Log Message:
tests/lint: add test for empty __attribute__(())


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

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/gcc_attribute.c
diff -u src/tests/usr.bin/xlint/lint1/gcc_attribute.c:1.7 src/tests/usr.bin/xlint/lint1/gcc_attribute.c:1.8
--- src/tests/usr.bin/xlint/lint1/gcc_attribute.c:1.7	Tue Jul  6 17:33:07 2021
+++ src/tests/usr.bin/xlint/lint1/gcc_attribute.c	Tue Jul  6 18:43:27 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: gcc_attribute.c,v 1.7 2021/07/06 17:33:07 rillig Exp $	*/
+/*	$NetBSD: gcc_attribute.c,v 1.8 2021/07/06 18:43:27 rillig Exp $	*/
 # 3 "gcc_attribute.c"
 
 /*
@@ -65,3 +65,22 @@ func(
 __attribute__((__noreturn__))
 __attribute__((__noreturn__))
 );
+
+/*
+ * https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html says that the
+ * attribute-list is a "possibly empty comma-separated sequence of
+ * attributes".
+ *
+ * No matter whether this particular example is interpreted as an empty list
+ * or a list containing a single empty attribute, the result is the same in
+ * both cases.
+ */
+void one_empty_attribute(void)
+__attribute__((/* none */));
+
+/*
+ * https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html further says that
+ * each individual attribute may be "Empty. Empty attributes are ignored".
+ */
+void two_empty_attributes(void)
+__attribute__((/* none */, /* still none */));



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

2021-07-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jul  6 06:38:29 UTC 2021

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

Log Message:
tests/lint: document wrong handling of GCC __attribute__


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

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/gcc_attribute.c
diff -u src/tests/usr.bin/xlint/lint1/gcc_attribute.c:1.5 src/tests/usr.bin/xlint/lint1/gcc_attribute.c:1.6
--- src/tests/usr.bin/xlint/lint1/gcc_attribute.c:1.5	Mon May  3 07:08:54 2021
+++ src/tests/usr.bin/xlint/lint1/gcc_attribute.c	Tue Jul  6 06:38:29 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: gcc_attribute.c,v 1.5 2021/05/03 07:08:54 rillig Exp $	*/
+/*	$NetBSD: gcc_attribute.c,v 1.6 2021/07/06 06:38:29 rillig Exp $	*/
 # 3 "gcc_attribute.c"
 
 /*
@@ -53,3 +53,21 @@ local_variable_pcs(void)
 	int pcs = 3;
 	return pcs;
 }
+
+/*
+ * FIXME: The attributes are handled by different grammar rules even though
+ *  they occur in the same syntactical position.
+ *
+ * Grammar rule abstract_decl_param_list handles the first attribute.
+ *
+ * Grammar rule direct_abstract_declarator handles all remaining attributes.
+ *
+ * Since abstract_decl_param_list contains type_attribute_opt, this could be
+ * the source of the many shift/reduce conflicts in the grammar.
+ */
+int
+func(
+int(int)
+__attribute__((__noreturn__))
+__attribute__((__noreturn__))
+);



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

2021-07-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jul  5 19:43:29 UTC 2021

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

Log Message:
tests/lint: fix typos in comment in expr_range


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

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/expr_range.c
diff -u src/tests/usr.bin/xlint/lint1/expr_range.c:1.2 src/tests/usr.bin/xlint/lint1/expr_range.c:1.3
--- src/tests/usr.bin/xlint/lint1/expr_range.c:1.2	Sat May 15 19:12:14 2021
+++ src/tests/usr.bin/xlint/lint1/expr_range.c	Mon Jul  5 19:43:29 2021
@@ -1,13 +1,13 @@
-/*	$NetBSD: expr_range.c,v 1.2 2021/05/15 19:12:14 rillig Exp $	*/
+/*	$NetBSD: expr_range.c,v 1.3 2021/07/05 19:43:29 rillig Exp $	*/
 # 3 "expr_range.c"
 
 /*
  * In a switch statement that has (expr & constant) as the controlling
- * expression, complain if one of the case branches is unreachable because
- * the case label does can never match the controlling expression.
+ * expression, complain if a case branch is unreachable because the case
+ * label can never match the controlling expression.
  *
  * GCC 10 does not complain about the unreachable branch.  It knows that the
- * branch is unreachable though since it doesn't generate any code for it.
+ * branch is unreachable though, since it doesn't generate any code for it.
  * GCC once had the option -Wunreachable-code, but that option was made a
  * no-op in 2011.
  *



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

2021-07-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jul  5 19:02:14 UTC 2021

Modified Files:
src/tests/usr.bin/xlint: check-expect.lua
src/tests/usr.bin/xlint/lint1: c99_bool_strict_suppressed.c

Log Message:
tests/lint: fix check-expect.lua for empty .exp file

An absent .exp file is equivalent to an empty .exp file.  In neither of
these cases must the corresponding .c file declare any expected
diagnostics.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/xlint/check-expect.lua
cvs rdiff -u -r1.2 -r1.3 \
src/tests/usr.bin/xlint/lint1/c99_bool_strict_suppressed.c

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

Modified files:

Index: src/tests/usr.bin/xlint/check-expect.lua
diff -u src/tests/usr.bin/xlint/check-expect.lua:1.9 src/tests/usr.bin/xlint/check-expect.lua:1.10
--- src/tests/usr.bin/xlint/check-expect.lua:1.9	Mon Jul  5 18:55:14 2021
+++ src/tests/usr.bin/xlint/check-expect.lua	Mon Jul  5 19:02:14 2021
@@ -1,5 +1,5 @@
 #!  /usr/bin/lua
--- $NetBSD: check-expect.lua,v 1.9 2021/07/05 18:55:14 rillig Exp $
+-- $NetBSD: check-expect.lua,v 1.10 2021/07/05 19:02:14 rillig Exp $
 
 --[[
 
@@ -76,7 +76,7 @@ end
 local function load_actual_messages_from_exp(exp_fname)
 
   local lines = load_lines(exp_fname)
-  if lines == nil then return nil end
+  if lines == nil then return {} end
 
   local messages = {}
   for exp_lineno, line in ipairs(lines) do

Index: src/tests/usr.bin/xlint/lint1/c99_bool_strict_suppressed.c
diff -u src/tests/usr.bin/xlint/lint1/c99_bool_strict_suppressed.c:1.2 src/tests/usr.bin/xlint/lint1/c99_bool_strict_suppressed.c:1.3
--- src/tests/usr.bin/xlint/lint1/c99_bool_strict_suppressed.c:1.2	Sun Jul  4 08:19:06 2021
+++ src/tests/usr.bin/xlint/lint1/c99_bool_strict_suppressed.c	Mon Jul  5 19:02:14 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: c99_bool_strict_suppressed.c,v 1.2 2021/07/04 08:19:06 rillig Exp $	*/
+/*	$NetBSD: c99_bool_strict_suppressed.c,v 1.3 2021/07/05 19:02:14 rillig Exp $	*/
 # 3 "c99_bool_strict_suppressed.c"
 
 /*
@@ -24,19 +24,19 @@ void
 test(_Bool b, int i, const char *p)
 {
 
-	/* expect+1: error: controlling expression must be bool, not 'int' [333] */
+	/* suppressed+1: error: controlling expression must be bool, not 'int' [333] */
 	while (1)
 		break;
 
-	/* expect+1: error: operands of '=' have incompatible types (_Bool != int) [107] */
+	/* suppressed+1: error: operands of '=' have incompatible types (_Bool != int) [107] */
 	b = i;
 
-	/* expect+1: error: operand of '!' must be bool, not 'int' [330] */
+	/* suppressed+1: error: operand of '!' must be bool, not 'int' [330] */
 	b = !i;
 
-	/* expect+1: error: left operand of '&&' must be bool, not 'int' [331] */
+	/* suppressed+1: error: left operand of '&&' must be bool, not 'int' [331] */
 	b = i && b;
 
-	/* expect+1: error: right operand of '&&' must be bool, not 'int' [332] */
+	/* suppressed+1: error: right operand of '&&' must be bool, not 'int' [332] */
 	b = b && i;
 }



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

2021-07-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Jul  5 18:55:14 UTC 2021

Modified Files:
src/tests/usr.bin/xlint: check-expect.lua

Log Message:
tests/lint: remove unused variables


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/xlint/check-expect.lua

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/check-expect.lua
diff -u src/tests/usr.bin/xlint/check-expect.lua:1.8 src/tests/usr.bin/xlint/check-expect.lua:1.9
--- src/tests/usr.bin/xlint/check-expect.lua:1.8	Thu Apr  8 22:18:27 2021
+++ src/tests/usr.bin/xlint/check-expect.lua	Mon Jul  5 18:55:14 2021
@@ -1,5 +1,5 @@
 #!  /usr/bin/lua
--- $NetBSD: check-expect.lua,v 1.8 2021/04/08 22:18:27 rillig Exp $
+-- $NetBSD: check-expect.lua,v 1.9 2021/07/05 18:55:14 rillig Exp $
 
 --[[
 
@@ -73,15 +73,14 @@ local function load_expect_comments_from
 end
 
 
-local function load_actual_messages_from_exp(exp_fname, primary_fname)
+local function load_actual_messages_from_exp(exp_fname)
 
   local lines = load_lines(exp_fname)
   if lines == nil then return nil end
 
   local messages = {}
   for exp_lineno, line in ipairs(lines) do
-for location, c_filename, c_lineno, message
- in line:gmatch("((%S+)%((%d+)%)): (.+)$") do
+for location, message in line:gmatch("(%S+%(%d+%)): (.+)$") do
   table.insert(messages, {
 exp_lineno = exp_lineno,
 location = location,
@@ -101,7 +100,7 @@ local function check_test(c_fname, error
 load_expect_comments_from_c(c_fname, errors)
   if comment_locations == nil then return end
 
-  local messages = load_actual_messages_from_exp(exp_fname, c_fname)
+  local messages = load_actual_messages_from_exp(exp_fname)
   if messages == nil then return end
 
   for _, act in ipairs(messages) do



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

2021-07-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul  4 17:32:24 UTC 2021

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

Log Message:
tests/lint: align tests for argument conversion to each other


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/xlint/lint1/msg_259.c
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/msg_259.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_259.c
diff -u src/tests/usr.bin/xlint/lint1/msg_259.c:1.8 src/tests/usr.bin/xlint/lint1/msg_259.c:1.9
--- src/tests/usr.bin/xlint/lint1/msg_259.c:1.8	Tue Jun 29 13:58:13 2021
+++ src/tests/usr.bin/xlint/lint1/msg_259.c	Sun Jul  4 17:32:24 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_259.c,v 1.8 2021/06/29 13:58:13 rillig Exp $	*/
+/*	$NetBSD: msg_259.c,v 1.9 2021/07/04 17:32:24 rillig Exp $	*/
 # 3 "msg_259.c"
 
 // Test for message: argument #%d is converted from '%s' to '%s' due to prototype [259]
@@ -15,11 +15,16 @@ example(char c, int i, long l)
 {
 	farg_char(c);
 	farg_int(c);
-	farg_long(c);		/* XXX: 259 on ILP32 but not LP64 */
+	/* No warning 259 on LP64, only on ILP32 */
+	farg_long(c);
+
 	farg_char(i);		/* XXX: why no warning? */
 	farg_int(i);
-	farg_long(i);		/* XXX: 259 on ILP32 but not LP64 */
+	/* No warning 259 on LP64, only on ILP32 */
+	farg_long(i);
+
 	farg_char(l);		/* XXX: why no warning? */
-	farg_int(l);		/* expect: 259 */
+	/* expect+1: from 'long' to 'int' due to prototype [259] */
+	farg_int(l);
 	farg_long(l);
 }

Index: src/tests/usr.bin/xlint/lint1/msg_259.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_259.exp:1.6 src/tests/usr.bin/xlint/lint1/msg_259.exp:1.7
--- src/tests/usr.bin/xlint/lint1/msg_259.exp:1.6	Tue Jun 29 09:19:17 2021
+++ src/tests/usr.bin/xlint/lint1/msg_259.exp	Sun Jul  4 17:32:24 2021
@@ -1 +1 @@
-msg_259.c(23): warning: argument #1 is converted from 'long' to 'int' due to prototype [259]
+msg_259.c(28): warning: argument #1 is converted from 'long' to 'int' due to prototype [259]



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

2021-07-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul  4 13:32:35 UTC 2021

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

Log Message:
tests/lint: document why lint does not need to detect wrong types


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_004.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_004.c
diff -u src/tests/usr.bin/xlint/lint1/msg_004.c:1.4 src/tests/usr.bin/xlint/lint1/msg_004.c:1.5
--- src/tests/usr.bin/xlint/lint1/msg_004.c:1.4	Mon Apr  5 01:35:34 2021
+++ src/tests/usr.bin/xlint/lint1/msg_004.c	Sun Jul  4 13:32:35 2021
@@ -1,9 +1,9 @@
-/*	$NetBSD: msg_004.c,v 1.4 2021/04/05 01:35:34 rillig Exp $	*/
+/*	$NetBSD: msg_004.c,v 1.5 2021/07/04 13:32:35 rillig Exp $	*/
 # 3 "msg_004.c"
 
 // Test for message: illegal type combination [4]
 
-// XXX: this goes undetected
+// Lint does not detect "two or more data types", but GCC does.
 signed double signed_double;
 
 int ok_int;



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

2021-07-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul  4 13:44:43 UTC 2021

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

Log Message:
tests/lint: fix unintended character constant in test

I originally intended to type ASCII DEL as an example of a nonprintable
character code.  The actual character that landed in the code was
instead U+2303 "house", which looks similar to the typical
representation of the DEL character.  The UTF-8 byte sequence for that
code point started with \xE2, or in octal \342.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_080.c \
src/tests/usr.bin/xlint/lint1/msg_080.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_080.c
diff -u src/tests/usr.bin/xlint/lint1/msg_080.c:1.3 src/tests/usr.bin/xlint/lint1/msg_080.c:1.4
--- src/tests/usr.bin/xlint/lint1/msg_080.c:1.3	Tue Jun 29 07:17:43 2021
+++ src/tests/usr.bin/xlint/lint1/msg_080.c	Sun Jul  4 13:44:43 2021
@@ -1,9 +1,7 @@
-/*	$NetBSD: msg_080.c,v 1.3 2021/06/29 07:17:43 rillig Exp $	*/
+/*	$NetBSD: msg_080.c,v 1.4 2021/07/04 13:44:43 rillig Exp $	*/
 # 3 "msg_080.c"
 
 // Test for message: dubious escape \%o [80]
 
-/* expect+3: dubious escape \342 [80] */ /* FIXME: Why 342? */
-/* expect+2: multi-character character constant [294] */
-/* expect+1: initializer does not fit */
-char backslash_delete = '\โŒ‚';
+/* expect+1: dubious escape \177 [80] */
+char backslash_delete = '\';
Index: src/tests/usr.bin/xlint/lint1/msg_080.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_080.exp:1.3 src/tests/usr.bin/xlint/lint1/msg_080.exp:1.4
--- src/tests/usr.bin/xlint/lint1/msg_080.exp:1.3	Tue Jun 29 07:17:43 2021
+++ src/tests/usr.bin/xlint/lint1/msg_080.exp	Sun Jul  4 13:44:43 2021
@@ -1,3 +1 @@
-msg_080.c(9): warning: dubious escape \342 [80]
-msg_080.c(9): warning: multi-character character constant [294]
-msg_080.c(9): warning: initializer does not fit [178]
+msg_080.c(7): warning: dubious escape \177 [80]



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

2021-07-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jul  4 08:50:26 UTC 2021

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

Log Message:
tests/lint: re-enable test c99_bool_strict_suppressed

It had been disabled accidentally in the previous commit.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/tests/usr.bin/xlint/lint1/Makefile

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/Makefile
diff -u src/tests/usr.bin/xlint/lint1/Makefile:1.76 src/tests/usr.bin/xlint/lint1/Makefile:1.77
--- src/tests/usr.bin/xlint/lint1/Makefile:1.76	Sun Jul  4 08:19:06 2021
+++ src/tests/usr.bin/xlint/lint1/Makefile	Sun Jul  4 08:50:26 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.76 2021/07/04 08:19:06 rillig Exp $
+# $NetBSD: Makefile,v 1.77 2021/07/04 08:50:26 rillig Exp $
 
 NOMAN=		# defined
 MAX_MESSAGE=	345		# see lint1/err.c
@@ -12,6 +12,7 @@ TESTS_SH=	t_integration
 FILESDIR=	${TESTSDIR}
 FILES+=		c11_generic_expression.c
 FILES+=		c11_generic_expression.exp
+FILES+=		c99_bool_strict_suppressed.c
 FILES+=		c99_init_array.c
 FILES+=		c99_init_array.exp
 FILES+=		c99_init_designator.c



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

2021-07-03 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Jul  3 19:34:47 UTC 2021

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

Log Message:
tests/lint: fix test d_cast_init on macppc

On macppc, char == unsigned, which generated the following unintended
warnings:

d_cast_init.c(18): warning: initialization of unsigned with negative
constant [221]
d_cast_init.c(18): warning: initialization of unsigned with negative
constant [221]
d_cast_init.c(18): warning: initialization of unsigned with negative
constant [221]
d_cast_init.c(18): warning: initialization of unsigned with negative
constant [221]


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/d_cast_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_cast_init.c
diff -u src/tests/usr.bin/xlint/lint1/d_cast_init.c:1.4 src/tests/usr.bin/xlint/lint1/d_cast_init.c:1.5
--- src/tests/usr.bin/xlint/lint1/d_cast_init.c:1.4	Sun Jan 31 14:57:28 2021
+++ src/tests/usr.bin/xlint/lint1/d_cast_init.c	Sat Jul  3 19:34:47 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: d_cast_init.c,v 1.4 2021/01/31 14:57:28 rillig Exp $	*/
+/*	$NetBSD: d_cast_init.c,v 1.5 2021/07/03 19:34:47 rillig Exp $	*/
 # 3 "d_cast_init.c"
 
 /* cast initialization */
@@ -8,7 +8,7 @@ typedef unsigned char u_char;
 struct sockaddr_x25 {
 	u_char x25_len;
 	u_char x25_family;
-	char x25_udata[4];
+	signed char x25_udata[4];
 };
 
 struct sockaddr_x25 x25_dgmask = {



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

2021-07-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jul  2 23:29:54 UTC 2021

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

Log Message:
tests/lint: encode the array length in the diagnostic


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/c99_init_array.c \
src/tests/usr.bin/xlint/lint1/c99_init_array.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/c99_init_array.c
diff -u src/tests/usr.bin/xlint/lint1/c99_init_array.c:1.2 src/tests/usr.bin/xlint/lint1/c99_init_array.c:1.3
--- src/tests/usr.bin/xlint/lint1/c99_init_array.c:1.2	Fri Jul  2 22:46:43 2021
+++ src/tests/usr.bin/xlint/lint1/c99_init_array.c	Fri Jul  2 23:29:54 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: c99_init_array.c,v 1.2 2021/07/02 22:46:43 rillig Exp $	*/
+/*	$NetBSD: c99_init_array.c,v 1.3 2021/07/02 23:29:54 rillig Exp $	*/
 # 3 "c99_init_array.c"
 
 /*
@@ -10,10 +10,10 @@
 // The size of the array is determined by the maximum index, not by the last
 // one mentioned.
 int arr_11[] = { [10] = 10, [0] = 0 };
-typedef int ctassert_11[sizeof(arr_11) / sizeof(arr_11[0]) == 11 ? -1 : 1];
-/* expect-1: error: negative array dimension (-1) [20] */
+typedef int ctassert_11[-(int)(sizeof(arr_11) / sizeof(arr_11[0]))];
+/* expect-1: error: negative array dimension (-11) [20] */
 
 // Without an explicit subscript designator, the subscript counts up.
 int arr_3[] = { [1] = 1, [0] = 0, 1, 2 };
-typedef int ctassert_3[sizeof(arr_3) / sizeof(arr_3[0]) == 3 ? -1 : 1];
-/* expect-1: error: negative array dimension (-1) [20] */
+typedef int ctassert_3[-(int)(sizeof(arr_3) / sizeof(arr_3[0]))];
+/* expect-1: error: negative array dimension (-3) [20] */
Index: src/tests/usr.bin/xlint/lint1/c99_init_array.exp
diff -u src/tests/usr.bin/xlint/lint1/c99_init_array.exp:1.2 src/tests/usr.bin/xlint/lint1/c99_init_array.exp:1.3
--- src/tests/usr.bin/xlint/lint1/c99_init_array.exp:1.2	Fri Jul  2 22:46:43 2021
+++ src/tests/usr.bin/xlint/lint1/c99_init_array.exp	Fri Jul  2 23:29:54 2021
@@ -1,2 +1,2 @@
-c99_init_array.c(13): error: negative array dimension (-1) [20]
-c99_init_array.c(18): error: negative array dimension (-1) [20]
+c99_init_array.c(13): error: negative array dimension (-11) [20]
+c99_init_array.c(18): error: negative array dimension (-3) [20]



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

2021-06-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Jun 30 14:15:39 UTC 2021

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

Log Message:
tests/lint: extend test for message 215 about implicit function


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_215.c \
src/tests/usr.bin/xlint/lint1/msg_215.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_215.c
diff -u src/tests/usr.bin/xlint/lint1/msg_215.c:1.5 src/tests/usr.bin/xlint/lint1/msg_215.c:1.6
--- src/tests/usr.bin/xlint/lint1/msg_215.c:1.5	Wed Jun 30 14:11:08 2021
+++ src/tests/usr.bin/xlint/lint1/msg_215.c	Wed Jun 30 14:15:39 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_215.c,v 1.5 2021/06/30 14:11:08 rillig Exp $	*/
+/*	$NetBSD: msg_215.c,v 1.6 2021/06/30 14:15:39 rillig Exp $	*/
 # 3 "msg_215.c"
 
 // Test for message: function implicitly declared to return int [215]
@@ -20,6 +20,10 @@ test(struct str str)
 	/* expect+1: error: function implicitly declared to return int [215] */
 	name();
 
+	/* expect+2: error: 'parenthesized' undefined [99] */
+	/* expect+1: error: illegal function (type int) [149] */
+	(parenthesized)();
+
 	/* expect+2: error: type 'struct str' does not have member 'member' [101] */
 	/* expect+1: error: illegal function (type int) [149] */
 	str.member();
Index: src/tests/usr.bin/xlint/lint1/msg_215.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_215.exp:1.5 src/tests/usr.bin/xlint/lint1/msg_215.exp:1.6
--- src/tests/usr.bin/xlint/lint1/msg_215.exp:1.5	Wed Jun 30 14:11:08 2021
+++ src/tests/usr.bin/xlint/lint1/msg_215.exp	Wed Jun 30 14:15:39 2021
@@ -1,3 +1,5 @@
 msg_215.c(21): error: function implicitly declared to return int [215]
-msg_215.c(25): error: type 'struct str' does not have member 'member' [101]
+msg_215.c(25): error: 'parenthesized' undefined [99]
 msg_215.c(25): error: illegal function (type int) [149]
+msg_215.c(29): error: type 'struct str' does not have member 'member' [101]
+msg_215.c(29): error: illegal function (type int) [149]



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

2021-06-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Jun 30 14:02:11 UTC 2021

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

Log Message:
tests/lint: extend tests for message 101

This demonstrates the wrong type name in the message.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_101.c \
src/tests/usr.bin/xlint/lint1/msg_101.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_101.c
diff -u src/tests/usr.bin/xlint/lint1/msg_101.c:1.4 src/tests/usr.bin/xlint/lint1/msg_101.c:1.5
--- src/tests/usr.bin/xlint/lint1/msg_101.c:1.4	Tue Mar 30 15:18:19 2021
+++ src/tests/usr.bin/xlint/lint1/msg_101.c	Wed Jun 30 14:02:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_101.c,v 1.4 2021/03/30 15:18:19 rillig Exp $	*/
+/*	$NetBSD: msg_101.c,v 1.5 2021/06/30 14:02:11 rillig Exp $	*/
 # 3 "msg_101.c"
 
 // Test for message: type '%s' does not have member '%s' [101]
@@ -7,8 +7,36 @@ struct point {
 	int x, y;
 };
 
-int
-get_z(const struct point *p)
+void sink(int);
+
+void
+test(const struct point *ptr, const struct point pt)
 {
-	return p.z;		/* expect: 101 */
+	/* accessing an existing member */
+	sink(ptr->x);
+	sink(pt.x);
+
+	/* accessing a nonexistent member */
+	/* FIXME: "type 'int'" is wrong. */
+	/* expect+1: error: type 'int' does not have member 'z' [101] */
+	sink(ptr->z);
+	/* FIXME: "type 'int'" is wrong. */
+	/* expect+1: error: type 'int' does not have member 'z' [101] */
+	sink(pt.z);
+
+	/* mixed up '.' and '->' */
+	/* TODO: mention actual type in the diagnostic */
+	/* expect+1: error: left operand of '.' must be struct/union object [103] */
+	sink(ptr.x);
+	/* TODO: put actual type in 'quotes' */
+	/* expect+1: error: left operand of '->' must be pointer to struct/union not struct point [104] */
+	sink(pt->x);
+
+	/* accessing a nonexistent member via the wrong operator */
+	/* FIXME: "type 'int'" is wrong. */
+	/* expect+1: error: type 'int' does not have member 'z' [101] */
+	sink(ptr.z);
+	/* FIXME: "type 'int'" is wrong. */
+	/* expect+1: error: type 'int' does not have member 'z' [101] */
+	sink(pt->z);
 }
Index: src/tests/usr.bin/xlint/lint1/msg_101.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_101.exp:1.4 src/tests/usr.bin/xlint/lint1/msg_101.exp:1.5
--- src/tests/usr.bin/xlint/lint1/msg_101.exp:1.4	Tue Mar 30 15:18:19 2021
+++ src/tests/usr.bin/xlint/lint1/msg_101.exp	Wed Jun 30 14:02:11 2021
@@ -1 +1,6 @@
-msg_101.c(13): error: type 'int' does not have member 'z' [101]
+msg_101.c(22): error: type 'int' does not have member 'z' [101]
+msg_101.c(25): error: type 'int' does not have member 'z' [101]
+msg_101.c(30): error: left operand of '.' must be struct/union object [103]
+msg_101.c(33): error: left operand of '->' must be pointer to struct/union not struct point [104]
+msg_101.c(38): error: type 'int' does not have member 'z' [101]
+msg_101.c(41): error: type 'int' does not have member 'z' [101]



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

2021-06-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Jun 30 13:50:15 UTC 2021

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

Log Message:
tests/lint: extend and explain test for implicit function declaration


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_215.c \
src/tests/usr.bin/xlint/lint1/msg_215.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_215.c
diff -u src/tests/usr.bin/xlint/lint1/msg_215.c:1.3 src/tests/usr.bin/xlint/lint1/msg_215.c:1.4
--- src/tests/usr.bin/xlint/lint1/msg_215.c:1.3	Mon Jun 28 11:27:00 2021
+++ src/tests/usr.bin/xlint/lint1/msg_215.c	Wed Jun 30 13:50:15 2021
@@ -1,10 +1,27 @@
-/*	$NetBSD: msg_215.c,v 1.3 2021/06/28 11:27:00 rillig Exp $	*/
+/*	$NetBSD: msg_215.c,v 1.4 2021/06/30 13:50:15 rillig Exp $	*/
 # 3 "msg_215.c"
 
 // Test for message: function implicitly declared to return int [215]
 
+/*
+ * In traditional C and C90, it was possible to implicitly declare a function
+ * by just calling it, without defining a prototype first.  Such a function
+ * would then be defined as taking unspecified parameters and returning int.
+ */
+
+struct str {
+	int dummy;
+};
+
+/* ARGSUSED */
 void
-caller(void)
+test(struct str str)
 {
-	callee(12345);		/* expect: [215] */
+	/* expect+1: error: function implicitly declared to return int [215] */
+	name();
+
+	/* FIXME: "type 'int'" sounds wrong. */
+	/* expect+2: error: type 'int' does not have member 'member' [101] */
+	/* expect+1: error: illegal function (type int) [149] */
+	str.member();
 }
Index: src/tests/usr.bin/xlint/lint1/msg_215.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_215.exp:1.3 src/tests/usr.bin/xlint/lint1/msg_215.exp:1.4
--- src/tests/usr.bin/xlint/lint1/msg_215.exp:1.3	Mon Jun 28 11:27:00 2021
+++ src/tests/usr.bin/xlint/lint1/msg_215.exp	Wed Jun 30 13:50:15 2021
@@ -1 +1,3 @@
-msg_215.c(9): error: function implicitly declared to return int [215]
+msg_215.c(21): error: function implicitly declared to return int [215]
+msg_215.c(26): error: type 'int' does not have member 'member' [101]
+msg_215.c(26): error: illegal function (type int) [149]



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

2021-06-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Jun 30 12:26:35 UTC 2021

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

Log Message:
tests/lint: add test for type name of enum converted to int


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/msg_155.c \
src/tests/usr.bin/xlint/lint1/msg_155.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_155.c
diff -u src/tests/usr.bin/xlint/lint1/msg_155.c:1.7 src/tests/usr.bin/xlint/lint1/msg_155.c:1.8
--- src/tests/usr.bin/xlint/lint1/msg_155.c:1.7	Mon Jun 28 11:27:00 2021
+++ src/tests/usr.bin/xlint/lint1/msg_155.c	Wed Jun 30 12:26:35 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_155.c,v 1.7 2021/06/28 11:27:00 rillig Exp $	*/
+/*	$NetBSD: msg_155.c,v 1.8 2021/06/30 12:26:35 rillig Exp $	*/
 # 3 "msg_155.c"
 
 // Test for message: passing '%s' to incompatible '%s', arg #%d [155]
@@ -46,3 +46,33 @@ provoke_error_messages(struct incompatib
 	/* expect+1: 'pointer to const pointer to function(unsigned int, ...) returning int' */
 	c99_6_7_6_example_h(arg);
 }
+
+extern void sink(struct incompatible);
+
+/*
+ * The function type_name has a special case for an enum type that has been
+ * implicitly converted to an int.  Such a type is still output as the enum
+ * type.
+ *
+ * XXX: The expressions 'day + 0' and '0 + day' should result in the same
+ *  type.
+ */
+void
+type_name_of_enum(void)
+{
+	enum Day {
+		MONDAY
+	} day = MONDAY;
+
+	/* expect+1: passing 'enum Day' */
+	sink(day);
+
+	/* expect+1: passing 'enum Day' */
+	sink(day + 0);
+
+	/* expect+1: passing 'int' */
+	sink(0 + day);
+
+	/* expect+1: passing 'int' */
+	sink(0);
+}
Index: src/tests/usr.bin/xlint/lint1/msg_155.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_155.exp:1.7 src/tests/usr.bin/xlint/lint1/msg_155.exp:1.8
--- src/tests/usr.bin/xlint/lint1/msg_155.exp:1.7	Mon Jun 28 11:27:00 2021
+++ src/tests/usr.bin/xlint/lint1/msg_155.exp	Wed Jun 30 12:26:35 2021
@@ -6,3 +6,7 @@ msg_155.c(38): warning: passing 'struct 
 msg_155.c(41): error: function implicitly declared to return int [215]
 msg_155.c(44): warning: passing 'struct incompatible' to incompatible 'pointer to function(void) returning int', arg #1 [155]
 msg_155.c(47): warning: passing 'struct incompatible' to incompatible 'pointer to const pointer to function(unsigned int, ...) returning int', arg #1 [155]
+msg_155.c(68): warning: passing 'enum Day' to incompatible 'struct incompatible', arg #1 [155]
+msg_155.c(71): warning: passing 'enum Day' to incompatible 'struct incompatible', arg #1 [155]
+msg_155.c(74): warning: passing 'int' to incompatible 'struct incompatible', arg #1 [155]
+msg_155.c(77): warning: passing 'int' to incompatible 'struct incompatible', arg #1 [155]



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

2021-06-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jun 29 09:44:25 UTC 2021

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

Log Message:
tests/lint: add 'make accept' to update the expected output


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/tests/usr.bin/xlint/lint1/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint1/accept.sh

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/Makefile
diff -u src/tests/usr.bin/xlint/lint1/Makefile:1.69 src/tests/usr.bin/xlint/lint1/Makefile:1.70
--- src/tests/usr.bin/xlint/lint1/Makefile:1.69	Tue Jun 29 09:19:17 2021
+++ src/tests/usr.bin/xlint/lint1/Makefile	Tue Jun 29 09:44:25 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.69 2021/06/29 09:19:17 rillig Exp $
+# $NetBSD: Makefile,v 1.70 2021/06/29 09:44:25 rillig Exp $
 
 NOMAN=		# defined
 MAX_MESSAGE=	345		# see lint1/err.c
@@ -161,4 +161,7 @@ sync-mi: .PHONY
 	mv "$$mi.tmp" "$$mi";		\
 	cvs diff "$$mi" || true
 
+accept: .PHONY
+	@sh ./accept.sh ''
+
 .include 

Added files:

Index: src/tests/usr.bin/xlint/lint1/accept.sh
diff -u /dev/null src/tests/usr.bin/xlint/lint1/accept.sh:1.1
--- /dev/null	Tue Jun 29 09:44:25 2021
+++ src/tests/usr.bin/xlint/lint1/accept.sh	Tue Jun 29 09:44:25 2021
@@ -0,0 +1,90 @@
+#! /bin/sh
+# $NetBSD: accept.sh,v 1.1 2021/06/29 09:44:25 rillig Exp $
+#
+# Copyright (c) 2021 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#notice, this list of conditions and the following disclaimer in the
+#documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+# usage: accept.sh ...
+#
+#	Accept the actual output from running the lint tests and save them
+#	back into the .exp files.
+
+set -eu
+
+. './t_integration.sh'
+
+for pattern in "$@"; do
+	for test in *$pattern*.c; do
+		base=${test%.*}
+		cfile="$base.c"
+		expfile="$base.exp"
+		tmpfile="$base.exp.tmp"
+		ln_file="$base.ln"
+
+		configure_test_case "$cfile"
+		if [ $skip = yes ]; then
+			continue
+		fi
+
+		if [ ! -f "$ln_file" ]; then
+			ln_file='/dev/null'
+		fi
+
+		if "$lint1" $flags "$base.c" "$ln_file" > "$tmpfile"; then
+			if [ -s "$tmpfile" ]; then
+echo "$base produces output but exits successfully"
+sed 's,^,| ,' "$tmpfile"
+			fi
+			rm -f "$expfile" "$tmpfile"
+		else
+			if [ -f "$tmpfile" ] && cmp -s "$tmpfile" "$expfile"; then
+rm "$tmpfile"
+			else
+echo "replacing $base"
+mv "$tmpfile" "$expfile"
+			fi
+		fi
+
+		case "$base" in (msg_*)
+			if [ ! -f "$expfile" ]; then
+echo "$base should produce warnings"
+			elif grep '^TODO: "Add example code' "$base.c" >/dev/null; then
+: 'ok, this test is not yet written'
+			else
+msgid=${base}
+msgid=${msgid#msg_00}
+msgid=${msgid#msg_0}
+msgid=${msgid#msg_}
+msgid=${msgid%_*}
+if ! grep "\\[$msgid\\]" "$expfile" >/dev/null; then
+	echo "$base should trigger the message '$msgid'"
+fi
+			fi
+		esac
+
+	done
+done
+
+lua '../check-expect.lua' *.c



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

2021-06-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jun 29 08:46:10 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: lex_integer.c t_integration.sh

Log Message:
tests/lint: allow tests to be skipped depending on platform properties


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/lex_integer.c
cvs rdiff -u -r1.63 -r1.64 src/tests/usr.bin/xlint/lint1/t_integration.sh

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/lex_integer.c
diff -u src/tests/usr.bin/xlint/lint1/lex_integer.c:1.2 src/tests/usr.bin/xlint/lint1/lex_integer.c:1.3
--- src/tests/usr.bin/xlint/lint1/lex_integer.c:1.2	Sun Jun 27 10:14:43 2021
+++ src/tests/usr.bin/xlint/lint1/lex_integer.c	Tue Jun 29 08:46:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lex_integer.c,v 1.2 2021/06/27 10:14:43 rillig Exp $	*/
+/*	$NetBSD: lex_integer.c,v 1.3 2021/06/29 08:46:10 rillig Exp $	*/
 # 3 "lex_integer.c"
 
 /*
@@ -7,7 +7,7 @@
  * C99 6.4.4.1 "Integer constants"
  */
 
-/* lint1-not-on-arch: i386 (has 32-bit long) */
+/* lint1-only-on-lp64 */
 
 void sinki(int);
 void sinku(unsigned int);

Index: src/tests/usr.bin/xlint/lint1/t_integration.sh
diff -u src/tests/usr.bin/xlint/lint1/t_integration.sh:1.63 src/tests/usr.bin/xlint/lint1/t_integration.sh:1.64
--- src/tests/usr.bin/xlint/lint1/t_integration.sh:1.63	Sun Jun 27 19:41:15 2021
+++ src/tests/usr.bin/xlint/lint1/t_integration.sh	Tue Jun 29 08:46:10 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.63 2021/06/27 19:41:15 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.64 2021/06/29 08:46:10 rillig Exp $
 #
 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -36,24 +36,45 @@ configure_test_case()
 
 	# shellcheck disable=SC2016
 	awk='
+		function is_ilp32() {
+			return match(machine_arch, /^(arm|coldfire|hppa|i386|m68000|m68k|mips|mips64|or1k|powerpc|riscv32|sh3|sparc|vax)$/)
+		}
+
+		function is_lp64() {
+			return match(machine_arch, /^(aarch64|alpha|ia64|mipsn64|powerpc64|riscv64|sparc64|x86_64)$/)
+		}
+
 		BEGIN {
 			machine_arch = "'"$machine_arch"'"
 			flags = "-g -S -w"
+			seen_only_on_arch = 0
+			match_only_on_arch = 0
 			skip = 0
 		}
-		/^\/\* (lint1-flags|lint1-extra-flags): .*\*\/$/ {
-			if ($2 == "lint1-flags:")
-flags = ""
-			for (i = 3; i < NF; i++)
-flags = flags " " $i
-		}
-		/^\/\* lint1-only-on-arch: .* \*\/$/ && $3 != machine_arch {
-			skip = 1
-		}
-		/^\/\* lint1-not-on-arch: .* \*\/$/ && $3 == machine_arch {
-			skip = 1
+		$1 == "/*" && $2 ~ /^lint1-/ && $NF == "*/" {
+			if ($2 == "lint1-flags:" || $2 == "lint1-extra-flags:") {
+if ($2 == "lint1-flags:")
+	flags = ""
+for (i = 3; i < NF; i++)
+	flags = flags " " $i
+			}
+			if ($2 == "lint1-only-on-arch") {
+seen_only_on_arch = 1
+if ($3 == machine_arch)
+	match_only_on_arch = 1
+			}
+			if ($2 == "lint1-not-on-arch" && $3 == machine_arch)
+skip = 1
+			if ($2 == "lint1-only-on-ilp32" && !is_ilp32())
+skip = 1
+			if ($2 == "lint1-only-on-lp64" && !is_lp64())
+skip = 1
 		}
+
 		END {
+			if (seen_only_on_arch && !match_only_on_arch)
+skip = 1
+
 			printf("flags='\''%s'\''\n", flags)
 			printf("skip=%s\n", skip ? "yes" : "no")
 		}



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

2021-06-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jun 29 07:28:02 UTC 2021

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

Log Message:
tests/lint: add test for character constant using backslash-newline


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/lex_char.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/lex_char.c
diff -u src/tests/usr.bin/xlint/lint1/lex_char.c:1.3 src/tests/usr.bin/xlint/lint1/lex_char.c:1.4
--- src/tests/usr.bin/xlint/lint1/lex_char.c:1.3	Tue Jun 29 07:17:43 2021
+++ src/tests/usr.bin/xlint/lint1/lex_char.c	Tue Jun 29 07:28:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lex_char.c,v 1.3 2021/06/29 07:17:43 rillig Exp $	*/
+/*	$NetBSD: lex_char.c,v 1.4 2021/06/29 07:28:01 rillig Exp $	*/
 # 3 "lex_char.c"
 
 /*
@@ -58,3 +58,14 @@ test(void)
 	/* U+000D carriage return */
 	sink('\r');
 }
+
+/*
+ * Even though backslash-newline is not supported by C99, lint accepts it
+ * in any mode, even for traditional C.
+ */
+char ch = '\
+\
+\
+\
+\
+x';



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

2021-06-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jun 29 07:17:43 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: lex_char.c lex_char.exp msg_076.c
msg_076.exp msg_077.c msg_077.exp msg_080.c msg_080.exp msg_082.c
msg_250.c msg_250.exp msg_251.c msg_251.exp msg_253.c msg_253.exp
msg_254.c msg_254.exp msg_262.c msg_262.exp msg_263.c msg_263.exp

Log Message:
tests/lint: add tests for the lexical analysis


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/lex_char.c \
src/tests/usr.bin/xlint/lint1/lex_char.exp \
src/tests/usr.bin/xlint/lint1/msg_076.c \
src/tests/usr.bin/xlint/lint1/msg_076.exp \
src/tests/usr.bin/xlint/lint1/msg_077.c \
src/tests/usr.bin/xlint/lint1/msg_077.exp \
src/tests/usr.bin/xlint/lint1/msg_080.c \
src/tests/usr.bin/xlint/lint1/msg_080.exp \
src/tests/usr.bin/xlint/lint1/msg_250.c \
src/tests/usr.bin/xlint/lint1/msg_250.exp \
src/tests/usr.bin/xlint/lint1/msg_251.c \
src/tests/usr.bin/xlint/lint1/msg_251.exp \
src/tests/usr.bin/xlint/lint1/msg_253.c \
src/tests/usr.bin/xlint/lint1/msg_253.exp \
src/tests/usr.bin/xlint/lint1/msg_254.c \
src/tests/usr.bin/xlint/lint1/msg_254.exp \
src/tests/usr.bin/xlint/lint1/msg_262.c \
src/tests/usr.bin/xlint/lint1/msg_262.exp \
src/tests/usr.bin/xlint/lint1/msg_263.c \
src/tests/usr.bin/xlint/lint1/msg_263.exp
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_082.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/lex_char.c
diff -u src/tests/usr.bin/xlint/lint1/lex_char.c:1.2 src/tests/usr.bin/xlint/lint1/lex_char.c:1.3
--- src/tests/usr.bin/xlint/lint1/lex_char.c:1.2	Sun Jun 20 18:23:07 2021
+++ src/tests/usr.bin/xlint/lint1/lex_char.c	Tue Jun 29 07:17:43 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lex_char.c,v 1.2 2021/06/20 18:23:07 rillig Exp $	*/
+/*	$NetBSD: lex_char.c,v 1.3 2021/06/29 07:17:43 rillig Exp $	*/
 # 3 "lex_char.c"
 
 /*
@@ -34,9 +34,27 @@ test(void)
 	/* octal */
 	sink('\177');
 
-	/* newline */
-	sink('\n');
-
 	/* expect+1: empty character constant */
 	sink('');
+
+	/* U+0007 alarm/bell */
+	sink('\a');
+
+	/* U+0008 backspace */
+	sink('\b');
+
+	/* U+0009 horizontal tabulation */
+	sink('\t');
+
+	/* U+000A line feed */
+	sink('\n');
+
+	/* U+000B vertical tabulation */
+	sink('\v');
+
+	/* U+000C form feed */
+	sink('\f');
+
+	/* U+000D carriage return */
+	sink('\r');
 }
Index: src/tests/usr.bin/xlint/lint1/lex_char.exp
diff -u src/tests/usr.bin/xlint/lint1/lex_char.exp:1.2 src/tests/usr.bin/xlint/lint1/lex_char.exp:1.3
--- src/tests/usr.bin/xlint/lint1/lex_char.exp:1.2	Sun Jun 20 18:23:07 2021
+++ src/tests/usr.bin/xlint/lint1/lex_char.exp	Tue Jun 29 07:17:43 2021
@@ -2,4 +2,4 @@ lex_char.c(16): error: empty character c
 lex_char.c(25): warning: multi-character character constant [294]
 lex_char.c(25): warning: conversion of 'int' to 'char' is out of range, arg #1 [295]
 lex_char.c(29): warning: dubious escape \e [79]
-lex_char.c(41): error: empty character constant [73]
+lex_char.c(38): error: empty character constant [73]
Index: src/tests/usr.bin/xlint/lint1/msg_076.c
diff -u src/tests/usr.bin/xlint/lint1/msg_076.c:1.2 src/tests/usr.bin/xlint/lint1/msg_076.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_076.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_076.c	Tue Jun 29 07:17:43 2021
@@ -1,7 +1,6 @@
-/*	$NetBSD: msg_076.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_076.c,v 1.3 2021/06/29 07:17:43 rillig Exp $	*/
 # 3 "msg_076.c"
 
 // Test for message: character escape does not fit in character [76]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+char ch = '\777';		/* expect: [76] */
Index: src/tests/usr.bin/xlint/lint1/msg_076.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_076.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_076.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_076.exp:1.2	Sun Mar 21 20:44:59 2021
+++ src/tests/usr.bin/xlint/lint1/msg_076.exp	Tue Jun 29 07:17:43 2021
@@ -1 +1 @@
-msg_076.c(6): error: syntax error ':' [249]
+msg_076.c(6): warning: character escape does not fit in character [76]
Index: src/tests/usr.bin/xlint/lint1/msg_077.c
diff -u src/tests/usr.bin/xlint/lint1/msg_077.c:1.2 src/tests/usr.bin/xlint/lint1/msg_077.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_077.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_077.c	Tue Jun 29 07:17:43 2021
@@ -1,7 +1,25 @@
-/*	$NetBSD: msg_077.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_077.c,v 1.3 2021/06/29 07:17:43 rillig Exp $	*/
 # 3 "msg_077.c"
 
-// Test for message: bad octal digit %c [77]
+/* Test for message: bad octal digit %c [77] */
 
-TODO: "Add example code that triggers the above message." 

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

2021-06-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 27 19:59:23 UTC 2021

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

Log Message:
tests/lint: add test for _Generic with incompatible return types


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/tests/usr.bin/xlint/lint1/c11_generic_expression.c \
src/tests/usr.bin/xlint/lint1/c11_generic_expression.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/c11_generic_expression.c
diff -u src/tests/usr.bin/xlint/lint1/c11_generic_expression.c:1.1 src/tests/usr.bin/xlint/lint1/c11_generic_expression.c:1.2
--- src/tests/usr.bin/xlint/lint1/c11_generic_expression.c:1.1	Sun Jun 27 18:48:45 2021
+++ src/tests/usr.bin/xlint/lint1/c11_generic_expression.c	Sun Jun 27 19:59:23 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: c11_generic_expression.c,v 1.1 2021/06/27 18:48:45 rillig Exp $	*/
+/*	$NetBSD: c11_generic_expression.c,v 1.2 2021/06/27 19:59:23 rillig Exp $	*/
 # 3 "c11_generic_expression.c"
 
 /*
@@ -18,7 +18,7 @@
  * generic-association.  This is a compile-time error.
  */
 const char *
-classify_integer_without_default(double var)
+classify_type_without_default(double var)
 {
 	return _Generic(var,
 	long double: "long double",
@@ -33,7 +33,7 @@ classify_integer_without_default(double 
  * In this case, the 'default' expression is selected.
  */
 const char *
-classify_integer_with_default(double var)
+classify_type_with_default(double var)
 {
 	return _Generic(var,
 	long double: "long double",
@@ -44,3 +44,16 @@ classify_integer_with_default(double var
 	/* expect-8: argument 'var' unused */
 	/* expect-2: type mismatch (pointer to const char) and (double) *//* FIXME */
 }
+
+/*
+ * The type of a _Generic expression is the one from the selected association.
+ */
+const char *
+classify_char(char c)
+{
+	return _Generic(c,
+	char: "yes",
+	default: 0.0
+	);
+	/* expect-1: (pointer to const char) and integer (char) [183] */
+}
Index: src/tests/usr.bin/xlint/lint1/c11_generic_expression.exp
diff -u src/tests/usr.bin/xlint/lint1/c11_generic_expression.exp:1.1 src/tests/usr.bin/xlint/lint1/c11_generic_expression.exp:1.2
--- src/tests/usr.bin/xlint/lint1/c11_generic_expression.exp:1.1	Sun Jun 27 18:48:45 2021
+++ src/tests/usr.bin/xlint/lint1/c11_generic_expression.exp	Sun Jun 27 19:59:23 2021
@@ -1,4 +1,5 @@
 c11_generic_expression.c(27): error: return value type mismatch (pointer to const char) and (double) [211]
-c11_generic_expression.c(21): warning: argument 'var' unused in function 'classify_integer_without_default' [231]
+c11_generic_expression.c(21): warning: argument 'var' unused in function 'classify_type_without_default' [231]
 c11_generic_expression.c(43): error: return value type mismatch (pointer to const char) and (double) [211]
-c11_generic_expression.c(36): warning: argument 'var' unused in function 'classify_integer_with_default' [231]
+c11_generic_expression.c(36): warning: argument 'var' unused in function 'classify_type_with_default' [231]
+c11_generic_expression.c(57): warning: illegal combination of pointer (pointer to const char) and integer (char) [183]



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

2021-06-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 27 19:41:15 UTC 2021

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

Log Message:
tests/lint: fix selection of the .exp-ln file

Since t_integration.sh 1.58 from today, the expected .ln output was not
detected anymore.  Changes to the file format would have gone unnoticed.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/tests/usr.bin/xlint/lint1/t_integration.sh

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/t_integration.sh
diff -u src/tests/usr.bin/xlint/lint1/t_integration.sh:1.62 src/tests/usr.bin/xlint/lint1/t_integration.sh:1.63
--- src/tests/usr.bin/xlint/lint1/t_integration.sh:1.62	Sun Jun 27 19:33:25 2021
+++ src/tests/usr.bin/xlint/lint1/t_integration.sh	Sun Jun 27 19:41:15 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.62 2021/06/27 19:33:25 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.63 2021/06/27 19:41:15 rillig Exp $
 #
 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -67,7 +67,7 @@ check_lint1()
 {
 	local src="$(atf_get_srcdir)/$1"
 	local exp="${src%.c}.exp"
-	local exp_ln="${src%.c}.ln"
+	local exp_ln="${src%.c}.exp-ln"
 	local wrk_ln="${1%.c}.ln"
 	local flags=""
 	local skip=""



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

2021-06-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 27 19:33:25 UTC 2021

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

Log Message:
tests/lint: remove list of test names from t_integration

By convention, each *.c file in the source directory is a test case.

There is no need to list them individually and redundantly.

There is also no need to group the tests for the individual messages.
This ensures that each test is run in the regular builds.  Previously,
the test all_messages stopped after the first failure.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/tests/usr.bin/xlint/lint1/t_integration.sh

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/t_integration.sh
diff -u src/tests/usr.bin/xlint/lint1/t_integration.sh:1.61 src/tests/usr.bin/xlint/lint1/t_integration.sh:1.62
--- src/tests/usr.bin/xlint/lint1/t_integration.sh:1.61	Sun Jun 27 19:10:29 2021
+++ src/tests/usr.bin/xlint/lint1/t_integration.sh	Sun Jun 27 19:33:25 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.61 2021/06/27 19:10:29 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.62 2021/06/27 19:33:25 rillig Exp $
 #
 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -27,7 +27,6 @@
 
 lint1=/usr/libexec/lint1
 
-test_case_names=
 machine_arch="$(sysctl -n hw.machine_arch)"
 
 
@@ -100,132 +99,21 @@ check_lint1()
 	fi
 }
 
-test_case()
-{
-	local name="$1"
-
-	atf_test_case "$name"
-	eval "${name}_head() {
-		atf_set 'require.progs' '$lint1'
-	}"
-	eval "${name}_body() {
-		check_lint1 '$name.c'
-	}"
-
-	test_case_names="$test_case_names $name"
-}
-
-
-test_case all_messages
-test_case c11_generic_expression
-test_case c99_init_designator
-test_case d_alignof
-test_case d_bltinoffsetof
-test_case d_c99_anon_struct
-test_case d_c99_anon_union
-test_case d_c99_bool
-test_case d_c99_bool_strict
-test_case d_c99_bool_strict_syshdr
-test_case d_c99_complex_num
-test_case d_c99_complex_split
-test_case d_c99_compound_literal_comma
-test_case d_c99_decls_after_stmt
-test_case d_c99_decls_after_stmt2
-test_case d_c99_decls_after_stmt3
-test_case d_c99_flex_array_packed
-test_case d_c99_for_loops
-test_case d_c99_func
-test_case d_c99_init
-test_case d_c99_nested_struct
-test_case d_c99_recursive_init
-test_case d_c99_struct_init
-test_case d_c99_union_cast
-test_case d_c99_union_init1
-test_case d_c99_union_init2
-test_case d_c99_union_init3
-test_case d_c99_union_init4
-test_case d_c99_union_init5
-test_case d_c9x_array_init
-test_case d_c9x_recursive_init
-test_case d_cast_fun_array_param
-test_case d_cast_init
-test_case d_cast_init2
-test_case d_cast_lhs
-test_case d_cast_typeof
-test_case d_compound_literals1
-test_case d_compound_literals2
-test_case d_constant_conv1
-test_case d_constant_conv2
-test_case d_cvt_constant
-test_case d_cvt_in_ternary
-test_case d_decl_old_style_arguments
-test_case d_ellipsis_in_switch
-test_case d_fold_test
-test_case d_gcc_compound_statements1
-test_case d_gcc_compound_statements2
-test_case d_gcc_compound_statements3
-test_case d_gcc_extension
-test_case d_gcc_func
-test_case d_gcc_variable_array_init
-test_case d_incorrect_array_size
-test_case d_init_array_using_string
-test_case d_init_pop_member
-test_case d_lint_assert
-test_case d_long_double_int
-test_case d_nested_structs
-test_case d_nolimit_init
-test_case d_packed_structs
-test_case d_pr_22119
-test_case d_return_type
-test_case d_shift_to_narrower_type
-test_case d_struct_init_nested
-test_case d_type_conv1
-test_case d_type_conv2
-test_case d_type_conv3
-test_case d_type_question_colon
-test_case d_typefun
-test_case d_typename_as_var
-test_case d_zero_sized_arrays
-test_case decl_struct_member
-test_case emit
-test_case expr_range
-test_case feat_stacktrace
-test_case gcc_attribute
-test_case gcc_attribute_aligned
-test_case gcc_bit_field_types
-test_case gcc_init_compound_literal
-test_case gcc_typeof_after_statement
-test_case lex_char
-test_case lex_comment
-test_case lex_floating
-test_case lex_integer
-test_case lex_string
-test_case lex_wide_char
-test_case lex_wide_string
-test_case op_colon
-test_case stmt_for
-
-all_messages_body()
-{
-	local failed msg
-
-	failed=""
-
-	for msg in $(seq 0 345); do
-		name="$(printf 'msg_%03d.c' "$msg")"
-		check_lint1 "$name" \
-		|| failed="$failed${failed:+ }$name"
-	done
-
-	if [ "$failed" != "" ]; then
-		atf_check "false" "$failed"
-	fi
-}
-
-
 atf_init_test_cases()
 {
-	for name in $test_case_names; do
+	local src name
+
+	for src in "$(atf_get_srcdir)"/*.c; do
+		src=${src##*/}
+		name=${src%.c}
+
+		atf_test_case "$name"
+		eval "${name}_head() {
+			atf_set 'require.progs' '$lint1'
+		}"
+		eval "${name}_body() {
+			check_lint1 '$name.c'
+		}"
 		atf_add_test_case "$name"
 	done
 }



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

2021-06-27 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 27 10:14:43 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: lex_integer.c lex_integer.exp
t_integration.sh

Log Message:
tests/lint: allow skipping individual tests

Depending on the platform, some tests do not make sense or produce
platform-dependent results.  Allow these tests to be marked as such.

For example, the test lex_integer.c only works on 64-bit platforms.
Therefore it is disabled on i386 for now since it prints different
warnings there.  Even better would be a "lint1-only-on-lpi32" toggle,
but that would need detection of 'sizeof(int)' at runtime.


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

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/lex_integer.c
diff -u src/tests/usr.bin/xlint/lint1/lex_integer.c:1.1 src/tests/usr.bin/xlint/lint1/lex_integer.c:1.2
--- src/tests/usr.bin/xlint/lint1/lex_integer.c:1.1	Sat Jun 19 08:30:08 2021
+++ src/tests/usr.bin/xlint/lint1/lex_integer.c	Sun Jun 27 10:14:43 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lex_integer.c,v 1.1 2021/06/19 08:30:08 rillig Exp $	*/
+/*	$NetBSD: lex_integer.c,v 1.2 2021/06/27 10:14:43 rillig Exp $	*/
 # 3 "lex_integer.c"
 
 /*
@@ -7,6 +7,8 @@
  * C99 6.4.4.1 "Integer constants"
  */
 
+/* lint1-not-on-arch: i386 (has 32-bit long) */
+
 void sinki(int);
 void sinku(unsigned int);
 
Index: src/tests/usr.bin/xlint/lint1/lex_integer.exp
diff -u src/tests/usr.bin/xlint/lint1/lex_integer.exp:1.1 src/tests/usr.bin/xlint/lint1/lex_integer.exp:1.2
--- src/tests/usr.bin/xlint/lint1/lex_integer.exp:1.1	Sat Jun 19 08:30:08 2021
+++ src/tests/usr.bin/xlint/lint1/lex_integer.exp	Sun Jun 27 10:14:43 2021
@@ -1,5 +1,5 @@
-lex_integer.c(25): warning: argument #1 is converted from 'long' to 'int' due to prototype [259]
-lex_integer.c(25): warning: conversion of 'long' to 'int' is out of range, arg #1 [295]
-lex_integer.c(30): warning: argument #1 is converted from 'long' to 'int' due to prototype [259]
-lex_integer.c(42): warning: argument #1 is converted from 'unsigned long' to 'unsigned int' due to prototype [259]
-lex_integer.c(42): warning: conversion of 'unsigned long' to 'unsigned int' is out of range, arg #1 [295]
+lex_integer.c(27): warning: argument #1 is converted from 'long' to 'int' due to prototype [259]
+lex_integer.c(27): warning: conversion of 'long' to 'int' is out of range, arg #1 [295]
+lex_integer.c(32): warning: argument #1 is converted from 'long' to 'int' due to prototype [259]
+lex_integer.c(44): warning: argument #1 is converted from 'unsigned long' to 'unsigned int' due to prototype [259]
+lex_integer.c(44): warning: conversion of 'unsigned long' to 'unsigned int' is out of range, arg #1 [295]

Index: src/tests/usr.bin/xlint/lint1/t_integration.sh
diff -u src/tests/usr.bin/xlint/lint1/t_integration.sh:1.58 src/tests/usr.bin/xlint/lint1/t_integration.sh:1.59
--- src/tests/usr.bin/xlint/lint1/t_integration.sh:1.58	Sun Jun 27 09:22:31 2021
+++ src/tests/usr.bin/xlint/lint1/t_integration.sh	Sun Jun 27 10:14:43 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.58 2021/06/27 09:22:31 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.59 2021/06/27 10:14:43 rillig Exp $
 #
 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -28,16 +28,19 @@
 lint1=/usr/libexec/lint1
 
 test_case_names=
+machine_arch="$(sysctl -n hw.machine_arch)"
 
 
-extract_flags()
+configure_test_case()
 {
-	local extract_flags_awk
+	local awk
 
 	# shellcheck disable=SC2016
-	extract_flags_awk='
+	awk='
 		BEGIN {
+			machine_arch = "'"$machine_arch"'"
 			flags = "-g -S -w"
+			skip = 0
 		}
 		/^\/\* (lint1-flags|lint1-extra-flags): .*\*\/$/ {
 			if ($2 == "lint1-flags:")
@@ -45,12 +48,19 @@ extract_flags()
 			for (i = 3; i < NF; i++)
 flags = flags " " $i
 		}
+		/^\/\* lint1-only-on-arch: .* \*\/$/ && $3 != machine_arch {
+			skip = 1
+		}
+		/^\/\* lint1-not-on-arch: .* \*\/$/ && $3 == machine_arch {
+			skip = 1
+		}
 		END {
-			print flags
+			printf("flags='\''%s'\''\n", flags)
+			printf("skip=%s\n", skip ? "yes" : "no")
 		}
 	'
 
-	awk "$extract_flags_awk" "$@"
+	eval "$(awk "$awk" "$1")"
 }
 
 # shellcheck disable=SC2155
@@ -60,13 +70,21 @@ check_lint1()
 	local exp="${src%.c}.exp"
 	local exp_ln="${src%.c}.ln"
 	local wrk_ln="${1%.c}.ln"
-	local flags="$(extract_flags "$src")"
+	local flags=""
+	local skip=""
 
 	if [ ! -f "$exp_ln" ]; then
 		exp_ln='/dev/null'
 		wrk_ln='/dev/null'
 	fi
 
+	configure_test_case "$src"
+
+	if [ "$skip" = "yes" ]; then
+		atf_check -o 'ignore' echo 'skipped'
+		return
+	fi
+
 	if [ -f "$exp" ]; then
 		# shellcheck disable=SC2086
 		atf_check -s not-exit:0 -o "file:$exp" -e empty \
@@ -77,7 

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

2021-06-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 20 18:23:07 UTC 2021

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

Log Message:
tests/lint: remove outdated comment about '\0'

That comment was only needed for lex.c 1.38 from 2021-06-18, which was
fixed with lex.c 1.39 from 2021-06-19, just a day later.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/lex_char.c \
src/tests/usr.bin/xlint/lint1/lex_char.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/lex_char.c
diff -u src/tests/usr.bin/xlint/lint1/lex_char.c:1.1 src/tests/usr.bin/xlint/lint1/lex_char.c:1.2
--- src/tests/usr.bin/xlint/lint1/lex_char.c:1.1	Sat Jun 19 08:30:08 2021
+++ src/tests/usr.bin/xlint/lint1/lex_char.c	Sun Jun 20 18:23:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lex_char.c,v 1.1 2021/06/19 08:30:08 rillig Exp $	*/
+/*	$NetBSD: lex_char.c,v 1.2 2021/06/20 18:23:07 rillig Exp $	*/
 # 3 "lex_char.c"
 
 /*
@@ -23,7 +23,6 @@ test(void)
 	/* expect+2: multi-character character constant */
 	/* expect+1: conversion of 'int' to 'char' is out of range */
 	sink('รค');
-	/* rescue the parser: ' */
 
 	/* GCC extension */
 	/* expect+1: dubious escape \e */
Index: src/tests/usr.bin/xlint/lint1/lex_char.exp
diff -u src/tests/usr.bin/xlint/lint1/lex_char.exp:1.1 src/tests/usr.bin/xlint/lint1/lex_char.exp:1.2
--- src/tests/usr.bin/xlint/lint1/lex_char.exp:1.1	Sat Jun 19 08:30:08 2021
+++ src/tests/usr.bin/xlint/lint1/lex_char.exp	Sun Jun 20 18:23:07 2021
@@ -1,5 +1,5 @@
 lex_char.c(16): error: empty character constant [73]
 lex_char.c(25): warning: multi-character character constant [294]
 lex_char.c(25): warning: conversion of 'int' to 'char' is out of range, arg #1 [295]
-lex_char.c(30): warning: dubious escape \e [79]
-lex_char.c(42): error: empty character constant [73]
+lex_char.c(29): warning: dubious escape \e [79]
+lex_char.c(41): error: empty character constant [73]



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

2021-06-20 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jun 20 18:11:21 UTC 2021

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

Log Message:
tests/lint: document disappearance of bug in pop_member


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

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/d_init_pop_member.c
diff -u src/tests/usr.bin/xlint/lint1/d_init_pop_member.c:1.7 src/tests/usr.bin/xlint/lint1/d_init_pop_member.c:1.8
--- src/tests/usr.bin/xlint/lint1/d_init_pop_member.c:1.7	Tue Mar 30 14:25:28 2021
+++ src/tests/usr.bin/xlint/lint1/d_init_pop_member.c	Sun Jun 20 18:11:21 2021
@@ -1,8 +1,8 @@
-/*	$NetBSD: d_init_pop_member.c,v 1.7 2021/03/30 14:25:28 rillig Exp $	*/
+/*	$NetBSD: d_init_pop_member.c,v 1.8 2021/06/20 18:11:21 rillig Exp $	*/
 # 3 "d_init_pop_member.c"
 
 /*
- * Since init.c 1.27 from 2015-07-28,
+ * Since init.c 1.27 from 2015-07-28 and before init.c 1.178 from 2021-03-29,
  * a bug in memberpop or pop_member led to a wrong error message
  * "undefined struct/union member: capital [101]" in the second and third
  * named initializer.



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

2021-06-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Jun 16 10:21:51 UTC 2021

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

Log Message:
tests/lint: sort the list of test cases

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/tests/usr.bin/xlint/lint1/t_integration.sh

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/t_integration.sh
diff -u src/tests/usr.bin/xlint/lint1/t_integration.sh:1.51 src/tests/usr.bin/xlint/lint1/t_integration.sh:1.52
--- src/tests/usr.bin/xlint/lint1/t_integration.sh:1.51	Wed Jun 16 10:19:23 2021
+++ src/tests/usr.bin/xlint/lint1/t_integration.sh	Wed Jun 16 10:21:51 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.51 2021/06/16 10:19:23 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.52 2021/06/16 10:21:51 rillig Exp $
 #
 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -98,73 +98,74 @@ test_case()
 }
 
 
+test_case all_messages
+test_case d_alignof
 test_case d_bltinoffsetof
 test_case d_c99_anon_struct
 test_case d_c99_anon_union
 test_case d_c99_bool
 test_case d_c99_bool_strict
 test_case d_c99_bool_strict_syshdr
+test_case d_c99_complex_num
+test_case d_c99_complex_split
 test_case d_c99_compound_literal_comma
+test_case d_c99_decls_after_stmt
 test_case d_c99_decls_after_stmt2
+test_case d_c99_decls_after_stmt3
 test_case d_c99_flex_array_packed
+test_case d_c99_for_loops
+test_case d_c99_func
 test_case d_c99_init
 test_case d_c99_nested_struct
+test_case d_c99_recursive_init
+test_case d_c99_struct_init
 test_case d_c99_union_cast
+test_case d_c99_union_init1
+test_case d_c99_union_init2
+test_case d_c99_union_init3
 test_case d_c99_union_init4
 test_case d_c99_union_init5
+test_case d_c9x_array_init
+test_case d_c9x_recursive_init
 test_case d_cast_fun_array_param
+test_case d_cast_init
+test_case d_cast_init2
+test_case d_cast_lhs
 test_case d_cast_typeof
+test_case d_compound_literals1
+test_case d_compound_literals2
+test_case d_constant_conv1
+test_case d_constant_conv2
+test_case d_cvt_constant
+test_case d_cvt_in_ternary
 test_case d_decl_old_style_arguments
+test_case d_ellipsis_in_switch
 test_case d_fold_test
+test_case d_gcc_compound_statements1
+test_case d_gcc_compound_statements2
+test_case d_gcc_compound_statements3
 test_case d_gcc_extension
+test_case d_gcc_func
+test_case d_gcc_variable_array_init
+test_case d_incorrect_array_size
 test_case d_init_array_using_string
 test_case d_init_pop_member
 test_case d_lint_assert
-test_case d_return_type
-test_case d_type_question_colon
-test_case d_typefun
-test_case d_typename_as_var
-test_case d_c99_struct_init
-test_case d_c99_union_init1
-test_case d_c99_union_init2
-test_case d_c99_union_init3
-test_case d_c99_recursive_init
-test_case d_c9x_recursive_init
+test_case d_long_double_int
 test_case d_nested_structs
+test_case d_nolimit_init
 test_case d_packed_structs
 test_case d_pr_22119
-test_case d_struct_init_nested
-test_case d_cast_init
-test_case d_cast_init2
-test_case d_cast_lhs
-test_case d_gcc_func
-test_case d_c99_func
-test_case d_gcc_variable_array_init
-test_case d_c9x_array_init
-test_case d_c99_decls_after_stmt
-test_case d_c99_decls_after_stmt3
-test_case d_nolimit_init
-test_case d_zero_sized_arrays
-test_case d_compound_literals1
-test_case d_compound_literals2
-test_case d_gcc_compound_statements1
-test_case d_gcc_compound_statements2
-test_case d_gcc_compound_statements3
-test_case d_cvt_in_ternary
-test_case d_cvt_constant
-test_case d_ellipsis_in_switch
-test_case d_c99_complex_num
-test_case d_c99_complex_split
-test_case d_c99_for_loops
-test_case d_alignof
+test_case d_return_type
 test_case d_shift_to_narrower_type
-test_case d_constant_conv1
-test_case d_constant_conv2
+test_case d_struct_init_nested
 test_case d_type_conv1
 test_case d_type_conv2
 test_case d_type_conv3
-test_case d_incorrect_array_size
-test_case d_long_double_int
+test_case d_type_question_colon
+test_case d_typefun
+test_case d_typename_as_var
+test_case d_zero_sized_arrays
 test_case emit
 test_case expr_range
 test_case feat_stacktrace
@@ -175,8 +176,6 @@ test_case gcc_init_compound_literal
 test_case gcc_typeof_after_statement
 test_case op_colon
 
-
-test_case all_messages
 all_messages_body()
 {
 	local failed msg



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

2021-06-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Jun 16 10:19:23 UTC 2021

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

Log Message:
tests/lint: clean up ATF test driver

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/tests/usr.bin/xlint/lint1/t_integration.sh

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/t_integration.sh
diff -u src/tests/usr.bin/xlint/lint1/t_integration.sh:1.50 src/tests/usr.bin/xlint/lint1/t_integration.sh:1.51
--- src/tests/usr.bin/xlint/lint1/t_integration.sh:1.50	Sun May 16 11:11:37 2021
+++ src/tests/usr.bin/xlint/lint1/t_integration.sh	Wed Jun 16 10:19:23 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.50 2021/05/16 11:11:37 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.51 2021/06/16 10:19:23 rillig Exp $
 #
 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -25,9 +25,10 @@
 # POSSIBILITY OF SUCH DAMAGE.
 #
 
-LINT1=/usr/libexec/lint1
+lint1=/usr/libexec/lint1
+
+test_case_names=
 
-Names=
 
 extract_flags()
 {
@@ -59,47 +60,44 @@ check_lint1()
 	local exp="${src%.c}.exp"
 	local src_ln="${src%.c}.ln"
 	local wrk_ln="${1%.c}.ln"
-	local flags="$(extract_flags "${src}")"
+	local flags="$(extract_flags "$src")"
 
-	if [ ! -f "${src_ln}" ]; then
-		src_ln="/dev/null"
-		wrk_ln="/dev/null"
+	if [ ! -f "$src_ln" ]; then
+		src_ln='/dev/null'
+		wrk_ln='/dev/null'
 	fi
 
-	if [ -f "${exp}" ]; then
+	if [ -f "$exp" ]; then
 		# shellcheck disable=SC2086
-		atf_check -s not-exit:0 -o "file:${exp}" -e empty \
-		${LINT1} ${flags} "${src}" "${wrk_ln}"
+		atf_check -s not-exit:0 -o "file:$exp" -e empty \
+		"$lint1" $flags "$src" "$wrk_ln"
 	else
 		# shellcheck disable=SC2086
 		atf_check -s exit:0 \
-		${LINT1} ${flags} "${src}" "${wrk_ln}"
+		"$lint1" $flags "$src" "$wrk_ln"
 	fi
 
-	if [ "${src_ln}" != "/dev/null" ]; then
-		atf_check -o "file:${src_ln}" cat "${wrk_ln}"
+	if [ "$src_ln" != '/dev/null' ]; then
+		atf_check -o "file:$src_ln" cat "$wrk_ln"
 	fi
 }
 
 test_case()
 {
-	local name="${1}"; shift
-	local descr="${*}"
+	local name="$1"
 
-	atf_test_case ${name}
+	atf_test_case "$name"
 	eval "${name}_head() {
-		if [ \"${descr}\" ]; then
-			atf_set \"descr\" \"${descr}\"
-		fi
-		atf_set \"require.progs\" \"${LINT1}\"
+		atf_set 'require.progs' '$lint1'
 	}"
 	eval "${name}_body() {
-		check_lint1 ${name}.c
+		check_lint1 '$name.c'
 	}"
 
-	Names="${Names} ${name}"
+	test_case_names="$test_case_names $name"
 }
 
+
 test_case d_bltinoffsetof
 test_case d_c99_anon_struct
 test_case d_c99_anon_union
@@ -126,7 +124,6 @@ test_case d_return_type
 test_case d_type_question_colon
 test_case d_typefun
 test_case d_typename_as_var
-
 test_case d_c99_struct_init
 test_case d_c99_union_init1
 test_case d_c99_union_init2
@@ -137,27 +134,22 @@ test_case d_nested_structs
 test_case d_packed_structs
 test_case d_pr_22119
 test_case d_struct_init_nested
-
 test_case d_cast_init
 test_case d_cast_init2
 test_case d_cast_lhs
-
 test_case d_gcc_func
 test_case d_c99_func
-
 test_case d_gcc_variable_array_init
 test_case d_c9x_array_init
 test_case d_c99_decls_after_stmt
 test_case d_c99_decls_after_stmt3
 test_case d_nolimit_init
 test_case d_zero_sized_arrays
-
 test_case d_compound_literals1
 test_case d_compound_literals2
 test_case d_gcc_compound_statements1
 test_case d_gcc_compound_statements2
 test_case d_gcc_compound_statements3
-
 test_case d_cvt_in_ternary
 test_case d_cvt_constant
 test_case d_ellipsis_in_switch
@@ -173,19 +165,16 @@ test_case d_type_conv2
 test_case d_type_conv3
 test_case d_incorrect_array_size
 test_case d_long_double_int
-
 test_case emit
 test_case expr_range
-
+test_case feat_stacktrace
 test_case gcc_attribute
 test_case gcc_attribute_aligned
 test_case gcc_bit_field_types
 test_case gcc_init_compound_literal
 test_case gcc_typeof_after_statement
-
 test_case op_colon
 
-test_case feat_stacktrace
 
 test_case all_messages
 all_messages_body()
@@ -195,8 +184,8 @@ all_messages_body()
 	failed=""
 
 	for msg in $(seq 0 344); do
-		name="$(printf 'msg_%03d.c' "${msg}")"
-		check_lint1 "${name}" \
+		name="$(printf 'msg_%03d.c' "$msg")"
+		check_lint1 "$name" \
 		|| failed="$failed${failed:+ }$name"
 	done
 
@@ -208,7 +197,7 @@ all_messages_body()
 
 atf_init_test_cases()
 {
-	for name in ${Names}; do
-		atf_add_test_case ${name}
+	for name in $test_case_names; do
+		atf_add_test_case "$name"
 	done
 }



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

2021-06-15 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Jun 15 08:48:49 UTC 2021

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

Log Message:
tests/lint: add test for previous prototype declaration


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_285.c \
src/tests/usr.bin/xlint/lint1/msg_285.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_285.c
diff -u src/tests/usr.bin/xlint/lint1/msg_285.c:1.2 src/tests/usr.bin/xlint/lint1/msg_285.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_285.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_285.c	Tue Jun 15 08:48:49 2021
@@ -1,7 +1,15 @@
-/*	$NetBSD: msg_285.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_285.c,v 1.3 2021/06/15 08:48:49 rillig Exp $	*/
 # 3 "msg_285.c"
 
 // Test for message: prototype declaration [285]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* lint1-extra-flags: -r */
+
+void function(int, int, int);	/* expect: 285 */
+
+/* ARGSUSED */
+extern void
+function(a, b)
+int a, b;
+{/* expect: 3 declared, 2 defined */
+}
Index: src/tests/usr.bin/xlint/lint1/msg_285.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_285.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_285.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_285.exp:1.2	Sun Mar 21 20:45:00 2021
+++ src/tests/usr.bin/xlint/lint1/msg_285.exp	Tue Jun 15 08:48:49 2021
@@ -1 +1,2 @@
-msg_285.c(6): error: syntax error ':' [249]
+msg_285.c(14): error: parameter mismatch: 3 declared, 2 defined [51]
+msg_285.c(8): prototype declaration [285]



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

2021-05-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue May 25 19:04:07 UTC 2021

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

Log Message:
tests/lint: make test 130 platform-independent

On 32-bit platforms such as i386 and sparc, sizeof(int) == sizeof(long),
which produced an additional unintended lint error message:

msg_130.c(78): error: duplicate case in switch: 4 [199]


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/tests/usr.bin/xlint/lint1/msg_130.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_130.c
diff -u src/tests/usr.bin/xlint/lint1/msg_130.c:1.13 src/tests/usr.bin/xlint/lint1/msg_130.c:1.14
--- src/tests/usr.bin/xlint/lint1/msg_130.c:1.13	Fri Apr  2 13:16:38 2021
+++ src/tests/usr.bin/xlint/lint1/msg_130.c	Tue May 25 19:04:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_130.c,v 1.13 2021/04/02 13:16:38 rillig Exp $	*/
+/*	$NetBSD: msg_130.c,v 1.14 2021/05/25 19:04:07 rillig Exp $	*/
 # 3 "msg_130.c"
 
 // Test for message: enum type mismatch: '%s' '%s' '%s' [130]
@@ -61,7 +61,7 @@ switch_example(enum color c)
  */
 enum {
 	sizeof_int = sizeof(int),
-	sizeof_long = sizeof(long)
+	sizeof_short = sizeof(short)
 };
 
 enum {
@@ -75,7 +75,7 @@ enum_constant_from_unnamed_type(int x)
 	switch (x) {
 	case sizeof_int:
 		return 1;
-	case sizeof_long:
+	case sizeof_short:
 		return 2;
 	default:
 		break;



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

2021-05-25 Thread Chris Pinnock
Module Name:src
Committed By:   cjep
Date:   Tue May 25 11:55:42 UTC 2021

Modified Files:
src/tests/usr.bin/patch: t_patch.sh

Log Message:
The long lines test is now expected to pass


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/patch/t_patch.sh

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

Modified files:

Index: src/tests/usr.bin/patch/t_patch.sh
diff -u src/tests/usr.bin/patch/t_patch.sh:1.2 src/tests/usr.bin/patch/t_patch.sh:1.3
--- src/tests/usr.bin/patch/t_patch.sh:1.2	Sat Feb 20 08:59:24 2021
+++ src/tests/usr.bin/patch/t_patch.sh	Tue May 25 11:55:42 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_patch.sh,v 1.2 2021/02/20 08:59:24 nia Exp $
+# $NetBSD: t_patch.sh,v 1.3 2021/05/25 11:55:42 cjep Exp $
 #
 # Copyright (c) 2020, 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -67,7 +67,6 @@ long_lines_head()
 
 long_lines_body()
 {
-	atf_expect_fail "PR bin/54620"
 	patch_lines 1
 }
 



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

2021-05-19 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Wed May 19 22:45:49 UTC 2021

Modified Files:
src/tests/usr.bin/printf: printf.sh

Log Message:
With the (very) recent changes to printf(1), a numeric conversion from data
of the form '+1 (two (or more) characters after the quote) will now generate
an error message, and cause printf(1) to exit(1) when it is done.

Adapt the test cases which use that data form to handle that.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/printf/printf.sh

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

Modified files:

Index: src/tests/usr.bin/printf/printf.sh
diff -u src/tests/usr.bin/printf/printf.sh:1.7 src/tests/usr.bin/printf/printf.sh:1.8
--- src/tests/usr.bin/printf/printf.sh:1.7	Wed May 19 22:20:34 2021
+++ src/tests/usr.bin/printf/printf.sh	Wed May 19 22:45:49 2021
@@ -1,4 +1,4 @@
-# $NetBSD: printf.sh,v 1.7 2021/05/19 22:20:34 kre Exp $
+# $NetBSD: printf.sh,v 1.8 2021/05/19 22:45:49 kre Exp $
 #
 # Copyright (c) 2018 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -403,15 +403,15 @@ d_decimal()
 	expect 65		'%d'		"'A"
 	expect 065		'%03d'		"'A"
 	expect 49		'%d'		"'1"
-	expect 45		'%d'		"'-1"
-	expect 43		'%d'		"'+1"
+	expect_fail 45		'%d'		"'-1"
+	expect_fail 43		'%d'		"'+1"
 	expect 00		'%.2d'		"'"
 
 	expect 68		'%d'		'"D'
 	expect 069		'%03d'		'"E'
 	expect 51		'%d'		'"3'
-	expect 45		'%d'		'"-3'
-	expect 43		'%d'		'"+3'
+	expect_fail 45		'%d'		'"-3'
+	expect_fail 43		'%d'		'"+3'
 
 	expect -1		'% d'		-1
 	expect ' 1'		'% d'		1
@@ -527,14 +527,14 @@ u_unsigned()
 	expect 65		'%u'		"'A"
 	expect 065		'%03u'		"'A"
 	expect 49		'%u'		"'1"
-	expect 45		'%u'		"'-1"
-	expect 43		'%u'		"'+1"
+	expect_fail 45		'%u'		"'-1"
+	expect_fail 43		'%u'		"'+1"
 
 	expect 68		'%u'		'"D'
 	expect 069		'%03u'		'"E'
 	expect 51		'%u'		'"3'
-	expect 45		'%u'		'"-3'
-	expect 43		'%u'		'"+3'
+	expect_fail 45		'%u'		'"-3'
+	expect_fail 43		'%u'		'"+3'
 
 	# Note that the ' ' and '+' flags only apply to signed conversions
 	# so they should be simply ignored for '%u'
@@ -604,8 +604,8 @@ o_octal()
 	expect 101		'%o'		"'A"
 	expect 0101		'%04o'		"'A"
 	expect 61		'%o'		"'1"
-	expect 55		'%o'		"'-1"
-	expect 53		'%o'		"'+1"
+	expect_fail 55		'%o'		"'-1"
+	expect_fail 53		'%o'		"'+1"
 
 	expect 01747		'%#o'		999
 	expect '  02'		'%#4o'		2
@@ -613,8 +613,8 @@ o_octal()
 	expect 0101		'%#o'		"'A"
 	expect 0101		'%#04o'		"'A"
 	expect 061		'%#o'		"'1"
-	expect 055		'%#o'		"'-1"
-	expect 053		'%#o'		"'+1"
+	expect_fail 055		'%#o'		"'-1"
+	expect_fail 053		'%#o'		"'+1"
 	expect 063		'%#o'		063
 
 	# negative numbers are allowed, but printed as unsigned.
@@ -652,8 +652,8 @@ x_hex()
 	expect 41		'%x'		"'A"
 	expect 041		'%03x'		"'A"
 	expect 31		'%x'		"'1"
-	expect 2d		'%x'		"'-1"
-	expect 2b		'%x'		"'+1"
+	expect_fail 2d		'%x'		"'-1"
+	expect_fail 2b		'%x'		"'+1"
 
 	expect ' face '		'%5x '		64206
 
@@ -690,8 +690,8 @@ X_hex()
 	# the alpha digits, so just do minimal testing of that...
 
 	expect 3E7		%X		999
-	expect 2D		%X		"'-1"
-	expect 2B		%X		"'+1"
+	expect_fail 2D		%X		"'-1"
+	expect_fail 2B		%X		"'+1"
 	expect ' FACE '		'%5X '		64206
 	expect DEADBEEF		%X		3735928559
 
@@ -1556,8 +1556,8 @@ NetBSD_extensions()
 	expect 6.50e+01	'%e'		"'A"
 	expect 6.5e+01		'%.1e'		"'A"
 	expect 5e+01		'%.0e'		"'1"
-	expect 4.50e+01		'%.2e'		"'-1"
-	expect 4.300e+01	'%.3e'		"'+1"
+	expect_fail 4.50e+01	'%.2e'		"'-1"
+	expect_fail 4.300e+01	'%.3e'		"'+1"
 	expect 99.00	'%f'		'"c'
 	expect 97		'%g'		'"a'
 



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

2021-05-19 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Wed May 19 22:20:34 UTC 2021

Modified Files:
src/tests/usr.bin/printf: printf.sh

Log Message:
Fix a truly embarrassing quoting screwup.   There is an explanation as
to why this didn't cause any failures, but I won't go into it here.
This was detected by the about to be committed printf changes.

While here also correct a couple of minor comment layout issues.


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

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

Modified files:

Index: src/tests/usr.bin/printf/printf.sh
diff -u src/tests/usr.bin/printf/printf.sh:1.6 src/tests/usr.bin/printf/printf.sh:1.7
--- src/tests/usr.bin/printf/printf.sh:1.6	Fri Apr 24 14:29:19 2020
+++ src/tests/usr.bin/printf/printf.sh	Wed May 19 22:20:34 2021
@@ -1,4 +1,4 @@
-# $NetBSD: printf.sh,v 1.6 2020/04/24 14:29:19 kre Exp $
+# $NetBSD: printf.sh,v 1.7 2021/05/19 22:20:34 kre Exp $
 #
 # Copyright (c) 2018 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -1071,13 +1071,13 @@ g_floats()
 	expect 1.0		%#g	1		# p = 6, x = 0 :  %.5f
 	expect -0.50	%#g	-0.5		# p = 6, x = -1:  %.6f
 
-	expect 0.001234		%#.4g	0.001234	# p= 4, x = -3:  %.6f
+	expect 0.001234		%#.4g	0.001234	# p= 4, x = -3 :  %.6f
 
 	expect .		%#.4g			# p = 4, x = 3 :  %.0f
 	expect .0		%#.5g			# p = 5, x = 3 :  %.1f
 
 	expect 4.4?e+03		%.3g			# p = 3, x = 3 :  %.2e
-	expect 1.2e-05		%.2g	0.12	# p = 2, x = -5:  $.1e
+	expect 1.2e-05		%.2g	0.12	# p = 2, x = -5:  %.1e
 
 	expect 1e+10		%g	100
 	expect 1e+10		%g	1e10
@@ -1558,8 +1558,8 @@ NetBSD_extensions()
 	expect 5e+01		'%.0e'		"'1"
 	expect 4.50e+01		'%.2e'		"'-1"
 	expect 4.300e+01	'%.3e'		"'+1"
-	expect 99.00	'%f'		'"c"
-	expect 97		'%g'		'"a"
+	expect 99.00	'%f'		'"c'
+	expect 97		'%g'		'"a'
 
 	# NetBSD (non-POSIX) format excape extensions
 	expect ''		'\e'



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

2021-05-16 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May 16 10:08:02 UTC 2021

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

Log Message:
tests/lint: add test for warning about zero-bits in '&'


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_309.c \
src/tests/usr.bin/xlint/lint1/msg_309.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_309.c
diff -u src/tests/usr.bin/xlint/lint1/msg_309.c:1.2 src/tests/usr.bin/xlint/lint1/msg_309.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_309.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_309.c	Sun May 16 10:08:01 2021
@@ -1,7 +1,39 @@
-/*	$NetBSD: msg_309.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_309.c,v 1.3 2021/05/16 10:08:01 rillig Exp $	*/
 # 3 "msg_309.c"
 
 // Test for message: extra bits set to 0 in conversion of '%s' to '%s', op %s [309]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+int
+scale(unsigned long long x) {
+
+	/*
+	 * Both operands of '&' have the same type, therefore no conversion
+	 * is necessary and no bits can get lost.
+	 */
+	if ((x & 0xULL) != 0)
+		return 32;
+
+	/*
+	 * The constant has type 'unsigned 32-bit'.  The usual arithmetic
+	 * conversions of '&' convert this constant to unsigned 64-bit.
+	 * The programmer may or may not have intended to sign-extend the
+	 * bit mask here.  This situation may occur during migration from a
+	 * 32-bit to a 64-bit platform.
+	 */
+	if ((x & 0x) != 0)	/* expect: 309 */
+		return 16;
+
+	/*
+	 * In the remaining cases, the constant does not have its most
+	 * significant bit set, therefore there is no ambiguity.
+	 */
+	if ((x & 0xff00) != 0)
+		return 8;
+	if ((x & 0xf0) != 0)
+		return 4;
+	if ((x & 0xc) != 0)
+		return 2;
+	if ((x & 0x2) != 0)
+		return 1;
+	return (int)(x & 0x1);
+}
Index: src/tests/usr.bin/xlint/lint1/msg_309.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_309.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_309.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_309.exp:1.2	Sun Mar 21 20:45:00 2021
+++ src/tests/usr.bin/xlint/lint1/msg_309.exp	Sun May 16 10:08:01 2021
@@ -1 +1 @@
-msg_309.c(6): error: syntax error ':' [249]
+msg_309.c(23): warning: extra bits set to 0 in conversion of 'unsigned int' to 'unsigned long long', op & [309]



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

2021-05-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue May  4 19:57:57 UTC 2021

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

Log Message:
tests/lint: make test for message 118 platform-independent


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_118.c
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_118.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_118.c
diff -u src/tests/usr.bin/xlint/lint1/msg_118.c:1.4 src/tests/usr.bin/xlint/lint1/msg_118.c:1.5
--- src/tests/usr.bin/xlint/lint1/msg_118.c:1.4	Tue Apr  6 21:59:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_118.c	Tue May  4 19:57:56 2021
@@ -1,18 +1,39 @@
-/*	$NetBSD: msg_118.c,v 1.4 2021/04/06 21:59:58 rillig Exp $	*/
+/*	$NetBSD: msg_118.c,v 1.5 2021/05/04 19:57:56 rillig Exp $	*/
 # 3 "msg_118.c"
 
 /* Test for message: semantics of '%s' change in ANSI C; use explicit cast [118] */
 
-/* lint1-flags: -hsw */
+/* lint1-flags: -hw */
 
 int
-int_shl_uint(int i, unsigned int u)
+int_shl_uint(int left, unsigned int right)
 {
-	return i << u;
+	return left << right;
 }
 
-unsigned
-uint_shl_ulong(unsigned a, unsigned long ul)
+int
+int_shr_uint(int left, unsigned int right)
+{
+	/* expect+1: semantics of '>>' change in ANSI C */
+	return left >> right;
+}
+
+int
+int_shl_int(int left, int right)
 {
-	return a << ul;		/* expect: 118 */
+	return left << right;
 }
+
+/*
+ * The behavior of typeok_shl can only be triggered on 64-bit platforms, or
+ * in C99 mode, and the above tests require C90 mode.
+ *
+ * On 32-bit platforms both operands of the '<<' operator are first promoted
+ * individually, and since C90 does not know 'long long', the maximum
+ * bit-size for an integer type is 32 bits.
+ *
+ * Because of this difference there is no test for that case since as of
+ * 2021-05-04, all lint1 tests must be independent of the target platform and
+ * there is no way to toggle individual tests depending on the properties of
+ * the target platform.
+ */

Index: src/tests/usr.bin/xlint/lint1/msg_118.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_118.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_118.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_118.exp:1.2	Sun Feb 28 01:22:02 2021
+++ src/tests/usr.bin/xlint/lint1/msg_118.exp	Tue May  4 19:57:56 2021
@@ -1 +1 @@
-msg_118.c(17): warning: semantics of '<<' change in ANSI C; use explicit cast [118]
+msg_118.c(18): warning: semantics of '>>' change in ANSI C; use explicit cast [118]



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

2021-05-03 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue May  4 05:32:52 UTC 2021

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

Log Message:
tests/lint: demonstrate assertion failure "len == size_in_bits(INT)"

Seen on sparc64 in hdtoa.c:341 since sparc64 is one of the platforms
that has 128-bit long double and defines struct ieee_ext.ext_frach:48
based on uint64_t, which is a GCC extension.  Plain C99 only allows
_Bool, signed int and unsigned int as base type for bit-fields.


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

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/gcc_bit_field_types.c
diff -u src/tests/usr.bin/xlint/lint1/gcc_bit_field_types.c:1.3 src/tests/usr.bin/xlint/lint1/gcc_bit_field_types.c:1.4
--- src/tests/usr.bin/xlint/lint1/gcc_bit_field_types.c:1.3	Sun May  2 22:07:49 2021
+++ src/tests/usr.bin/xlint/lint1/gcc_bit_field_types.c	Tue May  4 05:32:52 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: gcc_bit_field_types.c,v 1.3 2021/05/02 22:07:49 rillig Exp $	*/
+/*	$NetBSD: gcc_bit_field_types.c,v 1.4 2021/05/04 05:32:52 rillig Exp $	*/
 # 3 "gcc_bit_field_types.c"
 
 /*
@@ -19,3 +19,19 @@ struct example {
 	unsigned long long unsigned_long_long_flag: 1;
 	double double_flag: 1;	/* expect: illegal bit-field type 'double' */
 };
+
+struct large_bit_field {
+	unsigned long long member: 48;
+};
+
+unsigned long long
+promote_large_bit_field(struct large_bit_field lbf)
+{
+	/*
+	 * Before tree.c 1.281 from 2021-05-04:
+	 * lint: assertion "len == size_in_bits(INT)" failed
+	 * in promote at tree.c:1698
+	 */
+	/* TODO: remove the cast since it hides an assertion failure */
+	return (unsigned long long)lbf.member & 0xf;
+}



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

2021-05-03 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon May  3 06:24:18 UTC 2021

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

Log Message:
tests/lint: demonstrate bug in the lexer for GCC attributes


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

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/gcc_attribute.c
diff -u src/tests/usr.bin/xlint/lint1/gcc_attribute.c:1.3 src/tests/usr.bin/xlint/lint1/gcc_attribute.c:1.4
--- src/tests/usr.bin/xlint/lint1/gcc_attribute.c:1.3	Sat May  1 07:56:20 2021
+++ src/tests/usr.bin/xlint/lint1/gcc_attribute.c	Mon May  3 06:24:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: gcc_attribute.c,v 1.3 2021/05/01 07:56:20 rillig Exp $	*/
+/*	$NetBSD: gcc_attribute.c,v 1.4 2021/05/03 06:24:18 rillig Exp $	*/
 # 3 "gcc_attribute.c"
 
 /*
@@ -38,3 +38,16 @@ function_nonnull_list(void *, const void
 /* expect+1: syntax error 'unknown_attribute' */
 void __attribute__((unknown_attribute))
 function_with_unknown_attribute(void);
+
+/*
+ * There is an attribute called 'pcs', but that attribute must not prevent an
+ * ordinary variable from being named the same.
+ *
+ * Seen in yds.c, function yds_allocate_slots.
+ */
+void
+local_variable_pcs(void)
+{
+	int pcs = 3;		/* expect: syntax error 'pcs' *//*FIXME*/
+	return pcs;
+}
Index: src/tests/usr.bin/xlint/lint1/gcc_attribute.exp
diff -u src/tests/usr.bin/xlint/lint1/gcc_attribute.exp:1.3 src/tests/usr.bin/xlint/lint1/gcc_attribute.exp:1.4
--- src/tests/usr.bin/xlint/lint1/gcc_attribute.exp:1.3	Sat May  1 07:56:20 2021
+++ src/tests/usr.bin/xlint/lint1/gcc_attribute.exp	Mon May  3 06:24:18 2021
@@ -1 +1,2 @@
 gcc_attribute.c(39): error: syntax error 'unknown_attribute' [249]
+gcc_attribute.c(51): error: syntax error 'pcs' [249]



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

2021-05-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon May  3 03:50:43 UTC 2021

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

Log Message:
tests/lint: remove outdated comment

The test d_gcc_extension is already activated in line 121.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/tests/usr.bin/xlint/lint1/t_integration.sh

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/t_integration.sh
diff -u src/tests/usr.bin/xlint/lint1/t_integration.sh:1.47 src/tests/usr.bin/xlint/lint1/t_integration.sh:1.48
--- src/tests/usr.bin/xlint/lint1/t_integration.sh:1.47	Sun May  2 21:22:09 2021
+++ src/tests/usr.bin/xlint/lint1/t_integration.sh	Mon May  3 03:50:43 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.47 2021/05/02 21:22:09 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.48 2021/05/03 03:50:43 rillig Exp $
 #
 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -158,9 +158,6 @@ test_case d_gcc_compound_statements1
 test_case d_gcc_compound_statements2
 test_case d_gcc_compound_statements3
 
-# XXX: Because of polymorphic __builtin_isnan and expression has null effect
-# test_case gcc_extension "Checks GCC __extension__ and __typeof__"
-
 test_case d_cvt_in_ternary
 test_case d_cvt_constant
 test_case d_ellipsis_in_switch



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

2021-05-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun May  2 21:47:28 UTC 2021

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

Log Message:
tests/lint: fix test for GCC bit-field types

The whole purpose of this test is to try the message about invalid
bit-field types in GCC mode.  Therefore, use the default lint1-flags
that include -g.


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

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/gcc_bit_field_types.c
diff -u src/tests/usr.bin/xlint/lint1/gcc_bit_field_types.c:1.1 src/tests/usr.bin/xlint/lint1/gcc_bit_field_types.c:1.2
--- src/tests/usr.bin/xlint/lint1/gcc_bit_field_types.c:1.1	Sun May  2 21:22:09 2021
+++ src/tests/usr.bin/xlint/lint1/gcc_bit_field_types.c	Sun May  2 21:47:28 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: gcc_bit_field_types.c,v 1.1 2021/05/02 21:22:09 rillig Exp $	*/
+/*	$NetBSD: gcc_bit_field_types.c,v 1.2 2021/05/02 21:47:28 rillig Exp $	*/
 # 3 "gcc_bit_field_types.c"
 
 /*
@@ -10,12 +10,6 @@
  * See msg_035.c.
  */
 
-// Test for message: illegal bit-field type '%s' [35]
-
-/* Omit -g, see gcc_bit_field_types.c. */
-/* lint1-flags: -Sw */
-
-/* Try all types from tspec_t. */
 struct example {
 	int int_flag: 1;
 	unsigned int unsigned_int_flag: 1;
Index: src/tests/usr.bin/xlint/lint1/gcc_bit_field_types.exp
diff -u src/tests/usr.bin/xlint/lint1/gcc_bit_field_types.exp:1.1 src/tests/usr.bin/xlint/lint1/gcc_bit_field_types.exp:1.2
--- src/tests/usr.bin/xlint/lint1/gcc_bit_field_types.exp:1.1	Sun May  2 21:22:09 2021
+++ src/tests/usr.bin/xlint/lint1/gcc_bit_field_types.exp	Sun May  2 21:47:28 2021
@@ -1,5 +1,5 @@
-gcc_bit_field_types.c(22): warning: illegal bit-field type 'long' [35]
-gcc_bit_field_types.c(23): warning: illegal bit-field type 'unsigned long' [35]
-gcc_bit_field_types.c(24): warning: illegal bit-field type 'long long' [35]
-gcc_bit_field_types.c(25): warning: illegal bit-field type 'unsigned long long' [35]
-gcc_bit_field_types.c(26): warning: illegal bit-field type 'double' [35]
+gcc_bit_field_types.c(16): warning: illegal bit-field type 'long' [35]
+gcc_bit_field_types.c(17): warning: illegal bit-field type 'unsigned long' [35]
+gcc_bit_field_types.c(18): warning: illegal bit-field type 'long long' [35]
+gcc_bit_field_types.c(19): warning: illegal bit-field type 'unsigned long long' [35]
+gcc_bit_field_types.c(20): warning: illegal bit-field type 'double' [35]



  1   2   3   4   5   >