lint: add type information for message about unknown member namediff -r1.25 -r1.26 src/tests/usr.bin/xlint/lint1/d_c99_init.c
(rillig)
--- src/tests/usr.bin/xlint/lint1/d_c99_init.c 2021/03/30 15:05:05 1.25
+++ src/tests/usr.bin/xlint/lint1/d_c99_init.c 2021/03/30 15:18:19 1.26
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: d_c99_init.c,v 1.25 2021/03/30 15:05:05 rillig Exp $ */ | 1 | /* $NetBSD: d_c99_init.c,v 1.26 2021/03/30 15:18:19 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; | |
@@ -319,61 +319,61 @@ ensure_array_type_is_not_modified_during | @@ -319,61 +319,61 @@ ensure_array_type_is_not_modified_during | |||
319 | array_of_unknown_size a1 = { 1, 2, 3}; | 319 | array_of_unknown_size a1 = { 1, 2, 3}; | |
320 | 320 | |||
321 | switch (4) { | 321 | switch (4) { | |
322 | case sizeof(array_of_unknown_size): | 322 | case sizeof(array_of_unknown_size): | |
323 | case 0: /* expect: duplicate case in switch: 0 */ | 323 | case 0: /* expect: duplicate case in switch: 0 */ | |
324 | case 3: | 324 | case 3: | |
325 | case 4: | 325 | case 4: | |
326 | case 12: | 326 | case 12: | |
327 | break; | 327 | break; | |
328 | } | 328 | } | |
329 | } | 329 | } | |
330 | 330 | |||
331 | struct point unknown_member_name_beginning = { | 331 | struct point unknown_member_name_beginning = { | |
332 | .r = 5, /* expect: undefined struct/union member: r */ | 332 | .r = 5, /* expect: does not have member 'r' */ | |
333 | .x = 4, | 333 | .x = 4, | |
334 | .y = 3, | 334 | .y = 3, | |
335 | }; | 335 | }; | |
336 | 336 | |||
337 | struct point unknown_member_name_middle = { | 337 | struct point unknown_member_name_middle = { | |
338 | .x = 4, | 338 | .x = 4, | |
339 | .r = 5, /* expect: undefined struct/union member: r */ | 339 | .r = 5, /* expect: does not have member 'r' */ | |
340 | .y = 3, | 340 | .y = 3, | |
341 | }; | 341 | }; | |
342 | 342 | |||
343 | struct point unknown_member_name_end = { | 343 | struct point unknown_member_name_end = { | |
344 | .x = 4, | 344 | .x = 4, | |
345 | .y = 3, | 345 | .y = 3, | |
346 | .r = 5, /* expect: undefined struct/union member: r */ | 346 | .r = 5, /* expect: does not have member 'r' */ | |
347 | }; | 347 | }; | |
348 | 348 | |||
349 | union value { | 349 | union value { | |
350 | int int_value; | 350 | int int_value; | |
351 | void *pointer_value; | 351 | void *pointer_value; | |
352 | }; | 352 | }; | |
353 | 353 | |||
354 | union value unknown_union_member_name_first = { | 354 | union value unknown_union_member_name_first = { | |
355 | .unknown_value = 4, /* expect: undefined struct/union member */ | 355 | .unknown_value = 4, /* expect: does not have member */ | |
356 | .int_value = 3, | 356 | .int_value = 3, | |
357 | }; | 357 | }; | |
358 | 358 | |||
359 | union value unknown_union_member_name_second = { | 359 | union value unknown_union_member_name_second = { | |
360 | .int_value = 3, | 360 | .int_value = 3, | |
361 | .unknown_value = 4, /* expect: undefined struct/union member */ | 361 | .unknown_value = 4, /* expect: does not have member */ | |
362 | }; | 362 | }; | |
363 | 363 | |||
364 | struct point designators_with_subscript = { | 364 | struct point designators_with_subscript = { | |
365 | [0] = 3, /* expect: only for arrays */ | 365 | [0] = 3, /* expect: only for arrays */ | |
366 | .member[0][0].member = 4, /* expect: undefined struct/union member */ | 366 | .member[0][0].member = 4, /* expect: does not have member 'member' */ | |
367 | .x.y.z = 5, /* intentionally not caught, see designator_look_up */ | 367 | .x.y.z = 5, /* intentionally not caught, see designator_look_up */ | |
368 | }; | 368 | }; | |
369 | 369 | |||
370 | struct { | 370 | struct { | |
371 | int : 16; | 371 | int : 16; | |
372 | } struct_with_only_unnamed_members = { /* expect: has no named members */ | 372 | } struct_with_only_unnamed_members = { /* expect: has no named members */ | |
373 | 123, /* expect: too many struct/union initializers */ | 373 | 123, /* expect: too many struct/union initializers */ | |
374 | }; | 374 | }; | |
375 | 375 | |||
376 | union { | 376 | union { | |
377 | int : 16; | 377 | int : 16; | |
378 | } union_with_only_unnamed_members = { /* expect: has no named members */ | 378 | } union_with_only_unnamed_members = { /* expect: has no named members */ | |
379 | 123, /* expect: too many struct/union initializers */ | 379 | 123, /* expect: too many struct/union initializers */ |
--- src/tests/usr.bin/xlint/lint1/Attic/d_c99_init.exp 2021/03/30 15:10:46 1.19
+++ src/tests/usr.bin/xlint/lint1/Attic/d_c99_init.exp 2021/03/30 15:18:19 1.20
@@ -1,21 +1,21 @@ | @@ -1,21 +1,21 @@ | |||
1 | d_c99_init.c(23): error: too many initializers [174] | 1 | d_c99_init.c(23): error: too many initializers [174] | |
2 | d_c99_init.c(63): error: cannot initialize 'pointer to const void' from 'struct any' [185] | 2 | d_c99_init.c(63): error: cannot initialize 'pointer to const void' from 'struct any' [185] | |
3 | d_c99_init.c(80): error: too many array initializers, expected 3 [173] | 3 | d_c99_init.c(80): error: too many array initializers, expected 3 [173] | |
4 | d_c99_init.c(139): error: too many struct/union initializers [172] | 4 | d_c99_init.c(139): error: too many struct/union initializers [172] | |
5 | d_c99_init.c(145): error: syntax error 'designator '.member' is only for struct/union' [249] | 5 | d_c99_init.c(145): error: syntax error 'designator '.member' is only for struct/union' [249] | |
6 | d_c99_init.c(232): error: too many struct/union initializers [172] | 6 | d_c99_init.c(232): error: too many struct/union initializers [172] | |
7 | d_c99_init.c(238): warning: illegal combination of integer (char) and pointer (pointer to char) [183] | 7 | d_c99_init.c(238): warning: illegal combination of integer (char) and pointer (pointer to char) [183] | |
8 | d_c99_init.c(242): warning: illegal combination of integer (char) and pointer (pointer to char) [183] | 8 | d_c99_init.c(242): warning: illegal combination of integer (char) and pointer (pointer to char) [183] | |
9 | d_c99_init.c(281): error: cannot initialize 'struct <unnamed>' from 'int' [185] | 9 | d_c99_init.c(281): error: cannot initialize 'struct <unnamed>' from 'int' [185] | |
10 | d_c99_init.c(323): error: duplicate case in switch: 0 [199] | 10 | d_c99_init.c(323): error: duplicate case in switch: 0 [199] | |
11 | d_c99_init.c(332): error: undefined struct/union member: r [101] | 11 | d_c99_init.c(332): error: type 'struct point' does not have member 'r' [101] | |
12 | d_c99_init.c(339): error: undefined struct/union member: r [101] | 12 | d_c99_init.c(339): error: type 'struct point' does not have member 'r' [101] | |
13 | d_c99_init.c(346): error: undefined struct/union member: r [101] | 13 | d_c99_init.c(346): error: type 'struct point' does not have member 'r' [101] | |
14 | d_c99_init.c(355): error: undefined struct/union member: unknown_value [101] | 14 | d_c99_init.c(355): error: type 'union value' does not have member 'unknown_value' [101] | |
15 | d_c99_init.c(361): error: undefined struct/union member: unknown_value [101] | 15 | d_c99_init.c(361): error: type 'union value' does not have member 'unknown_value' [101] | |
16 | d_c99_init.c(365): error: syntax error 'designator '[...]' is only for arrays' [249] | 16 | d_c99_init.c(365): error: syntax error 'designator '[...]' is only for arrays' [249] | |
17 | d_c99_init.c(366): error: undefined struct/union member: member [101] | 17 | d_c99_init.c(366): error: type 'struct point' does not have member 'member' [101] | |
18 | d_c99_init.c(372): warning: structure has no named members [65] | 18 | d_c99_init.c(372): warning: structure has no named members [65] | |
19 | d_c99_init.c(373): error: too many struct/union initializers [172] | 19 | d_c99_init.c(373): error: too many struct/union initializers [172] | |
20 | d_c99_init.c(378): warning: union has no named members [65] | 20 | d_c99_init.c(378): warning: union has no named members [65] | |
21 | d_c99_init.c(379): error: too many struct/union initializers [172] | 21 | d_c99_init.c(379): error: too many struct/union initializers [172] |
--- src/tests/usr.bin/xlint/lint1/msg_101.c 2021/01/31 11:12:07 1.3
+++ src/tests/usr.bin/xlint/lint1/msg_101.c 2021/03/30 15:18:19 1.4
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: msg_101.c,v 1.3 2021/01/31 11:12:07 rillig Exp $ */ | 1 | /* $NetBSD: msg_101.c,v 1.4 2021/03/30 15:18:19 rillig Exp $ */ | |
2 | # 3 "msg_101.c" | 2 | # 3 "msg_101.c" | |
3 | 3 | |||
4 | // Test for message: undefined struct/union member: %s [101] | 4 | // Test for message: type '%s' does not have member '%s' [101] | |
5 | 5 | |||
6 | struct point { | 6 | struct point { | |
7 | int x, y; | 7 | int x, y; | |
8 | }; | 8 | }; | |
9 | 9 | |||
10 | int | 10 | int | |
11 | get_z(const struct point *p) | 11 | get_z(const struct point *p) | |
12 | { | 12 | { | |
13 | return p.z; /* expect: 101 */ | 13 | return p.z; /* expect: 101 */ | |
14 | } | 14 | } |
--- src/tests/usr.bin/xlint/lint1/Attic/msg_101.exp 2021/03/21 20:44:59 1.3
+++ src/tests/usr.bin/xlint/lint1/Attic/msg_101.exp 2021/03/30 15:18:19 1.4
--- src/usr.bin/xlint/lint1/err.c 2021/03/30 15:07:53 1.98
+++ src/usr.bin/xlint/lint1/err.c 2021/03/30 15:18:19 1.99
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: err.c,v 1.98 2021/03/30 15:07:53 rillig Exp $ */ | 1 | /* $NetBSD: err.c,v 1.99 2021/03/30 15:18:19 rillig Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1994, 1995 Jochen Pohl | 4 | * Copyright (c) 1994, 1995 Jochen Pohl | |
5 | * All Rights Reserved. | 5 | * All Rights Reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -27,27 +27,27 @@ | @@ -27,27 +27,27 @@ | |||
27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
32 | */ | 32 | */ | |
33 | 33 | |||
34 | #if HAVE_NBTOOL_CONFIG_H | 34 | #if HAVE_NBTOOL_CONFIG_H | |
35 | #include "nbtool_config.h" | 35 | #include "nbtool_config.h" | |
36 | #endif | 36 | #endif | |
37 | 37 | |||
38 | #include <sys/cdefs.h> | 38 | #include <sys/cdefs.h> | |
39 | #if defined(__RCSID) && !defined(lint) | 39 | #if defined(__RCSID) && !defined(lint) | |
40 | __RCSID("$NetBSD: err.c,v 1.98 2021/03/30 15:07:53 rillig Exp $"); | 40 | __RCSID("$NetBSD: err.c,v 1.99 2021/03/30 15:18:19 rillig Exp $"); | |
41 | #endif | 41 | #endif | |
42 | 42 | |||
43 | #include <sys/types.h> | 43 | #include <sys/types.h> | |
44 | #include <stdarg.h> | 44 | #include <stdarg.h> | |
45 | #include <stdlib.h> | 45 | #include <stdlib.h> | |
46 | 46 | |||
47 | #include "lint1.h" | 47 | #include "lint1.h" | |
48 | 48 | |||
49 | /* number of errors found */ | 49 | /* number of errors found */ | |
50 | int nerr; | 50 | int nerr; | |
51 | 51 | |||
52 | /* number of syntax errors */ | 52 | /* number of syntax errors */ | |
53 | int sytxerr; | 53 | int sytxerr; | |
@@ -145,27 +145,27 @@ const char *msgs[] = { | @@ -145,27 +145,27 @@ const char *msgs[] = { | |||
145 | "typedef hides external declaration: %s", /* 88 */ | 145 | "typedef hides external declaration: %s", /* 88 */ | |
146 | "typedef redeclared: %s", /* 89 */ | 146 | "typedef redeclared: %s", /* 89 */ | |
147 | "inconsistent redeclaration of extern: %s", /* 90 */ | 147 | "inconsistent redeclaration of extern: %s", /* 90 */ | |
148 | "declaration hides parameter: %s", /* 91 */ | 148 | "declaration hides parameter: %s", /* 91 */ | |
149 | "inconsistent redeclaration of static: %s", /* 92 */ | 149 | "inconsistent redeclaration of static: %s", /* 92 */ | |
150 | "dubious static function at block level: %s", /* 93 */ | 150 | "dubious static function at block level: %s", /* 93 */ | |
151 | "function has illegal storage class: %s", /* 94 */ | 151 | "function has illegal storage class: %s", /* 94 */ | |
152 | "declaration hides earlier one: %s", /* 95 */ | 152 | "declaration hides earlier one: %s", /* 95 */ | |
153 | "cannot dereference non-pointer type", /* 96 */ | 153 | "cannot dereference non-pointer type", /* 96 */ | |
154 | "suffix U is illegal in traditional C", /* 97 */ | 154 | "suffix U is illegal in traditional C", /* 97 */ | |
155 | "suffixes F and L are illegal in traditional C", /* 98 */ | 155 | "suffixes F and L are illegal in traditional C", /* 98 */ | |
156 | "'%s' undefined", /* 99 */ | 156 | "'%s' undefined", /* 99 */ | |
157 | "unary + is illegal in traditional C", /* 100 */ | 157 | "unary + is illegal in traditional C", /* 100 */ | |
158 | "undefined struct/union member: %s", /* 101 */ | 158 | "type '%s' does not have member '%s'", /* 101 */ | |
159 | "illegal member use: %s", /* 102 */ | 159 | "illegal member use: %s", /* 102 */ | |
160 | "left operand of '.' must be struct/union object", /* 103 */ | 160 | "left operand of '.' must be struct/union object", /* 103 */ | |
161 | "left operand of '->' must be pointer to struct/union not %s",/* 104 */ | 161 | "left operand of '->' must be pointer to struct/union not %s",/* 104 */ | |
162 | "non-unique member requires struct/union %s", /* 105 */ | 162 | "non-unique member requires struct/union %s", /* 105 */ | |
163 | "left operand of '->' must be pointer", /* 106 */ | 163 | "left operand of '->' must be pointer", /* 106 */ | |
164 | "operands of '%s' have incompatible types (%s != %s)", /* 107 */ | 164 | "operands of '%s' have incompatible types (%s != %s)", /* 107 */ | |
165 | "operand of '%s' has invalid type (%s)", /* 108 */ | 165 | "operand of '%s' has invalid type (%s)", /* 108 */ | |
166 | "void type illegal in expression", /* 109 */ | 166 | "void type illegal in expression", /* 109 */ | |
167 | "pointer to function is not allowed here", /* 110 */ | 167 | "pointer to function is not allowed here", /* 110 */ | |
168 | "unacceptable operand of '%s'", /* 111 */ | 168 | "unacceptable operand of '%s'", /* 111 */ | |
169 | "cannot take address of bit-field", /* 112 */ | 169 | "cannot take address of bit-field", /* 112 */ | |
170 | "cannot take address of register %s", /* 113 */ | 170 | "cannot take address of register %s", /* 113 */ | |
171 | "%soperand of '%s' must be lvalue", /* 114 */ | 171 | "%soperand of '%s' must be lvalue", /* 114 */ |
--- src/usr.bin/xlint/lint1/init.c 2021/03/30 15:10:46 1.181
+++ src/usr.bin/xlint/lint1/init.c 2021/03/30 15:18:19 1.182
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: init.c,v 1.181 2021/03/30 15:10:46 rillig Exp $ */ | 1 | /* $NetBSD: init.c,v 1.182 2021/03/30 15:18:19 rillig Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1994, 1995 Jochen Pohl | 4 | * Copyright (c) 1994, 1995 Jochen Pohl | |
5 | * Copyright (c) 2021 Roland Illig | 5 | * Copyright (c) 2021 Roland Illig | |
6 | * All Rights Reserved. | 6 | * All Rights Reserved. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
@@ -28,27 +28,27 @@ | @@ -28,27 +28,27 @@ | |||
28 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 28 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
32 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 32 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
33 | */ | 33 | */ | |
34 | 34 | |||
35 | #if HAVE_NBTOOL_CONFIG_H | 35 | #if HAVE_NBTOOL_CONFIG_H | |
36 | #include "nbtool_config.h" | 36 | #include "nbtool_config.h" | |
37 | #endif | 37 | #endif | |
38 | 38 | |||
39 | #include <sys/cdefs.h> | 39 | #include <sys/cdefs.h> | |
40 | #if defined(__RCSID) && !defined(lint) | 40 | #if defined(__RCSID) && !defined(lint) | |
41 | __RCSID("$NetBSD: init.c,v 1.181 2021/03/30 15:10:46 rillig Exp $"); | 41 | __RCSID("$NetBSD: init.c,v 1.182 2021/03/30 15:18:19 rillig Exp $"); | |
42 | #endif | 42 | #endif | |
43 | 43 | |||
44 | #include <stdlib.h> | 44 | #include <stdlib.h> | |
45 | #include <string.h> | 45 | #include <string.h> | |
46 | 46 | |||
47 | #include "lint1.h" | 47 | #include "lint1.h" | |
48 | 48 | |||
49 | 49 | |||
50 | /* | 50 | /* | |
51 | * Initialization of global or local objects, like in: | 51 | * Initialization of global or local objects, like in: | |
52 | * | 52 | * | |
53 | * int number = 12345; | 53 | * int number = 12345; | |
54 | * int number_with_braces = { 12345 }; | 54 | * int number_with_braces = { 12345 }; | |
@@ -296,29 +296,28 @@ static const type_t * | @@ -296,29 +296,28 @@ static const type_t * | |||
296 | sym_type(const sym_t *sym) | 296 | sym_type(const sym_t *sym) | |
297 | { | 297 | { | |
298 | 298 | |||
299 | return sym != NULL ? sym->s_type : NULL; | 299 | return sym != NULL ? sym->s_type : NULL; | |
300 | } | 300 | } | |
301 | 301 | |||
302 | static const type_t * | 302 | static const type_t * | |
303 | look_up_member_type(const type_t *tp, const char *name) | 303 | look_up_member_type(const type_t *tp, const char *name) | |
304 | { | 304 | { | |
305 | const sym_t *member; | 305 | const sym_t *member; | |
306 | 306 | |||
307 | member = look_up_member(tp, name); | 307 | member = look_up_member(tp, name); | |
308 | if (member == NULL) { | 308 | if (member == NULL) { | |
309 | /* TODO: add type information */ | 309 | /* type '%s' does not have member '%s' */ | |
310 | /* undefined struct/union member: %s */ | 310 | error(101, type_name(tp), name); | |
311 | error(101, name); | |||
312 | } | 311 | } | |
313 | 312 | |||
314 | return sym_type(member); | 313 | return sym_type(member); | |
315 | } | 314 | } | |
316 | 315 | |||
317 | static void | 316 | static void | |
318 | update_type_of_array_of_unknown_size(sym_t *sym, size_t size) | 317 | update_type_of_array_of_unknown_size(sym_t *sym, size_t size) | |
319 | { | 318 | { | |
320 | type_t *tp; | 319 | type_t *tp; | |
321 | 320 | |||
322 | tp = duptyp(sym->s_type); | 321 | tp = duptyp(sym->s_type); | |
323 | tp->t_dim = (int)size; | 322 | tp->t_dim = (int)size; | |
324 | tp->t_incomplete_array = false; | 323 | tp->t_incomplete_array = false; |
--- src/usr.bin/xlint/lint1/tree.c 2021/03/28 13:09:43 1.253
+++ src/usr.bin/xlint/lint1/tree.c 2021/03/30 15:18:19 1.254
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: tree.c,v 1.253 2021/03/28 13:09:43 rillig Exp $ */ | 1 | /* $NetBSD: tree.c,v 1.254 2021/03/30 15:18:19 rillig Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1994, 1995 Jochen Pohl | 4 | * Copyright (c) 1994, 1995 Jochen Pohl | |
5 | * All Rights Reserved. | 5 | * All Rights Reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -27,27 +27,27 @@ | @@ -27,27 +27,27 @@ | |||
27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
32 | */ | 32 | */ | |
33 | 33 | |||
34 | #if HAVE_NBTOOL_CONFIG_H | 34 | #if HAVE_NBTOOL_CONFIG_H | |
35 | #include "nbtool_config.h" | 35 | #include "nbtool_config.h" | |
36 | #endif | 36 | #endif | |
37 | 37 | |||
38 | #include <sys/cdefs.h> | 38 | #include <sys/cdefs.h> | |
39 | #if defined(__RCSID) && !defined(lint) | 39 | #if defined(__RCSID) && !defined(lint) | |
40 | __RCSID("$NetBSD: tree.c,v 1.253 2021/03/28 13:09:43 rillig Exp $"); | 40 | __RCSID("$NetBSD: tree.c,v 1.254 2021/03/30 15:18:19 rillig Exp $"); | |
41 | #endif | 41 | #endif | |
42 | 42 | |||
43 | #include <float.h> | 43 | #include <float.h> | |
44 | #include <limits.h> | 44 | #include <limits.h> | |
45 | #include <math.h> | 45 | #include <math.h> | |
46 | #include <signal.h> | 46 | #include <signal.h> | |
47 | #include <stdlib.h> | 47 | #include <stdlib.h> | |
48 | #include <string.h> | 48 | #include <string.h> | |
49 | 49 | |||
50 | #include "lint1.h" | 50 | #include "lint1.h" | |
51 | #include "cgram.h" | 51 | #include "cgram.h" | |
52 | 52 | |||
53 | static tnode_t *new_integer_constant_node(tspec_t, int64_t); | 53 | static tnode_t *new_integer_constant_node(tspec_t, int64_t); | |
@@ -337,28 +337,28 @@ sym_t * | @@ -337,28 +337,28 @@ sym_t * | |||
337 | struct_or_union_member(tnode_t *tn, op_t op, sym_t *msym) | 337 | struct_or_union_member(tnode_t *tn, op_t op, sym_t *msym) | |
338 | { | 338 | { | |
339 | struct_or_union *str; | 339 | struct_or_union *str; | |
340 | type_t *tp; | 340 | type_t *tp; | |
341 | sym_t *sym, *csym; | 341 | sym_t *sym, *csym; | |
342 | bool eq; | 342 | bool eq; | |
343 | tspec_t t; | 343 | tspec_t t; | |
344 | 344 | |||
345 | /* | 345 | /* | |
346 | * Remove the member if it was unknown until now, which means | 346 | * Remove the member if it was unknown until now, which means | |
347 | * that no defined struct or union has a member with the same name. | 347 | * that no defined struct or union has a member with the same name. | |
348 | */ | 348 | */ | |
349 | if (msym->s_scl == NOSCL) { | 349 | if (msym->s_scl == NOSCL) { | |
350 | /* undefined struct/union member: %s */ | 350 | /* type '%s' does not have member '%s' */ | |
351 | error(101, msym->s_name); | 351 | error(101, type_name(msym->s_type), msym->s_name); | |
352 | rmsym(msym); | 352 | rmsym(msym); | |
353 | msym->s_kind = FMEMBER; | 353 | msym->s_kind = FMEMBER; | |
354 | msym->s_scl = MOS; | 354 | msym->s_scl = MOS; | |
355 | msym->s_styp = tgetblk(sizeof *msym->s_styp); | 355 | msym->s_styp = tgetblk(sizeof *msym->s_styp); | |
356 | msym->s_styp->sou_tag = tgetblk(sizeof *msym->s_styp->sou_tag); | 356 | msym->s_styp->sou_tag = tgetblk(sizeof *msym->s_styp->sou_tag); | |
357 | msym->s_styp->sou_tag->s_name = unnamed; | 357 | msym->s_styp->sou_tag->s_name = unnamed; | |
358 | msym->s_value.v_tspec = INT; | 358 | msym->s_value.v_tspec = INT; | |
359 | return msym; | 359 | return msym; | |
360 | } | 360 | } | |
361 | 361 | |||
362 | /* Set str to the tag of which msym is expected to be a member. */ | 362 | /* Set str to the tag of which msym is expected to be a member. */ | |
363 | str = NULL; | 363 | str = NULL; | |
364 | t = (tp = tn->tn_type)->t_tspec; | 364 | t = (tp = tn->tn_type)->t_tspec; |