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 lint: add a few more tests



details:   https://anonhg.NetBSD.org/src/rev/7ff2436c2e99
branches:  trunk
changeset: 979604:7ff2436c2e99
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jan 02 18:06:01 2021 +0000

description:
lint: add a few more tests

No serious bugs found this time.

diffstat:

 tests/usr.bin/xlint/lint1/msg_000.c   |   9 ++++++---
 tests/usr.bin/xlint/lint1/msg_000.exp |   3 ++-
 tests/usr.bin/xlint/lint1/msg_001.c   |   7 ++++---
 tests/usr.bin/xlint/lint1/msg_001.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_002.c   |   7 ++++---
 tests/usr.bin/xlint/lint1/msg_002.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_004.c   |  20 +++++++++++++++++---
 tests/usr.bin/xlint/lint1/msg_004.exp |   5 ++++-
 tests/usr.bin/xlint/lint1/msg_005.c   |   7 ++++---
 tests/usr.bin/xlint/lint1/msg_005.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_085.c   |   8 +++++---
 tests/usr.bin/xlint/lint1/msg_085.exp |   3 ++-
 usr.bin/xlint/lint1/decl.c            |   8 ++++----
 13 files changed, 55 insertions(+), 28 deletions(-)

diffs (183 lines):

diff -r cfa7a560b817 -r 7ff2436c2e99 tests/usr.bin/xlint/lint1/msg_000.c
--- a/tests/usr.bin/xlint/lint1/msg_000.c       Sat Jan 02 17:17:00 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_000.c       Sat Jan 02 18:06:01 2021 +0000
@@ -1,7 +1,10 @@
-/*     $NetBSD: msg_000.c,v 1.1 2021/01/02 10:22:42 rillig Exp $       */
+/*     $NetBSD: msg_000.c,v 1.2 2021/01/02 18:06:01 rillig Exp $       */
 # 3 "msg_000.c"
 
 // Test for message: empty declaration [0]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+extern int extern_declared;
+
+;
+
+static int local_defined;
diff -r cfa7a560b817 -r 7ff2436c2e99 tests/usr.bin/xlint/lint1/msg_000.exp
--- a/tests/usr.bin/xlint/lint1/msg_000.exp     Sat Jan 02 17:17:00 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_000.exp     Sat Jan 02 18:06:01 2021 +0000
@@ -1,1 +1,2 @@
-msg_000.c(6): syntax error ':' [249]
+msg_000.c(8): warning: empty declaration [0]
+msg_000.c(10): warning: static variable local_defined unused [226]
diff -r cfa7a560b817 -r 7ff2436c2e99 tests/usr.bin/xlint/lint1/msg_001.c
--- a/tests/usr.bin/xlint/lint1/msg_001.c       Sat Jan 02 17:17:00 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_001.c       Sat Jan 02 18:06:01 2021 +0000
@@ -1,7 +1,8 @@
-/*     $NetBSD: msg_001.c,v 1.1 2021/01/02 10:22:42 rillig Exp $       */
+/*     $NetBSD: msg_001.c,v 1.2 2021/01/02 18:06:01 rillig Exp $       */
 # 3 "msg_001.c"
 
 // Test for message: old style declaration; add int [1]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+old_style = 1;
+
+int new_style = 1;
diff -r cfa7a560b817 -r 7ff2436c2e99 tests/usr.bin/xlint/lint1/msg_001.exp
--- a/tests/usr.bin/xlint/lint1/msg_001.exp     Sat Jan 02 17:17:00 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_001.exp     Sat Jan 02 18:06:01 2021 +0000
@@ -1,1 +1,1 @@
-msg_001.c(6): syntax error ':' [249]
+msg_001.c(6): warning: old style declaration; add int [1]
diff -r cfa7a560b817 -r 7ff2436c2e99 tests/usr.bin/xlint/lint1/msg_002.c
--- a/tests/usr.bin/xlint/lint1/msg_002.c       Sat Jan 02 17:17:00 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_002.c       Sat Jan 02 18:06:01 2021 +0000
@@ -1,7 +1,8 @@
-/*     $NetBSD: msg_002.c,v 1.1 2021/01/02 10:22:42 rillig Exp $       */
+/*     $NetBSD: msg_002.c,v 1.2 2021/01/02 18:06:01 rillig Exp $       */
 # 3 "msg_002.c"
 
 // Test for message: empty declaration [2]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+int;
+
+int local_variable;
diff -r cfa7a560b817 -r 7ff2436c2e99 tests/usr.bin/xlint/lint1/msg_002.exp
--- a/tests/usr.bin/xlint/lint1/msg_002.exp     Sat Jan 02 17:17:00 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_002.exp     Sat Jan 02 18:06:01 2021 +0000
@@ -1,1 +1,1 @@
-msg_002.c(6): syntax error ':' [249]
+msg_002.c(6): warning: empty declaration [2]
diff -r cfa7a560b817 -r 7ff2436c2e99 tests/usr.bin/xlint/lint1/msg_004.c
--- a/tests/usr.bin/xlint/lint1/msg_004.c       Sat Jan 02 17:17:00 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_004.c       Sat Jan 02 18:06:01 2021 +0000
@@ -1,7 +1,21 @@
-/*     $NetBSD: msg_004.c,v 1.1 2021/01/02 10:22:42 rillig Exp $       */
+/*     $NetBSD: msg_004.c,v 1.2 2021/01/02 18:06:01 rillig Exp $       */
 # 3 "msg_004.c"
 
 // Test for message: illegal type combination [4]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+// XXX: this goes undetected
+signed double signed_double;
+
+int ok_int;
+double ok_double;
+float _Complex ok_float_complex;
+
+int _Complex illegal_int_complex;
+
+char enum {
+       CHAR
+};
+
+long struct {
+       int member;
+};
diff -r cfa7a560b817 -r 7ff2436c2e99 tests/usr.bin/xlint/lint1/msg_004.exp
--- a/tests/usr.bin/xlint/lint1/msg_004.exp     Sat Jan 02 17:17:00 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_004.exp     Sat Jan 02 18:06:01 2021 +0000
@@ -1,1 +1,4 @@
-msg_004.c(6): syntax error ':' [249]
+msg_004.c(13): Invalid type for _Complex [308]
+msg_004.c(13): illegal type combination [4]
+msg_004.c(17): illegal type combination [4]
+msg_004.c(21): illegal type combination [4]
diff -r cfa7a560b817 -r 7ff2436c2e99 tests/usr.bin/xlint/lint1/msg_005.c
--- a/tests/usr.bin/xlint/lint1/msg_005.c       Sat Jan 02 17:17:00 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_005.c       Sat Jan 02 18:06:01 2021 +0000
@@ -1,7 +1,8 @@
-/*     $NetBSD: msg_005.c,v 1.1 2021/01/02 10:22:42 rillig Exp $       */
+/*     $NetBSD: msg_005.c,v 1.2 2021/01/02 18:06:01 rillig Exp $       */
 # 3 "msg_005.c"
 
 // Test for message: modifying typedef with '%s'; only qualifiers allowed [5]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+typedef int number;
+number long long_variable;
+number const const_variable;
diff -r cfa7a560b817 -r 7ff2436c2e99 tests/usr.bin/xlint/lint1/msg_005.exp
--- a/tests/usr.bin/xlint/lint1/msg_005.exp     Sat Jan 02 17:17:00 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_005.exp     Sat Jan 02 18:06:01 2021 +0000
@@ -1,1 +1,1 @@
-msg_005.c(6): syntax error ':' [249]
+msg_005.c(7): warning: modifying typedef with 'long'; only qualifiers allowed [5]
diff -r cfa7a560b817 -r 7ff2436c2e99 tests/usr.bin/xlint/lint1/msg_085.c
--- a/tests/usr.bin/xlint/lint1/msg_085.c       Sat Jan 02 17:17:00 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_085.c       Sat Jan 02 18:06:01 2021 +0000
@@ -1,7 +1,9 @@
-/*     $NetBSD: msg_085.c,v 1.1 2021/01/02 10:22:43 rillig Exp $       */
+/*     $NetBSD: msg_085.c,v 1.2 2021/01/02 18:06:01 rillig Exp $       */
 # 3 "msg_085.c"
 
 // Test for message: dubious tag declaration: %s %s [85]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+extern int stat(struct stat *);
+
+struct ok;
+extern int ok(struct ok *);
diff -r cfa7a560b817 -r 7ff2436c2e99 tests/usr.bin/xlint/lint1/msg_085.exp
--- a/tests/usr.bin/xlint/lint1/msg_085.exp     Sat Jan 02 17:17:00 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_085.exp     Sat Jan 02 18:06:01 2021 +0000
@@ -1,1 +1,2 @@
-msg_085.c(6): syntax error ':' [249]
+msg_085.c(6): warning: dubious tag declaration: struct stat [85]
+msg_085.c(8): warning: struct ok never defined [233]
diff -r cfa7a560b817 -r 7ff2436c2e99 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Sat Jan 02 17:17:00 2021 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Sat Jan 02 18:06:01 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.100 2021/01/02 17:17:00 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.101 2021/01/02 18:06:01 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.100 2021/01/02 17:17:00 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.101 2021/01/02 18:06:01 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -387,7 +387,7 @@
                if (t2 == CHAR || t2 == SHORT || t2 == INT || t2 == LONG ||
                    t2 == QUAD) {
                        if (!tflag)
-                               /* modifying typedef with ... */
+                               /* modifying typedef with '%s'; only ... */
                                warning(5, ttab[t].tt_name);
                        td = duptyp(gettyp(merge_type_specifiers(t2, t)));
                        td->t_typedef = 1;
@@ -396,7 +396,7 @@
                break;
        case SHORT:
                if (t2 == INT || t2 == UINT) {
-                       /* modifying typedef with ... */
+                       /* modifying typedef with '%s'; only qualifiers ... */
                        warning(5, "short");
                        td = duptyp(gettyp(t2 == INT ? SHORT : USHORT));
                        td->t_typedef = 1;



Home | Main Index | Thread Index | Old Index