| @@ -1,15 +1,15 @@ | | | @@ -1,15 +1,15 @@ |
1 | %{ | | 1 | %{ |
2 | /* $NetBSD: cgram.y,v 1.264 2021/07/06 20:56:38 rillig Exp $ */ | | 2 | /* $NetBSD: cgram.y,v 1.265 2021/07/06 21:41:36 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.264 2021/07/06 20:56:38 rillig Exp $"); | | 38 | __RCSID("$NetBSD: cgram.y,v 1.265 2021/07/06 21:41:36 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. |
| @@ -739,26 +739,31 @@ member_declaration: | | | @@ -739,26 +739,31 @@ member_declaration: |
739 | anonymize($$); | | 739 | anonymize($$); |
740 | } else { | | 740 | } else { |
741 | /* syntax error '%s' */ | | 741 | /* syntax error '%s' */ |
742 | error(249, "unnamed member"); | | 742 | error(249, "unnamed member"); |
743 | $$ = NULL; | | 743 | $$ = NULL; |
744 | } | | 744 | } |
745 | } | | 745 | } |
746 | | error { | | 746 | | error { |
747 | symtyp = FVFT; | | 747 | symtyp = FVFT; |
748 | $$ = NULL; | | 748 | $$ = NULL; |
749 | } | | 749 | } |
750 | ; | | 750 | ; |
751 | | | 751 | |
| | | 752 | /* |
| | | 753 | * XXX: shift/reduce conflict, caused by: |
| | | 754 | * type_attribute noclass_declspecs |
| | | 755 | * noclass_declspecs type_attribute |
| | | 756 | */ |
752 | noclass_declspecs: | | 757 | noclass_declspecs: |
753 | clrtyp_typespec { | | 758 | clrtyp_typespec { |
754 | add_type($1); | | 759 | add_type($1); |
755 | } | | 760 | } |
756 | | type_attribute noclass_declspecs | | 761 | | type_attribute noclass_declspecs |
757 | | noclass_declmods typespec { | | 762 | | noclass_declmods typespec { |
758 | add_type($2); | | 763 | add_type($2); |
759 | } | | 764 | } |
760 | | noclass_declspecs T_QUAL { | | 765 | | noclass_declspecs T_QUAL { |
761 | add_qualifier($2); | | 766 | add_qualifier($2); |
762 | } | | 767 | } |
763 | | noclass_declspecs notype_typespec { | | 768 | | noclass_declspecs notype_typespec { |
764 | add_type($2); | | 769 | add_type($2); |
| @@ -1342,26 +1347,31 @@ abstract_declaration: | | | @@ -1342,26 +1347,31 @@ abstract_declaration: |
1342 | abstract_declarator: /* C99 6.7.6 */ | | 1347 | abstract_declarator: /* C99 6.7.6 */ |
1343 | pointer { | | 1348 | pointer { |
1344 | $$ = add_pointer(abstract_name(), $1); | | 1349 | $$ = add_pointer(abstract_name(), $1); |
1345 | } | | 1350 | } |
1346 | | direct_abstract_declarator | | 1351 | | direct_abstract_declarator |
1347 | | pointer direct_abstract_declarator { | | 1352 | | pointer direct_abstract_declarator { |
1348 | $$ = add_pointer($2, $1); | | 1353 | $$ = add_pointer($2, $1); |
1349 | } | | 1354 | } |
1350 | | T_TYPEOF term { /* GCC extension */ | | 1355 | | T_TYPEOF term { /* GCC extension */ |
1351 | $$ = mktempsym($2->tn_type); | | 1356 | $$ = mktempsym($2->tn_type); |
1352 | } | | 1357 | } |
1353 | ; | | 1358 | ; |
1354 | | | 1359 | |
| | | 1360 | /* |
| | | 1361 | * XXX: shift/reduce conflict, caused by: |
| | | 1362 | * type_attribute direct_abstract_declarator |
| | | 1363 | * direct_abstract_declarator type_attribute |
| | | 1364 | */ |
1355 | direct_abstract_declarator: /* C99 6.7.6 */ | | 1365 | direct_abstract_declarator: /* C99 6.7.6 */ |
1356 | T_LPAREN abstract_declarator T_RPAREN { | | 1366 | T_LPAREN abstract_declarator T_RPAREN { |
1357 | $$ = $2; | | 1367 | $$ = $2; |
1358 | } | | 1368 | } |
1359 | | T_LBRACK T_RBRACK { | | 1369 | | T_LBRACK T_RBRACK { |
1360 | $$ = add_array(abstract_name(), false, 0); | | 1370 | $$ = add_array(abstract_name(), false, 0); |
1361 | } | | 1371 | } |
1362 | | T_LBRACK array_size T_RBRACK { | | 1372 | | T_LBRACK array_size T_RBRACK { |
1363 | $$ = add_array(abstract_name(), true, to_int_constant($2, false)); | | 1373 | $$ = add_array(abstract_name(), true, to_int_constant($2, false)); |
1364 | } | | 1374 | } |
1365 | | type_attribute direct_abstract_declarator { | | 1375 | | type_attribute direct_abstract_declarator { |
1366 | $$ = $2; | | 1376 | $$ = $2; |
1367 | } | | 1377 | } |