Module Name:    src
Committed By:   rillig
Date:           Sun Feb 27 20:02:44 UTC 2022

Modified Files:
        src/tests/usr.bin/xlint/lint1: msg_058.c msg_058.exp msg_059.c
            msg_059.exp msg_062.c msg_062.exp msg_063.c msg_063.exp
        src/usr.bin/xlint/lint1: decl.c

Log Message:
tests/lint: add tests for messages about old-style functions


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_058.c \
    src/tests/usr.bin/xlint/lint1/msg_058.exp \
    src/tests/usr.bin/xlint/lint1/msg_059.c \
    src/tests/usr.bin/xlint/lint1/msg_059.exp \
    src/tests/usr.bin/xlint/lint1/msg_062.c \
    src/tests/usr.bin/xlint/lint1/msg_062.exp \
    src/tests/usr.bin/xlint/lint1/msg_063.c \
    src/tests/usr.bin/xlint/lint1/msg_063.exp
cvs rdiff -u -r1.250 -r1.251 src/usr.bin/xlint/lint1/decl.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_058.c
diff -u src/tests/usr.bin/xlint/lint1/msg_058.c:1.2 src/tests/usr.bin/xlint/lint1/msg_058.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_058.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_058.c	Sun Feb 27 20:02:44 2022
@@ -1,7 +1,16 @@
-/*	$NetBSD: msg_058.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_058.c,v 1.3 2022/02/27 20:02:44 rillig Exp $	*/
 # 3 "msg_058.c"
 
 // Test for message: type does not match prototype: %s [58]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+int function(int, char, const char *);
+
+int
+function(i, dbl, str)
+	int i;
+	double dbl;
+	const char *str;
+/* expect+1: error: type does not match prototype: dbl [58] */
+{
+	return i + (int)dbl + str[0];
+}
Index: src/tests/usr.bin/xlint/lint1/msg_058.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_058.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_058.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_058.exp:1.2	Sun Mar 21 20:44:59 2021
+++ src/tests/usr.bin/xlint/lint1/msg_058.exp	Sun Feb 27 20:02:44 2022
@@ -1 +1 @@
-msg_058.c(6): error: syntax error ':' [249]
+msg_058.c(14): error: type does not match prototype: dbl [58]
Index: src/tests/usr.bin/xlint/lint1/msg_059.c
diff -u src/tests/usr.bin/xlint/lint1/msg_059.c:1.2 src/tests/usr.bin/xlint/lint1/msg_059.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_059.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_059.c	Sun Feb 27 20:02:44 2022
@@ -1,7 +1,12 @@
-/*	$NetBSD: msg_059.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_059.c,v 1.3 2022/02/27 20:02:44 rillig Exp $	*/
 # 3 "msg_059.c"
 
 // Test for message: formal parameter lacks name: param #%d [59]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* expect+4: error: formal parameter lacks name: param #2 [59] */
+/* expect+3: error: formal parameter lacks name: param #3 [59] */
+int
+function_definition(int a, int, double)
+{
+	return a;
+}
Index: src/tests/usr.bin/xlint/lint1/msg_059.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_059.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_059.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_059.exp:1.2	Sun Mar 21 20:44:59 2021
+++ src/tests/usr.bin/xlint/lint1/msg_059.exp	Sun Feb 27 20:02:44 2022
@@ -1 +1,2 @@
-msg_059.c(6): error: syntax error ':' [249]
+msg_059.c(10): error: formal parameter lacks name: param #2 [59]
+msg_059.c(10): error: formal parameter lacks name: param #3 [59]
Index: src/tests/usr.bin/xlint/lint1/msg_062.c
diff -u src/tests/usr.bin/xlint/lint1/msg_062.c:1.2 src/tests/usr.bin/xlint/lint1/msg_062.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_062.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_062.c	Sun Feb 27 20:02:44 2022
@@ -1,7 +1,10 @@
-/*	$NetBSD: msg_062.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_062.c,v 1.3 2022/02/27 20:02:44 rillig Exp $	*/
 # 3 "msg_062.c"
 
 // Test for message: function prototype parameters must have types [62]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+outer() {
+	/* expect+2: warning: function prototype parameters must have types [62] */
+	/* expect+1: warning: dubious static function at block level: inner [93] */
+	static int inner(a);
+}
Index: src/tests/usr.bin/xlint/lint1/msg_062.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_062.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_062.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_062.exp:1.2	Sun Mar 21 20:44:59 2021
+++ src/tests/usr.bin/xlint/lint1/msg_062.exp	Sun Feb 27 20:02:44 2022
@@ -1 +1,2 @@
-msg_062.c(6): error: syntax error ':' [249]
+msg_062.c(9): warning: function prototype parameters must have types [62]
+msg_062.c(9): warning: dubious static function at block level: inner [93]
Index: src/tests/usr.bin/xlint/lint1/msg_063.c
diff -u src/tests/usr.bin/xlint/lint1/msg_063.c:1.2 src/tests/usr.bin/xlint/lint1/msg_063.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_063.c:1.2	Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_063.c	Sun Feb 27 20:02:44 2022
@@ -1,7 +1,14 @@
-/*	$NetBSD: msg_063.c,v 1.2 2021/02/21 09:07:58 rillig Exp $	*/
+/*	$NetBSD: msg_063.c,v 1.3 2022/02/27 20:02:44 rillig Exp $	*/
 # 3 "msg_063.c"
 
 // Test for message: prototype does not match old-style definition [63]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+int
+function(a, b)
+	int a, b;
+{
+	return a + b;
+}
+
+/* expect+1: error: prototype does not match old-style definition [63] */
+double function(int);
Index: src/tests/usr.bin/xlint/lint1/msg_063.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_063.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_063.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_063.exp:1.2	Sun Mar 21 20:44:59 2021
+++ src/tests/usr.bin/xlint/lint1/msg_063.exp	Sun Feb 27 20:02:44 2022
@@ -1 +1 @@
-msg_063.c(6): error: syntax error ':' [249]
+msg_063.c(14): error: prototype does not match old-style definition [63]

Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.250 src/usr.bin/xlint/lint1/decl.c:1.251
--- src/usr.bin/xlint/lint1/decl.c:1.250	Sun Feb 27 11:40:29 2022
+++ src/usr.bin/xlint/lint1/decl.c	Sun Feb 27 20:02:43 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.250 2022/02/27 11:40:29 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.251 2022/02/27 20:02:43 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.250 2022/02/27 11:40:29 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.251 2022/02/27 20:02:43 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -1470,14 +1470,14 @@ old_style_function(sym_t *decl, sym_t *a
 {
 
 	/*
-	 * Remember list of params only if this is really seams to be
-	 * a function definition.
+	 * Remember list of parameters only if this really seems to be a
+	 * function definition.
 	 */
 	if (dcs->d_next->d_ctx == EXTERN &&
 	    decl->s_type == dcs->d_next->d_type) {
 		/*
 		 * We assume that this becomes a function definition. If
-		 * we are wrong, it's corrected in check_function_definition().
+		 * we are wrong, it's corrected in check_function_definition.
 		 */
 		if (args != NULL) {
 			decl->s_osdef = true;

Reply via email to