| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: init.c,v 1.180 2021/03/30 15:07:53 rillig Exp $ */ | | 1 | /* $NetBSD: init.c,v 1.181 2021/03/30 15:10:46 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.180 2021/03/30 15:07:53 rillig Exp $"); | | 41 | __RCSID("$NetBSD: init.c,v 1.181 2021/03/30 15:10:46 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 }; |
| @@ -442,30 +442,29 @@ designator_look_up(const struct designat | | | @@ -442,30 +442,29 @@ designator_look_up(const struct designat |
442 | { | | 442 | { |
443 | switch (tp->t_tspec) { | | 443 | switch (tp->t_tspec) { |
444 | case STRUCT: | | 444 | case STRUCT: |
445 | case UNION: | | 445 | case UNION: |
446 | if (dr->dr_name == NULL) { | | 446 | if (dr->dr_name == NULL) { |
447 | /* syntax error '%s' */ | | 447 | /* syntax error '%s' */ |
448 | error(249, "designator '[...]' is only for arrays"); | | 448 | error(249, "designator '[...]' is only for arrays"); |
449 | return sym_type(first_named_member(tp)); | | 449 | return sym_type(first_named_member(tp)); |
450 | } | | 450 | } |
451 | | | 451 | |
452 | return look_up_member_type(tp, dr->dr_name); | | 452 | return look_up_member_type(tp, dr->dr_name); |
453 | case ARRAY: | | 453 | case ARRAY: |
454 | if (dr->dr_name != NULL) { | | 454 | if (dr->dr_name != NULL) { |
455 | /* TODO: reword; kept for compatibility */ | | | |
456 | /* syntax error '%s' */ | | 455 | /* syntax error '%s' */ |
457 | error(249, | | 456 | error(249, |
458 | "named member must only be used with struct/union"); | | 457 | "designator '.member' is only for struct/union"); |
459 | } | | 458 | } |
460 | return tp->t_subt; | | 459 | return tp->t_subt; |
461 | default: | | 460 | default: |
462 | /* syntax error '%s' */ | | 461 | /* syntax error '%s' */ |
463 | error(249, "scalar type cannot use designator"); | | 462 | error(249, "scalar type cannot use designator"); |
464 | return tp; | | 463 | return tp; |
465 | } | | 464 | } |
466 | } | | 465 | } |
467 | | | 466 | |
468 | | | 467 | |
469 | #ifdef DEBUG | | 468 | #ifdef DEBUG |
470 | static void | | 469 | static void |
471 | designation_debug(const struct designation *dn) | | 470 | designation_debug(const struct designation *dn) |