lint: encode lifetime of allocated memory in the function names No functional change.diff -r1.36 -r1.37 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c
(rillig)
--- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c 2022/01/15 14:22:03 1.36
+++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c 2022/02/27 08:31:26 1.37
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: d_c99_bool_strict.c,v 1.36 2022/01/15 14:22:03 rillig Exp $ */ | 1 | /* $NetBSD: d_c99_bool_strict.c,v 1.37 2022/02/27 08:31:26 rillig Exp $ */ | |
2 | # 3 "d_c99_bool_strict.c" | 2 | # 3 "d_c99_bool_strict.c" | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * The option -T treats _Bool as incompatible with all other scalar types. | 5 | * The option -T treats _Bool as incompatible with all other scalar types. | |
6 | * This is implemented by the following rules: | 6 | * This is implemented by the following rules: | |
7 | * | 7 | * | |
8 | * strict-bool-typedef: | 8 | * strict-bool-typedef: | |
9 | * The type _Bool is compatible with any typedef of _Bool. | 9 | * The type _Bool is compatible with any typedef of _Bool. | |
10 | * | 10 | * | |
11 | * Note: Since <stdbool.h> defines bool as textual alias of _Bool, | 11 | * Note: Since <stdbool.h> defines bool as textual alias of _Bool, | |
12 | * having another typedef for bool is unusual. | 12 | * having another typedef for bool is unusual. | |
13 | * | 13 | * | |
14 | * strict-bool-constant: | 14 | * strict-bool-constant: | |
@@ -1032,27 +1032,27 @@ controlling_expression(FILE *f, const ch | @@ -1032,27 +1032,27 @@ controlling_expression(FILE *f, const ch | |||
1032 | * rather tn_relaxed at that time) to true. | 1032 | * rather tn_relaxed at that time) to true. | |
1033 | */ | 1033 | */ | |
1034 | /* expect+5: error: controlling expression must be bool, not 'int' [333] */ | 1034 | /* expect+5: error: controlling expression must be bool, not 'int' [333] */ | |
1035 | if (ferror( | 1035 | if (ferror( | |
1036 | # 1037 "d_c99_bool_strict.c" 3 4 | 1036 | # 1037 "d_c99_bool_strict.c" 3 4 | |
1037 | (stdio_stdout) | 1037 | (stdio_stdout) | |
1038 | # 1039 "d_c99_bool_strict.c" | 1038 | # 1039 "d_c99_bool_strict.c" | |
1039 | )) | 1039 | )) | |
1040 | return; | 1040 | return; | |
1041 | 1041 | |||
1042 | /* | 1042 | /* | |
1043 | * Before cgram.y 1.369 from 2021-11-16, the comment following | 1043 | * Before cgram.y 1.369 from 2021-11-16, the comment following | |
1044 | * 'stdio_stdout' did not prevent the search for '('. At the point | 1044 | * 'stdio_stdout' did not prevent the search for '('. At the point | |
1045 | * where build_name called expr_zalloc_tnode, the parser was already | 1045 | * where build_name called expr_alloc_tnode, the parser was already | |
1046 | * in the main file again, thus treating 'stdio_stdout' as not coming | 1046 | * in the main file again, thus treating 'stdio_stdout' as not coming | |
1047 | * from a system header. | 1047 | * from a system header. | |
1048 | * | 1048 | * | |
1049 | * This has been fixed in tree.c 1.395 from 2021-11-16. Before that, | 1049 | * This has been fixed in tree.c 1.395 from 2021-11-16. Before that, | |
1050 | * an expression had come from a system header if its operands came | 1050 | * an expression had come from a system header if its operands came | |
1051 | * from a system header, but that was only close to the truth. In a | 1051 | * from a system header, but that was only close to the truth. In a | |
1052 | * case where both operands come from a system header but the | 1052 | * case where both operands come from a system header but the | |
1053 | * operator comes from the main translation unit, the main | 1053 | * operator comes from the main translation unit, the main | |
1054 | * translation unit still has control over the whole expression. So | 1054 | * translation unit still has control over the whole expression. So | |
1055 | * the correct approach is to focus on the operator, not the | 1055 | * the correct approach is to focus on the operator, not the | |
1056 | * operands. There are a few corner cases where the operator is | 1056 | * operands. There are a few corner cases where the operator is | |
1057 | * invisible (for implicit conversions) or synthetic (for translating | 1057 | * invisible (for implicit conversions) or synthetic (for translating | |
1058 | * 'arr[index]' to '*(arr + index)', but these are handled as well. | 1058 | * 'arr[index]' to '*(arr + index)', but these are handled as well. |
--- src/usr.bin/xlint/lint1/cgram.y 2022/02/27 01:47:28 1.382
+++ src/usr.bin/xlint/lint1/cgram.y 2022/02/27 08:31:26 1.383
@@ -1,15 +1,15 @@ | @@ -1,15 +1,15 @@ | |||
1 | %{ | 1 | %{ | |
2 | /* $NetBSD: cgram.y,v 1.382 2022/02/27 01:47:28 rillig Exp $ */ | 2 | /* $NetBSD: cgram.y,v 1.383 2022/02/27 08:31:26 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,50 +25,50 @@ | @@ -25,50 +25,50 @@ | |||
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.382 2022/02/27 01:47:28 rillig Exp $"); | 38 | __RCSID("$NetBSD: cgram.y,v 1.383 2022/02/27 08:31:26 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. | |
52 | */ | 52 | */ | |
53 | int block_level; | 53 | int block_level; | |
54 | 54 | |||
55 | /* | 55 | /* | |
56 | * level for memory allocation. Normally the same as block_level. | 56 | * level for memory allocation. Normally the same as block_level. | |
57 | * An exception is the declaration of arguments in prototypes. Memory | 57 | * An exception is the declaration of arguments in prototypes. Memory | |
58 | * for these can't be freed after the declaration, but symbols must | 58 | * for these can't be freed after the declaration, but symbols must | |
59 | * be removed from the symbol table after the declaration. | 59 | * be removed from the symbol table after the declaration. | |
60 | */ | 60 | */ | |
61 | int mem_block_level; | 61 | size_t mem_block_level; | |
62 | 62 | |||
63 | /* | 63 | /* | |
64 | * Save the no-warns state and restore it to avoid the problem where | 64 | * Save the no-warns state and restore it to avoid the problem where | |
65 | * if (expr) { stmt } / * NOLINT * / stmt; | 65 | * if (expr) { stmt } / * NOLINT * / stmt; | |
66 | */ | 66 | */ | |
67 | static int olwarn = LWARN_BAD; | 67 | static int olwarn = LWARN_BAD; | |
68 | 68 | |||
69 | static void cgram_declare(sym_t *, bool, sbuf_t *); | 69 | static void cgram_declare(sym_t *, bool, sbuf_t *); | |
70 | static void read_until_rparen(void); | 70 | static void read_until_rparen(void); | |
71 | static sym_t *symbolrename(sym_t *, sbuf_t *); | 71 | static sym_t *symbolrename(sym_t *, sbuf_t *); | |
72 | 72 | |||
73 | 73 | |||
74 | #ifdef DEBUG | 74 | #ifdef DEBUG | |
@@ -467,32 +467,32 @@ generic_selection: | @@ -467,32 +467,32 @@ generic_selection: | |||
467 | 467 | |||
468 | /* K&R ---, C90 ---, C99 ---, C11 6.5.1.1 */ | 468 | /* K&R ---, C90 ---, C99 ---, C11 6.5.1.1 */ | |
469 | generic_assoc_list: | 469 | generic_assoc_list: | |
470 | generic_association | 470 | generic_association | |
471 | | generic_assoc_list T_COMMA generic_association { | 471 | | generic_assoc_list T_COMMA generic_association { | |
472 | $3->ga_prev = $1; | 472 | $3->ga_prev = $1; | |
473 | $$ = $3; | 473 | $$ = $3; | |
474 | } | 474 | } | |
475 | ; | 475 | ; | |
476 | 476 | |||
477 | /* K&R ---, C90 ---, C99 ---, C11 6.5.1.1 */ | 477 | /* K&R ---, C90 ---, C99 ---, C11 6.5.1.1 */ | |
478 | generic_association: | 478 | generic_association: | |
479 | type_name T_COLON assignment_expression { | 479 | type_name T_COLON assignment_expression { | |
480 | $$ = getblk(sizeof(*$$)); | 480 | $$ = block_zero_alloc(sizeof(*$$)); | |
481 | $$->ga_arg = $1; | 481 | $$->ga_arg = $1; | |
482 | $$->ga_result = $3; | 482 | $$->ga_result = $3; | |
483 | } | 483 | } | |
484 | | T_DEFAULT T_COLON assignment_expression { | 484 | | T_DEFAULT T_COLON assignment_expression { | |
485 | $$ = getblk(sizeof(*$$)); | 485 | $$ = block_zero_alloc(sizeof(*$$)); | |
486 | $$->ga_arg = NULL; | 486 | $$->ga_arg = NULL; | |
487 | $$->ga_result = $3; | 487 | $$->ga_result = $3; | |
488 | } | 488 | } | |
489 | ; | 489 | ; | |
490 | 490 | |||
491 | /* K&R 7.1, C90 ???, C99 6.5.2, C11 6.5.2 */ | 491 | /* K&R 7.1, C90 ???, C99 6.5.2, C11 6.5.2 */ | |
492 | postfix_expression: | 492 | postfix_expression: | |
493 | primary_expression | 493 | primary_expression | |
494 | | postfix_expression T_LBRACK sys expression T_RBRACK { | 494 | | postfix_expression T_LBRACK sys expression T_RBRACK { | |
495 | $$ = build_unary(INDIR, $3, build_binary($1, PLUS, $3, $4)); | 495 | $$ = build_unary(INDIR, $3, build_binary($1, PLUS, $3, $4)); | |
496 | } | 496 | } | |
497 | | postfix_expression T_LPAREN sys T_RPAREN { | 497 | | postfix_expression T_LPAREN sys T_RPAREN { | |
498 | $$ = build_function_call($1, $3, NULL); | 498 | $$ = build_function_call($1, $3, NULL); | |
@@ -539,32 +539,32 @@ comma_opt: /* helper for 'postfix_expr | @@ -539,32 +539,32 @@ comma_opt: /* helper for 'postfix_expr | |||
539 | gcc_statement_expr_list: | 539 | gcc_statement_expr_list: | |
540 | gcc_statement_expr_item | 540 | gcc_statement_expr_item | |
541 | | gcc_statement_expr_list gcc_statement_expr_item { | 541 | | gcc_statement_expr_list gcc_statement_expr_item { | |
542 | $$ = $2; | 542 | $$ = $2; | |
543 | } | 543 | } | |
544 | ; | 544 | ; | |
545 | 545 | |||
546 | gcc_statement_expr_item: | 546 | gcc_statement_expr_item: | |
547 | declaration_or_error { | 547 | declaration_or_error { | |
548 | clear_warning_flags(); | 548 | clear_warning_flags(); | |
549 | $$ = NULL; | 549 | $$ = NULL; | |
550 | } | 550 | } | |
551 | | non_expr_statement { | 551 | | non_expr_statement { | |
552 | $$ = expr_zalloc_tnode(); | 552 | $$ = expr_alloc_tnode(); | |
553 | $$->tn_type = gettyp(VOID); | 553 | $$->tn_type = gettyp(VOID); | |
554 | } | 554 | } | |
555 | | expression T_SEMI { | 555 | | expression T_SEMI { | |
556 | if ($1 == NULL) { /* in case of syntax errors */ | 556 | if ($1 == NULL) { /* in case of syntax errors */ | |
557 | $$ = expr_zalloc_tnode(); | 557 | $$ = expr_alloc_tnode(); | |
558 | $$->tn_type = gettyp(VOID); | 558 | $$->tn_type = gettyp(VOID); | |
559 | } else { | 559 | } else { | |
560 | /* XXX: do that only on the last name */ | 560 | /* XXX: do that only on the last name */ | |
561 | if ($1->tn_op == NAME) | 561 | if ($1->tn_op == NAME) | |
562 | $1->tn_sym->s_used = true; | 562 | $1->tn_sym->s_used = true; | |
563 | expr($1, false, false, false, false); | 563 | expr($1, false, false, false, false); | |
564 | seen_fallthrough = false; | 564 | seen_fallthrough = false; | |
565 | $$ = $1; | 565 | $$ = $1; | |
566 | } | 566 | } | |
567 | } | 567 | } | |
568 | ; | 568 | ; | |
569 | 569 | |||
570 | point_or_arrow: /* helper for 'postfix_expression' */ | 570 | point_or_arrow: /* helper for 'postfix_expression' */ | |
@@ -1682,27 +1682,27 @@ compound_statement: /* C99 6.8.2 */ | @@ -1682,27 +1682,27 @@ compound_statement: /* C99 6.8.2 */ | |||
1682 | ; | 1682 | ; | |
1683 | 1683 | |||
1684 | compound_statement_lbrace: | 1684 | compound_statement_lbrace: | |
1685 | T_LBRACE { | 1685 | T_LBRACE { | |
1686 | block_level++; | 1686 | block_level++; | |
1687 | mem_block_level++; | 1687 | mem_block_level++; | |
1688 | begin_declaration_level(AUTO); | 1688 | begin_declaration_level(AUTO); | |
1689 | } | 1689 | } | |
1690 | ; | 1690 | ; | |
1691 | 1691 | |||
1692 | compound_statement_rbrace: | 1692 | compound_statement_rbrace: | |
1693 | T_RBRACE { | 1693 | T_RBRACE { | |
1694 | end_declaration_level(); | 1694 | end_declaration_level(); | |
1695 | freeblk(); | 1695 | level_free_all(mem_block_level); | |
1696 | mem_block_level--; | 1696 | mem_block_level--; | |
1697 | block_level--; | 1697 | block_level--; | |
1698 | seen_fallthrough = false; | 1698 | seen_fallthrough = false; | |
1699 | } | 1699 | } | |
1700 | ; | 1700 | ; | |
1701 | 1701 | |||
1702 | block_item_list: /* C99 6.8.2 */ | 1702 | block_item_list: /* C99 6.8.2 */ | |
1703 | block_item | 1703 | block_item | |
1704 | | block_item_list block_item { | 1704 | | block_item_list block_item { | |
1705 | if (!Sflag && $1 && !$2) | 1705 | if (!Sflag && $1 && !$2) | |
1706 | /* declarations after statements is a C99 feature */ | 1706 | /* declarations after statements is a C99 feature */ | |
1707 | c99ism(327); | 1707 | c99ism(327); | |
1708 | $$ = $1 || $2; | 1708 | $$ = $1 || $2; |
--- src/usr.bin/xlint/lint1/decl.c 2022/02/27 01:47:28 1.245
+++ src/usr.bin/xlint/lint1/decl.c 2022/02/27 08:31:26 1.246
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: decl.c,v 1.245 2022/02/27 01:47:28 rillig Exp $ */ | 1 | /* $NetBSD: decl.c,v 1.246 2022/02/27 08:31:26 rillig Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. | 4 | * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. | |
5 | * Copyright (c) 1994, 1995 Jochen Pohl | 5 | * Copyright (c) 1994, 1995 Jochen Pohl | |
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: decl.c,v 1.245 2022/02/27 01:47:28 rillig Exp $"); | 41 | __RCSID("$NetBSD: decl.c,v 1.246 2022/02/27 08:31:26 rillig Exp $"); | |
42 | #endif | 42 | #endif | |
43 | 43 | |||
44 | #include <sys/param.h> | 44 | #include <sys/param.h> | |
45 | #include <limits.h> | 45 | #include <limits.h> | |
46 | #include <stdlib.h> | 46 | #include <stdlib.h> | |
47 | #include <string.h> | 47 | #include <string.h> | |
48 | 48 | |||
49 | #include "lint1.h" | 49 | #include "lint1.h" | |
50 | 50 | |||
51 | const char *unnamed = "<unnamed>"; | 51 | const char *unnamed = "<unnamed>"; | |
52 | 52 | |||
53 | /* shared type structures for arithmetic types and void */ | 53 | /* shared type structures for arithmetic types and void */ | |
54 | static type_t *typetab; | 54 | static type_t *typetab; | |
@@ -166,57 +166,57 @@ scl_name(scl_t scl) | @@ -166,57 +166,57 @@ scl_name(scl_t scl) | |||
166 | type_t * | 166 | type_t * | |
167 | gettyp(tspec_t t) | 167 | gettyp(tspec_t t) | |
168 | { | 168 | { | |
169 | 169 | |||
170 | /* TODO: make the return type 'const' */ | 170 | /* TODO: make the return type 'const' */ | |
171 | return &typetab[t]; | 171 | return &typetab[t]; | |
172 | } | 172 | } | |
173 | 173 | |||
174 | type_t * | 174 | type_t * | |
175 | dup_type(const type_t *tp) | 175 | dup_type(const type_t *tp) | |
176 | { | 176 | { | |
177 | type_t *ntp; | 177 | type_t *ntp; | |
178 | 178 | |||
179 | ntp = getblk(sizeof(*ntp)); | 179 | ntp = block_zero_alloc(sizeof(*ntp)); | |
180 | *ntp = *tp; | 180 | *ntp = *tp; | |
181 | return ntp; | 181 | return ntp; | |
182 | } | 182 | } | |
183 | 183 | |||
184 | /* | 184 | /* | |
185 | * Use expr_dup_type() instead of dup_type() inside expressions (if the | 185 | * Use expr_dup_type() instead of dup_type() inside expressions (if the | |
186 | * allocated memory should be freed after the expr). | 186 | * allocated memory should be freed after the expr). | |
187 | */ | 187 | */ | |
188 | type_t * | 188 | type_t * | |
189 | expr_dup_type(const type_t *tp) | 189 | expr_dup_type(const type_t *tp) | |
190 | { | 190 | { | |
191 | type_t *ntp; | 191 | type_t *ntp; | |
192 | 192 | |||
193 | ntp = expr_zalloc(sizeof(*ntp)); | 193 | ntp = expr_zero_alloc(sizeof(*ntp)); | |
194 | *ntp = *tp; | 194 | *ntp = *tp; | |
195 | return ntp; | 195 | return ntp; | |
196 | } | 196 | } | |
197 | 197 | |||
198 | /* | 198 | /* | |
199 | * Return the unqualified version of the type. The returned type is freed at | 199 | * Return the unqualified version of the type. The returned type is freed at | |
200 | * the end of the current expression. | 200 | * the end of the current expression. | |
201 | * | 201 | * | |
202 | * See C99 6.2.5p25. | 202 | * See C99 6.2.5p25. | |
203 | */ | 203 | */ | |
204 | type_t * | 204 | type_t * | |
205 | expr_unqualified_type(const type_t *tp) | 205 | expr_unqualified_type(const type_t *tp) | |
206 | { | 206 | { | |
207 | type_t *ntp; | 207 | type_t *ntp; | |
208 | 208 | |||
209 | ntp = expr_zalloc(sizeof(*ntp)); | 209 | ntp = expr_zero_alloc(sizeof(*ntp)); | |
210 | *ntp = *tp; | 210 | *ntp = *tp; | |
211 | ntp->t_const = false; | 211 | ntp->t_const = false; | |
212 | ntp->t_volatile = false; | 212 | ntp->t_volatile = false; | |
213 | 213 | |||
214 | /* | 214 | /* | |
215 | * In case of a struct or union type, the members should lose their | 215 | * In case of a struct or union type, the members should lose their | |
216 | * qualifiers as well, but that would require a deep copy of the | 216 | * qualifiers as well, but that would require a deep copy of the | |
217 | * struct or union type. This in turn would defeat the type | 217 | * struct or union type. This in turn would defeat the type | |
218 | * comparison in eqtype, which simply tests whether tp1->t_str == | 218 | * comparison in eqtype, which simply tests whether tp1->t_str == | |
219 | * tp2->t_str. | 219 | * tp2->t_str. | |
220 | */ | 220 | */ | |
221 | 221 | |||
222 | return ntp; | 222 | return ntp; | |
@@ -1242,27 +1242,27 @@ align(unsigned int al, unsigned int len) | @@ -1242,27 +1242,27 @@ align(unsigned int al, unsigned int len) | |||
1242 | no = (dcs->d_offset + (al - 1)) & ~(al - 1); | 1242 | no = (dcs->d_offset + (al - 1)) & ~(al - 1); | |
1243 | if (len == 0 || dcs->d_offset + len > no) | 1243 | if (len == 0 || dcs->d_offset + len > no) | |
1244 | dcs->d_offset = no; | 1244 | dcs->d_offset = no; | |
1245 | } | 1245 | } | |
1246 | 1246 | |||
1247 | /* | 1247 | /* | |
1248 | * Remember the width of the field in its type structure. | 1248 | * Remember the width of the field in its type structure. | |
1249 | */ | 1249 | */ | |
1250 | sym_t * | 1250 | sym_t * | |
1251 | bitfield(sym_t *dsym, int len) | 1251 | bitfield(sym_t *dsym, int len) | |
1252 | { | 1252 | { | |
1253 | 1253 | |||
1254 | if (dsym == NULL) { | 1254 | if (dsym == NULL) { | |
1255 | dsym = getblk(sizeof(*dsym)); | 1255 | dsym = block_zero_alloc(sizeof(*dsym)); | |
1256 | dsym->s_name = unnamed; | 1256 | dsym->s_name = unnamed; | |
1257 | dsym->s_kind = FMEMBER; | 1257 | dsym->s_kind = FMEMBER; | |
1258 | dsym->s_scl = MOS; | 1258 | dsym->s_scl = MOS; | |
1259 | dsym->s_type = gettyp(UINT); | 1259 | dsym->s_type = gettyp(UINT); | |
1260 | dsym->s_block_level = -1; | 1260 | dsym->s_block_level = -1; | |
1261 | } | 1261 | } | |
1262 | dsym->s_type = dup_type(dsym->s_type); | 1262 | dsym->s_type = dup_type(dsym->s_type); | |
1263 | dsym->s_type->t_bitfield = true; | 1263 | dsym->s_type->t_bitfield = true; | |
1264 | dsym->s_type->t_flen = len; | 1264 | dsym->s_type->t_flen = len; | |
1265 | dsym->s_bitfield = true; | 1265 | dsym->s_bitfield = true; | |
1266 | return dsym; | 1266 | return dsym; | |
1267 | } | 1267 | } | |
1268 | 1268 | |||
@@ -1318,54 +1318,54 @@ merge_qualified_pointer(qual_ptr *p1, qu | @@ -1318,54 +1318,54 @@ merge_qualified_pointer(qual_ptr *p1, qu | |||
1318 | sym_t * | 1318 | sym_t * | |
1319 | add_pointer(sym_t *decl, qual_ptr *p) | 1319 | add_pointer(sym_t *decl, qual_ptr *p) | |
1320 | { | 1320 | { | |
1321 | type_t **tpp, *tp; | 1321 | type_t **tpp, *tp; | |
1322 | qual_ptr *next; | 1322 | qual_ptr *next; | |
1323 | 1323 | |||
1324 | tpp = &decl->s_type; | 1324 | tpp = &decl->s_type; | |
1325 | while (*tpp != NULL && *tpp != dcs->d_type) | 1325 | while (*tpp != NULL && *tpp != dcs->d_type) | |
1326 | tpp = &(*tpp)->t_subt; | 1326 | tpp = &(*tpp)->t_subt; | |
1327 | if (*tpp == NULL) | 1327 | if (*tpp == NULL) | |
1328 | return decl; | 1328 | return decl; | |
1329 | 1329 | |||
1330 | while (p != NULL) { | 1330 | while (p != NULL) { | |
1331 | *tpp = tp = getblk(sizeof(*tp)); | 1331 | *tpp = tp = block_zero_alloc(sizeof(*tp)); | |
1332 | tp->t_tspec = PTR; | 1332 | tp->t_tspec = PTR; | |
1333 | tp->t_const = p->p_const; | 1333 | tp->t_const = p->p_const; | |
1334 | tp->t_volatile = p->p_volatile; | 1334 | tp->t_volatile = p->p_volatile; | |
1335 | *(tpp = &tp->t_subt) = dcs->d_type; | 1335 | *(tpp = &tp->t_subt) = dcs->d_type; | |
1336 | next = p->p_next; | 1336 | next = p->p_next; | |
1337 | free(p); | 1337 | free(p); | |
1338 | p = next; | 1338 | p = next; | |
1339 | } | 1339 | } | |
1340 | return decl; | 1340 | return decl; | |
1341 | } | 1341 | } | |
1342 | 1342 | |||
1343 | /* | 1343 | /* | |
1344 | * If a dimension was specified, dim is true, otherwise false | 1344 | * If a dimension was specified, dim is true, otherwise false | |
1345 | * n is the specified dimension | 1345 | * n is the specified dimension | |
1346 | */ | 1346 | */ | |
1347 | sym_t * | 1347 | sym_t * | |
1348 | add_array(sym_t *decl, bool dim, int n) | 1348 | add_array(sym_t *decl, bool dim, int n) | |
1349 | { | 1349 | { | |
1350 | type_t **tpp, *tp; | 1350 | type_t **tpp, *tp; | |
1351 | 1351 | |||
1352 | tpp = &decl->s_type; | 1352 | tpp = &decl->s_type; | |
1353 | while (*tpp != NULL && *tpp != dcs->d_type) | 1353 | while (*tpp != NULL && *tpp != dcs->d_type) | |
1354 | tpp = &(*tpp)->t_subt; | 1354 | tpp = &(*tpp)->t_subt; | |
1355 | if (*tpp == NULL) | 1355 | if (*tpp == NULL) | |
1356 | return decl; | 1356 | return decl; | |
1357 | 1357 | |||
1358 | *tpp = tp = getblk(sizeof(*tp)); | 1358 | *tpp = tp = block_zero_alloc(sizeof(*tp)); | |
1359 | tp->t_tspec = ARRAY; | 1359 | tp->t_tspec = ARRAY; | |
1360 | tp->t_subt = dcs->d_type; | 1360 | tp->t_subt = dcs->d_type; | |
1361 | tp->t_dim = n; | 1361 | tp->t_dim = n; | |
1362 | 1362 | |||
1363 | if (n < 0) { | 1363 | if (n < 0) { | |
1364 | /* negative array dimension (%d) */ | 1364 | /* negative array dimension (%d) */ | |
1365 | error(20, n); | 1365 | error(20, n); | |
1366 | n = 0; | 1366 | n = 0; | |
1367 | } else if (n == 0 && dim) { | 1367 | } else if (n == 0 && dim) { | |
1368 | /* zero sized array is a C99 extension */ | 1368 | /* zero sized array is a C99 extension */ | |
1369 | c99ism(322); | 1369 | c99ism(322); | |
1370 | } else if (n == 0 && !dim) { | 1370 | } else if (n == 0 && !dim) { | |
1371 | setcomplete(tp, false); | 1371 | setcomplete(tp, false); | |
@@ -1408,27 +1408,27 @@ add_function(sym_t *decl, sym_t *args) | @@ -1408,27 +1408,27 @@ add_function(sym_t *decl, sym_t *args) | |||
1408 | * XXX: What is this code doing on a semantic level, and why? | 1408 | * XXX: What is this code doing on a semantic level, and why? | |
1409 | * Returning decl leads to the wrong function types in msg_347. | 1409 | * Returning decl leads to the wrong function types in msg_347. | |
1410 | */ | 1410 | */ | |
1411 | tpp = &decl->s_type; | 1411 | tpp = &decl->s_type; | |
1412 | while (*tpp != NULL && *tpp != dcs->d_next->d_type) | 1412 | while (*tpp != NULL && *tpp != dcs->d_next->d_type) | |
1413 | /* | 1413 | /* | |
1414 | * XXX: accessing INT->t_subt feels strange, even though it | 1414 | * XXX: accessing INT->t_subt feels strange, even though it | |
1415 | * may even be guaranteed to be NULL. | 1415 | * may even be guaranteed to be NULL. | |
1416 | */ | 1416 | */ | |
1417 | tpp = &(*tpp)->t_subt; | 1417 | tpp = &(*tpp)->t_subt; | |
1418 | if (*tpp == NULL) | 1418 | if (*tpp == NULL) | |
1419 | return decl; /* see msg_347 */ | 1419 | return decl; /* see msg_347 */ | |
1420 | 1420 | |||
1421 | *tpp = tp = getblk(sizeof(*tp)); | 1421 | *tpp = tp = block_zero_alloc(sizeof(*tp)); | |
1422 | tp->t_tspec = FUNC; | 1422 | tp->t_tspec = FUNC; | |
1423 | tp->t_subt = dcs->d_next->d_type; | 1423 | tp->t_subt = dcs->d_next->d_type; | |
1424 | if ((tp->t_proto = dcs->d_proto) != false) | 1424 | if ((tp->t_proto = dcs->d_proto) != false) | |
1425 | tp->t_args = args; | 1425 | tp->t_args = args; | |
1426 | tp->t_vararg = dcs->d_vararg; | 1426 | tp->t_vararg = dcs->d_vararg; | |
1427 | 1427 | |||
1428 | return decl; | 1428 | return decl; | |
1429 | } | 1429 | } | |
1430 | 1430 | |||
1431 | /* | 1431 | /* | |
1432 | * Called for new style function declarations. | 1432 | * Called for new style function declarations. | |
1433 | */ | 1433 | */ | |
1434 | /* ARGSUSED */ | 1434 | /* ARGSUSED */ | |
@@ -1659,52 +1659,52 @@ mktag(sym_t *tag, tspec_t kind, bool dec | @@ -1659,52 +1659,52 @@ mktag(sym_t *tag, tspec_t kind, bool dec | |||
1659 | if (tag->s_scl != NOSCL) { | 1659 | if (tag->s_scl != NOSCL) { | |
1660 | tag = newtag(tag, scl, decl, semi); | 1660 | tag = newtag(tag, scl, decl, semi); | |
1661 | } else { | 1661 | } else { | |
1662 | /* a new tag, no empty declaration */ | 1662 | /* a new tag, no empty declaration */ | |
1663 | dcs->d_next->d_nonempty_decl = true; | 1663 | dcs->d_next->d_nonempty_decl = true; | |
1664 | if (scl == ENUM_TAG && !decl) { | 1664 | if (scl == ENUM_TAG && !decl) { | |
1665 | if (!tflag && (sflag || pflag)) | 1665 | if (!tflag && (sflag || pflag)) | |
1666 | /* forward reference to enum type */ | 1666 | /* forward reference to enum type */ | |
1667 | warning(42); | 1667 | warning(42); | |
1668 | } | 1668 | } | |
1669 | } | 1669 | } | |
1670 | if (tag->s_scl == NOSCL) { | 1670 | if (tag->s_scl == NOSCL) { | |
1671 | tag->s_scl = scl; | 1671 | tag->s_scl = scl; | |
1672 | tag->s_type = tp = getblk(sizeof(*tp)); | 1672 | tag->s_type = tp = block_zero_alloc(sizeof(*tp)); | |
1673 | tp->t_packed = dcs->d_packed; | 1673 | tp->t_packed = dcs->d_packed; | |
1674 | } else { | 1674 | } else { | |
1675 | tp = tag->s_type; | 1675 | tp = tag->s_type; | |
1676 | } | 1676 | } | |
1677 | } else { | 1677 | } else { | |
1678 | tag = getblk(sizeof(*tag)); | 1678 | tag = block_zero_alloc(sizeof(*tag)); | |
1679 | tag->s_name = unnamed; | 1679 | tag->s_name = unnamed; | |
1680 | UNIQUE_CURR_POS(tag->s_def_pos); | 1680 | UNIQUE_CURR_POS(tag->s_def_pos); | |
1681 | tag->s_kind = FTAG; | 1681 | tag->s_kind = FTAG; | |
1682 | tag->s_scl = scl; | 1682 | tag->s_scl = scl; | |
1683 | tag->s_block_level = -1; | 1683 | tag->s_block_level = -1; | |
1684 | tag->s_type = tp = getblk(sizeof(*tp)); | 1684 | tag->s_type = tp = block_zero_alloc(sizeof(*tp)); | |
1685 | tp->t_packed = dcs->d_packed; | 1685 | tp->t_packed = dcs->d_packed; | |
1686 | dcs->d_next->d_nonempty_decl = true; | 1686 | dcs->d_next->d_nonempty_decl = true; | |
1687 | } | 1687 | } | |
1688 | 1688 | |||
1689 | if (tp->t_tspec == NOTSPEC) { | 1689 | if (tp->t_tspec == NOTSPEC) { | |
1690 | tp->t_tspec = kind; | 1690 | tp->t_tspec = kind; | |
1691 | if (kind != ENUM) { | 1691 | if (kind != ENUM) { | |
1692 | tp->t_str = getblk(sizeof(*tp->t_str)); | 1692 | tp->t_str = block_zero_alloc(sizeof(*tp->t_str)); | |
1693 | tp->t_str->sou_align_in_bits = CHAR_SIZE; | 1693 | tp->t_str->sou_align_in_bits = CHAR_SIZE; | |
1694 | tp->t_str->sou_tag = tag; | 1694 | tp->t_str->sou_tag = tag; | |
1695 | } else { | 1695 | } else { | |
1696 | tp->t_is_enum = true; | 1696 | tp->t_is_enum = true; | |
1697 | tp->t_enum = getblk(sizeof(*tp->t_enum)); | 1697 | tp->t_enum = block_zero_alloc(sizeof(*tp->t_enum)); | |
1698 | tp->t_enum->en_tag = tag; | 1698 | tp->t_enum->en_tag = tag; | |
1699 | } | 1699 | } | |
1700 | setcomplete(tp, false); | 1700 | setcomplete(tp, false); | |
1701 | } | 1701 | } | |
1702 | return tp; | 1702 | return tp; | |
1703 | } | 1703 | } | |
1704 | 1704 | |||
1705 | /* | 1705 | /* | |
1706 | * Checks all possible cases of tag redeclarations. | 1706 | * Checks all possible cases of tag redeclarations. | |
1707 | * decl is true if T_LBRACE follows | 1707 | * decl is true if T_LBRACE follows | |
1708 | * semi is true if T_SEMI follows | 1708 | * semi is true if T_SEMI follows | |
1709 | */ | 1709 | */ | |
1710 | static sym_t * | 1710 | static sym_t * | |
@@ -1892,27 +1892,27 @@ enumeration_constant(sym_t *sym, int val | @@ -1892,27 +1892,27 @@ enumeration_constant(sym_t *sym, int val | |||
1892 | /* | 1892 | /* | |
1893 | * Process a single external declarator. | 1893 | * Process a single external declarator. | |
1894 | */ | 1894 | */ | |
1895 | static void | 1895 | static void | |
1896 | declare_extern(sym_t *dsym, bool initflg, sbuf_t *renaming) | 1896 | declare_extern(sym_t *dsym, bool initflg, sbuf_t *renaming) | |
1897 | { | 1897 | { | |
1898 | bool dowarn, rval, redec; | 1898 | bool dowarn, rval, redec; | |
1899 | sym_t *rdsym; | 1899 | sym_t *rdsym; | |
1900 | char *s; | 1900 | char *s; | |
1901 | 1901 | |||
1902 | if (renaming != NULL) { | 1902 | if (renaming != NULL) { | |
1903 | lint_assert(dsym->s_rename == NULL); | 1903 | lint_assert(dsym->s_rename == NULL); | |
1904 | 1904 | |||
1905 | s = getlblk(1, renaming->sb_len + 1); | 1905 | s = level_zero_alloc(1, renaming->sb_len + 1); | |
1906 | (void)memcpy(s, renaming->sb_name, renaming->sb_len + 1); | 1906 | (void)memcpy(s, renaming->sb_name, renaming->sb_len + 1); | |
1907 | dsym->s_rename = s; | 1907 | dsym->s_rename = s; | |
1908 | } | 1908 | } | |
1909 | 1909 | |||
1910 | check_function_definition(dsym, true); | 1910 | check_function_definition(dsym, true); | |
1911 | 1911 | |||
1912 | check_type(dsym); | 1912 | check_type(dsym); | |
1913 | 1913 | |||
1914 | if (initflg && !check_init(dsym)) | 1914 | if (initflg && !check_init(dsym)) | |
1915 | dsym->s_def = DEF; | 1915 | dsym->s_def = DEF; | |
1916 | 1916 | |||
1917 | /* | 1917 | /* | |
1918 | * Declarations of functions are marked as "tentative" in | 1918 | * Declarations of functions are marked as "tentative" in | |
@@ -2853,27 +2853,27 @@ check_init(sym_t *sym) | @@ -2853,27 +2853,27 @@ check_init(sym_t *sym) | |||
2853 | return erred; | 2853 | return erred; | |
2854 | } | 2854 | } | |
2855 | 2855 | |||
2856 | /* | 2856 | /* | |
2857 | * Create a symbol for an abstract declaration. | 2857 | * Create a symbol for an abstract declaration. | |
2858 | */ | 2858 | */ | |
2859 | sym_t * | 2859 | sym_t * | |
2860 | abstract_name(void) | 2860 | abstract_name(void) | |
2861 | { | 2861 | { | |
2862 | sym_t *sym; | 2862 | sym_t *sym; | |
2863 | 2863 | |||
2864 | lint_assert(dcs->d_ctx == ABSTRACT || dcs->d_ctx == PROTO_ARG); | 2864 | lint_assert(dcs->d_ctx == ABSTRACT || dcs->d_ctx == PROTO_ARG); | |
2865 | 2865 | |||
2866 | sym = getblk(sizeof(*sym)); | 2866 | sym = block_zero_alloc(sizeof(*sym)); | |
2867 | 2867 | |||
2868 | sym->s_name = unnamed; | 2868 | sym->s_name = unnamed; | |
2869 | sym->s_def = DEF; | 2869 | sym->s_def = DEF; | |
2870 | sym->s_scl = ABSTRACT; | 2870 | sym->s_scl = ABSTRACT; | |
2871 | sym->s_block_level = -1; | 2871 | sym->s_block_level = -1; | |
2872 | 2872 | |||
2873 | if (dcs->d_ctx == PROTO_ARG) | 2873 | if (dcs->d_ctx == PROTO_ARG) | |
2874 | sym->s_arg = true; | 2874 | sym->s_arg = true; | |
2875 | 2875 | |||
2876 | /* | 2876 | /* | |
2877 | * At this point, dcs->d_type contains only the basic type. That | 2877 | * At this point, dcs->d_type contains only the basic type. That | |
2878 | * type will be updated later, adding pointers, arrays and functions | 2878 | * type will be updated later, adding pointers, arrays and functions | |
2879 | * as necessary. | 2879 | * as necessary. |
--- src/usr.bin/xlint/lint1/externs1.h 2022/02/26 20:36:11 1.146
+++ src/usr.bin/xlint/lint1/externs1.h 2022/02/27 08:31:26 1.147
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: externs1.h,v 1.146 2022/02/26 20:36:11 rillig Exp $ */ | 1 | /* $NetBSD: externs1.h,v 1.147 2022/02/27 08:31:26 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. | |
@@ -51,27 +51,27 @@ extern bool vflag; | @@ -51,27 +51,27 @@ extern bool vflag; | |||
51 | extern bool yflag; | 51 | extern bool yflag; | |
52 | extern bool wflag; | 52 | extern bool wflag; | |
53 | extern bool zflag; | 53 | extern bool zflag; | |
54 | extern bool Sflag; | 54 | extern bool Sflag; | |
55 | extern bool Tflag; | 55 | extern bool Tflag; | |
56 | extern bool Pflag; | 56 | extern bool Pflag; | |
57 | 57 | |||
58 | extern void norecover(void); | 58 | extern void norecover(void); | |
59 | 59 | |||
60 | /* | 60 | /* | |
61 | * cgram.y | 61 | * cgram.y | |
62 | */ | 62 | */ | |
63 | extern int block_level; | 63 | extern int block_level; | |
64 | extern int mem_block_level; | 64 | extern size_t mem_block_level; | |
65 | extern int yydebug; | 65 | extern int yydebug; | |
66 | 66 | |||
67 | extern int yyerror(const char *); | 67 | extern int yyerror(const char *); | |
68 | extern int yyparse(void); | 68 | extern int yyparse(void); | |
69 | 69 | |||
70 | /* | 70 | /* | |
71 | * scan.l | 71 | * scan.l | |
72 | */ | 72 | */ | |
73 | extern bool in_gcc_attribute; | 73 | extern bool in_gcc_attribute; | |
74 | extern pos_t curr_pos; | 74 | extern pos_t curr_pos; | |
75 | extern pos_t csrc_pos; | 75 | extern pos_t csrc_pos; | |
76 | extern bool in_system_header; | 76 | extern bool in_system_header; | |
77 | extern symt_t symtyp; | 77 | extern symt_t symtyp; | |
@@ -90,33 +90,32 @@ extern void inssym(int, sym_t *); | @@ -90,33 +90,32 @@ extern void inssym(int, sym_t *); | |||
90 | extern void freeyyv(void *, int); | 90 | extern void freeyyv(void *, int); | |
91 | extern int yylex(void); | 91 | extern int yylex(void); | |
92 | 92 | |||
93 | /* | 93 | /* | |
94 | * mem1.c | 94 | * mem1.c | |
95 | */ | 95 | */ | |
96 | extern const char *record_filename(const char *, size_t); | 96 | extern const char *record_filename(const char *, size_t); | |
97 | extern int get_filename_id(const char *); | 97 | extern int get_filename_id(const char *); | |
98 | extern void add_directory_replacement(char *); | 98 | extern void add_directory_replacement(char *); | |
99 | extern const char *transform_filename(const char *, size_t); | 99 | extern const char *transform_filename(const char *, size_t); | |
100 | 100 | |||
101 | extern void initmem(void); | 101 | extern void initmem(void); | |
102 | 102 | |||
103 | extern void *getblk(size_t); | 103 | extern void *block_zero_alloc(size_t); | |
104 | extern void *getlblk(size_t, size_t); | 104 | extern void *level_zero_alloc(size_t, size_t); | |
105 | extern void freeblk(void); | 105 | extern void level_free_all(size_t); | |
106 | extern void freelblk(int); | |||
107 | 106 | |||
108 | extern void *expr_zalloc(size_t); | 107 | extern void *expr_zero_alloc(size_t); | |
109 | extern tnode_t *expr_zalloc_tnode(void); | 108 | extern tnode_t *expr_alloc_tnode(void); | |
110 | extern void expr_free_all(void); | 109 | extern void expr_free_all(void); | |
111 | extern struct memory_block *expr_save_memory(void); | 110 | extern struct memory_block *expr_save_memory(void); | |
112 | extern void expr_restore_memory(struct memory_block *); | 111 | extern void expr_restore_memory(struct memory_block *); | |
113 | 112 | |||
114 | /* | 113 | /* | |
115 | * debug.c | 114 | * debug.c | |
116 | */ | 115 | */ | |
117 | 116 | |||
118 | #ifdef DEBUG | 117 | #ifdef DEBUG | |
119 | void debug_node(const tnode_t *); | 118 | void debug_node(const tnode_t *); | |
120 | void debug_printf(const char *fmt, ...) __printflike(1, 2); | 119 | void debug_printf(const char *fmt, ...) __printflike(1, 2); | |
121 | void debug_print_indent(void); | 120 | void debug_print_indent(void); | |
122 | void debug_indent_inc(void); | 121 | void debug_indent_inc(void); |
--- src/usr.bin/xlint/lint1/func.c 2021/11/16 21:01:05 1.126
+++ src/usr.bin/xlint/lint1/func.c 2022/02/27 08:31:26 1.127
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: func.c,v 1.126 2021/11/16 21:01:05 rillig Exp $ */ | 1 | /* $NetBSD: func.c,v 1.127 2022/02/27 08:31:26 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: func.c,v 1.126 2021/11/16 21:01:05 rillig Exp $"); | 40 | __RCSID("$NetBSD: func.c,v 1.127 2022/02/27 08:31:26 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 | #include "cgram.h" | 47 | #include "cgram.h" | |
48 | 48 | |||
49 | /* | 49 | /* | |
50 | * Contains a pointer to the symbol table entry of the current function | 50 | * Contains a pointer to the symbol table entry of the current function | |
51 | * definition. | 51 | * definition. | |
52 | */ | 52 | */ | |
53 | sym_t *funcsym; | 53 | sym_t *funcsym; | |
@@ -1076,27 +1076,27 @@ do_return(bool sys, tnode_t *tn) | @@ -1076,27 +1076,27 @@ do_return(bool sys, tnode_t *tn) | |||
1076 | } else if (tn == NULL && funcsym->s_type->t_subt->t_tspec != VOID) { | 1076 | } else if (tn == NULL && funcsym->s_type->t_subt->t_tspec != VOID) { | |
1077 | /* | 1077 | /* | |
1078 | * Assume that the function has a return value only if it | 1078 | * Assume that the function has a return value only if it | |
1079 | * is explicitly declared. | 1079 | * is explicitly declared. | |
1080 | */ | 1080 | */ | |
1081 | if (!funcsym->s_return_type_implicit_int) | 1081 | if (!funcsym->s_return_type_implicit_int) | |
1082 | /* function '%s' expects to return value */ | 1082 | /* function '%s' expects to return value */ | |
1083 | warning(214, funcsym->s_name); | 1083 | warning(214, funcsym->s_name); | |
1084 | } | 1084 | } | |
1085 | 1085 | |||
1086 | if (tn != NULL) { | 1086 | if (tn != NULL) { | |
1087 | 1087 | |||
1088 | /* Create a temporary node for the left side */ | 1088 | /* Create a temporary node for the left side */ | |
1089 | ln = expr_zalloc(sizeof(*ln)); | 1089 | ln = expr_zero_alloc(sizeof(*ln)); | |
1090 | ln->tn_op = NAME; | 1090 | ln->tn_op = NAME; | |
1091 | ln->tn_type = expr_unqualified_type(funcsym->s_type->t_subt); | 1091 | ln->tn_type = expr_unqualified_type(funcsym->s_type->t_subt); | |
1092 | ln->tn_lvalue = true; | 1092 | ln->tn_lvalue = true; | |
1093 | ln->tn_sym = funcsym; /* better than nothing */ | 1093 | ln->tn_sym = funcsym; /* better than nothing */ | |
1094 | 1094 | |||
1095 | tn = build_binary(ln, RETURN, sys, tn); | 1095 | tn = build_binary(ln, RETURN, sys, tn); | |
1096 | 1096 | |||
1097 | if (tn != NULL) { | 1097 | if (tn != NULL) { | |
1098 | rn = tn->tn_right; | 1098 | rn = tn->tn_right; | |
1099 | while ((op = rn->tn_op) == CVT || op == PLUS) | 1099 | while ((op = rn->tn_op) == CVT || op == PLUS) | |
1100 | rn = rn->tn_left; | 1100 | rn = rn->tn_left; | |
1101 | if (rn->tn_op == ADDR && rn->tn_left->tn_op == NAME && | 1101 | if (rn->tn_op == ADDR && rn->tn_left->tn_op == NAME && | |
1102 | rn->tn_left->tn_sym->s_scl == AUTO) { | 1102 | rn->tn_left->tn_sym->s_scl == AUTO) { |
--- src/usr.bin/xlint/lint1/init.c 2021/12/22 14:35:23 1.230
+++ src/usr.bin/xlint/lint1/init.c 2022/02/27 08:31:26 1.231
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: init.c,v 1.230 2021/12/22 14:35:23 rillig Exp $ */ | 1 | /* $NetBSD: init.c,v 1.231 2022/02/27 08:31:26 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.230 2021/12/22 14:35:23 rillig Exp $"); | 41 | __RCSID("$NetBSD: init.c,v 1.231 2022/02/27 08:31:26 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 }; | |
@@ -304,27 +304,27 @@ check_trad_no_auto_aggregate(const sym_t | @@ -304,27 +304,27 @@ check_trad_no_auto_aggregate(const sym_t | |||
304 | } | 304 | } | |
305 | 305 | |||
306 | static void | 306 | static void | |
307 | check_init_expr(const type_t *ltp, sym_t *lsym, tnode_t *rn) | 307 | check_init_expr(const type_t *ltp, sym_t *lsym, tnode_t *rn) | |
308 | { | 308 | { | |
309 | tnode_t *ln; | 309 | tnode_t *ln; | |
310 | type_t *lutp; | 310 | type_t *lutp; | |
311 | tspec_t lt, rt; | 311 | tspec_t lt, rt; | |
312 | struct memory_block *tmem; | 312 | struct memory_block *tmem; | |
313 | 313 | |||
314 | lutp = expr_unqualified_type(ltp); | 314 | lutp = expr_unqualified_type(ltp); | |
315 | 315 | |||
316 | /* Create a temporary node for the left side. */ | 316 | /* Create a temporary node for the left side. */ | |
317 | ln = expr_zalloc(sizeof(*ln)); | 317 | ln = expr_zero_alloc(sizeof(*ln)); | |
318 | ln->tn_op = NAME; | 318 | ln->tn_op = NAME; | |
319 | ln->tn_type = lutp; | 319 | ln->tn_type = lutp; | |
320 | ln->tn_lvalue = true; | 320 | ln->tn_lvalue = true; | |
321 | ln->tn_sym = lsym; | 321 | ln->tn_sym = lsym; | |
322 | 322 | |||
323 | rn = cconv(rn); | 323 | rn = cconv(rn); | |
324 | 324 | |||
325 | lt = ln->tn_type->t_tspec; | 325 | lt = ln->tn_type->t_tspec; | |
326 | rt = rn->tn_type->t_tspec; | 326 | rt = rn->tn_type->t_tspec; | |
327 | 327 | |||
328 | debug_step("typeok '%s', '%s'", | 328 | debug_step("typeok '%s', '%s'", | |
329 | type_name(ln->tn_type), type_name(rn->tn_type)); | 329 | type_name(ln->tn_type), type_name(rn->tn_type)); | |
330 | if (!typeok(INIT, 0, ln, rn)) | 330 | if (!typeok(INIT, 0, ln, rn)) |
--- src/usr.bin/xlint/lint1/lex.c 2022/02/27 07:50:09 1.100
+++ src/usr.bin/xlint/lint1/lex.c 2022/02/27 08:31:26 1.101
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: lex.c,v 1.100 2022/02/27 07:50:09 rillig Exp $ */ | 1 | /* $NetBSD: lex.c,v 1.101 2022/02/27 08:31:26 rillig Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. | 4 | * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. | |
5 | * Copyright (c) 1994, 1995 Jochen Pohl | 5 | * Copyright (c) 1994, 1995 Jochen Pohl | |
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: lex.c,v 1.100 2022/02/27 07:50:09 rillig Exp $"); | 41 | __RCSID("$NetBSD: lex.c,v 1.101 2022/02/27 08:31:26 rillig Exp $"); | |
42 | #endif | 42 | #endif | |
43 | 43 | |||
44 | #include <ctype.h> | 44 | #include <ctype.h> | |
45 | #include <errno.h> | 45 | #include <errno.h> | |
46 | #include <float.h> | 46 | #include <float.h> | |
47 | #include <limits.h> | 47 | #include <limits.h> | |
48 | #include <math.h> | 48 | #include <math.h> | |
49 | #include <stdlib.h> | 49 | #include <stdlib.h> | |
50 | #include <string.h> | 50 | #include <string.h> | |
51 | 51 | |||
52 | #include "lint1.h" | 52 | #include "lint1.h" | |
53 | #include "cgram.h" | 53 | #include "cgram.h" | |
54 | 54 | |||
@@ -287,27 +287,27 @@ add_keyword(const struct keyword *kw, bo | @@ -287,27 +287,27 @@ add_keyword(const struct keyword *kw, bo | |||
287 | { | 287 | { | |
288 | sym_t *sym; | 288 | sym_t *sym; | |
289 | char buf[256]; | 289 | char buf[256]; | |
290 | const char *name; | 290 | const char *name; | |
291 | 291 | |||
292 | if (!leading && !trailing) { | 292 | if (!leading && !trailing) { | |
293 | name = kw->kw_name; | 293 | name = kw->kw_name; | |
294 | } else { | 294 | } else { | |
295 | (void)snprintf(buf, sizeof(buf), "%s%s%s", | 295 | (void)snprintf(buf, sizeof(buf), "%s%s%s", | |
296 | leading ? "__" : "", kw->kw_name, trailing ? "__" : ""); | 296 | leading ? "__" : "", kw->kw_name, trailing ? "__" : ""); | |
297 | name = xstrdup(buf); | 297 | name = xstrdup(buf); | |
298 | } | 298 | } | |
299 | 299 | |||
300 | sym = getblk(sizeof(*sym)); | 300 | sym = block_zero_alloc(sizeof(*sym)); | |
301 | sym->s_name = name; | 301 | sym->s_name = name; | |
302 | sym->s_keyword = kw; | 302 | sym->s_keyword = kw; | |
303 | sym->s_value.v_quad = kw->kw_token; | 303 | sym->s_value.v_quad = kw->kw_token; | |
304 | if (kw->kw_token == T_TYPE || kw->kw_token == T_STRUCT_OR_UNION) { | 304 | if (kw->kw_token == T_TYPE || kw->kw_token == T_STRUCT_OR_UNION) { | |
305 | sym->s_tspec = kw->kw_tspec; | 305 | sym->s_tspec = kw->kw_tspec; | |
306 | } else if (kw->kw_token == T_SCLASS) { | 306 | } else if (kw->kw_token == T_SCLASS) { | |
307 | sym->s_scl = kw->kw_scl; | 307 | sym->s_scl = kw->kw_scl; | |
308 | } else if (kw->kw_token == T_QUAL) { | 308 | } else if (kw->kw_token == T_QUAL) { | |
309 | sym->s_tqual = kw->kw_tqual; | 309 | sym->s_tqual = kw->kw_tqual; | |
310 | } | 310 | } | |
311 | 311 | |||
312 | symtab_add(sym); | 312 | symtab_add(sym); | |
313 | } | 313 | } | |
@@ -397,27 +397,27 @@ lex_name(const char *yytext, size_t yyle | @@ -397,27 +397,27 @@ lex_name(const char *yytext, size_t yyle | |||
397 | if ((sym = search(sb)) != NULL && sym->s_keyword != NULL) { | 397 | if ((sym = search(sb)) != NULL && sym->s_keyword != NULL) { | |
398 | free(sb); | 398 | free(sb); | |
399 | return keyw(sym); | 399 | return keyw(sym); | |
400 | } | 400 | } | |
401 | 401 | |||
402 | sb->sb_sym = sym; | 402 | sb->sb_sym = sym; | |
403 | 403 | |||
404 | if (sym != NULL) { | 404 | if (sym != NULL) { | |
405 | lint_assert(block_level >= sym->s_block_level); | 405 | lint_assert(block_level >= sym->s_block_level); | |
406 | sb->sb_name = sym->s_name; | 406 | sb->sb_name = sym->s_name; | |
407 | sb->sb_len = strlen(sym->s_name); | 407 | sb->sb_len = strlen(sym->s_name); | |
408 | tok = sym->s_scl == TYPEDEF ? T_TYPENAME : T_NAME; | 408 | tok = sym->s_scl == TYPEDEF ? T_TYPENAME : T_NAME; | |
409 | } else { | 409 | } else { | |
410 | s = getblk(yyleng + 1); | 410 | s = block_zero_alloc(yyleng + 1); | |
411 | (void)memcpy(s, yytext, yyleng + 1); | 411 | (void)memcpy(s, yytext, yyleng + 1); | |
412 | sb->sb_name = s; | 412 | sb->sb_name = s; | |
413 | sb->sb_len = yyleng; | 413 | sb->sb_len = yyleng; | |
414 | tok = T_NAME; | 414 | tok = T_NAME; | |
415 | } | 415 | } | |
416 | 416 | |||
417 | yylval.y_name = sb; | 417 | yylval.y_name = sb; | |
418 | return tok; | 418 | return tok; | |
419 | } | 419 | } | |
420 | 420 | |||
421 | static sym_t * | 421 | static sym_t * | |
422 | search(sbuf_t *sb) | 422 | search(sbuf_t *sb) | |
423 | { | 423 | { | |
@@ -1342,37 +1342,37 @@ getsym(sbuf_t *sb) | @@ -1342,37 +1342,37 @@ getsym(sbuf_t *sb) | |||
1342 | } | 1342 | } | |
1343 | 1343 | |||
1344 | if (sym != NULL) { | 1344 | if (sym != NULL) { | |
1345 | lint_assert(sym->s_kind == symtyp); | 1345 | lint_assert(sym->s_kind == symtyp); | |
1346 | symtyp = FVFT; | 1346 | symtyp = FVFT; | |
1347 | free(sb); | 1347 | free(sb); | |
1348 | return sym; | 1348 | return sym; | |
1349 | } | 1349 | } | |
1350 | 1350 | |||
1351 | /* create a new symbol table entry */ | 1351 | /* create a new symbol table entry */ | |
1352 | 1352 | |||
1353 | /* labels must always be allocated at level 1 (outermost block) */ | 1353 | /* labels must always be allocated at level 1 (outermost block) */ | |
1354 | if (symtyp == FLABEL) { | 1354 | if (symtyp == FLABEL) { | |
1355 | sym = getlblk(1, sizeof(*sym)); | 1355 | sym = level_zero_alloc(1, sizeof(*sym)); | |
1356 | s = getlblk(1, sb->sb_len + 1); | 1356 | s = level_zero_alloc(1, sb->sb_len + 1); | |
1357 | (void)memcpy(s, sb->sb_name, sb->sb_len + 1); | 1357 | (void)memcpy(s, sb->sb_name, sb->sb_len + 1); | |
1358 | sym->s_name = s; | 1358 | sym->s_name = s; | |
1359 | sym->s_block_level = 1; | 1359 | sym->s_block_level = 1; | |
1360 | di = dcs; | 1360 | di = dcs; | |
1361 | while (di->d_next != NULL && di->d_next->d_next != NULL) | 1361 | while (di->d_next != NULL && di->d_next->d_next != NULL) | |
1362 | di = di->d_next; | 1362 | di = di->d_next; | |
1363 | lint_assert(di->d_ctx == AUTO); | 1363 | lint_assert(di->d_ctx == AUTO); | |
1364 | } else { | 1364 | } else { | |
1365 | sym = getblk(sizeof(*sym)); | 1365 | sym = block_zero_alloc(sizeof(*sym)); | |
1366 | sym->s_name = sb->sb_name; | 1366 | sym->s_name = sb->sb_name; | |
1367 | sym->s_block_level = block_level; | 1367 | sym->s_block_level = block_level; | |
1368 | di = dcs; | 1368 | di = dcs; | |
1369 | } | 1369 | } | |
1370 | 1370 | |||
1371 | UNIQUE_CURR_POS(sym->s_def_pos); | 1371 | UNIQUE_CURR_POS(sym->s_def_pos); | |
1372 | if ((sym->s_kind = symtyp) != FLABEL) | 1372 | if ((sym->s_kind = symtyp) != FLABEL) | |
1373 | sym->s_type = gettyp(INT); | 1373 | sym->s_type = gettyp(INT); | |
1374 | 1374 | |||
1375 | symtyp = FVFT; | 1375 | symtyp = FVFT; | |
1376 | 1376 | |||
1377 | symtab_add(sym); | 1377 | symtab_add(sym); | |
1378 | 1378 | |||
@@ -1381,28 +1381,28 @@ getsym(sbuf_t *sb) | @@ -1381,28 +1381,28 @@ getsym(sbuf_t *sb) | |||
1381 | 1381 | |||
1382 | free(sb); | 1382 | free(sb); | |
1383 | return sym; | 1383 | return sym; | |
1384 | } | 1384 | } | |
1385 | 1385 | |||
1386 | /* | 1386 | /* | |
1387 | * Construct a temporary symbol. The symbol name starts with a digit, making | 1387 | * Construct a temporary symbol. The symbol name starts with a digit, making | |
1388 | * the name illegal. | 1388 | * the name illegal. | |
1389 | */ | 1389 | */ | |
1390 | sym_t * | 1390 | sym_t * | |
1391 | mktempsym(type_t *t) | 1391 | mktempsym(type_t *t) | |
1392 | { | 1392 | { | |
1393 | static int n = 0; | 1393 | static int n = 0; | |
1394 | char *s = getlblk(block_level, 64); | 1394 | char *s = level_zero_alloc(block_level, 64); | |
1395 | sym_t *sym = getblk(sizeof(*sym)); | 1395 | sym_t *sym = block_zero_alloc(sizeof(*sym)); | |
1396 | scl_t scl; | 1396 | scl_t scl; | |
1397 | 1397 | |||
1398 | (void)snprintf(s, 64, "%.8d_tmp", n++); | 1398 | (void)snprintf(s, 64, "%.8d_tmp", n++); | |
1399 | 1399 | |||
1400 | scl = dcs->d_scl; | 1400 | scl = dcs->d_scl; | |
1401 | if (scl == NOSCL) | 1401 | if (scl == NOSCL) | |
1402 | scl = block_level > 0 ? AUTO : EXTERN; | 1402 | scl = block_level > 0 ? AUTO : EXTERN; | |
1403 | 1403 | |||
1404 | sym->s_name = s; | 1404 | sym->s_name = s; | |
1405 | sym->s_type = t; | 1405 | sym->s_type = t; | |
1406 | sym->s_block_level = block_level; | 1406 | sym->s_block_level = block_level; | |
1407 | sym->s_scl = scl; | 1407 | sym->s_scl = scl; | |
1408 | sym->s_kind = FVFT; | 1408 | sym->s_kind = FVFT; | |
@@ -1466,51 +1466,51 @@ inssym(int bl, sym_t *sym) | @@ -1466,51 +1466,51 @@ inssym(int bl, sym_t *sym) | |||
1466 | } | 1466 | } | |
1467 | 1467 | |||
1468 | /* | 1468 | /* | |
1469 | * Called at level 0 after syntax errors. | 1469 | * Called at level 0 after syntax errors. | |
1470 | * | 1470 | * | |
1471 | * Removes all symbols which are not declared at level 0 from the | 1471 | * Removes all symbols which are not declared at level 0 from the | |
1472 | * symbol table. Also frees all memory which is not associated with | 1472 | * symbol table. Also frees all memory which is not associated with | |
1473 | * level 0. | 1473 | * level 0. | |
1474 | */ | 1474 | */ | |
1475 | void | 1475 | void | |
1476 | cleanup(void) | 1476 | cleanup(void) | |
1477 | { | 1477 | { | |
1478 | sym_t *sym, *nsym; | 1478 | sym_t *sym, *nsym; | |
1479 | int i; | 1479 | size_t i; | |
1480 | 1480 | |||
1481 | for (i = 0; i < HSHSIZ1; i++) { | 1481 | for (i = 0; i < HSHSIZ1; i++) { | |
1482 | for (sym = symtab[i]; sym != NULL; sym = nsym) { | 1482 | for (sym = symtab[i]; sym != NULL; sym = nsym) { | |
1483 | nsym = sym->s_link; | 1483 | nsym = sym->s_link; | |
1484 | if (sym->s_block_level >= 1) | 1484 | if (sym->s_block_level >= 1) | |
1485 | symtab_remove(sym); | 1485 | symtab_remove(sym); | |
1486 | } | 1486 | } | |
1487 | } | 1487 | } | |
1488 | 1488 | |||
1489 | for (i = mem_block_level; i > 0; i--) | 1489 | for (i = mem_block_level; i > 0; i--) | |
1490 | freelblk(i); | 1490 | level_free_all(i); | |
1491 | } | 1491 | } | |
1492 | 1492 | |||
1493 | /* | 1493 | /* | |
1494 | * Create a new symbol with the name of an existing symbol. | 1494 | * Create a new symbol with the name of an existing symbol. | |
1495 | */ | 1495 | */ | |
1496 | sym_t * | 1496 | sym_t * | |
1497 | pushdown(const sym_t *sym) | 1497 | pushdown(const sym_t *sym) | |
1498 | { | 1498 | { | |
1499 | sym_t *nsym; | 1499 | sym_t *nsym; | |
1500 | 1500 | |||
1501 | debug_step("pushdown '%s' %s '%s'", | 1501 | debug_step("pushdown '%s' %s '%s'", | |
1502 | sym->s_name, symt_name(sym->s_kind), type_name(sym->s_type)); | 1502 | sym->s_name, symt_name(sym->s_kind), type_name(sym->s_type)); | |
1503 | nsym = getblk(sizeof(*nsym)); | 1503 | nsym = block_zero_alloc(sizeof(*nsym)); | |
1504 | lint_assert(sym->s_block_level <= block_level); | 1504 | lint_assert(sym->s_block_level <= block_level); | |
1505 | nsym->s_name = sym->s_name; | 1505 | nsym->s_name = sym->s_name; | |
1506 | UNIQUE_CURR_POS(nsym->s_def_pos); | 1506 | UNIQUE_CURR_POS(nsym->s_def_pos); | |
1507 | nsym->s_kind = sym->s_kind; | 1507 | nsym->s_kind = sym->s_kind; | |
1508 | nsym->s_block_level = block_level; | 1508 | nsym->s_block_level = block_level; | |
1509 | 1509 | |||
1510 | symtab_add(nsym); | 1510 | symtab_add(nsym); | |
1511 | 1511 | |||
1512 | *dcs->d_ldlsym = nsym; | 1512 | *dcs->d_ldlsym = nsym; | |
1513 | dcs->d_ldlsym = &nsym->s_dlnxt; | 1513 | dcs->d_ldlsym = &nsym->s_dlnxt; | |
1514 | 1514 | |||
1515 | return nsym; | 1515 | return nsym; | |
1516 | } | 1516 | } |
--- src/usr.bin/xlint/lint1/mem1.c 2022/02/27 07:38:54 1.59
+++ src/usr.bin/xlint/lint1/mem1.c 2022/02/27 08:31:26 1.60
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: mem1.c,v 1.59 2022/02/27 07:38:54 rillig Exp $ */ | 1 | /* $NetBSD: mem1.c,v 1.60 2022/02/27 08:31:26 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: mem1.c,v 1.59 2022/02/27 07:38:54 rillig Exp $"); | 40 | __RCSID("$NetBSD: mem1.c,v 1.60 2022/02/27 08:31:26 rillig Exp $"); | |
41 | #endif | 41 | #endif | |
42 | 42 | |||
43 | #include <sys/param.h> | 43 | #include <sys/param.h> | |
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 | * Filenames allocated by record_filename are shared and have unlimited | 50 | * Filenames allocated by record_filename are shared and have unlimited | |
51 | * lifetime. | 51 | * lifetime. | |
52 | */ | 52 | */ | |
53 | struct filename { | 53 | struct filename { | |
@@ -233,97 +233,84 @@ xfreeblk(memory_block **fmbp) | @@ -233,97 +233,84 @@ xfreeblk(memory_block **fmbp) | |||
233 | } | 233 | } | |
234 | 234 | |||
235 | void | 235 | void | |
236 | initmem(void) | 236 | initmem(void) | |
237 | { | 237 | { | |
238 | 238 | |||
239 | mblk_size = mem_block_size(); | 239 | mblk_size = mem_block_size(); | |
240 | mblks = xcalloc(nmblks = ML_INC, sizeof(*mblks)); | 240 | mblks = xcalloc(nmblks = ML_INC, sizeof(*mblks)); | |
241 | } | 241 | } | |
242 | 242 | |||
243 | 243 | |||
244 | /* Allocate memory associated with level l, initialized with zero. */ | 244 | /* Allocate memory associated with level l, initialized with zero. */ | |
245 | void * | 245 | void * | |
246 | getlblk(size_t l, size_t s) | 246 | level_zero_alloc(size_t l, size_t s) | |
247 | { | 247 | { | |
248 | 248 | |||
249 | while (l >= nmblks) { | 249 | while (l >= nmblks) { | |
250 | mblks = xrealloc(mblks, (nmblks + ML_INC) * sizeof(*mblks)); | 250 | mblks = xrealloc(mblks, (nmblks + ML_INC) * sizeof(*mblks)); | |
251 | (void)memset(&mblks[nmblks], 0, ML_INC * sizeof(*mblks)); | 251 | (void)memset(&mblks[nmblks], 0, ML_INC * sizeof(*mblks)); | |
252 | nmblks += ML_INC; | 252 | nmblks += ML_INC; | |
253 | } | 253 | } | |
254 | return xgetblk(&mblks[l], s); | 254 | return xgetblk(&mblks[l], s); | |
255 | } | 255 | } | |
256 | 256 | |||
257 | /* | 257 | /* Allocate memory that is freed at the end of the current block. */ | |
258 | * Return allocated memory for the current mem_block_level, initialized with | |||
259 | * zero. | |||
260 | */ | |||
261 | void * | 258 | void * | |
262 | getblk(size_t s) | 259 | block_zero_alloc(size_t s) | |
263 | { | 260 | { | |
264 | 261 | |||
265 | return getlblk(mem_block_level, s); | 262 | return level_zero_alloc(mem_block_level, s); | |
266 | } | 263 | } | |
267 | 264 | |||
268 | /* Free all memory associated with level l. */ | |||
269 | void | 265 | void | |
270 | freelblk(int l) | 266 | level_free_all(size_t level) | |
271 | { | 267 | { | |
272 | 268 | |||
273 | xfreeblk(&mblks[l]); | 269 | xfreeblk(&mblks[level]); | |
274 | } | 270 | } | |
275 | 271 | |||
276 | void | |||
277 | freeblk(void) | |||
278 | { | |||
279 | ||||
280 | freelblk(mem_block_level); | |||
281 | } | |||
282 | 272 | |||
283 | static memory_block *tmblk; | 273 | static memory_block *tmblk; | |
284 | 274 | |||
285 | /* | 275 | /* Allocate memory that is freed at the end of the current expression. */ | |
286 | * Return zero-initialized memory that is freed at the end of the current | |||
287 | * expression. | |||
288 | */ | |||
289 | void * | 276 | void * | |
290 | expr_zalloc(size_t s) | 277 | expr_zero_alloc(size_t s) | |
291 | { | 278 | { | |
292 | 279 | |||
293 | return xgetblk(&tmblk, s); | 280 | return xgetblk(&tmblk, s); | |
294 | } | 281 | } | |
295 | 282 | |||
296 | static bool | 283 | static bool | |
297 | str_endswith(const char *haystack, const char *needle) | 284 | str_endswith(const char *haystack, const char *needle) | |
298 | { | 285 | { | |
299 | size_t hlen = strlen(haystack); | 286 | size_t hlen = strlen(haystack); | |
300 | size_t nlen = strlen(needle); | 287 | size_t nlen = strlen(needle); | |
301 | 288 | |||
302 | return nlen <= hlen && | 289 | return nlen <= hlen && | |
303 | memcmp(haystack + hlen - nlen, needle, nlen) == 0; | 290 | memcmp(haystack + hlen - nlen, needle, nlen) == 0; | |
304 | } | 291 | } | |
305 | 292 | |||
306 | /* | 293 | /* | |
307 | * Return a freshly allocated tree node that is freed at the end of the | 294 | * Return a freshly allocated tree node that is freed at the end of the | |
308 | * current expression. | 295 | * current expression. | |
309 | * | 296 | * | |
310 | * The node records whether it comes from a system file, which makes strict | 297 | * The node records whether it comes from a system file, which makes strict | |
311 | * bool mode less restrictive. | 298 | * bool mode less restrictive. | |
312 | */ | 299 | */ | |
313 | tnode_t * | 300 | tnode_t * | |
314 | expr_zalloc_tnode(void) | 301 | expr_alloc_tnode(void) | |
315 | { | 302 | { | |
316 | tnode_t *tn = expr_zalloc(sizeof(*tn)); | 303 | tnode_t *tn = expr_zero_alloc(sizeof(*tn)); | |
317 | /* | 304 | /* | |
318 | * files named *.c that are different from the main translation unit | 305 | * files named *.c that are different from the main translation unit | |
319 | * typically contain generated code that cannot be influenced, such | 306 | * typically contain generated code that cannot be influenced, such | |
320 | * as a flex lexer or a yacc parser. | 307 | * as a flex lexer or a yacc parser. | |
321 | */ | 308 | */ | |
322 | tn->tn_sys = in_system_header || | 309 | tn->tn_sys = in_system_header || | |
323 | (curr_pos.p_file != csrc_pos.p_file && | 310 | (curr_pos.p_file != csrc_pos.p_file && | |
324 | str_endswith(curr_pos.p_file, ".c")); | 311 | str_endswith(curr_pos.p_file, ".c")); | |
325 | return tn; | 312 | return tn; | |
326 | } | 313 | } | |
327 | 314 | |||
328 | /* Free all memory which is allocated by the current expression. */ | 315 | /* Free all memory which is allocated by the current expression. */ | |
329 | void | 316 | void |
--- src/usr.bin/xlint/lint1/tree.c 2022/02/26 20:36:11 1.404
+++ src/usr.bin/xlint/lint1/tree.c 2022/02/27 08:31:26 1.405
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: tree.c,v 1.404 2022/02/26 20:36:11 rillig Exp $ */ | 1 | /* $NetBSD: tree.c,v 1.405 2022/02/27 08:31:26 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.404 2022/02/26 20:36:11 rillig Exp $"); | 40 | __RCSID("$NetBSD: tree.c,v 1.405 2022/02/27 08:31:26 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 *build_integer_constant(tspec_t, int64_t); | 53 | static tnode_t *build_integer_constant(tspec_t, int64_t); | |
@@ -98,75 +98,75 @@ extern sig_atomic_t fpe; | @@ -98,75 +98,75 @@ extern sig_atomic_t fpe; | |||
98 | 98 | |||
99 | static const char * | 99 | static const char * | |
100 | op_name(op_t op) | 100 | op_name(op_t op) | |
101 | { | 101 | { | |
102 | return modtab[op].m_name; | 102 | return modtab[op].m_name; | |
103 | } | 103 | } | |
104 | 104 | |||
105 | /* Build 'pointer to tp', 'array of tp' or 'function returning tp'. */ | 105 | /* Build 'pointer to tp', 'array of tp' or 'function returning tp'. */ | |
106 | type_t * | 106 | type_t * | |
107 | derive_type(type_t *tp, tspec_t t) | 107 | derive_type(type_t *tp, tspec_t t) | |
108 | { | 108 | { | |
109 | type_t *tp2; | 109 | type_t *tp2; | |
110 | 110 | |||
111 | tp2 = getblk(sizeof(*tp2)); | 111 | tp2 = block_zero_alloc(sizeof(*tp2)); | |
112 | tp2->t_tspec = t; | 112 | tp2->t_tspec = t; | |
113 | tp2->t_subt = tp; | 113 | tp2->t_subt = tp; | |
114 | return tp2; | 114 | return tp2; | |
115 | } | 115 | } | |
116 | 116 | |||
117 | /* | 117 | /* | |
118 | * Derive 'pointer to tp' or 'function returning tp'. | 118 | * Derive 'pointer to tp' or 'function returning tp'. | |
119 | * The memory is freed at the end of the current expression. | 119 | * The memory is freed at the end of the current expression. | |
120 | */ | 120 | */ | |
121 | type_t * | 121 | type_t * | |
122 | expr_derive_type(type_t *tp, tspec_t t) | 122 | expr_derive_type(type_t *tp, tspec_t t) | |
123 | { | 123 | { | |
124 | type_t *tp2; | 124 | type_t *tp2; | |
125 | 125 | |||
126 | tp2 = expr_zalloc(sizeof(*tp2)); | 126 | tp2 = expr_zero_alloc(sizeof(*tp2)); | |
127 | tp2->t_tspec = t; | 127 | tp2->t_tspec = t; | |
128 | tp2->t_subt = tp; | 128 | tp2->t_subt = tp; | |
129 | return tp2; | 129 | return tp2; | |
130 | } | 130 | } | |
131 | 131 | |||
132 | /* | 132 | /* | |
133 | * Create a node for a constant. | 133 | * Create a node for a constant. | |
134 | */ | 134 | */ | |
135 | tnode_t * | 135 | tnode_t * | |
136 | build_constant(type_t *tp, val_t *v) | 136 | build_constant(type_t *tp, val_t *v) | |
137 | { | 137 | { | |
138 | tnode_t *n; | 138 | tnode_t *n; | |
139 | 139 | |||
140 | n = expr_zalloc_tnode(); | 140 | n = expr_alloc_tnode(); | |
141 | n->tn_op = CON; | 141 | n->tn_op = CON; | |
142 | n->tn_type = tp; | 142 | n->tn_type = tp; | |
143 | n->tn_val = expr_zalloc(sizeof(*n->tn_val)); | 143 | n->tn_val = expr_zero_alloc(sizeof(*n->tn_val)); | |
144 | n->tn_val->v_tspec = tp->t_tspec; | 144 | n->tn_val->v_tspec = tp->t_tspec; | |
145 | n->tn_val->v_unsigned_since_c90 = v->v_unsigned_since_c90; | 145 | n->tn_val->v_unsigned_since_c90 = v->v_unsigned_since_c90; | |
146 | n->tn_val->v_u = v->v_u; | 146 | n->tn_val->v_u = v->v_u; | |
147 | free(v); | 147 | free(v); | |
148 | return n; | 148 | return n; | |
149 | } | 149 | } | |
150 | 150 | |||
151 | static tnode_t * | 151 | static tnode_t * | |
152 | build_integer_constant(tspec_t t, int64_t q) | 152 | build_integer_constant(tspec_t t, int64_t q) | |
153 | { | 153 | { | |
154 | tnode_t *n; | 154 | tnode_t *n; | |
155 | 155 | |||
156 | n = expr_zalloc_tnode(); | 156 | n = expr_alloc_tnode(); | |
157 | n->tn_op = CON; | 157 | n->tn_op = CON; | |
158 | n->tn_type = gettyp(t); | 158 | n->tn_type = gettyp(t); | |
159 | n->tn_val = expr_zalloc(sizeof(*n->tn_val)); | 159 | n->tn_val = expr_zero_alloc(sizeof(*n->tn_val)); | |
160 | n->tn_val->v_tspec = t; | 160 | n->tn_val->v_tspec = t; | |
161 | n->tn_val->v_quad = q; | 161 | n->tn_val->v_quad = q; | |
162 | return n; | 162 | return n; | |
163 | } | 163 | } | |
164 | 164 | |||
165 | static void | 165 | static void | |
166 | fallback_symbol(sym_t *sym) | 166 | fallback_symbol(sym_t *sym) | |
167 | { | 167 | { | |
168 | 168 | |||
169 | if (fallback_symbol_strict_bool(sym)) | 169 | if (fallback_symbol_strict_bool(sym)) | |
170 | return; | 170 | return; | |
171 | 171 | |||
172 | if (block_level > 0 && (strcmp(sym->s_name, "__FUNCTION__") == 0 || | 172 | if (block_level > 0 && (strcmp(sym->s_name, "__FUNCTION__") == 0 || | |
@@ -267,73 +267,73 @@ build_name(sym_t *sym, bool is_funcname) | @@ -267,73 +267,73 @@ build_name(sym_t *sym, bool is_funcname) | |||
267 | tnode_t *n; | 267 | tnode_t *n; | |
268 | 268 | |||
269 | if (sym->s_scl == NOSCL) { | 269 | if (sym->s_scl == NOSCL) { | |
270 | sym->s_scl = EXTERN; | 270 | sym->s_scl = EXTERN; | |
271 | sym->s_def = DECL; | 271 | sym->s_def = DECL; | |
272 | if (is_funcname) | 272 | if (is_funcname) | |
273 | build_name_call(sym); | 273 | build_name_call(sym); | |
274 | else | 274 | else | |
275 | fallback_symbol(sym); | 275 | fallback_symbol(sym); | |
276 | } | 276 | } | |
277 | 277 | |||
278 | lint_assert(sym->s_kind == FVFT || sym->s_kind == FMEMBER); | 278 | lint_assert(sym->s_kind == FVFT || sym->s_kind == FMEMBER); | |
279 | 279 | |||
280 | n = expr_zalloc_tnode(); | 280 | n = expr_alloc_tnode(); | |
281 | n->tn_type = sym->s_type; | 281 | n->tn_type = sym->s_type; | |
282 | if (sym->s_scl == CTCONST) { | 282 | if (sym->s_scl == CTCONST) { | |
283 | n->tn_op = CON; | 283 | n->tn_op = CON; | |
284 | n->tn_val = expr_zalloc(sizeof(*n->tn_val)); | 284 | n->tn_val = expr_zero_alloc(sizeof(*n->tn_val)); | |
285 | *n->tn_val = sym->s_value; | 285 | *n->tn_val = sym->s_value; | |
286 | } else { | 286 | } else { | |
287 | n->tn_op = NAME; | 287 | n->tn_op = NAME; | |
288 | n->tn_sym = sym; | 288 | n->tn_sym = sym; | |
289 | if (sym->s_kind == FVFT && sym->s_type->t_tspec != FUNC) | 289 | if (sym->s_kind == FVFT && sym->s_type->t_tspec != FUNC) | |
290 | n->tn_lvalue = true; | 290 | n->tn_lvalue = true; | |
291 | } | 291 | } | |
292 | 292 | |||
293 | return n; | 293 | return n; | |
294 | } | 294 | } | |
295 | 295 | |||
296 | tnode_t * | 296 | tnode_t * | |
297 | build_string(strg_t *strg) | 297 | build_string(strg_t *strg) | |
298 | { | 298 | { | |
299 | size_t len; | 299 | size_t len; | |
300 | tnode_t *n; | 300 | tnode_t *n; | |
301 | type_t *tp; | 301 | type_t *tp; | |
302 | 302 | |||
303 | len = strg->st_len; | 303 | len = strg->st_len; | |
304 | 304 | |||
305 | n = expr_zalloc_tnode(); | 305 | n = expr_alloc_tnode(); | |
306 | 306 | |||
307 | tp = expr_zalloc(sizeof(*tp)); | 307 | tp = expr_zero_alloc(sizeof(*tp)); | |
308 | tp->t_tspec = ARRAY; | 308 | tp->t_tspec = ARRAY; | |
309 | tp->t_subt = gettyp(strg->st_tspec); | 309 | tp->t_subt = gettyp(strg->st_tspec); | |
310 | tp->t_dim = (int)(len + 1); | 310 | tp->t_dim = (int)(len + 1); | |
311 | 311 | |||
312 | n->tn_op = STRING; | 312 | n->tn_op = STRING; | |
313 | n->tn_type = tp; | 313 | n->tn_type = tp; | |
314 | n->tn_lvalue = true; | 314 | n->tn_lvalue = true; | |
315 | 315 | |||
316 | n->tn_string = expr_zalloc(sizeof(*n->tn_string)); | 316 | n->tn_string = expr_zero_alloc(sizeof(*n->tn_string)); | |
317 | n->tn_string->st_tspec = strg->st_tspec; | 317 | n->tn_string->st_tspec = strg->st_tspec; | |
318 | n->tn_string->st_len = len; | 318 | n->tn_string->st_len = len; | |
319 | 319 | |||
320 | if (strg->st_tspec == CHAR) { | 320 | if (strg->st_tspec == CHAR) { | |
321 | n->tn_string->st_cp = expr_zalloc(len + 1); | 321 | n->tn_string->st_cp = expr_zero_alloc(len + 1); | |
322 | (void)memcpy(n->tn_string->st_cp, strg->st_cp, len + 1); | 322 | (void)memcpy(n->tn_string->st_cp, strg->st_cp, len + 1); | |
323 | free(strg->st_cp); | 323 | free(strg->st_cp); | |
324 | } else { | 324 | } else { | |
325 | size_t size = (len + 1) * sizeof(*n->tn_string->st_wcp); | 325 | size_t size = (len + 1) * sizeof(*n->tn_string->st_wcp); | |
326 | n->tn_string->st_wcp = expr_zalloc(size); | 326 | n->tn_string->st_wcp = expr_zero_alloc(size); | |
327 | (void)memcpy(n->tn_string->st_wcp, strg->st_wcp, size); | 327 | (void)memcpy(n->tn_string->st_wcp, strg->st_wcp, size); | |
328 | free(strg->st_wcp); | 328 | free(strg->st_wcp); | |
329 | } | 329 | } | |
330 | free(strg); | 330 | free(strg); | |
331 | 331 | |||
332 | return n; | 332 | return n; | |
333 | } | 333 | } | |
334 | 334 | |||
335 | /* | 335 | /* | |
336 | * Returns a symbol which has the same name as the msym argument and is a | 336 | * Returns a symbol which has the same name as the msym argument and is a | |
337 | * member of the struct or union specified by the tn argument. | 337 | * member of the struct or union specified by the tn argument. | |
338 | */ | 338 | */ | |
339 | static sym_t * | 339 | static sym_t * | |
@@ -345,28 +345,28 @@ struct_or_union_member(tnode_t *tn, op_t | @@ -345,28 +345,28 @@ struct_or_union_member(tnode_t *tn, op_t | |||
345 | bool eq; | 345 | bool eq; | |
346 | tspec_t t; | 346 | tspec_t t; | |
347 | 347 | |||
348 | /* | 348 | /* | |
349 | * Remove the member if it was unknown until now, which means | 349 | * Remove the member if it was unknown until now, which means | |
350 | * that no defined struct or union has a member with the same name. | 350 | * that no defined struct or union has a member with the same name. | |
351 | */ | 351 | */ | |
352 | if (msym->s_scl == NOSCL) { | 352 | if (msym->s_scl == NOSCL) { | |
353 | /* type '%s' does not have member '%s' */ | 353 | /* type '%s' does not have member '%s' */ | |
354 | error(101, type_name(tn->tn_type), msym->s_name); | 354 | error(101, type_name(tn->tn_type), msym->s_name); | |
355 | rmsym(msym); | 355 | rmsym(msym); | |
356 | msym->s_kind = FMEMBER; | 356 | msym->s_kind = FMEMBER; | |
357 | msym->s_scl = MOS; | 357 | msym->s_scl = MOS; | |
358 | msym->s_styp = expr_zalloc(sizeof(*msym->s_styp)); | 358 | msym->s_styp = expr_zero_alloc(sizeof(*msym->s_styp)); | |
359 | msym->s_styp->sou_tag = expr_zalloc( | 359 | msym->s_styp->sou_tag = expr_zero_alloc( | |
360 | sizeof(*msym->s_styp->sou_tag)); | 360 | sizeof(*msym->s_styp->sou_tag)); | |
361 | msym->s_styp->sou_tag->s_name = unnamed; | 361 | msym->s_styp->sou_tag->s_name = unnamed; | |
362 | msym->s_value.v_tspec = INT; | 362 | msym->s_value.v_tspec = INT; | |
363 | return msym; | 363 | return msym; | |
364 | } | 364 | } | |
365 | 365 | |||
366 | /* Set str to the tag of which msym is expected to be a member. */ | 366 | /* Set str to the tag of which msym is expected to be a member. */ | |
367 | str = NULL; | 367 | str = NULL; | |
368 | t = (tp = tn->tn_type)->t_tspec; | 368 | t = (tp = tn->tn_type)->t_tspec; | |
369 | if (op == POINT) { | 369 | if (op == POINT) { | |
370 | if (t == STRUCT || t == UNION) | 370 | if (t == STRUCT || t == UNION) | |
371 | str = tp->t_str; | 371 | str = tp->t_str; | |
372 | } else if (op == ARROW && t == PTR) { | 372 | } else if (op == ARROW && t == PTR) { | |
@@ -1824,27 +1824,27 @@ check_enum_array_index(const tnode_t *ln | @@ -1824,27 +1824,27 @@ check_enum_array_index(const tnode_t *ln | |||
1824 | /* | 1824 | /* | |
1825 | * Build and initialize a new node. | 1825 | * Build and initialize a new node. | |
1826 | */ | 1826 | */ | |
1827 | static tnode_t * | 1827 | static tnode_t * | |
1828 | new_tnode(op_t op, bool sys, type_t *type, tnode_t *ln, tnode_t *rn) | 1828 | new_tnode(op_t op, bool sys, type_t *type, tnode_t *ln, tnode_t *rn) | |
1829 | { | 1829 | { | |
1830 | tnode_t *ntn; | 1830 | tnode_t *ntn; | |
1831 | tspec_t t; | 1831 | tspec_t t; | |
1832 | #if 0 /* not yet */ | 1832 | #if 0 /* not yet */ | |
1833 | size_t l; | 1833 | size_t l; | |
1834 | uint64_t rnum; | 1834 | uint64_t rnum; | |
1835 | #endif | 1835 | #endif | |
1836 | 1836 | |||
1837 | ntn = expr_zalloc_tnode(); | 1837 | ntn = expr_alloc_tnode(); | |
1838 | 1838 | |||
1839 | ntn->tn_op = op; | 1839 | ntn->tn_op = op; | |
1840 | ntn->tn_type = type; | 1840 | ntn->tn_type = type; | |
1841 | ntn->tn_sys = sys; | 1841 | ntn->tn_sys = sys; | |
1842 | ntn->tn_left = ln; | 1842 | ntn->tn_left = ln; | |
1843 | ntn->tn_right = rn; | 1843 | ntn->tn_right = rn; | |
1844 | 1844 | |||
1845 | switch (op) { | 1845 | switch (op) { | |
1846 | #if 0 /* not yet */ | 1846 | #if 0 /* not yet */ | |
1847 | case SHR: | 1847 | case SHR: | |
1848 | if (rn->tn_op != CON) | 1848 | if (rn->tn_op != CON) | |
1849 | break; | 1849 | break; | |
1850 | rnum = rn->tn_val->v_quad; | 1850 | rnum = rn->tn_val->v_quad; | |
@@ -2070,37 +2070,37 @@ convert(op_t op, int arg, type_t *tp, tn | @@ -2070,37 +2070,37 @@ convert(op_t op, int arg, type_t *tp, tn | |||
2070 | 2070 | |||
2071 | if (!tflag && !sflag && op == FARG) | 2071 | if (!tflag && !sflag && op == FARG) | |
2072 | check_prototype_conversion(arg, nt, ot, tp, tn); | 2072 | check_prototype_conversion(arg, nt, ot, tp, tn); | |
2073 | if (is_integer(nt) && is_integer(ot)) { | 2073 | if (is_integer(nt) && is_integer(ot)) { | |
2074 | check_integer_conversion(op, arg, nt, ot, tp, tn); | 2074 | check_integer_conversion(op, arg, nt, ot, tp, tn); | |
2075 | } else if (nt == PTR && is_null_pointer(tn)) { | 2075 | } else if (nt == PTR && is_null_pointer(tn)) { | |
2076 | /* a null pointer may be assigned to any pointer. */ | 2076 | /* a null pointer may be assigned to any pointer. */ | |
2077 | } else if (is_integer(nt) && nt != BOOL && ot == PTR) { | 2077 | } else if (is_integer(nt) && nt != BOOL && ot == PTR) { | |
2078 | check_pointer_integer_conversion(op, nt, tp, tn); | 2078 | check_pointer_integer_conversion(op, nt, tp, tn); | |
2079 | } else if (nt == PTR && ot == PTR && op == CVT) { | 2079 | } else if (nt == PTR && ot == PTR && op == CVT) { | |
2080 | check_pointer_conversion(tn, tp); | 2080 | check_pointer_conversion(tn, tp); | |
2081 | } | 2081 | } | |
2082 | 2082 | |||
2083 | ntn = expr_zalloc_tnode(); | 2083 | ntn = expr_alloc_tnode(); | |
2084 | ntn->tn_op = CVT; | 2084 | ntn->tn_op = CVT; | |
2085 | ntn->tn_type = tp; | 2085 | ntn->tn_type = tp; | |
2086 | ntn->tn_cast = op == CVT; | 2086 | ntn->tn_cast = op == CVT; | |
2087 | ntn->tn_sys |= tn->tn_sys; | 2087 | ntn->tn_sys |= tn->tn_sys; | |
2088 | ntn->tn_right = NULL; | 2088 | ntn->tn_right = NULL; | |
2089 | if (tn->tn_op != CON || nt == VOID) { | 2089 | if (tn->tn_op != CON || nt == VOID) { | |
2090 | ntn->tn_left = tn; | 2090 | ntn->tn_left = tn; | |
2091 | } else { | 2091 | } else { | |
2092 | ntn->tn_op = CON; | 2092 | ntn->tn_op = CON; | |
2093 | ntn->tn_val = expr_zalloc(sizeof(*ntn->tn_val)); | 2093 | ntn->tn_val = expr_zero_alloc(sizeof(*ntn->tn_val)); | |
2094 | convert_constant(op, arg, ntn->tn_type, ntn->tn_val, | 2094 | convert_constant(op, arg, ntn->tn_type, ntn->tn_val, | |
2095 | tn->tn_val); | 2095 | tn->tn_val); | |
2096 | } | 2096 | } | |
2097 | 2097 | |||
2098 | return ntn; | 2098 | return ntn; | |
2099 | } | 2099 | } | |
2100 | 2100 | |||
2101 | static bool | 2101 | static bool | |
2102 | should_warn_about_prototype_conversion(tspec_t nt, | 2102 | should_warn_about_prototype_conversion(tspec_t nt, | |
2103 | tspec_t ot, const tnode_t *ptn) | 2103 | tspec_t ot, const tnode_t *ptn) | |
2104 | { | 2104 | { | |
2105 | 2105 | |||
2106 | if (nt == ot) | 2106 | if (nt == ot) | |
@@ -3599,27 +3599,27 @@ cast(tnode_t *tn, type_t *tp) | @@ -3599,27 +3599,27 @@ cast(tnode_t *tn, type_t *tp) | |||
3599 | * But this seems really questionable. | 3599 | * But this seems really questionable. | |
3600 | */ | 3600 | */ | |
3601 | } else if (nt == UNION) { | 3601 | } else if (nt == UNION) { | |
3602 | sym_t *m; | 3602 | sym_t *m; | |
3603 | struct_or_union *str = tp->t_str; | 3603 | struct_or_union *str = tp->t_str; | |
3604 | if (!gflag) { | 3604 | if (!gflag) { | |
3605 | /* union cast is a GCC extension */ | 3605 | /* union cast is a GCC extension */ | |
3606 | error(328); | 3606 | error(328); | |
3607 | return NULL; | 3607 | return NULL; | |
3608 | } | 3608 | } | |
3609 | for (m = str->sou_first_member; m != NULL; m = m->s_next) { | 3609 | for (m = str->sou_first_member; m != NULL; m = m->s_next) { | |
3610 | if (eqtype(m->s_type, tn->tn_type, | 3610 | if (eqtype(m->s_type, tn->tn_type, | |
3611 | false, false, NULL)) { | 3611 | false, false, NULL)) { | |
3612 | tn = expr_zalloc_tnode(); | 3612 | tn = expr_alloc_tnode(); | |
3613 | tn->tn_op = CVT; | 3613 | tn->tn_op = CVT; | |
3614 | tn->tn_type = tp; | 3614 | tn->tn_type = tp; | |
3615 | tn->tn_cast = true; | 3615 | tn->tn_cast = true; | |
3616 | tn->tn_right = NULL; | 3616 | tn->tn_right = NULL; | |
3617 | return tn; | 3617 | return tn; | |
3618 | } | 3618 | } | |
3619 | } | 3619 | } | |
3620 | /* type '%s' is not a member of '%s' */ | 3620 | /* type '%s' is not a member of '%s' */ | |
3621 | error(329, type_name(tn->tn_type), type_name(tp)); | 3621 | error(329, type_name(tn->tn_type), type_name(tp)); | |
3622 | return NULL; | 3622 | return NULL; | |
3623 | } else if (nt == STRUCT || nt == ARRAY || nt == FUNC) { | 3623 | } else if (nt == STRUCT || nt == ARRAY || nt == FUNC) { | |
3624 | /* Casting to a struct is an undocumented GCC extension. */ | 3624 | /* Casting to a struct is an undocumented GCC extension. */ | |
3625 | if (!(gflag && nt == STRUCT)) | 3625 | if (!(gflag && nt == STRUCT)) |