Module Name: src Committed By: rillig Date: Sun Apr 3 09:34:46 UTC 2022
Modified Files: src/tests/usr.bin/xlint/lint1: msg_090.c msg_090.exp msg_091.c msg_091.exp msg_092.c msg_092.exp msg_093.c msg_093.exp msg_094.c msg_094.exp msg_095.c msg_095.exp msg_096.c msg_096.exp msg_097.c msg_097.exp msg_098.c msg_098.exp msg_099.c msg_099.exp Log Message: tests/lint: make a few tests self-contained, add some others To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_090.c \ src/tests/usr.bin/xlint/lint1/msg_090.exp \ src/tests/usr.bin/xlint/lint1/msg_091.c \ src/tests/usr.bin/xlint/lint1/msg_091.exp \ src/tests/usr.bin/xlint/lint1/msg_092.c \ src/tests/usr.bin/xlint/lint1/msg_092.exp \ src/tests/usr.bin/xlint/lint1/msg_093.exp \ src/tests/usr.bin/xlint/lint1/msg_095.exp cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_093.c \ src/tests/usr.bin/xlint/lint1/msg_094.c \ src/tests/usr.bin/xlint/lint1/msg_094.exp \ src/tests/usr.bin/xlint/lint1/msg_095.c \ src/tests/usr.bin/xlint/lint1/msg_097.c \ src/tests/usr.bin/xlint/lint1/msg_097.exp cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_096.c \ src/tests/usr.bin/xlint/lint1/msg_098.c \ src/tests/usr.bin/xlint/lint1/msg_098.exp \ src/tests/usr.bin/xlint/lint1/msg_099.c \ src/tests/usr.bin/xlint/lint1/msg_099.exp cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_096.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_090.c diff -u src/tests/usr.bin/xlint/lint1/msg_090.c:1.2 src/tests/usr.bin/xlint/lint1/msg_090.c:1.3 --- src/tests/usr.bin/xlint/lint1/msg_090.c:1.2 Sun Feb 21 09:07:58 2021 +++ src/tests/usr.bin/xlint/lint1/msg_090.c Sun Apr 3 09:34:45 2022 @@ -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); +} Index: src/tests/usr.bin/xlint/lint1/msg_090.exp diff -u src/tests/usr.bin/xlint/lint1/msg_090.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_090.exp:1.3 --- src/tests/usr.bin/xlint/lint1/msg_090.exp:1.2 Sun Mar 21 20:44:59 2021 +++ src/tests/usr.bin/xlint/lint1/msg_090.exp Sun Apr 3 09:34:45 2022 @@ -1 +1 @@ -msg_090.c(6): error: syntax error ':' [249] +msg_090.c(12): warning: inconsistent redeclaration of extern: random_number [90] Index: src/tests/usr.bin/xlint/lint1/msg_091.c diff -u src/tests/usr.bin/xlint/lint1/msg_091.c:1.2 src/tests/usr.bin/xlint/lint1/msg_091.c:1.3 --- src/tests/usr.bin/xlint/lint1/msg_091.c:1.2 Sun Feb 21 09:07:58 2021 +++ src/tests/usr.bin/xlint/lint1/msg_091.c Sun Apr 3 09:34:45 2022 @@ -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] */ -TODO: "Add example code that triggers the above message." /* expect: 249 */ -TODO: "Add example code that almost triggers the above message." +/* lint1-flags: -htw */ + +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; +} Index: src/tests/usr.bin/xlint/lint1/msg_091.exp diff -u src/tests/usr.bin/xlint/lint1/msg_091.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_091.exp:1.3 --- src/tests/usr.bin/xlint/lint1/msg_091.exp:1.2 Sun Mar 21 20:44:59 2021 +++ src/tests/usr.bin/xlint/lint1/msg_091.exp Sun Apr 3 09:34:45 2022 @@ -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] Index: src/tests/usr.bin/xlint/lint1/msg_092.c diff -u src/tests/usr.bin/xlint/lint1/msg_092.c:1.2 src/tests/usr.bin/xlint/lint1/msg_092.c:1.3 --- src/tests/usr.bin/xlint/lint1/msg_092.c:1.2 Sun Feb 21 09:07:58 2021 +++ src/tests/usr.bin/xlint/lint1/msg_092.c Sun Apr 3 09:34:45 2022 @@ -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); +} Index: src/tests/usr.bin/xlint/lint1/msg_092.exp diff -u src/tests/usr.bin/xlint/lint1/msg_092.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_092.exp:1.3 --- src/tests/usr.bin/xlint/lint1/msg_092.exp:1.2 Sun Mar 21 20:44:59 2021 +++ src/tests/usr.bin/xlint/lint1/msg_092.exp Sun Apr 3 09:34:45 2022 @@ -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] Index: src/tests/usr.bin/xlint/lint1/msg_093.exp diff -u src/tests/usr.bin/xlint/lint1/msg_093.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_093.exp:1.3 --- src/tests/usr.bin/xlint/lint1/msg_093.exp:1.2 Thu Jan 7 00:38:46 2021 +++ src/tests/usr.bin/xlint/lint1/msg_093.exp Sun Apr 3 09:34:45 2022 @@ -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] Index: src/tests/usr.bin/xlint/lint1/msg_095.exp diff -u src/tests/usr.bin/xlint/lint1/msg_095.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_095.exp:1.3 --- src/tests/usr.bin/xlint/lint1/msg_095.exp:1.2 Thu Jan 7 00:38:46 2021 +++ src/tests/usr.bin/xlint/lint1/msg_095.exp Sun Apr 3 09:34:45 2022 @@ -1 +1 @@ -msg_095.c(15): warning: declaration hides earlier one: identifier [95] +msg_095.c(16): warning: declaration hides earlier one: identifier [95] Index: src/tests/usr.bin/xlint/lint1/msg_093.c diff -u src/tests/usr.bin/xlint/lint1/msg_093.c:1.3 src/tests/usr.bin/xlint/lint1/msg_093.c:1.4 --- src/tests/usr.bin/xlint/lint1/msg_093.c:1.3 Sun Jan 31 11:12:07 2021 +++ src/tests/usr.bin/xlint/lint1/msg_093.c Sun Apr 3 09:34:45 2022 @@ -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(); } Index: src/tests/usr.bin/xlint/lint1/msg_094.c diff -u src/tests/usr.bin/xlint/lint1/msg_094.c:1.3 src/tests/usr.bin/xlint/lint1/msg_094.c:1.4 --- src/tests/usr.bin/xlint/lint1/msg_094.c:1.3 Sun Jan 31 11:12:07 2021 +++ src/tests/usr.bin/xlint/lint1/msg_094.c Sun Apr 3 09:34:45 2022 @@ -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; } Index: src/tests/usr.bin/xlint/lint1/msg_094.exp diff -u src/tests/usr.bin/xlint/lint1/msg_094.exp:1.3 src/tests/usr.bin/xlint/lint1/msg_094.exp:1.4 --- src/tests/usr.bin/xlint/lint1/msg_094.exp:1.3 Sun Mar 21 20:44:59 2021 +++ src/tests/usr.bin/xlint/lint1/msg_094.exp Sun Apr 3 09:34:45 2022 @@ -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] Index: src/tests/usr.bin/xlint/lint1/msg_095.c diff -u src/tests/usr.bin/xlint/lint1/msg_095.c:1.3 src/tests/usr.bin/xlint/lint1/msg_095.c:1.4 --- src/tests/usr.bin/xlint/lint1/msg_095.c:1.3 Sun Jan 31 11:12:07 2021 +++ src/tests/usr.bin/xlint/lint1/msg_095.c Sun Apr 3 09:34:45 2022 @@ -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 @@ example(int identifier) { { - int identifier = 3; /* expect: 95 */ + /* expect+1: warning: declaration hides earlier one: identifier [95] */ + int identifier = 3; } return identifier; Index: src/tests/usr.bin/xlint/lint1/msg_097.c diff -u src/tests/usr.bin/xlint/lint1/msg_097.c:1.3 src/tests/usr.bin/xlint/lint1/msg_097.c:1.4 --- src/tests/usr.bin/xlint/lint1/msg_097.c:1.3 Sun Jan 31 11:12:07 2021 +++ src/tests/usr.bin/xlint/lint1/msg_097.c Sun Apr 3 09:34:45 2022 @@ -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 @@ example() { 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; } Index: src/tests/usr.bin/xlint/lint1/msg_097.exp diff -u src/tests/usr.bin/xlint/lint1/msg_097.exp:1.3 src/tests/usr.bin/xlint/lint1/msg_097.exp:1.4 --- src/tests/usr.bin/xlint/lint1/msg_097.exp:1.3 Sat Jul 3 21:27:48 2021 +++ src/tests/usr.bin/xlint/lint1/msg_097.exp Sun Apr 3 09:34:45 2022 @@ -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] Index: src/tests/usr.bin/xlint/lint1/msg_096.c diff -u src/tests/usr.bin/xlint/lint1/msg_096.c:1.4 src/tests/usr.bin/xlint/lint1/msg_096.c:1.5 --- src/tests/usr.bin/xlint/lint1/msg_096.c:1.4 Mon Apr 5 01:35:34 2021 +++ src/tests/usr.bin/xlint/lint1/msg_096.c Sun Apr 3 09:34:45 2022 @@ -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 @@ unary_minus(int i) 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; } Index: src/tests/usr.bin/xlint/lint1/msg_098.c diff -u src/tests/usr.bin/xlint/lint1/msg_098.c:1.4 src/tests/usr.bin/xlint/lint1/msg_098.c:1.5 --- src/tests/usr.bin/xlint/lint1/msg_098.c:1.4 Mon Apr 5 01:35:34 2021 +++ src/tests/usr.bin/xlint/lint1/msg_098.c Sun Apr 3 09:34:45 2022 @@ -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 @@ void 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; } Index: src/tests/usr.bin/xlint/lint1/msg_098.exp diff -u src/tests/usr.bin/xlint/lint1/msg_098.exp:1.4 src/tests/usr.bin/xlint/lint1/msg_098.exp:1.5 --- src/tests/usr.bin/xlint/lint1/msg_098.exp:1.4 Sat Jul 3 21:27:48 2021 +++ src/tests/usr.bin/xlint/lint1/msg_098.exp Sun Apr 3 09:34:45 2022 @@ -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] Index: src/tests/usr.bin/xlint/lint1/msg_099.c diff -u src/tests/usr.bin/xlint/lint1/msg_099.c:1.4 src/tests/usr.bin/xlint/lint1/msg_099.c:1.5 --- src/tests/usr.bin/xlint/lint1/msg_099.c:1.4 Fri Mar 26 23:17:33 2021 +++ src/tests/usr.bin/xlint/lint1/msg_099.c Sun Apr 3 09:34:45 2022 @@ -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" // Test for message: '%s' undefined [99] @@ -7,5 +7,6 @@ void example(int defined_variable) { int ok = defined_variable; - int error = undefined_variable; /* expect: 99 */ + /* expect+1: error: 'undefined_variable' undefined [99] */ + int error = undefined_variable; } Index: src/tests/usr.bin/xlint/lint1/msg_099.exp diff -u src/tests/usr.bin/xlint/lint1/msg_099.exp:1.4 src/tests/usr.bin/xlint/lint1/msg_099.exp:1.5 --- src/tests/usr.bin/xlint/lint1/msg_099.exp:1.4 Fri Mar 26 23:17:33 2021 +++ src/tests/usr.bin/xlint/lint1/msg_099.exp Sun Apr 3 09:34:45 2022 @@ -1 +1 @@ -msg_099.c(10): error: 'undefined_variable' undefined [99] +msg_099.c(11): error: 'undefined_variable' undefined [99] Index: src/tests/usr.bin/xlint/lint1/msg_096.exp diff -u src/tests/usr.bin/xlint/lint1/msg_096.exp:1.5 src/tests/usr.bin/xlint/lint1/msg_096.exp:1.6 --- src/tests/usr.bin/xlint/lint1/msg_096.exp:1.5 Tue Aug 3 18:44:33 2021 +++ src/tests/usr.bin/xlint/lint1/msg_096.exp Sun Apr 3 09:34:45 2022 @@ -1,3 +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]