tests/lint: make 'expect+-' comments stricter Previously, the expectations from these comments were already satisfied if the expectation occurred somewhere in the actual message from lint. This meant that the prefix 'error:' or 'warning:' could be omitted from the 'expect' comment. These omissions were hard to see in a manual review. Now any omissions must be visually marked with '...'. The test msg_342 now reports its messages properly as being in the file msg_342.c, rather than msg_341.c. This had been a copy-and-paste mistake.diff -r1.20 -r1.21 src/tests/usr.bin/xlint/check-expect.lua
(rillig)
--- src/tests/usr.bin/xlint/Attic/check-expect.lua 2022/06/17 16:10:10 1.20
+++ src/tests/usr.bin/xlint/Attic/check-expect.lua 2022/06/17 18:54:53 1.21
@@ -1,49 +1,61 @@ | @@ -1,49 +1,61 @@ | |||
1 | #! /usr/bin/lua | 1 | #! /usr/bin/lua | |
2 | -- $NetBSD: check-expect.lua,v 1.20 2022/06/17 16:10:10 rillig Exp $ | 2 | -- $NetBSD: check-expect.lua,v 1.21 2022/06/17 18:54:53 rillig Exp $ | |
3 | 3 | |||
4 | --[[ | 4 | --[[ | |
5 | 5 | |||
6 | usage: lua ./check-expect.lua *.c | 6 | usage: lua ./check-expect.lua *.c | |
7 | 7 | |||
8 | Check that the /* expect+-n: ... */ comments in the .c source files match the | 8 | Check that the /* expect+-n: ... */ comments in the .c source files match the | |
9 | actual messages found in the corresponding .exp files. | 9 | actual messages found in the corresponding .exp files. | |
10 | 10 | |||
11 | To regenerate the .exp files, see lint1/accept.sh. | 11 | To regenerate the .exp files, see lint1/accept.sh. | |
12 | ]] | 12 | ]] | |
13 | 13 | |||
14 | 14 | |||
15 | local function test(func) | |||
16 | func() | |||
17 | end | |||
18 | ||||
19 | local function assert_equals(got, expected) | |||
20 | if got ~= expected then | |||
21 | assert(false, string.format("got %q, expected %q", got, expected)) | |||
22 | end | |||
23 | end | |||
24 | ||||
25 | ||||
15 | local had_errors = false | 26 | local had_errors = false | |
16 | ---@param fmt string | 27 | ---@param fmt string | |
17 | function print_error(fmt, ...) | 28 | function print_error(fmt, ...) | |
18 | print(fmt:format(...)) | 29 | print(fmt:format(...)) | |
19 | had_errors = true | 30 | had_errors = true | |
20 | end | 31 | end | |
21 | 32 | |||
22 | 33 | |||
23 | local function load_lines(fname) | 34 | local function load_lines(fname) | |
24 | local lines = {} | 35 | local lines = {} | |
25 | 36 | |||
26 | local f = io.open(fname, "r") | 37 | local f = io.open(fname, "r") | |
27 | if f == nil then return nil end | 38 | if f == nil then return nil end | |
28 | 39 | |||
29 | for line in f:lines() do | 40 | for line in f:lines() do | |
30 | table.insert(lines, line) | 41 | table.insert(lines, line) | |
31 | end | 42 | end | |
32 | f:close() | 43 | f:close() | |
33 | 44 | |||
34 | return lines | 45 | return lines | |
35 | end | 46 | end | |
36 | 47 | |||
48 | ||||
37 | -- Load the 'expect:' comments from a C source file. | 49 | -- Load the 'expect:' comments from a C source file. | |
38 | -- | 50 | -- | |
39 | -- example return values: | 51 | -- example return values: | |
40 | -- { | 52 | -- { | |
41 | -- ["file.c(18)"] = {"invalid argument 'a'", "invalid argument 'b'"}, | 53 | -- ["file.c(18)"] = {"invalid argument 'a'", "invalid argument 'b'"}, | |
42 | -- ["file.c(23)"] = {"not a constant expression [123]"}, | 54 | -- ["file.c(23)"] = {"not a constant expression [123]"}, | |
43 | -- }, | 55 | -- }, | |
44 | -- { "file.c(18)", "file.c(23)" } | 56 | -- { "file.c(18)", "file.c(23)" } | |
45 | local function load_c(fname) | 57 | local function load_c(fname) | |
46 | 58 | |||
47 | local lines = load_lines(fname) | 59 | local lines = load_lines(fname) | |
48 | if lines == nil then return nil, nil end | 60 | if lines == nil then return nil, nil end | |
49 | 61 | |||
@@ -104,52 +116,98 @@ local function load_exp(exp_fname) | @@ -104,52 +116,98 @@ local function load_exp(exp_fname) | |||
104 | for location, message in line:gmatch("(%S+%(%d+%)): (.+)$") do | 116 | for location, message in line:gmatch("(%S+%(%d+%)): (.+)$") do | |
105 | table.insert(messages, { | 117 | table.insert(messages, { | |
106 | exp_lineno = exp_lineno, | 118 | exp_lineno = exp_lineno, | |
107 | location = location, | 119 | location = location, | |
108 | message = message | 120 | message = message | |
109 | }) | 121 | }) | |
110 | end | 122 | end | |
111 | end | 123 | end | |
112 | 124 | |||
113 | return messages | 125 | return messages | |
114 | end | 126 | end | |
115 | 127 | |||
116 | 128 | |||
129 | ---@param comment string | |||
130 | ---@param pattern string | |||
131 | ---@return boolean | |||
132 | local function matches(comment, pattern) | |||
133 | if comment == "" then return false end | |||
134 | ||||
135 | local any_prefix = pattern:sub(1, 3) == "..." | |||
136 | if any_prefix then pattern = pattern:sub(4) end | |||
137 | local any_suffix = pattern:sub(-3) == "..." | |||
138 | if any_suffix then pattern = pattern:sub(1, -4) end | |||
139 | ||||
140 | if any_prefix and any_suffix then | |||
141 | return comment:find(pattern, 1, true) ~= nil | |||
142 | elseif any_prefix then | |||
143 | return pattern ~= "" and comment:sub(-#pattern) == pattern | |||
144 | elseif any_suffix then | |||
145 | return comment:sub(1, #pattern) == pattern | |||
146 | else | |||
147 | return comment == pattern | |||
148 | end | |||
149 | end | |||
150 | ||||
151 | test(function() | |||
152 | assert_equals(matches("a", "a"), true) | |||
153 | assert_equals(matches("a", "b"), false) | |||
154 | assert_equals(matches("a", "aaa"), false) | |||
155 | ||||
156 | assert_equals(matches("abc", "a..."), true) | |||
157 | assert_equals(matches("abc", "c..."), false) | |||
158 | ||||
159 | assert_equals(matches("abc", "...c"), true) | |||
160 | assert_equals(matches("abc", "...a"), false) | |||
161 | ||||
162 | assert_equals(matches("abc123xyz", "...a..."), true) | |||
163 | assert_equals(matches("abc123xyz", "...b..."), true) | |||
164 | assert_equals(matches("abc123xyz", "...c..."), true) | |||
165 | assert_equals(matches("abc123xyz", "...1..."), true) | |||
166 | assert_equals(matches("abc123xyz", "...2..."), true) | |||
167 | assert_equals(matches("abc123xyz", "...3..."), true) | |||
168 | assert_equals(matches("abc123xyz", "...x..."), true) | |||
169 | assert_equals(matches("abc123xyz", "...y..."), true) | |||
170 | assert_equals(matches("abc123xyz", "...z..."), true) | |||
171 | assert_equals(matches("pattern", "...pattern..."), true) | |||
172 | end) | |||
173 | ||||
174 | ||||
117 | local function check_test(c_fname) | 175 | local function check_test(c_fname) | |
118 | local exp_fname = c_fname:gsub("%.c$", ".exp") | 176 | local exp_fname = c_fname:gsub("%.c$", ".exp") | |
119 | 177 | |||
120 | local c_comment_locations, c_comments_by_location = load_c(c_fname) | 178 | local c_comment_locations, c_comments_by_location = load_c(c_fname) | |
121 | if c_comment_locations == nil then return end | 179 | if c_comment_locations == nil then return end | |
122 | 180 | |||
123 | local exp_messages = load_exp(exp_fname) | 181 | local exp_messages = load_exp(exp_fname) | |
124 | if exp_messages == nil then return end | 182 | if exp_messages == nil then return end | |
125 | 183 | |||
126 | for _, exp_message in ipairs(exp_messages) do | 184 | for _, exp_message in ipairs(exp_messages) do | |
127 | local c_comments = c_comments_by_location[exp_message.location] or {} | 185 | local c_comments = c_comments_by_location[exp_message.location] or {} | |
128 | local expected_comment = | 186 | local expected_message = | |
129 | exp_message.message:gsub("/%*", "**"):gsub("%*/", "**") | 187 | exp_message.message:gsub("/%*", "**"):gsub("%*/", "**") | |
130 | 188 | |||
131 | local found = false | 189 | local found = false | |
132 | for i, c_comment in ipairs(c_comments) do | 190 | for i, c_comment in ipairs(c_comments) do | |
133 | if c_comment ~= "" and expected_comment:find(c_comment, 1, true) then | 191 | if c_comment ~= "" and matches(expected_message, c_comment) then | |
134 | c_comments[i] = "" | 192 | c_comments[i] = "" | |
135 | found = true | 193 | found = true | |
136 | break | 194 | break | |
137 | end | 195 | end | |
138 | end | 196 | end | |
139 | 197 | |||
140 | if not found then | 198 | if not found then | |
141 | print_error("error: %s: missing /* expect+1: %s */", | 199 | print_error("error: %s: missing /* expect+1: %s */", | |
142 | exp_message.location, expected_comment) | 200 | exp_message.location, expected_message) | |
143 | end | 201 | end | |
144 | end | 202 | end | |
145 | 203 | |||
146 | for _, c_comment_location in ipairs(c_comment_locations) do | 204 | for _, c_comment_location in ipairs(c_comment_locations) do | |
147 | for _, c_comment in ipairs(c_comments_by_location[c_comment_location]) do | 205 | for _, c_comment in ipairs(c_comments_by_location[c_comment_location]) do | |
148 | if c_comment ~= "" then | 206 | if c_comment ~= "" then | |
149 | print_error( | 207 | print_error( | |
150 | "error: %s: declared message \"%s\" is not in the actual output", | 208 | "error: %s: declared message \"%s\" is not in the actual output", | |
151 | c_comment_location, c_comment) | 209 | c_comment_location, c_comment) | |
152 | end | 210 | end | |
153 | end | 211 | end | |
154 | end | 212 | end | |
155 | end | 213 | end |
--- src/tests/usr.bin/xlint/lint1/c11_generic_expression.c 2022/01/15 14:22:03 1.11
+++ src/tests/usr.bin/xlint/lint1/c11_generic_expression.c 2022/06/17 18:54:53 1.12
@@ -1,90 +1,90 @@ | @@ -1,90 +1,90 @@ | |||
1 | /* $NetBSD: c11_generic_expression.c,v 1.11 2022/01/15 14:22:03 rillig Exp $ */ | 1 | /* $NetBSD: c11_generic_expression.c,v 1.12 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "c11_generic_expression.c" | 2 | # 3 "c11_generic_expression.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * C99 added support for type-generic macros, but these were limited to the | 5 | * C99 added support for type-generic macros, but these were limited to the | |
6 | * header <tgmath.h>. C11 made this feature generally available. | 6 | * header <tgmath.h>. C11 made this feature generally available. | |
7 | * | 7 | * | |
8 | * The generic selection is typically used with macros, but since lint1 works | 8 | * The generic selection is typically used with macros, but since lint1 works | |
9 | * on the preprocessed source, the test cases look a bit strange. | 9 | * on the preprocessed source, the test cases look a bit strange. | |
10 | * | 10 | * | |
11 | * C99 6.5.1.1 "Generic selection" | 11 | * C99 6.5.1.1 "Generic selection" | |
12 | */ | 12 | */ | |
13 | 13 | |||
14 | /* lint1-extra-flags: -Ac11 */ | 14 | /* lint1-extra-flags: -Ac11 */ | |
15 | 15 | |||
16 | /* | 16 | /* | |
17 | * The type of 'var' is not compatible with any of the types from the | 17 | * The type of 'var' is not compatible with any of the types from the | |
18 | * generic-association. This is a compile-time error. | 18 | * generic-association. This is a compile-time error. | |
19 | */ | 19 | */ | |
20 | const char * | 20 | const char * | |
21 | classify_type_without_default(double var) | 21 | classify_type_without_default(double var) | |
22 | { | 22 | { | |
23 | /* expect-2: argument 'var' unused */ | 23 | /* expect-2: warning: argument 'var' unused in function 'classify_type_without_default' [231] */ | |
24 | 24 | |||
25 | return _Generic(var, | 25 | return _Generic(var, | |
26 | long double: "long double", | 26 | long double: "long double", | |
27 | long long: "long long", | 27 | long long: "long long", | |
28 | unsigned: "unsigned" | 28 | unsigned: "unsigned" | |
29 | ); | 29 | ); | |
30 | /* expect-1: expects to return value [214] */ | 30 | /* expect-1: warning: function 'classify_type_without_default' expects to return value [214] */ | |
31 | } | 31 | } | |
32 | 32 | |||
33 | /* | 33 | /* | |
34 | * In this case, the 'default' expression is selected. | 34 | * In this case, the 'default' expression is selected. | |
35 | */ | 35 | */ | |
36 | const char * | 36 | const char * | |
37 | classify_type_with_default(double var) | 37 | classify_type_with_default(double var) | |
38 | { | 38 | { | |
39 | /* expect-2: argument 'var' unused */ | 39 | /* expect-2: warning: argument 'var' unused in function 'classify_type_with_default' [231] */ | |
40 | 40 | |||
41 | return _Generic(var, | 41 | return _Generic(var, | |
42 | long double: "long double", | 42 | long double: "long double", | |
43 | long long: "long long", | 43 | long long: "long long", | |
44 | unsigned: "unsigned", | 44 | unsigned: "unsigned", | |
45 | default: "unknown" | 45 | default: "unknown" | |
46 | ); | 46 | ); | |
47 | } | 47 | } | |
48 | 48 | |||
49 | /* | 49 | /* | |
50 | * The type of a _Generic expression is the one from the selected association. | 50 | * The type of a _Generic expression is the one from the selected association. | |
51 | */ | 51 | */ | |
52 | const char * | 52 | const char * | |
53 | classify_char(char c) | 53 | classify_char(char c) | |
54 | { | 54 | { | |
55 | /* expect-2: argument 'c' unused */ | 55 | /* expect-2: warning: argument 'c' unused in function 'classify_char' [231] */ | |
56 | 56 | |||
57 | return _Generic(c, | 57 | return _Generic(c, | |
58 | char: "yes", | 58 | char: "yes", | |
59 | default: 0.0 | 59 | default: 0.0 | |
60 | ); | 60 | ); | |
61 | } | 61 | } | |
62 | 62 | |||
63 | /* | 63 | /* | |
64 | * Before cgram.y 1.238 from 2021-06-27, lint accepted a comma-expression, | 64 | * Before cgram.y 1.238 from 2021-06-27, lint accepted a comma-expression, | |
65 | * which looked as if _Generic would accept multiple arguments before the | 65 | * which looked as if _Generic would accept multiple arguments before the | |
66 | * selection. | 66 | * selection. | |
67 | */ | 67 | */ | |
68 | /* ARGSUSED */ | 68 | /* ARGSUSED */ | |
69 | const int * | 69 | const int * | |
70 | comma_expression(char first, double second) | 70 | comma_expression(char first, double second) | |
71 | { | 71 | { | |
72 | /* expect+1: error: syntax error 'second' [249] */ | 72 | /* expect+1: error: syntax error 'second' [249] */ | |
73 | return _Generic(first, second, | 73 | return _Generic(first, second, | |
74 | char: "first", | 74 | char: "first", | |
75 | double: 2.0 | 75 | double: 2.0 | |
76 | ); | 76 | ); | |
77 | /* expect+1: without returning value [217] */ | 77 | /* expect+1: warning: function comma_expression falls off bottom without returning value [217] */ | |
78 | } | 78 | } | |
79 | 79 | |||
80 | /* | 80 | /* | |
81 | * Ensure that assignment-expressions are accepted by the grammar, as | 81 | * Ensure that assignment-expressions are accepted by the grammar, as | |
82 | * opposed to comma-expressions. | 82 | * opposed to comma-expressions. | |
83 | */ | 83 | */ | |
84 | /* ARGSUSED */ | 84 | /* ARGSUSED */ | |
85 | int | 85 | int | |
86 | assignment_expression(int first, int second) | 86 | assignment_expression(int first, int second) | |
87 | { | 87 | { | |
88 | return _Generic(first = second, | 88 | return _Generic(first = second, | |
89 | int: second = first | 89 | int: second = first | |
90 | ); | 90 | ); |
--- src/tests/usr.bin/xlint/lint1/msg_249.c 2022/06/16 21:24:41 1.11
+++ src/tests/usr.bin/xlint/lint1/msg_249.c 2022/06/17 18:54:53 1.12
@@ -1,31 +1,31 @@ | @@ -1,31 +1,31 @@ | |||
1 | /* $NetBSD: msg_249.c,v 1.11 2022/06/16 21:24:41 rillig Exp $ */ | 1 | /* $NetBSD: msg_249.c,v 1.12 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_249.c" | 2 | # 3 "msg_249.c" | |
3 | 3 | |||
4 | // Test for message: syntax error '%s' [249] | 4 | // Test for message: syntax error '%s' [249] | |
5 | 5 | |||
6 | /* | 6 | /* | |
7 | * Cover the grammar rule 'top_level_declaration: error T_SEMI'. | 7 | * Cover the grammar rule 'top_level_declaration: error T_SEMI'. | |
8 | */ | 8 | */ | |
9 | /* expect+1: syntax error '"' [249] */ | 9 | /* expect+1: error: syntax error '"' [249] */ | |
10 | "syntax error in top_level_declaration"; | 10 | "syntax error in top_level_declaration"; | |
11 | 11 | |||
12 | /* XXX: This is necessary to recover the yacc parser. */ | 12 | /* XXX: This is necessary to recover the yacc parser. */ | |
13 | int recover_from_semi; | 13 | int recover_from_semi; | |
14 | 14 | |||
15 | /* | 15 | /* | |
16 | * Cover the grammar rule 'top_level_declaration: error T_RBRACE'. | 16 | * Cover the grammar rule 'top_level_declaration: error T_RBRACE'. | |
17 | */ | 17 | */ | |
18 | /* expect+1: syntax error '"' [249] */ | 18 | /* expect+1: error: syntax error '"' [249] */ | |
19 | "syntax error in top_level_declaration"} | 19 | "syntax error in top_level_declaration"} | |
20 | 20 | |||
21 | /* XXX: This is necessary to recover the yacc parser. */ | 21 | /* XXX: This is necessary to recover the yacc parser. */ | |
22 | int recover_from_rbrace; | 22 | int recover_from_rbrace; | |
23 | 23 | |||
24 | /* | 24 | /* | |
25 | * Before func.c 1.110 from 2021-06-19, lint ran into this: | 25 | * Before func.c 1.110 from 2021-06-19, lint ran into this: | |
26 | * assertion "cstmt->c_kind == kind" failed in end_control_statement | 26 | * assertion "cstmt->c_kind == kind" failed in end_control_statement | |
27 | */ | 27 | */ | |
28 | void | 28 | void | |
29 | function(void) | 29 | function(void) | |
30 | { | 30 | { | |
31 | /* expect+2: warning: statement not reached [193] */ | 31 | /* expect+2: warning: statement not reached [193] */ |
--- src/tests/usr.bin/xlint/lint1/d_c99_init.c 2022/01/15 14:22:03 1.40
+++ src/tests/usr.bin/xlint/lint1/d_c99_init.c 2022/06/17 18:54:53 1.41
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: d_c99_init.c,v 1.40 2022/01/15 14:22:03 rillig Exp $ */ | 1 | /* $NetBSD: d_c99_init.c,v 1.41 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "d_c99_init.c" | 2 | # 3 "d_c99_init.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Test C99 initializers. | 5 | * Test C99 initializers. | |
6 | * | 6 | * | |
7 | * See C99 6.7.8 "Initialization". | 7 | * See C99 6.7.8 "Initialization". | |
8 | */ | 8 | */ | |
9 | 9 | |||
10 | 10 | |||
11 | void use(const void *); | 11 | void use(const void *); | |
12 | 12 | |||
13 | typedef struct any { | 13 | typedef struct any { | |
14 | const void *value; | 14 | const void *value; | |
@@ -212,46 +212,46 @@ struct geometry { | @@ -212,46 +212,46 @@ struct geometry { | |||
212 | struct pentagon pentagons[6]; | 212 | struct pentagon pentagons[6]; | |
213 | struct triangle triangles[10]; | 213 | struct triangle triangles[10]; | |
214 | struct point points[3][5][2]; | 214 | struct point points[3][5][2]; | |
215 | }; | 215 | }; | |
216 | 216 | |||
217 | /* | 217 | /* | |
218 | * Initialization of a complex struct containing nested arrays and nested | 218 | * Initialization of a complex struct containing nested arrays and nested | |
219 | * structs. | 219 | * structs. | |
220 | */ | 220 | */ | |
221 | struct geometry geometry = { | 221 | struct geometry geometry = { | |
222 | .pentagons[0].points[4].x = 1, | 222 | .pentagons[0].points[4].x = 1, | |
223 | .points[0][0][0] = { 0, 0 }, | 223 | .points[0][0][0] = { 0, 0 }, | |
224 | .points[2][4][1] = {301, 302 }, | 224 | .points[2][4][1] = {301, 302 }, | |
225 | /* expect+1: array subscript cannot be > 2: 3 */ | 225 | /* expect+1: error: array subscript cannot be > 2: 3 [168] */ | |
226 | .points[3][0][0] = {3001, 3002 }, | 226 | .points[3][0][0] = {3001, 3002 }, | |
227 | /* expect+1: array subscript cannot be > 4: 5 */ | 227 | /* expect+1: error: array subscript cannot be > 4: 5 [168] */ | |
228 | .points[0][5][0] = {501, 502 }, | 228 | .points[0][5][0] = {501, 502 }, | |
229 | /* expect+1: array subscript cannot be > 1: 2 */ | 229 | /* expect+1: error: array subscript cannot be > 1: 2 [168] */ | |
230 | .points[0][0][2] = {21, 22 }, | 230 | .points[0][0][2] = {21, 22 }, | |
231 | }; | 231 | }; | |
232 | 232 | |||
233 | struct ends_with_unnamed_bit_field { | 233 | struct ends_with_unnamed_bit_field { | |
234 | int member; | 234 | int member; | |
235 | int:0; | 235 | int:0; | |
236 | } ends_with_unnamed_bit_field = { | 236 | } ends_with_unnamed_bit_field = { | |
237 | 12345, | 237 | 12345, | |
238 | /* expect+1: too many struct/union initializers */ | 238 | /* expect+1: error: too many struct/union initializers [172] */ | |
239 | 23456, | 239 | 23456, | |
240 | }; | 240 | }; | |
241 | 241 | |||
242 | char prefixed_message[] = { | 242 | char prefixed_message[] = { | |
243 | 'E', ':', ' ', | 243 | 'E', ':', ' ', | |
244 | /* expect+1: illegal combination of integer (char) and pointer */ | 244 | /* expect+1: warning: illegal combination of integer (char) and pointer (pointer to char) [183] */ | |
245 | "message\n", | 245 | "message\n", | |
246 | }; | 246 | }; | |
247 | 247 | |||
248 | char message_with_suffix[] = { | 248 | char message_with_suffix[] = { | |
249 | "message", | 249 | "message", | |
250 | /* The excess character is not detected by lint but by compilers. */ | 250 | /* The excess character is not detected by lint but by compilers. */ | |
251 | '\n', | 251 | '\n', | |
252 | }; | 252 | }; | |
253 | 253 | |||
254 | struct ten { | 254 | struct ten { | |
255 | int i0; | 255 | int i0; | |
256 | int i1; | 256 | int i1; | |
257 | int i2; | 257 | int i2; |
--- src/tests/usr.bin/xlint/lint1/d_init_array_using_string.c 2022/01/15 14:22:03 1.10
+++ src/tests/usr.bin/xlint/lint1/d_init_array_using_string.c 2022/06/17 18:54:53 1.11
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: d_init_array_using_string.c,v 1.10 2022/01/15 14:22:03 rillig Exp $ */ | 1 | /* $NetBSD: d_init_array_using_string.c,v 1.11 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "d_init_array_using_string.c" | 2 | # 3 "d_init_array_using_string.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Test initialization of arrays and pointers by string literals. | 5 | * Test initialization of arrays and pointers by string literals. | |
6 | */ | 6 | */ | |
7 | 7 | |||
8 | void sink(const void *); | 8 | void sink(const void *); | |
9 | 9 | |||
10 | void | 10 | void | |
11 | test_assignment_initialization(void) | 11 | test_assignment_initialization(void) | |
12 | { | 12 | { | |
13 | const char *cs_match = ""; | 13 | const char *cs_match = ""; | |
14 | const int *ws_match = L""; | 14 | const int *ws_match = L""; | |
@@ -62,24 +62,24 @@ test_array_initialization_in_struct(void | @@ -62,24 +62,24 @@ test_array_initialization_in_struct(void | |||
62 | struct cs_ws type_mismatch = { | 62 | struct cs_ws type_mismatch = { | |
63 | /* expect+1: warning: illegal combination of integer (char) and pointer (pointer to int) [183] */ | 63 | /* expect+1: warning: illegal combination of integer (char) and pointer (pointer to int) [183] */ | |
64 | L"", | 64 | L"", | |
65 | /* expect+1: warning: illegal combination of integer (char) and pointer (pointer to char) [183] */ | 65 | /* expect+1: warning: illegal combination of integer (char) and pointer (pointer to char) [183] */ | |
66 | "", | 66 | "", | |
67 | }; | 67 | }; | |
68 | 68 | |||
69 | struct cs_ws no_terminating_null = { | 69 | struct cs_ws no_terminating_null = { | |
70 | "0123456789", | 70 | "0123456789", | |
71 | L"0123456789", | 71 | L"0123456789", | |
72 | }; | 72 | }; | |
73 | 73 | |||
74 | struct cs_ws too_many_characters = { | 74 | struct cs_ws too_many_characters = { | |
75 | /* expect+1: warning: string literal too long (11) for target array (10) */ | 75 | /* expect+1: warning: string literal too long (11) for target array (10) [187] */ | |
76 | "0123456789X", | 76 | "0123456789X", | |
77 | /* expect+1: warning: string literal too long (11) for target array (10) */ | 77 | /* expect+1: warning: string literal too long (11) for target array (10) [187] */ | |
78 | L"0123456789X", | 78 | L"0123456789X", | |
79 | }; | 79 | }; | |
80 | 80 | |||
81 | struct cs_ws extra_braces = { | 81 | struct cs_ws extra_braces = { | |
82 | { "" }, | 82 | { "" }, | |
83 | { L"" }, | 83 | { L"" }, | |
84 | }; | 84 | }; | |
85 | } | 85 | } |
--- src/tests/usr.bin/xlint/lint1/gcc_attribute.c 2021/07/15 21:00:05 1.10
+++ src/tests/usr.bin/xlint/lint1/gcc_attribute.c 2022/06/17 18:54:53 1.11
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: gcc_attribute.c,v 1.10 2021/07/15 21:00:05 rillig Exp $ */ | 1 | /* $NetBSD: gcc_attribute.c,v 1.11 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "gcc_attribute.c" | 2 | # 3 "gcc_attribute.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Tests for the various attributes for functions, types, statements that are | 5 | * Tests for the various attributes for functions, types, statements that are | |
6 | * provided by GCC. | 6 | * provided by GCC. | |
7 | * | 7 | * | |
8 | * https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html | 8 | * https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html | |
9 | */ | 9 | */ | |
10 | 10 | |||
11 | void __attribute__((noinline)) | 11 | void __attribute__((noinline)) | |
12 | do_not_inline(void) | 12 | do_not_inline(void) | |
13 | { | 13 | { | |
14 | } | 14 | } | |
@@ -19,27 +19,27 @@ function_nonnull(void *, const void *, i | @@ -19,27 +19,27 @@ function_nonnull(void *, const void *, i | |||
19 | 19 | |||
20 | /* | 20 | /* | |
21 | * The documentation suggests that the argument list of nonnull be nonempty, | 21 | * The documentation suggests that the argument list of nonnull be nonempty, | |
22 | * but GCC 9.3.0 accepts an empty list as well, treating all parameters as | 22 | * but GCC 9.3.0 accepts an empty list as well, treating all parameters as | |
23 | * nonnull. | 23 | * nonnull. | |
24 | */ | 24 | */ | |
25 | void __attribute__((nonnull())) | 25 | void __attribute__((nonnull())) | |
26 | function_nonnull_list(void *, const void *, int); | 26 | function_nonnull_list(void *, const void *, int); | |
27 | 27 | |||
28 | /* Arguments 1 and 2 must be nonnull. */ | 28 | /* Arguments 1 and 2 must be nonnull. */ | |
29 | void __attribute__((nonnull(1, 2))) | 29 | void __attribute__((nonnull(1, 2))) | |
30 | function_nonnull_list(void *, const void *, int); | 30 | function_nonnull_list(void *, const void *, int); | |
31 | 31 | |||
32 | /* expect+1: syntax error 'unknown_attribute' */ | 32 | /* expect+1: error: syntax error 'unknown_attribute' [249] */ | |
33 | void __attribute__((unknown_attribute)) | 33 | void __attribute__((unknown_attribute)) | |
34 | function_with_unknown_attribute(void); | 34 | function_with_unknown_attribute(void); | |
35 | 35 | |||
36 | /* | 36 | /* | |
37 | * There is an attribute called 'pcs', but that attribute must not prevent an | 37 | * There is an attribute called 'pcs', but that attribute must not prevent an | |
38 | * ordinary variable from being named the same. Starting with scan.l 1.77 | 38 | * ordinary variable from being named the same. Starting with scan.l 1.77 | |
39 | * from 2017-01-07, that variable name generated a syntax error. Fixed in | 39 | * from 2017-01-07, that variable name generated a syntax error. Fixed in | |
40 | * lex.c 1.33 from 2021-05-03. | 40 | * lex.c 1.33 from 2021-05-03. | |
41 | * | 41 | * | |
42 | * Seen in yds.c, function yds_allocate_slots. | 42 | * Seen in yds.c, function yds_allocate_slots. | |
43 | */ | 43 | */ | |
44 | int | 44 | int | |
45 | local_variable_pcs(void) | 45 | local_variable_pcs(void) | |
@@ -115,15 +115,15 @@ __attribute__((deprecated("d5"))) | @@ -115,15 +115,15 @@ __attribute__((deprecated("d5"))) | |||
115 | void | 115 | void | |
116 | __attribute__((deprecated("d7"))) | 116 | __attribute__((deprecated("d7"))) | |
117 | ) | 117 | ) | |
118 | __attribute__((deprecated("d8"))) | 118 | __attribute__((deprecated("d8"))) | |
119 | ; | 119 | ; | |
120 | 120 | |||
121 | /* | 121 | /* | |
122 | * The attribute 'const' provides stronger guarantees than 'pure', and | 122 | * The attribute 'const' provides stronger guarantees than 'pure', and | |
123 | * 'volatile' is not defined. To keep the grammar simple, any T_QUAL is | 123 | * 'volatile' is not defined. To keep the grammar simple, any T_QUAL is | |
124 | * allowed at this point, but only syntactically. | 124 | * allowed at this point, but only syntactically. | |
125 | */ | 125 | */ | |
126 | int const_function(int) __attribute__((const)); | 126 | int const_function(int) __attribute__((const)); | |
127 | /* cover 'gcc_attribute_spec: T_QUAL' */ | 127 | /* cover 'gcc_attribute_spec: T_QUAL' */ | |
128 | /* expect+1: syntax error 'volatile' [249] */ | 128 | /* expect+1: error: syntax error 'volatile' [249] */ | |
129 | int volatile_function(int) __attribute__((volatile)); | 129 | int volatile_function(int) __attribute__((volatile)); |
--- src/tests/usr.bin/xlint/lint1/msg_155.c 2022/04/01 22:28:21 1.10
+++ src/tests/usr.bin/xlint/lint1/msg_155.c 2022/06/17 18:54:53 1.11
@@ -1,79 +1,79 @@ | @@ -1,79 +1,79 @@ | |||
1 | /* $NetBSD: msg_155.c,v 1.10 2022/04/01 22:28:21 rillig Exp $ */ | 1 | /* $NetBSD: msg_155.c,v 1.11 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_155.c" | 2 | # 3 "msg_155.c" | |
3 | 3 | |||
4 | // Test for message: passing '%s' to incompatible '%s', arg #%d [155] | 4 | // Test for message: passing '%s' to incompatible '%s', arg #%d [155] | |
5 | 5 | |||
6 | 6 | |||
7 | void c99_6_7_6_example_a(int); | 7 | void c99_6_7_6_example_a(int); | |
8 | void c99_6_7_6_example_b(int *); | 8 | void c99_6_7_6_example_b(int *); | |
9 | void c99_6_7_6_example_c(int *[3]); | 9 | void c99_6_7_6_example_c(int *[3]); | |
10 | void c99_6_7_6_example_d(int (*)[3]); | 10 | void c99_6_7_6_example_d(int (*)[3]); | |
11 | void c99_6_7_6_example_e(int (*)[*]); | 11 | void c99_6_7_6_example_e(int (*)[*]); | |
12 | /* Wrong type before decl.c 1.256 from 2022-04-01. */ | 12 | /* Wrong type before decl.c 1.256 from 2022-04-01. */ | |
13 | void c99_6_7_6_example_f(int *()); | 13 | void c99_6_7_6_example_f(int *()); | |
14 | void c99_6_7_6_example_g(int (*)(void)); | 14 | void c99_6_7_6_example_g(int (*)(void)); | |
15 | void c99_6_7_6_example_h(int (*const[])(unsigned int, ...)); | 15 | void c99_6_7_6_example_h(int (*const[])(unsigned int, ...)); | |
16 | 16 | |||
17 | struct incompatible { | 17 | struct incompatible { | |
18 | int member; | 18 | int member; | |
19 | }; | 19 | }; | |
20 | 20 | |||
21 | void | 21 | void | |
22 | provoke_error_messages(struct incompatible arg) | 22 | provoke_error_messages(struct incompatible arg) | |
23 | { | 23 | { | |
24 | /* expect+1: 'int' */ | 24 | /* expect+1: ... 'int', ... */ | |
25 | c99_6_7_6_example_a(arg); | 25 | c99_6_7_6_example_a(arg); | |
26 | 26 | |||
27 | /* expect+1: 'pointer to int' */ | 27 | /* expect+1: ... 'pointer to int', ... */ | |
28 | c99_6_7_6_example_b(arg); | 28 | c99_6_7_6_example_b(arg); | |
29 | 29 | |||
30 | /* C99 says 'array[3] of pointer to int', which is close enough. */ | 30 | /* C99 says 'array[3] of pointer to int', which is close enough. */ | |
31 | /* expect+1: 'pointer to pointer to int' */ | 31 | /* expect+1: ... 'pointer to pointer to int', ... */ | |
32 | c99_6_7_6_example_c(arg); | 32 | c99_6_7_6_example_c(arg); | |
33 | 33 | |||
34 | /* expect+1: 'pointer to array[3] of int' */ | 34 | /* expect+1: ... 'pointer to array[3] of int', ... */ | |
35 | c99_6_7_6_example_d(arg); | 35 | c99_6_7_6_example_d(arg); | |
36 | 36 | |||
37 | /* expect+1: 'pointer to array[unknown_size] of int' */ | 37 | /* expect+1: ... 'pointer to array[unknown_size] of int', ... */ | |
38 | c99_6_7_6_example_e(arg); | 38 | c99_6_7_6_example_e(arg); | |
39 | 39 | |||
40 | /* Wrong type before decl.c 1.256 from 2022-04-01. */ | 40 | /* Wrong type before decl.c 1.256 from 2022-04-01. */ | |
41 | /* expect+1: 'pointer to function() returning pointer to int' */ | 41 | /* expect+1: ... 'pointer to function() returning pointer to int', ... */ | |
42 | c99_6_7_6_example_f(arg); | 42 | c99_6_7_6_example_f(arg); | |
43 | 43 | |||
44 | /* expect+1: 'pointer to function(void) returning int' */ | 44 | /* expect+1: ... 'pointer to function(void) returning int', ... */ | |
45 | c99_6_7_6_example_g(arg); | 45 | c99_6_7_6_example_g(arg); | |
46 | 46 | |||
47 | /* expect+1: 'pointer to const pointer to function(unsigned int, ...) returning int' */ | 47 | /* expect+1: ... 'pointer to const pointer to function(unsigned int, ...) returning int', ... */ | |
48 | c99_6_7_6_example_h(arg); | 48 | c99_6_7_6_example_h(arg); | |
49 | } | 49 | } | |
50 | 50 | |||
51 | extern void sink(struct incompatible); | 51 | extern void sink(struct incompatible); | |
52 | 52 | |||
53 | /* | 53 | /* | |
54 | * The function type_name has a special case for an enum type that has been | 54 | * The function type_name has a special case for an enum type that has been | |
55 | * implicitly converted to an int. Such a type is still output as the enum | 55 | * implicitly converted to an int. Such a type is still output as the enum | |
56 | * type. | 56 | * type. | |
57 | * | 57 | * | |
58 | * XXX: The expressions 'day + 0' and '0 + day' should result in the same | 58 | * XXX: The expressions 'day + 0' and '0 + day' should result in the same | |
59 | * type. | 59 | * type. | |
60 | */ | 60 | */ | |
61 | void | 61 | void | |
62 | type_name_of_enum(void) | 62 | type_name_of_enum(void) | |
63 | { | 63 | { | |
64 | enum Day { | 64 | enum Day { | |
65 | MONDAY | 65 | MONDAY | |
66 | } day = MONDAY; | 66 | } day = MONDAY; | |
67 | 67 | |||
68 | /* expect+1: passing 'enum Day' */ | 68 | /* expect+1: ... passing 'enum Day' ... */ | |
69 | sink(day); | 69 | sink(day); | |
70 | 70 | |||
71 | /* expect+1: passing 'enum Day' */ | 71 | /* expect+1: ... passing 'enum Day' ... */ | |
72 | sink(day + 0); | 72 | sink(day + 0); | |
73 | 73 | |||
74 | /* expect+1: passing 'int' */ | 74 | /* expect+1: ... passing 'int' ... */ | |
75 | sink(0 + day); | 75 | sink(0 + day); | |
76 | 76 | |||
77 | /* expect+1: passing 'int' */ | 77 | /* expect+1: ... passing 'int' ... */ | |
78 | sink(0); | 78 | sink(0); | |
79 | } | 79 | } |
--- src/tests/usr.bin/xlint/lint1/decl.c 2022/06/11 11:52:13 1.16
+++ src/tests/usr.bin/xlint/lint1/decl.c 2022/06/17 18:54:53 1.17
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: decl.c,v 1.16 2022/06/11 11:52:13 rillig Exp $ */ | 1 | /* $NetBSD: decl.c,v 1.17 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "decl.c" | 2 | # 3 "decl.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Tests for declarations, especially the distinction between the | 5 | * Tests for declarations, especially the distinction between the | |
6 | * declaration-specifiers and the declarators. | 6 | * declaration-specifiers and the declarators. | |
7 | */ | 7 | */ | |
8 | 8 | |||
9 | /* | 9 | /* | |
10 | * Even though 'const' comes after 'char' and is therefore quite close to the | 10 | * Even though 'const' comes after 'char' and is therefore quite close to the | |
11 | * first identifier, it applies to both identifiers. | 11 | * first identifier, it applies to both identifiers. | |
12 | */ | 12 | */ | |
13 | void | 13 | void | |
14 | specifier_qualifier(void) | 14 | specifier_qualifier(void) | |
@@ -29,64 +29,64 @@ void | @@ -29,64 +29,64 @@ void | |||
29 | qualifier_specifier(void) | 29 | qualifier_specifier(void) | |
30 | { | 30 | { | |
31 | const char a = 1, b = 2; | 31 | const char a = 1, b = 2; | |
32 | 32 | |||
33 | /* expect+1: warning: left operand of '=' must be modifiable lvalue [115] */ | 33 | /* expect+1: warning: left operand of '=' must be modifiable lvalue [115] */ | |
34 | a = 3; | 34 | a = 3; | |
35 | /* expect+1: warning: left operand of '=' must be modifiable lvalue [115] */ | 35 | /* expect+1: warning: left operand of '=' must be modifiable lvalue [115] */ | |
36 | b = 5; | 36 | b = 5; | |
37 | } | 37 | } | |
38 | 38 | |||
39 | void | 39 | void | |
40 | declarator_with_prefix_qualifier(void) | 40 | declarator_with_prefix_qualifier(void) | |
41 | { | 41 | { | |
42 | /* expect+1: syntax error 'const' [249] */ | 42 | /* expect+1: error: syntax error 'const' [249] */ | |
43 | char a = 1, const b = 2; | 43 | char a = 1, const b = 2; | |
44 | 44 | |||
45 | a = 1; | 45 | a = 1; | |
46 | /* expect+1: error: 'b' undefined [99] */ | 46 | /* expect+1: error: 'b' undefined [99] */ | |
47 | b = 2; | 47 | b = 2; | |
48 | } | 48 | } | |
49 | 49 | |||
50 | void | 50 | void | |
51 | declarator_with_postfix_qualifier(void) | 51 | declarator_with_postfix_qualifier(void) | |
52 | { | 52 | { | |
53 | /* expect+1: syntax error 'const' [249] */ | 53 | /* expect+1: error: syntax error 'const' [249] */ | |
54 | char a = 1, b const = 2; | 54 | char a = 1, b const = 2; | |
55 | 55 | |||
56 | a = 1; | 56 | a = 1; | |
57 | b = 2; | 57 | b = 2; | |
58 | } | 58 | } | |
59 | 59 | |||
60 | void sink(double *); | 60 | void sink(double *); | |
61 | 61 | |||
62 | void | 62 | void | |
63 | declarators(void) | 63 | declarators(void) | |
64 | { | 64 | { | |
65 | char *pc = 0, c = 0, **ppc = 0; | 65 | char *pc = 0, c = 0, **ppc = 0; | |
66 | 66 | |||
67 | /* expect+1: warning: converting 'pointer to char' to incompatible 'pointer to double' */ | 67 | /* expect+1: warning: converting 'pointer to char' to incompatible 'pointer to double' for argument 1 [153] */ | |
68 | sink(pc); | 68 | sink(pc); | |
69 | /* expect+1: warning: illegal combination of pointer (pointer to double) and integer (char) */ | 69 | /* expect+1: warning: illegal combination of pointer (pointer to double) and integer (char), arg #1 [154] */ | |
70 | sink(c); | 70 | sink(c); | |
71 | /* expect+1: converting 'pointer to pointer to char' to incompatible 'pointer to double' */ | 71 | /* expect+1: warning: converting 'pointer to pointer to char' to incompatible 'pointer to double' for argument 1 [153] */ | |
72 | sink(ppc); | 72 | sink(ppc); | |
73 | } | 73 | } | |
74 | 74 | |||
75 | _Bool | 75 | _Bool | |
76 | enum_error_handling(void) | 76 | enum_error_handling(void) | |
77 | { | 77 | { | |
78 | enum { | 78 | enum { | |
79 | /* expect+1: syntax error '"' [249] */ | 79 | /* expect+1: error: syntax error '"' [249] */ | |
80 | "error 1" | 80 | "error 1" | |
81 | : /* still the same error */ | 81 | : /* still the same error */ | |
82 | , /* back on track */ | 82 | , /* back on track */ | |
83 | A, | 83 | A, | |
84 | B | 84 | B | |
85 | } x = A; | 85 | } x = A; | |
86 | 86 | |||
87 | return x == B; | 87 | return x == B; | |
88 | } | 88 | } | |
89 | 89 | |||
90 | /* | 90 | /* | |
91 | * An __attribute__ at the beginning of a declaration may become ambiguous | 91 | * An __attribute__ at the beginning of a declaration may become ambiguous | |
92 | * since a GCC fallthrough statement starts with __attribute__ as well. | 92 | * since a GCC fallthrough statement starts with __attribute__ as well. | |
@@ -150,31 +150,31 @@ unsigned long sizes = | @@ -150,31 +150,31 @@ unsigned long sizes = | |||
150 | sizeof(const typeof(bool)) + | 150 | sizeof(const typeof(bool)) + | |
151 | sizeof(const typeof(plain_char)) + | 151 | sizeof(const typeof(plain_char)) + | |
152 | sizeof(const typeof(signed_char)) + | 152 | sizeof(const typeof(signed_char)) + | |
153 | sizeof(const typeof(unsigned_char)) + | 153 | sizeof(const typeof(unsigned_char)) + | |
154 | sizeof(const typeof(signed_short)) + | 154 | sizeof(const typeof(signed_short)) + | |
155 | sizeof(const typeof(unsigned_short)) + | 155 | sizeof(const typeof(unsigned_short)) + | |
156 | sizeof(const typeof(signed_int)) + | 156 | sizeof(const typeof(signed_int)) + | |
157 | sizeof(const typeof(unsigned_int)) + | 157 | sizeof(const typeof(unsigned_int)) + | |
158 | sizeof(const typeof(signed_long)) + | 158 | sizeof(const typeof(signed_long)) + | |
159 | sizeof(const typeof(unsigned_long)) + | 159 | sizeof(const typeof(unsigned_long)) + | |
160 | sizeof(const typeof(unnamed_struct)); | 160 | sizeof(const typeof(unnamed_struct)); | |
161 | 161 | |||
162 | /* expect+2: error: old style declaration; add 'int' [1] */ | 162 | /* expect+2: error: old style declaration; add 'int' [1] */ | |
163 | /* expect+1: syntax error 'int' [249] */ | 163 | /* expect+1: error: syntax error 'int' [249] */ | |
164 | thread int thread_int; | 164 | thread int thread_int; | |
165 | __thread int thread_int; | 165 | __thread int thread_int; | |
166 | /* expect+2: error: old style declaration; add 'int' [1] */ | 166 | /* expect+2: error: old style declaration; add 'int' [1] */ | |
167 | /* expect+1: syntax error 'int' [249] */ | 167 | /* expect+1: error: syntax error 'int' [249] */ | |
168 | __thread__ int thread_int; | 168 | __thread__ int thread_int; | |
169 | 169 | |||
170 | /* expect+4: error: old style declaration; add 'int' [1] */ | 170 | /* expect+4: error: old style declaration; add 'int' [1] */ | |
171 | /* expect+2: warning: static function 'cover_func_declarator' unused [236] */ | 171 | /* expect+2: warning: static function 'cover_func_declarator' unused [236] */ | |
172 | static | 172 | static | |
173 | cover_func_declarator(void) | 173 | cover_func_declarator(void) | |
174 | { | 174 | { | |
175 | } | 175 | } | |
176 | 176 | |||
177 | /* | 177 | /* | |
178 | * Before decl.c 1.268 from 2022-04-03, lint ran into an assertion failure for | 178 | * Before decl.c 1.268 from 2022-04-03, lint ran into an assertion failure for | |
179 | * "elsz > 0" in 'length'. | 179 | * "elsz > 0" in 'length'. | |
180 | */ | 180 | */ |
--- src/tests/usr.bin/xlint/lint1/decl_direct_abstract.c 2022/04/01 23:16:32 1.6
+++ src/tests/usr.bin/xlint/lint1/decl_direct_abstract.c 2022/06/17 18:54:53 1.7
@@ -1,75 +1,75 @@ | @@ -1,75 +1,75 @@ | |||
1 | /* $NetBSD: decl_direct_abstract.c,v 1.6 2022/04/01 23:16:32 rillig Exp $ */ | 1 | /* $NetBSD: decl_direct_abstract.c,v 1.7 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "decl_direct_abstract.c" | 2 | # 3 "decl_direct_abstract.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Test parsing of direct-abstract-declarator (C99 6.7.6), which are a tricky | 5 | * Test parsing of direct-abstract-declarator (C99 6.7.6), which are a tricky | |
6 | * part of the C standard since they require lookahead and are so complicated | 6 | * part of the C standard since they require lookahead and are so complicated | |
7 | * that GCC's parser dedicates 34 lines of comments to this topic. | 7 | * that GCC's parser dedicates 34 lines of comments to this topic. | |
8 | * | 8 | * | |
9 | * See msg_155.c. | 9 | * See msg_155.c. | |
10 | */ | 10 | */ | |
11 | 11 | |||
12 | /* | 12 | /* | |
13 | * The following tests do not use int, to avoid confusion with the implicit | 13 | * The following tests do not use int, to avoid confusion with the implicit | |
14 | * return type. | 14 | * return type. | |
15 | */ | 15 | */ | |
16 | 16 | |||
17 | char func0001(short (*)(long)); | 17 | char func0001(short (*)(long)); | |
18 | 18 | |||
19 | /* GCC says 'char (*)(short int (*)(long int))' */ | 19 | /* GCC says 'char (*)(short int (*)(long int))' */ | |
20 | /* Clang says 'char (short (*)(long))' */ | 20 | /* Clang says 'char (short (*)(long))' */ | |
21 | /* cdecl says 'function (pointer to function (long) returning short) returning char' */ | 21 | /* cdecl says 'function (pointer to function (long) returning short) returning char' */ | |
22 | /* expect+1: 'pointer to function(pointer to function(long) returning short) returning char' */ | 22 | /* expect+1: error: cannot initialize 'double' from 'pointer to function(pointer to function(long) returning short) returning char' [185] */ | |
23 | double type_of_func0001 = func0001; | 23 | double type_of_func0001 = func0001; | |
24 | 24 | |||
25 | char func0002(short *(long)); | 25 | char func0002(short *(long)); | |
26 | 26 | |||
27 | /* GCC says 'char (*)(short int * (*)(long int))' */ | 27 | /* GCC says 'char (*)(short int * (*)(long int))' */ | |
28 | /* Clang says 'char (short *(*)(long))' */ | 28 | /* Clang says 'char (short *(*)(long))' */ | |
29 | /* cdecl says 'syntax error' */ | 29 | /* cdecl says 'syntax error' */ | |
30 | /* FIXME: lint is wrong, it discards the 'short *' */ | 30 | /* FIXME: lint is wrong, it discards the 'short *' */ | |
31 | /* expect+1: 'pointer to function(long) returning char' */ | 31 | /* expect+1: error: cannot initialize 'double' from 'pointer to function(long) returning char' [185] */ | |
32 | double type_of_func0002 = func0002; | 32 | double type_of_func0002 = func0002; | |
33 | 33 | |||
34 | void c99_6_7_6_example_a(int); | 34 | void c99_6_7_6_example_a(int); | |
35 | void c99_6_7_6_example_b(int *); | 35 | void c99_6_7_6_example_b(int *); | |
36 | void c99_6_7_6_example_c(int *[3]); | 36 | void c99_6_7_6_example_c(int *[3]); | |
37 | void c99_6_7_6_example_d(int (*)[3]); | 37 | void c99_6_7_6_example_d(int (*)[3]); | |
38 | void c99_6_7_6_example_e(int (*)[*]); | 38 | void c99_6_7_6_example_e(int (*)[*]); | |
39 | void c99_6_7_6_example_f(int *()); | 39 | void c99_6_7_6_example_f(int *()); | |
40 | void c99_6_7_6_example_g(int (*)(void)); | 40 | void c99_6_7_6_example_g(int (*)(void)); | |
41 | void c99_6_7_6_example_h(int (*const[])(unsigned int, ...)); | 41 | void c99_6_7_6_example_h(int (*const[])(unsigned int, ...)); | |
42 | 42 | |||
43 | struct incompatible { | 43 | struct incompatible { | |
44 | int member; | 44 | int member; | |
45 | } x; | 45 | } x; | |
46 | 46 | |||
47 | /* expect+1: 'pointer to function(int) returning void' */ | 47 | /* expect+1: ... 'pointer to function(int) returning void' ... */ | |
48 | double type_of_c99_6_7_6_example_a = c99_6_7_6_example_a; | 48 | double type_of_c99_6_7_6_example_a = c99_6_7_6_example_a; | |
49 | /* expect+1: 'pointer to function(pointer to int) returning void' */ | 49 | /* expect+1: ... 'pointer to function(pointer to int) returning void' ... */ | |
50 | double type_of_c99_6_7_6_example_b = c99_6_7_6_example_b; | 50 | double type_of_c99_6_7_6_example_b = c99_6_7_6_example_b; | |
51 | /* expect+1: 'pointer to function(pointer to pointer to int) returning void' */ | 51 | /* expect+1: ... 'pointer to function(pointer to pointer to int) returning void' ... */ | |
52 | double type_of_c99_6_7_6_example_c = c99_6_7_6_example_c; | 52 | double type_of_c99_6_7_6_example_c = c99_6_7_6_example_c; | |
53 | /* expect+1: 'pointer to function(pointer to array[3] of int) returning void' */ | 53 | /* expect+1: ... 'pointer to function(pointer to array[3] of int) returning void' ... */ | |
54 | double type_of_c99_6_7_6_example_d = c99_6_7_6_example_d; | 54 | double type_of_c99_6_7_6_example_d = c99_6_7_6_example_d; | |
55 | /* expect+1: 'pointer to function(pointer to array[unknown_size] of int) returning void' */ | 55 | /* expect+1: ... 'pointer to function(pointer to array[unknown_size] of int) returning void' ... */ | |
56 | double type_of_c99_6_7_6_example_e = c99_6_7_6_example_e; | 56 | double type_of_c99_6_7_6_example_e = c99_6_7_6_example_e; | |
57 | /* Wrong type before decl.c 1.256 from 2022-04-01. */ | 57 | /* Wrong type before decl.c 1.256 from 2022-04-01. */ | |
58 | /* expect+1: 'pointer to function(pointer to function() returning pointer to int) returning void' */ | 58 | /* expect+1: ... 'pointer to function(pointer to function() returning pointer to int) returning void' ... */ | |
59 | double type_of_c99_6_7_6_example_f = c99_6_7_6_example_f; | 59 | double type_of_c99_6_7_6_example_f = c99_6_7_6_example_f; | |
60 | /* expect+1: 'pointer to function(pointer to function(void) returning int) returning void' */ | 60 | /* expect+1: ... 'pointer to function(pointer to function(void) returning int) returning void' ... */ | |
61 | double type_of_c99_6_7_6_example_g = c99_6_7_6_example_g; | 61 | double type_of_c99_6_7_6_example_g = c99_6_7_6_example_g; | |
62 | /* expect+1: 'pointer to function(pointer to const pointer to function(unsigned int, ...) returning int) returning void' */ | 62 | /* expect+1: ... 'pointer to function(pointer to const pointer to function(unsigned int, ...) returning int) returning void' ... */ | |
63 | double type_of_c99_6_7_6_example_h = c99_6_7_6_example_h; | 63 | double type_of_c99_6_7_6_example_h = c99_6_7_6_example_h; | |
64 | 64 | |||
65 | void int_array(int[]); | 65 | void int_array(int[]); | |
66 | void int_array_3(int[3]); | 66 | void int_array_3(int[3]); | |
67 | /* supported since cgram.y 1.363 from 2021-09-14 */ | 67 | /* supported since cgram.y 1.363 from 2021-09-14 */ | |
68 | void int_array_ast(int[*]); | 68 | void int_array_ast(int[*]); | |
69 | /* expect+1: error: null dimension [17] */ | 69 | /* expect+1: error: null dimension [17] */ | |
70 | void int_array_7_array(int[7][]); | 70 | void int_array_7_array(int[7][]); | |
71 | void int_array_7_array_3(int[7][3]); | 71 | void int_array_7_array_3(int[7][3]); | |
72 | /* expect+1: error: null dimension [17] */ | 72 | /* expect+1: error: null dimension [17] */ | |
73 | void int_array_7_array_ast(int[7][*]); | 73 | void int_array_7_array_ast(int[7][*]); | |
74 | 74 | |||
75 | void int_array_array(int[][7]); | 75 | void int_array_array(int[][7]); |
--- src/tests/usr.bin/xlint/lint1/msg_343.c 2022/06/17 06:59:16 1.6
+++ src/tests/usr.bin/xlint/lint1/msg_343.c 2022/06/17 18:54:53 1.7
@@ -1,49 +1,49 @@ | @@ -1,49 +1,49 @@ | |||
1 | /* $NetBSD: msg_343.c,v 1.6 2022/06/17 06:59:16 rillig Exp $ */ | 1 | /* $NetBSD: msg_343.c,v 1.7 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_343.c" | 2 | # 3 "msg_343.c" | |
3 | 3 | |||
4 | /* Test for message: static array size is a C11 extension [343] */ | 4 | /* Test for message: static array size is a C11 extension [343] */ | |
5 | 5 | |||
6 | /* lint1-flags: -Sw */ | 6 | /* lint1-flags: -Sw */ | |
7 | 7 | |||
8 | void takes_int_pointer(int []); | 8 | void takes_int_pointer(int []); | |
9 | void takes_int_pointer_with_ignored_size(int [3]); | 9 | void takes_int_pointer_with_ignored_size(int [3]); | |
10 | /* expect+1: error: static array size is a C11 extension [343] */ | 10 | /* expect+1: error: static array size is a C11 extension [343] */ | |
11 | void takes_int_array(int[static 3]); | 11 | void takes_int_array(int[static 3]); | |
12 | /* expect+1: syntax error '3' */ | 12 | /* expect+1: error: syntax error '3' [249] */ | |
13 | void takes_volatile_int_array(int[volatile 3]); | 13 | void takes_volatile_int_array(int[volatile 3]); | |
14 | 14 | |||
15 | int | 15 | int | |
16 | returns_int_pointer(int a[]) | 16 | returns_int_pointer(int a[]) | |
17 | { | 17 | { | |
18 | return a[0]; | 18 | return a[0]; | |
19 | } | 19 | } | |
20 | 20 | |||
21 | int | 21 | int | |
22 | returns_int_pointer_with_ignored_size(int a[3]) | 22 | returns_int_pointer_with_ignored_size(int a[3]) | |
23 | { | 23 | { | |
24 | return a[0]; | 24 | return a[0]; | |
25 | } | 25 | } | |
26 | 26 | |||
27 | int | 27 | int | |
28 | /* expect+1: error: static array size is a C11 extension [343] */ | 28 | /* expect+1: error: static array size is a C11 extension [343] */ | |
29 | returns_int_array(int a[static 3]) | 29 | returns_int_array(int a[static 3]) | |
30 | { | 30 | { | |
31 | return a[0]; | 31 | return a[0]; | |
32 | } | 32 | } | |
33 | 33 | |||
34 | int | 34 | int | |
35 | /* expect+1: syntax error '3' */ | 35 | /* expect+1: error: syntax error '3' [249] */ | |
36 | returns_volatile_int_array(int a[volatile 3]) | 36 | returns_volatile_int_array(int a[volatile 3]) | |
37 | { | 37 | { | |
38 | /* expect+2: cannot dereference non-pointer type */ | 38 | /* expect+2: error: cannot dereference non-pointer type [96] */ | |
39 | /* expect+1: expects to return value */ | 39 | /* expect+1: ... expects to return value [214] */ | |
40 | return a[0]; | 40 | return a[0]; | |
41 | } | 41 | } | |
42 | 42 | |||
43 | /* | 43 | /* | |
44 | * This triggers the "Bad attribute", but for some reason, that custom error | 44 | * This triggers the "Bad attribute", but for some reason, that custom error | |
45 | * message does not make it into the actual diagnostic. | 45 | * message does not make it into the actual diagnostic. | |
46 | */ | 46 | */ | |
47 | /* expect+2: error: syntax error ']' [249] */ | 47 | /* expect+2: error: syntax error ']' [249] */ | |
48 | /* expect+1: error: static array size is a C11 extension [343] */ | 48 | /* expect+1: error: static array size is a C11 extension [343] */ | |
49 | void invalid_storage_class(int a[const typedef 3]); | 49 | void invalid_storage_class(int a[const typedef 3]); |
--- src/tests/usr.bin/xlint/lint1/decl_enum_c90.c 2021/07/15 21:00:05 1.1
+++ src/tests/usr.bin/xlint/lint1/decl_enum_c90.c 2022/06/17 18:54:53 1.2
@@ -1,13 +1,13 @@ | @@ -1,13 +1,13 @@ | |||
1 | /* $NetBSD: decl_enum_c90.c,v 1.1 2021/07/15 21:00:05 rillig Exp $ */ | 1 | /* $NetBSD: decl_enum_c90.c,v 1.2 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "decl_enum_c90.c" | 2 | # 3 "decl_enum_c90.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Tests for enum declarations in C90 mode. | 5 | * Tests for enum declarations in C90 mode. | |
6 | */ | 6 | */ | |
7 | 7 | |||
8 | /* lint1-flags: -sw */ | 8 | /* lint1-flags: -sw */ | |
9 | 9 | |||
10 | enum { | 10 | enum { | |
11 | A, | 11 | A, | |
12 | }; | 12 | }; | |
13 | /* expect-1: trailing ',' prohibited in enum declaration [54] */ | 13 | /* expect-1: error: trailing ',' prohibited in enum declaration [54] */ |
--- src/tests/usr.bin/xlint/lint1/expr_binary_trad.c 2021/08/01 16:29:28 1.1
+++ src/tests/usr.bin/xlint/lint1/expr_binary_trad.c 2022/06/17 18:54:53 1.2
@@ -1,67 +1,67 @@ | @@ -1,67 +1,67 @@ | |||
1 | /* $NetBSD: expr_binary_trad.c,v 1.1 2021/08/01 16:29:28 rillig Exp $ */ | 1 | /* $NetBSD: expr_binary_trad.c,v 1.2 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "expr_binary_trad.c" | 2 | # 3 "expr_binary_trad.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Test binary operators in traditional C. | 5 | * Test binary operators in traditional C. | |
6 | */ | 6 | */ | |
7 | 7 | |||
8 | /* lint1-flags: -tw */ | 8 | /* lint1-flags: -tw */ | |
9 | 9 | |||
10 | struct incompatible { /* just to generate the error message */ | 10 | struct incompatible { /* just to generate the error message */ | |
11 | int member; | 11 | int member; | |
12 | }; | 12 | }; | |
13 | struct incompatible sink; | 13 | struct incompatible sink; | |
14 | 14 | |||
15 | /* | 15 | /* | |
16 | * Test the usual arithmetic conversions. | 16 | * Test the usual arithmetic conversions. | |
17 | * | 17 | * | |
18 | * C99 6.3.1.8 "Usual arithmetic conversions" | 18 | * C99 6.3.1.8 "Usual arithmetic conversions" | |
19 | */ | 19 | */ | |
20 | void | 20 | void | |
21 | cover_balance() | 21 | cover_balance() | |
22 | { | 22 | { | |
23 | 23 | |||
24 | /* expect+1: 'pointer to char' */ | 24 | /* expect+1: ... 'pointer to char' ... */ | |
25 | sink = (char *)0 + 0; | 25 | sink = (char *)0 + 0; | |
26 | 26 | |||
27 | /* expect+1: 'pointer to char' */ | 27 | /* expect+1: ... 'pointer to char' ... */ | |
28 | sink = 0 + (char *)0; | 28 | sink = 0 + (char *)0; | |
29 | 29 | |||
30 | /* expect+1: 'int' */ | 30 | /* expect+1: ... 'int' ... */ | |
31 | sink = 1 + 1; | 31 | sink = 1 + 1; | |
32 | 32 | |||
33 | /* expect+1: 'double' */ | 33 | /* expect+1: ... 'double' ... */ | |
34 | sink = 0.0 + 0; | 34 | sink = 0.0 + 0; | |
35 | /* expect+1: 'double' */ | 35 | /* expect+1: ... 'double' ... */ | |
36 | sink = 0 + 0.0; | 36 | sink = 0 + 0.0; | |
37 | /* expect+1: 'double' */ | 37 | /* expect+1: ... 'double' ... */ | |
38 | sink = 0.0 + (float)0.0; | 38 | sink = 0.0 + (float)0.0; | |
39 | /* expect+1: 'double' */ | 39 | /* expect+1: ... 'double' ... */ | |
40 | sink = (float)0.0 + 0.0; | 40 | sink = (float)0.0 + 0.0; | |
41 | 41 | |||
42 | /* | 42 | /* | |
43 | * In traditional C, 'float' gets promoted to 'double' before | 43 | * In traditional C, 'float' gets promoted to 'double' before | |
44 | * applying the usual arithmetic conversions; see 'promote'. | 44 | * applying the usual arithmetic conversions; see 'promote'. | |
45 | */ | 45 | */ | |
46 | /* expect+1: 'double' */ | 46 | /* expect+1: ... 'double' ... */ | |
47 | sink = (float)0.0 + 0; | 47 | sink = (float)0.0 + 0; | |
48 | /* expect+1: 'double' */ | 48 | /* expect+1: ... 'double' ... */ | |
49 | sink = 0 + (float)0.0; | 49 | sink = 0 + (float)0.0; | |
50 | 50 | |||
51 | /* expect+1: 'unsigned long' */ | 51 | /* expect+1: ... 'unsigned long' ... */ | |
52 | sink = (unsigned long)0 + 0; | 52 | sink = (unsigned long)0 + 0; | |
53 | /* expect+1: 'unsigned long' */ | 53 | /* expect+1: ... 'unsigned long' ... */ | |
54 | sink = 0 + (unsigned long)0; | 54 | sink = 0 + (unsigned long)0; | |
55 | 55 | |||
56 | /* expect+1: 'unsigned long' */ | 56 | /* expect+1: ... 'unsigned long' ... */ | |
57 | sink = (unsigned long)0 + (long)0; | 57 | sink = (unsigned long)0 + (long)0; | |
58 | /* expect+1: 'unsigned long' */ | 58 | /* expect+1: ... 'unsigned long' ... */ | |
59 | sink = (long)0 + (unsigned long)0; | 59 | sink = (long)0 + (unsigned long)0; | |
60 | 60 | |||
61 | /* | 61 | /* | |
62 | * In traditional C, if one of the operands is unsigned, the result | 62 | * In traditional C, if one of the operands is unsigned, the result | |
63 | * is unsigned as well. | 63 | * is unsigned as well. | |
64 | */ | 64 | */ | |
65 | /* expect+1: 'unsigned long' */ | 65 | /* expect+1: ... 'unsigned long' ... */ | |
66 | sink = (unsigned)0 + (long)0; | 66 | sink = (unsigned)0 + (long)0; | |
67 | } | 67 | } |
--- src/tests/usr.bin/xlint/lint1/lex_integer_binary.c 2021/07/13 19:38:10 1.1
+++ src/tests/usr.bin/xlint/lint1/lex_integer_binary.c 2022/06/17 18:54:53 1.2
@@ -1,30 +1,30 @@ | @@ -1,30 +1,30 @@ | |||
1 | /* $NetBSD: lex_integer_binary.c,v 1.1 2021/07/13 19:38:10 rillig Exp $ */ | 1 | /* $NetBSD: lex_integer_binary.c,v 1.2 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "lex_integer_binary.c" | 2 | # 3 "lex_integer_binary.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Test for parsing binary integer literals in non-GCC mode. | 5 | * Test for parsing binary integer literals in non-GCC mode. | |
6 | * As of C11, binary integer literals are not supported. | 6 | * As of C11, binary integer literals are not supported. | |
7 | * Neither are underscores in integer literals. | 7 | * Neither are underscores in integer literals. | |
8 | */ | 8 | */ | |
9 | 9 | |||
10 | /* Remove the default -g flag. */ | 10 | /* Remove the default -g flag. */ | |
11 | /* lint1-flags: -Ac11 -w */ | 11 | /* lint1-flags: -Ac11 -w */ | |
12 | 12 | |||
13 | void sink(unsigned int); | 13 | void sink(unsigned int); | |
14 | 14 | |||
15 | void | 15 | void | |
16 | binary_literal(void) | 16 | binary_literal(void) | |
17 | { | 17 | { | |
18 | /* | 18 | /* | |
19 | * Binary integer literals are a GCC extension, but lint allows them | 19 | * Binary integer literals are a GCC extension, but lint allows them | |
20 | * even in non-GCC mode. | 20 | * even in non-GCC mode. | |
21 | */ | 21 | */ | |
22 | sink(0b1111000001011010); | 22 | sink(0b1111000001011010); | |
23 | 23 | |||
24 | /* | 24 | /* | |
25 | * Even though it would be useful for binary literals, GCC does not | 25 | * Even though it would be useful for binary literals, GCC does not | |
26 | * support underscores to separate the digit groups. | 26 | * support underscores to separate the digit groups. | |
27 | */ | 27 | */ | |
28 | /* expect+1: syntax error '_0000_0101_1010' [249] */ | 28 | /* expect+1: error: syntax error '_0000_0101_1010' [249] */ | |
29 | sink(0b1111_0000_0101_1010); | 29 | sink(0b1111_0000_0101_1010); | |
30 | } | 30 | } |
--- src/tests/usr.bin/xlint/lint1/msg_341.c 2021/04/05 02:05:47 1.1
+++ src/tests/usr.bin/xlint/lint1/msg_341.c 2022/06/17 18:54:53 1.2
@@ -1,48 +1,48 @@ | @@ -1,48 +1,48 @@ | |||
1 | /* $NetBSD: msg_341.c,v 1.1 2021/04/05 02:05:47 rillig Exp $ */ | 1 | /* $NetBSD: msg_341.c,v 1.2 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_341.c" | 2 | # 3 "msg_341.c" | |
3 | 3 | |||
4 | // Test for message: argument to '%s' must be 'unsigned char' or EOF, not '%s' [341] | 4 | // Test for message: argument to '%s' must be 'unsigned char' or EOF, not '%s' [341] | |
5 | 5 | |||
6 | /* | 6 | /* | |
7 | * Ensure that the functions from <ctype.h> are called with the correct | 7 | * Ensure that the functions from <ctype.h> are called with the correct | |
8 | * argument. | 8 | * argument. | |
9 | */ | 9 | */ | |
10 | 10 | |||
11 | /* NetBSD 9.99.81, <ctype.h> */ | 11 | /* NetBSD 9.99.81, <ctype.h> */ | |
12 | extern const unsigned short *_ctype_tab_; | 12 | extern const unsigned short *_ctype_tab_; | |
13 | extern const short *_tolower_tab_; | 13 | extern const short *_tolower_tab_; | |
14 | extern const short *_toupper_tab_; | 14 | extern const short *_toupper_tab_; | |
15 | int isspace(int); | 15 | int isspace(int); | |
16 | 16 | |||
17 | void sink(int); | 17 | void sink(int); | |
18 | 18 | |||
19 | void | 19 | void | |
20 | function_call_char(char c) | 20 | function_call_char(char c) | |
21 | { | 21 | { | |
22 | 22 | |||
23 | /* expect+1: argument to 'isspace' must be 'unsigned char' or EOF, not 'char' */ | 23 | /* expect+1: warning: argument to 'isspace' must be 'unsigned char' or EOF, not 'char' [341] */ | |
24 | (isspace)(c); | 24 | (isspace)(c); | |
25 | 25 | |||
26 | /* This is the only allowed form. */ | 26 | /* This is the only allowed form. */ | |
27 | isspace((unsigned char)c); | 27 | isspace((unsigned char)c); | |
28 | 28 | |||
29 | /* The cast to 'int' is redundant, it doesn't hurt though. */ | 29 | /* The cast to 'int' is redundant, it doesn't hurt though. */ | |
30 | isspace((int)(unsigned char)c); | 30 | isspace((int)(unsigned char)c); | |
31 | 31 | |||
32 | /* expect+1: argument to 'isspace' must be cast to 'unsigned char', not to 'int' */ | 32 | /* expect+1: warning: argument to 'isspace' must be cast to 'unsigned char', not to 'int' [342] */ | |
33 | isspace((int)c); | 33 | isspace((int)c); | |
34 | 34 | |||
35 | /* expect+1: argument to 'isspace' must be cast to 'unsigned char', not to 'unsigned int' */ | 35 | /* expect+1: warning: argument to 'isspace' must be cast to 'unsigned char', not to 'unsigned int' [342] */ | |
36 | isspace((unsigned int)c); | 36 | isspace((unsigned int)c); | |
37 | } | 37 | } | |
38 | 38 | |||
39 | /* | 39 | /* | |
40 | * If the expression starts with type 'unsigned char', it can be cast to any | 40 | * If the expression starts with type 'unsigned char', it can be cast to any | |
41 | * other type. Chances are low enough that the cast is to 'char', which would | 41 | * other type. Chances are low enough that the cast is to 'char', which would | |
42 | * be the only bad type. | 42 | * be the only bad type. | |
43 | */ | 43 | */ | |
44 | void | 44 | void | |
45 | function_call_unsigned_char(unsigned char c) | 45 | function_call_unsigned_char(unsigned char c) | |
46 | { | 46 | { | |
47 | 47 | |||
48 | (isspace)(c); | 48 | (isspace)(c); | |
@@ -53,25 +53,25 @@ function_call_unsigned_char(unsigned cha | @@ -53,25 +53,25 @@ function_call_unsigned_char(unsigned cha | |||
53 | 53 | |||
54 | /* When used in a loop of fgetc, the type is already 'int'. That's fine. */ | 54 | /* When used in a loop of fgetc, the type is already 'int'. That's fine. */ | |
55 | void | 55 | void | |
56 | function_call_int(int c) | 56 | function_call_int(int c) | |
57 | { | 57 | { | |
58 | 58 | |||
59 | isspace(c); | 59 | isspace(c); | |
60 | } | 60 | } | |
61 | 61 | |||
62 | void | 62 | void | |
63 | macro_invocation_NetBSD(char c) | 63 | macro_invocation_NetBSD(char c) | |
64 | { | 64 | { | |
65 | 65 | |||
66 | /* expect+1: argument to 'function from <ctype.h>' must be 'unsigned char' or EOF, not 'char' */ | 66 | /* expect+1: warning: argument to 'function from <ctype.h>' must be 'unsigned char' or EOF, not 'char' [341] */ | |
67 | sink(((int)((_ctype_tab_ + 1)[(c)] & 0x0040))); | 67 | sink(((int)((_ctype_tab_ + 1)[(c)] & 0x0040))); | |
68 | 68 | |||
69 | /* This is the only allowed form. */ | 69 | /* This is the only allowed form. */ | |
70 | sink(((int)((_ctype_tab_ + 1)[((unsigned char)c)] & 0x0040))); | 70 | sink(((int)((_ctype_tab_ + 1)[((unsigned char)c)] & 0x0040))); | |
71 | 71 | |||
72 | /* expect+1: argument to 'function from <ctype.h>' must be cast to 'unsigned char', not to 'int' */ | 72 | /* expect+1: warning: argument to 'function from <ctype.h>' must be cast to 'unsigned char', not to 'int' [342] */ | |
73 | sink(((int)((_ctype_tab_ + 1)[((int)c)] & 0x0040))); | 73 | sink(((int)((_ctype_tab_ + 1)[((int)c)] & 0x0040))); | |
74 | 74 | |||
75 | /* expect+1: argument to 'function from <ctype.h>' must be cast to 'unsigned char', not to 'unsigned int' */ | 75 | /* expect+1: warning: argument to 'function from <ctype.h>' must be cast to 'unsigned char', not to 'unsigned int' [342] */ | |
76 | sink(((int)((_ctype_tab_ + 1)[((unsigned int)c)] & 0x0040))); | 76 | sink(((int)((_ctype_tab_ + 1)[((unsigned int)c)] & 0x0040))); | |
77 | } | 77 | } |
--- src/tests/usr.bin/xlint/lint1/msg_344.c 2021/05/16 11:11:37 1.1
+++ src/tests/usr.bin/xlint/lint1/msg_344.c 2022/06/17 18:54:53 1.2
@@ -1,24 +1,24 @@ | @@ -1,24 +1,24 @@ | |||
1 | /* $NetBSD: msg_344.c,v 1.1 2021/05/16 11:11:37 rillig Exp $ */ | 1 | /* $NetBSD: msg_344.c,v 1.2 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_344.c" | 2 | # 3 "msg_344.c" | |
3 | 3 | |||
4 | // Test for message: bit-field of type plain 'int' has implementation-defined signedness [344] | 4 | // Test for message: bit-field of type plain 'int' has implementation-defined signedness [344] | |
5 | 5 | |||
6 | /* lint1-extra-flags: -p */ | 6 | /* lint1-extra-flags: -p */ | |
7 | 7 | |||
8 | /* | 8 | /* | |
9 | * C90 3.5.2.1 allows 'int', 'signed int', 'unsigned int' as bit-field types. | 9 | * C90 3.5.2.1 allows 'int', 'signed int', 'unsigned int' as bit-field types. | |
10 | * | 10 | * | |
11 | * C99 6.7.2.1 significantly changed the wording of the allowable types for | 11 | * C99 6.7.2.1 significantly changed the wording of the allowable types for | |
12 | * bit-fields. For example, 6.7.2.1p4 does not mention plain 'int' at all. | 12 | * bit-fields. For example, 6.7.2.1p4 does not mention plain 'int' at all. | |
13 | * The rationale for C99 6.7.2.1 mentions plain 'int' though, and it would | 13 | * The rationale for C99 6.7.2.1 mentions plain 'int' though, and it would | |
14 | * have broken a lot of existing code to disallow plain 'int' as a bit-field | 14 | * have broken a lot of existing code to disallow plain 'int' as a bit-field | |
15 | * type. Footnote 104 explicitly mentions plain 'int' as well and it even | 15 | * type. Footnote 104 explicitly mentions plain 'int' as well and it even | |
16 | * allows typedef-types for bit-fields. | 16 | * allows typedef-types for bit-fields. | |
17 | */ | 17 | */ | |
18 | struct example { | 18 | struct example { | |
19 | /* expect+1: 344 */ | 19 | /* expect+1: warning: bit-field of type plain 'int' has implementation-defined signedness [344] */ | |
20 | int plain_int: 1; | 20 | int plain_int: 1; | |
21 | 21 | |||
22 | signed int signed_int: 1; | 22 | signed int signed_int: 1; | |
23 | unsigned int unsigned_int: 1; | 23 | unsigned int unsigned_int: 1; | |
24 | }; | 24 | }; |
--- src/tests/usr.bin/xlint/lint1/parse_stmt_error.c 2021/07/25 09:29:20 1.1
+++ src/tests/usr.bin/xlint/lint1/parse_stmt_error.c 2022/06/17 18:54:53 1.2
@@ -1,26 +1,26 @@ | @@ -1,26 +1,26 @@ | |||
1 | /* $NetBSD: parse_stmt_error.c,v 1.1 2021/07/25 09:29:20 rillig Exp $ */ | 1 | /* $NetBSD: parse_stmt_error.c,v 1.2 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "parse_stmt_error.c" | 2 | # 3 "parse_stmt_error.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Test parsing of errors in selection statements (if, switch). | 5 | * Test parsing of errors in selection statements (if, switch). | |
6 | */ | 6 | */ | |
7 | 7 | |||
8 | void do_nothing(void); | 8 | void do_nothing(void); | |
9 | 9 | |||
10 | void | 10 | void | |
11 | cover_selection_statement_else(_Bool cond) | 11 | cover_selection_statement_else(_Bool cond) | |
12 | { | 12 | { | |
13 | if (cond) | 13 | if (cond) | |
14 | do_nothing(); | 14 | do_nothing(); | |
15 | else | 15 | else | |
16 | /* expect+1: syntax error ']' [249] */ | 16 | /* expect+1: error: syntax error ']' [249] */ | |
17 | ]; | 17 | ]; | |
18 | } | 18 | } | |
19 | 19 | |||
20 | void | 20 | void | |
21 | cover_selection_statement_switch(int x) | 21 | cover_selection_statement_switch(int x) | |
22 | { | 22 | { | |
23 | switch (x) | 23 | switch (x) | |
24 | /* expect+1: syntax error ']' [249] */ | 24 | /* expect+1: error: syntax error ']' [249] */ | |
25 | ]; | 25 | ]; | |
26 | } | 26 | } |
--- src/tests/usr.bin/xlint/lint1/parse_stmt_iter_error.c 2021/07/25 09:29:20 1.1
+++ src/tests/usr.bin/xlint/lint1/parse_stmt_iter_error.c 2022/06/17 18:54:53 1.2
@@ -1,32 +1,32 @@ | @@ -1,32 +1,32 @@ | |||
1 | /* $NetBSD: parse_stmt_iter_error.c,v 1.1 2021/07/25 09:29:20 rillig Exp $ */ | 1 | /* $NetBSD: parse_stmt_iter_error.c,v 1.2 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "parse_stmt_iter_error.c" | 2 | # 3 "parse_stmt_iter_error.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Test parsing of errors in iteration statements (while, do, for). | 5 | * Test parsing of errors in iteration statements (while, do, for). | |
6 | */ | 6 | */ | |
7 | 7 | |||
8 | void do_nothing(void); | 8 | void do_nothing(void); | |
9 | 9 | |||
10 | void | 10 | void | |
11 | cover_iteration_statement_while(_Bool cond) | 11 | cover_iteration_statement_while(_Bool cond) | |
12 | { | 12 | { | |
13 | while (cond) | 13 | while (cond) | |
14 | /* expect+1: syntax error ']' [249] */ | 14 | /* expect+1: error: syntax error ']' [249] */ | |
15 | ]; | 15 | ]; | |
16 | } | 16 | } | |
17 | 17 | |||
18 | void | 18 | void | |
19 | cover_iteration_statement_do(void) | 19 | cover_iteration_statement_do(void) | |
20 | { | 20 | { | |
21 | do | 21 | do | |
22 | /* expect+1: syntax error ']' [249] */ | 22 | /* expect+1: error: syntax error ']' [249] */ | |
23 | ]; | 23 | ]; | |
24 | } | 24 | } | |
25 | 25 | |||
26 | void | 26 | void | |
27 | cover_iteration_statement_for(void) | 27 | cover_iteration_statement_for(void) | |
28 | { | 28 | { | |
29 | for (int i = 0; i < 10; i++) | 29 | for (int i = 0; i < 10; i++) | |
30 | /* expect+1: syntax error ']' [249] */ | 30 | /* expect+1: error: syntax error ']' [249] */ | |
31 | ]; | 31 | ]; | |
32 | } | 32 | } |
--- src/tests/usr.bin/xlint/lint1/stmt_goto.c 2021/07/14 20:39:13 1.1
+++ src/tests/usr.bin/xlint/lint1/stmt_goto.c 2022/06/17 18:54:53 1.2
@@ -1,26 +1,26 @@ | @@ -1,26 +1,26 @@ | |||
1 | /* $NetBSD: stmt_goto.c,v 1.1 2021/07/14 20:39:13 rillig Exp $ */ | 1 | /* $NetBSD: stmt_goto.c,v 1.2 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "stmt_goto.c" | 2 | # 3 "stmt_goto.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Tests for the 'goto' statement. | 5 | * Tests for the 'goto' statement. | |
6 | */ | 6 | */ | |
7 | 7 | |||
8 | /* expect+1: syntax error 'goto' [249] */ | 8 | /* expect+1: error: syntax error 'goto' [249] */ | |
9 | goto invalid_at_top_level; | 9 | goto invalid_at_top_level; | |
10 | 10 | |||
11 | void | 11 | void | |
12 | function(void) | 12 | function(void) | |
13 | { | 13 | { | |
14 | goto label; | 14 | goto label; | |
15 | label: | 15 | label: | |
16 | /* expect+1: syntax error '"' [249] */ | 16 | /* expect+1: error: syntax error '"' [249] */ | |
17 | goto "string"; | 17 | goto "string"; | |
18 | 18 | |||
19 | /* Reset the error handling of the parser. */ | 19 | /* Reset the error handling of the parser. */ | |
20 | goto ok; | 20 | goto ok; | |
21 | ok: | 21 | ok: | |
22 | 22 | |||
23 | /* Numeric labels work in Pascal, but not in C. */ | 23 | /* Numeric labels work in Pascal, but not in C. */ | |
24 | /* expect+1: syntax error '12345' [249] */ | 24 | /* expect+1: error: syntax error '12345' [249] */ | |
25 | goto 12345; | 25 | goto 12345; | |
26 | } | 26 | } |
--- src/tests/usr.bin/xlint/lint1/stmt_if.c 2021/07/11 18:58:13 1.1
+++ src/tests/usr.bin/xlint/lint1/stmt_if.c 2022/06/17 18:54:53 1.2
@@ -1,28 +1,28 @@ | @@ -1,28 +1,28 @@ | |||
1 | /* $NetBSD: stmt_if.c,v 1.1 2021/07/11 18:58:13 rillig Exp $ */ | 1 | /* $NetBSD: stmt_if.c,v 1.2 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "stmt_if.c" | 2 | # 3 "stmt_if.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Test parsing of 'if' statements. | 5 | * Test parsing of 'if' statements. | |
6 | */ | 6 | */ | |
7 | 7 | |||
8 | void println(const char *); | 8 | void println(const char *); | |
9 | 9 | |||
10 | void | 10 | void | |
11 | dangling_else(int x) | 11 | dangling_else(int x) | |
12 | { | 12 | { | |
13 | if (x > 0) | 13 | if (x > 0) | |
14 | if (x > 10) | 14 | if (x > 10) | |
15 | println("> 10"); | 15 | println("> 10"); | |
16 | /* This 'else' is bound to the closest unfinished 'if'. */ | 16 | /* This 'else' is bound to the closest unfinished 'if'. */ | |
17 | else | 17 | else | |
18 | println("> 0"); | 18 | println("> 0"); | |
19 | /* | 19 | /* | |
20 | * If the above 'else' were bound to the other 'if', the next 'else' | 20 | * If the above 'else' were bound to the other 'if', the next 'else' | |
21 | * would have no corresponding 'if', resulting in a syntax error. | 21 | * would have no corresponding 'if', resulting in a syntax error. | |
22 | */ | 22 | */ | |
23 | else | 23 | else | |
24 | println("not positive"); | 24 | println("not positive"); | |
25 | /* expect+1: syntax error 'else' [249] */ | 25 | /* expect+1: error: syntax error 'else' [249] */ | |
26 | else | 26 | else | |
27 | println("syntax error"); | 27 | println("syntax error"); | |
28 | } | 28 | } |
--- src/tests/usr.bin/xlint/lint1/decl_struct_member.c 2022/01/15 14:22:03 1.14
+++ src/tests/usr.bin/xlint/lint1/decl_struct_member.c 2022/06/17 18:54:53 1.15
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: decl_struct_member.c,v 1.14 2022/01/15 14:22:03 rillig Exp $ */ | 1 | /* $NetBSD: decl_struct_member.c,v 1.15 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "decl_struct_member.c" | 2 | # 3 "decl_struct_member.c" | |
3 | 3 | |||
4 | struct multi_attributes { | 4 | struct multi_attributes { | |
5 | __attribute__((deprecated)) | 5 | __attribute__((deprecated)) | |
6 | __attribute__((deprecated)) | 6 | __attribute__((deprecated)) | |
7 | __attribute__((deprecated)) | 7 | __attribute__((deprecated)) | |
8 | int deprecated; | 8 | int deprecated; | |
9 | }; | 9 | }; | |
10 | 10 | |||
11 | struct cover_begin_type_specifier_qualifier_list { | 11 | struct cover_begin_type_specifier_qualifier_list { | |
12 | int m1; | 12 | int m1; | |
13 | __attribute__((deprecated)) int m2; | 13 | __attribute__((deprecated)) int m2; | |
14 | const int m3; | 14 | const int m3; | |
@@ -77,14 +77,14 @@ struct array_of_bit_fields { | @@ -77,14 +77,14 @@ struct array_of_bit_fields { | |||
77 | * Before decl.c 1.188 from 2021-06-20, lint ran into a segmentation fault. | 77 | * Before decl.c 1.188 from 2021-06-20, lint ran into a segmentation fault. | |
78 | */ | 78 | */ | |
79 | struct { | 79 | struct { | |
80 | /* expect+1: error: syntax error '0' [249] */ | 80 | /* expect+1: error: syntax error '0' [249] */ | |
81 | char a(_)0 | 81 | char a(_)0 | |
82 | 82 | |||
83 | /* | 83 | /* | |
84 | * Before cgram.y 1.328 from 2021-07-15, lint ran into an assertion failure | 84 | * Before cgram.y 1.328 from 2021-07-15, lint ran into an assertion failure | |
85 | * at the closing semicolon: | 85 | * at the closing semicolon: | |
86 | * | 86 | * | |
87 | * assertion "t == NOTSPEC" failed in end_type at decl.c:774 | 87 | * assertion "t == NOTSPEC" failed in end_type at decl.c:774 | |
88 | */ | 88 | */ | |
89 | }; | 89 | }; | |
90 | /* expect+1: cannot recover from previous errors */ | 90 | /* expect+1: error: cannot recover from previous errors [224] */ |
--- src/tests/usr.bin/xlint/lint1/expr_binary.c 2021/08/01 14:51:41 1.5
+++ src/tests/usr.bin/xlint/lint1/expr_binary.c 2022/06/17 18:54:53 1.6
@@ -1,129 +1,129 @@ | @@ -1,129 +1,129 @@ | |||
1 | /* $NetBSD: expr_binary.c,v 1.5 2021/08/01 14:51:41 rillig Exp $ */ | 1 | /* $NetBSD: expr_binary.c,v 1.6 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "expr_binary.c" | 2 | # 3 "expr_binary.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Test binary operators. | 5 | * Test binary operators. | |
6 | */ | 6 | */ | |
7 | 7 | |||
8 | /* lint1-only-if: lp64 */ | 8 | /* lint1-only-if: lp64 */ | |
9 | 9 | |||
10 | struct incompatible { /* just to generate the error message */ | 10 | struct incompatible { /* just to generate the error message */ | |
11 | int member; | 11 | int member; | |
12 | }; | 12 | }; | |
13 | void sink(struct incompatible); | 13 | void sink(struct incompatible); | |
14 | 14 | |||
15 | /* | 15 | /* | |
16 | * Test the usual arithmetic conversions. | 16 | * Test the usual arithmetic conversions. | |
17 | * | 17 | * | |
18 | * C99 6.3.1.8 "Usual arithmetic conversions" | 18 | * C99 6.3.1.8 "Usual arithmetic conversions" | |
19 | */ | 19 | */ | |
20 | void | 20 | void | |
21 | cover_balance(void) | 21 | cover_balance(void) | |
22 | { | 22 | { | |
23 | /* expect+1: 'pointer to void' */ | 23 | /* expect+1: ... 'pointer to void' ... */ | |
24 | sink((void *)0 + 0); | 24 | sink((void *)0 + 0); | |
25 | 25 | |||
26 | /* expect+1: 'pointer to void' */ | 26 | /* expect+1: ... 'pointer to void' ... */ | |
27 | sink(0 + (void *)0); | 27 | sink(0 + (void *)0); | |
28 | 28 | |||
29 | /* expect+1: 'int' */ | 29 | /* expect+1: ... 'int' ... */ | |
30 | sink(1 + 1); | 30 | sink(1 + 1); | |
31 | 31 | |||
32 | /* expect+1: 'const int' */ | 32 | /* expect+1: ... 'const int' ... */ | |
33 | sink((const int)1 + (volatile int)1); | 33 | sink((const int)1 + (volatile int)1); | |
34 | 34 | |||
35 | /* expect+1: 'volatile int' */ | 35 | /* expect+1: ... 'volatile int' ... */ | |
36 | sink((volatile int)1 + (const int)1); | 36 | sink((volatile int)1 + (const int)1); | |
37 | 37 | |||
38 | long double _Complex cldbl = 0.0; | 38 | long double _Complex cldbl = 0.0; | |
39 | double _Complex cdbl = 0.0; | 39 | double _Complex cdbl = 0.0; | |
40 | float _Complex cflt = 0.0f; | 40 | float _Complex cflt = 0.0f; | |
41 | /* expect+1: error: invalid type for _Complex [308] */ | 41 | /* expect+1: error: invalid type for _Complex [308] */ | |
42 | _Complex invalid = 0.0; | 42 | _Complex invalid = 0.0; | |
43 | 43 | |||
44 | /* expect+1: 'long double _Complex' */ | 44 | /* expect+1: ... 'long double _Complex' ... */ | |
45 | sink(cldbl + 0); | 45 | sink(cldbl + 0); | |
46 | /* expect+1: 'long double _Complex' */ | 46 | /* expect+1: ... 'long double _Complex' ... */ | |
47 | sink(0 + cldbl); | 47 | sink(0 + cldbl); | |
48 | /* expect+1: 'long double _Complex' */ | 48 | /* expect+1: ... 'long double _Complex' ... */ | |
49 | sink(cldbl + cdbl); | 49 | sink(cldbl + cdbl); | |
50 | /* expect+1: 'long double _Complex' */ | 50 | /* expect+1: ... 'long double _Complex' ... */ | |
51 | sink(cdbl + cldbl); | 51 | sink(cdbl + cldbl); | |
52 | 52 | |||
53 | /* expect+1: 'double _Complex' */ | 53 | /* expect+1: ... 'double _Complex' ... */ | |
54 | sink(cdbl + 0); | 54 | sink(cdbl + 0); | |
55 | /* expect+1: 'double _Complex' */ | 55 | /* expect+1: ... 'double _Complex' ... */ | |
56 | sink(0 + cdbl); | 56 | sink(0 + cdbl); | |
57 | /* expect+1: 'double _Complex' */ | 57 | /* expect+1: ... 'double _Complex' ... */ | |
58 | sink(cdbl + cflt); | 58 | sink(cdbl + cflt); | |
59 | /* expect+1: 'double _Complex' */ | 59 | /* expect+1: ... 'double _Complex' ... */ | |
60 | sink(cflt + cdbl); | 60 | sink(cflt + cdbl); | |
61 | 61 | |||
62 | /* expect+1: 'float _Complex' */ | 62 | /* expect+1: ... 'float _Complex' ... */ | |
63 | sink(cflt + 0); | 63 | sink(cflt + 0); | |
64 | /* expect+1: 'float _Complex' */ | 64 | /* expect+1: ... 'float _Complex' ... */ | |
65 | sink(0 + cflt); | 65 | sink(0 + cflt); | |
66 | /* expect+1: 'float _Complex' */ | 66 | /* expect+1: ... 'float _Complex' ... */ | |
67 | sink(cflt + (__uint128_t)0); | 67 | sink(cflt + (__uint128_t)0); | |
68 | /* expect+1: 'float _Complex' */ | 68 | /* expect+1: ... 'float _Complex' ... */ | |
69 | sink((__uint128_t)0 + cflt); | 69 | sink((__uint128_t)0 + cflt); | |
70 | 70 | |||
71 | /* | 71 | /* | |
72 | * The type specifier '_Complex' is only used during parsing, it does | 72 | * The type specifier '_Complex' is only used during parsing, it does | |
73 | * not make it to the expression. | 73 | * not make it to the expression. | |
74 | */ | 74 | */ | |
75 | /* expect+1: 'double _Complex' */ | 75 | /* expect+1: ... 'double _Complex' ... */ | |
76 | sink(invalid + 0); | 76 | sink(invalid + 0); | |
77 | 77 | |||
78 | /* expect+1: 'long double' */ | 78 | /* expect+1: ... 'long double' ... */ | |
79 | sink(0.0L + 0); | 79 | sink(0.0L + 0); | |
80 | /* expect+1: 'long double' */ | 80 | /* expect+1: ... 'long double' ... */ | |
81 | sink(0 + 0.0L); | 81 | sink(0 + 0.0L); | |
82 | /* expect+1: 'long double' */ | 82 | /* expect+1: ... 'long double' ... */ | |
83 | sink(0.0L + 0.0); | 83 | sink(0.0L + 0.0); | |
84 | /* expect+1: 'long double' */ | 84 | /* expect+1: ... 'long double' ... */ | |
85 | sink(0.0 + 0.0L); | 85 | sink(0.0 + 0.0L); | |
86 | 86 | |||
87 | /* expect+1: 'double' */ | 87 | /* expect+1: ... 'double' ... */ | |
88 | sink(0.0 + 0); | 88 | sink(0.0 + 0); | |
89 | /* expect+1: 'double' */ | 89 | /* expect+1: ... 'double' ... */ | |
90 | sink(0 + 0.0); | 90 | sink(0 + 0.0); | |
91 | /* expect+1: 'double' */ | 91 | /* expect+1: ... 'double' ... */ | |
92 | sink(0.0 + 0.0f); | 92 | sink(0.0 + 0.0f); | |
93 | /* expect+1: 'double' */ | 93 | /* expect+1: ... 'double' ... */ | |
94 | sink(0.0f + 0.0); | 94 | sink(0.0f + 0.0); | |
95 | 95 | |||
96 | /* expect+1: 'float' */ | 96 | /* expect+1: ... 'float' ... */ | |
97 | sink(0.0f + 0); | 97 | sink(0.0f + 0); | |
98 | /* expect+1: 'float' */ | 98 | /* expect+1: ... 'float' ... */ | |
99 | sink(0 + 0.0f); | 99 | sink(0 + 0.0f); | |
100 | /* expect+1: 'float' */ | 100 | /* expect+1: ... 'float' ... */ | |
101 | sink(0.0f + (__uint128_t)0); | 101 | sink(0.0f + (__uint128_t)0); | |
102 | /* expect+1: 'float' */ | 102 | /* expect+1: ... 'float' ... */ | |
103 | sink((__uint128_t)0 + 0.0f); | 103 | sink((__uint128_t)0 + 0.0f); | |
104 | 104 | |||
105 | /* expect+1: 'unsigned long long' */ | 105 | /* expect+1: ... 'unsigned long long' ... */ | |
106 | sink(0ULL + 0); | 106 | sink(0ULL + 0); | |
107 | /* expect+1: 'unsigned long long' */ | 107 | /* expect+1: ... 'unsigned long long' ... */ | |
108 | sink(0 + 0ULL); | 108 | sink(0 + 0ULL); | |
109 | 109 | |||
110 | /* expect+1: 'unsigned long long' */ | 110 | /* expect+1: ... 'unsigned long long' ... */ | |
111 | sink(0ULL + 0LL); | 111 | sink(0ULL + 0LL); | |
112 | /* expect+1: 'unsigned long long' */ | 112 | /* expect+1: ... 'unsigned long long' ... */ | |
113 | sink(0LL + 0ULL); | 113 | sink(0LL + 0ULL); | |
114 | 114 | |||
115 | /* If the bit-width is the same, prefer the unsigned variant. */ | 115 | /* If the bit-width is the same, prefer the unsigned variant. */ | |
116 | /* expect+1: 'unsigned long long' */ | 116 | /* expect+1: ... 'unsigned long long' ... */ | |
117 | sink(0UL + 0LL); | 117 | sink(0UL + 0LL); | |
118 | /* expect+1: 'unsigned long long' */ | 118 | /* expect+1: ... 'unsigned long long' ... */ | |
119 | sink(0LL + 0UL); | 119 | sink(0LL + 0UL); | |
120 | 120 | |||
121 | /* | 121 | /* | |
122 | * Ensure that __int128_t is listed in the integer ranks. This table | 122 | * Ensure that __int128_t is listed in the integer ranks. This table | |
123 | * only becomes relevant when both operands have the same width. | 123 | * only becomes relevant when both operands have the same width. | |
124 | */ | 124 | */ | |
125 | /* expect+1: '__uint128_t' */ | 125 | /* expect+1: ... '__uint128_t' ... */ | |
126 | sink((__uint128_t)1 + (__int128_t)1); | 126 | sink((__uint128_t)1 + (__int128_t)1); | |
127 | /* expect+1: '__uint128_t' */ | 127 | /* expect+1: ... '__uint128_t' ... */ | |
128 | sink((__int128_t)1 + (__uint128_t)1); | 128 | sink((__int128_t)1 + (__uint128_t)1); | |
129 | } | 129 | } |
--- src/tests/usr.bin/xlint/lint1/gcc_init_compound_literal.c 2022/06/11 11:52:13 1.5
+++ src/tests/usr.bin/xlint/lint1/gcc_init_compound_literal.c 2022/06/17 18:54:53 1.6
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: gcc_init_compound_literal.c,v 1.5 2022/06/11 11:52:13 rillig Exp $ */ | 1 | /* $NetBSD: gcc_init_compound_literal.c,v 1.6 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "gcc_init_compound_literal.c" | 2 | # 3 "gcc_init_compound_literal.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * C99 says in 6.7.8p4: | 5 | * C99 says in 6.7.8p4: | |
6 | * | 6 | * | |
7 | * All the expressions in an initializer for an object that has static | 7 | * All the expressions in an initializer for an object that has static | |
8 | * storage duration shall be constant expressions or string literals. | 8 | * storage duration shall be constant expressions or string literals. | |
9 | * | 9 | * | |
10 | * The term "constant expression" is defined in C99 6.6, where 6.6p9 allows | 10 | * The term "constant expression" is defined in C99 6.6, where 6.6p9 allows | |
11 | * "constant expressions" in initializers to also be an "address constant". | 11 | * "constant expressions" in initializers to also be an "address constant". | |
12 | * Using these address constants, it is possible to reference an unnamed | 12 | * Using these address constants, it is possible to reference an unnamed | |
13 | * object created by a compound literal (C99 6.5.2.5), using either an | 13 | * object created by a compound literal (C99 6.5.2.5), using either an | |
14 | * explicit '&' or the implicit array-to-pointer conversion from C99 6.3.2.1. | 14 | * explicit '&' or the implicit array-to-pointer conversion from C99 6.3.2.1. | |
@@ -27,27 +27,27 @@ const struct { | @@ -27,27 +27,27 @@ const struct { | |||
27 | }, | 27 | }, | |
28 | }; | 28 | }; | |
29 | 29 | |||
30 | struct node { | 30 | struct node { | |
31 | int num; | 31 | int num; | |
32 | struct node *left; | 32 | struct node *left; | |
33 | struct node *right; | 33 | struct node *right; | |
34 | }; | 34 | }; | |
35 | 35 | |||
36 | /* | 36 | /* | |
37 | * Initial tree for representing the decisions in the classic number guessing | 37 | * Initial tree for representing the decisions in the classic number guessing | |
38 | * game often used in teaching the basics of programming. | 38 | * game often used in teaching the basics of programming. | |
39 | */ | 39 | */ | |
40 | /* expect+1: static variable 'guess' unused */ | 40 | /* expect+1: warning: static variable 'guess' unused [226] */ | |
41 | static const struct node guess = { | 41 | static const struct node guess = { | |
42 | 50, | 42 | 50, | |
43 | &(struct node){ | 43 | &(struct node){ | |
44 | 25, | 44 | 25, | |
45 | &(struct node){ | 45 | &(struct node){ | |
46 | 12, | 46 | 12, | |
47 | (void *)0, | 47 | (void *)0, | |
48 | (void *)0, | 48 | (void *)0, | |
49 | }, | 49 | }, | |
50 | &(struct node){ | 50 | &(struct node){ | |
51 | 37, | 51 | 37, | |
52 | (void *)0, | 52 | (void *)0, | |
53 | (void *)0, | 53 | (void *)0, |
--- src/tests/usr.bin/xlint/lint1/lex_char.c 2022/04/01 21:12:42 1.5
+++ src/tests/usr.bin/xlint/lint1/lex_char.c 2022/06/17 18:54:53 1.6
@@ -1,50 +1,50 @@ | @@ -1,50 +1,50 @@ | |||
1 | /* $NetBSD: lex_char.c,v 1.5 2022/04/01 21:12:42 rillig Exp $ */ | 1 | /* $NetBSD: lex_char.c,v 1.6 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "lex_char.c" | 2 | # 3 "lex_char.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Tests for lexical analysis of character constants. | 5 | * Tests for lexical analysis of character constants. | |
6 | * | 6 | * | |
7 | * C99 6.4.4.4 "Character constants" | 7 | * C99 6.4.4.4 "Character constants" | |
8 | */ | 8 | */ | |
9 | 9 | |||
10 | void sink(char); | 10 | void sink(char); | |
11 | 11 | |||
12 | void | 12 | void | |
13 | test(void) | 13 | test(void) | |
14 | { | 14 | { | |
15 | /* expect+1: empty character constant */ | 15 | /* expect+1: error: empty character constant [73] */ | |
16 | sink(''); | 16 | sink(''); | |
17 | 17 | |||
18 | sink('a'); | 18 | sink('a'); | |
19 | 19 | |||
20 | sink('\0'); | 20 | sink('\0'); | |
21 | 21 | |||
22 | /* UTF-8 */ | 22 | /* UTF-8 */ | |
23 | /* expect+2: multi-character character constant */ | 23 | /* expect+2: warning: multi-character character constant [294] */ | |
24 | /* expect+1: conversion of 'int' to 'char' is out of range */ | 24 | /* expect+1: warning: conversion of 'int' to 'char' is out of range, arg #1 [295] */ | |
25 | sink('ä'); | 25 | sink('ä'); | |
26 | 26 | |||
27 | /* GCC extension */ | 27 | /* GCC extension */ | |
28 | /* expect+1: dubious escape \e */ | 28 | /* expect+1: warning: dubious escape \e [79] */ | |
29 | sink('\e'); | 29 | sink('\e'); | |
30 | 30 | |||
31 | /* since C99 */ | 31 | /* since C99 */ | |
32 | sink('\x12'); | 32 | sink('\x12'); | |
33 | 33 | |||
34 | /* octal */ | 34 | /* octal */ | |
35 | sink('\177'); | 35 | sink('\177'); | |
36 | 36 | |||
37 | /* expect+1: empty character constant */ | 37 | /* expect+1: error: empty character constant [73] */ | |
38 | sink(''); | 38 | sink(''); | |
39 | 39 | |||
40 | /* U+0007 alarm/bell */ | 40 | /* U+0007 alarm/bell */ | |
41 | sink('\a'); | 41 | sink('\a'); | |
42 | 42 | |||
43 | /* U+0008 backspace */ | 43 | /* U+0008 backspace */ | |
44 | sink('\b'); | 44 | sink('\b'); | |
45 | 45 | |||
46 | /* U+0009 horizontal tabulation */ | 46 | /* U+0009 horizontal tabulation */ | |
47 | sink('\t'); | 47 | sink('\t'); | |
48 | 48 | |||
49 | /* U+000A line feed */ | 49 | /* U+000A line feed */ | |
50 | sink('\n'); | 50 | sink('\n'); |
--- src/tests/usr.bin/xlint/lint1/msg_034.c 2021/05/16 11:11:37 1.5
+++ src/tests/usr.bin/xlint/lint1/msg_034.c 2022/06/17 18:54:53 1.6
@@ -1,28 +1,28 @@ | @@ -1,28 +1,28 @@ | |||
1 | /* $NetBSD: msg_034.c,v 1.5 2021/05/16 11:11:37 rillig Exp $ */ | 1 | /* $NetBSD: msg_034.c,v 1.6 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_034.c" | 2 | # 3 "msg_034.c" | |
3 | 3 | |||
4 | // Test for message: nonportable bit-field type '%s' [34] | 4 | // Test for message: nonportable bit-field type '%s' [34] | |
5 | 5 | |||
6 | /* No -g since GCC allows all integer types as bit-fields. */ | 6 | /* No -g since GCC allows all integer types as bit-fields. */ | |
7 | /* lint1-flags: -S -p -w */ | 7 | /* lint1-flags: -S -p -w */ | |
8 | 8 | |||
9 | /* | 9 | /* | |
10 | * C90 3.5.2.1 allows 'int', 'signed int', 'unsigned int' as bit-field types. | 10 | * C90 3.5.2.1 allows 'int', 'signed int', 'unsigned int' as bit-field types. | |
11 | * | 11 | * | |
12 | * C99 6.7.2.1 significantly changed the wording of the allowable types for | 12 | * C99 6.7.2.1 significantly changed the wording of the allowable types for | |
13 | * bit-fields. For example, 6.7.2.1p4 does not mention plain 'int' at all. | 13 | * bit-fields. For example, 6.7.2.1p4 does not mention plain 'int' at all. | |
14 | * The rationale for C99 6.7.2.1 mentions plain int though, and it would have | 14 | * The rationale for C99 6.7.2.1 mentions plain int though, and it would have | |
15 | * broken a lot of existing code to disallow plain 'int' as a bit-field type. | 15 | * broken a lot of existing code to disallow plain 'int' as a bit-field type. | |
16 | * Footnote 104 explicitly mentions plain 'int' as well and it even allows | 16 | * Footnote 104 explicitly mentions plain 'int' as well and it even allows | |
17 | * typedef-types for bit-fields. | 17 | * typedef-types for bit-fields. | |
18 | */ | 18 | */ | |
19 | struct example { | 19 | struct example { | |
20 | /* expect+1: 34 */ | 20 | /* expect+1: warning: nonportable bit-field type 'unsigned short' [34] */ | |
21 | unsigned short ushort: 1; | 21 | unsigned short ushort: 1; | |
22 | 22 | |||
23 | /* expect+1: 344 */ | 23 | /* expect+1: warning: bit-field of type plain 'int' has implementation-defined signedness [344] */ | |
24 | int plain_int: 1; | 24 | int plain_int: 1; | |
25 | 25 | |||
26 | signed int signed_int: 1; | 26 | signed int signed_int: 1; | |
27 | unsigned int portable: 1; | 27 | unsigned int portable: 1; | |
28 | }; | 28 | }; |
--- src/tests/usr.bin/xlint/lint1/msg_066.c 2021/08/26 19:23:25 1.5
+++ src/tests/usr.bin/xlint/lint1/msg_066.c 2022/06/17 18:54:53 1.6
@@ -1,16 +1,16 @@ | @@ -1,16 +1,16 @@ | |||
1 | /* $NetBSD: msg_066.c,v 1.5 2021/08/26 19:23:25 rillig Exp $ */ | 1 | /* $NetBSD: msg_066.c,v 1.6 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_066.c" | 2 | # 3 "msg_066.c" | |
3 | 3 | |||
4 | // Test for message: syntax requires ';' after last struct/union member [66] | 4 | // Test for message: syntax requires ';' after last struct/union member [66] | |
5 | /* This message is not used. */ | 5 | /* This message is not used. */ | |
6 | 6 | |||
7 | /* | 7 | /* | |
8 | * This message was removed in cgram.y 1.328 from 2021-07-15 because all | 8 | * This message was removed in cgram.y 1.328 from 2021-07-15 because all | |
9 | * C standards and even K&R require a semicolon. | 9 | * C standards and even K&R require a semicolon. | |
10 | */ | 10 | */ | |
11 | 11 | |||
12 | struct number { | 12 | struct number { | |
13 | int value | 13 | int value | |
14 | }; | 14 | }; | |
15 | /* expect-1: syntax error '}' [249] */ | 15 | /* expect-1: error: syntax error '}' [249] */ | |
16 | /* expect+1: error: cannot recover from previous errors [224] */ | 16 | /* expect+1: error: cannot recover from previous errors [224] */ |
--- src/tests/usr.bin/xlint/lint1/msg_077.c 2022/06/15 20:18:31 1.5
+++ src/tests/usr.bin/xlint/lint1/msg_077.c 2022/06/17 18:54:53 1.6
@@ -1,27 +1,27 @@ | @@ -1,27 +1,27 @@ | |||
1 | /* $NetBSD: msg_077.c,v 1.5 2022/06/15 20:18:31 rillig Exp $ */ | 1 | /* $NetBSD: msg_077.c,v 1.6 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_077.c" | 2 | # 3 "msg_077.c" | |
3 | 3 | |||
4 | /* Test for message: bad octal digit %c [77] */ | 4 | /* Test for message: bad octal digit %c [77] */ | |
5 | 5 | |||
6 | /* lint1-flags: -tw */ | 6 | /* lint1-flags: -tw */ | |
7 | 7 | |||
8 | /* expect+1: warning: bad octal digit 8 [77] */ | 8 | /* expect+1: warning: bad octal digit 8 [77] */ | |
9 | char single_digit = '\8'; | 9 | char single_digit = '\8'; | |
10 | 10 | |||
11 | /* | 11 | /* | |
12 | * Before lex.c 1.47 from 2021-06-29, lint intended to detect a "bad octal | 12 | * Before lex.c 1.47 from 2021-06-29, lint intended to detect a "bad octal | |
13 | * digit" following good octal digits, but the corresponding code had an | 13 | * digit" following good octal digits, but the corresponding code had an | |
14 | * unsatisfiable guard clause. | 14 | * unsatisfiable guard clause. | |
15 | * | 15 | * | |
16 | * The C Reference Manual 1978, 2.4.3 "Character constants" does not mention | 16 | * The C Reference Manual 1978, 2.4.3 "Character constants" does not mention | |
17 | * non-octal digits, therefore this code must have been due to a particular | 17 | * non-octal digits, therefore this code must have been due to a particular | |
18 | * C compiler's interpretation. It's even wrong according to the Reference | 18 | * C compiler's interpretation. It's even wrong according to the Reference | |
19 | * Manual to interpret '\088' as anything else than a malformed character | 19 | * Manual to interpret '\088' as anything else than a malformed character | |
20 | * literal. | 20 | * literal. | |
21 | * | 21 | * | |
22 | * That code has been removed since nobody runs lint in traditional C mode | 22 | * That code has been removed since nobody runs lint in traditional C mode | |
23 | * anyway. | 23 | * anyway. | |
24 | * https://mail-index.netbsd.org/tech-toolchain/2021/03/16/msg003933.html | 24 | * https://mail-index.netbsd.org/tech-toolchain/2021/03/16/msg003933.html | |
25 | */ | 25 | */ | |
26 | /* expect+1: multi-character character constant [294] */ | 26 | /* expect+1: warning: multi-character character constant [294] */ | |
27 | char several_digits = '\08'; | 27 | char several_digits = '\08'; |
--- src/tests/usr.bin/xlint/lint1/msg_118.c 2021/05/04 19:57:56 1.5
+++ src/tests/usr.bin/xlint/lint1/msg_118.c 2022/06/17 18:54:53 1.6
@@ -1,30 +1,30 @@ | @@ -1,30 +1,30 @@ | |||
1 | /* $NetBSD: msg_118.c,v 1.5 2021/05/04 19:57:56 rillig Exp $ */ | 1 | /* $NetBSD: msg_118.c,v 1.6 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_118.c" | 2 | # 3 "msg_118.c" | |
3 | 3 | |||
4 | /* Test for message: semantics of '%s' change in ANSI C; use explicit cast [118] */ | 4 | /* Test for message: semantics of '%s' change in ANSI C; use explicit cast [118] */ | |
5 | 5 | |||
6 | /* lint1-flags: -hw */ | 6 | /* lint1-flags: -hw */ | |
7 | 7 | |||
8 | int | 8 | int | |
9 | int_shl_uint(int left, unsigned int right) | 9 | int_shl_uint(int left, unsigned int right) | |
10 | { | 10 | { | |
11 | return left << right; | 11 | return left << right; | |
12 | } | 12 | } | |
13 | 13 | |||
14 | int | 14 | int | |
15 | int_shr_uint(int left, unsigned int right) | 15 | int_shr_uint(int left, unsigned int right) | |
16 | { | 16 | { | |
17 | /* expect+1: semantics of '>>' change in ANSI C */ | 17 | /* expect+1: warning: semantics of '>>' change in ANSI C; use explicit cast [118] */ | |
18 | return left >> right; | 18 | return left >> right; | |
19 | } | 19 | } | |
20 | 20 | |||
21 | int | 21 | int | |
22 | int_shl_int(int left, int right) | 22 | int_shl_int(int left, int right) | |
23 | { | 23 | { | |
24 | return left << right; | 24 | return left << right; | |
25 | } | 25 | } | |
26 | 26 | |||
27 | /* | 27 | /* | |
28 | * The behavior of typeok_shl can only be triggered on 64-bit platforms, or | 28 | * The behavior of typeok_shl can only be triggered on 64-bit platforms, or | |
29 | * in C99 mode, and the above tests require C90 mode. | 29 | * in C99 mode, and the above tests require C90 mode. | |
30 | * | 30 | * |
--- src/tests/usr.bin/xlint/lint1/msg_189.c 2021/08/26 19:23:25 1.5
+++ src/tests/usr.bin/xlint/lint1/msg_189.c 2022/06/17 18:54:53 1.6
@@ -1,21 +1,21 @@ | @@ -1,21 +1,21 @@ | |||
1 | /* $NetBSD: msg_189.c,v 1.5 2021/08/26 19:23:25 rillig Exp $ */ | 1 | /* $NetBSD: msg_189.c,v 1.6 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_189.c" | 2 | # 3 "msg_189.c" | |
3 | 3 | |||
4 | /* Test for message: assignment of struct/union illegal in traditional C [189] */ | 4 | /* Test for message: assignment of struct/union illegal in traditional C [189] */ | |
5 | /* This message is not used. */ | 5 | /* This message is not used. */ | |
6 | 6 | |||
7 | /* lint1-flags: -tw */ | 7 | /* lint1-flags: -tw */ | |
8 | 8 | |||
9 | struct s { | 9 | struct s { | |
10 | int member; | 10 | int member; | |
11 | }; | 11 | }; | |
12 | 12 | |||
13 | void | 13 | void | |
14 | example() | 14 | example() | |
15 | { | 15 | { | |
16 | struct s a, b; | 16 | struct s a, b; | |
17 | 17 | |||
18 | a.member = 3; | 18 | a.member = 3; | |
19 | b = a; /* message 189 is not triggered anymore */ | 19 | b = a; /* message 189 is not triggered anymore */ | |
20 | /* expect-1: 'b' set but not used in function 'example' */ | 20 | /* expect-1: warning: 'b' set but not used in function 'example' [191] */ | |
21 | } | 21 | } |
--- src/tests/usr.bin/xlint/lint1/msg_232.c 2021/07/11 19:30:56 1.5
+++ src/tests/usr.bin/xlint/lint1/msg_232.c 2022/06/17 18:54:53 1.6
@@ -1,15 +1,15 @@ | @@ -1,15 +1,15 @@ | |||
1 | /* $NetBSD: msg_232.c,v 1.5 2021/07/11 19:30:56 rillig Exp $ */ | 1 | /* $NetBSD: msg_232.c,v 1.6 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_232.c" | 2 | # 3 "msg_232.c" | |
3 | 3 | |||
4 | // Test for message: label '%s' unused in function '%s' [232] | 4 | // Test for message: label '%s' unused in function '%s' [232] | |
5 | 5 | |||
6 | void | 6 | void | |
7 | example(void) | 7 | example(void) | |
8 | { | 8 | { | |
9 | goto used_label; | 9 | goto used_label; | |
10 | /* expect+1: label 'unused_label' unused in function 'example' [232] */ | 10 | /* expect+1: warning: label 'unused_label' unused in function 'example' [232] */ | |
11 | unused_label: | 11 | unused_label: | |
12 | return; | 12 | return; | |
13 | used_label: | 13 | used_label: | |
14 | return; | 14 | return; | |
15 | } | 15 | } |
--- src/tests/usr.bin/xlint/lint1/expr_precedence.c 2021/11/16 17:41:23 1.8
+++ src/tests/usr.bin/xlint/lint1/expr_precedence.c 2022/06/17 18:54:53 1.9
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: expr_precedence.c,v 1.8 2021/11/16 17:41:23 rillig Exp $ */ | 1 | /* $NetBSD: expr_precedence.c,v 1.9 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "expr_precedence.c" | 2 | # 3 "expr_precedence.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Tests for the precedence among operators. | 5 | * Tests for the precedence among operators. | |
6 | */ | 6 | */ | |
7 | 7 | |||
8 | int var; | 8 | int var; | |
9 | 9 | |||
10 | /* | 10 | /* | |
11 | * An initializer needs an assignment-expression; the comma must be | 11 | * An initializer needs an assignment-expression; the comma must be | |
12 | * interpreted as a separator, not an operator. | 12 | * interpreted as a separator, not an operator. | |
13 | */ | 13 | */ | |
14 | /* expect+1: error: syntax error '4' [249] */ | 14 | /* expect+1: error: syntax error '4' [249] */ | |
@@ -21,27 +21,27 @@ int init_syntactically_ok = var = 1 ? 2 | @@ -21,27 +21,27 @@ int init_syntactically_ok = var = 1 ? 2 | |||
21 | * The arguments of __attribute__ must be constant-expression, as assignments | 21 | * The arguments of __attribute__ must be constant-expression, as assignments | |
22 | * don't make sense at that point. | 22 | * don't make sense at that point. | |
23 | */ | 23 | */ | |
24 | void __attribute__((format(printf, | 24 | void __attribute__((format(printf, | |
25 | /* | 25 | /* | |
26 | * Inside of __attribute__((...)), symbol lookup works differently. For | 26 | * Inside of __attribute__((...)), symbol lookup works differently. For | |
27 | * example, 'printf' is a keyword, and since all arguments to | 27 | * example, 'printf' is a keyword, and since all arguments to | |
28 | * __attribute__ are constant expressions, looking up global variables | 28 | * __attribute__ are constant expressions, looking up global variables | |
29 | * would not make sense. Therefore, 'var' is undefined. | 29 | * would not make sense. Therefore, 'var' is undefined. | |
30 | * | 30 | * | |
31 | * See lex.c, function 'search', keyword 'in_gcc_attribute'. | 31 | * See lex.c, function 'search', keyword 'in_gcc_attribute'. | |
32 | */ | 32 | */ | |
33 | /* expect+2: error: 'var' undefined [99] */ | 33 | /* expect+2: error: 'var' undefined [99] */ | |
34 | /* expect+1: syntax error '=' [249] */ | 34 | /* expect+1: error: syntax error '=' [249] */ | |
35 | var = 1, | 35 | var = 1, | |
36 | /* Syntactically ok, must be a constant expression though. */ | 36 | /* Syntactically ok, must be a constant expression though. */ | |
37 | var > 0 ? 2 : 1))) | 37 | var > 0 ? 2 : 1))) | |
38 | my_printf(const char *, ...); | 38 | my_printf(const char *, ...); | |
39 | 39 | |||
40 | void | 40 | void | |
41 | assignment_associativity(int arg) | 41 | assignment_associativity(int arg) | |
42 | { | 42 | { | |
43 | int left, right; | 43 | int left, right; | |
44 | 44 | |||
45 | /* | 45 | /* | |
46 | * Assignments are right-associative. If they were left-associative, | 46 | * Assignments are right-associative. If they were left-associative, | |
47 | * the result of (left = right) would be an rvalue, resulting in this | 47 | * the result of (left = right) would be an rvalue, resulting in this |
--- src/tests/usr.bin/xlint/lint1/parse_type_name.c 2022/04/01 23:16:32 1.8
+++ src/tests/usr.bin/xlint/lint1/parse_type_name.c 2022/06/17 18:54:53 1.9
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: parse_type_name.c,v 1.8 2022/04/01 23:16:32 rillig Exp $ */ | 1 | /* $NetBSD: parse_type_name.c,v 1.9 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "parse_type_name.c" | 2 | # 3 "parse_type_name.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Test parsing of the grammar rule 'type_name', which among others appears | 5 | * Test parsing of the grammar rule 'type_name', which among others appears | |
6 | * in the expression 'sizeof(type_name)'. | 6 | * in the expression 'sizeof(type_name)'. | |
7 | */ | 7 | */ | |
8 | 8 | |||
9 | void sink(unsigned long); | 9 | void sink(unsigned long); | |
10 | 10 | |||
11 | void | 11 | void | |
12 | cover_type_name(void) | 12 | cover_type_name(void) | |
13 | { | 13 | { | |
14 | /* cover 'abstract_declaration' */ | 14 | /* cover 'abstract_declaration' */ | |
@@ -104,35 +104,35 @@ cover_abstract_decl_param_list(void) | @@ -104,35 +104,35 @@ cover_abstract_decl_param_list(void) | |||
104 | * All following __attribute__ come from direct_abstract_declarator. | 104 | * All following __attribute__ come from direct_abstract_declarator. | |
105 | */ | 105 | */ | |
106 | sink(sizeof(void (*)() __attribute__(()) __attribute__(()))); | 106 | sink(sizeof(void (*)() __attribute__(()) __attribute__(()))); | |
107 | 107 | |||
108 | /* cover 'abstract_decl_lparen vararg_parameter_type_list T_RPAREN type_attribute_opt' */ | 108 | /* cover 'abstract_decl_lparen vararg_parameter_type_list T_RPAREN type_attribute_opt' */ | |
109 | sink(sizeof(void (*)(void) __attribute__(()))); | 109 | sink(sizeof(void (*)(void) __attribute__(()))); | |
110 | /* | 110 | /* | |
111 | * XXX: The grammar allows only a single type_attribute_opt. | 111 | * XXX: The grammar allows only a single type_attribute_opt. | |
112 | * All following __attribute__ come from direct_abstract_declarator. | 112 | * All following __attribute__ come from direct_abstract_declarator. | |
113 | */ | 113 | */ | |
114 | sink(sizeof(void (*)(void) __attribute__(()) __attribute__(()))); | 114 | sink(sizeof(void (*)(void) __attribute__(()) __attribute__(()))); | |
115 | 115 | |||
116 | /* cover 'abstract_decl_lparen error T_RPAREN type_attribute_opt' */ | 116 | /* cover 'abstract_decl_lparen error T_RPAREN type_attribute_opt' */ | |
117 | /* expect+1: syntax error 'goto' [249] */ | 117 | /* expect+1: error: syntax error 'goto' [249] */ | |
118 | sink(sizeof(void (*)(goto))); | 118 | sink(sizeof(void (*)(goto))); | |
119 | /* expect+1: syntax error 'goto' [249] */ | 119 | /* expect+1: error: syntax error 'goto' [249] */ | |
120 | sink(sizeof(void (*)(goto) __attribute__(()))); | 120 | sink(sizeof(void (*)(goto) __attribute__(()))); | |
121 | /* | 121 | /* | |
122 | * XXX: The grammar allows only a single type_attribute_opt. | 122 | * XXX: The grammar allows only a single type_attribute_opt. | |
123 | * All following __attribute__ come from direct_abstract_declarator. | 123 | * All following __attribute__ come from direct_abstract_declarator. | |
124 | */ | 124 | */ | |
125 | /* expect+1: syntax error 'goto' [249] */ | 125 | /* expect+1: error: syntax error 'goto' [249] */ | |
126 | sink(sizeof(void (*)(goto) __attribute__(()) __attribute__(()))); | 126 | sink(sizeof(void (*)(goto) __attribute__(()) __attribute__(()))); | |
127 | } | 127 | } | |
128 | 128 | |||
129 | void | 129 | void | |
130 | cover_vararg_parameter_type_list(void) | 130 | cover_vararg_parameter_type_list(void) | |
131 | { | 131 | { | |
132 | /* cover 'parameter_type_list' */ | 132 | /* cover 'parameter_type_list' */ | |
133 | sink(sizeof(void (*)(double))); | 133 | sink(sizeof(void (*)(double))); | |
134 | 134 | |||
135 | /* cover 'parameter_type_list T_COMMA T_ELLIPSIS' */ | 135 | /* cover 'parameter_type_list T_COMMA T_ELLIPSIS' */ | |
136 | sink(sizeof(void (*)(double, ...))); | 136 | sink(sizeof(void (*)(double, ...))); | |
137 | 137 | |||
138 | /* cover 'T_ELLIPSIS' */ | 138 | /* cover 'T_ELLIPSIS' */ |
--- src/tests/usr.bin/xlint/lint1/feat_stacktrace.c 2022/01/15 14:22:03 1.2
+++ src/tests/usr.bin/xlint/lint1/feat_stacktrace.c 2022/06/17 18:54:53 1.3
@@ -1,32 +1,32 @@ | @@ -1,32 +1,32 @@ | |||
1 | /* $NetBSD: feat_stacktrace.c,v 1.2 2022/01/15 14:22:03 rillig Exp $ */ | 1 | /* $NetBSD: feat_stacktrace.c,v 1.3 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "feat_stacktrace.c" | 2 | # 3 "feat_stacktrace.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * In macros or nested includes, lint prints a stack trace to show exactly | 5 | * In macros or nested includes, lint prints a stack trace to show exactly | |
6 | * where the code comes from. | 6 | * where the code comes from. | |
7 | */ | 7 | */ | |
8 | 8 | |||
9 | # 1 "/usr/include/stdlib.h" 1 3 4 | 9 | # 1 "/usr/include/stdlib.h" 1 3 4 | |
10 | # 38 "/usr/include/stdlib.h" 3 4 | 10 | # 38 "/usr/include/stdlib.h" 3 4 | |
11 | # 39 "/usr/include/stdlib.h" 3 4 | 11 | # 39 "/usr/include/stdlib.h" 3 4 | |
12 | # 1 "/usr/include/sys/types.h" 1 3 4 | 12 | # 1 "/usr/include/sys/types.h" 1 3 4 | |
13 | # 43 "/usr/include/sys/types.h" 3 4 | 13 | # 43 "/usr/include/sys/types.h" 3 4 | |
14 | # 1 "/usr/include/amd64/types.h" 1 3 4 | 14 | # 1 "/usr/include/amd64/types.h" 1 3 4 | |
15 | # 40 "/usr/include/amd64/types.h" 3 4 | 15 | # 40 "/usr/include/amd64/types.h" 3 4 | |
16 | # 1 "/usr/include/sys/featuretest.h" 1 3 4 | 16 | # 1 "/usr/include/sys/featuretest.h" 1 3 4 | |
17 | # 41 "/usr/include/amd64/types.h" 2 3 4 | 17 | # 41 "/usr/include/amd64/types.h" 2 3 4 | |
18 | # 1 "/usr/include/amd64/int_types.h" 1 3 4 | 18 | # 1 "/usr/include/amd64/int_types.h" 1 3 4 | |
19 | 19 | |||
20 | /* | 20 | /* | |
21 | * The next filename is a relative filename since the tests are run without | 21 | * The next filename is a relative filename since the tests are run without | |
22 | * the lint option -F, which would generate the fully qualified filename for | 22 | * the lint option -F, which would generate the fully qualified filename for | |
23 | * the main file as well. | 23 | * the main file as well. | |
24 | */ | 24 | */ | |
25 | # 1 "common_int_types.h" 1 3 4 | 25 | # 1 "common_int_types.h" 1 3 4 | |
26 | /* expect+1: typedef declares no type name [72] */ | 26 | /* expect+1: warning: typedef declares no type name [72] */ | |
27 | typedef int; | 27 | typedef int; | |
28 | # 39 "common_int_types.h" 3 4 | 28 | # 39 "common_int_types.h" 3 4 | |
29 | # 39 "/usr/include/amd64/int_types.h" 2 3 4 | 29 | # 39 "/usr/include/amd64/int_types.h" 2 3 4 | |
30 | # 42 "/usr/include/amd64/types.h" 2 3 4 | 30 | # 42 "/usr/include/amd64/types.h" 2 3 4 | |
31 | # 68 "/usr/include/amd64/types.h" 3 4 | 31 | # 68 "/usr/include/amd64/types.h" 3 4 | |
32 | # 46 "/usr/include/sys/types.h" 2 3 4 | 32 | # 46 "/usr/include/sys/types.h" 2 3 4 |
--- src/tests/usr.bin/xlint/lint1/gcc_attribute_aligned.c 2022/01/15 14:22:03 1.2
+++ src/tests/usr.bin/xlint/lint1/gcc_attribute_aligned.c 2022/06/17 18:54:53 1.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: gcc_attribute_aligned.c,v 1.2 2022/01/15 14:22:03 rillig Exp $ */ | 1 | /* $NetBSD: gcc_attribute_aligned.c,v 1.3 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "gcc_attribute_aligned.c" | 2 | # 3 "gcc_attribute_aligned.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Test size computations on aligned and packed structs. | 5 | * Test size computations on aligned and packed structs. | |
6 | */ | 6 | */ | |
7 | 7 | |||
8 | typedef unsigned short uint16_t; | 8 | typedef unsigned short uint16_t; | |
9 | typedef unsigned int uint32_t; | 9 | typedef unsigned int uint32_t; | |
10 | typedef unsigned long long uint64_t; | 10 | typedef unsigned long long uint64_t; | |
11 | 11 | |||
12 | /* from sys/arch/x86/include/cpu_extended_state.h */ | 12 | /* from sys/arch/x86/include/cpu_extended_state.h */ | |
13 | 13 | |||
14 | union fp_addr { | 14 | union fp_addr { | |
@@ -30,16 +30,16 @@ struct save87 { | @@ -30,16 +30,16 @@ struct save87 { | |||
30 | uint16_t s87_sw __attribute__((aligned(4))); | 30 | uint16_t s87_sw __attribute__((aligned(4))); | |
31 | uint16_t s87_tw __attribute__((aligned(4))); | 31 | uint16_t s87_tw __attribute__((aligned(4))); | |
32 | union fp_addr s87_ip; | 32 | union fp_addr s87_ip; | |
33 | union fp_addr s87_dp; | 33 | union fp_addr s87_dp; | |
34 | struct fpacc87 s87_ac[8]; | 34 | struct fpacc87 s87_ac[8]; | |
35 | }; | 35 | }; | |
36 | 36 | |||
37 | struct { | 37 | struct { | |
38 | unsigned int sizeof_fp_addr: sizeof(union fp_addr) == 8 ? 1 : -1; | 38 | unsigned int sizeof_fp_addr: sizeof(union fp_addr) == 8 ? 1 : -1; | |
39 | 39 | |||
40 | unsigned int sizeof_fpacc87: sizeof(struct fpacc87) == 10 ? 1 : -1; | 40 | unsigned int sizeof_fpacc87: sizeof(struct fpacc87) == 10 ? 1 : -1; | |
41 | 41 | |||
42 | /* FIXME: @4 2 + @4 2 + @4 2 + @4 8 + @4 8 + @2 (8 * 10) == 108 */ | 42 | /* FIXME: @4 2 + @4 2 + @4 2 + @4 8 + @4 8 + @2 (8 * 10) == 108 */ | |
43 | /* expect+1: illegal bit-field size: 255 */ | 43 | /* expect+1: error: illegal bit-field size: 255 [36] */ | |
44 | unsigned int sizeof_save87: sizeof(struct save87) == 108 ? 1 : -1; | 44 | unsigned int sizeof_save87: sizeof(struct save87) == 108 ? 1 : -1; | |
45 | }; | 45 | }; |
--- src/tests/usr.bin/xlint/lint1/gcc_typeof_after_statement.c 2021/05/03 05:24:44 1.2
+++ src/tests/usr.bin/xlint/lint1/gcc_typeof_after_statement.c 2022/06/17 18:54:53 1.3
@@ -1,22 +1,22 @@ | @@ -1,22 +1,22 @@ | |||
1 | /* $NetBSD: gcc_typeof_after_statement.c,v 1.2 2021/05/03 05:24:44 rillig Exp $ */ | 1 | /* $NetBSD: gcc_typeof_after_statement.c,v 1.3 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "gcc_typeof_after_statement.c" | 2 | # 3 "gcc_typeof_after_statement.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Before cgram.y 1.226 from 2021-05-03, lint could not parse typeof(...) if | 5 | * Before cgram.y 1.226 from 2021-05-03, lint could not parse typeof(...) if | |
6 | * there was a statement before it. | 6 | * there was a statement before it. | |
7 | */ | 7 | */ | |
8 | 8 | |||
9 | void * | 9 | void * | |
10 | example(void **ptr) | 10 | example(void **ptr) | |
11 | { | 11 | { | |
12 | return ({ | 12 | return ({ | |
13 | if (*ptr != (void *)0) | 13 | if (*ptr != (void *)0) | |
14 | ptr++; | 14 | ptr++; | |
15 | __typeof__(*ptr) ret = *ptr; | 15 | __typeof__(*ptr) ret = *ptr; | |
16 | ret; | 16 | ret; | |
17 | }); | 17 | }); | |
18 | } | 18 | } | |
19 | 19 | |||
20 | /* Just to keep the .exp file. */ | 20 | /* Just to keep the .exp file. */ | |
21 | /* expect+1: static function unused declared but not defined */ | 21 | /* expect+1: warning: static function unused declared but not defined [290] */ | |
22 | static void unused(void); | 22 | static void unused(void); |
--- src/tests/usr.bin/xlint/lint1/lex_wide_char.c 2021/06/20 18:38:12 1.2
+++ src/tests/usr.bin/xlint/lint1/lex_wide_char.c 2022/06/17 18:54:53 1.3
@@ -1,41 +1,41 @@ | @@ -1,41 +1,41 @@ | |||
1 | /* $NetBSD: lex_wide_char.c,v 1.2 2021/06/20 18:38:12 rillig Exp $ */ | 1 | /* $NetBSD: lex_wide_char.c,v 1.3 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "lex_wide_char.c" | 2 | # 3 "lex_wide_char.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Tests for lexical analysis of character constants. | 5 | * Tests for lexical analysis of character constants. | |
6 | * | 6 | * | |
7 | * C99 6.4.4.4 "Character constants" | 7 | * C99 6.4.4.4 "Character constants" | |
8 | */ | 8 | */ | |
9 | 9 | |||
10 | void sink(int); | 10 | void sink(int); | |
11 | 11 | |||
12 | void | 12 | void | |
13 | test(void) | 13 | test(void) | |
14 | { | 14 | { | |
15 | /* expect+1: empty character constant */ | 15 | /* expect+1: error: empty character constant [73] */ | |
16 | sink(L''); | 16 | sink(L''); | |
17 | 17 | |||
18 | sink(L'a'); | 18 | sink(L'a'); | |
19 | 19 | |||
20 | sink(L'\0'); | 20 | sink(L'\0'); | |
21 | 21 | |||
22 | /* UTF-8 */ | 22 | /* UTF-8 */ | |
23 | /* expect+1: too many characters in character constant */ | 23 | /* expect+1: error: too many characters in character constant [71] */ | |
24 | sink(L'ä'); | 24 | sink(L'ä'); | |
25 | 25 | |||
26 | /* GCC extension */ | 26 | /* GCC extension */ | |
27 | /* expect+1: dubious escape \e */ | 27 | /* expect+1: warning: dubious escape \e [79] */ | |
28 | sink(L'\e'); | 28 | sink(L'\e'); | |
29 | 29 | |||
30 | /* since C99 */ | 30 | /* since C99 */ | |
31 | sink(L'\x12'); | 31 | sink(L'\x12'); | |
32 | 32 | |||
33 | /* octal */ | 33 | /* octal */ | |
34 | sink(L'\177'); | 34 | sink(L'\177'); | |
35 | 35 | |||
36 | /* newline */ | 36 | /* newline */ | |
37 | sink(L'\n'); | 37 | sink(L'\n'); | |
38 | 38 | |||
39 | /* expect+1: empty character constant */ | 39 | /* expect+1: error: empty character constant [73] */ | |
40 | sink(L''); | 40 | sink(L''); | |
41 | } | 41 | } |
--- src/tests/usr.bin/xlint/lint1/lex_wide_string.c 2021/08/23 17:47:34 1.2
+++ src/tests/usr.bin/xlint/lint1/lex_wide_string.c 2022/06/17 18:54:53 1.3
@@ -1,33 +1,33 @@ | @@ -1,33 +1,33 @@ | |||
1 | /* $NetBSD: lex_wide_string.c,v 1.2 2021/08/23 17:47:34 rillig Exp $ */ | 1 | /* $NetBSD: lex_wide_string.c,v 1.3 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "lex_wide_string.c" | 2 | # 3 "lex_wide_string.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Test lexical analysis of wide string constants. | 5 | * Test lexical analysis of wide string constants. | |
6 | * | 6 | * | |
7 | * C99 6.4.5 "String literals" | 7 | * C99 6.4.5 "String literals" | |
8 | */ | 8 | */ | |
9 | 9 | |||
10 | void sink(const int *); | 10 | void sink(const int *); | |
11 | 11 | |||
12 | void | 12 | void | |
13 | test(void) | 13 | test(void) | |
14 | { | 14 | { | |
15 | sink(L""); | 15 | sink(L""); | |
16 | 16 | |||
17 | sink(L"hello, world\n"); | 17 | sink(L"hello, world\n"); | |
18 | 18 | |||
19 | sink(L"\0"); | 19 | sink(L"\0"); | |
20 | 20 | |||
21 | sink(L"\0\0\0\0"); | 21 | sink(L"\0\0\0\0"); | |
22 | 22 | |||
23 | /* expect+1: no hex digits follow \x [74] */ | 23 | /* expect+1: error: no hex digits follow \x [74] */ | |
24 | sink(L"\x"); | 24 | sink(L"\x"); | |
25 | 25 | |||
26 | /* expect+1: dubious escape \y [79] */ | 26 | /* expect+1: warning: dubious escape \y [79] */ | |
27 | sink(L"\y"); | 27 | sink(L"\y"); | |
28 | 28 | |||
29 | sink(L"first" L"second"); | 29 | sink(L"first" L"second"); | |
30 | 30 | |||
31 | /* expect+1: error: cannot concatenate wide and regular string literals [292] */ | 31 | /* expect+1: error: cannot concatenate wide and regular string literals [292] */ | |
32 | sink(L"wide" "plain"); | 32 | sink(L"wide" "plain"); | |
33 | } | 33 | } |
--- src/tests/usr.bin/xlint/lint1/msg_345.c 2021/06/27 20:47:13 1.2
+++ src/tests/usr.bin/xlint/lint1/msg_345.c 2022/06/17 18:54:53 1.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: msg_345.c,v 1.2 2021/06/27 20:47:13 rillig Exp $ */ | 1 | /* $NetBSD: msg_345.c,v 1.3 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_345.c" | 2 | # 3 "msg_345.c" | |
3 | 3 | |||
4 | // Test for message: generic selection requires C11 or later [345] | 4 | // Test for message: generic selection requires C11 or later [345] | |
5 | 5 | |||
6 | /* Omit flag -g since it silences c11ism. */ | 6 | /* Omit flag -g since it silences c11ism. */ | |
7 | /* lint1-flags: -Sw */ | 7 | /* lint1-flags: -Sw */ | |
8 | 8 | |||
9 | int | 9 | int | |
10 | test(int x) | 10 | test(int x) | |
11 | { | 11 | { | |
12 | /* expect+1: generic selection requires C11 or later [345] */ | 12 | /* expect+1: error: generic selection requires C11 or later [345] */ | |
13 | return _Generic(x, default: 3) + x; | 13 | return _Generic(x, default: 3) + x; | |
14 | } | 14 | } |
--- src/tests/usr.bin/xlint/lint1/op_colon.c 2022/01/15 14:22:03 1.2
+++ src/tests/usr.bin/xlint/lint1/op_colon.c 2022/06/17 18:54:53 1.3
@@ -1,50 +1,50 @@ | @@ -1,50 +1,50 @@ | |||
1 | /* $NetBSD: op_colon.c,v 1.2 2022/01/15 14:22:03 rillig Exp $ */ | 1 | /* $NetBSD: op_colon.c,v 1.3 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "op_colon.c" | 2 | # 3 "op_colon.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Test handling of the operator ':', as part of the '?:'. | 5 | * Test handling of the operator ':', as part of the '?:'. | |
6 | */ | 6 | */ | |
7 | 7 | |||
8 | /* lint1-extra-flags: -p */ | 8 | /* lint1-extra-flags: -p */ | |
9 | 9 | |||
10 | void sink(void *); | 10 | void sink(void *); | |
11 | 11 | |||
12 | void | 12 | void | |
13 | test_merge_qualifiers(_Bool cond, int *p, const int *c, volatile int *v, | 13 | test_merge_qualifiers(_Bool cond, int *p, const int *c, volatile int *v, | |
14 | const volatile int *cv) | 14 | const volatile int *cv) | |
15 | { | 15 | { | |
16 | sink(cond ? p : p); | 16 | sink(cond ? p : p); | |
17 | /* expect+1: 'pointer to const int' */ | 17 | /* expect+1: ... 'pointer to const int' ... */ | |
18 | sink(cond ? p : c); | 18 | sink(cond ? p : c); | |
19 | /* expect+1: 'pointer to volatile int' */ | 19 | /* expect+1: ... 'pointer to volatile int' ... */ | |
20 | sink(cond ? p : v); | 20 | sink(cond ? p : v); | |
21 | /* expect+1: 'pointer to const volatile int' */ | 21 | /* expect+1: ... 'pointer to const volatile int' ... */ | |
22 | sink(cond ? p : cv); | 22 | sink(cond ? p : cv); | |
23 | 23 | |||
24 | /* expect+1: 'pointer to const int' */ | 24 | /* expect+1: ... 'pointer to const int' ... */ | |
25 | sink(cond ? c : p); | 25 | sink(cond ? c : p); | |
26 | /* expect+1: 'pointer to const int' */ | 26 | /* expect+1: ... 'pointer to const int' ... */ | |
27 | sink(cond ? c : c); | 27 | sink(cond ? c : c); | |
28 | /* expect+1: 'pointer to const volatile int' */ | 28 | /* expect+1: ... 'pointer to const volatile int' ... */ | |
29 | sink(cond ? c : v); | 29 | sink(cond ? c : v); | |
30 | /* expect+1: 'pointer to const volatile int' */ | 30 | /* expect+1: ... 'pointer to const volatile int' ... */ | |
31 | sink(cond ? c : cv); | 31 | sink(cond ? c : cv); | |
32 | 32 | |||
33 | /* expect+1: 'pointer to volatile int' */ | 33 | /* expect+1: ... 'pointer to volatile int' ... */ | |
34 | sink(cond ? v : p); | 34 | sink(cond ? v : p); | |
35 | /* expect+1: 'pointer to const volatile int' */ | 35 | /* expect+1: ... 'pointer to const volatile int' ... */ | |
36 | sink(cond ? v : c); | 36 | sink(cond ? v : c); | |
37 | /* expect+1: 'pointer to volatile int' */ | 37 | /* expect+1: ... 'pointer to volatile int' ... */ | |
38 | sink(cond ? v : v); | 38 | sink(cond ? v : v); | |
39 | /* expect+1: 'pointer to const volatile int' */ | 39 | /* expect+1: ... 'pointer to const volatile int' ... */ | |
40 | sink(cond ? v : cv); | 40 | sink(cond ? v : cv); | |
41 | 41 | |||
42 | /* expect+1: 'pointer to const volatile int' */ | 42 | /* expect+1: ... 'pointer to const volatile int' ... */ | |
43 | sink(cond ? cv : p); | 43 | sink(cond ? cv : p); | |
44 | /* expect+1: 'pointer to const volatile int' */ | 44 | /* expect+1: ... 'pointer to const volatile int' ... */ | |
45 | sink(cond ? cv : c); | 45 | sink(cond ? cv : c); | |
46 | /* expect+1: 'pointer to const volatile int' */ | 46 | /* expect+1: ... 'pointer to const volatile int' ... */ | |
47 | sink(cond ? cv : v); | 47 | sink(cond ? cv : v); | |
48 | /* expect+1: 'pointer to const volatile int' */ | 48 | /* expect+1: ... 'pointer to const volatile int' ... */ | |
49 | sink(cond ? cv : cv); | 49 | sink(cond ? cv : cv); | |
50 | } | 50 | } |
--- src/tests/usr.bin/xlint/lint1/stmt_for.c 2022/01/15 14:22:03 1.2
+++ src/tests/usr.bin/xlint/lint1/stmt_for.c 2022/06/17 18:54:53 1.3
@@ -1,17 +1,17 @@ | @@ -1,17 +1,17 @@ | |||
1 | /* $NetBSD: stmt_for.c,v 1.2 2022/01/15 14:22:03 rillig Exp $ */ | 1 | /* $NetBSD: stmt_for.c,v 1.3 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "stmt_for.c" | 2 | # 3 "stmt_for.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Before func.c 1.111 from 2021-06-19, lint ran into an assertion failure: | 5 | * Before func.c 1.111 from 2021-06-19, lint ran into an assertion failure: | |
6 | * | 6 | * | |
7 | * "dcs->d_next == NULL" failed in funcend at func.c:422 | 7 | * "dcs->d_next == NULL" failed in funcend at func.c:422 | |
8 | */ | 8 | */ | |
9 | 9 | |||
10 | void | 10 | void | |
11 | test(void) | 11 | test(void) | |
12 | { | 12 | { | |
13 | /* expect+1: error: syntax error '0' [249] */ | 13 | /* expect+1: error: syntax error '0' [249] */ | |
14 | for (0 0; | 14 | for (0 0; | |
15 | } | 15 | } | |
16 | 16 | |||
17 | /* expect+1: cannot recover from previous errors */ | 17 | /* expect+1: error: cannot recover from previous errors [224] */ |
--- src/tests/usr.bin/xlint/lint1/gcc_attribute_enum.c 2021/07/25 18:48:47 1.4
+++ src/tests/usr.bin/xlint/lint1/gcc_attribute_enum.c 2022/06/17 18:54:53 1.5
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: gcc_attribute_enum.c,v 1.4 2021/07/25 18:48:47 rillig Exp $ */ | 1 | /* $NetBSD: gcc_attribute_enum.c,v 1.5 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "gcc_attribute_enum.c" | 2 | # 3 "gcc_attribute_enum.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Tests for the GCC __attribute__ for enumerators. | 5 | * Tests for the GCC __attribute__ for enumerators. | |
6 | * | 6 | * | |
7 | * https://gcc.gnu.org/onlinedocs/gcc/Enumerator-Attributes.html | 7 | * https://gcc.gnu.org/onlinedocs/gcc/Enumerator-Attributes.html | |
8 | */ | 8 | */ | |
9 | 9 | |||
10 | /* | 10 | /* | |
11 | * Attributes in enum-specifier. | 11 | * Attributes in enum-specifier. | |
12 | * | 12 | * | |
13 | * See GCC, c-parser.c, function c_parser_enum_specifier. | 13 | * See GCC, c-parser.c, function c_parser_enum_specifier. | |
14 | */ | 14 | */ | |
@@ -27,20 +27,20 @@ enum __attribute__(()) { | @@ -27,20 +27,20 @@ enum __attribute__(()) { | |||
27 | * Attributes in enumerator. | 27 | * Attributes in enumerator. | |
28 | * | 28 | * | |
29 | * See GCC, c-parser.c, function c_parser_enum_specifier. | 29 | * See GCC, c-parser.c, function c_parser_enum_specifier. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | enum without_initializer { | 32 | enum without_initializer { | |
33 | NO_INIT_FIRST __attribute__(()), | 33 | NO_INIT_FIRST __attribute__(()), | |
34 | NO_INIT_LAST __attribute__(()) | 34 | NO_INIT_LAST __attribute__(()) | |
35 | }; | 35 | }; | |
36 | 36 | |||
37 | enum with_initializer { | 37 | enum with_initializer { | |
38 | INIT_FIRST __attribute__(()) = 1, | 38 | INIT_FIRST __attribute__(()) = 1, | |
39 | INIT_LAST __attribute__(()) = 2, | 39 | INIT_LAST __attribute__(()) = 2, | |
40 | /* expect+1: syntax error '__attribute__' [249] */ | 40 | /* expect+1: error: syntax error '__attribute__' [249] */ | |
41 | INIT_WRONG = 3 __attribute__(()), | 41 | INIT_WRONG = 3 __attribute__(()), | |
42 | }; | 42 | }; | |
43 | 43 | |||
44 | enum tag { | 44 | enum tag { | |
45 | TAG | 45 | TAG | |
46 | }; | 46 | }; |
--- src/tests/usr.bin/xlint/lint1/lex_string.c 2021/11/20 17:27:46 1.4
+++ src/tests/usr.bin/xlint/lint1/lex_string.c 2022/06/17 18:54:53 1.5
@@ -1,36 +1,36 @@ | @@ -1,36 +1,36 @@ | |||
1 | /* $NetBSD: lex_string.c,v 1.4 2021/11/20 17:27:46 rillig Exp $ */ | 1 | /* $NetBSD: lex_string.c,v 1.5 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "lex_string.c" | 2 | # 3 "lex_string.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Test lexical analysis of string constants. | 5 | * Test lexical analysis of string constants. | |
6 | * | 6 | * | |
7 | * C99 6.4.5 "String literals" | 7 | * C99 6.4.5 "String literals" | |
8 | */ | 8 | */ | |
9 | 9 | |||
10 | void sink(const char *); | 10 | void sink(const char *); | |
11 | 11 | |||
12 | void | 12 | void | |
13 | test(void) | 13 | test(void) | |
14 | { | 14 | { | |
15 | sink(""); | 15 | sink(""); | |
16 | 16 | |||
17 | sink("hello, world\n"); | 17 | sink("hello, world\n"); | |
18 | 18 | |||
19 | sink("\0"); | 19 | sink("\0"); | |
20 | 20 | |||
21 | sink("\0\0\0\0"); | 21 | sink("\0\0\0\0"); | |
22 | 22 | |||
23 | /* expect+1: no hex digits follow \x [74] */ | 23 | /* expect+1: error: no hex digits follow \x [74] */ | |
24 | sink("\x"); /* unfinished */ | 24 | sink("\x"); /* unfinished */ | |
25 | 25 | |||
26 | /* expect+1: dubious escape \y [79] */ | 26 | /* expect+1: warning: dubious escape \y [79] */ | |
27 | sink("\y"); /* unknown escape sequence */ | 27 | sink("\y"); /* unknown escape sequence */ | |
28 | 28 | |||
29 | sink("first" "second"); | 29 | sink("first" "second"); | |
30 | 30 | |||
31 | /* expect+1: error: cannot concatenate wide and regular string literals [292] */ | 31 | /* expect+1: error: cannot concatenate wide and regular string literals [292] */ | |
32 | sink("plain" L"wide"); | 32 | sink("plain" L"wide"); | |
33 | } | 33 | } | |
34 | 34 | |||
35 | /* TODO: test digraphs inside string literals */ | 35 | /* TODO: test digraphs inside string literals */ | |
36 | /* TODO: test trigraphs inside string literals */ | 36 | /* TODO: test trigraphs inside string literals */ |
--- src/tests/usr.bin/xlint/lint1/msg_005.c 2021/09/04 13:45:37 1.4
+++ src/tests/usr.bin/xlint/lint1/msg_005.c 2022/06/17 18:54:53 1.5
@@ -1,29 +1,29 @@ | @@ -1,29 +1,29 @@ | |||
1 | /* $NetBSD: msg_005.c,v 1.4 2021/09/04 13:45:37 rillig Exp $ */ | 1 | /* $NetBSD: msg_005.c,v 1.5 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_005.c" | 2 | # 3 "msg_005.c" | |
3 | 3 | |||
4 | // Test for message: modifying typedef with '%s'; only qualifiers allowed [5] | 4 | // Test for message: modifying typedef with '%s'; only qualifiers allowed [5] | |
5 | 5 | |||
6 | typedef int number; | 6 | typedef int number; | |
7 | 7 | |||
8 | /* expect+1: warning: modifying typedef with 'signed'; only qualifiers allowed [5] */ | 8 | /* expect+1: warning: modifying typedef with 'signed'; only qualifiers allowed [5] */ | |
9 | typedef number signed signed_number; | 9 | typedef number signed signed_number; | |
10 | 10 | |||
11 | /* expect+1: warning: modifying typedef with 'unsigned'; only qualifiers allowed [5] */ | 11 | /* expect+1: warning: modifying typedef with 'unsigned'; only qualifiers allowed [5] */ | |
12 | typedef number unsigned unsigned_number; | 12 | typedef number unsigned unsigned_number; | |
13 | 13 | |||
14 | /* expect+1: warning: modifying typedef with 'short'; only qualifiers allowed [5] */ | 14 | /* expect+1: warning: modifying typedef with 'short'; only qualifiers allowed [5] */ | |
15 | typedef number short short_number; | 15 | typedef number short short_number; | |
16 | 16 | |||
17 | /* expect+1: modifying typedef with 'long'; only qualifiers allowed [5] */ | 17 | /* expect+1: warning: modifying typedef with 'long'; only qualifiers allowed [5] */ | |
18 | typedef number long long_number; | 18 | typedef number long long_number; | |
19 | 19 | |||
20 | /* | 20 | /* | |
21 | * If the type qualifier comes first, the following name is interpreted as a | 21 | * If the type qualifier comes first, the following name is interpreted as a | |
22 | * new name, not as the one referring to the typedef. This makes the above | 22 | * new name, not as the one referring to the typedef. This makes the above | |
23 | * type modifications even more obscure. | 23 | * type modifications even more obscure. | |
24 | */ | 24 | */ | |
25 | /* expect+1: error: syntax error 'prefix_long_number' [249] */ | 25 | /* expect+1: error: syntax error 'prefix_long_number' [249] */ | |
26 | typedef long number prefix_long_number; | 26 | typedef long number prefix_long_number; | |
27 | 27 | |||
28 | /* Type qualifiers are OK. */ | 28 | /* Type qualifiers are OK. */ | |
29 | typedef number const const_number; | 29 | typedef number const const_number; |
--- src/tests/usr.bin/xlint/lint1/msg_041.c 2022/02/07 02:44:49 1.4
+++ src/tests/usr.bin/xlint/lint1/msg_041.c 2022/06/17 18:54:53 1.5
@@ -1,10 +1,10 @@ | @@ -1,10 +1,10 @@ | |||
1 | /* $NetBSD: msg_041.c,v 1.4 2022/02/07 02:44:49 rillig Exp $ */ | 1 | /* $NetBSD: msg_041.c,v 1.5 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_041.c" | 2 | # 3 "msg_041.c" | |
3 | 3 | |||
4 | // Test for message: bit-field in union is very unusual [41] | 4 | // Test for message: bit-field in union is very unusual [41] | |
5 | 5 | |||
6 | union u { | 6 | union u { | |
7 | int member; | 7 | int member; | |
8 | /* expect+1: bit-field in union is very unusual [41] */ | 8 | /* expect+1: warning: bit-field in union is very unusual [41] */ | |
9 | unsigned bit_field : 7; | 9 | unsigned bit_field : 7; | |
10 | }; | 10 | }; |
--- src/tests/usr.bin/xlint/lint1/msg_048.c 2022/04/08 21:48:19 1.4
+++ src/tests/usr.bin/xlint/lint1/msg_048.c 2022/06/17 18:54:53 1.5
@@ -1,22 +1,22 @@ | @@ -1,22 +1,22 @@ | |||
1 | /* $NetBSD: msg_048.c,v 1.4 2022/04/08 21:48:19 rillig Exp $ */ | 1 | /* $NetBSD: msg_048.c,v 1.5 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_048.c" | 2 | # 3 "msg_048.c" | |
3 | 3 | |||
4 | // Test for message: overflow in enumeration values: %s [48] | 4 | // Test for message: overflow in enumeration values: %s [48] | |
5 | 5 | |||
6 | /* | 6 | /* | |
7 | * Before decl.c 1.269 from 2022-04-08, the comparison for enum constant | 7 | * Before decl.c 1.269 from 2022-04-08, the comparison for enum constant | |
8 | * overflow was done in signed arithmetic, and since 'enumval' wrapped | 8 | * overflow was done in signed arithmetic, and since 'enumval' wrapped | |
9 | * around, its value became INT_MIN, at least on platforms where integer | 9 | * around, its value became INT_MIN, at least on platforms where integer | |
10 | * overflow was defined as 2-complements wrap-around. When comparing | 10 | * overflow was defined as 2-complements wrap-around. When comparing | |
11 | * 'enumval - 1 == TARG_INT_MAX', there was another integer overflow, and | 11 | * 'enumval - 1 == TARG_INT_MAX', there was another integer overflow, and | |
12 | * this one was optimized away by GCC, taking advantage of the undefined | 12 | * this one was optimized away by GCC, taking advantage of the undefined | |
13 | * behavior. | 13 | * behavior. | |
14 | */ | 14 | */ | |
15 | enum int_limits { | 15 | enum int_limits { | |
16 | MAX_MINUS_2 = 0x7ffffffd, | 16 | MAX_MINUS_2 = 0x7ffffffd, | |
17 | MAX_MINUS_1, | 17 | MAX_MINUS_1, | |
18 | MAX, | 18 | MAX, | |
19 | /* expect+1: overflow in enumeration values: MIN [48] */ | 19 | /* expect+1: warning: overflow in enumeration values: MIN [48] */ | |
20 | MIN, | 20 | MIN, | |
21 | MIN_PLUS_1 | 21 | MIN_PLUS_1 | |
22 | }; | 22 | }; |
--- src/tests/usr.bin/xlint/lint1/msg_080.c 2021/07/04 13:44:43 1.4
+++ src/tests/usr.bin/xlint/lint1/msg_080.c 2022/06/17 18:54:53 1.5
@@ -1,7 +1,7 @@ | @@ -1,7 +1,7 @@ | |||
1 | /* $NetBSD: msg_080.c,v 1.4 2021/07/04 13:44:43 rillig Exp $ */ | 1 | /* $NetBSD: msg_080.c,v 1.5 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_080.c" | 2 | # 3 "msg_080.c" | |
3 | 3 | |||
4 | // Test for message: dubious escape \%o [80] | 4 | // Test for message: dubious escape \%o [80] | |
5 | 5 | |||
6 | /* expect+1: dubious escape \177 [80] */ | 6 | /* expect+1: warning: dubious escape \177 [80] */ | |
7 | char backslash_delete = '\'; | 7 | char backslash_delete = '\'; |
--- src/tests/usr.bin/xlint/lint1/msg_184.c 2021/08/14 13:00:55 1.4
+++ src/tests/usr.bin/xlint/lint1/msg_184.c 2022/06/17 18:54:53 1.5
@@ -1,11 +1,11 @@ | @@ -1,11 +1,11 @@ | |||
1 | /* $NetBSD: msg_184.c,v 1.4 2021/08/14 13:00:55 rillig Exp $ */ | 1 | /* $NetBSD: msg_184.c,v 1.5 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_184.c" | 2 | # 3 "msg_184.c" | |
3 | 3 | |||
4 | // Test for message: illegal combination of '%s' and '%s' [184] | 4 | // Test for message: illegal combination of '%s' and '%s' [184] | |
5 | 5 | |||
6 | int * | 6 | int * | |
7 | example(char *cp) | 7 | example(char *cp) | |
8 | { | 8 | { | |
9 | /* expect+1: illegal combination of 'pointer to int' and 'pointer to char' [184] */ | 9 | /* expect+1: warning: illegal combination of 'pointer to int' and 'pointer to char' [184] */ | |
10 | return cp; | 10 | return cp; | |
11 | } | 11 | } |
--- src/tests/usr.bin/xlint/lint1/msg_250.c 2022/04/24 20:08:23 1.4
+++ src/tests/usr.bin/xlint/lint1/msg_250.c 2022/06/17 18:54:53 1.5
@@ -1,10 +1,10 @@ | @@ -1,10 +1,10 @@ | |||
1 | /* $NetBSD: msg_250.c,v 1.4 2022/04/24 20:08:23 rillig Exp $ */ | 1 | /* $NetBSD: msg_250.c,v 1.5 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_250.c" | 2 | # 3 "msg_250.c" | |
3 | 3 | |||
4 | // Test for message: unknown character \%o [250] | 4 | // Test for message: unknown character \%o [250] | |
5 | 5 | |||
6 | /* expect+1: unknown character \100 [250] */ | 6 | /* expect+1: error: unknown character \100 [250] */ | |
7 | @deprecated | 7 | @deprecated | |
8 | /* expect+2: error: old style declaration; add 'int' [1] */ | 8 | /* expect+2: error: old style declaration; add 'int' [1] */ | |
9 | /* expect+1: syntax error 'char' [249] */ | 9 | /* expect+1: error: syntax error 'char' [249] */ | |
10 | char *gets(void); | 10 | char *gets(void); |
--- src/tests/usr.bin/xlint/lint1/msg_265.c 2021/12/22 14:25:35 1.4
+++ src/tests/usr.bin/xlint/lint1/msg_265.c 2022/06/17 18:54:53 1.5
@@ -1,16 +1,16 @@ | @@ -1,16 +1,16 @@ | |||
1 | /* $NetBSD: msg_265.c,v 1.4 2021/12/22 14:25:35 rillig Exp $ */ | 1 | /* $NetBSD: msg_265.c,v 1.5 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_265.c" | 2 | # 3 "msg_265.c" | |
3 | 3 | |||
4 | /* Test for message: %s does not support 'long long' [265] */ | 4 | /* Test for message: %s does not support 'long long' [265] */ | |
5 | 5 | |||
6 | /* lint1-flags: -w */ | 6 | /* lint1-flags: -w */ | |
7 | 7 | |||
8 | /* expect+1: C90 does not support 'long long' [265] */ | 8 | /* expect+1: warning: C90 does not support 'long long' [265] */ | |
9 | long long unsupported_variable; | 9 | long long unsupported_variable; | |
10 | 10 | |||
11 | /*LONGLONG*/ | 11 | /*LONGLONG*/ | |
12 | long long suppressed_variable, | 12 | long long suppressed_variable, | |
13 | second_suppressed_variable; | 13 | second_suppressed_variable; | |
14 | 14 | |||
15 | /* expect+1: C90 does not support 'long long' [265] */ | 15 | /* expect+1: warning: C90 does not support 'long long' [265] */ | |
16 | long long another_unsupported_variable; | 16 | long long another_unsupported_variable; |
--- src/tests/usr.bin/xlint/lint1/msg_333.c 2021/07/04 07:09:39 1.4
+++ src/tests/usr.bin/xlint/lint1/msg_333.c 2022/06/17 18:54:53 1.5
@@ -1,39 +1,39 @@ | @@ -1,39 +1,39 @@ | |||
1 | /* $NetBSD: msg_333.c,v 1.4 2021/07/04 07:09:39 rillig Exp $ */ | 1 | /* $NetBSD: msg_333.c,v 1.5 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_333.c" | 2 | # 3 "msg_333.c" | |
3 | 3 | |||
4 | // Test for message: controlling expression must be bool, not '%s' [333] | 4 | // Test for message: controlling expression must be bool, not '%s' [333] | |
5 | // | 5 | // | |
6 | // See d_c99_bool_strict.c for many more examples. | 6 | // See d_c99_bool_strict.c for many more examples. | |
7 | 7 | |||
8 | /* lint1-extra-flags: -T */ | 8 | /* lint1-extra-flags: -T */ | |
9 | 9 | |||
10 | typedef _Bool bool; | 10 | typedef _Bool bool; | |
11 | 11 | |||
12 | const char * | 12 | const char * | |
13 | example(bool b, int i, const char *p) | 13 | example(bool b, int i, const char *p) | |
14 | { | 14 | { | |
15 | 15 | |||
16 | if (b) | 16 | if (b) | |
17 | return "bool"; | 17 | return "bool"; | |
18 | 18 | |||
19 | /* expect+1: must be bool, not 'int' [333] */ | 19 | /* expect+1: error: controlling expression must be bool, not 'int' [333] */ | |
20 | if (i) | 20 | if (i) | |
21 | return "int"; | 21 | return "int"; | |
22 | 22 | |||
23 | /* expect+1: must be bool, not 'pointer' [333] */ | 23 | /* expect+1: error: controlling expression must be bool, not 'pointer' [333] */ | |
24 | if (p) | 24 | if (p) | |
25 | return "pointer"; | 25 | return "pointer"; | |
26 | 26 | |||
27 | if (__lint_false) { | 27 | if (__lint_false) { | |
28 | /* expect+1: warning: statement not reached [193] */ | 28 | /* expect+1: warning: statement not reached [193] */ | |
29 | return "bool constant"; | 29 | return "bool constant"; | |
30 | } | 30 | } | |
31 | 31 | |||
32 | /* expect+1: controlling expression must be bool, not 'int' [333] */ | 32 | /* expect+1: error: controlling expression must be bool, not 'int' [333] */ | |
33 | if (0) { | 33 | if (0) { | |
34 | /* expect+1: warning: statement not reached [193] */ | 34 | /* expect+1: warning: statement not reached [193] */ | |
35 | return "integer constant"; | 35 | return "integer constant"; | |
36 | } | 36 | } | |
37 | 37 | |||
38 | return p + i; | 38 | return p + i; | |
39 | } | 39 | } |
--- src/tests/usr.bin/xlint/lint1/gcc_stmt_asm.c 2021/07/21 21:04:00 1.3
+++ src/tests/usr.bin/xlint/lint1/gcc_stmt_asm.c 2022/06/17 18:54:53 1.4
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: gcc_stmt_asm.c,v 1.3 2021/07/21 21:04:00 rillig Exp $ */ | 1 | /* $NetBSD: gcc_stmt_asm.c,v 1.4 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "gcc_stmt_asm.c" | 2 | # 3 "gcc_stmt_asm.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Tests for the GCC 'asm' statement. | 5 | * Tests for the GCC 'asm' statement. | |
6 | */ | 6 | */ | |
7 | 7 | |||
8 | void | 8 | void | |
9 | function(void) | 9 | function(void) | |
10 | { | 10 | { | |
11 | /* | 11 | /* | |
12 | * lint is not really interested in assembly language, therefore it | 12 | * lint is not really interested in assembly language, therefore it | |
13 | * just skips everything until and including the closing parenthesis. | 13 | * just skips everything until and including the closing parenthesis. | |
14 | */ | 14 | */ | |
@@ -23,20 +23,20 @@ function(void) | @@ -23,20 +23,20 @@ function(void) | |||
23 | 23 | |||
24 | __asm__(); | 24 | __asm__(); | |
25 | } | 25 | } | |
26 | 26 | |||
27 | /* | 27 | /* | |
28 | * Even on the top level, 'asm' is allowed. It is interpreted as a | 28 | * Even on the top level, 'asm' is allowed. It is interpreted as a | |
29 | * declaration. | 29 | * declaration. | |
30 | */ | 30 | */ | |
31 | __asm__(); | 31 | __asm__(); | |
32 | 32 | |||
33 | void | 33 | void | |
34 | syntax_error(void) | 34 | syntax_error(void) | |
35 | { | 35 | { | |
36 | /* expect+1: syntax error '__asm__' [249] */ | 36 | /* expect+1: error: syntax error '__asm__' [249] */ | |
37 | int i = __asm__(); | 37 | int i = __asm__(); | |
38 | } | 38 | } | |
39 | 39 | |||
40 | __asm__( | 40 | __asm__( | |
41 | /* cover read_until_rparen at EOF */ | 41 | /* cover read_until_rparen at EOF */ | |
42 | /* expect+1: error: syntax error '' [249] */ | 42 | /* expect+1: error: syntax error '' [249] */ |
--- src/tests/usr.bin/xlint/lint1/init_c90.c 2022/02/27 11:40:30 1.3
+++ src/tests/usr.bin/xlint/lint1/init_c90.c 2022/06/17 18:54:53 1.4
@@ -1,30 +1,30 @@ | @@ -1,30 +1,30 @@ | |||
1 | /* $NetBSD: init_c90.c,v 1.3 2022/02/27 11:40:30 rillig Exp $ */ | 1 | /* $NetBSD: init_c90.c,v 1.4 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "init_c90.c" | 2 | # 3 "init_c90.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Test initialization before C99. | 5 | * Test initialization before C99. | |
6 | * | 6 | * | |
7 | * C90 3.5.7 | 7 | * C90 3.5.7 | |
8 | */ | 8 | */ | |
9 | 9 | |||
10 | /* lint1-flags: -sw */ | 10 | /* lint1-flags: -sw */ | |
11 | 11 | |||
12 | struct point { | 12 | struct point { | |
13 | int x, y; | 13 | int x, y; | |
14 | }; | 14 | }; | |
15 | 15 | |||
16 | struct point point_c90 = { 0, 0 }; | 16 | struct point point_c90 = { 0, 0 }; | |
17 | /* expect+2: warning: struct or union member name in initializer is a C99 feature [313] */ | 17 | /* expect+2: warning: struct or union member name in initializer is a C99 feature [313] */ | |
18 | /* expect+1: warning: struct or union member name in initializer is a C99 feature [313] */ | 18 | /* expect+1: warning: struct or union member name in initializer is a C99 feature [313] */ | |
19 | struct point point_c99 = { .x = 0, .y = 0 }; | 19 | struct point point_c99 = { .x = 0, .y = 0 }; | |
20 | 20 | |||
21 | struct point points_c90[] = {{ 0, 0 }}; | 21 | struct point points_c90[] = {{ 0, 0 }}; | |
22 | /* expect+1: warning: array initializer with designators is a C99 feature [321] */ | 22 | /* expect+1: warning: array initializer with designators is a C99 feature [321] */ | |
23 | struct point points_c99[] = {[3] = { 0, 0 }}; | 23 | struct point points_c99[] = {[3] = { 0, 0 }}; | |
24 | 24 | |||
25 | 25 | |||
26 | struct point | 26 | struct point | |
27 | compound_literal(void) { | 27 | compound_literal(void) { | |
28 | /* expect+1: compound literals are a C99/GCC extension [319] */ | 28 | /* expect+1: error: compound literals are a C99/GCC extension [319] */ | |
29 | return (struct point){ 0, 0 }; | 29 | return (struct point){ 0, 0 }; | |
30 | } | 30 | } |
--- src/tests/usr.bin/xlint/lint1/lex_integer_ilp32.c 2021/08/21 11:50:57 1.3
+++ src/tests/usr.bin/xlint/lint1/lex_integer_ilp32.c 2022/06/17 18:54:53 1.4
@@ -1,44 +1,44 @@ | @@ -1,44 +1,44 @@ | |||
1 | /* $NetBSD: lex_integer_ilp32.c,v 1.3 2021/08/21 11:50:57 rillig Exp $ */ | 1 | /* $NetBSD: lex_integer_ilp32.c,v 1.4 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "lex_integer_ilp32.c" | 2 | # 3 "lex_integer_ilp32.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Tests for lexical analysis of integer constants. | 5 | * Tests for lexical analysis of integer constants. | |
6 | * | 6 | * | |
7 | * C99 6.4.4.1 "Integer constants" | 7 | * C99 6.4.4.1 "Integer constants" | |
8 | */ | 8 | */ | |
9 | 9 | |||
10 | /* lint1-only-if: ilp32 */ | 10 | /* lint1-only-if: ilp32 */ | |
11 | 11 | |||
12 | void sinki(int); | 12 | void sinki(int); | |
13 | void sinku(unsigned int); | 13 | void sinku(unsigned int); | |
14 | 14 | |||
15 | /* All platforms supported by lint have 32-bit int in two's complement. */ | 15 | /* All platforms supported by lint have 32-bit int in two's complement. */ | |
16 | void | 16 | void | |
17 | test_signed_int(void) | 17 | test_signed_int(void) | |
18 | { | 18 | { | |
19 | sinki(0); | 19 | sinki(0); | |
20 | 20 | |||
21 | sinki(-1); | 21 | sinki(-1); | |
22 | 22 | |||
23 | sinki(2147483647); | 23 | sinki(2147483647); | |
24 | 24 | |||
25 | /* expect+1: 'unsigned long' to 'int' is out of range, arg #1 [295] */ | 25 | /* expect+1: warning: conversion of 'unsigned long' to 'int' is out of range, arg #1 [295] */ | |
26 | sinki(2147483648); | 26 | sinki(2147483648); | |
27 | 27 | |||
28 | sinki(-2147483647); | 28 | sinki(-2147483647); | |
29 | 29 | |||
30 | /* expect+2: ANSI C treats constant as unsigned, op - [218] */ | 30 | /* expect+2: warning: ANSI C treats constant as unsigned, op - [218] */ | |
31 | /* expect+1: 'unsigned long' to 'int' is out of range, arg #1 [295] */ | 31 | /* expect+1: warning: conversion of 'unsigned long' to 'int' is out of range, arg #1 [295] */ | |
32 | sinki(-2147483648); | 32 | sinki(-2147483648); | |
33 | } | 33 | } | |
34 | 34 | |||
35 | void | 35 | void | |
36 | test_unsigned_int(void) | 36 | test_unsigned_int(void) | |
37 | { | 37 | { | |
38 | sinku(0); | 38 | sinku(0); | |
39 | 39 | |||
40 | sinku(4294967295U); | 40 | sinku(4294967295U); | |
41 | 41 | |||
42 | /* expect+1: integer constant out of range [252] */ | 42 | /* expect+1: warning: integer constant out of range [252] */ | |
43 | sinku(4294967296U); | 43 | sinku(4294967296U); | |
44 | } | 44 | } |
--- src/tests/usr.bin/xlint/lint1/msg_069.c 2022/04/08 21:29:29 1.3
+++ src/tests/usr.bin/xlint/lint1/msg_069.c 2022/06/17 18:54:53 1.4
@@ -1,12 +1,12 @@ | @@ -1,12 +1,12 @@ | |||
1 | /* $NetBSD: msg_069.c,v 1.3 2022/04/08 21:29:29 rillig Exp $ */ | 1 | /* $NetBSD: msg_069.c,v 1.4 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_069.c" | 2 | # 3 "msg_069.c" | |
3 | 3 | |||
4 | // Test for message: inappropriate qualifiers with 'void' [69] | 4 | // Test for message: inappropriate qualifiers with 'void' [69] | |
5 | 5 | |||
6 | /* expect+2: error: void type for 'const_void' [19] */ | 6 | /* expect+2: error: void type for 'const_void' [19] */ | |
7 | /* expect+1: warning: inappropriate qualifiers with 'void' */ | 7 | /* expect+1: warning: inappropriate qualifiers with 'void' [69] */ | |
8 | const void const_void; | 8 | const void const_void; | |
9 | 9 | |||
10 | /* expect+2: error: void type for 'volatile_void' [19] */ | 10 | /* expect+2: error: void type for 'volatile_void' [19] */ | |
11 | /* expect+1: warning: inappropriate qualifiers with 'void' */ | 11 | /* expect+1: warning: inappropriate qualifiers with 'void' [69] */ | |
12 | volatile void volatile_void; | 12 | volatile void volatile_void; |
--- src/tests/usr.bin/xlint/lint1/msg_103.c 2021/07/04 17:01:58 1.3
+++ src/tests/usr.bin/xlint/lint1/msg_103.c 2022/06/17 18:54:53 1.4
@@ -1,16 +1,16 @@ | @@ -1,16 +1,16 @@ | |||
1 | /* $NetBSD: msg_103.c,v 1.3 2021/07/04 17:01:58 rillig Exp $ */ | 1 | /* $NetBSD: msg_103.c,v 1.4 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_103.c" | 2 | # 3 "msg_103.c" | |
3 | 3 | |||
4 | // Test for message: left operand of '.' must be struct or union, not '%s' [103] | 4 | // Test for message: left operand of '.' must be struct or union, not '%s' [103] | |
5 | 5 | |||
6 | struct point { | 6 | struct point { | |
7 | int x, y; | 7 | int x, y; | |
8 | }; | 8 | }; | |
9 | 9 | |||
10 | void | 10 | void | |
11 | test(struct point pt, struct point *ptr) | 11 | test(struct point pt, struct point *ptr) | |
12 | { | 12 | { | |
13 | pt.x = 0; | 13 | pt.x = 0; | |
14 | /* expect+1: left operand of '.' must be struct or union, not 'pointer to struct point' [103] */ | 14 | /* expect+1: error: left operand of '.' must be struct or union, not 'pointer to struct point' [103] */ | |
15 | ptr.y = 0; | 15 | ptr.y = 0; | |
16 | } | 16 | } |
--- src/tests/usr.bin/xlint/lint1/msg_104.c 2021/07/04 17:01:58 1.3
+++ src/tests/usr.bin/xlint/lint1/msg_104.c 2022/06/17 18:54:53 1.4
@@ -1,17 +1,17 @@ | @@ -1,17 +1,17 @@ | |||
1 | /* $NetBSD: msg_104.c,v 1.3 2021/07/04 17:01:58 rillig Exp $ */ | 1 | /* $NetBSD: msg_104.c,v 1.4 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_104.c" | 2 | # 3 "msg_104.c" | |
3 | 3 | |||
4 | // Test for message: left operand of '->' must be pointer to struct or union, not '%s' [104] | 4 | // Test for message: left operand of '->' must be pointer to struct or union, not '%s' [104] | |
5 | 5 | |||
6 | struct point { | 6 | struct point { | |
7 | int x, y; | 7 | int x, y; | |
8 | }; | 8 | }; | |
9 | 9 | |||
10 | /* ARGSUSED */ | 10 | /* ARGSUSED */ | |
11 | void | 11 | void | |
12 | test(struct point pt, struct point *ptr) | 12 | test(struct point pt, struct point *ptr) | |
13 | { | 13 | { | |
14 | /* expect+1: left operand of '->' must be pointer to struct or union, not 'struct point' [104] */ | 14 | /* expect+1: error: left operand of '->' must be pointer to struct or union, not 'struct point' [104] */ | |
15 | pt->x = 0; | 15 | pt->x = 0; | |
16 | ptr->y = 0; | 16 | ptr->y = 0; | |
17 | } | 17 | } |
--- src/tests/usr.bin/xlint/lint1/msg_211.c 2021/08/16 18:51:58 1.3
+++ src/tests/usr.bin/xlint/lint1/msg_211.c 2022/06/17 18:54:53 1.4
@@ -1,22 +1,22 @@ | @@ -1,22 +1,22 @@ | |||
1 | /* $NetBSD: msg_211.c,v 1.3 2021/08/16 18:51:58 rillig Exp $ */ | 1 | /* $NetBSD: msg_211.c,v 1.4 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_211.c" | 2 | # 3 "msg_211.c" | |
3 | 3 | |||
4 | // Test for message: return value type mismatch (%s) and (%s) [211] | 4 | // Test for message: return value type mismatch (%s) and (%s) [211] | |
5 | 5 | |||
6 | struct str { | 6 | struct str { | |
7 | int member; | 7 | int member; | |
8 | }; | 8 | }; | |
9 | 9 | |||
10 | int | 10 | int | |
11 | return_int(double dbl, void *ptr, struct str str) | 11 | return_int(double dbl, void *ptr, struct str str) | |
12 | { | 12 | { | |
13 | if (dbl > 0.0) | 13 | if (dbl > 0.0) | |
14 | return dbl; | 14 | return dbl; | |
15 | if (ptr != (void *)0) | 15 | if (ptr != (void *)0) | |
16 | /* expect+1: warning: illegal combination of integer (int) and pointer (pointer to void) [183] */ | 16 | /* expect+1: warning: illegal combination of integer (int) and pointer (pointer to void) [183] */ | |
17 | return ptr; | 17 | return ptr; | |
18 | if (str.member > 0) | 18 | if (str.member > 0) | |
19 | /* expect+1: error: return value type mismatch (int) and (struct str) [211 */ | 19 | /* expect+1: error: return value type mismatch (int) and (struct str) [211] */ | |
20 | return str; | 20 | return str; | |
21 | return 3; | 21 | return 3; | |
22 | } | 22 | } |
--- src/tests/usr.bin/xlint/lint1/msg_251.c 2021/06/29 07:17:43 1.3
+++ src/tests/usr.bin/xlint/lint1/msg_251.c 2022/06/17 18:54:53 1.4
@@ -1,10 +1,10 @@ | @@ -1,10 +1,10 @@ | |||
1 | /* $NetBSD: msg_251.c,v 1.3 2021/06/29 07:17:43 rillig Exp $ */ | 1 | /* $NetBSD: msg_251.c,v 1.4 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_251.c" | 2 | # 3 "msg_251.c" | |
3 | 3 | |||
4 | // Test for message: malformed integer constant [251] | 4 | // Test for message: malformed integer constant [251] | |
5 | 5 | |||
6 | /* expect+1: malformed integer constant */ | 6 | /* expect+1: warning: malformed integer constant [251] */ | |
7 | int lll = 123LLL; | 7 | int lll = 123LLL; | |
8 | 8 | |||
9 | /* expect+1: malformed integer constant */ | 9 | /* expect+1: warning: malformed integer constant [251] */ | |
10 | unsigned int uu = 123UU; | 10 | unsigned int uu = 123UU; |
--- src/tests/usr.bin/xlint/lint1/msg_253.c 2021/06/29 07:17:43 1.3
+++ src/tests/usr.bin/xlint/lint1/msg_253.c 2022/06/17 18:54:53 1.4
@@ -1,8 +1,8 @@ | @@ -1,8 +1,8 @@ | |||
1 | /* $NetBSD: msg_253.c,v 1.3 2021/06/29 07:17:43 rillig Exp $ */ | 1 | /* $NetBSD: msg_253.c,v 1.4 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_253.c" | 2 | # 3 "msg_253.c" | |
3 | 3 | |||
4 | // Test for message: unterminated character constant [253] | 4 | // Test for message: unterminated character constant [253] | |
5 | 5 | |||
6 | /* expect+3: [253] */ | 6 | /* expect+3: error: unterminated character constant [253] */ | |
7 | /* expect+2: syntax error '' */ | 7 | /* expect+2: error: syntax error '' [249] */ | |
8 | ' | 8 | ' |
--- src/tests/usr.bin/xlint/lint1/msg_254.c 2021/06/29 07:17:43 1.3
+++ src/tests/usr.bin/xlint/lint1/msg_254.c 2022/06/17 18:54:53 1.4
@@ -1,19 +1,19 @@ | @@ -1,19 +1,19 @@ | |||
1 | /* $NetBSD: msg_254.c,v 1.3 2021/06/29 07:17:43 rillig Exp $ */ | 1 | /* $NetBSD: msg_254.c,v 1.4 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_254.c" | 2 | # 3 "msg_254.c" | |
3 | 3 | |||
4 | /* Test for message: newline in string or char constant [254] */ | 4 | /* Test for message: newline in string or char constant [254] */ | |
5 | 5 | |||
6 | /* lint1-flags: -tw */ | 6 | /* lint1-flags: -tw */ | |
7 | 7 | |||
8 | /* | 8 | /* | |
9 | * The sequence backslash-newline is a GCC extension. | 9 | * The sequence backslash-newline is a GCC extension. | |
10 | * C99 does not allow it. | 10 | * C99 does not allow it. | |
11 | */ | 11 | */ | |
12 | 12 | |||
13 | /* expect+6: newline in string or char constant [254] */ | 13 | /* expect+6: error: newline in string or char constant [254] */ | |
14 | /* expect+5: unterminated string constant [258] */ | 14 | /* expect+5: error: unterminated string constant [258] */ | |
15 | /* expect+4: syntax error '"' [249] */ | 15 | /* expect+4: error: syntax error '"' [249] */ | |
16 | /* expect+4: newline in string or char constant [254] */ | 16 | /* expect+4: error: newline in string or char constant [254] */ | |
17 | /* expect+3: unterminated string constant [258] */ | 17 | /* expect+3: error: unterminated string constant [258] */ | |
18 | "line1 | 18 | "line1 | |
19 | line2" | 19 | line2" |
--- src/tests/usr.bin/xlint/lint1/msg_257.c 2021/08/27 20:49:25 1.3
+++ src/tests/usr.bin/xlint/lint1/msg_257.c 2022/06/17 18:54:53 1.4
@@ -1,28 +1,28 @@ | @@ -1,28 +1,28 @@ | |||
1 | /* $NetBSD: msg_257.c,v 1.3 2021/08/27 20:49:25 rillig Exp $ */ | 1 | /* $NetBSD: msg_257.c,v 1.4 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_257.c" | 2 | # 3 "msg_257.c" | |
3 | 3 | |||
4 | // Test for message: extra characters in lint comment [257] | 4 | // Test for message: extra characters in lint comment [257] | |
5 | 5 | |||
6 | void take(const void *); | 6 | void take(const void *); | |
7 | 7 | |||
8 | /* expect+1: warning: extra characters in lint comment [257] */ | 8 | /* expect+1: warning: extra characters in lint comment [257] */ | |
9 | /* FALLTHROUGH 3 */ | 9 | /* FALLTHROUGH 3 */ | |
10 | 10 | |||
11 | /* expect+1: warning: extra characters in lint comment [257] */ | 11 | /* expect+1: warning: extra characters in lint comment [257] */ | |
12 | /* FALLTHROUGH extra */ | 12 | /* FALLTHROUGH extra */ | |
13 | 13 | |||
14 | /* PRINTFLIKE 7 */ | 14 | /* PRINTFLIKE 7 */ | |
15 | void | 15 | void | |
16 | my_printf(const char *fmt) | 16 | my_printf(const char *fmt) | |
17 | /* expect+1: warning: argument number mismatch with directive: */ | 17 | /* expect+1: warning: argument number mismatch with directive: ** PRINTFLIKE ** [283] */ | |
18 | { | 18 | { | |
19 | take(fmt); | 19 | take(fmt); | |
20 | } | 20 | } | |
21 | 21 | |||
22 | /* expect+1: warning: extra characters in lint comment [257] */ | 22 | /* expect+1: warning: extra characters in lint comment [257] */ | |
23 | /* SCANFLIKE extra */ | 23 | /* SCANFLIKE extra */ | |
24 | void | 24 | void | |
25 | my_scanf(const char *fmt) | 25 | my_scanf(const char *fmt) | |
26 | { | 26 | { | |
27 | take(fmt); | 27 | take(fmt); | |
28 | } | 28 | } |
--- src/tests/usr.bin/xlint/lint1/msg_259_c90.c 2021/09/02 17:55:27 1.3
+++ src/tests/usr.bin/xlint/lint1/msg_259_c90.c 2022/06/17 18:54:53 1.4
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: msg_259_c90.c,v 1.3 2021/09/02 17:55:27 rillig Exp $ */ | 1 | /* $NetBSD: msg_259_c90.c,v 1.4 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_259_c90.c" | 2 | # 3 "msg_259_c90.c" | |
3 | 3 | |||
4 | /* Test for message: argument #%d is converted from '%s' to '%s' due to prototype [259] */ | 4 | /* Test for message: argument #%d is converted from '%s' to '%s' due to prototype [259] */ | |
5 | 5 | |||
6 | /* | 6 | /* | |
7 | * This warning detects function calls that are translated in very different | 7 | * This warning detects function calls that are translated in very different | |
8 | * translation environments, one where prototypes are omitted, and one where | 8 | * translation environments, one where prototypes are omitted, and one where | |
9 | * prototypes are active. It is possible to make such code interoperable, | 9 | * prototypes are active. It is possible to make such code interoperable, | |
10 | * but that requires that each argument is converted to its proper type by | 10 | * but that requires that each argument is converted to its proper type by | |
11 | * the caller of the function. | 11 | * the caller of the function. | |
12 | * | 12 | * | |
13 | * When lint is run with the '-s' flag, it no longer warns about code with | 13 | * When lint is run with the '-s' flag, it no longer warns about code with | |
14 | * incompatibilities between traditional C and C90, therefore this test omits | 14 | * incompatibilities between traditional C and C90, therefore this test omits | |
@@ -37,27 +37,27 @@ void | @@ -37,27 +37,27 @@ void | |||
37 | change_in_type_width(char c, int i, long l) | 37 | change_in_type_width(char c, int i, long l) | |
38 | { | 38 | { | |
39 | plain_char(c); | 39 | plain_char(c); | |
40 | signed_int(c); | 40 | signed_int(c); | |
41 | /* No warning 259 on LP64, only on ILP32 */ | 41 | /* No warning 259 on LP64, only on ILP32 */ | |
42 | signed_long(c); | 42 | signed_long(c); | |
43 | 43 | |||
44 | plain_char(i); /* XXX: why no warning? */ | 44 | plain_char(i); /* XXX: why no warning? */ | |
45 | signed_int(i); | 45 | signed_int(i); | |
46 | /* No warning 259 on LP64, only on ILP32 */ | 46 | /* No warning 259 on LP64, only on ILP32 */ | |
47 | signed_long(i); | 47 | signed_long(i); | |
48 | 48 | |||
49 | plain_char(l); /* XXX: why no warning? */ | 49 | plain_char(l); /* XXX: why no warning? */ | |
50 | /* expect+1: from 'long' to 'int' due to prototype [259] */ | 50 | /* expect+1: ... from 'long' to 'int' due to prototype [259] */ | |
51 | signed_int(l); | 51 | signed_int(l); | |
52 | signed_long(l); | 52 | signed_long(l); | |
53 | } | 53 | } | |
54 | 54 | |||
55 | /* | 55 | /* | |
56 | * Converting a signed integer type to its corresponding unsigned integer | 56 | * Converting a signed integer type to its corresponding unsigned integer | |
57 | * type (C99 6.2.5p6) is usually not a problem since the actual values of the | 57 | * type (C99 6.2.5p6) is usually not a problem since the actual values of the | |
58 | * expressions are usually not anywhere near the maximum signed value. From | 58 | * expressions are usually not anywhere near the maximum signed value. From | |
59 | * a technical standpoint, it is correct to warn here since even small | 59 | * a technical standpoint, it is correct to warn here since even small | |
60 | * negative numbers may result in very large positive numbers. | 60 | * negative numbers may result in very large positive numbers. | |
61 | * | 61 | * | |
62 | * A common case where it occurs is when the difference of two pointers is | 62 | * A common case where it occurs is when the difference of two pointers is | |
63 | * converted to size_t. The type ptrdiff_t is defined to be signed, but in | 63 | * converted to size_t. The type ptrdiff_t is defined to be signed, but in |
--- src/tests/usr.bin/xlint/lint1/msg_283.c 2021/08/30 19:48:21 1.3
+++ src/tests/usr.bin/xlint/lint1/msg_283.c 2022/06/17 18:54:53 1.4
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: msg_283.c,v 1.3 2021/08/30 19:48:21 rillig Exp $ */ | 1 | /* $NetBSD: msg_283.c,v 1.4 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_283.c" | 2 | # 3 "msg_283.c" | |
3 | 3 | |||
4 | // Test for message: argument number mismatch with directive: /* %s */ [283] | 4 | // Test for message: argument number mismatch with directive: /* %s */ [283] | |
5 | 5 | |||
6 | /* Do not warn about unused parameters. */ | 6 | /* Do not warn about unused parameters. */ | |
7 | /* lint1-extra-flags: -X 231 */ | 7 | /* lint1-extra-flags: -X 231 */ | |
8 | 8 | |||
9 | /* PRINTFLIKE */ | 9 | /* PRINTFLIKE */ | |
10 | void | 10 | void | |
11 | printflike_comment(const char *fmt) | 11 | printflike_comment(const char *fmt) | |
12 | { | 12 | { | |
13 | } | 13 | } | |
14 | 14 | |||
@@ -17,16 +17,16 @@ void | @@ -17,16 +17,16 @@ void | |||
17 | printflike_0_comment(const char *fmt) | 17 | printflike_0_comment(const char *fmt) | |
18 | { | 18 | { | |
19 | } | 19 | } | |
20 | 20 | |||
21 | /* PRINTFLIKE 2 */ | 21 | /* PRINTFLIKE 2 */ | |
22 | void | 22 | void | |
23 | printflike_2_comment(int a, const char *fmt) | 23 | printflike_2_comment(int a, const char *fmt) | |
24 | { | 24 | { | |
25 | } | 25 | } | |
26 | 26 | |||
27 | /* PRINTFLIKE 3 */ | 27 | /* PRINTFLIKE 3 */ | |
28 | void | 28 | void | |
29 | printflike_3_comment(int a, const char *fmt) | 29 | printflike_3_comment(int a, const char *fmt) | |
30 | /* expect+1: warning: argument number mismatch with directive */ | 30 | /* expect+1: warning: argument number mismatch with directive: ** PRINTFLIKE ** [283] */ | |
31 | { | 31 | { | |
32 | } | 32 | } |
--- src/tests/usr.bin/xlint/lint1/msg_289.c 2021/08/27 20:49:25 1.3
+++ src/tests/usr.bin/xlint/lint1/msg_289.c 2022/06/17 18:54:53 1.4
@@ -1,11 +1,11 @@ | @@ -1,11 +1,11 @@ | |||
1 | /* $NetBSD: msg_289.c,v 1.3 2021/08/27 20:49:25 rillig Exp $ */ | 1 | /* $NetBSD: msg_289.c,v 1.4 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_289.c" | 2 | # 3 "msg_289.c" | |
3 | 3 | |||
4 | // Test for message: can't be used together: /* PRINTFLIKE */ /* SCANFLIKE */ [289] | 4 | // Test for message: can't be used together: /* PRINTFLIKE */ /* SCANFLIKE */ [289] | |
5 | 5 | |||
6 | /* PRINTFLIKE */ /* SCANFLIKE */ | 6 | /* PRINTFLIKE */ /* SCANFLIKE */ | |
7 | void | 7 | void | |
8 | both(void) | 8 | both(void) | |
9 | /* expect+1: warning: can't be used together */ | 9 | /* expect+1: warning: can't be used together: ** PRINTFLIKE ** ** SCANFLIKE ** [289] */ | |
10 | { | 10 | { | |
11 | } | 11 | } |
--- src/tests/usr.bin/xlint/lint1/msg_312.c 2021/12/22 14:25:35 1.3
+++ src/tests/usr.bin/xlint/lint1/msg_312.c 2022/06/17 18:54:53 1.4
@@ -1,9 +1,9 @@ | @@ -1,9 +1,9 @@ | |||
1 | /* $NetBSD: msg_312.c,v 1.3 2021/12/22 14:25:35 rillig Exp $ */ | 1 | /* $NetBSD: msg_312.c,v 1.4 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_312.c" | 2 | # 3 "msg_312.c" | |
3 | 3 | |||
4 | /* Test for message: %s does not support // comments [312] */ | 4 | /* Test for message: %s does not support // comments [312] */ | |
5 | 5 | |||
6 | /* lint1-flags: -tw */ | 6 | /* lint1-flags: -tw */ | |
7 | 7 | |||
8 | /* expect+1: traditional C does not support // comments [312] */ | 8 | /* expect+1: warning: traditional C does not support // comments [312] */ | |
9 | // C99 comment | 9 | // C99 comment |
--- src/tests/usr.bin/xlint/lint1/msg_342.c 2021/07/25 22:43:08 1.3
+++ src/tests/usr.bin/xlint/lint1/msg_342.c 2022/06/17 18:54:53 1.4
@@ -1,15 +1,15 @@ | @@ -1,15 +1,15 @@ | |||
1 | /* $NetBSD: msg_342.c,v 1.3 2021/07/25 22:43:08 rillig Exp $ */ | 1 | /* $NetBSD: msg_342.c,v 1.4 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_341.c" | 2 | # 3 "msg_342.c" | |
3 | 3 | |||
4 | // Test for message: argument to '%s' must be cast to 'unsigned char', not to '%s' [342] | 4 | // Test for message: argument to '%s' must be cast to 'unsigned char', not to '%s' [342] | |
5 | 5 | |||
6 | /* | 6 | /* | |
7 | * Ensure that the functions from <ctype.h> are called with the correct | 7 | * Ensure that the functions from <ctype.h> are called with the correct | |
8 | * argument. | 8 | * argument. | |
9 | */ | 9 | */ | |
10 | 10 | |||
11 | /* NetBSD 9.99.81, <ctype.h> */ | 11 | /* NetBSD 9.99.81, <ctype.h> */ | |
12 | extern const unsigned short *_ctype_tab_; | 12 | extern const unsigned short *_ctype_tab_; | |
13 | extern const short *_tolower_tab_; | 13 | extern const short *_tolower_tab_; | |
14 | extern const short *_toupper_tab_; | 14 | extern const short *_toupper_tab_; | |
15 | int isalnum(int); | 15 | int isalnum(int); | |
@@ -63,39 +63,39 @@ cover_is_ctype_function(char c) | @@ -63,39 +63,39 @@ cover_is_ctype_function(char c) | |||
63 | tolower(c); | 63 | tolower(c); | |
64 | /* expect+1: warning: argument to 'toupper' must be 'unsigned char' or EOF, not 'char' [341] */ | 64 | /* expect+1: warning: argument to 'toupper' must be 'unsigned char' or EOF, not 'char' [341] */ | |
65 | toupper(c); | 65 | toupper(c); | |
66 | 66 | |||
67 | /* Functions with similar names are not checked. */ | 67 | /* Functions with similar names are not checked. */ | |
68 | is_other(c); | 68 | is_other(c); | |
69 | to_other(c); | 69 | to_other(c); | |
70 | } | 70 | } | |
71 | 71 | |||
72 | void | 72 | void | |
73 | function_call_char(char c) | 73 | function_call_char(char c) | |
74 | { | 74 | { | |
75 | 75 | |||
76 | /* expect+1: argument to 'isspace' must be 'unsigned char' or EOF, not 'char' */ | 76 | /* expect+1: warning: argument to 'isspace' must be 'unsigned char' or EOF, not 'char' [341] */ | |
77 | (isspace)(c); | 77 | (isspace)(c); | |
78 | 78 | |||
79 | /* This is the only allowed form. */ | 79 | /* This is the only allowed form. */ | |
80 | isspace((unsigned char)c); | 80 | isspace((unsigned char)c); | |
81 | 81 | |||
82 | /* The cast to 'int' is redundant, it doesn't hurt though. */ | 82 | /* The cast to 'int' is redundant, it doesn't hurt though. */ | |
83 | isspace((int)(unsigned char)c); | 83 | isspace((int)(unsigned char)c); | |
84 | 84 | |||
85 | /* expect+1: argument to 'isspace' must be cast to 'unsigned char', not to 'int' */ | 85 | /* expect+1: warning: argument to 'isspace' must be cast to 'unsigned char', not to 'int' [342] */ | |
86 | isspace((int)c); | 86 | isspace((int)c); | |
87 | 87 | |||
88 | /* expect+1: argument to 'isspace' must be cast to 'unsigned char', not to 'unsigned int' */ | 88 | /* expect+1: warning: argument to 'isspace' must be cast to 'unsigned char', not to 'unsigned int' [342] */ | |
89 | isspace((unsigned int)c); | 89 | isspace((unsigned int)c); | |
90 | } | 90 | } | |
91 | 91 | |||
92 | /* | 92 | /* | |
93 | * If the expression starts with type 'unsigned char', it can be cast to any | 93 | * If the expression starts with type 'unsigned char', it can be cast to any | |
94 | * other type. Chances are low enough that the cast is to 'char', which would | 94 | * other type. Chances are low enough that the cast is to 'char', which would | |
95 | * be the only bad type. | 95 | * be the only bad type. | |
96 | */ | 96 | */ | |
97 | void | 97 | void | |
98 | function_call_unsigned_char(unsigned char c) | 98 | function_call_unsigned_char(unsigned char c) | |
99 | { | 99 | { | |
100 | 100 | |||
101 | (isspace)(c); | 101 | (isspace)(c); | |
@@ -106,25 +106,25 @@ function_call_unsigned_char(unsigned cha | @@ -106,25 +106,25 @@ function_call_unsigned_char(unsigned cha | |||
106 | 106 | |||
107 | /* When used in a loop of fgetc, the type is already 'int'. That's fine. */ | 107 | /* When used in a loop of fgetc, the type is already 'int'. That's fine. */ | |
108 | void | 108 | void | |
109 | function_call_int(int c) | 109 | function_call_int(int c) | |
110 | { | 110 | { | |
111 | 111 | |||
112 | isspace(c); | 112 | isspace(c); | |
113 | } | 113 | } | |
114 | 114 | |||
115 | void | 115 | void | |
116 | macro_invocation_NetBSD(char c) | 116 | macro_invocation_NetBSD(char c) | |
117 | { | 117 | { | |
118 | 118 | |||
119 | /* expect+1: argument to 'function from <ctype.h>' must be 'unsigned char' or EOF, not 'char' */ | 119 | /* expect+1: warning: argument to 'function from <ctype.h>' must be 'unsigned char' or EOF, not 'char' [341] */ | |
120 | sink(((int)((_ctype_tab_ + 1)[(c)] & 0x0040))); | 120 | sink(((int)((_ctype_tab_ + 1)[(c)] & 0x0040))); | |
121 | 121 | |||
122 | /* This is the only allowed form. */ | 122 | /* This is the only allowed form. */ | |
123 | sink(((int)((_ctype_tab_ + 1)[((unsigned char)c)] & 0x0040))); | 123 | sink(((int)((_ctype_tab_ + 1)[((unsigned char)c)] & 0x0040))); | |
124 | 124 | |||
125 | /* expect+1: argument to 'function from <ctype.h>' must be cast to 'unsigned char', not to 'int' */ | 125 | /* expect+1: warning: argument to 'function from <ctype.h>' must be cast to 'unsigned char', not to 'int' [342] */ | |
126 | sink(((int)((_ctype_tab_ + 1)[((int)c)] & 0x0040))); | 126 | sink(((int)((_ctype_tab_ + 1)[((int)c)] & 0x0040))); | |
127 | 127 | |||
128 | /* expect+1: argument to 'function from <ctype.h>' must be cast to 'unsigned char', not to 'unsigned int' */ | 128 | /* expect+1: warning: argument to 'function from <ctype.h>' must be cast to 'unsigned char', not to 'unsigned int' [342] */ | |
129 | sink(((int)((_ctype_tab_ + 1)[((unsigned int)c)] & 0x0040))); | 129 | sink(((int)((_ctype_tab_ + 1)[((unsigned int)c)] & 0x0040))); | |
130 | } | 130 | } |
--- src/tests/usr.bin/xlint/lint1/Attic/msg_342.exp 2021/07/25 22:43:08 1.3
+++ src/tests/usr.bin/xlint/lint1/Attic/msg_342.exp 2022/06/17 18:54:53 1.4
@@ -1,20 +1,20 @@ | @@ -1,20 +1,20 @@ | |||
1 | msg_341.c(39): warning: argument to 'isalnum' must be 'unsigned char' or EOF, not 'char' [341] | 1 | msg_342.c(39): warning: argument to 'isalnum' must be 'unsigned char' or EOF, not 'char' [341] | |
2 | msg_341.c(41): warning: argument to 'isalpha' must be 'unsigned char' or EOF, not 'char' [341] | 2 | msg_342.c(41): warning: argument to 'isalpha' must be 'unsigned char' or EOF, not 'char' [341] | |
3 | msg_341.c(43): warning: argument to 'isblank' must be 'unsigned char' or EOF, not 'char' [341] | 3 | msg_342.c(43): warning: argument to 'isblank' must be 'unsigned char' or EOF, not 'char' [341] | |
4 | msg_341.c(45): warning: argument to 'iscntrl' must be 'unsigned char' or EOF, not 'char' [341] | 4 | msg_342.c(45): warning: argument to 'iscntrl' must be 'unsigned char' or EOF, not 'char' [341] | |
5 | msg_341.c(47): warning: argument to 'isdigit' must be 'unsigned char' or EOF, not 'char' [341] | 5 | msg_342.c(47): warning: argument to 'isdigit' must be 'unsigned char' or EOF, not 'char' [341] | |
6 | msg_341.c(49): warning: argument to 'isgraph' must be 'unsigned char' or EOF, not 'char' [341] | 6 | msg_342.c(49): warning: argument to 'isgraph' must be 'unsigned char' or EOF, not 'char' [341] | |
7 | msg_341.c(51): warning: argument to 'islower' must be 'unsigned char' or EOF, not 'char' [341] | 7 | msg_342.c(51): warning: argument to 'islower' must be 'unsigned char' or EOF, not 'char' [341] | |
8 | msg_341.c(53): warning: argument to 'isprint' must be 'unsigned char' or EOF, not 'char' [341] | 8 | msg_342.c(53): warning: argument to 'isprint' must be 'unsigned char' or EOF, not 'char' [341] | |
9 | msg_341.c(55): warning: argument to 'ispunct' must be 'unsigned char' or EOF, not 'char' [341] | 9 | msg_342.c(55): warning: argument to 'ispunct' must be 'unsigned char' or EOF, not 'char' [341] | |
10 | msg_341.c(57): warning: argument to 'isspace' must be 'unsigned char' or EOF, not 'char' [341] | 10 | msg_342.c(57): warning: argument to 'isspace' must be 'unsigned char' or EOF, not 'char' [341] | |
11 | msg_341.c(59): warning: argument to 'isupper' must be 'unsigned char' or EOF, not 'char' [341] | 11 | msg_342.c(59): warning: argument to 'isupper' must be 'unsigned char' or EOF, not 'char' [341] | |
12 | msg_341.c(61): warning: argument to 'isxdigit' must be 'unsigned char' or EOF, not 'char' [341] | 12 | msg_342.c(61): warning: argument to 'isxdigit' must be 'unsigned char' or EOF, not 'char' [341] | |
13 | msg_341.c(63): warning: argument to 'tolower' must be 'unsigned char' or EOF, not 'char' [341] | 13 | msg_342.c(63): warning: argument to 'tolower' must be 'unsigned char' or EOF, not 'char' [341] | |
14 | msg_341.c(65): warning: argument to 'toupper' must be 'unsigned char' or EOF, not 'char' [341] | 14 | msg_342.c(65): warning: argument to 'toupper' must be 'unsigned char' or EOF, not 'char' [341] | |
15 | msg_341.c(77): warning: argument to 'isspace' must be 'unsigned char' or EOF, not 'char' [341] | 15 | msg_342.c(77): warning: argument to 'isspace' must be 'unsigned char' or EOF, not 'char' [341] | |
16 | msg_341.c(86): warning: argument to 'isspace' must be cast to 'unsigned char', not to 'int' [342] | 16 | msg_342.c(86): warning: argument to 'isspace' must be cast to 'unsigned char', not to 'int' [342] | |
17 | msg_341.c(89): warning: argument to 'isspace' must be cast to 'unsigned char', not to 'unsigned int' [342] | 17 | msg_342.c(89): warning: argument to 'isspace' must be cast to 'unsigned char', not to 'unsigned int' [342] | |
18 | msg_341.c(120): warning: argument to 'function from <ctype.h>' must be 'unsigned char' or EOF, not 'char' [341] | 18 | msg_342.c(120): warning: argument to 'function from <ctype.h>' must be 'unsigned char' or EOF, not 'char' [341] | |
19 | msg_341.c(126): warning: argument to 'function from <ctype.h>' must be cast to 'unsigned char', not to 'int' [342] | 19 | msg_342.c(126): warning: argument to 'function from <ctype.h>' must be cast to 'unsigned char', not to 'int' [342] | |
20 | msg_341.c(129): warning: argument to 'function from <ctype.h>' must be cast to 'unsigned char', not to 'unsigned int' [342] | 20 | msg_342.c(129): warning: argument to 'function from <ctype.h>' must be cast to 'unsigned char', not to 'unsigned int' [342] |
--- src/tests/usr.bin/xlint/lint1/lex_integer.c 2021/08/28 21:01:34 1.9
+++ src/tests/usr.bin/xlint/lint1/lex_integer.c 2022/06/17 18:54:53 1.10
@@ -1,150 +1,150 @@ | @@ -1,150 +1,150 @@ | |||
1 | /* $NetBSD: lex_integer.c,v 1.9 2021/08/28 21:01:34 rillig Exp $ */ | 1 | /* $NetBSD: lex_integer.c,v 1.10 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "lex_integer.c" | 2 | # 3 "lex_integer.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Tests for lexical analysis of integer constants. | 5 | * Tests for lexical analysis of integer constants. | |
6 | * | 6 | * | |
7 | * C99 6.4.4.1 "Integer constants" | 7 | * C99 6.4.4.1 "Integer constants" | |
8 | */ | 8 | */ | |
9 | 9 | |||
10 | /* lint1-only-if: lp64 */ | 10 | /* lint1-only-if: lp64 */ | |
11 | 11 | |||
12 | long signed_long; | 12 | long signed_long; | |
13 | unsigned long long unsigned_long_long_var; | 13 | unsigned long long unsigned_long_long_var; | |
14 | 14 | |||
15 | struct s { | 15 | struct s { | |
16 | int member; | 16 | int member; | |
17 | }; | 17 | }; | |
18 | /* | 18 | /* | |
19 | * When lint tries to convert the argument to 'struct s', it prints the | 19 | * When lint tries to convert the argument to 'struct s', it prints the | |
20 | * actual type of the argument as a side effect. | 20 | * actual type of the argument as a side effect. | |
21 | */ | 21 | */ | |
22 | void print_type(struct s); | 22 | void print_type(struct s); | |
23 | 23 | |||
24 | void | 24 | void | |
25 | no_suffix(void) | 25 | no_suffix(void) | |
26 | { | 26 | { | |
27 | /* expect+1: passing 'int' */ | 27 | /* expect+1: ... passing 'int' ... */ | |
28 | print_type(0); | 28 | print_type(0); | |
29 | /* The '-' is not part of the constant, it is a unary operator. */ | 29 | /* The '-' is not part of the constant, it is a unary operator. */ | |
30 | /* expect+1: passing 'int' */ | 30 | /* expect+1: ... passing 'int' ... */ | |
31 | print_type(-1); | 31 | print_type(-1); | |
32 | 32 | |||
33 | /* expect+1: passing 'int' */ | 33 | /* expect+1: ... passing 'int' ... */ | |
34 | print_type(2147483647); | 34 | print_type(2147483647); | |
35 | /* expect+1: passing 'int' */ | 35 | /* expect+1: ... passing 'int' ... */ | |
36 | print_type(0x7fffffff); | 36 | print_type(0x7fffffff); | |
37 | /* expect+1: passing 'int' */ | 37 | /* expect+1: ... passing 'int' ... */ | |
38 | print_type(017777777777); | 38 | print_type(017777777777); | |
39 | 39 | |||
40 | /* expect+1: passing 'unsigned int' */ | 40 | /* expect+1: ... passing 'unsigned int' ... */ | |
41 | print_type(0x80000000); | 41 | print_type(0x80000000); | |
42 | /* expect+1: passing 'unsigned int' */ | 42 | /* expect+1: ... passing 'unsigned int' ... */ | |
43 | print_type(020000000000); | 43 | print_type(020000000000); | |
44 | /* expect+1: passing 'unsigned int' */ | 44 | /* expect+1: ... passing 'unsigned int' ... */ | |
45 | print_type(0xffffffff); | 45 | print_type(0xffffffff); | |
46 | 46 | |||
47 | /* expect+1: passing 'long' */ | 47 | /* expect+1: ... passing 'long' ... */ | |
48 | print_type(2147483648); | 48 | print_type(2147483648); | |
49 | /* expect+1: passing 'long' */ | 49 | /* expect+1: ... passing 'long' ... */ | |
50 | print_type(0x0000000100000000); | 50 | print_type(0x0000000100000000); | |
51 | /* expect+1: passing 'long' */ | 51 | /* expect+1: ... passing 'long' ... */ | |
52 | print_type(0x7fffffffffffffff); | 52 | print_type(0x7fffffffffffffff); | |
53 | 53 | |||
54 | /* expect+1: passing 'unsigned long' */ | 54 | /* expect+1: ... passing 'unsigned long' ... */ | |
55 | print_type(0x8000000000000000); | 55 | print_type(0x8000000000000000); | |
56 | /* expect+1: passing 'unsigned long' */ | 56 | /* expect+1: ... passing 'unsigned long' ... */ | |
57 | print_type(0xffffffffffffffff); | 57 | print_type(0xffffffffffffffff); | |
58 | 58 | |||
59 | /* expect+2: warning: integer constant out of range [252] */ | 59 | /* expect+2: warning: integer constant out of range [252] */ | |
60 | /* expect+1: warning: passing 'unsigned long' */ | 60 | /* expect+1: ... passing 'unsigned long' ... */ | |
61 | print_type(0x00010000000000000000); | 61 | print_type(0x00010000000000000000); | |
62 | } | 62 | } | |
63 | 63 | |||
64 | void | 64 | void | |
65 | suffix_u(void) | 65 | suffix_u(void) | |
66 | { | 66 | { | |
67 | /* expect+1: passing 'unsigned int' */ | 67 | /* expect+1: ... passing 'unsigned int' ... */ | |
68 | print_type(3U); | 68 | print_type(3U); | |
69 | /* expect+1: passing 'unsigned int' */ | 69 | /* expect+1: ... passing 'unsigned int' ... */ | |
70 | print_type(3u); | 70 | print_type(3u); | |
71 | 71 | |||
72 | /* expect+1: passing 'unsigned int' */ | 72 | /* expect+1: ... passing 'unsigned int' ... */ | |
73 | print_type(4294967295U); | 73 | print_type(4294967295U); | |
74 | /* expect+1: passing 'unsigned long' */ | 74 | /* expect+1: ... passing 'unsigned long' ... */ | |
75 | print_type(4294967296U); | 75 | print_type(4294967296U); | |
76 | } | 76 | } | |
77 | 77 | |||
78 | void | 78 | void | |
79 | suffix_l(void) | 79 | suffix_l(void) | |
80 | { | 80 | { | |
81 | /* expect+1: passing 'long' */ | 81 | /* expect+1: ... passing 'long' ... */ | |
82 | print_type(3L); | 82 | print_type(3L); | |
83 | 83 | |||
84 | /* expect+1: passing 'long' */ | 84 | /* expect+1: ... passing 'long' ... */ | |
85 | print_type(3l); | 85 | print_type(3l); | |
86 | } | 86 | } | |
87 | 87 | |||
88 | void | 88 | void | |
89 | suffix_ul(void) | 89 | suffix_ul(void) | |
90 | { | 90 | { | |
91 | /* expect+1: passing 'unsigned long' */ | 91 | /* expect+1: ... passing 'unsigned long' ... */ | |
92 | print_type(3UL); | 92 | print_type(3UL); | |
93 | /* expect+1: passing 'unsigned long' */ | 93 | /* expect+1: ... passing 'unsigned long' ... */ | |
94 | print_type(3LU); | 94 | print_type(3LU); | |
95 | } | 95 | } | |
96 | 96 | |||
97 | void | 97 | void | |
98 | suffix_ll(void) | 98 | suffix_ll(void) | |
99 | { | 99 | { | |
100 | /* expect+1: passing 'long long' */ | 100 | /* expect+1: ... passing 'long long' ... */ | |
101 | print_type(3LL); | 101 | print_type(3LL); | |
102 | 102 | |||
103 | /* The 'Ll' must not use mixed case. Checked by the compiler. */ | 103 | /* The 'Ll' must not use mixed case. Checked by the compiler. */ | |
104 | /* expect+1: passing 'long long' */ | 104 | /* expect+1: ... passing 'long long' ... */ | |
105 | print_type(3Ll); | 105 | print_type(3Ll); | |
106 | 106 | |||
107 | /* expect+1: passing 'long long' */ | 107 | /* expect+1: ... passing 'long long' ... */ | |
108 | print_type(3ll); | 108 | print_type(3ll); | |
109 | } | 109 | } | |
110 | 110 | |||
111 | void | 111 | void | |
112 | suffix_ull(void) | 112 | suffix_ull(void) | |
113 | { | 113 | { | |
114 | /* expect+1: passing 'unsigned long long' */ | 114 | /* expect+1: ... passing 'unsigned long long' ... */ | |
115 | print_type(3llu); | 115 | print_type(3llu); | |
116 | /* expect+1: passing 'unsigned long long' */ | 116 | /* expect+1: ... passing 'unsigned long long' ... */ | |
117 | print_type(3Ull); | 117 | print_type(3Ull); | |
118 | 118 | |||
119 | /* The 'LL' must not be split. Checked by the compiler. */ | 119 | /* The 'LL' must not be split. Checked by the compiler. */ | |
120 | /* expect+1: passing 'unsigned long long' */ | 120 | /* expect+1: ... passing 'unsigned long long' ... */ | |
121 | print_type(3lul); | 121 | print_type(3lul); | |
122 | 122 | |||
123 | /* The 'Ll' must not use mixed case. Checked by the compiler. */ | 123 | /* The 'Ll' must not use mixed case. Checked by the compiler. */ | |
124 | /* expect+1: passing 'unsigned long long' */ | 124 | /* expect+1: ... passing 'unsigned long long' ... */ | |
125 | print_type(3ULl); | 125 | print_type(3ULl); | |
126 | } | 126 | } | |
127 | 127 | |||
128 | void | 128 | void | |
129 | suffix_too_many(void) | 129 | suffix_too_many(void) | |
130 | { | 130 | { | |
131 | /* expect+2: warning: malformed integer constant [251] */ | 131 | /* expect+2: warning: malformed integer constant [251] */ | |
132 | /* expect+1: passing 'long long' */ | 132 | /* expect+1: ... passing 'long long' ... */ | |
133 | print_type(3LLL); | 133 | print_type(3LLL); | |
134 | 134 | |||
135 | /* expect+2: warning: malformed integer constant [251] */ | 135 | /* expect+2: warning: malformed integer constant [251] */ | |
136 | /* expect+1: passing 'unsigned int' */ | 136 | /* expect+1: ... passing 'unsigned int' ... */ | |
137 | print_type(3uu); | 137 | print_type(3uu); | |
138 | } | 138 | } | |
139 | 139 | |||
140 | /* https://gcc.gnu.org/onlinedocs/gcc/Binary-constants.html */ | 140 | /* https://gcc.gnu.org/onlinedocs/gcc/Binary-constants.html */ | |
141 | void | 141 | void | |
142 | binary_literal(void) | 142 | binary_literal(void) | |
143 | { | 143 | { | |
144 | /* This is a GCC extension, but lint doesn't know that. */ | 144 | /* This is a GCC extension, but lint doesn't know that. */ | |
145 | /* expect+1: passing 'int' */ | 145 | /* expect+1: ... passing 'int' ... */ | |
146 | print_type(0b1111000001011010); | 146 | print_type(0b1111000001011010); | |
147 | 147 | |||
148 | /* expect+1: passing 'unsigned int' */ | 148 | /* expect+1: ... passing 'unsigned int' ... */ | |
149 | print_type(0b11110000111100001111000011110000); | 149 | print_type(0b11110000111100001111000011110000); | |
150 | } | 150 | } |
--- src/tests/usr.bin/xlint/lint1/msg_031.c 2022/06/15 20:18:31 1.7
+++ src/tests/usr.bin/xlint/lint1/msg_031.c 2022/06/17 18:54:53 1.8
@@ -1,21 +1,21 @@ | @@ -1,21 +1,21 @@ | |||
1 | /* $NetBSD: msg_031.c,v 1.7 2022/06/15 20:18:31 rillig Exp $ */ | 1 | /* $NetBSD: msg_031.c,v 1.8 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_031.c" | 2 | # 3 "msg_031.c" | |
3 | 3 | |||
4 | // Test for message: '%s' has incomplete type '%s' [31] | 4 | // Test for message: '%s' has incomplete type '%s' [31] | |
5 | 5 | |||
6 | struct complete { | 6 | struct complete { | |
7 | int dummy; | 7 | int dummy; | |
8 | }; | 8 | }; | |
9 | 9 | |||
10 | /* expect+1: warning: struct 'incomplete' never defined [233] */ | 10 | /* expect+1: warning: struct 'incomplete' never defined [233] */ | |
11 | struct incomplete; | 11 | struct incomplete; | |
12 | 12 | |||
13 | 13 | |||
14 | struct complete complete_var; | 14 | struct complete complete_var; | |
15 | 15 | |||
16 | /* expect+1: 'incomplete_var' has incomplete type 'incomplete struct incomplete' */ | 16 | /* expect+1: error: 'incomplete_var' has incomplete type 'incomplete struct incomplete' [31] */ | |
17 | struct incomplete incomplete_var; | 17 | struct incomplete incomplete_var; | |
18 | 18 | |||
19 | 19 | |||
20 | /* expect+1: '<unnamed>' has incomplete type 'incomplete struct incomplete' [31] */ | 20 | /* expect+1: error: '<unnamed>' has incomplete type 'incomplete struct incomplete' [31] */ | |
21 | void function(struct incomplete); | 21 | void function(struct incomplete); |
--- src/tests/usr.bin/xlint/lint1/msg_259_ilp32.c 2022/04/16 18:41:21 1.7
+++ src/tests/usr.bin/xlint/lint1/msg_259_ilp32.c 2022/06/17 18:54:53 1.8
@@ -1,37 +1,37 @@ | @@ -1,37 +1,37 @@ | |||
1 | /* $NetBSD: msg_259_ilp32.c,v 1.7 2022/04/16 18:41:21 rillig Exp $ */ | 1 | /* $NetBSD: msg_259_ilp32.c,v 1.8 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_259_ilp32.c" | 2 | # 3 "msg_259_ilp32.c" | |
3 | 3 | |||
4 | /* Test for message: argument #%d is converted from '%s' to '%s' due to prototype [259] */ | 4 | /* Test for message: argument #%d is converted from '%s' to '%s' due to prototype [259] */ | |
5 | 5 | |||
6 | /* | 6 | /* | |
7 | * See also msg_259, which contains more examples for this warning. | 7 | * See also msg_259, which contains more examples for this warning. | |
8 | * | 8 | * | |
9 | * See also msg_297, but that requires the flags -a -p -P, which are not | 9 | * See also msg_297, but that requires the flags -a -p -P, which are not | |
10 | * enabled in the default NetBSD build. | 10 | * enabled in the default NetBSD build. | |
11 | */ | 11 | */ | |
12 | 12 | |||
13 | /* lint1-only-if: ilp32 */ | 13 | /* lint1-only-if: ilp32 */ | |
14 | /* lint1-flags: -h -w */ | 14 | /* lint1-flags: -h -w */ | |
15 | 15 | |||
16 | void plain_char(char); | 16 | void plain_char(char); | |
17 | void signed_int(int); | 17 | void signed_int(int); | |
18 | void signed_long(long); | 18 | void signed_long(long); | |
19 | 19 | |||
20 | void | 20 | void | |
21 | example(char c, int i, long l) | 21 | example(char c, int i, long l) | |
22 | { | 22 | { | |
23 | plain_char(c); | 23 | plain_char(c); | |
24 | signed_int(c); | 24 | signed_int(c); | |
25 | /* expect+1: from 'char' to 'long' due to prototype [259] */ | 25 | /* expect+1: ... from 'char' to 'long' due to prototype [259] */ | |
26 | signed_long(c); | 26 | signed_long(c); | |
27 | 27 | |||
28 | plain_char(i); | 28 | plain_char(i); | |
29 | signed_int(i); | 29 | signed_int(i); | |
30 | /* expect+1: from 'int' to 'long' due to prototype [259] */ | 30 | /* expect+1: ... from 'int' to 'long' due to prototype [259] */ | |
31 | signed_long(i); | 31 | signed_long(i); | |
32 | 32 | |||
33 | plain_char(l); | 33 | plain_char(l); | |
34 | /* expect+1: from 'long' to 'int' due to prototype [259] */ | 34 | /* expect+1: ... from 'long' to 'int' due to prototype [259] */ | |
35 | signed_int(l); | 35 | signed_int(l); | |
36 | signed_long(l); | 36 | signed_long(l); | |
37 | } | 37 | } |
--- src/tests/usr.bin/xlint/lint1/msg_193.c 2022/06/16 16:58:36 1.18
+++ src/tests/usr.bin/xlint/lint1/msg_193.c 2022/06/17 18:54:53 1.19
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: msg_193.c,v 1.18 2022/06/16 16:58:36 rillig Exp $ */ | 1 | /* $NetBSD: msg_193.c,v 1.19 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_193.c" | 2 | # 3 "msg_193.c" | |
3 | 3 | |||
4 | // Test for message: statement not reached [193] | 4 | // Test for message: statement not reached [193] | |
5 | 5 | |||
6 | /* | 6 | /* | |
7 | * Test the reachability of statements in a function. | 7 | * Test the reachability of statements in a function. | |
8 | * | 8 | * | |
9 | * if | 9 | * if | |
10 | * if-else | 10 | * if-else | |
11 | * if-else-if-else | 11 | * if-else-if-else | |
12 | * for | 12 | * for | |
13 | * while | 13 | * while | |
14 | * do-while | 14 | * do-while | |
@@ -42,512 +42,512 @@ test_compound_statement(void) | @@ -42,512 +42,512 @@ test_compound_statement(void) | |||
42 | reachable(); | 42 | reachable(); | |
43 | reachable(); | 43 | reachable(); | |
44 | } | 44 | } | |
45 | reachable(); | 45 | reachable(); | |
46 | } | 46 | } | |
47 | 47 | |||
48 | void | 48 | void | |
49 | test_if_statement(void) | 49 | test_if_statement(void) | |
50 | { | 50 | { | |
51 | if (1) | 51 | if (1) | |
52 | reachable(); | 52 | reachable(); | |
53 | reachable(); | 53 | reachable(); | |
54 | if (0) | 54 | if (0) | |
55 | unreachable(); /* expect+0: 193 */ | 55 | unreachable(); /* expect+0: ... [193] */ | |
56 | reachable(); | 56 | reachable(); | |
57 | } | 57 | } | |
58 | 58 | |||
59 | void | 59 | void | |
60 | test_if_compound_statement(void) | 60 | test_if_compound_statement(void) | |
61 | { | 61 | { | |
62 | if (1) { | 62 | if (1) { | |
63 | reachable(); | 63 | reachable(); | |
64 | } | 64 | } | |
65 | if (1) { | 65 | if (1) { | |
66 | { | 66 | { | |
67 | { | 67 | { | |
68 | reachable(); | 68 | reachable(); | |
69 | } | 69 | } | |
70 | } | 70 | } | |
71 | } | 71 | } | |
72 | 72 | |||
73 | if (0) { | 73 | if (0) { | |
74 | unreachable(); /* expect+0: 193 */ | 74 | unreachable(); /* expect+0: ... [193] */ | |
75 | } | 75 | } | |
76 | if (0) { | 76 | if (0) { | |
77 | { | 77 | { | |
78 | { | 78 | { | |
79 | unreachable(); /* expect+0: 193 */ | 79 | unreachable(); /* expect+0: ... [193] */ | |
80 | } | 80 | } | |
81 | } | 81 | } | |
82 | } | 82 | } | |
83 | } | 83 | } | |
84 | 84 | |||
85 | void | 85 | void | |
86 | test_if_without_else(void) | 86 | test_if_without_else(void) | |
87 | { | 87 | { | |
88 | if (1) | 88 | if (1) | |
89 | reachable(); | 89 | reachable(); | |
90 | reachable(); | 90 | reachable(); | |
91 | 91 | |||
92 | if (0) | 92 | if (0) | |
93 | unreachable(); /* expect+0: 193 */ | 93 | unreachable(); /* expect+0: ... [193] */ | |
94 | reachable(); | 94 | reachable(); | |
95 | } | 95 | } | |
96 | 96 | |||
97 | void | 97 | void | |
98 | test_if_with_else(void) | 98 | test_if_with_else(void) | |
99 | { | 99 | { | |
100 | if (1) | 100 | if (1) | |
101 | reachable(); | 101 | reachable(); | |
102 | else | 102 | else | |
103 | unreachable(); /* expect+0: 193 */ | 103 | unreachable(); /* expect+0: ... [193] */ | |
104 | reachable(); | 104 | reachable(); | |
105 | 105 | |||
106 | if (0) | 106 | if (0) | |
107 | unreachable(); /* expect+0: 193 */ | 107 | unreachable(); /* expect+0: ... [193] */ | |
108 | else | 108 | else | |
109 | reachable(); | 109 | reachable(); | |
110 | reachable(); | 110 | reachable(); | |
111 | } | 111 | } | |
112 | 112 | |||
113 | void | 113 | void | |
114 | test_if_else_if_else(void) | 114 | test_if_else_if_else(void) | |
115 | { | 115 | { | |
116 | if (1) | 116 | if (1) | |
117 | reachable(); | 117 | reachable(); | |
118 | else if (1) /* expect+0: 193 */ | 118 | else if (1) /* expect+0: ... [193] */ | |
119 | unreachable(); | 119 | unreachable(); | |
120 | else | 120 | else | |
121 | unreachable(); /* expect+0: 193 */ | 121 | unreachable(); /* expect+0: ... [193] */ | |
122 | 122 | |||
123 | if (0) | 123 | if (0) | |
124 | unreachable(); /* expect+0: 193 */ | 124 | unreachable(); /* expect+0: ... [193] */ | |
125 | else if (1) | 125 | else if (1) | |
126 | reachable(); | 126 | reachable(); | |
127 | else | 127 | else | |
128 | unreachable(); /* expect+0: 193 */ | 128 | unreachable(); /* expect+0: ... [193] */ | |
129 | 129 | |||
130 | if (0) | 130 | if (0) | |
131 | unreachable(); /* expect+0: 193 */ | 131 | unreachable(); /* expect+0: ... [193] */ | |
132 | else if (0) | 132 | else if (0) | |
133 | unreachable(); /* expect+0: 193 */ | 133 | unreachable(); /* expect+0: ... [193] */ | |
134 | else | 134 | else | |
135 | reachable(); | 135 | reachable(); | |
136 | } | 136 | } | |
137 | 137 | |||
138 | void | 138 | void | |
139 | test_if_return(void) | 139 | test_if_return(void) | |
140 | { | 140 | { | |
141 | if (1) | 141 | if (1) | |
142 | return; | 142 | return; | |
143 | unreachable(); /* expect+0: 193 */ | 143 | unreachable(); /* expect+0: ... [193] */ | |
144 | } | 144 | } | |
145 | 145 | |||
146 | void | 146 | void | |
147 | test_if_else_return(void) | 147 | test_if_else_return(void) | |
148 | { | 148 | { | |
149 | if (1) | 149 | if (1) | |
150 | reachable(); | 150 | reachable(); | |
151 | else | 151 | else | |
152 | return; /* expect+0: 193 */ | 152 | return; /* expect+0: ... [193] */ | |
153 | reachable(); | 153 | reachable(); | |
154 | } | 154 | } | |
155 | 155 | |||
156 | void | 156 | void | |
157 | test_for_forever(void) | 157 | test_for_forever(void) | |
158 | { | 158 | { | |
159 | for (;;) | 159 | for (;;) | |
160 | reachable(); | 160 | reachable(); | |
161 | unreachable(); /* expect+0: 193 */ | 161 | unreachable(); /* expect+0: ... [193] */ | |
162 | } | 162 | } | |
163 | 163 | |||
164 | void | 164 | void | |
165 | test_for_true(void) | 165 | test_for_true(void) | |
166 | { | 166 | { | |
167 | for (; 1;) | 167 | for (; 1;) | |
168 | reachable(); | 168 | reachable(); | |
169 | unreachable(); /* expect+0: 193 */ | 169 | unreachable(); /* expect+0: ... [193] */ | |
170 | } | 170 | } | |
171 | 171 | |||
172 | void | 172 | void | |
173 | test_for_false(void) | 173 | test_for_false(void) | |
174 | { | 174 | { | |
175 | for (; 0;) | 175 | for (; 0;) | |
176 | unreachable(); /* expect+0: 193 */ | 176 | unreachable(); /* expect+0: ... [193] */ | |
177 | reachable(); | 177 | reachable(); | |
178 | } | 178 | } | |
179 | 179 | |||
180 | void | 180 | void | |
181 | test_for_break(void) | 181 | test_for_break(void) | |
182 | { | 182 | { | |
183 | for (;;) { | 183 | for (;;) { | |
184 | reachable(); | 184 | reachable(); | |
185 | break; | 185 | break; | |
186 | unreachable(); /* expect+0: 193 */ | 186 | unreachable(); /* expect+0: ... [193] */ | |
187 | } | 187 | } | |
188 | reachable(); | 188 | reachable(); | |
189 | } | 189 | } | |
190 | 190 | |||
191 | void | 191 | void | |
192 | test_for_if_break(void) | 192 | test_for_if_break(void) | |
193 | { | 193 | { | |
194 | for (;;) { | 194 | for (;;) { | |
195 | reachable(); | 195 | reachable(); | |
196 | if (0) { | 196 | if (0) { | |
197 | unreachable(); /* expect+0: 193 */ | 197 | unreachable(); /* expect+0: ... [193] */ | |
198 | break; | 198 | break; | |
199 | unreachable(); /* expect+0: 193 */ | 199 | unreachable(); /* expect+0: ... [193] */ | |
200 | } | 200 | } | |
201 | if (1) { | 201 | if (1) { | |
202 | reachable(); | 202 | reachable(); | |
203 | break; | 203 | break; | |
204 | unreachable(); /* expect+0: 193 */ | 204 | unreachable(); /* expect+0: ... [193] */ | |
205 | } | 205 | } | |
206 | unreachable(); /* expect+0: 193 */ | 206 | unreachable(); /* expect+0: ... [193] */ | |
207 | } | 207 | } | |
208 | reachable(); | 208 | reachable(); | |
209 | } | 209 | } | |
210 | 210 | |||
211 | void | 211 | void | |
212 | test_for_continue(void) | 212 | test_for_continue(void) | |
213 | { | 213 | { | |
214 | for (;;) { | 214 | for (;;) { | |
215 | reachable(); | 215 | reachable(); | |
216 | continue; | 216 | continue; | |
217 | unreachable(); /* expect+0: 193 */ | 217 | unreachable(); /* expect+0: ... [193] */ | |
218 | } | 218 | } | |
219 | unreachable(); /* expect+0: 193 */ | 219 | unreachable(); /* expect+0: ... [193] */ | |
220 | } | 220 | } | |
221 | 221 | |||
222 | void | 222 | void | |
223 | test_for_if_continue(void) | 223 | test_for_if_continue(void) | |
224 | { | 224 | { | |
225 | for (;;) { | 225 | for (;;) { | |
226 | reachable(); | 226 | reachable(); | |
227 | if (0) { | 227 | if (0) { | |
228 | unreachable(); /* expect+0: 193 */ | 228 | unreachable(); /* expect+0: ... [193] */ | |
229 | continue; | 229 | continue; | |
230 | unreachable(); /* expect+0: 193 */ | 230 | unreachable(); /* expect+0: ... [193] */ | |
231 | } | 231 | } | |
232 | if (1) { | 232 | if (1) { | |
233 | reachable(); | 233 | reachable(); | |
234 | continue; | 234 | continue; | |
235 | unreachable(); /* expect+0: 193 */ | 235 | unreachable(); /* expect+0: ... [193] */ | |
236 | } | 236 | } | |
237 | unreachable(); /* expect+0: 193 */ | 237 | unreachable(); /* expect+0: ... [193] */ | |
238 | } | 238 | } | |
239 | unreachable(); /* expect+0: 193 */ | 239 | unreachable(); /* expect+0: ... [193] */ | |
240 | } | 240 | } | |
241 | 241 | |||
242 | void | 242 | void | |
243 | test_for_return(void) | 243 | test_for_return(void) | |
244 | { | 244 | { | |
245 | for (;;) { | 245 | for (;;) { | |
246 | reachable(); | 246 | reachable(); | |
247 | return; | 247 | return; | |
248 | unreachable(); /* expect+0: 193 */ | 248 | unreachable(); /* expect+0: ... [193] */ | |
249 | } | 249 | } | |
250 | unreachable(); /* expect+0: 193 */ | 250 | unreachable(); /* expect+0: ... [193] */ | |
251 | } | 251 | } | |
252 | 252 | |||
253 | void | 253 | void | |
254 | test_for_if_return(void) | 254 | test_for_if_return(void) | |
255 | { | 255 | { | |
256 | for (;;) { | 256 | for (;;) { | |
257 | reachable(); | 257 | reachable(); | |
258 | if (0) { | 258 | if (0) { | |
259 | unreachable(); /* expect+0: 193 */ | 259 | unreachable(); /* expect+0: ... [193] */ | |
260 | return; | 260 | return; | |
261 | unreachable(); /* expect+0: 193 */ | 261 | unreachable(); /* expect+0: ... [193] */ | |
262 | } | 262 | } | |
263 | if (1) { | 263 | if (1) { | |
264 | reachable(); | 264 | reachable(); | |
265 | return; | 265 | return; | |
266 | unreachable(); /* expect+0: 193 */ | 266 | unreachable(); /* expect+0: ... [193] */ | |
267 | } | 267 | } | |
268 | unreachable(); /* expect+0: 193 */ | 268 | unreachable(); /* expect+0: ... [193] */ | |
269 | } | 269 | } | |
270 | unreachable(); /* expect+0: 193 */ | 270 | unreachable(); /* expect+0: ... [193] */ | |
271 | } | 271 | } | |
272 | 272 | |||
273 | void | 273 | void | |
274 | test_while_true(void) | 274 | test_while_true(void) | |
275 | { | 275 | { | |
276 | while (1) | 276 | while (1) | |
277 | reachable(); | 277 | reachable(); | |
278 | unreachable(); /* expect+0: 193 */ | 278 | unreachable(); /* expect+0: ... [193] */ | |
279 | } | 279 | } | |
280 | 280 | |||
281 | void | 281 | void | |
282 | test_while_false(void) | 282 | test_while_false(void) | |
283 | { | 283 | { | |
284 | while (0) | 284 | while (0) | |
285 | unreachable(); /* expect+0: 193 */ | 285 | unreachable(); /* expect+0: ... [193] */ | |
286 | reachable(); | 286 | reachable(); | |
287 | } | 287 | } | |
288 | 288 | |||
289 | void | 289 | void | |
290 | test_while_break(void) | 290 | test_while_break(void) | |
291 | { | 291 | { | |
292 | while (1) { | 292 | while (1) { | |
293 | reachable(); | 293 | reachable(); | |
294 | break; | 294 | break; | |
295 | unreachable(); /* expect+0: 193 */ | 295 | unreachable(); /* expect+0: ... [193] */ | |
296 | } | 296 | } | |
297 | reachable(); | 297 | reachable(); | |
298 | } | 298 | } | |
299 | 299 | |||
300 | void | 300 | void | |
301 | test_while_if_break(void) | 301 | test_while_if_break(void) | |
302 | { | 302 | { | |
303 | while (1) { | 303 | while (1) { | |
304 | reachable(); | 304 | reachable(); | |
305 | if (0) { | 305 | if (0) { | |
306 | unreachable(); /* expect+0: 193 */ | 306 | unreachable(); /* expect+0: ... [193] */ | |
307 | break; | 307 | break; | |
308 | unreachable(); /* expect+0: 193 */ | 308 | unreachable(); /* expect+0: ... [193] */ | |
309 | } | 309 | } | |
310 | if (1) { | 310 | if (1) { | |
311 | reachable(); | 311 | reachable(); | |
312 | break; | 312 | break; | |
313 | unreachable(); /* expect+0: 193 */ | 313 | unreachable(); /* expect+0: ... [193] */ | |
314 | } | 314 | } | |
315 | unreachable(); /* expect+0: 193 */ | 315 | unreachable(); /* expect+0: ... [193] */ | |
316 | } | 316 | } | |
317 | reachable(); | 317 | reachable(); | |
318 | } | 318 | } | |
319 | 319 | |||
320 | void | 320 | void | |
321 | test_while_continue(void) | 321 | test_while_continue(void) | |
322 | { | 322 | { | |
323 | while (1) { | 323 | while (1) { | |
324 | reachable(); | 324 | reachable(); | |
325 | continue; | 325 | continue; | |
326 | unreachable(); /* expect+0: 193 */ | 326 | unreachable(); /* expect+0: ... [193] */ | |
327 | } | 327 | } | |
328 | unreachable(); /* expect+0: 193 */ | 328 | unreachable(); /* expect+0: ... [193] */ | |
329 | } | 329 | } | |
330 | 330 | |||
331 | void | 331 | void | |
332 | test_while_if_continue(void) | 332 | test_while_if_continue(void) | |
333 | { | 333 | { | |
334 | while (1) { | 334 | while (1) { | |
335 | reachable(); | 335 | reachable(); | |
336 | if (0) { | 336 | if (0) { | |
337 | unreachable(); /* expect+0: 193 */ | 337 | unreachable(); /* expect+0: ... [193] */ | |
338 | continue; | 338 | continue; | |
339 | unreachable(); /* expect+0: 193 */ | 339 | unreachable(); /* expect+0: ... [193] */ | |
340 | } | 340 | } | |
341 | if (1) { | 341 | if (1) { | |
342 | reachable(); | 342 | reachable(); | |
343 | continue; | 343 | continue; | |
344 | unreachable(); /* expect+0: 193 */ | 344 | unreachable(); /* expect+0: ... [193] */ | |
345 | } | 345 | } | |
346 | unreachable(); /* expect+0: 193 */ | 346 | unreachable(); /* expect+0: ... [193] */ | |
347 | } | 347 | } | |
348 | unreachable(); /* expect+0: 193 */ | 348 | unreachable(); /* expect+0: ... [193] */ | |
349 | } | 349 | } | |
350 | 350 | |||
351 | void | 351 | void | |
352 | test_while_return(void) | 352 | test_while_return(void) | |
353 | { | 353 | { | |
354 | while (1) { | 354 | while (1) { | |
355 | reachable(); | 355 | reachable(); | |
356 | return; | 356 | return; | |
357 | unreachable(); /* expect+0: 193 */ | 357 | unreachable(); /* expect+0: ... [193] */ | |
358 | } | 358 | } | |
359 | unreachable(); /* expect+0: 193 */ | 359 | unreachable(); /* expect+0: ... [193] */ | |
360 | } | 360 | } | |
361 | 361 | |||
362 | void | 362 | void | |
363 | test_while_if_return(void) | 363 | test_while_if_return(void) | |
364 | { | 364 | { | |
365 | while (1) { | 365 | while (1) { | |
366 | reachable(); | 366 | reachable(); | |
367 | if (0) { | 367 | if (0) { | |
368 | unreachable(); /* expect+0: 193 */ | 368 | unreachable(); /* expect+0: ... [193] */ | |
369 | return; | 369 | return; | |
370 | unreachable(); /* expect+0: 193 */ | 370 | unreachable(); /* expect+0: ... [193] */ | |
371 | } | 371 | } | |
372 | if (1) { | 372 | if (1) { | |
373 | reachable(); | 373 | reachable(); | |
374 | return; | 374 | return; | |
375 | unreachable(); /* expect+0: 193 */ | 375 | unreachable(); /* expect+0: ... [193] */ | |
376 | } | 376 | } | |
377 | unreachable(); /* expect+0: 193 */ | 377 | unreachable(); /* expect+0: ... [193] */ | |
378 | } | 378 | } | |
379 | unreachable(); /* expect+0: 193 */ | 379 | unreachable(); /* expect+0: ... [193] */ | |
380 | } | 380 | } | |
381 | 381 | |||
382 | void | 382 | void | |
383 | test_do_while_true(void) | 383 | test_do_while_true(void) | |
384 | { | 384 | { | |
385 | do { | 385 | do { | |
386 | reachable(); | 386 | reachable(); | |
387 | } while (1); | 387 | } while (1); | |
388 | unreachable(); /* expect+0: 193 */ | 388 | unreachable(); /* expect+0: ... [193] */ | |
389 | } | 389 | } | |
390 | 390 | |||
391 | void | 391 | void | |
392 | test_do_while_false(void) | 392 | test_do_while_false(void) | |
393 | { | 393 | { | |
394 | do { | 394 | do { | |
395 | reachable(); | 395 | reachable(); | |
396 | } while (0); | 396 | } while (0); | |
397 | reachable(); | 397 | reachable(); | |
398 | } | 398 | } | |
399 | 399 | |||
400 | void | 400 | void | |
401 | test_do_while_break(void) | 401 | test_do_while_break(void) | |
402 | { | 402 | { | |
403 | do { | 403 | do { | |
404 | reachable(); | 404 | reachable(); | |
405 | break; | 405 | break; | |
406 | unreachable(); /* expect+0: 193 */ | 406 | unreachable(); /* expect+0: ... [193] */ | |
407 | } while (1); | 407 | } while (1); | |
408 | reachable(); | 408 | reachable(); | |
409 | } | 409 | } | |
410 | 410 | |||
411 | void | 411 | void | |
412 | test_do_while_if_break(void) | 412 | test_do_while_if_break(void) | |
413 | { | 413 | { | |
414 | do { | 414 | do { | |
415 | reachable(); | 415 | reachable(); | |
416 | if (0) { | 416 | if (0) { | |
417 | unreachable(); /* expect+0: 193 */ | 417 | unreachable(); /* expect+0: ... [193] */ | |
418 | break; | 418 | break; | |
419 | unreachable(); /* expect+0: 193 */ | 419 | unreachable(); /* expect+0: ... [193] */ | |
420 | } | 420 | } | |
421 | if (1) { | 421 | if (1) { | |
422 | reachable(); | 422 | reachable(); | |
423 | break; | 423 | break; | |
424 | unreachable(); /* expect+0: 193 */ | 424 | unreachable(); /* expect+0: ... [193] */ | |
425 | } | 425 | } | |
426 | unreachable(); /* expect+0: 193 */ | 426 | unreachable(); /* expect+0: ... [193] */ | |
427 | } while (1); | 427 | } while (1); | |
428 | reachable(); | 428 | reachable(); | |
429 | } | 429 | } | |
430 | 430 | |||
431 | void | 431 | void | |
432 | test_do_while_continue(void) | 432 | test_do_while_continue(void) | |
433 | { | 433 | { | |
434 | do { | 434 | do { | |
435 | reachable(); | 435 | reachable(); | |
436 | continue; | 436 | continue; | |
437 | unreachable(); /* expect+0: 193 */ | 437 | unreachable(); /* expect+0: ... [193] */ | |
438 | } while (1); | 438 | } while (1); | |
439 | unreachable(); /* expect+0: 193 */ | 439 | unreachable(); /* expect+0: ... [193] */ | |
440 | } | 440 | } | |
441 | 441 | |||
442 | void | 442 | void | |
443 | test_do_while_if_continue(void) | 443 | test_do_while_if_continue(void) | |
444 | { | 444 | { | |
445 | do { | 445 | do { | |
446 | reachable(); | 446 | reachable(); | |
447 | if (0) { | 447 | if (0) { | |
448 | unreachable(); /* expect+0: 193 */ | 448 | unreachable(); /* expect+0: ... [193] */ | |
449 | continue; | 449 | continue; | |
450 | unreachable(); /* expect+0: 193 */ | 450 | unreachable(); /* expect+0: ... [193] */ | |
451 | } | 451 | } | |
452 | if (1) { | 452 | if (1) { | |
453 | reachable(); | 453 | reachable(); | |
454 | continue; | 454 | continue; | |
455 | unreachable(); /* expect+0: 193 */ | 455 | unreachable(); /* expect+0: ... [193] */ | |
456 | } | 456 | } | |
457 | unreachable(); /* expect+0: 193 */ | 457 | unreachable(); /* expect+0: ... [193] */ | |
458 | } while (1); | 458 | } while (1); | |
459 | unreachable(); /* expect+0: 193 */ | 459 | unreachable(); /* expect+0: ... [193] */ | |
460 | } | 460 | } | |
461 | 461 | |||
462 | void | 462 | void | |
463 | test_do_while_return(void) | 463 | test_do_while_return(void) | |
464 | { | 464 | { | |
465 | do { | 465 | do { | |
466 | reachable(); | 466 | reachable(); | |
467 | return; | 467 | return; | |
468 | unreachable(); /* expect+0: 193 */ | 468 | unreachable(); /* expect+0: ... [193] */ | |
469 | } while (1); | 469 | } while (1); | |
470 | unreachable(); /* expect+0: 193 */ | 470 | unreachable(); /* expect+0: ... [193] */ | |
471 | } | 471 | } | |
472 | 472 | |||
473 | void | 473 | void | |
474 | test_do_while_if_return(void) | 474 | test_do_while_if_return(void) | |
475 | { | 475 | { | |
476 | do { | 476 | do { | |
477 | reachable(); | 477 | reachable(); | |
478 | if (0) { | 478 | if (0) { | |
479 | unreachable(); /* expect+0: 193 */ | 479 | unreachable(); /* expect+0: ... [193] */ | |
480 | return; | 480 | return; | |
481 | unreachable(); /* expect+0: 193 */ | 481 | unreachable(); /* expect+0: ... [193] */ | |
482 | } | 482 | } | |
483 | if (1) { | 483 | if (1) { | |
484 | reachable(); | 484 | reachable(); | |
485 | return; | 485 | return; | |
486 | unreachable(); /* expect+0: 193 */ | 486 | unreachable(); /* expect+0: ... [193] */ | |
487 | } | 487 | } | |
488 | unreachable(); /* expect+0: 193 */ | 488 | unreachable(); /* expect+0: ... [193] */ | |
489 | } while (1); | 489 | } while (1); | |
490 | unreachable(); /* expect+0: 193 */ | 490 | unreachable(); /* expect+0: ... [193] */ | |
491 | } | 491 | } | |
492 | 492 | |||
493 | void | 493 | void | |
494 | test_if_nested(void) | 494 | test_if_nested(void) | |
495 | { | 495 | { | |
496 | if (0) { | 496 | if (0) { | |
497 | if (1) /* expect+0: 193 */ | 497 | if (1) /* expect+0: ... [193] */ | |
498 | unreachable(); | 498 | unreachable(); | |
499 | else | 499 | else | |
500 | unreachable(); /* expect+0: 193 *//* XXX: redundant */ | 500 | unreachable(); /* expect+0: ... [193] *//* XXX: redundant */ | |
501 | 501 | |||
502 | if (0) | 502 | if (0) | |
503 | unreachable(); /* expect+0: 193 *//* XXX: redundant */ | 503 | unreachable(); /* expect+0: ... [193] *//* XXX: redundant */ | |
504 | else | 504 | else | |
505 | unreachable(); | 505 | unreachable(); | |
506 | 506 | |||
507 | unreachable(); | 507 | unreachable(); | |
508 | } | 508 | } | |
509 | reachable(); | 509 | reachable(); | |
510 | 510 | |||
511 | if (1) { | 511 | if (1) { | |
512 | if (1) | 512 | if (1) | |
513 | reachable(); | 513 | reachable(); | |
514 | else | 514 | else | |
515 | unreachable(); /* expect+0: 193 */ | 515 | unreachable(); /* expect+0: ... [193] */ | |
516 | 516 | |||
517 | if (0) | 517 | if (0) | |
518 | unreachable(); /* expect+0: 193 */ | 518 | unreachable(); /* expect+0: ... [193] */ | |
519 | else | 519 | else | |
520 | reachable(); | 520 | reachable(); | |
521 | 521 | |||
522 | reachable(); | 522 | reachable(); | |
523 | } | 523 | } | |
524 | reachable(); | 524 | reachable(); | |
525 | } | 525 | } | |
526 | 526 | |||
527 | void | 527 | void | |
528 | test_if_maybe(void) | 528 | test_if_maybe(void) | |
529 | { | 529 | { | |
530 | if (maybe()) { | 530 | if (maybe()) { | |
531 | if (0) | 531 | if (0) | |
532 | unreachable(); /* expect+0: 193 */ | 532 | unreachable(); /* expect+0: ... [193] */ | |
533 | else | 533 | else | |
534 | reachable(); | 534 | reachable(); | |
535 | reachable(); | 535 | reachable(); | |
536 | } | 536 | } | |
537 | reachable(); | 537 | reachable(); | |
538 | 538 | |||
539 | if (0) { | 539 | if (0) { | |
540 | if (maybe()) /* expect+0: 193 */ | 540 | if (maybe()) /* expect+0: ... [193] */ | |
541 | unreachable(); | 541 | unreachable(); | |
542 | else | 542 | else | |
543 | unreachable(); | 543 | unreachable(); | |
544 | unreachable(); | 544 | unreachable(); | |
545 | } | 545 | } | |
546 | reachable(); | 546 | reachable(); | |
547 | 547 | |||
548 | if (1) { | 548 | if (1) { | |
549 | if (maybe()) | 549 | if (maybe()) | |
550 | reachable(); | 550 | reachable(); | |
551 | else | 551 | else | |
552 | reachable(); | 552 | reachable(); | |
553 | reachable(); | 553 | reachable(); | |
@@ -585,36 +585,36 @@ ten: | @@ -585,36 +585,36 @@ ten: | |||
585 | three: | 585 | three: | |
586 | goto four; | 586 | goto four; | |
587 | two: | 587 | two: | |
588 | goto three; | 588 | goto three; | |
589 | } | 589 | } | |
590 | 590 | |||
591 | void | 591 | void | |
592 | test_while_goto(void) | 592 | test_while_goto(void) | |
593 | { | 593 | { | |
594 | while (1) { | 594 | while (1) { | |
595 | goto out; | 595 | goto out; | |
596 | break; /* lint only warns with the -b option */ | 596 | break; /* lint only warns with the -b option */ | |
597 | } | 597 | } | |
598 | unreachable(); /* expect+0: 193 */ | 598 | unreachable(); /* expect+0: ... [193] */ | |
599 | out: | 599 | out: | |
600 | reachable(); | 600 | reachable(); | |
601 | } | 601 | } | |
602 | 602 | |||
603 | void | 603 | void | |
604 | test_unreachable_label(void) | 604 | test_unreachable_label(void) | |
605 | { | 605 | { | |
606 | if (0) | 606 | if (0) | |
607 | goto unreachable; /* expect+0: 193 */ | 607 | goto unreachable; /* expect+0: ... [193] */ | |
608 | goto reachable; | 608 | goto reachable; | |
609 | 609 | |||
610 | /* named_label assumes that any label is reachable. */ | 610 | /* named_label assumes that any label is reachable. */ | |
611 | unreachable: | 611 | unreachable: | |
612 | unreachable(); | 612 | unreachable(); | |
613 | reachable: | 613 | reachable: | |
614 | reachable(); | 614 | reachable(); | |
615 | } | 615 | } | |
616 | 616 | |||
617 | /* TODO: switch */ | 617 | /* TODO: switch */ | |
618 | 618 | |||
619 | /* TODO: system-dependent constant expression (see tn_system_dependent) */ | 619 | /* TODO: system-dependent constant expression (see tn_system_dependent) */ | |
620 | 620 |
--- src/tests/usr.bin/xlint/lint1/msg_259.c 2022/04/15 21:50:07 1.20
+++ src/tests/usr.bin/xlint/lint1/msg_259.c 2022/06/17 18:54:53 1.21
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: msg_259.c,v 1.20 2022/04/15 21:50:07 rillig Exp $ */ | 1 | /* $NetBSD: msg_259.c,v 1.21 2022/06/17 18:54:53 rillig Exp $ */ | |
2 | # 3 "msg_259.c" | 2 | # 3 "msg_259.c" | |
3 | 3 | |||
4 | // Test for message: argument #%d is converted from '%s' to '%s' due to prototype [259] | 4 | // Test for message: argument #%d is converted from '%s' to '%s' due to prototype [259] | |
5 | 5 | |||
6 | /* | 6 | /* | |
7 | * This warning detects function calls that are translated in very different | 7 | * This warning detects function calls that are translated in very different | |
8 | * translation environments, one where prototypes are omitted, and one where | 8 | * translation environments, one where prototypes are omitted, and one where | |
9 | * prototypes are active. It is possible to make such code interoperable, | 9 | * prototypes are active. It is possible to make such code interoperable, | |
10 | * but that requires that each argument is converted to its proper type by | 10 | * but that requires that each argument is converted to its proper type by | |
11 | * the caller of the function. | 11 | * the caller of the function. | |
12 | * | 12 | * | |
13 | * When lint is run with the '-s' flag, it no longer warns about code with | 13 | * When lint is run with the '-s' flag, it no longer warns about code with | |
14 | * incompatibilities between traditional C and C90, therefore this test omits | 14 | * incompatibilities between traditional C and C90, therefore this test omits | |
@@ -38,27 +38,27 @@ void | @@ -38,27 +38,27 @@ void | |||
38 | change_in_type_width(char c, int i, long l) | 38 | change_in_type_width(char c, int i, long l) | |
39 | { | 39 | { | |
40 | plain_char(c); | 40 | plain_char(c); | |
41 | signed_int(c); | 41 | signed_int(c); | |
42 | /* No warning 259 on LP64, only on ILP32 */ | 42 | /* No warning 259 on LP64, only on ILP32 */ | |
43 | signed_long(c); | 43 | signed_long(c); | |
44 | 44 | |||
45 | plain_char(i); /* XXX: why no warning? */ | 45 | plain_char(i); /* XXX: why no warning? */ | |
46 | signed_int(i); | 46 | signed_int(i); | |
47 | /* No warning 259 on LP64, only on ILP32 */ | 47 | /* No warning 259 on LP64, only on ILP32 */ | |
48 | signed_long(i); | 48 | signed_long(i); | |
49 | 49 | |||
50 | plain_char(l); /* XXX: why no warning? */ | 50 | plain_char(l); /* XXX: why no warning? */ | |
51 | /* expect+1: from 'long' to 'int' due to prototype [259] */ | 51 | /* expect+1: ... from 'long' to 'int' due to prototype [259] */ | |
52 | signed_int(l); | 52 | signed_int(l); | |
53 | signed_long(l); | 53 | signed_long(l); | |
54 | } | 54 | } | |
55 | 55 | |||
56 | /* | 56 | /* | |
57 | * Converting a signed integer type to its corresponding unsigned integer | 57 | * Converting a signed integer type to its corresponding unsigned integer | |
58 | * type (C99 6.2.5p6) is usually not a problem since the actual values of the | 58 | * type (C99 6.2.5p6) is usually not a problem since the actual values of the | |
59 | * expressions are usually not anywhere near the maximum signed value. From | 59 | * expressions are usually not anywhere near the maximum signed value. From | |
60 | * a technical standpoint, it is correct to warn here since even small | 60 | * a technical standpoint, it is correct to warn here since even small | |
61 | * negative numbers may result in very large positive numbers. | 61 | * negative numbers may result in very large positive numbers. | |
62 | * | 62 | * | |
63 | * A common case where it occurs is when the difference of two pointers is | 63 | * A common case where it occurs is when the difference of two pointers is | |
64 | * converted to size_t. The type ptrdiff_t is defined to be signed, but in | 64 | * converted to size_t. The type ptrdiff_t is defined to be signed, but in |
--- src/usr.bin/xlint/lint1/README.md 2022/06/15 18:11:02 1.5
+++ src/usr.bin/xlint/lint1/README.md 2022/06/17 18:54:53 1.6
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | [//]: # ($NetBSD: README.md,v 1.5 2022/06/15 18:11:02 rillig Exp $) | 1 | [//]: # ($NetBSD: README.md,v 1.6 2022/06/17 18:54:53 rillig Exp $) | |
2 | 2 | |||
3 | # Introduction | 3 | # Introduction | |
4 | 4 | |||
5 | Lint1 analyzes a single translation unit of C code. | 5 | Lint1 analyzes a single translation unit of C code. | |
6 | 6 | |||
7 | * It reads the output of the C preprocessor, comments are retained. | 7 | * It reads the output of the C preprocessor, comments are retained. | |
8 | * The lexer in `scan.l` and `lex.c` splits the input into tokens. | 8 | * The lexer in `scan.l` and `lex.c` splits the input into tokens. | |
9 | * The parser in `cgram.y` creates types and expressions from the tokens. | 9 | * The parser in `cgram.y` creates types and expressions from the tokens. | |
10 | * It checks declarations in `decl.c`. | 10 | * It checks declarations in `decl.c`. | |
11 | * It checks initializations in `init.c`. | 11 | * It checks initializations in `init.c`. | |
12 | * It checks types and expressions in `tree.c`. | 12 | * It checks types and expressions in `tree.c`. | |
13 | 13 | |||
14 | To see how a specific lint message is triggered, read the corresponding unit | 14 | To see how a specific lint message is triggered, read the corresponding unit | |
@@ -150,26 +150,28 @@ By default, each test is run with the li | @@ -150,26 +150,28 @@ By default, each test is run with the li | |||
150 | `-S` for C99 mode and `-w` to report warnings as errors. | 150 | `-S` for C99 mode and `-w` to report warnings as errors. | |
151 | 151 | |||
152 | Each test can override the lint flags using comments of the following forms: | 152 | Each test can override the lint flags using comments of the following forms: | |
153 | 153 | |||
154 | * `/* lint1-flags: -tw */` replaces the default flags. | 154 | * `/* lint1-flags: -tw */` replaces the default flags. | |
155 | * `/* lint1-extra-flags: -p */` adds to the default flags. | 155 | * `/* lint1-extra-flags: -p */` adds to the default flags. | |
156 | 156 | |||
157 | Most tests check the diagnostics that lint generates. | 157 | Most tests check the diagnostics that lint generates. | |
158 | They do this by placing `expect` comments near the location of the diagnostic. | 158 | They do this by placing `expect` comments near the location of the diagnostic. | |
159 | The comment `/* expect+1: ... */` expects a diagnostic to be generated for the | 159 | The comment `/* expect+1: ... */` expects a diagnostic to be generated for the | |
160 | code 1 line below, `/* expect-5: ... */` expects a diagnostic to be generated | 160 | code 1 line below, `/* expect-5: ... */` expects a diagnostic to be generated | |
161 | for the code 5 lines above. | 161 | for the code 5 lines above. | |
162 | Each `expect` comment must be in a single line. | 162 | Each `expect` comment must be in a single line. | |
163 | There may be other code or comments in the same line. | 163 | At the start and the end of the comment, the placeholder `...` stands for an | |
164 | arbitrary sequence of characters. | |||
165 | There may be other code or comments in the same line of the `.c` file. | |||
164 | 166 | |||
165 | Each diagnostic has its own test `msg_???.c` that triggers the corresponding | 167 | Each diagnostic has its own test `msg_???.c` that triggers the corresponding | |
166 | diagnostic. | 168 | diagnostic. | |
167 | Most other tests focus on a single feature. | 169 | Most other tests focus on a single feature. | |
168 | 170 | |||
169 | ## Adding a new test | 171 | ## Adding a new test | |
170 | 172 | |||
171 | 1. Run `make add-test NAME=test_name`. | 173 | 1. Run `make add-test NAME=test_name`. | |
172 | 2. Sort the `FILES` lines in `../../tests/usr.bin/xlint/lint1/Makefile`. | 174 | 2. Sort the `FILES` lines in `../../tests/usr.bin/xlint/lint1/Makefile`. | |
173 | 3. Make the test generate the desired diagnostics. | 175 | 3. Make the test generate the desired diagnostics. | |
174 | 4. Run `cd ../../tests/usr.bin/xlint/lint1 && sh ./accept.sh test_name`. | 176 | 4. Run `cd ../../tests/usr.bin/xlint/lint1 && sh ./accept.sh test_name`. | |
175 | 5. Run `cd ../.. && cvs commit distrib/sets/lists/tests/mi tests/usr.bin/xlint`. | 177 | 5. Run `cd ../.. && cvs commit distrib/sets/lists/tests/mi tests/usr.bin/xlint`. |