Module Name: src Committed By: rillig Date: Sun Jan 3 15:35:01 UTC 2021
Modified Files: src/tests/usr.bin/xlint/lint1: msg_027.c msg_027.exp msg_029.c msg_029.exp msg_031.c msg_031.exp msg_034.c msg_034.exp msg_036.c msg_036.exp msg_037.c msg_037.exp msg_071.c msg_071.exp msg_072.c msg_072.exp msg_073.c msg_073.exp msg_074.c msg_074.exp msg_086.c msg_086.exp msg_087.c msg_087.exp msg_088.c msg_088.exp msg_230.c msg_230.exp Log Message: lint: add tests for some of the messages To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_027.c \ src/tests/usr.bin/xlint/lint1/msg_027.exp \ src/tests/usr.bin/xlint/lint1/msg_029.c \ src/tests/usr.bin/xlint/lint1/msg_029.exp \ src/tests/usr.bin/xlint/lint1/msg_031.c \ src/tests/usr.bin/xlint/lint1/msg_031.exp \ src/tests/usr.bin/xlint/lint1/msg_034.c \ src/tests/usr.bin/xlint/lint1/msg_034.exp \ src/tests/usr.bin/xlint/lint1/msg_036.c \ src/tests/usr.bin/xlint/lint1/msg_036.exp \ src/tests/usr.bin/xlint/lint1/msg_037.c \ src/tests/usr.bin/xlint/lint1/msg_037.exp \ src/tests/usr.bin/xlint/lint1/msg_071.c \ src/tests/usr.bin/xlint/lint1/msg_071.exp \ src/tests/usr.bin/xlint/lint1/msg_072.c \ src/tests/usr.bin/xlint/lint1/msg_072.exp \ src/tests/usr.bin/xlint/lint1/msg_073.c \ src/tests/usr.bin/xlint/lint1/msg_073.exp \ src/tests/usr.bin/xlint/lint1/msg_074.c \ src/tests/usr.bin/xlint/lint1/msg_074.exp \ src/tests/usr.bin/xlint/lint1/msg_086.c \ src/tests/usr.bin/xlint/lint1/msg_086.exp \ src/tests/usr.bin/xlint/lint1/msg_087.c \ src/tests/usr.bin/xlint/lint1/msg_087.exp \ src/tests/usr.bin/xlint/lint1/msg_088.c \ src/tests/usr.bin/xlint/lint1/msg_088.exp \ src/tests/usr.bin/xlint/lint1/msg_230.c \ src/tests/usr.bin/xlint/lint1/msg_230.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_027.c diff -u src/tests/usr.bin/xlint/lint1/msg_027.c:1.1 src/tests/usr.bin/xlint/lint1/msg_027.c:1.2 --- src/tests/usr.bin/xlint/lint1/msg_027.c:1.1 Sat Jan 2 10:22:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_027.c Sun Jan 3 15:35:00 2021 @@ -1,7 +1,8 @@ -/* $NetBSD: msg_027.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */ +/* $NetBSD: msg_027.c,v 1.2 2021/01/03 15:35:00 rillig Exp $ */ # 3 "msg_027.c" // Test for message: redeclaration of %s [27] -TODO: "Add example code that triggers the above message." -TODO: "Add example code that almost triggers the above message." +extern int identifier(void); + +extern double identifier(void); Index: src/tests/usr.bin/xlint/lint1/msg_027.exp diff -u src/tests/usr.bin/xlint/lint1/msg_027.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_027.exp:1.2 --- src/tests/usr.bin/xlint/lint1/msg_027.exp:1.1 Sat Jan 2 10:22:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_027.exp Sun Jan 3 15:35:00 2021 @@ -1 +1 @@ -msg_027.c(6): syntax error ':' [249] +msg_027.c(8): redeclaration of identifier [27] Index: src/tests/usr.bin/xlint/lint1/msg_029.c diff -u src/tests/usr.bin/xlint/lint1/msg_029.c:1.1 src/tests/usr.bin/xlint/lint1/msg_029.c:1.2 --- src/tests/usr.bin/xlint/lint1/msg_029.c:1.1 Sat Jan 2 10:22:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_029.c Sun Jan 3 15:35:00 2021 @@ -1,7 +1,11 @@ -/* $NetBSD: msg_029.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */ +/* $NetBSD: msg_029.c,v 1.2 2021/01/03 15:35:00 rillig Exp $ */ # 3 "msg_029.c" // Test for message: previously declared extern, becomes static: %s [29] -TODO: "Add example code that triggers the above message." -TODO: "Add example code that almost triggers the above message." +extern int function(void); + +static int function(void) +{ + return function(); +} Index: src/tests/usr.bin/xlint/lint1/msg_029.exp diff -u src/tests/usr.bin/xlint/lint1/msg_029.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_029.exp:1.2 --- src/tests/usr.bin/xlint/lint1/msg_029.exp:1.1 Sat Jan 2 10:22:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_029.exp Sun Jan 3 15:35:00 2021 @@ -1 +1 @@ -msg_029.c(6): syntax error ':' [249] +msg_029.c(9): warning: previously declared extern, becomes static: function [29] Index: src/tests/usr.bin/xlint/lint1/msg_031.c diff -u src/tests/usr.bin/xlint/lint1/msg_031.c:1.1 src/tests/usr.bin/xlint/lint1/msg_031.c:1.2 --- src/tests/usr.bin/xlint/lint1/msg_031.c:1.1 Sat Jan 2 10:22:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_031.c Sun Jan 3 15:35:00 2021 @@ -1,7 +1,15 @@ -/* $NetBSD: msg_031.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */ +/* $NetBSD: msg_031.c,v 1.2 2021/01/03 15:35:00 rillig Exp $ */ # 3 "msg_031.c" // Test for message: incomplete structure or union %s: %s [31] -TODO: "Add example code that triggers the above message." -TODO: "Add example code that almost triggers the above message." +struct complete { + int dummy; +}; + +struct incomplete; + + +struct complete complete_var; + +struct incomplete incomplete_var; Index: src/tests/usr.bin/xlint/lint1/msg_031.exp diff -u src/tests/usr.bin/xlint/lint1/msg_031.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_031.exp:1.2 --- src/tests/usr.bin/xlint/lint1/msg_031.exp:1.1 Sat Jan 2 10:22:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_031.exp Sun Jan 3 15:35:00 2021 @@ -1 +1,2 @@ -msg_031.c(6): syntax error ':' [249] +msg_031.c(10): warning: struct incomplete never defined [233] +msg_031.c(15): incomplete structure or union incomplete: incomplete_var [31] Index: src/tests/usr.bin/xlint/lint1/msg_034.c diff -u src/tests/usr.bin/xlint/lint1/msg_034.c:1.1 src/tests/usr.bin/xlint/lint1/msg_034.c:1.2 --- src/tests/usr.bin/xlint/lint1/msg_034.c:1.1 Sat Jan 2 10:22:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_034.c Sun Jan 3 15:35:00 2021 @@ -1,7 +1,11 @@ -/* $NetBSD: msg_034.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */ +/* $NetBSD: msg_034.c,v 1.2 2021/01/03 15:35:00 rillig Exp $ */ # 3 "msg_034.c" // Test for message: nonportable bit-field type [34] -TODO: "Add example code that triggers the above message." -TODO: "Add example code that almost triggers the above message." +/* lint1-flags: -S -g -p -w */ + +struct example { + int nonportable: 1; + unsigned int portable: 1; +}; Index: src/tests/usr.bin/xlint/lint1/msg_034.exp diff -u src/tests/usr.bin/xlint/lint1/msg_034.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_034.exp:1.2 --- src/tests/usr.bin/xlint/lint1/msg_034.exp:1.1 Sat Jan 2 10:22:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_034.exp Sun Jan 3 15:35:00 2021 @@ -1 +1 @@ -msg_034.c(6): syntax error ':' [249] +msg_034.c(9): warning: nonportable bit-field type [34] Index: src/tests/usr.bin/xlint/lint1/msg_036.c diff -u src/tests/usr.bin/xlint/lint1/msg_036.c:1.1 src/tests/usr.bin/xlint/lint1/msg_036.c:1.2 --- src/tests/usr.bin/xlint/lint1/msg_036.c:1.1 Sat Jan 2 10:22:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_036.c Sun Jan 3 15:35:00 2021 @@ -1,7 +1,10 @@ -/* $NetBSD: msg_036.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */ +/* $NetBSD: msg_036.c,v 1.2 2021/01/03 15:35:00 rillig Exp $ */ # 3 "msg_036.c" // Test for message: illegal bit-field size: %d [36] -TODO: "Add example code that triggers the above message." -TODO: "Add example code that almost triggers the above message." +struct example { + unsigned int too_large: 100000; + unsigned int negative: -1; + unsigned int ok: 3; +}; Index: src/tests/usr.bin/xlint/lint1/msg_036.exp diff -u src/tests/usr.bin/xlint/lint1/msg_036.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_036.exp:1.2 --- src/tests/usr.bin/xlint/lint1/msg_036.exp:1.1 Sat Jan 2 10:22:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_036.exp Sun Jan 3 15:35:00 2021 @@ -1 +1,2 @@ -msg_036.c(6): syntax error ':' [249] +msg_036.c(7): illegal bit-field size: 160 [36] +msg_036.c(8): illegal bit-field size: 255 [36] Index: src/tests/usr.bin/xlint/lint1/msg_037.c diff -u src/tests/usr.bin/xlint/lint1/msg_037.c:1.1 src/tests/usr.bin/xlint/lint1/msg_037.c:1.2 --- src/tests/usr.bin/xlint/lint1/msg_037.c:1.1 Sat Jan 2 10:22:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_037.c Sun Jan 3 15:35:00 2021 @@ -1,7 +1,9 @@ -/* $NetBSD: msg_037.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */ +/* $NetBSD: msg_037.c,v 1.2 2021/01/03 15:35:00 rillig Exp $ */ # 3 "msg_037.c" // Test for message: zero size bit-field [37] -TODO: "Add example code that triggers the above message." -TODO: "Add example code that almost triggers the above message." +struct example { + unsigned int zero: 0; + unsigned int ok: 3; +}; Index: src/tests/usr.bin/xlint/lint1/msg_037.exp diff -u src/tests/usr.bin/xlint/lint1/msg_037.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_037.exp:1.2 --- src/tests/usr.bin/xlint/lint1/msg_037.exp:1.1 Sat Jan 2 10:22:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_037.exp Sun Jan 3 15:35:00 2021 @@ -1 +1 @@ -msg_037.c(6): syntax error ':' [249] +msg_037.c(7): zero size bit-field [37] Index: src/tests/usr.bin/xlint/lint1/msg_071.c diff -u src/tests/usr.bin/xlint/lint1/msg_071.c:1.1 src/tests/usr.bin/xlint/lint1/msg_071.c:1.2 --- src/tests/usr.bin/xlint/lint1/msg_071.c:1.1 Sat Jan 2 10:22:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_071.c Sun Jan 3 15:35:00 2021 @@ -1,7 +1,11 @@ -/* $NetBSD: msg_071.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */ +/* $NetBSD: msg_071.c,v 1.2 2021/01/03 15:35:00 rillig Exp $ */ # 3 "msg_071.c" // Test for message: too many characters in character constant [71] -TODO: "Add example code that triggers the above message." -TODO: "Add example code that almost triggers the above message." +/* + * C11 6.4.4.4p7 says: Each hexadecimal escape sequence is the longest + * sequence of characters that can constitute the escape sequence. + */ +char valid_multi_digit_hex = '\x0000000000000000000000a'; +char invalid_multi_digit_hex = '\x000g000000000000000000a'; Index: src/tests/usr.bin/xlint/lint1/msg_071.exp diff -u src/tests/usr.bin/xlint/lint1/msg_071.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_071.exp:1.2 --- src/tests/usr.bin/xlint/lint1/msg_071.exp:1.1 Sat Jan 2 10:22:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_071.exp Sun Jan 3 15:35:00 2021 @@ -1 +1,2 @@ -msg_071.c(6): syntax error ':' [249] +msg_071.c(11): too many characters in character constant [71] +msg_071.c(11): warning: initializer does not fit [178] Index: src/tests/usr.bin/xlint/lint1/msg_072.c diff -u src/tests/usr.bin/xlint/lint1/msg_072.c:1.1 src/tests/usr.bin/xlint/lint1/msg_072.c:1.2 --- src/tests/usr.bin/xlint/lint1/msg_072.c:1.1 Sat Jan 2 10:22:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_072.c Sun Jan 3 15:35:00 2021 @@ -1,7 +1,8 @@ -/* $NetBSD: msg_072.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */ +/* $NetBSD: msg_072.c,v 1.2 2021/01/03 15:35:00 rillig Exp $ */ # 3 "msg_072.c" // Test for message: typedef declares no type name [72] -TODO: "Add example code that triggers the above message." -TODO: "Add example code that almost triggers the above message." +typedef int; + +typedef int number; Index: src/tests/usr.bin/xlint/lint1/msg_072.exp diff -u src/tests/usr.bin/xlint/lint1/msg_072.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_072.exp:1.2 --- src/tests/usr.bin/xlint/lint1/msg_072.exp:1.1 Sat Jan 2 10:22:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_072.exp Sun Jan 3 15:35:00 2021 @@ -1 +1 @@ -msg_072.c(6): syntax error ':' [249] +msg_072.c(6): warning: typedef declares no type name [72] Index: src/tests/usr.bin/xlint/lint1/msg_073.c diff -u src/tests/usr.bin/xlint/lint1/msg_073.c:1.1 src/tests/usr.bin/xlint/lint1/msg_073.c:1.2 --- src/tests/usr.bin/xlint/lint1/msg_073.c:1.1 Sat Jan 2 10:22:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_073.c Sun Jan 3 15:35:00 2021 @@ -1,7 +1,7 @@ -/* $NetBSD: msg_073.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */ +/* $NetBSD: msg_073.c,v 1.2 2021/01/03 15:35:00 rillig Exp $ */ # 3 "msg_073.c" // Test for message: empty character constant [73] -TODO: "Add example code that triggers the above message." -TODO: "Add example code that almost triggers the above message." +char empty = ''; +char letter = 'x'; Index: src/tests/usr.bin/xlint/lint1/msg_073.exp diff -u src/tests/usr.bin/xlint/lint1/msg_073.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_073.exp:1.2 --- src/tests/usr.bin/xlint/lint1/msg_073.exp:1.1 Sat Jan 2 10:22:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_073.exp Sun Jan 3 15:35:00 2021 @@ -1 +1 @@ -msg_073.c(6): syntax error ':' [249] +msg_073.c(6): empty character constant [73] Index: src/tests/usr.bin/xlint/lint1/msg_074.c diff -u src/tests/usr.bin/xlint/lint1/msg_074.c:1.1 src/tests/usr.bin/xlint/lint1/msg_074.c:1.2 --- src/tests/usr.bin/xlint/lint1/msg_074.c:1.1 Sat Jan 2 10:22:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_074.c Sun Jan 3 15:35:00 2021 @@ -1,7 +1,9 @@ -/* $NetBSD: msg_074.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */ +/* $NetBSD: msg_074.c,v 1.2 2021/01/03 15:35:00 rillig Exp $ */ # 3 "msg_074.c" // Test for message: no hex digits follow \x [74] -TODO: "Add example code that triggers the above message." -TODO: "Add example code that almost triggers the above message." +char invalid_hex = '\x'; +char invalid_hex_letter = '\xg'; +char valid_hex = '\xff'; +char valid_single_digit_hex = '\xa'; Index: src/tests/usr.bin/xlint/lint1/msg_074.exp diff -u src/tests/usr.bin/xlint/lint1/msg_074.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_074.exp:1.2 --- src/tests/usr.bin/xlint/lint1/msg_074.exp:1.1 Sat Jan 2 10:22:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_074.exp Sun Jan 3 15:35:00 2021 @@ -1 +1,3 @@ -msg_074.c(6): syntax error ':' [249] +msg_074.c(6): no hex digits follow \x [74] +msg_074.c(7): no hex digits follow \x [74] +msg_074.c(7): warning: multi-character character constant [294] Index: src/tests/usr.bin/xlint/lint1/msg_086.c diff -u src/tests/usr.bin/xlint/lint1/msg_086.c:1.1 src/tests/usr.bin/xlint/lint1/msg_086.c:1.2 --- src/tests/usr.bin/xlint/lint1/msg_086.c:1.1 Sat Jan 2 10:22:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_086.c Sun Jan 3 15:35:00 2021 @@ -1,7 +1,22 @@ -/* $NetBSD: msg_086.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */ +/* $NetBSD: msg_086.c,v 1.2 2021/01/03 15:35:00 rillig Exp $ */ # 3 "msg_086.c" // Test for message: automatic hides external declaration: %s [86] -TODO: "Add example code that triggers the above message." -TODO: "Add example code that almost triggers the above message." +/* lint1-flags: -S -g -h -w */ + +extern int identifier; + +int +local_auto(void) +{ + int identifier = 3; + return identifier; +} + +/* XXX: the function argument does not trigger the warning. */ +int +arg_auto(int identifier) +{ + return identifier; +} Index: src/tests/usr.bin/xlint/lint1/msg_086.exp diff -u src/tests/usr.bin/xlint/lint1/msg_086.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_086.exp:1.2 --- src/tests/usr.bin/xlint/lint1/msg_086.exp:1.1 Sat Jan 2 10:22:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_086.exp Sun Jan 3 15:35:00 2021 @@ -1 +1 @@ -msg_086.c(6): syntax error ':' [249] +msg_086.c(13): warning: automatic hides external declaration: identifier [86] Index: src/tests/usr.bin/xlint/lint1/msg_087.c diff -u src/tests/usr.bin/xlint/lint1/msg_087.c:1.1 src/tests/usr.bin/xlint/lint1/msg_087.c:1.2 --- src/tests/usr.bin/xlint/lint1/msg_087.c:1.1 Sat Jan 2 10:22:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_087.c Sun Jan 3 15:35:00 2021 @@ -1,7 +1,15 @@ -/* $NetBSD: msg_087.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */ +/* $NetBSD: msg_087.c,v 1.2 2021/01/03 15:35:00 rillig Exp $ */ # 3 "msg_087.c" // Test for message: static hides external declaration: %s [87] -TODO: "Add example code that triggers the above message." -TODO: "Add example code that almost triggers the above message." +/* lint1-flags: -g -h -S -w */ + +extern int counter; + +int +count(void) +{ + static int counter; + return counter++; +} Index: src/tests/usr.bin/xlint/lint1/msg_087.exp diff -u src/tests/usr.bin/xlint/lint1/msg_087.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_087.exp:1.2 --- src/tests/usr.bin/xlint/lint1/msg_087.exp:1.1 Sat Jan 2 10:22:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_087.exp Sun Jan 3 15:35:00 2021 @@ -1 +1 @@ -msg_087.c(6): syntax error ':' [249] +msg_087.c(13): warning: static hides external declaration: counter [87] Index: src/tests/usr.bin/xlint/lint1/msg_088.c diff -u src/tests/usr.bin/xlint/lint1/msg_088.c:1.1 src/tests/usr.bin/xlint/lint1/msg_088.c:1.2 --- src/tests/usr.bin/xlint/lint1/msg_088.c:1.1 Sat Jan 2 10:22:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_088.c Sun Jan 3 15:35:00 2021 @@ -1,7 +1,14 @@ -/* $NetBSD: msg_088.c,v 1.1 2021/01/02 10:22:43 rillig Exp $ */ +/* $NetBSD: msg_088.c,v 1.2 2021/01/03 15:35:00 rillig Exp $ */ # 3 "msg_088.c" // Test for message: typedef hides external declaration: %s [88] -TODO: "Add example code that triggers the above message." -TODO: "Add example code that almost triggers the above message." +/* lint1-flags: -g -h -S -w */ + +extern int identifier; + +void +func(void) +{ + typedef double identifier; +} Index: src/tests/usr.bin/xlint/lint1/msg_088.exp diff -u src/tests/usr.bin/xlint/lint1/msg_088.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_088.exp:1.2 --- src/tests/usr.bin/xlint/lint1/msg_088.exp:1.1 Sat Jan 2 10:22:43 2021 +++ src/tests/usr.bin/xlint/lint1/msg_088.exp Sun Jan 3 15:35:00 2021 @@ -1 +1 @@ -msg_088.c(6): syntax error ':' [249] +msg_088.c(13): warning: typedef hides external declaration: identifier [88] Index: src/tests/usr.bin/xlint/lint1/msg_230.c diff -u src/tests/usr.bin/xlint/lint1/msg_230.c:1.1 src/tests/usr.bin/xlint/lint1/msg_230.c:1.2 --- src/tests/usr.bin/xlint/lint1/msg_230.c:1.1 Sat Jan 2 10:22:44 2021 +++ src/tests/usr.bin/xlint/lint1/msg_230.c Sun Jan 3 15:35:01 2021 @@ -1,7 +1,26 @@ -/* $NetBSD: msg_230.c,v 1.1 2021/01/02 10:22:44 rillig Exp $ */ +/* $NetBSD: msg_230.c,v 1.2 2021/01/03 15:35:01 rillig Exp $ */ # 3 "msg_230.c" // Test for message: nonportable character comparison, op %s [230] -TODO: "Add example code that triggers the above message." -TODO: "Add example code that almost triggers the above message." +/* lint1-flags: -S -g -p -w */ + +void example(char c, unsigned char uc, signed char sc) +{ + if (c < 0) + if (uc < 0) + if (sc < 0) + return; + + /* + * XXX: The comparison "<= -1" looks very similar to "< 0", + * nevertheless "< 0" does not generate a warning. + * + * The comparisons may actually differ subtly because of the usual + * arithmetic promotions. + * */ + if (c <= -1) + if (uc <= -1) + if (sc <= -1) + return; +} Index: src/tests/usr.bin/xlint/lint1/msg_230.exp diff -u src/tests/usr.bin/xlint/lint1/msg_230.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_230.exp:1.2 --- src/tests/usr.bin/xlint/lint1/msg_230.exp:1.1 Sat Jan 2 10:22:44 2021 +++ src/tests/usr.bin/xlint/lint1/msg_230.exp Sun Jan 3 15:35:01 2021 @@ -1 +1,3 @@ -msg_230.c(6): syntax error ':' [249] +msg_230.c(11): warning: comparison of unsigned char with 0, op p < p [162] +msg_230.c(22): warning: nonportable character comparison, op p <= p [230] +msg_230.c(23): warning: comparison of unsigned char with negative constant, op p <= p [162]