| @@ -1,15 +1,15 @@ | | | @@ -1,15 +1,15 @@ |
1 | %{ | | 1 | %{ |
2 | /* $NetBSD: cgram.y,v 1.310 2021/07/11 18:03:47 rillig Exp $ */ | | 2 | /* $NetBSD: cgram.y,v 1.311 2021/07/11 18:22:02 rillig Exp $ */ |
3 | | | 3 | |
4 | /* | | 4 | /* |
5 | * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. | | 5 | * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. |
6 | * Copyright (c) 1994, 1995 Jochen Pohl | | 6 | * Copyright (c) 1994, 1995 Jochen Pohl |
7 | * All Rights Reserved. | | 7 | * All Rights Reserved. |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * 1. Redistributions of source code must retain the above copyright | | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
15 | * notice, this list of conditions and the following disclaimer in the | | 15 | * notice, this list of conditions and the following disclaimer in the |
| @@ -25,27 +25,27 @@ | | | @@ -25,27 +25,27 @@ |
25 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 25 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
26 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 26 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
27 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 27 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | | 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
29 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 29 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
30 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 30 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
31 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 31 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
32 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 32 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
33 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 33 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
34 | */ | | 34 | */ |
35 | | | 35 | |
36 | #include <sys/cdefs.h> | | 36 | #include <sys/cdefs.h> |
37 | #if defined(__RCSID) && !defined(lint) | | 37 | #if defined(__RCSID) && !defined(lint) |
38 | __RCSID("$NetBSD: cgram.y,v 1.310 2021/07/11 18:03:47 rillig Exp $"); | | 38 | __RCSID("$NetBSD: cgram.y,v 1.311 2021/07/11 18:22:02 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. |
| @@ -114,27 +114,27 @@ RESTORE_WARN_FLAGS(const char *file, siz | | | @@ -114,27 +114,27 @@ RESTORE_WARN_FLAGS(const char *file, siz |
114 | #define save_warning_flags() SAVE_WARN_FLAGS(__FILE__, __LINE__) | | 114 | #define save_warning_flags() SAVE_WARN_FLAGS(__FILE__, __LINE__) |
115 | #define restore_warning_flags() RESTORE_WARN_FLAGS(__FILE__, __LINE__) | | 115 | #define restore_warning_flags() RESTORE_WARN_FLAGS(__FILE__, __LINE__) |
116 | | | 116 | |
117 | /* unbind the anonymous struct members from the struct */ | | 117 | /* unbind the anonymous struct members from the struct */ |
118 | static void | | 118 | static void |
119 | anonymize(sym_t *s) | | 119 | anonymize(sym_t *s) |
120 | { | | 120 | { |
121 | for ( ; s != NULL; s = s->s_next) | | 121 | for ( ; s != NULL; s = s->s_next) |
122 | s->s_styp = NULL; | | 122 | s->s_styp = NULL; |
123 | } | | 123 | } |
124 | | | 124 | |
125 | %} | | 125 | %} |
126 | | | 126 | |
127 | %expect 172 | | 127 | %expect 168 |
128 | | | 128 | |
129 | %union { | | 129 | %union { |
130 | val_t *y_val; | | 130 | val_t *y_val; |
131 | sbuf_t *y_name; | | 131 | sbuf_t *y_name; |
132 | sym_t *y_sym; | | 132 | sym_t *y_sym; |
133 | op_t y_op; | | 133 | op_t y_op; |
134 | scl_t y_scl; | | 134 | scl_t y_scl; |
135 | tspec_t y_tspec; | | 135 | tspec_t y_tspec; |
136 | tqual_t y_tqual; | | 136 | tqual_t y_tqual; |
137 | type_t *y_type; | | 137 | type_t *y_type; |
138 | tnode_t *y_tnode; | | 138 | tnode_t *y_tnode; |
139 | range_t y_range; | | 139 | range_t y_range; |
140 | strg_t *y_string; | | 140 | strg_t *y_string; |
| @@ -969,27 +969,27 @@ notype_direct_decl: | | | @@ -969,27 +969,27 @@ notype_direct_decl: |
969 | $$ = $2; | | 969 | $$ = $2; |
970 | } | | 970 | } |
971 | | notype_direct_decl T_LBRACK T_RBRACK { | | 971 | | notype_direct_decl T_LBRACK T_RBRACK { |
972 | $$ = add_array($1, false, 0); | | 972 | $$ = add_array($1, false, 0); |
973 | } | | 973 | } |
974 | | notype_direct_decl T_LBRACK array_size T_RBRACK { | | 974 | | notype_direct_decl T_LBRACK array_size T_RBRACK { |
975 | $$ = add_array($1, true, to_int_constant($3, false)); | | 975 | $$ = add_array($1, true, to_int_constant($3, false)); |
976 | } | | 976 | } |
977 | | notype_direct_decl param_list asm_or_symbolrename_opt { | | 977 | | notype_direct_decl param_list asm_or_symbolrename_opt { |
978 | $$ = add_function(symbolrename($1, $3), $2); | | 978 | $$ = add_function(symbolrename($1, $3), $2); |
979 | end_declaration_level(); | | 979 | end_declaration_level(); |
980 | block_level--; | | 980 | block_level--; |
981 | } | | 981 | } |
982 | | notype_direct_decl type_attribute_list | | 982 | | notype_direct_decl type_attribute |
983 | ; | | 983 | ; |
984 | | | 984 | |
985 | type_direct_decl: | | 985 | type_direct_decl: |
986 | identifier { | | 986 | identifier { |
987 | $$ = declarator_name(getsym($1)); | | 987 | $$ = declarator_name(getsym($1)); |
988 | } | | 988 | } |
989 | | T_LPAREN type_decl T_RPAREN { | | 989 | | T_LPAREN type_decl T_RPAREN { |
990 | $$ = $2; | | 990 | $$ = $2; |
991 | } | | 991 | } |
992 | | type_attribute type_direct_decl { | | 992 | | type_attribute type_direct_decl { |
993 | $$ = $2; | | 993 | $$ = $2; |
994 | } | | 994 | } |
995 | | type_direct_decl T_LBRACK T_RBRACK { | | 995 | | type_direct_decl T_LBRACK T_RBRACK { |