| @@ -1,15 +1,15 @@ | | | @@ -1,15 +1,15 @@ |
1 | %{ | | 1 | %{ |
2 | /* $NetBSD: cgram.y,v 1.313 2021/07/11 19:24:41 rillig Exp $ */ | | 2 | /* $NetBSD: cgram.y,v 1.314 2021/07/11 19:46:09 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.313 2021/07/11 19:24:41 rillig Exp $"); | | 38 | __RCSID("$NetBSD: cgram.y,v 1.314 2021/07/11 19:46:09 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 167 | | 127 | %expect 165 |
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; |
| @@ -1843,32 +1843,26 @@ unary_expression: /* C99 6.5.3 */ | | | @@ -1843,32 +1843,26 @@ unary_expression: /* C99 6.5.3 */ |
1843 | ; | | 1843 | ; |
1844 | | | 1844 | |
1845 | term: /* see C99 6.5.1 */ | | 1845 | term: /* see C99 6.5.1 */ |
1846 | unary_expression | | 1846 | unary_expression |
1847 | | T_REAL term { | | 1847 | | T_REAL term { |
1848 | $$ = build(REAL, $2, NULL); | | 1848 | $$ = build(REAL, $2, NULL); |
1849 | } | | 1849 | } |
1850 | | T_IMAG term { | | 1850 | | T_IMAG term { |
1851 | $$ = build(IMAG, $2, NULL); | | 1851 | $$ = build(IMAG, $2, NULL); |
1852 | } | | 1852 | } |
1853 | | T_EXTENSION term { | | 1853 | | T_EXTENSION term { |
1854 | $$ = $2; | | 1854 | $$ = $2; |
1855 | } | | 1855 | } |
1856 | | T_REAL T_LPAREN term T_RPAREN { | | | |
1857 | $$ = build(REAL, $3, NULL); | | | |
1858 | } | | | |
1859 | | T_IMAG T_LPAREN term T_RPAREN { | | | |
1860 | $$ = build(IMAG, $3, NULL); | | | |
1861 | } | | | |
1862 | | T_BUILTIN_OFFSETOF T_LPAREN type_name T_COMMA identifier T_RPAREN { | | 1856 | | T_BUILTIN_OFFSETOF T_LPAREN type_name T_COMMA identifier T_RPAREN { |
1863 | symtyp = FMEMBER; | | 1857 | symtyp = FMEMBER; |
1864 | $$ = build_offsetof($3, getsym($5)); | | 1858 | $$ = build_offsetof($3, getsym($5)); |
1865 | } | | 1859 | } |
1866 | | T_ALIGNOF T_LPAREN type_name T_RPAREN { | | 1860 | | T_ALIGNOF T_LPAREN type_name T_RPAREN { |
1867 | $$ = build_alignof($3); | | 1861 | $$ = build_alignof($3); |
1868 | } | | 1862 | } |
1869 | | T_LPAREN type_name T_RPAREN term { | | 1863 | | T_LPAREN type_name T_RPAREN term { |
1870 | $$ = cast($4, $2); | | 1864 | $$ = cast($4, $2); |
1871 | } | | 1865 | } |
1872 | ; | | 1866 | ; |
1873 | | | 1867 | |
1874 | generic_selection: /* C11 6.5.1.1 */ | | 1868 | generic_selection: /* C11 6.5.1.1 */ |