lint: rename public designator functions Their previous names were too similar to the actual implementation functions, which was confusing. No functional change.diff -r1.204 -r1.205 src/usr.bin/xlint/lint1/cgram.y
(rillig)
--- src/usr.bin/xlint/lint1/cgram.y 2021/03/26 20:31:07 1.204
+++ src/usr.bin/xlint/lint1/cgram.y 2021/03/28 10:09:34 1.205
@@ -1,15 +1,15 @@ | @@ -1,15 +1,15 @@ | |||
1 | %{ | 1 | %{ | |
2 | /* $NetBSD: cgram.y,v 1.204 2021/03/26 20:31:07 rillig Exp $ */ | 2 | /* $NetBSD: cgram.y,v 1.205 2021/03/28 10:09:34 rillig Exp $ */ | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. | 5 | * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. | |
6 | * Copyright (c) 1994, 1995 Jochen Pohl | 6 | * Copyright (c) 1994, 1995 Jochen Pohl | |
7 | * All Rights Reserved. | 7 | * All Rights Reserved. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
15 | * notice, this list of conditions and the following disclaimer in the | 15 | * notice, this list of conditions and the following disclaimer in the | |
@@ -25,27 +25,27 @@ | @@ -25,27 +25,27 @@ | |||
25 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 25 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
26 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 26 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
27 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 27 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
29 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 29 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
30 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 30 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
31 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 31 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
32 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 32 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
33 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 33 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
34 | */ | 34 | */ | |
35 | 35 | |||
36 | #include <sys/cdefs.h> | 36 | #include <sys/cdefs.h> | |
37 | #if defined(__RCSID) && !defined(lint) | 37 | #if defined(__RCSID) && !defined(lint) | |
38 | __RCSID("$NetBSD: cgram.y,v 1.204 2021/03/26 20:31:07 rillig Exp $"); | 38 | __RCSID("$NetBSD: cgram.y,v 1.205 2021/03/28 10:09:34 rillig Exp $"); | |
39 | #endif | 39 | #endif | |
40 | 40 | |||
41 | #include <limits.h> | 41 | #include <limits.h> | |
42 | #include <stdlib.h> | 42 | #include <stdlib.h> | |
43 | #include <string.h> | 43 | #include <string.h> | |
44 | 44 | |||
45 | #include "lint1.h" | 45 | #include "lint1.h" | |
46 | 46 | |||
47 | extern char *yytext; | 47 | extern char *yytext; | |
48 | 48 | |||
49 | /* | 49 | /* | |
50 | * Contains the level of current declaration, used for symbol table entries. | 50 | * Contains the level of current declaration, used for symbol table entries. | |
51 | * 0 is the top-level, > 0 is inside a function body. | 51 | * 0 is the top-level, > 0 is inside a function body. | |
@@ -1369,50 +1369,50 @@ range: | @@ -1369,50 +1369,50 @@ range: | |||
1369 | $$.lo = to_int_constant($1, true); | 1369 | $$.lo = to_int_constant($1, true); | |
1370 | $$.hi = $$.lo; | 1370 | $$.hi = $$.lo; | |
1371 | } | 1371 | } | |
1372 | | constant_expr T_ELLIPSIS constant_expr { | 1372 | | constant_expr T_ELLIPSIS constant_expr { | |
1373 | $$.lo = to_int_constant($1, true); | 1373 | $$.lo = to_int_constant($1, true); | |
1374 | $$.hi = to_int_constant($3, true); | 1374 | $$.hi = to_int_constant($3, true); | |
1375 | /* initialization with '[a...b]' is a GNU extension */ | 1375 | /* initialization with '[a...b]' is a GNU extension */ | |
1376 | gnuism(340); | 1376 | gnuism(340); | |
1377 | } | 1377 | } | |
1378 | ; | 1378 | ; | |
1379 | 1379 | |||
1380 | designator: /* C99 6.7.8 "Initialization" */ | 1380 | designator: /* C99 6.7.8 "Initialization" */ | |
1381 | T_LBRACK range T_RBRACK { | 1381 | T_LBRACK range T_RBRACK { | |
1382 | designation_add_subscript($2); | 1382 | add_designator_subscript($2); | |
1383 | if (!Sflag) | 1383 | if (!Sflag) | |
1384 | /* array initializer with des.s is a C9X feature */ | 1384 | /* array initializer with des.s is a C9X feature */ | |
1385 | warning(321); | 1385 | warning(321); | |
1386 | } | 1386 | } | |
1387 | | point identifier { | 1387 | | point identifier { | |
1388 | if (!Sflag) | 1388 | if (!Sflag) | |
1389 | /* struct or union member name in initializer is ... */ | 1389 | /* struct or union member name in initializer is ... */ | |
1390 | warning(313); | 1390 | warning(313); | |
1391 | designation_add_name($2); | 1391 | add_designator_member($2); | |
1392 | } | 1392 | } | |
1393 | ; | 1393 | ; | |
1394 | 1394 | |||
1395 | designator_list: /* C99 6.7.8 "Initialization" */ | 1395 | designator_list: /* C99 6.7.8 "Initialization" */ | |
1396 | designator | 1396 | designator | |
1397 | | designator_list designator | 1397 | | designator_list designator | |
1398 | ; | 1398 | ; | |
1399 | 1399 | |||
1400 | designation: /* C99 6.7.8 "Initialization" */ | 1400 | designation: /* C99 6.7.8 "Initialization" */ | |
1401 | designator_list T_ASSIGN | 1401 | designator_list T_ASSIGN | |
1402 | | identifier T_COLON { | 1402 | | identifier T_COLON { | |
1403 | /* GCC style struct or union member name in initializer */ | 1403 | /* GCC style struct or union member name in initializer */ | |
1404 | gnuism(315); | 1404 | gnuism(315); | |
1405 | designation_add_name($1); | 1405 | add_designator_member($1); | |
1406 | } | 1406 | } | |
1407 | ; | 1407 | ; | |
1408 | 1408 | |||
1409 | init_lbrace: | 1409 | init_lbrace: | |
1410 | T_LBRACE { | 1410 | T_LBRACE { | |
1411 | init_lbrace(); | 1411 | init_lbrace(); | |
1412 | } | 1412 | } | |
1413 | ; | 1413 | ; | |
1414 | 1414 | |||
1415 | init_rbrace: | 1415 | init_rbrace: | |
1416 | T_RBRACE { | 1416 | T_RBRACE { | |
1417 | init_rbrace(); | 1417 | init_rbrace(); | |
1418 | } | 1418 | } |
--- src/usr.bin/xlint/lint1/externs1.h 2021/03/27 22:04:39 1.92
+++ src/usr.bin/xlint/lint1/externs1.h 2021/03/28 10:09:34 1.93
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: externs1.h,v 1.92 2021/03/27 22:04:39 rillig Exp $ */ | 1 | /* $NetBSD: externs1.h,v 1.93 2021/03/28 10:09:34 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. | |
@@ -289,28 +289,28 @@ extern void bitfieldtype(int); | @@ -289,28 +289,28 @@ extern void bitfieldtype(int); | |||
289 | 289 | |||
290 | /* | 290 | /* | |
291 | * init.c | 291 | * init.c | |
292 | */ | 292 | */ | |
293 | extern void begin_initialization(sym_t *); | 293 | extern void begin_initialization(sym_t *); | |
294 | extern void end_initialization(void); | 294 | extern void end_initialization(void); | |
295 | extern bool *current_initerr(void); | 295 | extern bool *current_initerr(void); | |
296 | extern sym_t **current_initsym(void); | 296 | extern sym_t **current_initsym(void); | |
297 | 297 | |||
298 | extern void initstack_init(void); | 298 | extern void initstack_init(void); | |
299 | extern void init_rbrace(void); | 299 | extern void init_rbrace(void); | |
300 | extern void init_lbrace(void); | 300 | extern void init_lbrace(void); | |
301 | extern void init_using_expr(tnode_t *); | 301 | extern void init_using_expr(tnode_t *); | |
302 | extern void designation_add_name(sbuf_t *); | 302 | extern void add_designator_member(sbuf_t *); | |
303 | extern void designation_add_subscript(range_t); | 303 | extern void add_designator_subscript(range_t); | |
304 | 304 | |||
305 | /* | 305 | /* | |
306 | * emit.c | 306 | * emit.c | |
307 | */ | 307 | */ | |
308 | extern void outtype(const type_t *); | 308 | extern void outtype(const type_t *); | |
309 | extern const char *ttos(const type_t *); | 309 | extern const char *ttos(const type_t *); | |
310 | extern void outsym(const sym_t *, scl_t, def_t); | 310 | extern void outsym(const sym_t *, scl_t, def_t); | |
311 | extern void outfdef(const sym_t *, const pos_t *, bool, bool, | 311 | extern void outfdef(const sym_t *, const pos_t *, bool, bool, | |
312 | const sym_t *); | 312 | const sym_t *); | |
313 | extern void outcall(const tnode_t *, bool, bool); | 313 | extern void outcall(const tnode_t *, bool, bool); | |
314 | extern void outusg(const sym_t *); | 314 | extern void outusg(const sym_t *); | |
315 | 315 | |||
316 | /* | 316 | /* |
--- src/usr.bin/xlint/lint1/init.c 2021/03/28 10:05:19 1.156
+++ src/usr.bin/xlint/lint1/init.c 2021/03/28 10:09:34 1.157
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: init.c,v 1.156 2021/03/28 10:05:19 rillig Exp $ */ | 1 | /* $NetBSD: init.c,v 1.157 2021/03/28 10:09:34 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: init.c,v 1.156 2021/03/28 10:05:19 rillig Exp $"); | 40 | __RCSID("$NetBSD: init.c,v 1.157 2021/03/28 10:09:34 rillig Exp $"); | |
41 | #endif | 41 | #endif | |
42 | 42 | |||
43 | #include <stdlib.h> | 43 | #include <stdlib.h> | |
44 | #include <string.h> | 44 | #include <string.h> | |
45 | 45 | |||
46 | #include "lint1.h" | 46 | #include "lint1.h" | |
47 | 47 | |||
48 | 48 | |||
49 | /* | 49 | /* | |
50 | * Initialization | 50 | * Initialization | |
51 | * | 51 | * | |
52 | * Handles initializations of global or local objects, like in: | 52 | * Handles initializations of global or local objects, like in: | |
53 | * | 53 | * | |
@@ -62,28 +62,28 @@ __RCSID("$NetBSD: init.c,v 1.156 2021/03 | @@ -62,28 +62,28 @@ __RCSID("$NetBSD: init.c,v 1.156 2021/03 | |||
62 | * struct { int x, y; } point = { .y = 4, .x = 3 }; | 62 | * struct { int x, y; } point = { .y = 4, .x = 3 }; | |
63 | * | 63 | * | |
64 | * Any scalar expression in the initializer may be surrounded by arbitrarily | 64 | * Any scalar expression in the initializer may be surrounded by arbitrarily | |
65 | * many extra pairs of braces, like in the example 'number_with_braces' (C99 | 65 | * many extra pairs of braces, like in the example 'number_with_braces' (C99 | |
66 | * 6.7.8p11). | 66 | * 6.7.8p11). | |
67 | * | 67 | * | |
68 | * For multi-dimensional arrays, the inner braces may be omitted like in | 68 | * For multi-dimensional arrays, the inner braces may be omitted like in | |
69 | * array_flat or spelled out like in array_nested. | 69 | * array_flat or spelled out like in array_nested. | |
70 | * | 70 | * | |
71 | * For the initializer, the grammar parser calls these functions: | 71 | * For the initializer, the grammar parser calls these functions: | |
72 | * | 72 | * | |
73 | * begin_initialization | 73 | * begin_initialization | |
74 | * init_lbrace for each '{' | 74 | * init_lbrace for each '{' | |
75 | * designation_add_name for each '.member' before '=' | 75 | * add_designator_member for each '.member' before '=' | |
76 | * designation_add_subscript for each '[123]' before '=' | 76 | * add_designator_subscript for each '[123]' before '=' | |
77 | * init_using_expr for each expression | 77 | * init_using_expr for each expression | |
78 | * init_rbrace for each '}' | 78 | * init_rbrace for each '}' | |
79 | * end_initialization | 79 | * end_initialization | |
80 | * | 80 | * | |
81 | * Each '{' begins a new brace level, each '}' ends the current brace level. | 81 | * Each '{' begins a new brace level, each '}' ends the current brace level. | |
82 | * Each brace level has an associated "current object". | 82 | * Each brace level has an associated "current object". | |
83 | * | 83 | * | |
84 | * Most of the time, the topmost level of brace_level contains a scalar type, | 84 | * Most of the time, the topmost level of brace_level contains a scalar type, | |
85 | * and its remaining count toggles between 1 and 0. | 85 | * and its remaining count toggles between 1 and 0. | |
86 | * | 86 | * | |
87 | * See also: | 87 | * See also: | |
88 | * C99 6.7.8 "Initialization" | 88 | * C99 6.7.8 "Initialization" | |
89 | * d_c99_init.c for more examples | 89 | * d_c99_init.c for more examples | |
@@ -645,57 +645,55 @@ begin_initialization(sym_t *sym) | @@ -645,57 +645,55 @@ begin_initialization(sym_t *sym) | |||
645 | } | 645 | } | |
646 | 646 | |||
647 | void | 647 | void | |
648 | end_initialization(void) | 648 | end_initialization(void) | |
649 | { | 649 | { | |
650 | struct initialization *in; | 650 | struct initialization *in; | |
651 | 651 | |||
652 | in = init; | 652 | in = init; | |
653 | init = init->next; | 653 | init = init->next; | |
654 | initialization_free(in); | 654 | initialization_free(in); | |
655 | debug_step("end initialization"); | 655 | debug_step("end initialization"); | |
656 | } | 656 | } | |
657 | 657 | |||
658 | ||||
659 | ||||
660 | void | 658 | void | |
661 | designation_add_name(sbuf_t *sb) | 659 | add_designator_member(sbuf_t *sb) | |
662 | { | 660 | { | |
663 | designation_add(¤t_init()->designation, | 661 | designation_add(¤t_init()->designation, | |
664 | designator_new(sb->sb_name)); | 662 | designator_new(sb->sb_name)); | |
665 | } | 663 | } | |
666 | 664 | |||
667 | /* TODO: Move the function body up here, to avoid the forward declaration. */ | 665 | /* TODO: Move the function body up here, to avoid the forward declaration. */ | |
668 | static void initstack_pop_nobrace(struct initialization *); | 666 | static void initstack_pop_nobrace(struct initialization *); | |
669 | 667 | |||
670 | /* | 668 | /* | |
671 | * A sub-object of an array is initialized using a designator. This does not | 669 | * A sub-object of an array is initialized using a designator. This does not | |
672 | * have to be an array element directly, it can also be used to initialize | 670 | * have to be an array element directly, it can also be used to initialize | |
673 | * only a sub-object of the array element. | 671 | * only a sub-object of the array element. | |
674 | * | 672 | * | |
675 | * C99 example: struct { int member[4]; } var = { [2] = 12345 }; | 673 | * C99 example: struct { int member[4]; } var = { [2] = 12345 }; | |
676 | * | 674 | * | |
677 | * GNU example: struct { int member[4]; } var = { [1 ... 3] = 12345 }; | 675 | * GNU example: struct { int member[4]; } var = { [1 ... 3] = 12345 }; | |
678 | * | 676 | * | |
679 | * TODO: test the following initialization with an outer and an inner type: | 677 | * TODO: test the following initialization with an outer and an inner type: | |
680 | * | 678 | * | |
681 | * .deeply[0].nested = { | 679 | * .deeply[0].nested = { | |
682 | * .deeply[1].nested = { | 680 | * .deeply[1].nested = { | |
683 | * 12345, | 681 | * 12345, | |
684 | * }, | 682 | * }, | |
685 | * } | 683 | * } | |
686 | */ | 684 | */ | |
687 | void | 685 | void | |
688 | designation_add_subscript(range_t range) | 686 | add_designator_subscript(range_t range) | |
689 | { | 687 | { | |
690 | struct initialization *in = current_init(); | 688 | struct initialization *in = current_init(); | |
691 | struct brace_level *level; | 689 | struct brace_level *level; | |
692 | 690 | |||
693 | debug_enter(); | 691 | debug_enter(); | |
694 | if (range.lo == range.hi) | 692 | if (range.lo == range.hi) | |
695 | debug_step("subscript is %zu", range.hi); | 693 | debug_step("subscript is %zu", range.hi); | |
696 | else | 694 | else | |
697 | debug_step("subscript range is %zu ... %zu", | 695 | debug_step("subscript range is %zu ... %zu", | |
698 | range.lo, range.hi); | 696 | range.lo, range.hi); | |
699 | 697 | |||
700 | /* XXX: This call is wrong here, it must be somewhere else. */ | 698 | /* XXX: This call is wrong here, it must be somewhere else. */ | |
701 | initstack_pop_nobrace(in); | 699 | initstack_pop_nobrace(in); |