Source-Changes-HG archive

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

[src/trunk]: src/tests/usr.bin/xlint/lint1 tests/lint: make a few tests self-...



details:   https://anonhg.NetBSD.org/src/rev/026e6915eb67
branches:  trunk
changeset: 364658:026e6915eb67
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Apr 03 09:34:45 2022 +0000

description:
tests/lint: make a few tests self-contained, add some others

diffstat:

 tests/usr.bin/xlint/lint1/msg_090.c   |  12 +++++++++---
 tests/usr.bin/xlint/lint1/msg_090.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_091.c   |  17 +++++++++++++----
 tests/usr.bin/xlint/lint1/msg_091.exp |   3 ++-
 tests/usr.bin/xlint/lint1/msg_092.c   |  19 ++++++++++++++++---
 tests/usr.bin/xlint/lint1/msg_092.exp |   3 ++-
 tests/usr.bin/xlint/lint1/msg_093.c   |   5 +++--
 tests/usr.bin/xlint/lint1/msg_093.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_094.c   |   8 +++++---
 tests/usr.bin/xlint/lint1/msg_094.exp |   4 ++--
 tests/usr.bin/xlint/lint1/msg_095.c   |   5 +++--
 tests/usr.bin/xlint/lint1/msg_095.exp |   2 +-
 tests/usr.bin/xlint/lint1/msg_096.c   |  11 +++++++----
 tests/usr.bin/xlint/lint1/msg_096.exp |   4 +---
 tests/usr.bin/xlint/lint1/msg_097.c   |  15 ++++++++++-----
 tests/usr.bin/xlint/lint1/msg_097.exp |   6 +++---
 tests/usr.bin/xlint/lint1/msg_098.c   |  18 ++++++++++++------
 tests/usr.bin/xlint/lint1/msg_098.exp |  10 +++++-----
 tests/usr.bin/xlint/lint1/msg_099.c   |   5 +++--
 tests/usr.bin/xlint/lint1/msg_099.exp |   2 +-
 20 files changed, 100 insertions(+), 53 deletions(-)

diffs (truncated from 315 to 300 lines):

diff -r 3c4c71e5ce81 -r 026e6915eb67 tests/usr.bin/xlint/lint1/msg_090.c
--- a/tests/usr.bin/xlint/lint1/msg_090.c       Sun Apr 03 01:12:47 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_090.c       Sun Apr 03 09:34:45 2022 +0000
@@ -1,7 +1,13 @@
-/*     $NetBSD: msg_090.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_090.c,v 1.3 2022/04/03 09:34:45 rillig Exp $       */
 # 3 "msg_090.c"
 
 // Test for message: inconsistent redeclaration of extern: %s [90]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+extern int random_number(void);
+
+void
+use(void)
+{
+       /* expect+1: warning: inconsistent redeclaration of extern: random_number [90] */
+       extern int random_number(int);
+}
diff -r 3c4c71e5ce81 -r 026e6915eb67 tests/usr.bin/xlint/lint1/msg_090.exp
--- a/tests/usr.bin/xlint/lint1/msg_090.exp     Sun Apr 03 01:12:47 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_090.exp     Sun Apr 03 09:34:45 2022 +0000
@@ -1,1 +1,1 @@
-msg_090.c(6): error: syntax error ':' [249]
+msg_090.c(12): warning: inconsistent redeclaration of extern: random_number [90]
diff -r 3c4c71e5ce81 -r 026e6915eb67 tests/usr.bin/xlint/lint1/msg_091.c
--- a/tests/usr.bin/xlint/lint1/msg_091.c       Sun Apr 03 01:12:47 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_091.c       Sun Apr 03 09:34:45 2022 +0000
@@ -1,7 +1,16 @@
-/*     $NetBSD: msg_091.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_091.c,v 1.3 2022/04/03 09:34:45 rillig Exp $       */
 # 3 "msg_091.c"
 
-// Test for message: declaration hides parameter: %s [91]
+/* Test for message: declaration hides parameter: %s [91] */
+
+/* lint1-flags: -htw */
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+add(a, b)
+       int a, b;
+{
+       /* expect+1: warning: declaration hides parameter: a [91] */
+       int a;
+
+       /* expect+1: warning: a may be used before set [158] */
+       return a + b;
+}
diff -r 3c4c71e5ce81 -r 026e6915eb67 tests/usr.bin/xlint/lint1/msg_091.exp
--- a/tests/usr.bin/xlint/lint1/msg_091.exp     Sun Apr 03 01:12:47 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_091.exp     Sun Apr 03 09:34:45 2022 +0000
@@ -1,1 +1,2 @@
-msg_091.c(6): error: syntax error ':' [249]
+msg_091.c(12): warning: declaration hides parameter: a [91]
+msg_091.c(15): warning: a may be used before set [158]
diff -r 3c4c71e5ce81 -r 026e6915eb67 tests/usr.bin/xlint/lint1/msg_092.c
--- a/tests/usr.bin/xlint/lint1/msg_092.c       Sun Apr 03 01:12:47 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_092.c       Sun Apr 03 09:34:45 2022 +0000
@@ -1,7 +1,20 @@
-/*     $NetBSD: msg_092.c,v 1.2 2021/02/21 09:07:58 rillig Exp $       */
+/*     $NetBSD: msg_092.c,v 1.3 2022/04/03 09:34:45 rillig Exp $       */
 # 3 "msg_092.c"
 
 // Test for message: inconsistent redeclaration of static: %s [92]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+static int
+random(void)
+{
+       return 4;
+}
+
+void
+use_random(void)
+{
+       random();
+
+       /* expect+2: warning: dubious static function at block level: random [93] */
+       /* expect+1: warning: inconsistent redeclaration of static: random [92] */
+       static double random(void);
+}
diff -r 3c4c71e5ce81 -r 026e6915eb67 tests/usr.bin/xlint/lint1/msg_092.exp
--- a/tests/usr.bin/xlint/lint1/msg_092.exp     Sun Apr 03 01:12:47 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_092.exp     Sun Apr 03 09:34:45 2022 +0000
@@ -1,1 +1,2 @@
-msg_092.c(6): error: syntax error ':' [249]
+msg_092.c(19): warning: dubious static function at block level: random [93]
+msg_092.c(19): warning: inconsistent redeclaration of static: random [92]
diff -r 3c4c71e5ce81 -r 026e6915eb67 tests/usr.bin/xlint/lint1/msg_093.c
--- a/tests/usr.bin/xlint/lint1/msg_093.c       Sun Apr 03 01:12:47 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_093.c       Sun Apr 03 09:34:45 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_093.c,v 1.3 2021/01/31 11:12:07 rillig Exp $       */
+/*     $NetBSD: msg_093.c,v 1.4 2022/04/03 09:34:45 rillig Exp $       */
 # 3 "msg_093.c"
 
 // Test for message: dubious static function at block level: %s [93]
@@ -6,7 +6,8 @@
 void
 example(void)
 {
-       static void nested(void);       /* expect: 93 */
+       /* expect+1: warning: dubious static function at block level: nested [93] */
+       static void nested(void);
 
        nested();
 }
diff -r 3c4c71e5ce81 -r 026e6915eb67 tests/usr.bin/xlint/lint1/msg_093.exp
--- a/tests/usr.bin/xlint/lint1/msg_093.exp     Sun Apr 03 01:12:47 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_093.exp     Sun Apr 03 09:34:45 2022 +0000
@@ -1,1 +1,1 @@
-msg_093.c(9): warning: dubious static function at block level: nested [93]
+msg_093.c(10): warning: dubious static function at block level: nested [93]
diff -r 3c4c71e5ce81 -r 026e6915eb67 tests/usr.bin/xlint/lint1/msg_094.c
--- a/tests/usr.bin/xlint/lint1/msg_094.c       Sun Apr 03 01:12:47 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_094.c       Sun Apr 03 09:34:45 2022 +0000
@@ -1,12 +1,14 @@
-/*     $NetBSD: msg_094.c,v 1.3 2021/01/31 11:12:07 rillig Exp $       */
+/*     $NetBSD: msg_094.c,v 1.4 2022/04/03 09:34:45 rillig Exp $       */
 # 3 "msg_094.c"
 
 // Test for message: function has illegal storage class: %s [94]
 
+/* expect+2: error: illegal storage class [8] */
 register int
-global_example(int arg)                                /* expect: 8 */
+global_example(int arg)
 {
-       register int register_example(int);     /* expect: 94 */
+       /* expect+1: error: function has illegal storage class: register_example [94] */
+       register int register_example(int);
 
        return arg;
 }
diff -r 3c4c71e5ce81 -r 026e6915eb67 tests/usr.bin/xlint/lint1/msg_094.exp
--- a/tests/usr.bin/xlint/lint1/msg_094.exp     Sun Apr 03 01:12:47 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_094.exp     Sun Apr 03 09:34:45 2022 +0000
@@ -1,2 +1,2 @@
-msg_094.c(7): error: illegal storage class [8]
-msg_094.c(9): error: function has illegal storage class: register_example [94]
+msg_094.c(8): error: illegal storage class [8]
+msg_094.c(11): error: function has illegal storage class: register_example [94]
diff -r 3c4c71e5ce81 -r 026e6915eb67 tests/usr.bin/xlint/lint1/msg_095.c
--- a/tests/usr.bin/xlint/lint1/msg_095.c       Sun Apr 03 01:12:47 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_095.c       Sun Apr 03 09:34:45 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_095.c,v 1.3 2021/01/31 11:12:07 rillig Exp $       */
+/*     $NetBSD: msg_095.c,v 1.4 2022/04/03 09:34:45 rillig Exp $       */
 # 3 "msg_095.c"
 
 // Test for message: declaration hides earlier one: %s [95]
@@ -12,7 +12,8 @@
 {
 
        {
-               int identifier = 3;     /* expect: 95 */
+               /* expect+1: warning: declaration hides earlier one: identifier [95] */
+               int identifier = 3;
        }
 
        return identifier;
diff -r 3c4c71e5ce81 -r 026e6915eb67 tests/usr.bin/xlint/lint1/msg_095.exp
--- a/tests/usr.bin/xlint/lint1/msg_095.exp     Sun Apr 03 01:12:47 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_095.exp     Sun Apr 03 09:34:45 2022 +0000
@@ -1,1 +1,1 @@
-msg_095.c(15): warning: declaration hides earlier one: identifier [95]
+msg_095.c(16): warning: declaration hides earlier one: identifier [95]
diff -r 3c4c71e5ce81 -r 026e6915eb67 tests/usr.bin/xlint/lint1/msg_096.c
--- a/tests/usr.bin/xlint/lint1/msg_096.c       Sun Apr 03 01:12:47 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_096.c       Sun Apr 03 09:34:45 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_096.c,v 1.4 2021/04/05 01:35:34 rillig Exp $       */
+/*     $NetBSD: msg_096.c,v 1.5 2022/04/03 09:34:45 rillig Exp $       */
 # 3 "msg_096.c"
 
 // Test for message: cannot dereference non-pointer type [96]
@@ -15,8 +15,11 @@
        return -i;
 }
 
-int
-unary_asterisk(int i)          /* expect: 231 */
+void
+unary_asterisk(int i)
 {
-       return *i;              /* expect: 96 *//* expect: 214 */
+       i++;
+
+       /* expect+1: error: cannot dereference non-pointer type [96] */
+       return *i;
 }
diff -r 3c4c71e5ce81 -r 026e6915eb67 tests/usr.bin/xlint/lint1/msg_096.exp
--- a/tests/usr.bin/xlint/lint1/msg_096.exp     Sun Apr 03 01:12:47 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_096.exp     Sun Apr 03 09:34:45 2022 +0000
@@ -1,3 +1,1 @@
-msg_096.c(21): error: cannot dereference non-pointer type [96]
-msg_096.c(21): warning: function 'unary_asterisk' expects to return value [214]
-msg_096.c(19): warning: argument 'i' unused in function 'unary_asterisk' [231]
+msg_096.c(24): error: cannot dereference non-pointer type [96]
diff -r 3c4c71e5ce81 -r 026e6915eb67 tests/usr.bin/xlint/lint1/msg_097.c
--- a/tests/usr.bin/xlint/lint1/msg_097.c       Sun Apr 03 01:12:47 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_097.c       Sun Apr 03 09:34:45 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_097.c,v 1.3 2021/01/31 11:12:07 rillig Exp $       */
+/*     $NetBSD: msg_097.c,v 1.4 2022/04/03 09:34:45 rillig Exp $       */
 # 3 "msg_097.c"
 
 /* Test for message: suffix U is illegal in traditional C [97] */
@@ -10,12 +10,17 @@
 {
        int i = 1234567;
        unsigned u = 1234567;
-       unsigned u_upper = 1234567U;            /* expect: 97 */
-       unsigned u_lower = 1234567u;            /* expect: 97 */
+
+       /* expect+1: warning: suffix U is illegal in traditional C [97] */
+       unsigned u_upper = 1234567U;
+       /* expect+1: warning: suffix U is illegal in traditional C [97] */
+       unsigned u_lower = 1234567u;
 
        long l = 1234567L;
-       unsigned long ul = 1234567UL;           /* expect: 97 */
+       /* expect+1: warning: suffix U is illegal in traditional C [97] */
+       unsigned long ul = 1234567UL;
 
        long long ll = 1234567LL;
-       unsigned long long ull = 1234567ULL;    /* expect: 97 */
+       /* expect+1: warning: suffix U is illegal in traditional C [97] */
+       unsigned long long ull = 1234567ULL;
 }
diff -r 3c4c71e5ce81 -r 026e6915eb67 tests/usr.bin/xlint/lint1/msg_097.exp
--- a/tests/usr.bin/xlint/lint1/msg_097.exp     Sun Apr 03 01:12:47 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_097.exp     Sun Apr 03 09:34:45 2022 +0000
@@ -1,4 +1,4 @@
-msg_097.c(13): warning: suffix U is illegal in traditional C [97]
-msg_097.c(14): warning: suffix U is illegal in traditional C [97]
+msg_097.c(15): warning: suffix U is illegal in traditional C [97]
 msg_097.c(17): warning: suffix U is illegal in traditional C [97]
-msg_097.c(20): warning: suffix U is illegal in traditional C [97]
+msg_097.c(21): warning: suffix U is illegal in traditional C [97]
+msg_097.c(25): warning: suffix U is illegal in traditional C [97]
diff -r 3c4c71e5ce81 -r 026e6915eb67 tests/usr.bin/xlint/lint1/msg_098.c
--- a/tests/usr.bin/xlint/lint1/msg_098.c       Sun Apr 03 01:12:47 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_098.c       Sun Apr 03 09:34:45 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_098.c,v 1.4 2021/04/05 01:35:34 rillig Exp $       */
+/*     $NetBSD: msg_098.c,v 1.5 2022/04/03 09:34:45 rillig Exp $       */
 # 3 "msg_098.c"
 
 /* Test for message: suffixes F and L are illegal in traditional C [98] */
@@ -9,12 +9,18 @@
 example()
 {
        float f = 1234.5;
-       float f_F = 1234.5F;            /* expect: 98 */
-       float f_f = 1234.5f;            /* expect: 98 */
+       /* expect+1: warning: suffixes F and L are illegal in traditional C [98] */
+       float f_F = 1234.5F;
+       /* expect+1: warning: suffixes F and L are illegal in traditional C [98] */
+       float f_f = 1234.5f;
 
        double d = 1234.5;
-       double d_U = 1234.5U;           /* expect: 249 */
+       /* expect+1: error: syntax error 'U' [249] */
+       double d_U = 1234.5U;
 
-       long double ld = 1234.5;        /* expect: 266 */
-       long double ld_L = 1234.5L;     /* expect: 98 *//* expect: 266 */
+       /* expect+1: warning: 'long double' is illegal in traditional C [266] */
+       long double ld = 1234.5;
+       /* expect+2: warning: 'long double' is illegal in traditional C [266] */
+       /* expect+1: warning: suffixes F and L are illegal in traditional C [98] */
+       long double ld_L = 1234.5L;
 }
diff -r 3c4c71e5ce81 -r 026e6915eb67 tests/usr.bin/xlint/lint1/msg_098.exp
--- a/tests/usr.bin/xlint/lint1/msg_098.exp     Sun Apr 03 01:12:47 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_098.exp     Sun Apr 03 09:34:45 2022 +0000
@@ -1,6 +1,6 @@
-msg_098.c(12): warning: suffixes F and L are illegal in traditional C [98]
 msg_098.c(13): warning: suffixes F and L are illegal in traditional C [98]
-msg_098.c(16): error: syntax error 'U' [249]
-msg_098.c(18): warning: 'long double' is illegal in traditional C [266]
-msg_098.c(19): warning: 'long double' is illegal in traditional C [266]
-msg_098.c(19): warning: suffixes F and L are illegal in traditional C [98]
+msg_098.c(15): warning: suffixes F and L are illegal in traditional C [98]
+msg_098.c(19): error: syntax error 'U' [249]
+msg_098.c(22): warning: 'long double' is illegal in traditional C [266]
+msg_098.c(25): warning: 'long double' is illegal in traditional C [266]
+msg_098.c(25): warning: suffixes F and L are illegal in traditional C [98]
diff -r 3c4c71e5ce81 -r 026e6915eb67 tests/usr.bin/xlint/lint1/msg_099.c
--- a/tests/usr.bin/xlint/lint1/msg_099.c       Sun Apr 03 01:12:47 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_099.c       Sun Apr 03 09:34:45 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msg_099.c,v 1.4 2021/03/26 23:17:33 rillig Exp $       */
+/*     $NetBSD: msg_099.c,v 1.5 2022/04/03 09:34:45 rillig Exp $       */
 # 3 "msg_099.c"
 



Home | Main Index | Thread Index | Old Index