| @@ -1,15 +1,15 @@ | | | @@ -1,15 +1,15 @@ |
1 | %{ | | 1 | %{ |
2 | /* $NetBSD: cgram.y,v 1.311 2021/07/11 18:22:02 rillig Exp $ */ | | 2 | /* $NetBSD: cgram.y,v 1.312 2021/07/11 19:01:37 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.311 2021/07/11 18:22:02 rillig Exp $"); | | 38 | __RCSID("$NetBSD: cgram.y,v 1.312 2021/07/11 19:01:37 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 168 | | 127 | %expect 167 |
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; |
| @@ -247,26 +247,28 @@ anonymize(sym_t *s) | | | @@ -247,26 +247,28 @@ anonymize(sym_t *s) |
247 | %token T_AT_PURE | | 247 | %token T_AT_PURE |
248 | %token T_AT_RETURNS_TWICE | | 248 | %token T_AT_RETURNS_TWICE |
249 | %token T_AT_SECTION | | 249 | %token T_AT_SECTION |
250 | %token T_AT_SENTINEL | | 250 | %token T_AT_SENTINEL |
251 | %token T_AT_STRING | | 251 | %token T_AT_STRING |
252 | %token T_AT_TLS_MODEL | | 252 | %token T_AT_TLS_MODEL |
253 | %token T_AT_TUNION | | 253 | %token T_AT_TUNION |
254 | %token T_AT_UNUSED | | 254 | %token T_AT_UNUSED |
255 | %token T_AT_USED | | 255 | %token T_AT_USED |
256 | %token T_AT_VISIBILITY | | 256 | %token T_AT_VISIBILITY |
257 | %token T_AT_WARN_UNUSED_RESULT | | 257 | %token T_AT_WARN_UNUSED_RESULT |
258 | %token T_AT_WEAK | | 258 | %token T_AT_WEAK |
259 | | | 259 | |
| | | 260 | %left T_THEN |
| | | 261 | %left T_ELSE |
260 | %left T_COMMA | | 262 | %left T_COMMA |
261 | %right T_ASSIGN T_OPASSIGN | | 263 | %right T_ASSIGN T_OPASSIGN |
262 | %right T_QUEST T_COLON | | 264 | %right T_QUEST T_COLON |
263 | %left T_LOGOR | | 265 | %left T_LOGOR |
264 | %left T_LOGAND | | 266 | %left T_LOGAND |
265 | %left T_BITOR | | 267 | %left T_BITOR |
266 | %left T_BITXOR | | 268 | %left T_BITXOR |
267 | %left T_AMPER | | 269 | %left T_AMPER |
268 | %left T_EQUALITY | | 270 | %left T_EQUALITY |
269 | %left T_RELATIONAL | | 271 | %left T_RELATIONAL |
270 | %left T_SHIFT | | 272 | %left T_SHIFT |
271 | %left T_ADDITIVE | | 273 | %left T_ADDITIVE |
272 | %left T_ASTERISK T_MULTIPLICATIVE | | 274 | %left T_ASTERISK T_MULTIPLICATIVE |
| @@ -1476,27 +1478,27 @@ block_item: /* C99 6.8.2 */ | | | @@ -1476,27 +1478,27 @@ block_item: /* C99 6.8.2 */ |
1476 | ; | | 1478 | ; |
1477 | | | 1479 | |
1478 | expression_statement: /* C99 6.8.3 */ | | 1480 | expression_statement: /* C99 6.8.3 */ |
1479 | expr T_SEMI { | | 1481 | expr T_SEMI { |
1480 | expr($1, false, false, false, false); | | 1482 | expr($1, false, false, false, false); |
1481 | seen_fallthrough = false; | | 1483 | seen_fallthrough = false; |
1482 | } | | 1484 | } |
1483 | | T_SEMI { | | 1485 | | T_SEMI { |
1484 | seen_fallthrough = false; | | 1486 | seen_fallthrough = false; |
1485 | } | | 1487 | } |
1486 | ; | | 1488 | ; |
1487 | | | 1489 | |
1488 | selection_statement: /* C99 6.8.4 */ | | 1490 | selection_statement: /* C99 6.8.4 */ |
1489 | if_without_else { | | 1491 | if_without_else %prec T_THEN { |
1490 | save_warning_flags(); | | 1492 | save_warning_flags(); |
1491 | if2(); | | 1493 | if2(); |
1492 | if3(false); | | 1494 | if3(false); |
1493 | } | | 1495 | } |
1494 | | if_without_else T_ELSE { | | 1496 | | if_without_else T_ELSE { |
1495 | save_warning_flags(); | | 1497 | save_warning_flags(); |
1496 | if2(); | | 1498 | if2(); |
1497 | } statement { | | 1499 | } statement { |
1498 | clear_warning_flags(); | | 1500 | clear_warning_flags(); |
1499 | if3(true); | | 1501 | if3(true); |
1500 | } | | 1502 | } |
1501 | | if_without_else T_ELSE error { | | 1503 | | if_without_else T_ELSE error { |
1502 | clear_warning_flags(); | | 1504 | clear_warning_flags(); |