| @@ -1,15 +1,15 @@ | | | @@ -1,15 +1,15 @@ |
1 | %{ | | 1 | %{ |
2 | /* $NetBSD: cgram.y,v 1.268 2021/07/08 03:22:47 rillig Exp $ */ | | 2 | /* $NetBSD: cgram.y,v 1.269 2021/07/08 03:35:07 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.268 2021/07/08 03:22:47 rillig Exp $"); | | 38 | __RCSID("$NetBSD: cgram.y,v 1.269 2021/07/08 03:35:07 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. |
| @@ -280,27 +280,27 @@ anonymize(sym_t *s) | | | @@ -280,27 +280,27 @@ anonymize(sym_t *s) |
280 | %type <y_sym> func_decl | | 280 | %type <y_sym> func_decl |
281 | %type <y_sym> notype_decl | | 281 | %type <y_sym> notype_decl |
282 | %type <y_sym> type_decl | | 282 | %type <y_sym> type_decl |
283 | %type <y_type> typespec | | 283 | %type <y_type> typespec |
284 | %type <y_type> clrtyp_typespec | | 284 | %type <y_type> clrtyp_typespec |
285 | %type <y_type> notype_typespec | | 285 | %type <y_type> notype_typespec |
286 | %type <y_type> struct_spec | | 286 | %type <y_type> struct_spec |
287 | %type <y_type> enum_spec | | 287 | %type <y_type> enum_spec |
288 | %type <y_sym> struct_tag | | 288 | %type <y_sym> struct_tag |
289 | %type <y_sym> enum_tag | | 289 | %type <y_sym> enum_tag |
290 | %type <y_tspec> struct | | 290 | %type <y_tspec> struct |
291 | %type <y_sym> struct_declaration | | 291 | %type <y_sym> struct_declaration |
292 | %type <y_sb> identifier | | 292 | %type <y_sb> identifier |
293 | %type <y_sym> member_declaration_list_with_rbrace | | 293 | %type <y_sym> member_declaration_list_semi |
294 | %type <y_sym> member_declaration_list | | 294 | %type <y_sym> member_declaration_list |
295 | %type <y_sym> member_declaration | | 295 | %type <y_sym> member_declaration |
296 | %type <y_sym> notype_member_decls | | 296 | %type <y_sym> notype_member_decls |
297 | %type <y_sym> type_member_decls | | 297 | %type <y_sym> type_member_decls |
298 | %type <y_sym> notype_member_decl | | 298 | %type <y_sym> notype_member_decl |
299 | %type <y_sym> type_member_decl | | 299 | %type <y_sym> type_member_decl |
300 | %type <y_tnode> constant_expr | | 300 | %type <y_tnode> constant_expr |
301 | %type <y_tnode> array_size | | 301 | %type <y_tnode> array_size |
302 | %type <y_sym> enum_declaration | | 302 | %type <y_sym> enum_declaration |
303 | %type <y_sym> enumerator_list | | 303 | %type <y_sym> enumerator_list |
304 | %type <y_sym> enumerator | | 304 | %type <y_sym> enumerator |
305 | %type <y_sym> enumeration_constant | | 305 | %type <y_sym> enumeration_constant |
306 | %type <y_sym> notype_direct_decl | | 306 | %type <y_sym> notype_direct_decl |
| @@ -652,52 +652,48 @@ struct: | | | @@ -652,52 +652,48 @@ struct: |
652 | dcs->d_offset = 0; | | 652 | dcs->d_offset = 0; |
653 | dcs->d_sou_align_in_bits = CHAR_SIZE; | | 653 | dcs->d_sou_align_in_bits = CHAR_SIZE; |
654 | $$ = $1; | | 654 | $$ = $1; |
655 | } | | 655 | } |
656 | ; | | 656 | ; |
657 | | | 657 | |
658 | struct_tag: | | 658 | struct_tag: |
659 | identifier { | | 659 | identifier { |
660 | $$ = getsym($1); | | 660 | $$ = getsym($1); |
661 | } | | 661 | } |
662 | ; | | 662 | ; |
663 | | | 663 | |
664 | struct_declaration: | | 664 | struct_declaration: |
665 | struct_decl_lbrace member_declaration_list_with_rbrace { | | | |
666 | $$ = $2; | | | |
667 | } | | | |
668 | ; | | | |
669 | | | | |
670 | struct_decl_lbrace: | | | |
671 | T_LBRACE { | | 665 | T_LBRACE { |
672 | symtyp = FVFT; | | 666 | symtyp = FVFT; |
| | | 667 | } member_declaration_list_semi T_RBRACE { |
| | | 668 | $$ = $3; |
673 | } | | 669 | } |
674 | ; | | 670 | ; |
675 | | | 671 | |
676 | member_declaration_list_with_rbrace: | | 672 | member_declaration_list_semi: |
677 | member_declaration_list T_SEMI T_RBRACE | | 673 | /* empty */ { |
678 | | member_declaration_list T_RBRACE { | | 674 | $$ = NULL; |
| | | 675 | } |
| | | 676 | | member_declaration_list T_SEMI |
| | | 677 | | member_declaration_list { |
679 | if (sflag) { | | 678 | if (sflag) { |
680 | /* syntax req. ';' after last struct/union member */ | | 679 | /* syntax req. ';' after last struct/union member */ |
681 | error(66); | | 680 | error(66); |
682 | } else { | | 681 | } else { |
683 | /* syntax req. ';' after last struct/union member */ | | 682 | /* syntax req. ';' after last struct/union member */ |
684 | warning(66); | | 683 | warning(66); |
685 | } | | 684 | } |
686 | $$ = $1; | | 685 | $$ = $1; |
687 | } | | 686 | } |
688 | | T_RBRACE { | | | |
689 | $$ = NULL; | | | |
690 | } | | | |
691 | ; | | 687 | ; |
692 | | | 688 | |
693 | member_declaration_list: | | 689 | member_declaration_list: |
694 | member_declaration | | 690 | member_declaration |
695 | | member_declaration_list T_SEMI member_declaration { | | 691 | | member_declaration_list T_SEMI member_declaration { |
696 | $$ = lnklst($1, $3); | | 692 | $$ = lnklst($1, $3); |
697 | } | | 693 | } |
698 | ; | | 694 | ; |
699 | | | 695 | |
700 | member_declaration: | | 696 | member_declaration: |
701 | noclass_declmods deftyp { | | 697 | noclass_declmods deftyp { |
702 | /* too late, i know, but getsym() compensates it */ | | 698 | /* too late, i know, but getsym() compensates it */ |
703 | symtyp = FMEMBER; | | 699 | symtyp = FMEMBER; |