Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/lint1 tests/lint: add tests for messages about...



details:   https://anonhg.NetBSD.org/src/rev/abc342592140
branches:  trunk
changeset: 362460:abc342592140
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Feb 27 20:02:43 2022 +0000

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

diffstat:

 tests/usr.bin/xlint/lint1/msg_058.c   |  15 ++++++++++++---
 tests/usr.bin/xlint/lint1/msg_058.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_059.c   |  11 ++++++++---
 tests/usr.bin/xlint/lint1/msg_059.exp |   3 ++-
 tests/usr.bin/xlint/lint1/msg_062.c   |   9 ++++++---
 tests/usr.bin/xlint/lint1/msg_062.exp |   3 ++-
 tests/usr.bin/xlint/lint1/msg_063.c   |  13 ++++++++++---
 tests/usr.bin/xlint/lint1/msg_063.exp |   2 +-
 usr.bin/xlint/lint1/decl.c            |  10 +++++-----
 9 files changed, 47 insertions(+), 21 deletions(-)

diffs (142 lines):

diff -r d12fa0e75421 -r abc342592140 tests/usr.bin/xlint/lint1/msg_058.c
--- a/tests/usr.bin/xlint/lint1/msg_058.c       Sun Feb 27 19:32:51 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_058.c       Sun Feb 27 20:02:43 2022 +0000
@@ -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];
+}
diff -r d12fa0e75421 -r abc342592140 tests/usr.bin/xlint/lint1/msg_058.exp
--- a/tests/usr.bin/xlint/lint1/msg_058.exp     Sun Feb 27 19:32:51 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_058.exp     Sun Feb 27 20:02:43 2022 +0000
@@ -1,1 +1,1 @@
-msg_058.c(6): error: syntax error ':' [249]
+msg_058.c(14): error: type does not match prototype: dbl [58]
diff -r d12fa0e75421 -r abc342592140 tests/usr.bin/xlint/lint1/msg_059.c
--- a/tests/usr.bin/xlint/lint1/msg_059.c       Sun Feb 27 19:32:51 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_059.c       Sun Feb 27 20:02:43 2022 +0000
@@ -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;
+}
diff -r d12fa0e75421 -r abc342592140 tests/usr.bin/xlint/lint1/msg_059.exp
--- a/tests/usr.bin/xlint/lint1/msg_059.exp     Sun Feb 27 19:32:51 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_059.exp     Sun Feb 27 20:02:43 2022 +0000
@@ -1,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]
diff -r d12fa0e75421 -r abc342592140 tests/usr.bin/xlint/lint1/msg_062.c
--- a/tests/usr.bin/xlint/lint1/msg_062.c       Sun Feb 27 19:32:51 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_062.c       Sun Feb 27 20:02:43 2022 +0000
@@ -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);
+}
diff -r d12fa0e75421 -r abc342592140 tests/usr.bin/xlint/lint1/msg_062.exp
--- a/tests/usr.bin/xlint/lint1/msg_062.exp     Sun Feb 27 19:32:51 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_062.exp     Sun Feb 27 20:02:43 2022 +0000
@@ -1,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]
diff -r d12fa0e75421 -r abc342592140 tests/usr.bin/xlint/lint1/msg_063.c
--- a/tests/usr.bin/xlint/lint1/msg_063.c       Sun Feb 27 19:32:51 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_063.c       Sun Feb 27 20:02:43 2022 +0000
@@ -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);
diff -r d12fa0e75421 -r abc342592140 tests/usr.bin/xlint/lint1/msg_063.exp
--- a/tests/usr.bin/xlint/lint1/msg_063.exp     Sun Feb 27 19:32:51 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_063.exp     Sun Feb 27 20:02:43 2022 +0000
@@ -1,1 +1,1 @@
-msg_063.c(6): error: syntax error ':' [249]
+msg_063.c(14): error: prototype does not match old-style definition [63]
diff -r d12fa0e75421 -r abc342592140 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Sun Feb 27 19:32:51 2022 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Sun Feb 27 20:02:43 2022 +0000
@@ -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 @@
 {
 
        /*
-        * 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;



Home | Main Index | Thread Index | Old Index