Tue Mar 30 15:05:05 2021 UTC ()
tests/lint: remove outdated comments


(rillig)
diff -r1.24 -r1.25 src/tests/usr.bin/xlint/lint1/d_c99_init.c
diff -r1.17 -r1.18 src/tests/usr.bin/xlint/lint1/d_c99_init.exp
diff -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/msg_247.c

cvs diff -r1.24 -r1.25 src/tests/usr.bin/xlint/lint1/d_c99_init.c (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/d_c99_init.c 2021/03/30 14:25:28 1.24
+++ src/tests/usr.bin/xlint/lint1/d_c99_init.c 2021/03/30 15:05:05 1.25
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: d_c99_init.c,v 1.24 2021/03/30 14:25:28 rillig Exp $ */ 1/* $NetBSD: d_c99_init.c,v 1.25 2021/03/30 15:05:05 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
11void use(const void *); 11void use(const void *);
12 12
13typedef struct any { 13typedef struct any {
14 const void *value; 14 const void *value;
@@ -250,29 +250,28 @@ struct ten { @@ -250,29 +250,28 @@ struct ten {
250 int i2; 250 int i2;
251 int i3; 251 int i3;
252 int i4; 252 int i4;
253 int i5; 253 int i5;
254 int i6; 254 int i6;
255 int i7; 255 int i7;
256 int i8; 256 int i8;
257 int i9; 257 int i9;
258}; 258};
259 259
260struct ten ten = { 260struct ten ten = {
261 .i3 = 3, 261 .i3 = 3,
262 4, 262 4,
263 // FIXME: assertion "level->bl_type->t_tspec == ARRAY" failed in brace_level_extend_if_array_of_unknown_size 263 5,
264 // 5, 264 6,
265 // 6, 
266}; 265};
267 266
268int c99_6_7_8_p26_example3[4][3] = { 267int c99_6_7_8_p26_example3[4][3] = {
269 { 1, 3, 5 }, 268 { 1, 3, 5 },
270 { 2, 4, 6 }, 269 { 2, 4, 6 },
271 { 3, 5, 7 }, 270 { 3, 5, 7 },
272}; 271};
273 272
274int c99_6_7_8_p27_example4[4][3] = { 273int c99_6_7_8_p27_example4[4][3] = {
275 { 1 }, { 2 }, { 3 }, { 4 } 274 { 1 }, { 2 }, { 3 }, { 4 }
276}; 275};
277 276
278struct { 277struct {
@@ -320,58 +319,55 @@ ensure_array_type_is_not_modified_during @@ -320,58 +319,55 @@ ensure_array_type_is_not_modified_during
320 array_of_unknown_size a1 = { 1, 2, 3}; 319 array_of_unknown_size a1 = { 1, 2, 3};
321 320
322 switch (4) { 321 switch (4) {
323 case sizeof(array_of_unknown_size): 322 case sizeof(array_of_unknown_size):
324 case 0: /* expect: duplicate case in switch: 0 */ 323 case 0: /* expect: duplicate case in switch: 0 */
325 case 3: 324 case 3:
326 case 4: 325 case 4:
327 case 12: 326 case 12:
328 break; 327 break;
329 } 328 }
330} 329}
331 330
332struct point unknown_member_name_beginning = { 331struct point unknown_member_name_beginning = {
333 /* TODO: remove me */ 
334 .r = 5, /* expect: undefined struct/union member: r */ 332 .r = 5, /* expect: undefined struct/union member: r */
335 .x = 4, 333 .x = 4,
336 .y = 3, 334 .y = 3,
337}; 335};
338 336
339struct point unknown_member_name_middle = { 337struct point unknown_member_name_middle = {
340 .x = 4, 338 .x = 4,
341 .r = 5, /* expect: undefined struct/union member: r */ 339 .r = 5, /* expect: undefined struct/union member: r */
342 .y = 3, 340 .y = 3,
343}; 341};
344 342
345struct point unknown_member_name_end = { 343struct point unknown_member_name_end = {
346 .x = 4, 344 .x = 4,
347 .y = 3, 345 .y = 3,
348 .r = 5, /* expect: undefined struct/union member: r */ 346 .r = 5, /* expect: undefined struct/union member: r */
349}; 347};
350 348
351union value { 349union value {
352 int int_value; 350 int int_value;
353 void *pointer_value; 351 void *pointer_value;
354}; 352};
355 353
356union value unknown_union_member_name_first = { 354union value unknown_union_member_name_first = {
357 /* TODO: remove me */ 
358 .unknown_value = 4, /* expect: undefined struct/union member */ 355 .unknown_value = 4, /* expect: undefined struct/union member */
359 .int_value = 3, 356 .int_value = 3,
360}; 357};
361 358
362union value unknown_union_member_name_second = { 359union value unknown_union_member_name_second = {
363 .int_value = 3, 360 .int_value = 3,
364 /* TODO: remove me */ 
365 .unknown_value = 4, /* expect: undefined struct/union member */ 361 .unknown_value = 4, /* expect: undefined struct/union member */
366}; 362};
367 363
368struct point designators_with_subscript = { 364struct point designators_with_subscript = {
369 [0] = 3, /* expect: only for arrays */ 365 [0] = 3, /* expect: only for arrays */
370 .member[0][0].member = 4, /* expect: undefined struct/union member */ 366 .member[0][0].member = 4, /* expect: undefined struct/union member */
371 .x.y.z = 5, /* intentionally not caught, see designator_look_up */ 367 .x.y.z = 5, /* intentionally not caught, see designator_look_up */
372}; 368};
373 369
374struct { 370struct {
375 int : 16; 371 int : 16;
376} struct_with_only_unnamed_members = { /* expect: has no named members */ 372} struct_with_only_unnamed_members = { /* expect: has no named members */
377 123, /* expect: too many struct/union initializers */ 373 123, /* expect: too many struct/union initializers */

cvs diff -r1.17 -r1.18 src/tests/usr.bin/xlint/lint1/Attic/d_c99_init.exp (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/Attic/d_c99_init.exp 2021/03/30 14:25:28 1.17
+++ src/tests/usr.bin/xlint/lint1/Attic/d_c99_init.exp 2021/03/30 15:05:05 1.18
@@ -1,21 +1,21 @@ @@ -1,21 +1,21 @@
1d_c99_init.c(23): error: too many initializers [174] 1d_c99_init.c(23): error: too many initializers [174]
2d_c99_init.c(63): error: cannot initialize 'pointer to const void' from 'struct any' [185] 2d_c99_init.c(63): error: cannot initialize 'pointer to const void' from 'struct any' [185]
3d_c99_init.c(80): error: too many array initializers, expected 3 [173] 3d_c99_init.c(80): error: too many array initializers, expected 3 [173]
4d_c99_init.c(139): error: too many struct/union initializers [172] 4d_c99_init.c(139): error: too many struct/union initializers [172]
5d_c99_init.c(145): error: syntax error 'named member must only be used with struct/union' [249] 5d_c99_init.c(145): error: syntax error 'named member must only be used with struct/union' [249]
6d_c99_init.c(232): error: too many struct/union initializers [172] 6d_c99_init.c(232): error: too many struct/union initializers [172]
7d_c99_init.c(238): warning: illegal combination of integer (char) and pointer (pointer to char) [183] 7d_c99_init.c(238): warning: illegal combination of integer (char) and pointer (pointer to char) [183]
8d_c99_init.c(242): warning: illegal combination of integer (char) and pointer (pointer to char) [183] 8d_c99_init.c(242): warning: illegal combination of integer (char) and pointer (pointer to char) [183]
9d_c99_init.c(282): error: cannot initialize 'struct <unnamed>' from 'int' [185] 9d_c99_init.c(281): error: cannot initialize 'struct <unnamed>' from 'int' [185]
10d_c99_init.c(324): error: duplicate case in switch: 0 [199] 10d_c99_init.c(323): error: duplicate case in switch: 0 [199]
11d_c99_init.c(334): error: undefined struct/union member: r [101] 11d_c99_init.c(332): error: undefined struct/union member: r [101]
12d_c99_init.c(341): error: undefined struct/union member: r [101] 12d_c99_init.c(339): error: undefined struct/union member: r [101]
13d_c99_init.c(348): error: undefined struct/union member: r [101] 13d_c99_init.c(346): error: undefined struct/union member: r [101]
14d_c99_init.c(358): error: undefined struct/union member: unknown_value [101] 14d_c99_init.c(355): error: undefined struct/union member: unknown_value [101]
15d_c99_init.c(365): error: undefined struct/union member: unknown_value [101] 15d_c99_init.c(361): error: undefined struct/union member: unknown_value [101]
16d_c99_init.c(369): error: syntax error 'designator '[...]' is only for arrays' [249] 16d_c99_init.c(365): error: syntax error 'designator '[...]' is only for arrays' [249]
17d_c99_init.c(370): error: undefined struct/union member: member [101] 17d_c99_init.c(366): error: undefined struct/union member: member [101]
18d_c99_init.c(376): warning: structure has no named members [65] 18d_c99_init.c(372): warning: structure has no named members [65]
19d_c99_init.c(377): error: too many struct/union initializers [172] 19d_c99_init.c(373): error: too many struct/union initializers [172]
20d_c99_init.c(382): warning: union has no named members [65] 20d_c99_init.c(378): warning: union has no named members [65]
21d_c99_init.c(383): error: too many struct/union initializers [172] 21d_c99_init.c(379): error: too many struct/union initializers [172]

cvs diff -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/msg_247.c (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/msg_247.c 2021/03/26 16:59:19 1.7
+++ src/tests/usr.bin/xlint/lint1/msg_247.c 2021/03/30 15:05:05 1.8
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: msg_247.c,v 1.7 2021/03/26 16:59:19 rillig Exp $ */ 1/* $NetBSD: msg_247.c,v 1.8 2021/03/30 15:05:05 rillig Exp $ */
2# 3 "msg_247.c" 2# 3 "msg_247.c"
3 3
4// Test for message: pointer cast from '%s' to '%s' may be troublesome [247] 4// Test for message: pointer cast from '%s' to '%s' may be troublesome [247]
5 5
6/* lint1-extra-flags: -c */ 6/* lint1-extra-flags: -c */
7 7
8/* example taken from Xlib.h */ 8/* example taken from Xlib.h */
9typedef struct { 9typedef struct {
10 int id; 10 int id;
11} *PDisplay; 11} *PDisplay;
12 12
13struct Other { 13struct Other {
14 int id; 14 int id;
@@ -30,27 +30,27 @@ example(struct Other *arg) @@ -30,27 +30,27 @@ example(struct Other *arg)
30 */ 30 */
31 display = (PDisplay)arg; /* expect: 247 */ 31 display = (PDisplay)arg; /* expect: 247 */
32} 32}
33 33
34/* 34/*
35 * C code with a long history that has existed in pre-C90 times already often 35 * C code with a long history that has existed in pre-C90 times already often
36 * uses 'pointer to char' where modern code would use 'pointer to void'. 36 * uses 'pointer to char' where modern code would use 'pointer to void'.
37 * Since 'char' is the most general underlying type, there is nothing wrong 37 * Since 'char' is the most general underlying type, there is nothing wrong
38 * with casting to it. An example for this type of code is X11. 38 * with casting to it. An example for this type of code is X11.
39 * 39 *
40 * Casting to 'pointer to char' may also be used by programmers who don't know 40 * Casting to 'pointer to char' may also be used by programmers who don't know
41 * about endianness, but that's not something lint can do anything about. The 41 * about endianness, but that's not something lint can do anything about. The
42 * code for these two use cases looks exactly the same, so lint errs on the 42 * code for these two use cases looks exactly the same, so lint errs on the
43 * side of fewer false positive warnings here. (after fixing the FIXME below) 43 * side of fewer false positive warnings here.
44 */ 44 */
45char * 45char *
46cast_to_char_pointer(struct Other *arg) 46cast_to_char_pointer(struct Other *arg)
47{ 47{
48 return (char *)arg; 48 return (char *)arg;
49} 49}
50 50
51/* 51/*
52 * In traditional C there was 'unsigned char' as well, so the same reasoning 52 * In traditional C there was 'unsigned char' as well, so the same reasoning
53 * as for plain 'char' applies here. 53 * as for plain 'char' applies here.
54 */ 54 */
55unsigned char * 55unsigned char *
56cast_to_unsigned_char_pointer(struct Other *arg) 56cast_to_unsigned_char_pointer(struct Other *arg)