]>
Commit | Line | Data |
---|---|---|
66ea6f4c | 1 | /* YACC parser for C syntax and for Objective C. -*-c-*- |
f560bf91 JM |
2 | Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, |
3 | 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. | |
028299c6 | 4 | |
1322177d | 5 | This file is part of GCC. |
028299c6 | 6 | |
1322177d LB |
7 | GCC is free software; you can redistribute it and/or modify it under |
8 | the terms of the GNU General Public License as published by the Free | |
9 | Software Foundation; either version 2, or (at your option) any later | |
10 | version. | |
028299c6 | 11 | |
1322177d LB |
12 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
13 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 | for more details. | |
028299c6 RS |
16 | |
17 | You should have received a copy of the GNU General Public License | |
1322177d LB |
18 | along with GCC; see the file COPYING. If not, write to the Free |
19 | Software Foundation, 59 Temple Place - Suite 330, Boston, MA | |
20 | 02111-1307, USA. */ | |
028299c6 RS |
21 | |
22 | /* This file defines the grammar of C and that of Objective C. | |
264fa2db ZL |
23 | @@ifobjc ... @@end_ifobjc conditionals contain code for Objective C only. |
24 | @@ifc ... @@end_ifc conditionals contain code for C only. | |
66b2ba11 | 25 | Sed commands in Makefile.in are used to convert this file into |
028299c6 RS |
26 | c-parse.y and into objc-parse.y. */ |
27 | ||
28 | /* To whomever it may concern: I have heard that such a thing was once | |
41ddaaa4 | 29 | written by AT&T, but I have never seen it. */ |
028299c6 | 30 | |
264fa2db | 31 | @@ifc |
f2e6e530 | 32 | %expect 10 /* shift/reduce conflicts, and no reduce/reduce conflicts. */ |
264fa2db | 33 | @@end_ifc |
028299c6 RS |
34 | |
35 | %{ | |
818e50a5 | 36 | #include "config.h" |
944fc8ab | 37 | #include "system.h" |
4977bab6 ZW |
38 | #include "coretypes.h" |
39 | #include "tm.h" | |
028299c6 | 40 | #include "tree.h" |
e57e265b | 41 | #include "langhooks.h" |
028299c6 | 42 | #include "input.h" |
8b97c5f8 ZW |
43 | #include "cpplib.h" |
44 | #include "intl.h" | |
45 | #include "timevar.h" | |
81a75f0f | 46 | #include "c-pragma.h" /* For YYDEBUG definition, and parse_in. */ |
028299c6 RS |
47 | #include "c-tree.h" |
48 | #include "flags.h" | |
17211ab5 | 49 | #include "varray.h" |
990ac8d7 | 50 | #include "output.h" |
5f6da302 | 51 | #include "toplev.h" |
1526a060 | 52 | #include "ggc.h" |
84d901be | 53 | |
264fa2db | 54 | @@ifobjc |
df24d0da | 55 | #include "objc-act.h" |
264fa2db | 56 | @@end_ifobjc |
028299c6 | 57 | |
028299c6 RS |
58 | /* Like YYERROR but do call yyerror. */ |
59 | #define YYERROR1 { yyerror ("syntax error"); YYERROR; } | |
94a50397 RH |
60 | |
61 | /* Like the default stack expander, except (1) use realloc when possible, | |
62 | (2) impose no hard maxiumum on stack size, (3) REALLY do not use alloca. | |
63 | ||
64 | Irritatingly, YYSTYPE is defined after this %{ %} block, so we cannot | |
65 | give malloced_yyvs its proper type. This is ok since all we need from | |
66 | it is to be able to free it. */ | |
67 | ||
68 | static short *malloced_yyss; | |
69 | static void *malloced_yyvs; | |
70 | ||
71 | #define yyoverflow(MSG, SS, SSSIZE, VS, VSSIZE, YYSSZ) \ | |
72 | do { \ | |
73 | size_t newsize; \ | |
74 | short *newss; \ | |
75 | YYSTYPE *newvs; \ | |
76 | newsize = *(YYSSZ) *= 2; \ | |
77 | if (malloced_yyss) \ | |
78 | { \ | |
703ad42b KG |
79 | newss = really_call_realloc (*(SS), newsize * sizeof (short)); \ |
80 | newvs = really_call_realloc (*(VS), newsize * sizeof (YYSTYPE)); \ | |
94a50397 RH |
81 | } \ |
82 | else \ | |
83 | { \ | |
703ad42b KG |
84 | newss = really_call_malloc (newsize * sizeof (short)); \ |
85 | newvs = really_call_malloc (newsize * sizeof (YYSTYPE)); \ | |
94a50397 RH |
86 | if (newss) \ |
87 | memcpy (newss, *(SS), (SSSIZE)); \ | |
88 | if (newvs) \ | |
89 | memcpy (newvs, *(VS), (VSSIZE)); \ | |
90 | } \ | |
91 | if (!newss || !newvs) \ | |
92 | { \ | |
93 | yyerror (MSG); \ | |
94 | return 2; \ | |
95 | } \ | |
96 | *(SS) = newss; \ | |
97 | *(VS) = newvs; \ | |
98 | malloced_yyss = newss; \ | |
99 | malloced_yyvs = (void *) newvs; \ | |
100 | } while (0) | |
028299c6 RS |
101 | %} |
102 | ||
103 | %start program | |
104 | ||
105 | %union {long itype; tree ttype; enum tree_code code; | |
374a4e6c | 106 | location_t location; } |
028299c6 RS |
107 | |
108 | /* All identifiers that are not reserved words | |
109 | and are not declared typedefs in the current block */ | |
110 | %token IDENTIFIER | |
111 | ||
112 | /* All identifiers that are declared typedefs in the current block. | |
113 | In some contexts, they are treated just like IDENTIFIER, | |
114 | but they can also serve as typespecs in declarations. */ | |
115 | %token TYPENAME | |
116 | ||
117 | /* Reserved words that specify storage class. | |
118 | yylval contains an IDENTIFIER_NODE which indicates which one. */ | |
f79f2651 NB |
119 | %token SCSPEC /* Storage class other than static. */ |
120 | %token STATIC /* Static storage class. */ | |
028299c6 RS |
121 | |
122 | /* Reserved words that specify type. | |
123 | yylval contains an IDENTIFIER_NODE which indicates which one. */ | |
124 | %token TYPESPEC | |
125 | ||
3932261a | 126 | /* Reserved words that qualify type: "const", "volatile", or "restrict". |
028299c6 RS |
127 | yylval contains an IDENTIFIER_NODE which indicates which one. */ |
128 | %token TYPE_QUAL | |
129 | ||
130 | /* Character or numeric constants. | |
131 | yylval is the node for the constant. */ | |
132 | %token CONSTANT | |
133 | ||
a23c9413 NB |
134 | /* String constants in raw form. |
135 | yylval is a STRING_CST node. */ | |
d479d37f | 136 | |
a23c9413 | 137 | %token STRING |
028299c6 RS |
138 | |
139 | /* "...", used for functions with variable arglists. */ | |
140 | %token ELLIPSIS | |
141 | ||
142 | /* the reserved words */ | |
143 | /* SCO include files test "ASM", so use something else. */ | |
144 | %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT | |
5ed7f7b1 | 145 | %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF |
028299c6 | 146 | %token ATTRIBUTE EXTENSION LABEL |
ecbcf7b3 | 147 | %token REALPART IMAGPART VA_ARG CHOOSE_EXPR TYPES_COMPATIBLE_P |
4b4f19ec | 148 | %token PTR_VALUE PTR_BASE PTR_EXTENT |
7a3ea201 | 149 | %token FUNC_NAME OFFSETOF |
0ba8a114 | 150 | |
028299c6 RS |
151 | /* Add precedence rules to solve dangling else s/r conflict */ |
152 | %nonassoc IF | |
153 | %nonassoc ELSE | |
154 | ||
155 | /* Define the operator tokens and their precedences. | |
156 | The value is an integer because, if used, it is the tree code | |
157 | to use in the expression made from the operator. */ | |
158 | ||
159 | %right <code> ASSIGN '=' | |
160 | %right <code> '?' ':' | |
161 | %left <code> OROR | |
162 | %left <code> ANDAND | |
163 | %left <code> '|' | |
164 | %left <code> '^' | |
165 | %left <code> '&' | |
166 | %left <code> EQCOMPARE | |
167 | %left <code> ARITHCOMPARE | |
168 | %left <code> LSHIFT RSHIFT | |
169 | %left <code> '+' '-' | |
170 | %left <code> '*' '/' '%' | |
171 | %right <code> UNARY PLUSPLUS MINUSMINUS | |
172 | %left HYPERUNARY | |
173 | %left <code> POINTSAT '.' '(' '[' | |
174 | ||
175 | /* The Objective-C keywords. These are included in C and in | |
176 | Objective C, so that the token codes are the same in both. */ | |
f2b5cf97 DA |
177 | %token AT_INTERFACE AT_IMPLEMENTATION AT_END AT_SELECTOR AT_DEFS AT_ENCODE |
178 | %token CLASSNAME AT_PUBLIC AT_PRIVATE AT_PROTECTED AT_PROTOCOL | |
179 | %token OBJECTNAME AT_CLASS AT_ALIAS | |
264fa2db | 180 | %token AT_THROW AT_TRY AT_CATCH AT_FINALLY AT_SYNCHRONIZED |
e6cc3a24 | 181 | %token OBJC_STRING |
e31c7eec | 182 | |
028299c6 | 183 | %type <code> unop |
0e5921e8 ZW |
184 | %type <ttype> ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT |
185 | %type <ttype> BREAK CONTINUE RETURN GOTO ASM_KEYWORD SIZEOF TYPEOF ALIGNOF | |
028299c6 RS |
186 | |
187 | %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist | |
b84a3874 | 188 | %type <ttype> expr_no_commas cast_expr unary_expr primary STRING |
25d78ace JM |
189 | %type <ttype> declspecs_nosc_nots_nosa_noea declspecs_nosc_nots_nosa_ea |
190 | %type <ttype> declspecs_nosc_nots_sa_noea declspecs_nosc_nots_sa_ea | |
191 | %type <ttype> declspecs_nosc_ts_nosa_noea declspecs_nosc_ts_nosa_ea | |
192 | %type <ttype> declspecs_nosc_ts_sa_noea declspecs_nosc_ts_sa_ea | |
193 | %type <ttype> declspecs_sc_nots_nosa_noea declspecs_sc_nots_nosa_ea | |
194 | %type <ttype> declspecs_sc_nots_sa_noea declspecs_sc_nots_sa_ea | |
195 | %type <ttype> declspecs_sc_ts_nosa_noea declspecs_sc_ts_nosa_ea | |
196 | %type <ttype> declspecs_sc_ts_sa_noea declspecs_sc_ts_sa_ea | |
197 | %type <ttype> declspecs_ts declspecs_nots | |
198 | %type <ttype> declspecs_ts_nosa declspecs_nots_nosa | |
199 | %type <ttype> declspecs_nosc_ts declspecs_nosc_nots declspecs_nosc declspecs | |
91d231cb | 200 | %type <ttype> maybe_type_quals_attrs typespec_nonattr typespec_attr |
25d78ace JM |
201 | %type <ttype> typespec_reserved_nonattr typespec_reserved_attr |
202 | %type <ttype> typespec_nonreserved_nonattr | |
7a3ea201 | 203 | %type <ttype> offsetof_member_designator |
25d78ace | 204 | |
9f0e2d86 ZW |
205 | %type <ttype> scspec SCSPEC STATIC TYPESPEC TYPE_QUAL maybe_volatile |
206 | %type <ttype> initdecls notype_initdecls initdcl notype_initdcl init | |
8507c40a | 207 | %type <ttype> simple_asm_expr maybeasm asm_stmt asm_argument |
028299c6 | 208 | %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers |
660b43c8 | 209 | %type <ttype> maybe_attribute attributes attribute attribute_list attrib |
1aaec916 | 210 | %type <ttype> any_word |
028299c6 | 211 | |
325c3691 RH |
212 | %type <ttype> compstmt compstmt_start compstmt_primary_start |
213 | %type <ttype> do_stmt_start stmt label | |
028299c6 | 214 | |
325c3691 | 215 | %type <ttype> c99_block_start c99_block_lineno_labeled_stmt |
028299c6 RS |
216 | %type <ttype> declarator |
217 | %type <ttype> notype_declarator after_type_declarator | |
218 | %type <ttype> parm_declarator | |
97d24516 | 219 | %type <ttype> parm_declarator_starttypename parm_declarator_nostarttypename |
0e03329a | 220 | %type <ttype> array_declarator |
028299c6 | 221 | |
25d78ace JM |
222 | %type <ttype> structsp_attr structsp_nonattr |
223 | %type <ttype> component_decl_list component_decl_list2 | |
224 | %type <ttype> component_decl components components_notype component_declarator | |
225 | %type <ttype> component_notype_declarator | |
028299c6 | 226 | %type <ttype> enumlist enumerator |
4051959b | 227 | %type <ttype> struct_head union_head enum_head |
25d78ace JM |
228 | %type <ttype> typename absdcl absdcl1 absdcl1_ea absdcl1_noea |
229 | %type <ttype> direct_absdcl1 absdcl_maybe_attribute | |
230 | %type <ttype> xexpr parms parm firstparm identifiers | |
028299c6 RS |
231 | |
232 | %type <ttype> parmlist parmlist_1 parmlist_2 | |
233 | %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1 | |
234 | %type <ttype> identifiers_or_typenames | |
235 | ||
1aaec916 | 236 | %type <itype> setspecs setspecs_fp extension |
028299c6 | 237 | |
374a4e6c | 238 | %type <location> save_location |
028299c6 | 239 | \f |
264fa2db | 240 | @@ifobjc |
028299c6 RS |
241 | /* the Objective-C nonterminals */ |
242 | ||
243 | %type <ttype> ivar_decl_list ivar_decls ivar_decl ivars ivar_declarator | |
244 | %type <ttype> methoddecl unaryselector keywordselector selector | |
245 | %type <ttype> keyworddecl receiver objcmessageexpr messageargs | |
246 | %type <ttype> keywordexpr keywordarglist keywordarg | |
247 | %type <ttype> myparms myparm optparmlist reservedwords objcselectorexpr | |
248 | %type <ttype> selectorarg keywordnamelist keywordname objcencodeexpr | |
e6cc3a24 | 249 | %type <ttype> non_empty_protocolrefs protocolrefs identifier_list objcprotocolexpr |
957a1c32 | 250 | |
e6cc3a24 | 251 | %type <ttype> CLASSNAME OBJECTNAME OBJC_STRING |
264fa2db | 252 | |
4a6bcd93 | 253 | %type <ttype> superclass |
264fa2db | 254 | @@end_ifobjc |
028299c6 RS |
255 | \f |
256 | %{ | |
84d901be | 257 | /* Number of statements (loosely speaking) and compound statements |
818e50a5 | 258 | seen so far. */ |
028299c6 | 259 | static int stmt_count; |
818e50a5 | 260 | static int compstmt_count; |
84d901be | 261 | |
028299c6 | 262 | /* List of types and structure classes of the current declaration. */ |
e2500fed GK |
263 | static GTY(()) tree current_declspecs; |
264 | static GTY(()) tree prefix_attributes; | |
028299c6 | 265 | |
4b01f8d8 JM |
266 | /* List of all the attributes applying to the identifier currently being |
267 | declared; includes prefix_attributes and possibly some more attributes | |
268 | just after a comma. */ | |
e2500fed | 269 | static GTY(()) tree all_prefix_attributes; |
4b01f8d8 JM |
270 | |
271 | /* Stack of saved values of current_declspecs, prefix_attributes and | |
272 | all_prefix_attributes. */ | |
e2500fed | 273 | static GTY(()) tree declspec_stack; |
028299c6 | 274 | |
4b01f8d8 JM |
275 | /* PUSH_DECLSPEC_STACK is called from setspecs; POP_DECLSPEC_STACK |
276 | should be called from the productions making use of setspecs. */ | |
277 | #define PUSH_DECLSPEC_STACK \ | |
278 | do { \ | |
279 | declspec_stack = tree_cons (build_tree_list (prefix_attributes, \ | |
280 | all_prefix_attributes), \ | |
281 | current_declspecs, \ | |
282 | declspec_stack); \ | |
283 | } while (0) | |
284 | ||
285 | #define POP_DECLSPEC_STACK \ | |
286 | do { \ | |
287 | current_declspecs = TREE_VALUE (declspec_stack); \ | |
288 | prefix_attributes = TREE_PURPOSE (TREE_PURPOSE (declspec_stack)); \ | |
289 | all_prefix_attributes = TREE_VALUE (TREE_PURPOSE (declspec_stack)); \ | |
290 | declspec_stack = TREE_CHAIN (declspec_stack); \ | |
291 | } while (0) | |
292 | ||
c3b6e114 JK |
293 | /* For __extension__, save/restore the warning flags which are |
294 | controlled by __extension__. */ | |
1aaec916 RH |
295 | #define SAVE_EXT_FLAGS() \ |
296 | (pedantic \ | |
297 | | (warn_pointer_arith << 1) \ | |
298 | | (warn_traditional << 2) \ | |
299 | | (flag_iso << 3)) | |
5137bd4f | 300 | |
1aaec916 | 301 | #define RESTORE_EXT_FLAGS(val) \ |
5137bd4f | 302 | do { \ |
5137bd4f RH |
303 | pedantic = val & 1; \ |
304 | warn_pointer_arith = (val >> 1) & 1; \ | |
305 | warn_traditional = (val >> 2) & 1; \ | |
750491fc | 306 | flag_iso = (val >> 3) & 1; \ |
c3b6e114 JK |
307 | } while (0) |
308 | ||
264fa2db | 309 | @@ifobjc |
8607f1bc ZL |
310 | /* Objective-C specific parser/lexer information */ |
311 | ||
312 | static enum tree_code objc_inherit_code; | |
313 | static int objc_pq_context = 0, objc_public_flag = 0; | |
028299c6 | 314 | |
f2e6e530 | 315 | /* The following flag is needed to contextualize ObjC lexical analysis. |
84d901be AD |
316 | In some cases (e.g., 'int NSObject;'), it is undesirable to bind |
317 | an identifier to an ObjC class, even if a class with that name | |
f2e6e530 | 318 | exists. */ |
8607f1bc | 319 | static int objc_need_raw_identifier; |
f2e6e530 | 320 | #define OBJC_NEED_RAW_IDENTIFIER(VAL) objc_need_raw_identifier = VAL |
264fa2db | 321 | @@end_ifobjc |
028299c6 | 322 | |
264fa2db | 323 | @@ifc |
f2e6e530 | 324 | #define OBJC_NEED_RAW_IDENTIFIER(VAL) /* nothing */ |
264fa2db | 325 | @@end_ifc |
f2e6e530 | 326 | |
028299c6 RS |
327 | /* Tell yyparse how to print a token's value, if yydebug is set. */ |
328 | ||
329 | #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL) | |
0e5921e8 | 330 | |
f55ade6e AJ |
331 | static void yyprint (FILE *, int, YYSTYPE); |
332 | static void yyerror (const char *); | |
333 | static int yylexname (void); | |
334 | static inline int _yylex (void); | |
335 | static int yylex (void); | |
336 | static void init_reswords (void); | |
1526a060 | 337 | |
e2500fed | 338 | /* Initialisation routine for this file. */ |
1526a060 | 339 | void |
f55ade6e | 340 | c_parse_init (void) |
1526a060 | 341 | { |
f5e99456 | 342 | init_reswords (); |
1526a060 BS |
343 | } |
344 | ||
028299c6 RS |
345 | %} |
346 | \f | |
347 | %% | |
348 | program: /* empty */ | |
349 | { if (pedantic) | |
89abf8d1 | 350 | pedwarn ("ISO C forbids an empty source file"); |
028299c6 RS |
351 | } |
352 | | extdefs | |
028299c6 RS |
353 | ; |
354 | ||
355 | /* the reason for the strange actions in this rule | |
356 | is so that notype_initdecls when reached via datadef | |
357 | can find a valid list of type and sc specs in $0. */ | |
358 | ||
359 | extdefs: | |
360 | {$<ttype>$ = NULL_TREE; } extdef | |
fbddce27 | 361 | | extdefs {$<ttype>$ = NULL_TREE; ggc_collect(); } extdef |
028299c6 RS |
362 | ; |
363 | ||
364 | extdef: | |
365 | fndef | |
366 | | datadef | |
9f0e2d86 ZW |
367 | | asmdef |
368 | | extension extdef | |
369 | { RESTORE_EXT_FLAGS ($1); } | |
264fa2db | 370 | @@ifobjc |
028299c6 | 371 | | objcdef |
264fa2db | 372 | @@end_ifobjc |
028299c6 RS |
373 | ; |
374 | ||
375 | datadef: | |
376 | setspecs notype_initdecls ';' | |
377 | { if (pedantic) | |
89abf8d1 | 378 | error ("ISO C forbids data definition with no type or storage class"); |
f458d1d5 | 379 | else |
84d901be | 380 | warning ("data definition has no type or storage class"); |
962a2496 | 381 | |
4b01f8d8 | 382 | POP_DECLSPEC_STACK; } |
25d78ace | 383 | | declspecs_nots setspecs notype_initdecls ';' |
4b01f8d8 | 384 | { POP_DECLSPEC_STACK; } |
25d78ace | 385 | | declspecs_ts setspecs initdecls ';' |
4b01f8d8 | 386 | { POP_DECLSPEC_STACK; } |
25d78ace | 387 | | declspecs ';' |
028299c6 RS |
388 | { shadow_tag ($1); } |
389 | | error ';' | |
390 | | error '}' | |
391 | | ';' | |
392 | { if (pedantic) | |
89abf8d1 | 393 | pedwarn ("ISO C does not allow extra `;' outside of a function"); } |
028299c6 RS |
394 | ; |
395 | \f | |
396 | fndef: | |
25d78ace | 397 | declspecs_ts setspecs declarator |
084c4c25 | 398 | { if (! start_function (current_declspecs, $3, |
4b01f8d8 | 399 | all_prefix_attributes)) |
028299c6 | 400 | YYERROR1; |
0e5921e8 | 401 | } |
374a4e6c | 402 | old_style_parm_decls save_location |
f31686a3 | 403 | { DECL_SOURCE_LOCATION (current_function_decl) = $6; |
b190f239 | 404 | store_parm_decls (); } |
374a4e6c | 405 | compstmt_or_error |
4a46cbfb | 406 | { finish_function (); |
4b01f8d8 | 407 | POP_DECLSPEC_STACK; } |
25d78ace | 408 | | declspecs_ts setspecs declarator error |
4b01f8d8 | 409 | { POP_DECLSPEC_STACK; } |
25d78ace | 410 | | declspecs_nots setspecs notype_declarator |
084c4c25 | 411 | { if (! start_function (current_declspecs, $3, |
4b01f8d8 | 412 | all_prefix_attributes)) |
028299c6 | 413 | YYERROR1; |
0e5921e8 | 414 | } |
374a4e6c | 415 | old_style_parm_decls save_location |
f31686a3 | 416 | { DECL_SOURCE_LOCATION (current_function_decl) = $6; |
b190f239 NS |
417 | store_parm_decls (); } |
418 | compstmt_or_error | |
4a46cbfb | 419 | { finish_function (); |
4b01f8d8 | 420 | POP_DECLSPEC_STACK; } |
25d78ace | 421 | | declspecs_nots setspecs notype_declarator error |
4b01f8d8 | 422 | { POP_DECLSPEC_STACK; } |
9fe9dd86 | 423 | | setspecs notype_declarator |
866890d9 | 424 | { if (! start_function (NULL_TREE, $2, |
4b01f8d8 | 425 | all_prefix_attributes)) |
028299c6 | 426 | YYERROR1; |
0e5921e8 | 427 | } |
374a4e6c | 428 | old_style_parm_decls save_location |
f31686a3 | 429 | { DECL_SOURCE_LOCATION (current_function_decl) = $5; |
b190f239 NS |
430 | store_parm_decls (); } |
431 | compstmt_or_error | |
4a46cbfb | 432 | { finish_function (); |
4b01f8d8 | 433 | POP_DECLSPEC_STACK; } |
028299c6 | 434 | | setspecs notype_declarator error |
4b01f8d8 | 435 | { POP_DECLSPEC_STACK; } |
028299c6 RS |
436 | ; |
437 | ||
438 | identifier: | |
439 | IDENTIFIER | |
440 | | TYPENAME | |
264fa2db | 441 | @@ifobjc |
e31c7eec | 442 | | OBJECTNAME |
f2e6e530 | 443 | | CLASSNAME |
264fa2db | 444 | @@end_ifobjc |
028299c6 RS |
445 | ; |
446 | ||
447 | unop: '&' | |
448 | { $$ = ADDR_EXPR; } | |
449 | | '-' | |
450 | { $$ = NEGATE_EXPR; } | |
451 | | '+' | |
895ea614 | 452 | { $$ = CONVERT_EXPR; |
264fa2db | 453 | @@ifc |
aac625ac | 454 | if (warn_traditional && !in_system_header) |
895ea614 | 455 | warning ("traditional C rejects the unary plus operator"); |
264fa2db | 456 | @@end_ifc |
895ea614 | 457 | } |
028299c6 RS |
458 | | PLUSPLUS |
459 | { $$ = PREINCREMENT_EXPR; } | |
460 | | MINUSMINUS | |
461 | { $$ = PREDECREMENT_EXPR; } | |
462 | | '~' | |
463 | { $$ = BIT_NOT_EXPR; } | |
464 | | '!' | |
465 | { $$ = TRUTH_NOT_EXPR; } | |
466 | ; | |
467 | ||
468 | expr: nonnull_exprlist | |
469 | { $$ = build_compound_expr ($1); } | |
470 | ; | |
471 | ||
472 | exprlist: | |
473 | /* empty */ | |
474 | { $$ = NULL_TREE; } | |
475 | | nonnull_exprlist | |
476 | ; | |
477 | ||
478 | nonnull_exprlist: | |
479 | expr_no_commas | |
480 | { $$ = build_tree_list (NULL_TREE, $1); } | |
481 | | nonnull_exprlist ',' expr_no_commas | |
482 | { chainon ($1, build_tree_list (NULL_TREE, $3)); } | |
483 | ; | |
484 | ||
485 | unary_expr: | |
486 | primary | |
487 | | '*' cast_expr %prec UNARY | |
488 | { $$ = build_indirect_ref ($2, "unary *"); } | |
489 | /* __extension__ turns off -pedantic for following primary. */ | |
72acf258 JM |
490 | | extension cast_expr %prec UNARY |
491 | { $$ = $2; | |
750491fc | 492 | RESTORE_EXT_FLAGS ($1); } |
028299c6 | 493 | | unop cast_expr %prec UNARY |
5303129f RS |
494 | { $$ = build_unary_op ($1, $2, 0); |
495 | overflow_warning ($$); } | |
028299c6 RS |
496 | /* Refer to the address of a label as a pointer. */ |
497 | | ANDAND identifier | |
15b732b2 | 498 | { $$ = finish_label_address_expr ($2); } |
5f8f4a07 RK |
499 | | sizeof unary_expr %prec UNARY |
500 | { skip_evaluation--; | |
501 | if (TREE_CODE ($2) == COMPONENT_REF | |
818e50a5 | 502 | && DECL_C_BIT_FIELD (TREE_OPERAND ($2, 1))) |
028299c6 RS |
503 | error ("`sizeof' applied to a bit-field"); |
504 | $$ = c_sizeof (TREE_TYPE ($2)); } | |
5f8f4a07 RK |
505 | | sizeof '(' typename ')' %prec HYPERUNARY |
506 | { skip_evaluation--; | |
507 | $$ = c_sizeof (groktypename ($3)); } | |
508 | | alignof unary_expr %prec UNARY | |
509 | { skip_evaluation--; | |
510 | $$ = c_alignof_expr ($2); } | |
511 | | alignof '(' typename ')' %prec HYPERUNARY | |
512 | { skip_evaluation--; | |
513 | $$ = c_alignof (groktypename ($3)); } | |
475e8534 | 514 | | REALPART cast_expr %prec UNARY |
12d073e7 | 515 | { $$ = build_unary_op (REALPART_EXPR, $2, 0); } |
475e8534 | 516 | | IMAGPART cast_expr %prec UNARY |
12d073e7 | 517 | { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); } |
028299c6 RS |
518 | ; |
519 | ||
5f8f4a07 RK |
520 | sizeof: |
521 | SIZEOF { skip_evaluation++; } | |
522 | ; | |
523 | ||
524 | alignof: | |
525 | ALIGNOF { skip_evaluation++; } | |
526 | ; | |
527 | ||
25587e40 AO |
528 | typeof: |
529 | TYPEOF { skip_evaluation++; } | |
530 | ; | |
531 | ||
028299c6 RS |
532 | cast_expr: |
533 | unary_expr | |
534 | | '(' typename ')' cast_expr %prec UNARY | |
15b732b2 | 535 | { $$ = c_cast_expr ($2, $4); } |
028299c6 RS |
536 | ; |
537 | ||
538 | expr_no_commas: | |
539 | cast_expr | |
540 | | expr_no_commas '+' expr_no_commas | |
541 | { $$ = parser_build_binary_op ($2, $1, $3); } | |
542 | | expr_no_commas '-' expr_no_commas | |
543 | { $$ = parser_build_binary_op ($2, $1, $3); } | |
544 | | expr_no_commas '*' expr_no_commas | |
545 | { $$ = parser_build_binary_op ($2, $1, $3); } | |
546 | | expr_no_commas '/' expr_no_commas | |
547 | { $$ = parser_build_binary_op ($2, $1, $3); } | |
548 | | expr_no_commas '%' expr_no_commas | |
549 | { $$ = parser_build_binary_op ($2, $1, $3); } | |
550 | | expr_no_commas LSHIFT expr_no_commas | |
551 | { $$ = parser_build_binary_op ($2, $1, $3); } | |
552 | | expr_no_commas RSHIFT expr_no_commas | |
553 | { $$ = parser_build_binary_op ($2, $1, $3); } | |
554 | | expr_no_commas ARITHCOMPARE expr_no_commas | |
555 | { $$ = parser_build_binary_op ($2, $1, $3); } | |
556 | | expr_no_commas EQCOMPARE expr_no_commas | |
557 | { $$ = parser_build_binary_op ($2, $1, $3); } | |
558 | | expr_no_commas '&' expr_no_commas | |
559 | { $$ = parser_build_binary_op ($2, $1, $3); } | |
560 | | expr_no_commas '|' expr_no_commas | |
561 | { $$ = parser_build_binary_op ($2, $1, $3); } | |
562 | | expr_no_commas '^' expr_no_commas | |
563 | { $$ = parser_build_binary_op ($2, $1, $3); } | |
5f8f4a07 | 564 | | expr_no_commas ANDAND |
673fda6b | 565 | { $1 = lang_hooks.truthvalue_conversion |
78ef5b89 | 566 | (default_conversion ($1)); |
de7df9eb | 567 | skip_evaluation += $1 == truthvalue_false_node; } |
5f8f4a07 | 568 | expr_no_commas |
de7df9eb | 569 | { skip_evaluation -= $1 == truthvalue_false_node; |
5f8f4a07 RK |
570 | $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $4); } |
571 | | expr_no_commas OROR | |
673fda6b | 572 | { $1 = lang_hooks.truthvalue_conversion |
78ef5b89 | 573 | (default_conversion ($1)); |
de7df9eb | 574 | skip_evaluation += $1 == truthvalue_true_node; } |
5f8f4a07 | 575 | expr_no_commas |
de7df9eb | 576 | { skip_evaluation -= $1 == truthvalue_true_node; |
5f8f4a07 RK |
577 | $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $4); } |
578 | | expr_no_commas '?' | |
673fda6b | 579 | { $1 = lang_hooks.truthvalue_conversion |
78ef5b89 | 580 | (default_conversion ($1)); |
de7df9eb | 581 | skip_evaluation += $1 == truthvalue_false_node; } |
5f8f4a07 | 582 | expr ':' |
de7df9eb JM |
583 | { skip_evaluation += (($1 == truthvalue_true_node) |
584 | - ($1 == truthvalue_false_node)); } | |
5f8f4a07 | 585 | expr_no_commas |
de7df9eb | 586 | { skip_evaluation -= $1 == truthvalue_true_node; |
5f8f4a07 RK |
587 | $$ = build_conditional_expr ($1, $4, $7); } |
588 | | expr_no_commas '?' | |
589 | { if (pedantic) | |
89abf8d1 | 590 | pedwarn ("ISO C forbids omitting the middle term of a ?: expression"); |
5f8f4a07 | 591 | /* Make sure first operand is calculated only once. */ |
e57e265b | 592 | $<ttype>2 = save_expr (default_conversion ($1)); |
673fda6b | 593 | $1 = lang_hooks.truthvalue_conversion ($<ttype>2); |
de7df9eb | 594 | skip_evaluation += $1 == truthvalue_true_node; } |
5f8f4a07 | 595 | ':' expr_no_commas |
de7df9eb | 596 | { skip_evaluation -= $1 == truthvalue_true_node; |
5f8f4a07 | 597 | $$ = build_conditional_expr ($1, $<ttype>2, $5); } |
028299c6 | 598 | | expr_no_commas '=' expr_no_commas |
19d6ff23 RH |
599 | { char class; |
600 | $$ = build_modify_expr ($1, NOP_EXPR, $3); | |
601 | class = TREE_CODE_CLASS (TREE_CODE ($$)); | |
686deecb | 602 | if (IS_EXPR_CODE_CLASS (class)) |
19d6ff23 RH |
603 | C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); |
604 | } | |
028299c6 | 605 | | expr_no_commas ASSIGN expr_no_commas |
19d6ff23 RH |
606 | { char class; |
607 | $$ = build_modify_expr ($1, $2, $3); | |
78ef5b89 NB |
608 | /* This inhibits warnings in |
609 | c_common_truthvalue_conversion. */ | |
19d6ff23 | 610 | class = TREE_CODE_CLASS (TREE_CODE ($$)); |
686deecb | 611 | if (IS_EXPR_CODE_CLASS (class)) |
19d6ff23 RH |
612 | C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); |
613 | } | |
028299c6 RS |
614 | ; |
615 | ||
616 | primary: | |
617 | IDENTIFIER | |
618 | { | |
7e585d16 ZW |
619 | if (yychar == YYEMPTY) |
620 | yychar = YYLEX; | |
621 | $$ = build_external_ref ($1, yychar == '('); | |
028299c6 RS |
622 | } |
623 | | CONSTANT | |
b84a3874 | 624 | | STRING |
e6cc3a24 | 625 | | FUNC_NAME |
0ba8a114 | 626 | { $$ = fname_decl (C_RID_CODE ($$), $$); } |
84d901be | 627 | | '(' typename ')' '{' |
cedd825f JM |
628 | { start_init (NULL_TREE, NULL, 0); |
629 | $2 = groktypename ($2); | |
630 | really_start_incremental_init ($2); } | |
631 | initlist_maybe_comma '}' %prec UNARY | |
db3acfa5 | 632 | { tree constructor = pop_init_level (0); |
cedd825f JM |
633 | tree type = $2; |
634 | finish_init (); | |
635 | ||
636 | if (pedantic && ! flag_isoc99) | |
b46b8fb4 | 637 | pedwarn ("ISO C90 forbids compound literals"); |
db3acfa5 | 638 | $$ = build_compound_literal (type, constructor); |
cedd825f | 639 | } |
028299c6 RS |
640 | | '(' expr ')' |
641 | { char class = TREE_CODE_CLASS (TREE_CODE ($2)); | |
686deecb | 642 | if (IS_EXPR_CODE_CLASS (class)) |
028299c6 RS |
643 | C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK); |
644 | $$ = $2; } | |
645 | | '(' error ')' | |
646 | { $$ = error_mark_node; } | |
d0668a73 | 647 | | compstmt_primary_start compstmt_nostart ')' |
325c3691 RH |
648 | { if (pedantic) |
649 | pedwarn ("ISO C forbids braced-groups within expressions"); | |
650 | $$ = c_finish_stmt_expr ($1); | |
d0668a73 RH |
651 | } |
652 | | compstmt_primary_start error ')' | |
325c3691 | 653 | { c_finish_stmt_expr ($1); |
d0668a73 | 654 | $$ = error_mark_node; |
028299c6 RS |
655 | } |
656 | | primary '(' exprlist ')' %prec '.' | |
657 | { $$ = build_function_call ($1, $3); } | |
2f401cc8 NS |
658 | | VA_ARG '(' expr_no_commas ',' typename ')' |
659 | { $$ = build_va_arg ($3, groktypename ($5)); } | |
d3b4cd6f | 660 | |
7a3ea201 RH |
661 | | OFFSETOF '(' typename ',' offsetof_member_designator ')' |
662 | { $$ = build_offsetof (groktypename ($3), $5); } | |
663 | | OFFSETOF '(' error ')' | |
664 | { $$ = error_mark_node; } | |
665 | | CHOOSE_EXPR '(' expr_no_commas ',' expr_no_commas ',' | |
666 | expr_no_commas ')' | |
ecbcf7b3 AH |
667 | { |
668 | tree c; | |
669 | ||
670 | c = fold ($3); | |
671 | STRIP_NOPS (c); | |
672 | if (TREE_CODE (c) != INTEGER_CST) | |
7a3ea201 RH |
673 | error ("first argument to __builtin_choose_expr not" |
674 | " a constant"); | |
ecbcf7b3 AH |
675 | $$ = integer_zerop (c) ? $7 : $5; |
676 | } | |
7a3ea201 RH |
677 | | CHOOSE_EXPR '(' error ')' |
678 | { $$ = error_mark_node; } | |
679 | | TYPES_COMPATIBLE_P '(' typename ',' typename ')' | |
ecbcf7b3 AH |
680 | { |
681 | tree e1, e2; | |
682 | ||
683 | e1 = TYPE_MAIN_VARIANT (groktypename ($3)); | |
684 | e2 = TYPE_MAIN_VARIANT (groktypename ($5)); | |
685 | ||
132da1a5 | 686 | $$ = comptypes (e1, e2) |
ecbcf7b3 AH |
687 | ? build_int_2 (1, 0) : build_int_2 (0, 0); |
688 | } | |
7a3ea201 RH |
689 | | TYPES_COMPATIBLE_P '(' error ')' |
690 | { $$ = error_mark_node; } | |
028299c6 RS |
691 | | primary '[' expr ']' %prec '.' |
692 | { $$ = build_array_ref ($1, $3); } | |
693 | | primary '.' identifier | |
7a3ea201 | 694 | { $$ = build_component_ref ($1, $3); } |
028299c6 RS |
695 | | primary POINTSAT identifier |
696 | { | |
697 | tree expr = build_indirect_ref ($1, "->"); | |
7a3ea201 | 698 | $$ = build_component_ref (expr, $3); |
028299c6 RS |
699 | } |
700 | | primary PLUSPLUS | |
701 | { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); } | |
702 | | primary MINUSMINUS | |
703 | { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); } | |
264fa2db | 704 | @@ifobjc |
028299c6 RS |
705 | | objcmessageexpr |
706 | { $$ = build_message_expr ($1); } | |
707 | | objcselectorexpr | |
708 | { $$ = build_selector_expr ($1); } | |
e31c7eec TW |
709 | | objcprotocolexpr |
710 | { $$ = build_protocol_expr ($1); } | |
028299c6 RS |
711 | | objcencodeexpr |
712 | { $$ = build_encode_expr ($1); } | |
e6cc3a24 | 713 | | OBJC_STRING |
e31c7eec | 714 | { $$ = build_objc_string_object ($1); } |
264fa2db | 715 | @@end_ifobjc |
028299c6 RS |
716 | ; |
717 | ||
7a3ea201 RH |
718 | /* This is the second argument to __builtin_offsetof. We must have one |
719 | identifier, and beyond that we want to accept sub structure and sub | |
720 | array references. We return tree list where each element has | |
721 | PURPOSE set for component refs or VALUE set for array refs. We'll | |
722 | turn this into something real inside build_offsetof. */ | |
723 | ||
724 | offsetof_member_designator: | |
725 | identifier | |
726 | { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); } | |
727 | | offsetof_member_designator '.' identifier | |
728 | { $$ = tree_cons ($3, NULL_TREE, $1); } | |
729 | | offsetof_member_designator '[' expr ']' | |
730 | { $$ = tree_cons (NULL_TREE, $3, $1); } | |
731 | ; | |
732 | ||
084c4c25 | 733 | old_style_parm_decls: |
028299c6 RS |
734 | /* empty */ |
735 | | datadecls | |
028299c6 RS |
736 | ; |
737 | ||
738 | /* The following are analogous to lineno_decl, decls and decl | |
739 | except that they do not allow nested functions. | |
740 | They are used for old-style parm decls. */ | |
741 | lineno_datadecl: | |
374a4e6c | 742 | save_location datadecl |
028299c6 RS |
743 | { } |
744 | ; | |
745 | ||
746 | datadecls: | |
747 | lineno_datadecl | |
748 | | errstmt | |
749 | | datadecls lineno_datadecl | |
750 | | lineno_datadecl errstmt | |
751 | ; | |
752 | ||
084c4c25 RK |
753 | /* We don't allow prefix attributes here because they cause reduce/reduce |
754 | conflicts: we can't know whether we're parsing a function decl with | |
755 | attribute suffix, or function defn with attribute prefix on first old | |
756 | style parm. */ | |
028299c6 | 757 | datadecl: |
25d78ace | 758 | declspecs_ts_nosa setspecs initdecls ';' |
4b01f8d8 | 759 | { POP_DECLSPEC_STACK; } |
25d78ace | 760 | | declspecs_nots_nosa setspecs notype_initdecls ';' |
4b01f8d8 | 761 | { POP_DECLSPEC_STACK; } |
25d78ace | 762 | | declspecs_ts_nosa ';' |
028299c6 RS |
763 | { shadow_tag_warned ($1, 1); |
764 | pedwarn ("empty declaration"); } | |
25d78ace | 765 | | declspecs_nots_nosa ';' |
028299c6 RS |
766 | { pedwarn ("empty declaration"); } |
767 | ; | |
768 | ||
769 | /* This combination which saves a lineno before a decl | |
770 | is the normal thing to use, rather than decl itself. | |
771 | This is to avoid shift/reduce conflicts in contexts | |
772 | where statement labels are allowed. */ | |
773 | lineno_decl: | |
374a4e6c | 774 | save_location decl |
028299c6 RS |
775 | { } |
776 | ; | |
777 | ||
028299c6 RS |
778 | /* records the type and storage class specs to use for processing |
779 | the declarators that follow. | |
780 | Maintains a stack of outer-level values of current_declspecs, | |
781 | for the sake of parm declarations nested in function declarators. */ | |
782 | setspecs: /* empty */ | |
4dd7201e | 783 | { pending_xref_error (); |
4b01f8d8 | 784 | PUSH_DECLSPEC_STACK; |
084c4c25 | 785 | split_specs_attrs ($<ttype>0, |
4b01f8d8 JM |
786 | ¤t_declspecs, &prefix_attributes); |
787 | all_prefix_attributes = prefix_attributes; } | |
34724814 RK |
788 | ; |
789 | ||
4b01f8d8 JM |
790 | /* Possibly attributes after a comma, which should reset all_prefix_attributes |
791 | to prefix_attributes with these ones chained on the front. */ | |
792 | maybe_resetattrs: | |
91d231cb JM |
793 | maybe_attribute |
794 | { all_prefix_attributes = chainon ($1, prefix_attributes); } | |
4b01f8d8 JM |
795 | ; |
796 | ||
028299c6 | 797 | decl: |
25d78ace | 798 | declspecs_ts setspecs initdecls ';' |
4b01f8d8 | 799 | { POP_DECLSPEC_STACK; } |
25d78ace | 800 | | declspecs_nots setspecs notype_initdecls ';' |
4b01f8d8 | 801 | { POP_DECLSPEC_STACK; } |
25d78ace | 802 | | declspecs_ts setspecs nested_function |
4b01f8d8 | 803 | { POP_DECLSPEC_STACK; } |
25d78ace | 804 | | declspecs_nots setspecs notype_nested_function |
4b01f8d8 | 805 | { POP_DECLSPEC_STACK; } |
25d78ace | 806 | | declspecs ';' |
028299c6 | 807 | { shadow_tag ($1); } |
72acf258 | 808 | | extension decl |
750491fc | 809 | { RESTORE_EXT_FLAGS ($1); } |
028299c6 RS |
810 | ; |
811 | ||
25d78ace JM |
812 | /* A list of declaration specifiers. These are: |
813 | ||
f79f2651 | 814 | - Storage class specifiers (scspec), which for GCC currently includes |
25d78ace JM |
815 | function specifiers ("inline"). |
816 | ||
817 | - Type specifiers (typespec_*). | |
818 | ||
819 | - Type qualifiers (TYPE_QUAL). | |
820 | ||
821 | - Attribute specifier lists (attributes). | |
822 | ||
823 | These are stored as a TREE_LIST; the head of the list is the last | |
824 | item in the specifier list. Each entry in the list has either a | |
825 | TREE_PURPOSE that is an attribute specifier list, or a TREE_VALUE that | |
826 | is a single other specifier or qualifier; and a TREE_CHAIN that is the | |
827 | rest of the list. TREE_STATIC is set on the list if something other | |
828 | than a storage class specifier or attribute has been seen; this is used | |
829 | to warn for the obsolescent usage of storage class specifiers other than | |
830 | at the start of the list. (Doing this properly would require function | |
831 | specifiers to be handled separately from storage class specifiers.) | |
832 | ||
833 | The various cases below are classified according to: | |
834 | ||
835 | (a) Whether a storage class specifier is included or not; some | |
836 | places in the grammar disallow storage class specifiers (_sc or _nosc). | |
837 | ||
838 | (b) Whether a type specifier has been seen; after a type specifier, | |
839 | a typedef name is an identifier to redeclare (_ts or _nots). | |
840 | ||
841 | (c) Whether the list starts with an attribute; in certain places, | |
842 | the grammar requires specifiers that don't start with an attribute | |
843 | (_sa or _nosa). | |
844 | ||
845 | (d) Whether the list ends with an attribute (or a specifier such that | |
846 | any following attribute would have been parsed as part of that specifier); | |
847 | this avoids shift-reduce conflicts in the parsing of attributes | |
848 | (_ea or _noea). | |
849 | ||
850 | TODO: | |
851 | ||
852 | (i) Distinguish between function specifiers and storage class specifiers, | |
853 | at least for the purpose of warnings about obsolescent usage. | |
854 | ||
855 | (ii) Halve the number of productions here by eliminating the _sc/_nosc | |
856 | distinction and instead checking where required that storage class | |
857 | specifiers aren't present. */ | |
858 | ||
028299c6 RS |
859 | /* Declspecs which contain at least one type specifier or typedef name. |
860 | (Just `const' or `volatile' is not enough.) | |
084c4c25 RK |
861 | A typedef'd name following these is taken as a name to be declared. |
862 | Declspecs have a non-NULL TREE_VALUE, attributes do not. */ | |
028299c6 | 863 | |
25d78ace JM |
864 | declspecs_nosc_nots_nosa_noea: |
865 | TYPE_QUAL | |
866 | { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); | |
867 | TREE_STATIC ($$) = 1; } | |
868 | | declspecs_nosc_nots_nosa_noea TYPE_QUAL | |
869 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
870 | TREE_STATIC ($$) = 1; } | |
871 | | declspecs_nosc_nots_nosa_ea TYPE_QUAL | |
872 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
873 | TREE_STATIC ($$) = 1; } | |
028299c6 RS |
874 | ; |
875 | ||
25d78ace JM |
876 | declspecs_nosc_nots_nosa_ea: |
877 | declspecs_nosc_nots_nosa_noea attributes | |
878 | { $$ = tree_cons ($2, NULL_TREE, $1); | |
879 | TREE_STATIC ($$) = TREE_STATIC ($1); } | |
880 | ; | |
881 | ||
882 | declspecs_nosc_nots_sa_noea: | |
883 | declspecs_nosc_nots_sa_noea TYPE_QUAL | |
884 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
885 | TREE_STATIC ($$) = 1; } | |
886 | | declspecs_nosc_nots_sa_ea TYPE_QUAL | |
887 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
888 | TREE_STATIC ($$) = 1; } | |
889 | ; | |
890 | ||
891 | declspecs_nosc_nots_sa_ea: | |
892 | attributes | |
893 | { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); | |
894 | TREE_STATIC ($$) = 0; } | |
895 | | declspecs_nosc_nots_sa_noea attributes | |
896 | { $$ = tree_cons ($2, NULL_TREE, $1); | |
897 | TREE_STATIC ($$) = TREE_STATIC ($1); } | |
898 | ; | |
899 | ||
900 | declspecs_nosc_ts_nosa_noea: | |
901 | typespec_nonattr | |
902 | { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); | |
903 | TREE_STATIC ($$) = 1; } | |
904 | | declspecs_nosc_ts_nosa_noea TYPE_QUAL | |
905 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
906 | TREE_STATIC ($$) = 1; } | |
907 | | declspecs_nosc_ts_nosa_ea TYPE_QUAL | |
908 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
909 | TREE_STATIC ($$) = 1; } | |
910 | | declspecs_nosc_ts_nosa_noea typespec_reserved_nonattr | |
911 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
912 | TREE_STATIC ($$) = 1; } | |
913 | | declspecs_nosc_ts_nosa_ea typespec_reserved_nonattr | |
914 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
915 | TREE_STATIC ($$) = 1; } | |
916 | | declspecs_nosc_nots_nosa_noea typespec_nonattr | |
917 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
918 | TREE_STATIC ($$) = 1; } | |
919 | | declspecs_nosc_nots_nosa_ea typespec_nonattr | |
920 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
921 | TREE_STATIC ($$) = 1; } | |
922 | ; | |
923 | ||
924 | declspecs_nosc_ts_nosa_ea: | |
925 | typespec_attr | |
926 | { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); | |
927 | TREE_STATIC ($$) = 1; } | |
928 | | declspecs_nosc_ts_nosa_noea attributes | |
929 | { $$ = tree_cons ($2, NULL_TREE, $1); | |
930 | TREE_STATIC ($$) = TREE_STATIC ($1); } | |
931 | | declspecs_nosc_ts_nosa_noea typespec_reserved_attr | |
932 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
933 | TREE_STATIC ($$) = 1; } | |
934 | | declspecs_nosc_ts_nosa_ea typespec_reserved_attr | |
935 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
936 | TREE_STATIC ($$) = 1; } | |
937 | | declspecs_nosc_nots_nosa_noea typespec_attr | |
938 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
939 | TREE_STATIC ($$) = 1; } | |
940 | | declspecs_nosc_nots_nosa_ea typespec_attr | |
941 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
942 | TREE_STATIC ($$) = 1; } | |
943 | ; | |
944 | ||
945 | declspecs_nosc_ts_sa_noea: | |
946 | declspecs_nosc_ts_sa_noea TYPE_QUAL | |
947 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
948 | TREE_STATIC ($$) = 1; } | |
949 | | declspecs_nosc_ts_sa_ea TYPE_QUAL | |
950 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
951 | TREE_STATIC ($$) = 1; } | |
952 | | declspecs_nosc_ts_sa_noea typespec_reserved_nonattr | |
953 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
954 | TREE_STATIC ($$) = 1; } | |
955 | | declspecs_nosc_ts_sa_ea typespec_reserved_nonattr | |
956 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
957 | TREE_STATIC ($$) = 1; } | |
958 | | declspecs_nosc_nots_sa_noea typespec_nonattr | |
959 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
960 | TREE_STATIC ($$) = 1; } | |
961 | | declspecs_nosc_nots_sa_ea typespec_nonattr | |
962 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
963 | TREE_STATIC ($$) = 1; } | |
964 | ; | |
965 | ||
966 | declspecs_nosc_ts_sa_ea: | |
967 | declspecs_nosc_ts_sa_noea attributes | |
968 | { $$ = tree_cons ($2, NULL_TREE, $1); | |
969 | TREE_STATIC ($$) = TREE_STATIC ($1); } | |
970 | | declspecs_nosc_ts_sa_noea typespec_reserved_attr | |
971 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
972 | TREE_STATIC ($$) = 1; } | |
973 | | declspecs_nosc_ts_sa_ea typespec_reserved_attr | |
974 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
975 | TREE_STATIC ($$) = 1; } | |
976 | | declspecs_nosc_nots_sa_noea typespec_attr | |
977 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
978 | TREE_STATIC ($$) = 1; } | |
979 | | declspecs_nosc_nots_sa_ea typespec_attr | |
980 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
981 | TREE_STATIC ($$) = 1; } | |
982 | ; | |
983 | ||
984 | declspecs_sc_nots_nosa_noea: | |
f79f2651 | 985 | scspec |
25d78ace JM |
986 | { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); |
987 | TREE_STATIC ($$) = 0; } | |
988 | | declspecs_sc_nots_nosa_noea TYPE_QUAL | |
989 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
990 | TREE_STATIC ($$) = 1; } | |
991 | | declspecs_sc_nots_nosa_ea TYPE_QUAL | |
992 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
993 | TREE_STATIC ($$) = 1; } | |
f79f2651 | 994 | | declspecs_nosc_nots_nosa_noea scspec |
25d78ace | 995 | { if (extra_warnings && TREE_STATIC ($1)) |
028299c6 RS |
996 | warning ("`%s' is not at beginning of declaration", |
997 | IDENTIFIER_POINTER ($2)); | |
25d78ace JM |
998 | $$ = tree_cons (NULL_TREE, $2, $1); |
999 | TREE_STATIC ($$) = TREE_STATIC ($1); } | |
f79f2651 | 1000 | | declspecs_nosc_nots_nosa_ea scspec |
25d78ace JM |
1001 | { if (extra_warnings && TREE_STATIC ($1)) |
1002 | warning ("`%s' is not at beginning of declaration", | |
1003 | IDENTIFIER_POINTER ($2)); | |
1004 | $$ = tree_cons (NULL_TREE, $2, $1); | |
1005 | TREE_STATIC ($$) = TREE_STATIC ($1); } | |
f79f2651 | 1006 | | declspecs_sc_nots_nosa_noea scspec |
25d78ace JM |
1007 | { if (extra_warnings && TREE_STATIC ($1)) |
1008 | warning ("`%s' is not at beginning of declaration", | |
1009 | IDENTIFIER_POINTER ($2)); | |
1010 | $$ = tree_cons (NULL_TREE, $2, $1); | |
1011 | TREE_STATIC ($$) = TREE_STATIC ($1); } | |
f79f2651 | 1012 | | declspecs_sc_nots_nosa_ea scspec |
25d78ace JM |
1013 | { if (extra_warnings && TREE_STATIC ($1)) |
1014 | warning ("`%s' is not at beginning of declaration", | |
1015 | IDENTIFIER_POINTER ($2)); | |
1016 | $$ = tree_cons (NULL_TREE, $2, $1); | |
1017 | TREE_STATIC ($$) = TREE_STATIC ($1); } | |
084c4c25 RK |
1018 | ; |
1019 | ||
25d78ace JM |
1020 | declspecs_sc_nots_nosa_ea: |
1021 | declspecs_sc_nots_nosa_noea attributes | |
1022 | { $$ = tree_cons ($2, NULL_TREE, $1); | |
1023 | TREE_STATIC ($$) = TREE_STATIC ($1); } | |
084c4c25 RK |
1024 | ; |
1025 | ||
25d78ace JM |
1026 | declspecs_sc_nots_sa_noea: |
1027 | declspecs_sc_nots_sa_noea TYPE_QUAL | |
1028 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
1029 | TREE_STATIC ($$) = 1; } | |
1030 | | declspecs_sc_nots_sa_ea TYPE_QUAL | |
1031 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
1032 | TREE_STATIC ($$) = 1; } | |
f79f2651 | 1033 | | declspecs_nosc_nots_sa_noea scspec |
25d78ace JM |
1034 | { if (extra_warnings && TREE_STATIC ($1)) |
1035 | warning ("`%s' is not at beginning of declaration", | |
1036 | IDENTIFIER_POINTER ($2)); | |
1037 | $$ = tree_cons (NULL_TREE, $2, $1); | |
1038 | TREE_STATIC ($$) = TREE_STATIC ($1); } | |
f79f2651 | 1039 | | declspecs_nosc_nots_sa_ea scspec |
25d78ace JM |
1040 | { if (extra_warnings && TREE_STATIC ($1)) |
1041 | warning ("`%s' is not at beginning of declaration", | |
1042 | IDENTIFIER_POINTER ($2)); | |
1043 | $$ = tree_cons (NULL_TREE, $2, $1); | |
1044 | TREE_STATIC ($$) = TREE_STATIC ($1); } | |
f79f2651 | 1045 | | declspecs_sc_nots_sa_noea scspec |
25d78ace JM |
1046 | { if (extra_warnings && TREE_STATIC ($1)) |
1047 | warning ("`%s' is not at beginning of declaration", | |
1048 | IDENTIFIER_POINTER ($2)); | |
1049 | $$ = tree_cons (NULL_TREE, $2, $1); | |
1050 | TREE_STATIC ($$) = TREE_STATIC ($1); } | |
f79f2651 | 1051 | | declspecs_sc_nots_sa_ea scspec |
25d78ace | 1052 | { if (extra_warnings && TREE_STATIC ($1)) |
084c4c25 RK |
1053 | warning ("`%s' is not at beginning of declaration", |
1054 | IDENTIFIER_POINTER ($2)); | |
25d78ace JM |
1055 | $$ = tree_cons (NULL_TREE, $2, $1); |
1056 | TREE_STATIC ($$) = TREE_STATIC ($1); } | |
028299c6 RS |
1057 | ; |
1058 | ||
25d78ace JM |
1059 | declspecs_sc_nots_sa_ea: |
1060 | declspecs_sc_nots_sa_noea attributes | |
1061 | { $$ = tree_cons ($2, NULL_TREE, $1); | |
1062 | TREE_STATIC ($$) = TREE_STATIC ($1); } | |
084c4c25 RK |
1063 | ; |
1064 | ||
25d78ace JM |
1065 | declspecs_sc_ts_nosa_noea: |
1066 | declspecs_sc_ts_nosa_noea TYPE_QUAL | |
1067 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
028299c6 | 1068 | TREE_STATIC ($$) = 1; } |
25d78ace JM |
1069 | | declspecs_sc_ts_nosa_ea TYPE_QUAL |
1070 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
1071 | TREE_STATIC ($$) = 1; } | |
1072 | | declspecs_sc_ts_nosa_noea typespec_reserved_nonattr | |
1073 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
1074 | TREE_STATIC ($$) = 1; } | |
1075 | | declspecs_sc_ts_nosa_ea typespec_reserved_nonattr | |
1076 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
1077 | TREE_STATIC ($$) = 1; } | |
1078 | | declspecs_sc_nots_nosa_noea typespec_nonattr | |
028299c6 RS |
1079 | { $$ = tree_cons (NULL_TREE, $2, $1); |
1080 | TREE_STATIC ($$) = 1; } | |
25d78ace JM |
1081 | | declspecs_sc_nots_nosa_ea typespec_nonattr |
1082 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
1083 | TREE_STATIC ($$) = 1; } | |
f79f2651 | 1084 | | declspecs_nosc_ts_nosa_noea scspec |
25d78ace JM |
1085 | { if (extra_warnings && TREE_STATIC ($1)) |
1086 | warning ("`%s' is not at beginning of declaration", | |
1087 | IDENTIFIER_POINTER ($2)); | |
1088 | $$ = tree_cons (NULL_TREE, $2, $1); | |
1089 | TREE_STATIC ($$) = TREE_STATIC ($1); } | |
f79f2651 | 1090 | | declspecs_nosc_ts_nosa_ea scspec |
25d78ace JM |
1091 | { if (extra_warnings && TREE_STATIC ($1)) |
1092 | warning ("`%s' is not at beginning of declaration", | |
1093 | IDENTIFIER_POINTER ($2)); | |
1094 | $$ = tree_cons (NULL_TREE, $2, $1); | |
1095 | TREE_STATIC ($$) = TREE_STATIC ($1); } | |
f79f2651 | 1096 | | declspecs_sc_ts_nosa_noea scspec |
25d78ace JM |
1097 | { if (extra_warnings && TREE_STATIC ($1)) |
1098 | warning ("`%s' is not at beginning of declaration", | |
1099 | IDENTIFIER_POINTER ($2)); | |
1100 | $$ = tree_cons (NULL_TREE, $2, $1); | |
1101 | TREE_STATIC ($$) = TREE_STATIC ($1); } | |
f79f2651 | 1102 | | declspecs_sc_ts_nosa_ea scspec |
028299c6 RS |
1103 | { if (extra_warnings && TREE_STATIC ($1)) |
1104 | warning ("`%s' is not at beginning of declaration", | |
1105 | IDENTIFIER_POINTER ($2)); | |
1106 | $$ = tree_cons (NULL_TREE, $2, $1); | |
1107 | TREE_STATIC ($$) = TREE_STATIC ($1); } | |
1108 | ; | |
1109 | ||
25d78ace JM |
1110 | declspecs_sc_ts_nosa_ea: |
1111 | declspecs_sc_ts_nosa_noea attributes | |
1112 | { $$ = tree_cons ($2, NULL_TREE, $1); | |
1113 | TREE_STATIC ($$) = TREE_STATIC ($1); } | |
1114 | | declspecs_sc_ts_nosa_noea typespec_reserved_attr | |
1115 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
1116 | TREE_STATIC ($$) = 1; } | |
1117 | | declspecs_sc_ts_nosa_ea typespec_reserved_attr | |
1118 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
1119 | TREE_STATIC ($$) = 1; } | |
1120 | | declspecs_sc_nots_nosa_noea typespec_attr | |
1121 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
1122 | TREE_STATIC ($$) = 1; } | |
1123 | | declspecs_sc_nots_nosa_ea typespec_attr | |
1124 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
1125 | TREE_STATIC ($$) = 1; } | |
1126 | ; | |
028299c6 | 1127 | |
25d78ace JM |
1128 | declspecs_sc_ts_sa_noea: |
1129 | declspecs_sc_ts_sa_noea TYPE_QUAL | |
1130 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
1131 | TREE_STATIC ($$) = 1; } | |
1132 | | declspecs_sc_ts_sa_ea TYPE_QUAL | |
1133 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
1134 | TREE_STATIC ($$) = 1; } | |
1135 | | declspecs_sc_ts_sa_noea typespec_reserved_nonattr | |
1136 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
1137 | TREE_STATIC ($$) = 1; } | |
1138 | | declspecs_sc_ts_sa_ea typespec_reserved_nonattr | |
1139 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
1140 | TREE_STATIC ($$) = 1; } | |
1141 | | declspecs_sc_nots_sa_noea typespec_nonattr | |
1142 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
1143 | TREE_STATIC ($$) = 1; } | |
1144 | | declspecs_sc_nots_sa_ea typespec_nonattr | |
1145 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
1146 | TREE_STATIC ($$) = 1; } | |
f79f2651 | 1147 | | declspecs_nosc_ts_sa_noea scspec |
25d78ace JM |
1148 | { if (extra_warnings && TREE_STATIC ($1)) |
1149 | warning ("`%s' is not at beginning of declaration", | |
1150 | IDENTIFIER_POINTER ($2)); | |
1151 | $$ = tree_cons (NULL_TREE, $2, $1); | |
1152 | TREE_STATIC ($$) = TREE_STATIC ($1); } | |
f79f2651 | 1153 | | declspecs_nosc_ts_sa_ea scspec |
25d78ace JM |
1154 | { if (extra_warnings && TREE_STATIC ($1)) |
1155 | warning ("`%s' is not at beginning of declaration", | |
1156 | IDENTIFIER_POINTER ($2)); | |
1157 | $$ = tree_cons (NULL_TREE, $2, $1); | |
1158 | TREE_STATIC ($$) = TREE_STATIC ($1); } | |
f79f2651 | 1159 | | declspecs_sc_ts_sa_noea scspec |
25d78ace JM |
1160 | { if (extra_warnings && TREE_STATIC ($1)) |
1161 | warning ("`%s' is not at beginning of declaration", | |
1162 | IDENTIFIER_POINTER ($2)); | |
1163 | $$ = tree_cons (NULL_TREE, $2, $1); | |
1164 | TREE_STATIC ($$) = TREE_STATIC ($1); } | |
f79f2651 | 1165 | | declspecs_sc_ts_sa_ea scspec |
25d78ace JM |
1166 | { if (extra_warnings && TREE_STATIC ($1)) |
1167 | warning ("`%s' is not at beginning of declaration", | |
1168 | IDENTIFIER_POINTER ($2)); | |
1169 | $$ = tree_cons (NULL_TREE, $2, $1); | |
1170 | TREE_STATIC ($$) = TREE_STATIC ($1); } | |
1171 | ; | |
028299c6 | 1172 | |
25d78ace JM |
1173 | declspecs_sc_ts_sa_ea: |
1174 | declspecs_sc_ts_sa_noea attributes | |
1175 | { $$ = tree_cons ($2, NULL_TREE, $1); | |
1176 | TREE_STATIC ($$) = TREE_STATIC ($1); } | |
1177 | | declspecs_sc_ts_sa_noea typespec_reserved_attr | |
1178 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
1179 | TREE_STATIC ($$) = 1; } | |
1180 | | declspecs_sc_ts_sa_ea typespec_reserved_attr | |
1181 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
1182 | TREE_STATIC ($$) = 1; } | |
1183 | | declspecs_sc_nots_sa_noea typespec_attr | |
1184 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
1185 | TREE_STATIC ($$) = 1; } | |
1186 | | declspecs_sc_nots_sa_ea typespec_attr | |
1187 | { $$ = tree_cons (NULL_TREE, $2, $1); | |
1188 | TREE_STATIC ($$) = 1; } | |
028299c6 RS |
1189 | ; |
1190 | ||
25d78ace JM |
1191 | /* Particular useful classes of declspecs. */ |
1192 | declspecs_ts: | |
1193 | declspecs_nosc_ts_nosa_noea | |
1194 | | declspecs_nosc_ts_nosa_ea | |
1195 | | declspecs_nosc_ts_sa_noea | |
1196 | | declspecs_nosc_ts_sa_ea | |
1197 | | declspecs_sc_ts_nosa_noea | |
1198 | | declspecs_sc_ts_nosa_ea | |
1199 | | declspecs_sc_ts_sa_noea | |
1200 | | declspecs_sc_ts_sa_ea | |
1201 | ; | |
1202 | ||
1203 | declspecs_nots: | |
1204 | declspecs_nosc_nots_nosa_noea | |
1205 | | declspecs_nosc_nots_nosa_ea | |
1206 | | declspecs_nosc_nots_sa_noea | |
1207 | | declspecs_nosc_nots_sa_ea | |
1208 | | declspecs_sc_nots_nosa_noea | |
1209 | | declspecs_sc_nots_nosa_ea | |
1210 | | declspecs_sc_nots_sa_noea | |
1211 | | declspecs_sc_nots_sa_ea | |
1212 | ; | |
1213 | ||
1214 | declspecs_ts_nosa: | |
1215 | declspecs_nosc_ts_nosa_noea | |
1216 | | declspecs_nosc_ts_nosa_ea | |
1217 | | declspecs_sc_ts_nosa_noea | |
1218 | | declspecs_sc_ts_nosa_ea | |
1219 | ; | |
1220 | ||
1221 | declspecs_nots_nosa: | |
1222 | declspecs_nosc_nots_nosa_noea | |
1223 | | declspecs_nosc_nots_nosa_ea | |
1224 | | declspecs_sc_nots_nosa_noea | |
1225 | | declspecs_sc_nots_nosa_ea | |
1226 | ; | |
1227 | ||
1228 | declspecs_nosc_ts: | |
1229 | declspecs_nosc_ts_nosa_noea | |
1230 | | declspecs_nosc_ts_nosa_ea | |
1231 | | declspecs_nosc_ts_sa_noea | |
1232 | | declspecs_nosc_ts_sa_ea | |
1233 | ; | |
1234 | ||
1235 | declspecs_nosc_nots: | |
1236 | declspecs_nosc_nots_nosa_noea | |
1237 | | declspecs_nosc_nots_nosa_ea | |
1238 | | declspecs_nosc_nots_sa_noea | |
1239 | | declspecs_nosc_nots_sa_ea | |
1240 | ; | |
1241 | ||
1242 | declspecs_nosc: | |
1243 | declspecs_nosc_ts_nosa_noea | |
1244 | | declspecs_nosc_ts_nosa_ea | |
1245 | | declspecs_nosc_ts_sa_noea | |
1246 | | declspecs_nosc_ts_sa_ea | |
1247 | | declspecs_nosc_nots_nosa_noea | |
1248 | | declspecs_nosc_nots_nosa_ea | |
1249 | | declspecs_nosc_nots_sa_noea | |
1250 | | declspecs_nosc_nots_sa_ea | |
1251 | ; | |
1252 | ||
1253 | declspecs: | |
1254 | declspecs_nosc_nots_nosa_noea | |
1255 | | declspecs_nosc_nots_nosa_ea | |
1256 | | declspecs_nosc_nots_sa_noea | |
1257 | | declspecs_nosc_nots_sa_ea | |
1258 | | declspecs_nosc_ts_nosa_noea | |
1259 | | declspecs_nosc_ts_nosa_ea | |
1260 | | declspecs_nosc_ts_sa_noea | |
1261 | | declspecs_nosc_ts_sa_ea | |
1262 | | declspecs_sc_nots_nosa_noea | |
1263 | | declspecs_sc_nots_nosa_ea | |
1264 | | declspecs_sc_nots_sa_noea | |
1265 | | declspecs_sc_nots_sa_ea | |
1266 | | declspecs_sc_ts_nosa_noea | |
1267 | | declspecs_sc_ts_nosa_ea | |
1268 | | declspecs_sc_ts_sa_noea | |
1269 | | declspecs_sc_ts_sa_ea | |
1270 | ; | |
1271 | ||
91d231cb JM |
1272 | /* A (possibly empty) sequence of type qualifiers and attributes. */ |
1273 | maybe_type_quals_attrs: | |
25d78ace | 1274 | /* empty */ |
028299c6 | 1275 | { $$ = NULL_TREE; } |
25d78ace | 1276 | | declspecs_nosc_nots |
91d231cb | 1277 | { $$ = $1; } |
028299c6 RS |
1278 | ; |
1279 | ||
25d78ace | 1280 | /* A type specifier (but not a type qualifier). |
028299c6 | 1281 | Once we have seen one of these in a declaration, |
25d78ace | 1282 | if a typedef name appears then it is being redeclared. |
028299c6 | 1283 | |
25d78ace JM |
1284 | The _reserved versions start with a reserved word and may appear anywhere |
1285 | in the declaration specifiers; the _nonreserved versions may only | |
1286 | appear before any other type specifiers, and after that are (if names) | |
1287 | being redeclared. | |
1288 | ||
1289 | FIXME: should the _nonreserved version be restricted to names being | |
1290 | redeclared only? The other entries there relate only the GNU extensions | |
1291 | and Objective C, and are historically parsed thus, and don't make sense | |
1292 | after other type specifiers, but it might be cleaner to count them as | |
1293 | _reserved. | |
1294 | ||
1295 | _attr means: specifiers that either end with attributes, | |
1296 | or are such that any following attributes would | |
1297 | be parsed as part of the specifier. | |
1298 | ||
1299 | _nonattr: specifiers. */ | |
1300 | ||
1301 | typespec_nonattr: | |
1302 | typespec_reserved_nonattr | |
1303 | | typespec_nonreserved_nonattr | |
1304 | ; | |
1305 | ||
1306 | typespec_attr: | |
1307 | typespec_reserved_attr | |
1308 | ; | |
1309 | ||
1310 | typespec_reserved_nonattr: | |
1311 | TYPESPEC | |
f2e6e530 | 1312 | { OBJC_NEED_RAW_IDENTIFIER (1); } |
25d78ace JM |
1313 | | structsp_nonattr |
1314 | ; | |
1315 | ||
1316 | typespec_reserved_attr: | |
1317 | structsp_attr | |
1318 | ; | |
1319 | ||
1320 | typespec_nonreserved_nonattr: | |
1321 | TYPENAME | |
028299c6 RS |
1322 | { /* For a typedef name, record the meaning, not the name. |
1323 | In case of `foo foo, bar;'. */ | |
1324 | $$ = lookup_name ($1); } | |
264fa2db | 1325 | @@ifobjc |
e31c7eec TW |
1326 | | CLASSNAME protocolrefs |
1327 | { $$ = get_static_reference ($1, $2); } | |
1328 | | OBJECTNAME protocolrefs | |
5c234cd7 | 1329 | { $$ = get_protocol_reference ($2); } |
957a1c32 RK |
1330 | |
1331 | /* Make "<SomeProtocol>" equivalent to "id <SomeProtocol>" | |
1332 | - nisse@lysator.liu.se */ | |
1333 | | non_empty_protocolrefs | |
5c234cd7 | 1334 | { $$ = get_protocol_reference ($1); } |
264fa2db | 1335 | @@end_ifobjc |
25587e40 | 1336 | | typeof '(' expr ')' |
65f0edec JM |
1337 | { skip_evaluation--; |
1338 | if (TREE_CODE ($3) == COMPONENT_REF | |
1339 | && DECL_C_BIT_FIELD (TREE_OPERAND ($3, 1))) | |
1340 | error ("`typeof' applied to a bit-field"); | |
1341 | $$ = TREE_TYPE ($3); } | |
25587e40 AO |
1342 | | typeof '(' typename ')' |
1343 | { skip_evaluation--; $$ = groktypename ($3); } | |
028299c6 RS |
1344 | ; |
1345 | ||
25d78ace | 1346 | /* typespec_nonreserved_attr does not exist. */ |
028299c6 RS |
1347 | |
1348 | initdecls: | |
1349 | initdcl | |
4b01f8d8 | 1350 | | initdecls ',' maybe_resetattrs initdcl |
028299c6 RS |
1351 | ; |
1352 | ||
1353 | notype_initdecls: | |
1354 | notype_initdcl | |
4b01f8d8 | 1355 | | notype_initdecls ',' maybe_resetattrs notype_initdcl |
028299c6 RS |
1356 | ; |
1357 | ||
028299c6 RS |
1358 | initdcl: |
1359 | declarator maybeasm maybe_attribute '=' | |
99ac47b5 | 1360 | { $<ttype>$ = start_decl ($1, current_declspecs, 1, |
4b01f8d8 | 1361 | chainon ($3, all_prefix_attributes)); |
6126f4db | 1362 | start_init ($<ttype>$, $2, global_bindings_p ()); } |
028299c6 RS |
1363 | init |
1364 | /* Note how the declaration of the variable is in effect while its init is parsed! */ | |
42e651a6 | 1365 | { finish_init (); |
6126f4db | 1366 | finish_decl ($<ttype>5, $6, $2); } |
028299c6 | 1367 | | declarator maybeasm maybe_attribute |
99ac47b5 | 1368 | { tree d = start_decl ($1, current_declspecs, 0, |
4b01f8d8 | 1369 | chainon ($3, all_prefix_attributes)); |
84d901be | 1370 | finish_decl (d, NULL_TREE, $2); |
34724814 | 1371 | } |
028299c6 RS |
1372 | ; |
1373 | ||
1374 | notype_initdcl: | |
1375 | notype_declarator maybeasm maybe_attribute '=' | |
99ac47b5 | 1376 | { $<ttype>$ = start_decl ($1, current_declspecs, 1, |
4b01f8d8 | 1377 | chainon ($3, all_prefix_attributes)); |
6126f4db | 1378 | start_init ($<ttype>$, $2, global_bindings_p ()); } |
028299c6 RS |
1379 | init |
1380 | /* Note how the declaration of the variable is in effect while its init is parsed! */ | |
42e651a6 | 1381 | { finish_init (); |
6126f4db | 1382 | finish_decl ($<ttype>5, $6, $2); } |
028299c6 | 1383 | | notype_declarator maybeasm maybe_attribute |
99ac47b5 | 1384 | { tree d = start_decl ($1, current_declspecs, 0, |
4b01f8d8 | 1385 | chainon ($3, all_prefix_attributes)); |
028299c6 RS |
1386 | finish_decl (d, NULL_TREE, $2); } |
1387 | ; | |
1388 | /* the * rules are dummies to accept the Apollo extended syntax | |
1389 | so that the header files compile. */ | |
1390 | maybe_attribute: | |
660b43c8 | 1391 | /* empty */ |
c14bc6db | 1392 | { $$ = NULL_TREE; } |
660b43c8 RK |
1393 | | attributes |
1394 | { $$ = $1; } | |
1395 | ; | |
84d901be | 1396 | |
660b43c8 RK |
1397 | attributes: |
1398 | attribute | |
1399 | { $$ = $1; } | |
1400 | | attributes attribute | |
1401 | { $$ = chainon ($1, $2); } | |
1402 | ; | |
1403 | ||
1404 | attribute: | |
21526606 EC |
1405 | ATTRIBUTE stop_string_translation |
1406 | '(' '(' attribute_list ')' ')' start_string_translation | |
1407 | { $$ = $5; } | |
1408 | | ATTRIBUTE error start_string_translation | |
1409 | {} | |
660b43c8 RK |
1410 | ; |
1411 | ||
1412 | attribute_list: | |
1413 | attrib | |
5d7a33dc | 1414 | { $$ = $1; } |
660b43c8 | 1415 | | attribute_list ',' attrib |
5d7a33dc | 1416 | { $$ = chainon ($1, $3); } |
660b43c8 | 1417 | ; |
84d901be | 1418 | |
660b43c8 | 1419 | attrib: |
028299c6 RS |
1420 | /* empty */ |
1421 | { $$ = NULL_TREE; } | |
660b43c8 | 1422 | | any_word |
5d7a33dc | 1423 | { $$ = build_tree_list ($1, NULL_TREE); } |
660b43c8 | 1424 | | any_word '(' IDENTIFIER ')' |
5d7a33dc | 1425 | { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); } |
660b43c8 | 1426 | | any_word '(' IDENTIFIER ',' nonnull_exprlist ')' |
5d7a33dc | 1427 | { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); } |
f365e8f6 | 1428 | | any_word '(' exprlist ')' |
5d7a33dc | 1429 | { $$ = build_tree_list ($1, $3); } |
660b43c8 RK |
1430 | ; |
1431 | ||
1432 | /* This still leaves out most reserved keywords, | |
1433 | shouldn't we include them? */ | |
1434 | ||
1435 | any_word: | |
1436 | identifier | |
f79f2651 | 1437 | | scspec |
660b43c8 RK |
1438 | | TYPESPEC |
1439 | | TYPE_QUAL | |
1440 | ; | |
f79f2651 NB |
1441 | |
1442 | scspec: | |
1443 | STATIC | |
1444 | | SCSPEC | |
1445 | ; | |
42e651a6 RS |
1446 | \f |
1447 | /* Initializers. `init' is the entry point. */ | |
028299c6 RS |
1448 | |
1449 | init: | |
1450 | expr_no_commas | |
42e651a6 | 1451 | | '{' |
4dd7201e | 1452 | { really_start_incremental_init (NULL_TREE); } |
42e651a6 | 1453 | initlist_maybe_comma '}' |
4dd7201e | 1454 | { $$ = pop_init_level (0); } |
028299c6 | 1455 | | error |
e1eb754f | 1456 | { $$ = error_mark_node; } |
028299c6 RS |
1457 | ; |
1458 | ||
42e651a6 RS |
1459 | /* `initlist_maybe_comma' is the guts of an initializer in braces. */ |
1460 | initlist_maybe_comma: | |
1461 | /* empty */ | |
1462 | { if (pedantic) | |
89abf8d1 | 1463 | pedwarn ("ISO C forbids empty initializer braces"); } |
42e651a6 RS |
1464 | | initlist1 maybecomma |
1465 | ; | |
1466 | ||
1467 | initlist1: | |
1468 | initelt | |
1469 | | initlist1 ',' initelt | |
1470 | ; | |
1471 | ||
1472 | /* `initelt' is a single element of an initializer. | |
1473 | It may use braces. */ | |
1474 | initelt: | |
6f4d7222 | 1475 | designator_list '=' initval |
26d4fec7 | 1476 | { if (pedantic && ! flag_isoc99) |
b46b8fb4 | 1477 | pedwarn ("ISO C90 forbids specifying subobject to initialize"); } |
6f4d7222 | 1478 | | designator initval |
26d4fec7 JM |
1479 | { if (pedantic) |
1480 | pedwarn ("obsolete use of designated initializer without `='"); } | |
6f4d7222 | 1481 | | identifier ':' |
26d4fec7 JM |
1482 | { set_init_label ($1); |
1483 | if (pedantic) | |
1484 | pedwarn ("obsolete use of designated initializer with `:'"); } | |
6f4d7222 | 1485 | initval |
84d901be | 1486 | {} |
6f4d7222 UD |
1487 | | initval |
1488 | ; | |
1489 | ||
1490 | initval: | |
1491 | '{' | |
42e651a6 RS |
1492 | { push_init_level (0); } |
1493 | initlist_maybe_comma '}' | |
1494 | { process_init_element (pop_init_level (0)); } | |
6f4d7222 UD |
1495 | | expr_no_commas |
1496 | { process_init_element ($1); } | |
42e651a6 | 1497 | | error |
6f4d7222 UD |
1498 | ; |
1499 | ||
1500 | designator_list: | |
1501 | designator | |
1502 | | designator_list designator | |
1503 | ; | |
1504 | ||
1505 | designator: | |
1506 | '.' identifier | |
1507 | { set_init_label ($2); } | |
6f4d7222 | 1508 | | '[' expr_no_commas ELLIPSIS expr_no_commas ']' |
26d4fec7 JM |
1509 | { set_init_index ($2, $4); |
1510 | if (pedantic) | |
1511 | pedwarn ("ISO C forbids specifying range of elements to initialize"); } | |
a78bdb8e RK |
1512 | | '[' expr_no_commas ']' |
1513 | { set_init_index ($2, NULL_TREE); } | |
028299c6 | 1514 | ; |
42e651a6 | 1515 | \f |
028299c6 | 1516 | nested_function: |
093c7153 | 1517 | declarator |
e2ecd91c | 1518 | { if (pedantic) |
89abf8d1 | 1519 | pedwarn ("ISO C forbids nested functions"); |
e2ecd91c BS |
1520 | |
1521 | push_function_context (); | |
ee7d912e | 1522 | if (! start_function (current_declspecs, $1, |
4b01f8d8 | 1523 | all_prefix_attributes)) |
028299c6 | 1524 | { |
e2ecd91c | 1525 | pop_function_context (); |
028299c6 RS |
1526 | YYERROR1; |
1527 | } | |
0e5921e8 | 1528 | } |
093c7153 | 1529 | old_style_parm_decls save_location |
b190f239 | 1530 | { tree decl = current_function_decl; |
f31686a3 | 1531 | DECL_SOURCE_LOCATION (decl) = $4; |
b190f239 | 1532 | store_parm_decls (); } |
093c7153 RH |
1533 | /* This used to use compstmt_or_error. That caused a bug with |
1534 | input `f(g) int g {}', where the use of YYERROR1 above caused | |
1535 | an error which then was handled by compstmt_or_error. There | |
1536 | followed a repeated execution of that same rule, which called | |
1537 | YYERROR1 again, and so on. */ | |
1538 | compstmt | |
8f17b5c5 | 1539 | { tree decl = current_function_decl; |
093c7153 | 1540 | add_stmt ($6); |
4a46cbfb | 1541 | finish_function (); |
84d901be | 1542 | pop_function_context (); |
543a0daa | 1543 | add_stmt (build_stmt (DECL_STMT, decl)); } |
028299c6 RS |
1544 | ; |
1545 | ||
1546 | notype_nested_function: | |
093c7153 | 1547 | notype_declarator |
e2ecd91c | 1548 | { if (pedantic) |
89abf8d1 | 1549 | pedwarn ("ISO C forbids nested functions"); |
e2ecd91c BS |
1550 | |
1551 | push_function_context (); | |
ee7d912e | 1552 | if (! start_function (current_declspecs, $1, |
4b01f8d8 | 1553 | all_prefix_attributes)) |
028299c6 | 1554 | { |
e2ecd91c | 1555 | pop_function_context (); |
028299c6 RS |
1556 | YYERROR1; |
1557 | } | |
0e5921e8 | 1558 | } |
093c7153 | 1559 | old_style_parm_decls save_location |
b190f239 | 1560 | { tree decl = current_function_decl; |
f31686a3 | 1561 | DECL_SOURCE_LOCATION (decl) = $4; |
b190f239 | 1562 | store_parm_decls (); } |
093c7153 RH |
1563 | /* This used to use compstmt_or_error. That caused a bug with |
1564 | input `f(g) int g {}', where the use of YYERROR1 above caused | |
1565 | an error which then was handled by compstmt_or_error. There | |
1566 | followed a repeated execution of that same rule, which called | |
1567 | YYERROR1 again, and so on. */ | |
1568 | compstmt | |
8f17b5c5 | 1569 | { tree decl = current_function_decl; |
093c7153 | 1570 | add_stmt ($6); |
4a46cbfb | 1571 | finish_function (); |
84d901be | 1572 | pop_function_context (); |
543a0daa | 1573 | add_stmt (build_stmt (DECL_STMT, decl)); } |
028299c6 RS |
1574 | ; |
1575 | ||
1576 | /* Any kind of declarator (thus, all declarators allowed | |
1577 | after an explicit typespec). */ | |
1578 | ||
1579 | declarator: | |
1580 | after_type_declarator | |
1581 | | notype_declarator | |
1582 | ; | |
1583 | ||
1584 | /* A declarator that is allowed only after an explicit typespec. */ | |
1585 | ||
1586 | after_type_declarator: | |
91d231cb JM |
1587 | '(' maybe_attribute after_type_declarator ')' |
1588 | { $$ = $2 ? tree_cons ($2, $3, NULL_TREE) : $3; } | |
028299c6 RS |
1589 | | after_type_declarator '(' parmlist_or_identifiers %prec '.' |
1590 | { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); } | |
0e03329a JM |
1591 | | after_type_declarator array_declarator %prec '.' |
1592 | { $$ = set_array_declarator_type ($2, $1, 0); } | |
91d231cb | 1593 | | '*' maybe_type_quals_attrs after_type_declarator %prec UNARY |
028299c6 RS |
1594 | { $$ = make_pointer_declarator ($2, $3); } |
1595 | | TYPENAME | |
264fa2db | 1596 | @@ifobjc |
e31c7eec | 1597 | | OBJECTNAME |
264fa2db | 1598 | @@end_ifobjc |
028299c6 RS |
1599 | ; |
1600 | ||
1601 | /* Kinds of declarator that can appear in a parameter list | |
1602 | in addition to notype_declarator. This is like after_type_declarator | |
1603 | but does not allow a typedef name in parentheses as an identifier | |
1604 | (because it would conflict with a function with that typedef as arg). */ | |
028299c6 | 1605 | parm_declarator: |
97d24516 JM |
1606 | parm_declarator_starttypename |
1607 | | parm_declarator_nostarttypename | |
1608 | ; | |
1609 | ||
1610 | parm_declarator_starttypename: | |
1611 | parm_declarator_starttypename '(' parmlist_or_identifiers %prec '.' | |
028299c6 | 1612 | { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); } |
0e03329a JM |
1613 | | parm_declarator_starttypename array_declarator %prec '.' |
1614 | { $$ = set_array_declarator_type ($2, $1, 0); } | |
028299c6 | 1615 | | TYPENAME |
264fa2db | 1616 | @@ifobjc |
f2e6e530 | 1617 | | OBJECTNAME |
264fa2db | 1618 | @@end_ifobjc |
028299c6 RS |
1619 | ; |
1620 | ||
97d24516 JM |
1621 | parm_declarator_nostarttypename: |
1622 | parm_declarator_nostarttypename '(' parmlist_or_identifiers %prec '.' | |
1623 | { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); } | |
0e03329a JM |
1624 | | parm_declarator_nostarttypename array_declarator %prec '.' |
1625 | { $$ = set_array_declarator_type ($2, $1, 0); } | |
91d231cb | 1626 | | '*' maybe_type_quals_attrs parm_declarator_starttypename %prec UNARY |
97d24516 | 1627 | { $$ = make_pointer_declarator ($2, $3); } |
91d231cb | 1628 | | '*' maybe_type_quals_attrs parm_declarator_nostarttypename %prec UNARY |
97d24516 | 1629 | { $$ = make_pointer_declarator ($2, $3); } |
91d231cb JM |
1630 | | '(' maybe_attribute parm_declarator_nostarttypename ')' |
1631 | { $$ = $2 ? tree_cons ($2, $3, NULL_TREE) : $3; } | |
97d24516 JM |
1632 | ; |
1633 | ||
028299c6 RS |
1634 | /* A declarator allowed whether or not there has been |
1635 | an explicit typespec. These cannot redeclare a typedef-name. */ | |
1636 | ||
1637 | notype_declarator: | |
1638 | notype_declarator '(' parmlist_or_identifiers %prec '.' | |
1639 | { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); } | |
91d231cb JM |
1640 | | '(' maybe_attribute notype_declarator ')' |
1641 | { $$ = $2 ? tree_cons ($2, $3, NULL_TREE) : $3; } | |
1642 | | '*' maybe_type_quals_attrs notype_declarator %prec UNARY | |
028299c6 | 1643 | { $$ = make_pointer_declarator ($2, $3); } |
0e03329a JM |
1644 | | notype_declarator array_declarator %prec '.' |
1645 | { $$ = set_array_declarator_type ($2, $1, 0); } | |
028299c6 RS |
1646 | | IDENTIFIER |
1647 | ; | |
1648 | ||
4051959b JM |
1649 | struct_head: |
1650 | STRUCT | |
1651 | { $$ = NULL_TREE; } | |
1652 | | STRUCT attributes | |
1653 | { $$ = $2; } | |
1654 | ; | |
1655 | ||
1656 | union_head: | |
1657 | UNION | |
1658 | { $$ = NULL_TREE; } | |
1659 | | UNION attributes | |
1660 | { $$ = $2; } | |
1661 | ; | |
1662 | ||
1663 | enum_head: | |
1664 | ENUM | |
1665 | { $$ = NULL_TREE; } | |
1666 | | ENUM attributes | |
1667 | { $$ = $2; } | |
1668 | ; | |
1669 | ||
25d78ace JM |
1670 | /* structsp_attr: struct/union/enum specifiers that either |
1671 | end with attributes, or are such that any following attributes would | |
1672 | be parsed as part of the struct/union/enum specifier. | |
1673 | ||
1674 | structsp_nonattr: other struct/union/enum specifiers. */ | |
1675 | ||
1676 | structsp_attr: | |
4051959b | 1677 | struct_head identifier '{' |
028299c6 RS |
1678 | { $$ = start_struct (RECORD_TYPE, $2); |
1679 | /* Start scope of tag before parsing components. */ | |
1680 | } | |
84d901be | 1681 | component_decl_list '}' maybe_attribute |
66ea6f4c RH |
1682 | { $$ = finish_struct ($<ttype>4, nreverse ($5), |
1683 | chainon ($1, $7)); } | |
4051959b | 1684 | | struct_head '{' component_decl_list '}' maybe_attribute |
028299c6 | 1685 | { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE), |
66ea6f4c | 1686 | nreverse ($3), chainon ($1, $5)); |
5d7a33dc | 1687 | } |
4051959b | 1688 | | union_head identifier '{' |
028299c6 | 1689 | { $$ = start_struct (UNION_TYPE, $2); } |
5d7a33dc | 1690 | component_decl_list '}' maybe_attribute |
66ea6f4c RH |
1691 | { $$ = finish_struct ($<ttype>4, nreverse ($5), |
1692 | chainon ($1, $7)); } | |
4051959b | 1693 | | union_head '{' component_decl_list '}' maybe_attribute |
028299c6 | 1694 | { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE), |
66ea6f4c | 1695 | nreverse ($3), chainon ($1, $5)); |
af6f30c4 | 1696 | } |
4051959b | 1697 | | enum_head identifier '{' |
4dd7201e | 1698 | { $$ = start_enum ($2); } |
41ddaaa4 | 1699 | enumlist maybecomma_warn '}' maybe_attribute |
4dd7201e ZW |
1700 | { $$ = finish_enum ($<ttype>4, nreverse ($5), |
1701 | chainon ($1, $8)); } | |
4051959b | 1702 | | enum_head '{' |
4dd7201e | 1703 | { $$ = start_enum (NULL_TREE); } |
41ddaaa4 | 1704 | enumlist maybecomma_warn '}' maybe_attribute |
4dd7201e ZW |
1705 | { $$ = finish_enum ($<ttype>3, nreverse ($4), |
1706 | chainon ($1, $7)); } | |
25d78ace JM |
1707 | ; |
1708 | ||
1709 | structsp_nonattr: | |
1710 | struct_head identifier | |
1711 | { $$ = xref_tag (RECORD_TYPE, $2); } | |
1712 | | union_head identifier | |
1713 | { $$ = xref_tag (UNION_TYPE, $2); } | |
4051959b | 1714 | | enum_head identifier |
0aca1a4f JM |
1715 | { $$ = xref_tag (ENUMERAL_TYPE, $2); |
1716 | /* In ISO C, enumerated types can be referred to | |
1717 | only if already defined. */ | |
1718 | if (pedantic && !COMPLETE_TYPE_P ($$)) | |
1719 | pedwarn ("ISO C forbids forward references to `enum' types"); } | |
028299c6 RS |
1720 | ; |
1721 | ||
1722 | maybecomma: | |
1723 | /* empty */ | |
1724 | | ',' | |
1725 | ; | |
1726 | ||
1727 | maybecomma_warn: | |
1728 | /* empty */ | |
1729 | | ',' | |
b919445a | 1730 | { if (pedantic && ! flag_isoc99) |
6f4d7222 | 1731 | pedwarn ("comma at end of enumerator list"); } |
028299c6 RS |
1732 | ; |
1733 | ||
66ea6f4c RH |
1734 | /* We chain the components in reverse order. They are put in forward |
1735 | order in structsp_attr. | |
1736 | ||
1737 | Note that component_declarator returns single decls, so components | |
1738 | and components_notype can use TREE_CHAIN directly, wheras components | |
1739 | and components_notype return lists (of comma separated decls), so | |
1740 | component_decl_list and component_decl_list2 must use chainon. | |
1741 | ||
1742 | The theory behind all this is that there will be more semicolon | |
1743 | separated fields than comma separated fields, and so we'll be | |
1744 | minimizing the number of node traversals required by chainon. */ | |
1745 | ||
028299c6 RS |
1746 | component_decl_list: |
1747 | component_decl_list2 | |
1748 | { $$ = $1; } | |
1749 | | component_decl_list2 component_decl | |
66ea6f4c | 1750 | { $$ = chainon ($2, $1); |
ee759b21 | 1751 | pedwarn ("no semicolon at end of struct or union"); } |
028299c6 RS |
1752 | ; |
1753 | ||
1754 | component_decl_list2: /* empty */ | |
1755 | { $$ = NULL_TREE; } | |
1756 | | component_decl_list2 component_decl ';' | |
66ea6f4c | 1757 | { $$ = chainon ($2, $1); } |
028299c6 RS |
1758 | | component_decl_list2 ';' |
1759 | { if (pedantic) | |
1760 | pedwarn ("extra semicolon in struct or union specified"); } | |
264fa2db | 1761 | @@ifobjc |
028299c6 | 1762 | /* foo(sizeof(struct{ @defs(ClassName)})); */ |
f2b5cf97 | 1763 | | AT_DEFS '(' CLASSNAME ')' |
264fa2db ZL |
1764 | { $$ = nreverse (get_class_ivars_from_name ($3)); } |
1765 | @@end_ifobjc | |
028299c6 RS |
1766 | ; |
1767 | ||
028299c6 | 1768 | component_decl: |
25d78ace | 1769 | declspecs_nosc_ts setspecs components |
028299c6 | 1770 | { $$ = $3; |
4b01f8d8 | 1771 | POP_DECLSPEC_STACK; } |
bc4721b8 | 1772 | | declspecs_nosc_ts setspecs |
ffc3b0f9 | 1773 | { |
84d901be AD |
1774 | /* Support for unnamed structs or unions as members of |
1775 | structs or unions (which is [a] useful and [b] supports | |
ffc3b0f9 AH |
1776 | MS P-SDK). */ |
1777 | if (pedantic) | |
89abf8d1 | 1778 | pedwarn ("ISO C doesn't support unnamed structs/unions"); |
ffc3b0f9 | 1779 | |
bc4721b8 | 1780 | $$ = grokfield(NULL, current_declspecs, NULL_TREE); |
4b01f8d8 | 1781 | POP_DECLSPEC_STACK; } |
25d78ace | 1782 | | declspecs_nosc_nots setspecs components_notype |
028299c6 | 1783 | { $$ = $3; |
4b01f8d8 | 1784 | POP_DECLSPEC_STACK; } |
25d78ace | 1785 | | declspecs_nosc_nots |
028299c6 | 1786 | { if (pedantic) |
89abf8d1 | 1787 | pedwarn ("ISO C forbids member declarations with no members"); |
eb1dfbb2 | 1788 | shadow_tag_warned ($1, pedantic); |
028299c6 RS |
1789 | $$ = NULL_TREE; } |
1790 | | error | |
1791 | { $$ = NULL_TREE; } | |
72acf258 JM |
1792 | | extension component_decl |
1793 | { $$ = $2; | |
750491fc | 1794 | RESTORE_EXT_FLAGS ($1); } |
028299c6 RS |
1795 | ; |
1796 | ||
1797 | components: | |
1798 | component_declarator | |
4b01f8d8 | 1799 | | components ',' maybe_resetattrs component_declarator |
66ea6f4c | 1800 | { TREE_CHAIN ($4) = $1; $$ = $4; } |
25d78ace JM |
1801 | ; |
1802 | ||
1803 | components_notype: | |
1804 | component_notype_declarator | |
4b01f8d8 | 1805 | | components_notype ',' maybe_resetattrs component_notype_declarator |
66ea6f4c | 1806 | { TREE_CHAIN ($4) = $1; $$ = $4; } |
028299c6 RS |
1807 | ; |
1808 | ||
1809 | component_declarator: | |
bc4721b8 NS |
1810 | declarator maybe_attribute |
1811 | { $$ = grokfield ($1, current_declspecs, NULL_TREE); | |
1812 | decl_attributes (&$$, | |
1813 | chainon ($2, all_prefix_attributes), 0); } | |
1814 | | declarator ':' expr_no_commas maybe_attribute | |
1815 | { $$ = grokfield ($1, current_declspecs, $3); | |
1816 | decl_attributes (&$$, | |
1817 | chainon ($4, all_prefix_attributes), 0); } | |
1818 | | ':' expr_no_commas maybe_attribute | |
1819 | { $$ = grokfield (NULL_TREE, current_declspecs, $2); | |
1820 | decl_attributes (&$$, | |
1821 | chainon ($3, all_prefix_attributes), 0); } | |
028299c6 RS |
1822 | ; |
1823 | ||
25d78ace | 1824 | component_notype_declarator: |
bc4721b8 NS |
1825 | notype_declarator maybe_attribute |
1826 | { $$ = grokfield ($1, current_declspecs, NULL_TREE); | |
1827 | decl_attributes (&$$, | |
1828 | chainon ($2, all_prefix_attributes), 0); } | |
1829 | | notype_declarator ':' expr_no_commas maybe_attribute | |
1830 | { $$ = grokfield ($1, current_declspecs, $3); | |
1831 | decl_attributes (&$$, | |
1832 | chainon ($4, all_prefix_attributes), 0); } | |
1833 | | ':' expr_no_commas maybe_attribute | |
1834 | { $$ = grokfield (NULL_TREE, current_declspecs, $2); | |
1835 | decl_attributes (&$$, | |
1836 | chainon ($3, all_prefix_attributes), 0); } | |
25d78ace JM |
1837 | ; |
1838 | ||
028299c6 | 1839 | /* We chain the enumerators in reverse order. |
66ea6f4c | 1840 | They are put in forward order in structsp_attr. */ |
028299c6 RS |
1841 | |
1842 | enumlist: | |
1843 | enumerator | |
1844 | | enumlist ',' enumerator | |
a0d074e1 RK |
1845 | { if ($1 == error_mark_node) |
1846 | $$ = $1; | |
1847 | else | |
66ea6f4c | 1848 | TREE_CHAIN ($3) = $1, $$ = $3; } |
adc3b521 RS |
1849 | | error |
1850 | { $$ = error_mark_node; } | |
028299c6 RS |
1851 | ; |
1852 | ||
1853 | ||
1854 | enumerator: | |
1855 | identifier | |
1856 | { $$ = build_enumerator ($1, NULL_TREE); } | |
1857 | | identifier '=' expr_no_commas | |
1858 | { $$ = build_enumerator ($1, $3); } | |
1859 | ; | |
1860 | ||
1861 | typename: | |
25d78ace | 1862 | declspecs_nosc |
d3b4cd6f AH |
1863 | { pending_xref_error (); |
1864 | $<ttype>$ = $1; } | |
0aca1a4f | 1865 | absdcl |
25d78ace | 1866 | { $$ = build_tree_list ($<ttype>2, $3); } |
028299c6 RS |
1867 | ; |
1868 | ||
1869 | absdcl: /* an absolute declarator */ | |
1870 | /* empty */ | |
1871 | { $$ = NULL_TREE; } | |
1872 | | absdcl1 | |
1873 | ; | |
1874 | ||
25d78ace JM |
1875 | absdcl_maybe_attribute: /* absdcl maybe_attribute, but not just attributes */ |
1876 | /* empty */ | |
1877 | { $$ = build_tree_list (build_tree_list (current_declspecs, | |
1878 | NULL_TREE), | |
4b01f8d8 | 1879 | all_prefix_attributes); } |
25d78ace JM |
1880 | | absdcl1 |
1881 | { $$ = build_tree_list (build_tree_list (current_declspecs, | |
1882 | $1), | |
4b01f8d8 | 1883 | all_prefix_attributes); } |
25d78ace JM |
1884 | | absdcl1_noea attributes |
1885 | { $$ = build_tree_list (build_tree_list (current_declspecs, | |
1886 | $1), | |
4b01f8d8 | 1887 | chainon ($2, all_prefix_attributes)); } |
028299c6 RS |
1888 | ; |
1889 | ||
25d78ace JM |
1890 | absdcl1: /* a nonempty absolute declarator */ |
1891 | absdcl1_ea | |
1892 | | absdcl1_noea | |
028299c6 RS |
1893 | ; |
1894 | ||
25d78ace JM |
1895 | absdcl1_noea: |
1896 | direct_absdcl1 | |
91d231cb | 1897 | | '*' maybe_type_quals_attrs absdcl1_noea |
028299c6 | 1898 | { $$ = make_pointer_declarator ($2, $3); } |
25d78ace JM |
1899 | ; |
1900 | ||
1901 | absdcl1_ea: | |
91d231cb | 1902 | '*' maybe_type_quals_attrs |
028299c6 | 1903 | { $$ = make_pointer_declarator ($2, NULL_TREE); } |
91d231cb | 1904 | | '*' maybe_type_quals_attrs absdcl1_ea |
25d78ace JM |
1905 | { $$ = make_pointer_declarator ($2, $3); } |
1906 | ; | |
1907 | ||
1908 | direct_absdcl1: | |
91d231cb JM |
1909 | '(' maybe_attribute absdcl1 ')' |
1910 | { $$ = $2 ? tree_cons ($2, $3, NULL_TREE) : $3; } | |
25d78ace | 1911 | | direct_absdcl1 '(' parmlist |
028299c6 | 1912 | { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); } |
0e03329a JM |
1913 | | direct_absdcl1 array_declarator |
1914 | { $$ = set_array_declarator_type ($2, $1, 1); } | |
25d78ace | 1915 | | '(' parmlist |
028299c6 | 1916 | { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); } |
0e03329a JM |
1917 | | array_declarator |
1918 | { $$ = set_array_declarator_type ($1, NULL_TREE, 1); } | |
1919 | ; | |
1920 | ||
1921 | /* The [...] part of a declarator for an array type. */ | |
1922 | ||
1923 | array_declarator: | |
88682ff6 | 1924 | '[' maybe_type_quals_attrs expr_no_commas ']' |
0e03329a | 1925 | { $$ = build_array_declarator ($3, $2, 0, 0); } |
f79f2651 | 1926 | | '[' maybe_type_quals_attrs ']' |
0e03329a | 1927 | { $$ = build_array_declarator (NULL_TREE, $2, 0, 0); } |
f79f2651 | 1928 | | '[' maybe_type_quals_attrs '*' ']' |
0e03329a | 1929 | { $$ = build_array_declarator (NULL_TREE, $2, 0, 1); } |
88682ff6 | 1930 | | '[' STATIC maybe_type_quals_attrs expr_no_commas ']' |
f79f2651 NB |
1931 | { $$ = build_array_declarator ($4, $3, 1, 0); } |
1932 | /* declspecs_nosc_nots is a synonym for type_quals_attrs. */ | |
88682ff6 | 1933 | | '[' declspecs_nosc_nots STATIC expr_no_commas ']' |
f79f2651 | 1934 | { $$ = build_array_declarator ($4, $2, 1, 0); } |
0e03329a | 1935 | ; |
028299c6 | 1936 | |
b7438415 JM |
1937 | /* A nonempty series of declarations and statements (possibly followed by |
1938 | some labels) that can form the body of a compound statement. | |
1939 | NOTE: we don't allow labels on declarations; this might seem like a | |
1940 | natural extension, but there would be a conflict between attributes | |
1941 | on the label and prefix attributes on the declaration. */ | |
028299c6 | 1942 | |
b7438415 JM |
1943 | stmts_and_decls: |
1944 | lineno_stmt_decl_or_labels_ending_stmt | |
1945 | | lineno_stmt_decl_or_labels_ending_decl | |
1946 | | lineno_stmt_decl_or_labels_ending_label | |
28a19afc | 1947 | { |
f560bf91 | 1948 | error ("label at end of compound statement"); |
28a19afc | 1949 | } |
b7438415 | 1950 | | lineno_stmt_decl_or_labels_ending_error |
28a19afc RK |
1951 | ; |
1952 | ||
b7438415 JM |
1953 | lineno_stmt_decl_or_labels_ending_stmt: |
1954 | lineno_stmt | |
1955 | | lineno_stmt_decl_or_labels_ending_stmt lineno_stmt | |
1956 | | lineno_stmt_decl_or_labels_ending_decl lineno_stmt | |
1957 | | lineno_stmt_decl_or_labels_ending_label lineno_stmt | |
1958 | | lineno_stmt_decl_or_labels_ending_error lineno_stmt | |
028299c6 RS |
1959 | ; |
1960 | ||
b7438415 JM |
1961 | lineno_stmt_decl_or_labels_ending_decl: |
1962 | lineno_decl | |
1963 | | lineno_stmt_decl_or_labels_ending_stmt lineno_decl | |
85617eba HPN |
1964 | { |
1965 | if ((pedantic && !flag_isoc99) | |
1966 | || warn_declaration_after_statement) | |
1967 | pedwarn_c90 ("ISO C90 forbids mixed declarations and code"); | |
1968 | } | |
b7438415 JM |
1969 | | lineno_stmt_decl_or_labels_ending_decl lineno_decl |
1970 | | lineno_stmt_decl_or_labels_ending_error lineno_decl | |
1971 | ; | |
1972 | ||
1973 | lineno_stmt_decl_or_labels_ending_label: | |
1974 | lineno_label | |
1975 | | lineno_stmt_decl_or_labels_ending_stmt lineno_label | |
1976 | | lineno_stmt_decl_or_labels_ending_decl lineno_label | |
1977 | | lineno_stmt_decl_or_labels_ending_label lineno_label | |
1978 | | lineno_stmt_decl_or_labels_ending_error lineno_label | |
1979 | ; | |
1980 | ||
1981 | lineno_stmt_decl_or_labels_ending_error: | |
1982 | errstmt | |
1983 | | lineno_stmt_decl_or_labels errstmt | |
1984 | ; | |
1985 | ||
1986 | lineno_stmt_decl_or_labels: | |
1987 | lineno_stmt_decl_or_labels_ending_stmt | |
1988 | | lineno_stmt_decl_or_labels_ending_decl | |
1989 | | lineno_stmt_decl_or_labels_ending_label | |
1990 | | lineno_stmt_decl_or_labels_ending_error | |
028299c6 RS |
1991 | ; |
1992 | ||
1993 | errstmt: error ';' | |
1994 | ; | |
1995 | ||
444ca59f JM |
1996 | /* Start and end blocks created for the new scopes of C99. */ |
1997 | c99_block_start: /* empty */ | |
325c3691 | 1998 | { $$ = c_begin_compound_stmt (flag_isoc99); } |
444ca59f JM |
1999 | ; |
2000 | ||
028299c6 RS |
2001 | /* Read zero or more forward-declarations for labels |
2002 | that nested functions can jump to. */ | |
2003 | maybe_label_decls: | |
2004 | /* empty */ | |
2005 | | label_decls | |
2006 | { if (pedantic) | |
89abf8d1 | 2007 | pedwarn ("ISO C forbids label declarations"); } |
028299c6 RS |
2008 | ; |
2009 | ||
2010 | label_decls: | |
2011 | label_decl | |
2012 | | label_decls label_decl | |
2013 | ; | |
2014 | ||
2015 | label_decl: | |
2016 | LABEL identifiers_or_typenames ';' | |
2017 | { tree link; | |
2018 | for (link = $2; link; link = TREE_CHAIN (link)) | |
2019 | { | |
14e33ee8 | 2020 | tree label = declare_label (TREE_VALUE (link)); |
028299c6 | 2021 | C_DECLARED_LABEL_FLAG (label) = 1; |
543a0daa | 2022 | add_stmt (build_stmt (DECL_STMT, label)); |
028299c6 RS |
2023 | } |
2024 | } | |
2025 | ; | |
2026 | ||
2027 | /* This is the body of a function definition. | |
2028 | It causes syntax errors to ignore to the next openbrace. */ | |
2029 | compstmt_or_error: | |
2030 | compstmt | |
093c7153 | 2031 | { add_stmt ($1); } |
028299c6 RS |
2032 | | error compstmt |
2033 | ; | |
2034 | ||
8f17b5c5 | 2035 | compstmt_start: '{' { compstmt_count++; |
325c3691 | 2036 | $$ = c_begin_compound_stmt (true); } |
7d6f6369 | 2037 | ; |
818e50a5 | 2038 | |
d0668a73 | 2039 | compstmt_nostart: '}' |
325c3691 | 2040 | | maybe_label_decls compstmt_contents_nonempty '}' |
028299c6 RS |
2041 | ; |
2042 | ||
b7438415 JM |
2043 | compstmt_contents_nonempty: |
2044 | stmts_and_decls | |
2045 | | error | |
2046 | ; | |
2047 | ||
d0668a73 RH |
2048 | compstmt_primary_start: |
2049 | '(' '{' | |
2050 | { if (current_function_decl == 0) | |
2051 | { | |
325c3691 RH |
2052 | error ("braced-group within expression allowed " |
2053 | "only inside a function"); | |
d0668a73 RH |
2054 | YYERROR; |
2055 | } | |
d0668a73 | 2056 | compstmt_count++; |
325c3691 | 2057 | $$ = c_begin_stmt_expr (); |
d0668a73 | 2058 | } |
7d6f6369 | 2059 | ; |
d0668a73 RH |
2060 | |
2061 | compstmt: compstmt_start compstmt_nostart | |
093c7153 | 2062 | { $$ = c_end_compound_stmt ($1, true); } |
d0668a73 RH |
2063 | ; |
2064 | ||
028299c6 | 2065 | if_prefix: |
16865eaa RH |
2066 | /* We must build the if statement node before parsing its |
2067 | condition so that we get its location pointing to the | |
2068 | line containing the "if", and not the line containing | |
2069 | the close-parenthesis. */ | |
c1e14513 | 2070 | IF |
9e51cf9d | 2071 | { c_begin_if_stmt (); } |
c1e14513 | 2072 | '(' expr ')' |
16865eaa | 2073 | { c_finish_if_cond ($4, compstmt_count, ++stmt_count); } |
c1e14513 | 2074 | ; |
028299c6 | 2075 | |
16865eaa RH |
2076 | simple_if: |
2077 | if_prefix c99_block_lineno_labeled_stmt | |
2078 | { c_finish_then ($2); } | |
2079 | /* Make sure c_finish_if_stmt is run for each call to | |
2080 | c_begin_if_stmt. Otherwise a crash is likely. */ | |
2081 | | if_prefix error | |
2082 | ; | |
2083 | ||
028299c6 RS |
2084 | /* This is a subroutine of stmt. |
2085 | It is used twice, once for valid DO statements | |
2086 | and once for catching errors in parsing the end test. */ | |
2087 | do_stmt_start: | |
2088 | DO | |
2089 | { stmt_count++; | |
818e50a5 | 2090 | compstmt_count++; |
e13e48e7 | 2091 | c_in_iteration_stmt++; |
84d901be | 2092 | $<ttype>$ |
8f17b5c5 MM |
2093 | = add_stmt (build_stmt (DO_STMT, NULL_TREE, |
2094 | NULL_TREE)); | |
2095 | /* In the event that a parse error prevents | |
2096 | parsing the complete do-statement, set the | |
2097 | condition now. Otherwise, we can get crashes at | |
2098 | RTL-generation time. */ | |
2099 | DO_COND ($<ttype>$) = error_mark_node; } | |
444ca59f | 2100 | c99_block_lineno_labeled_stmt WHILE |
8f17b5c5 | 2101 | { $$ = $<ttype>2; |
325c3691 | 2102 | DO_BODY ($$) = $3; |
e13e48e7 | 2103 | c_in_iteration_stmt--; } |
028299c6 RS |
2104 | ; |
2105 | ||
0e5921e8 ZW |
2106 | /* The forced readahead in here is because we might be at the end of a |
2107 | line, and the line and file won't be bumped until yylex absorbs the | |
2108 | first token on the next line. */ | |
028299c6 | 2109 | |
374a4e6c | 2110 | save_location: |
0e5921e8 ZW |
2111 | { if (yychar == YYEMPTY) |
2112 | yychar = YYLEX; | |
374a4e6c | 2113 | $$ = input_location; } |
028299c6 RS |
2114 | ; |
2115 | ||
2116 | lineno_labeled_stmt: | |
64094f6a RH |
2117 | lineno_stmt |
2118 | | lineno_label lineno_labeled_stmt | |
028299c6 RS |
2119 | ; |
2120 | ||
444ca59f JM |
2121 | /* Like lineno_labeled_stmt, but a block in C99. */ |
2122 | c99_block_lineno_labeled_stmt: | |
325c3691 RH |
2123 | c99_block_start lineno_labeled_stmt |
2124 | { $$ = c_end_compound_stmt ($1, flag_isoc99); } | |
444ca59f JM |
2125 | ; |
2126 | ||
b7438415 | 2127 | lineno_stmt: |
374a4e6c | 2128 | save_location stmt |
325c3691 RH |
2129 | { |
2130 | /* Two cases cannot and do not have line numbers associated: | |
2131 | If stmt is degenerate, such as "2;", then stmt is an | |
2132 | INTEGER_CST, which cannot hold line numbers. But that's | |
2133 | ok because the statement will either be changed to a | |
2134 | MODIFY_EXPR during gimplification of the statement expr, | |
2135 | or discarded. If stmt was compound, but without new | |
2136 | variables, we will have skipped the creation of a BIND | |
2137 | and will have a bare STATEMENT_LIST. But that's ok | |
2138 | because (recursively) all of the component statments | |
2139 | should already have line numbers assigned. */ | |
2140 | if ($2 && EXPR_P ($2)) | |
64094f6a | 2141 | { |
6de9cd9a DN |
2142 | SET_EXPR_LOCUS ($2, NULL); |
2143 | annotate_with_locus ($2, $1); | |
64094f6a RH |
2144 | } |
2145 | } | |
028299c6 RS |
2146 | ; |
2147 | ||
b7438415 | 2148 | lineno_label: |
374a4e6c NS |
2149 | save_location label |
2150 | { if ($2) | |
64094f6a | 2151 | { |
6de9cd9a DN |
2152 | SET_EXPR_LOCUS ($2, NULL); |
2153 | annotate_with_locus ($2, $1); | |
64094f6a RH |
2154 | } |
2155 | } | |
028299c6 RS |
2156 | ; |
2157 | ||
444ca59f JM |
2158 | select_or_iter_stmt: |
2159 | simple_if ELSE | |
16865eaa | 2160 | { c_begin_else (stmt_count); } |
444ca59f | 2161 | c99_block_lineno_labeled_stmt |
16865eaa | 2162 | { c_finish_else ($4); c_finish_if_stmt (stmt_count); } |
028299c6 | 2163 | | simple_if %prec IF |
16865eaa | 2164 | { c_finish_if_stmt (stmt_count); } |
028299c6 | 2165 | | simple_if ELSE error |
16865eaa | 2166 | { c_finish_if_stmt (stmt_count + 1); } |
c1e14513 | 2167 | /* We must build the WHILE_STMT node before parsing its |
6de9cd9a | 2168 | condition so that EXPR_LOCUS refers to the line |
c1e14513 JL |
2169 | containing the "while", and not the line containing |
2170 | the close-parenthesis. | |
2171 | ||
2172 | c_begin_while_stmt returns the WHILE_STMT node, which | |
2173 | we later pass to c_finish_while_stmt_cond to fill | |
2174 | in the condition and other tidbits. */ | |
028299c6 | 2175 | | WHILE |
84d901be | 2176 | { stmt_count++; |
c1e14513 | 2177 | $<ttype>$ = c_begin_while_stmt (); } |
028299c6 | 2178 | '(' expr ')' |
e13e48e7 | 2179 | { c_in_iteration_stmt++; |
325c3691 | 2180 | c_finish_while_stmt_cond ($4, $<ttype>2); } |
444ca59f | 2181 | c99_block_lineno_labeled_stmt |
e13e48e7 | 2182 | { c_in_iteration_stmt--; |
325c3691 | 2183 | c_finish_while_stmt ($7, $<ttype>2); } |
028299c6 RS |
2184 | | do_stmt_start |
2185 | '(' expr ')' ';' | |
673fda6b | 2186 | { DO_COND ($1) = lang_hooks.truthvalue_conversion ($3); } |
028299c6 | 2187 | | do_stmt_start error |
c14bc6db | 2188 | { } |
028299c6 | 2189 | | FOR |
325c3691 | 2190 | { $<ttype>$ = c_begin_for_stmt (); } |
77c4d6c0 JM |
2191 | '(' for_init_stmt |
2192 | { stmt_count++; | |
325c3691 | 2193 | c_finish_for_stmt_init ($<ttype>2); } |
028299c6 | 2194 | xexpr ';' |
325c3691 | 2195 | { c_finish_for_stmt_cond ($6, $<ttype>2); } |
028299c6 | 2196 | xexpr ')' |
e13e48e7 | 2197 | { c_in_iteration_stmt++; |
325c3691 | 2198 | c_finish_for_stmt_incr ($9, $<ttype>2); } |
444ca59f | 2199 | c99_block_lineno_labeled_stmt |
325c3691 RH |
2200 | { c_finish_for_stmt ($12, $<ttype>2); |
2201 | c_in_iteration_stmt--; } | |
028299c6 RS |
2202 | | SWITCH '(' expr ')' |
2203 | { stmt_count++; | |
e13e48e7 EC |
2204 | $<ttype>$ = c_start_case ($3); |
2205 | c_in_case_stmt++; } | |
444ca59f | 2206 | c99_block_lineno_labeled_stmt |
325c3691 | 2207 | { c_finish_case ($6); |
e13e48e7 | 2208 | c_in_case_stmt--; } |
444ca59f JM |
2209 | ; |
2210 | ||
77c4d6c0 JM |
2211 | for_init_stmt: |
2212 | xexpr ';' | |
3a5b9284 | 2213 | { c_finish_expr_stmt ($1); } |
77c4d6c0 JM |
2214 | | decl |
2215 | { check_for_loop_decls (); } | |
2216 | ; | |
2217 | ||
9f0e2d86 ZW |
2218 | xexpr: |
2219 | /* empty */ | |
2220 | { $$ = NULL_TREE; } | |
2221 | | expr | |
2222 | ; | |
2223 | ||
444ca59f JM |
2224 | /* Parse a single real statement, not including any labels. */ |
2225 | stmt: | |
2226 | compstmt | |
093c7153 | 2227 | { stmt_count++; add_stmt ($1); } |
444ca59f | 2228 | | expr ';' |
3a5b9284 | 2229 | { stmt_count++; c_finish_expr_stmt ($1); } |
325c3691 | 2230 | | c99_block_start select_or_iter_stmt |
093c7153 | 2231 | { add_stmt (c_end_compound_stmt ($1, flag_isoc99)); } |
028299c6 | 2232 | | BREAK ';' |
8f17b5c5 | 2233 | { stmt_count++; |
325c3691 | 2234 | if (!(c_in_iteration_stmt || c_in_case_stmt)) |
093c7153 | 2235 | error ("break statement not within loop or switch"); |
325c3691 | 2236 | else |
093c7153 | 2237 | add_stmt (build_break_stmt ()); } |
028299c6 | 2238 | | CONTINUE ';' |
8f17b5c5 | 2239 | { stmt_count++; |
325c3691 | 2240 | if (!c_in_iteration_stmt) |
093c7153 | 2241 | error ("continue statement not within a loop"); |
325c3691 | 2242 | else |
093c7153 | 2243 | add_stmt (build_continue_stmt ()); } |
028299c6 | 2244 | | RETURN ';' |
093c7153 | 2245 | { stmt_count++; c_expand_return (NULL_TREE); } |
028299c6 | 2246 | | RETURN expr ';' |
093c7153 | 2247 | { stmt_count++; c_expand_return ($2); } |
9f0e2d86 | 2248 | | asm_stmt |
028299c6 RS |
2249 | | GOTO identifier ';' |
2250 | { tree decl; | |
2251 | stmt_count++; | |
028299c6 RS |
2252 | decl = lookup_label ($2); |
2253 | if (decl != 0) | |
2254 | { | |
2255 | TREE_USED (decl) = 1; | |
093c7153 | 2256 | add_stmt (build_stmt (GOTO_EXPR, decl)); |
028299c6 RS |
2257 | } |
2258 | } | |
2259 | | GOTO '*' expr ';' | |
e64bb706 | 2260 | { if (pedantic) |
89abf8d1 | 2261 | pedwarn ("ISO C forbids `goto *expr;'"); |
e64bb706 | 2262 | stmt_count++; |
8f17b5c5 | 2263 | $3 = convert (ptr_type_node, $3); |
093c7153 | 2264 | add_stmt (build_stmt (GOTO_EXPR, $3)); } |
028299c6 | 2265 | | ';' |
093c7153 | 2266 | { } |
264fa2db ZL |
2267 | @@ifobjc |
2268 | | AT_THROW expr ';' | |
093c7153 | 2269 | { stmt_count++; objc_build_throw_stmt ($2); } |
264fa2db | 2270 | | AT_THROW ';' |
093c7153 | 2271 | { stmt_count++; objc_build_throw_stmt (NULL_TREE); } |
e13e48e7 | 2272 | | objc_try_catch_stmt |
093c7153 RH |
2273 | { } |
2274 | | AT_SYNCHRONIZED '(' expr ')' save_location compstmt | |
2275 | { stmt_count++; objc_build_synchronized ($5, $3, $6); } | |
264fa2db ZL |
2276 | ; |
2277 | ||
093c7153 RH |
2278 | objc_catch_prefix: |
2279 | AT_CATCH '(' parm ')' | |
2280 | { objc_begin_catch_clause ($3); } | |
264fa2db ZL |
2281 | ; |
2282 | ||
093c7153 RH |
2283 | objc_catch_clause: |
2284 | objc_catch_prefix '{' compstmt_nostart | |
2285 | { objc_finish_catch_clause (); } | |
2286 | | objc_catch_prefix '{' error '}' | |
2287 | { objc_finish_catch_clause (); } | |
2288 | ; | |
264fa2db | 2289 | |
093c7153 RH |
2290 | objc_opt_catch_list: |
2291 | /* empty */ | |
2292 | | objc_opt_catch_list objc_catch_clause | |
264fa2db | 2293 | ; |
e13e48e7 | 2294 | |
093c7153 RH |
2295 | objc_try_catch_clause: |
2296 | AT_TRY save_location compstmt | |
2297 | { stmt_count++; objc_begin_try_stmt ($2, $3); } | |
2298 | objc_opt_catch_list | |
264fa2db ZL |
2299 | ; |
2300 | ||
093c7153 RH |
2301 | objc_finally_clause: |
2302 | AT_FINALLY save_location compstmt | |
2303 | { objc_build_finally_clause ($2, $3); } | |
264fa2db ZL |
2304 | ; |
2305 | ||
093c7153 RH |
2306 | objc_try_catch_stmt: |
2307 | objc_try_catch_clause | |
2308 | { objc_finish_try_stmt (); } | |
2309 | | objc_try_catch_clause objc_finally_clause | |
2310 | { objc_finish_try_stmt (); } | |
264fa2db | 2311 | @@end_ifobjc |
028299c6 RS |
2312 | ; |
2313 | ||
2314 | /* Any kind of label, including jump labels and case labels. | |
2315 | ANSI C accepts labels only before statements, but we allow them | |
2316 | also at the end of a compound statement. */ | |
2317 | ||
b00e5f0d | 2318 | label: CASE expr_no_commas ':' |
56cb9733 | 2319 | { stmt_count++; |
64094f6a | 2320 | $$ = do_case ($2, NULL_TREE); } |
b00e5f0d | 2321 | | CASE expr_no_commas ELLIPSIS expr_no_commas ':' |
56cb9733 | 2322 | { stmt_count++; |
64094f6a | 2323 | $$ = do_case ($2, $4); } |
028299c6 | 2324 | | DEFAULT ':' |
56cb9733 | 2325 | { stmt_count++; |
64094f6a | 2326 | $$ = do_case (NULL_TREE, NULL_TREE); } |
374a4e6c | 2327 | | identifier save_location ':' maybe_attribute |
5b030314 | 2328 | { tree label = define_label ($2, $1); |
028299c6 | 2329 | stmt_count++; |
028299c6 | 2330 | if (label) |
736b02fd | 2331 | { |
374a4e6c | 2332 | decl_attributes (&label, $4, 0); |
9e14e18f | 2333 | $$ = add_stmt (build_stmt (LABEL_EXPR, label)); |
736b02fd | 2334 | } |
64094f6a RH |
2335 | else |
2336 | $$ = NULL_TREE; | |
0e5921e8 | 2337 | } |
028299c6 RS |
2338 | ; |
2339 | ||
9f0e2d86 | 2340 | /* Asm expressions and statements */ |
028299c6 | 2341 | |
9f0e2d86 ZW |
2342 | /* simple_asm_expr is used in restricted contexts, where a full |
2343 | expression with inputs and outputs does not make sense. */ | |
2344 | simple_asm_expr: | |
21526606 EC |
2345 | ASM_KEYWORD stop_string_translation |
2346 | '(' STRING ')' start_string_translation | |
2347 | { $$ = $4; } | |
9f0e2d86 ZW |
2348 | ; |
2349 | ||
2350 | /* maybeasm: used for assembly names for declarations */ | |
2351 | maybeasm: | |
2352 | /* empty */ | |
0de456a5 | 2353 | { $$ = NULL_TREE; } |
9f0e2d86 | 2354 | | simple_asm_expr |
028299c6 RS |
2355 | ; |
2356 | ||
9f0e2d86 ZW |
2357 | /* asmdef: asm() outside a function body. */ |
2358 | asmdef: | |
2359 | simple_asm_expr ';' | |
2360 | { assemble_asm ($1); } | |
21526606 EC |
2361 | | ASM_KEYWORD error start_string_translation ';' |
2362 | {} | |
9f0e2d86 ZW |
2363 | ; |
2364 | ||
2365 | /* Full-blown asm statement with inputs, outputs, clobbers, and | |
2366 | volatile tag allowed. */ | |
2367 | asm_stmt: | |
21526606 EC |
2368 | ASM_KEYWORD maybe_volatile stop_string_translation |
2369 | '(' asm_argument ')' start_string_translation ';' | |
9f0e2d86 | 2370 | { stmt_count++; |
21526606 | 2371 | $$ = build_asm_stmt ($2, $5); } |
9f0e2d86 ZW |
2372 | ; |
2373 | ||
2374 | asm_argument: | |
2375 | /* no operands */ | |
2376 | STRING | |
2377 | { $$ = build_asm_expr ($1, 0, 0, 0, true); } | |
2378 | /* output operands */ | |
2379 | | STRING ':' asm_operands | |
2380 | { $$ = build_asm_expr ($1, $3, 0, 0, false); } | |
2381 | /* output and input operands */ | |
2382 | | STRING ':' asm_operands ':' asm_operands | |
2383 | { $$ = build_asm_expr ($1, $3, $5, 0, false); } | |
2384 | /* output and input operands and clobbers */ | |
2385 | | STRING ':' asm_operands ':' asm_operands ':' asm_clobbers | |
2386 | { $$ = build_asm_expr ($1, $3, $5, $7, false); } | |
2387 | ; | |
2388 | ||
2389 | /* Either 'volatile' or nothing. First thing in an `asm' statement. */ | |
2390 | ||
2391 | maybe_volatile: | |
028299c6 | 2392 | /* empty */ |
9f0e2d86 ZW |
2393 | { $$ = 0; } |
2394 | | TYPE_QUAL | |
2395 | { if ($1 != ridpointers[RID_VOLATILE]) | |
2396 | { | |
2397 | warning ("%E qualifier ignored on asm", $1); | |
2398 | $$ = 0; | |
2399 | } | |
2400 | else | |
2401 | $$ = $1; | |
2402 | } | |
028299c6 RS |
2403 | ; |
2404 | ||
2405 | /* These are the operands other than the first string and colon | |
2406 | in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */ | |
2407 | asm_operands: /* empty */ | |
2408 | { $$ = NULL_TREE; } | |
2409 | | nonnull_asm_operands | |
2410 | ; | |
2411 | ||
2412 | nonnull_asm_operands: | |
2413 | asm_operand | |
2414 | | nonnull_asm_operands ',' asm_operand | |
2415 | { $$ = chainon ($1, $3); } | |
2416 | ; | |
2417 | ||
2418 | asm_operand: | |
21526606 EC |
2419 | STRING start_string_translation '(' expr ')' stop_string_translation |
2420 | { $$ = build_tree_list (build_tree_list (NULL_TREE, $1), $4); } | |
2421 | | '[' identifier ']' STRING start_string_translation | |
2422 | '(' expr ')' stop_string_translation | |
fc552851 RS |
2423 | { $2 = build_string (IDENTIFIER_LENGTH ($2), |
2424 | IDENTIFIER_POINTER ($2)); | |
21526606 | 2425 | $$ = build_tree_list (build_tree_list ($2, $4), $7); } |
028299c6 RS |
2426 | ; |
2427 | ||
2428 | asm_clobbers: | |
b84a3874 RH |
2429 | STRING |
2430 | { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); } | |
2431 | | asm_clobbers ',' STRING | |
2432 | { $$ = tree_cons (NULL_TREE, $3, $1); } | |
028299c6 | 2433 | ; |
21526606 EC |
2434 | |
2435 | stop_string_translation: | |
0173bb6f | 2436 | { c_lex_string_translate = 0; } |
21526606 EC |
2437 | ; |
2438 | ||
2439 | start_string_translation: | |
0173bb6f | 2440 | { c_lex_string_translate = 1; } |
21526606 EC |
2441 | ; |
2442 | ||
028299c6 RS |
2443 | \f |
2444 | /* This is what appears inside the parens in a function declarator. | |
25d78ace JM |
2445 | Its value is a list of ..._TYPE nodes. Attributes must appear here |
2446 | to avoid a conflict with their appearance after an open parenthesis | |
2447 | in an abstract declarator, as in | |
2448 | "void bar (int (__attribute__((__mode__(SI))) int foo));". */ | |
028299c6 | 2449 | parmlist: |
25d78ace | 2450 | maybe_attribute |
f75fbaf7 | 2451 | { push_scope (); |
eb1dfbb2 | 2452 | declare_parm_level (); } |
028299c6 | 2453 | parmlist_1 |
25d78ace | 2454 | { $$ = $3; |
f75fbaf7 | 2455 | pop_scope (); } |
028299c6 RS |
2456 | ; |
2457 | ||
2458 | parmlist_1: | |
2459 | parmlist_2 ')' | |
2460 | | parms ';' | |
55d54003 | 2461 | { mark_forward_parm_decls (); } |
25d78ace JM |
2462 | maybe_attribute |
2463 | { /* Dummy action so attributes are in known place | |
2464 | on parser stack. */ } | |
028299c6 | 2465 | parmlist_1 |
25d78ace | 2466 | { $$ = $6; } |
028299c6 | 2467 | | error ')' |
f75fbaf7 | 2468 | { $$ = make_node (TREE_LIST); } |
028299c6 RS |
2469 | ; |
2470 | ||
2471 | /* This is what appears inside the parens in a function declarator. | |
2472 | Is value is represented in the format that grokdeclarator expects. */ | |
2473 | parmlist_2: /* empty */ | |
f75fbaf7 | 2474 | { $$ = make_node (TREE_LIST); } |
028299c6 | 2475 | | ELLIPSIS |
f75fbaf7 ZW |
2476 | { $$ = make_node (TREE_LIST); |
2477 | /* Suppress -Wold-style-definition for this case. */ | |
2478 | TREE_CHAIN ($$) = error_mark_node; | |
89abf8d1 | 2479 | error ("ISO C requires a named argument before `...'"); |
028299c6 RS |
2480 | } |
2481 | | parms | |
f75fbaf7 | 2482 | { $$ = get_parm_info (/*ellipsis=*/false); } |
028299c6 | 2483 | | parms ',' ELLIPSIS |
f75fbaf7 | 2484 | { $$ = get_parm_info (/*ellipsis=*/true); } |
028299c6 RS |
2485 | ; |
2486 | ||
2487 | parms: | |
25d78ace | 2488 | firstparm |
028299c6 RS |
2489 | { push_parm_decl ($1); } |
2490 | | parms ',' parm | |
2491 | { push_parm_decl ($3); } | |
2492 | ; | |
2493 | ||
2494 | /* A single parameter declaration or parameter type name, | |
2495 | as found in a parmlist. */ | |
2496 | parm: | |
25d78ace | 2497 | declspecs_ts setspecs parm_declarator maybe_attribute |
d27543a7 RK |
2498 | { $$ = build_tree_list (build_tree_list (current_declspecs, |
2499 | $3), | |
4b01f8d8 JM |
2500 | chainon ($4, all_prefix_attributes)); |
2501 | POP_DECLSPEC_STACK; } | |
25d78ace | 2502 | | declspecs_ts setspecs notype_declarator maybe_attribute |
d27543a7 RK |
2503 | { $$ = build_tree_list (build_tree_list (current_declspecs, |
2504 | $3), | |
84d901be | 2505 | chainon ($4, all_prefix_attributes)); |
4b01f8d8 | 2506 | POP_DECLSPEC_STACK; } |
25d78ace JM |
2507 | | declspecs_ts setspecs absdcl_maybe_attribute |
2508 | { $$ = $3; | |
4b01f8d8 | 2509 | POP_DECLSPEC_STACK; } |
25d78ace | 2510 | | declspecs_nots setspecs notype_declarator maybe_attribute |
d27543a7 RK |
2511 | { $$ = build_tree_list (build_tree_list (current_declspecs, |
2512 | $3), | |
4b01f8d8 JM |
2513 | chainon ($4, all_prefix_attributes)); |
2514 | POP_DECLSPEC_STACK; } | |
25d78ace JM |
2515 | |
2516 | | declspecs_nots setspecs absdcl_maybe_attribute | |
2517 | { $$ = $3; | |
4b01f8d8 | 2518 | POP_DECLSPEC_STACK; } |
25d78ace JM |
2519 | ; |
2520 | ||
2521 | /* The first parm, which must suck attributes from off the top of the parser | |
2522 | stack. */ | |
2523 | firstparm: | |
2524 | declspecs_ts_nosa setspecs_fp parm_declarator maybe_attribute | |
d27543a7 RK |
2525 | { $$ = build_tree_list (build_tree_list (current_declspecs, |
2526 | $3), | |
4b01f8d8 JM |
2527 | chainon ($4, all_prefix_attributes)); |
2528 | POP_DECLSPEC_STACK; } | |
25d78ace JM |
2529 | | declspecs_ts_nosa setspecs_fp notype_declarator maybe_attribute |
2530 | { $$ = build_tree_list (build_tree_list (current_declspecs, | |
2531 | $3), | |
84d901be | 2532 | chainon ($4, all_prefix_attributes)); |
4b01f8d8 | 2533 | POP_DECLSPEC_STACK; } |
25d78ace JM |
2534 | | declspecs_ts_nosa setspecs_fp absdcl_maybe_attribute |
2535 | { $$ = $3; | |
4b01f8d8 | 2536 | POP_DECLSPEC_STACK; } |
25d78ace | 2537 | | declspecs_nots_nosa setspecs_fp notype_declarator maybe_attribute |
d27543a7 RK |
2538 | { $$ = build_tree_list (build_tree_list (current_declspecs, |
2539 | $3), | |
4b01f8d8 JM |
2540 | chainon ($4, all_prefix_attributes)); |
2541 | POP_DECLSPEC_STACK; } | |
25d78ace JM |
2542 | |
2543 | | declspecs_nots_nosa setspecs_fp absdcl_maybe_attribute | |
2544 | { $$ = $3; | |
4b01f8d8 | 2545 | POP_DECLSPEC_STACK; } |
25d78ace JM |
2546 | ; |
2547 | ||
2548 | setspecs_fp: | |
2549 | setspecs | |
4b01f8d8 JM |
2550 | { prefix_attributes = chainon (prefix_attributes, $<ttype>-2); |
2551 | all_prefix_attributes = prefix_attributes; } | |
028299c6 RS |
2552 | ; |
2553 | ||
2554 | /* This is used in a function definition | |
2555 | where either a parmlist or an identifier list is ok. | |
2556 | Its value is a list of ..._TYPE nodes or a list of identifiers. */ | |
2557 | parmlist_or_identifiers: | |
709619d9 | 2558 | maybe_attribute |
f75fbaf7 | 2559 | { push_scope (); |
eb1dfbb2 | 2560 | declare_parm_level (); } |
028299c6 | 2561 | parmlist_or_identifiers_1 |
709619d9 | 2562 | { $$ = $3; |
f75fbaf7 | 2563 | pop_scope (); } |
028299c6 RS |
2564 | ; |
2565 | ||
2566 | parmlist_or_identifiers_1: | |
2567 | parmlist_1 | |
2568 | | identifiers ')' | |
2569 | { tree t; | |
2570 | for (t = $1; t; t = TREE_CHAIN (t)) | |
2571 | if (TREE_VALUE (t) == NULL_TREE) | |
2572 | error ("`...' in old-style identifier list"); | |
709619d9 AH |
2573 | $$ = tree_cons (NULL_TREE, NULL_TREE, $1); |
2574 | ||
2575 | /* Make sure we have a parmlist after attributes. */ | |
2576 | if ($<ttype>-1 != 0 | |
2577 | && (TREE_CODE ($$) != TREE_LIST | |
2578 | || TREE_PURPOSE ($$) == 0 | |
2579 | || TREE_CODE (TREE_PURPOSE ($$)) != PARM_DECL)) | |
2580 | YYERROR1; | |
2581 | } | |
028299c6 RS |
2582 | ; |
2583 | ||
2584 | /* A nonempty list of identifiers. */ | |
2585 | identifiers: | |
2586 | IDENTIFIER | |
2587 | { $$ = build_tree_list (NULL_TREE, $1); } | |
2588 | | identifiers ',' IDENTIFIER | |
2589 | { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); } | |
2590 | ; | |
2591 | ||
2592 | /* A nonempty list of identifiers, including typenames. */ | |
2593 | identifiers_or_typenames: | |
2594 | identifier | |
2595 | { $$ = build_tree_list (NULL_TREE, $1); } | |
2596 | | identifiers_or_typenames ',' identifier | |
2597 | { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); } | |
2598 | ; | |
72acf258 JM |
2599 | |
2600 | extension: | |
2601 | EXTENSION | |
750491fc | 2602 | { $$ = SAVE_EXT_FLAGS(); |
c3b6e114 | 2603 | pedantic = 0; |
5137bd4f | 2604 | warn_pointer_arith = 0; |
750491fc RH |
2605 | warn_traditional = 0; |
2606 | flag_iso = 0; } | |
72acf258 | 2607 | ; |
028299c6 | 2608 | \f |
264fa2db | 2609 | @@ifobjc |
028299c6 RS |
2610 | /* Objective-C productions. */ |
2611 | ||
2612 | objcdef: | |
2613 | classdef | |
e31c7eec TW |
2614 | | classdecl |
2615 | | aliasdecl | |
2616 | | protocoldef | |
028299c6 | 2617 | | methoddef |
f2b5cf97 | 2618 | | AT_END |
028299c6 RS |
2619 | { |
2620 | if (objc_implementation_context) | |
2621 | { | |
2622 | finish_class (objc_implementation_context); | |
2623 | objc_ivar_chain = NULL_TREE; | |
2624 | objc_implementation_context = NULL_TREE; | |
2625 | } | |
2626 | else | |
2627 | warning ("`@end' must appear in an implementation context"); | |
2628 | } | |
2629 | ; | |
2630 | ||
e31c7eec TW |
2631 | /* A nonempty list of identifiers. */ |
2632 | identifier_list: | |
2633 | identifier | |
2634 | { $$ = build_tree_list (NULL_TREE, $1); } | |
2635 | | identifier_list ',' identifier | |
2636 | { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); } | |
2637 | ; | |
2638 | ||
2639 | classdecl: | |
f2b5cf97 | 2640 | AT_CLASS identifier_list ';' |
e31c7eec TW |
2641 | { |
2642 | objc_declare_class ($2); | |
2643 | } | |
84d901be | 2644 | ; |
e31c7eec TW |
2645 | |
2646 | aliasdecl: | |
f2b5cf97 | 2647 | AT_ALIAS identifier identifier ';' |
e31c7eec TW |
2648 | { |
2649 | objc_declare_alias ($2, $3); | |
2650 | } | |
84d901be | 2651 | ; |
e31c7eec | 2652 | |
264fa2db ZL |
2653 | superclass: |
2654 | ':' identifier { $$ = $2; } | |
2655 | | /* NULL */ %prec HYPERUNARY { $$ = NULL_TREE; } | |
2656 | ; | |
028299c6 | 2657 | |
264fa2db ZL |
2658 | class_ivars: |
2659 | '{' ivar_decl_list '}' | |
2660 | | /* NULL */ | |
2661 | ; | |
028299c6 | 2662 | |
264fa2db | 2663 | classdef: |
f2b5cf97 | 2664 | AT_INTERFACE identifier superclass protocolrefs |
028299c6 RS |
2665 | { |
2666 | objc_interface_context = objc_ivar_context | |
264fa2db | 2667 | = start_class (CLASS_INTERFACE_TYPE, $2, $3, $4); |
028299c6 RS |
2668 | objc_public_flag = 0; |
2669 | } | |
264fa2db | 2670 | class_ivars |
028299c6 RS |
2671 | { |
2672 | continue_class (objc_interface_context); | |
2673 | } | |
f2b5cf97 | 2674 | methodprotolist AT_END |
028299c6 RS |
2675 | { |
2676 | finish_class (objc_interface_context); | |
2677 | objc_interface_context = NULL_TREE; | |
2678 | } | |
2679 | ||
f2b5cf97 | 2680 | | AT_IMPLEMENTATION identifier superclass |
028299c6 RS |
2681 | { |
2682 | objc_implementation_context = objc_ivar_context | |
264fa2db | 2683 | = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $3, NULL_TREE); |
028299c6 RS |
2684 | objc_public_flag = 0; |
2685 | } | |
264fa2db | 2686 | class_ivars |
028299c6 RS |
2687 | { |
2688 | objc_ivar_chain | |
2689 | = continue_class (objc_implementation_context); | |
2690 | } | |
2691 | ||
f2b5cf97 | 2692 | | AT_INTERFACE identifier '(' identifier ')' protocolrefs |
028299c6 RS |
2693 | { |
2694 | objc_interface_context | |
e31c7eec | 2695 | = start_class (CATEGORY_INTERFACE_TYPE, $2, $4, $6); |
028299c6 RS |
2696 | continue_class (objc_interface_context); |
2697 | } | |
f2b5cf97 | 2698 | methodprotolist AT_END |
028299c6 RS |
2699 | { |
2700 | finish_class (objc_interface_context); | |
2701 | objc_interface_context = NULL_TREE; | |
2702 | } | |
2703 | ||
f2b5cf97 | 2704 | | AT_IMPLEMENTATION identifier '(' identifier ')' |
028299c6 RS |
2705 | { |
2706 | objc_implementation_context | |
e31c7eec | 2707 | = start_class (CATEGORY_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE); |
028299c6 RS |
2708 | objc_ivar_chain |
2709 | = continue_class (objc_implementation_context); | |
2710 | } | |
2711 | ; | |
2712 | ||
e31c7eec | 2713 | protocoldef: |
f2b5cf97 | 2714 | AT_PROTOCOL identifier protocolrefs |
e31c7eec | 2715 | { |
4c521bad | 2716 | objc_pq_context = 1; |
e31c7eec TW |
2717 | objc_interface_context |
2718 | = start_protocol(PROTOCOL_INTERFACE_TYPE, $2, $3); | |
2719 | } | |
f2b5cf97 | 2720 | methodprotolist AT_END |
e31c7eec | 2721 | { |
4c521bad | 2722 | objc_pq_context = 0; |
e31c7eec TW |
2723 | finish_protocol(objc_interface_context); |
2724 | objc_interface_context = NULL_TREE; | |
2725 | } | |
f2e6e530 ZL |
2726 | /* The @protocol forward-declaration production introduces a |
2727 | reduce/reduce conflict on ';', which should be resolved in | |
2728 | favor of the production 'identifier_list -> identifier'. */ | |
f2b5cf97 | 2729 | | AT_PROTOCOL identifier_list ';' |
f2e6e530 ZL |
2730 | { |
2731 | objc_declare_protocols ($2); | |
2732 | } | |
e31c7eec TW |
2733 | ; |
2734 | ||
2735 | protocolrefs: | |
2736 | /* empty */ | |
2737 | { | |
2738 | $$ = NULL_TREE; | |
2739 | } | |
957a1c32 RK |
2740 | | non_empty_protocolrefs |
2741 | ; | |
2742 | ||
2743 | non_empty_protocolrefs: | |
2744 | ARITHCOMPARE identifier_list ARITHCOMPARE | |
e31c7eec TW |
2745 | { |
2746 | if ($1 == LT_EXPR && $3 == GT_EXPR) | |
2747 | $$ = $2; | |
2748 | else | |
2749 | YYERROR1; | |
2750 | } | |
2751 | ; | |
2752 | ||
028299c6 | 2753 | ivar_decl_list: |
e31c7eec | 2754 | ivar_decl_list visibility_spec ivar_decls |
028299c6 RS |
2755 | | ivar_decls |
2756 | ; | |
2757 | ||
e31c7eec | 2758 | visibility_spec: |
f2b5cf97 DA |
2759 | AT_PRIVATE { objc_public_flag = 2; } |
2760 | | AT_PROTECTED { objc_public_flag = 0; } | |
2761 | | AT_PUBLIC { objc_public_flag = 1; } | |
e31c7eec TW |
2762 | ; |
2763 | ||
028299c6 RS |
2764 | ivar_decls: |
2765 | /* empty */ | |
2766 | { | |
2767 | $$ = NULL_TREE; | |
2768 | } | |
2769 | | ivar_decls ivar_decl ';' | |
2770 | | ivar_decls ';' | |
2771 | { | |
2772 | if (pedantic) | |
ea3cfc81 | 2773 | pedwarn ("extra semicolon in struct or union specified"); |
028299c6 RS |
2774 | } |
2775 | ; | |
2776 | ||
2777 | ||
2778 | /* There is a shift-reduce conflict here, because `components' may | |
2779 | start with a `typename'. It happens that shifting (the default resolution) | |
2780 | does the right thing, because it treats the `typename' as part of | |
2781 | a `typed_typespecs'. | |
2782 | ||
2783 | It is possible that this same technique would allow the distinction | |
2784 | between `notype_initdecls' and `initdecls' to be eliminated. | |
2785 | But I am being cautious and not trying it. */ | |
2786 | ||
2787 | ivar_decl: | |
25d78ace | 2788 | declspecs_nosc_ts setspecs ivars |
962a2496 | 2789 | { $$ = $3; |
4b01f8d8 | 2790 | POP_DECLSPEC_STACK; } |
25d78ace | 2791 | | declspecs_nosc_nots setspecs ivars |
962a2496 | 2792 | { $$ = $3; |
4b01f8d8 | 2793 | POP_DECLSPEC_STACK; } |
028299c6 RS |
2794 | | error |
2795 | { $$ = NULL_TREE; } | |
2796 | ; | |
2797 | ||
2798 | ivars: | |
2799 | /* empty */ | |
2800 | { $$ = NULL_TREE; } | |
2801 | | ivar_declarator | |
4b01f8d8 | 2802 | | ivars ',' maybe_resetattrs ivar_declarator |
028299c6 RS |
2803 | ; |
2804 | ||
2805 | ivar_declarator: | |
2806 | declarator | |
2807 | { | |
2808 | $$ = add_instance_variable (objc_ivar_context, | |
2809 | objc_public_flag, | |
2810 | $1, current_declspecs, | |
2811 | NULL_TREE); | |
2812 | } | |
2813 | | declarator ':' expr_no_commas | |
2814 | { | |
2815 | $$ = add_instance_variable (objc_ivar_context, | |
2816 | objc_public_flag, | |
2817 | $1, current_declspecs, $3); | |
2818 | } | |
2819 | | ':' expr_no_commas | |
2820 | { | |
2821 | $$ = add_instance_variable (objc_ivar_context, | |
2822 | objc_public_flag, | |
2823 | NULL_TREE, | |
2824 | current_declspecs, $2); | |
2825 | } | |
2826 | ; | |
2827 | ||
0b1cdaf2 | 2828 | methodtype: |
028299c6 | 2829 | '+' |
0b1cdaf2 | 2830 | { objc_inherit_code = CLASS_METHOD_DECL; } |
028299c6 | 2831 | | '-' |
0b1cdaf2 NB |
2832 | { objc_inherit_code = INSTANCE_METHOD_DECL; } |
2833 | ; | |
2834 | ||
2835 | methoddef: | |
2836 | methodtype | |
028299c6 | 2837 | { |
4c521bad | 2838 | objc_pq_context = 1; |
0b1cdaf2 | 2839 | if (!objc_implementation_context) |
400500c4 | 2840 | fatal_error ("method definition not in class context"); |
028299c6 RS |
2841 | } |
2842 | methoddecl | |
2843 | { | |
4c521bad | 2844 | objc_pq_context = 0; |
4898423c ZL |
2845 | objc_add_method (objc_implementation_context, |
2846 | $3, | |
2847 | objc_inherit_code == CLASS_METHOD_DECL); | |
028299c6 | 2848 | start_method_def ($3); |
028299c6 RS |
2849 | } |
2850 | optarglist | |
2851 | { | |
2852 | continue_method_def (); | |
2853 | } | |
2854 | compstmt_or_error | |
2855 | { | |
2856 | finish_method_def (); | |
028299c6 RS |
2857 | } |
2858 | ; | |
2859 | ||
2860 | /* the reason for the strange actions in this rule | |
2861 | is so that notype_initdecls when reached via datadef | |
2862 | can find a valid list of type and sc specs in $0. */ | |
2863 | ||
2864 | methodprotolist: | |
2865 | /* empty */ | |
264fa2db ZL |
2866 | | methodprotolist methodproto |
2867 | | methodprotolist { $<ttype>$ = NULL_TREE; } datadef | |
028299c6 RS |
2868 | ; |
2869 | ||
2870 | semi_or_error: | |
2871 | ';' | |
2872 | | error | |
2873 | ; | |
2874 | ||
2875 | methodproto: | |
0b1cdaf2 | 2876 | methodtype |
028299c6 | 2877 | { |
990ac8d7 | 2878 | /* Remember protocol qualifiers in prototypes. */ |
4c521bad | 2879 | objc_pq_context = 1; |
028299c6 RS |
2880 | } |
2881 | methoddecl | |
2882 | { | |
990ac8d7 | 2883 | /* Forget protocol qualifiers here. */ |
4c521bad | 2884 | objc_pq_context = 0; |
4898423c ZL |
2885 | objc_add_method (objc_interface_context, |
2886 | $3, | |
2887 | objc_inherit_code == CLASS_METHOD_DECL); | |
028299c6 RS |
2888 | } |
2889 | semi_or_error | |
2890 | ; | |
2891 | ||
2892 | methoddecl: | |
2893 | '(' typename ')' unaryselector | |
2894 | { | |
2895 | $$ = build_method_decl (objc_inherit_code, $2, $4, NULL_TREE); | |
2896 | } | |
2897 | ||
2898 | | unaryselector | |
2899 | { | |
2900 | $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, NULL_TREE); | |
2901 | } | |
2902 | ||
2903 | | '(' typename ')' keywordselector optparmlist | |
2904 | { | |
2905 | $$ = build_method_decl (objc_inherit_code, $2, $4, $5); | |
2906 | } | |
2907 | ||
2908 | | keywordselector optparmlist | |
2909 | { | |
2910 | $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, $2); | |
2911 | } | |
2912 | ; | |
2913 | ||
2914 | /* "optarglist" assumes that start_method_def has already been called... | |
2915 | if it is not, the "xdecls" will not be placed in the proper scope */ | |
2916 | ||
2917 | optarglist: | |
2918 | /* empty */ | |
2919 | | ';' myxdecls | |
2920 | ; | |
2921 | ||
2922 | /* to get around the following situation: "int foo (int a) int b; {}" that | |
2923 | is synthesized when parsing "- a:a b:b; id c; id d; { ... }" */ | |
2924 | ||
2925 | myxdecls: | |
2926 | /* empty */ | |
2927 | | mydecls | |
2928 | ; | |
2929 | ||
2930 | mydecls: | |
2931 | mydecl | |
2932 | | errstmt | |
2933 | | mydecls mydecl | |
2934 | | mydecl errstmt | |
2935 | ; | |
2936 | ||
2937 | mydecl: | |
25d78ace | 2938 | declspecs_ts setspecs myparms ';' |
4b01f8d8 | 2939 | { POP_DECLSPEC_STACK; } |
25d78ace | 2940 | | declspecs_ts ';' |
028299c6 | 2941 | { shadow_tag ($1); } |
25d78ace | 2942 | | declspecs_nots ';' |
028299c6 RS |
2943 | { pedwarn ("empty declaration"); } |
2944 | ; | |
2945 | ||
2946 | myparms: | |
2947 | myparm | |
2948 | { push_parm_decl ($1); } | |
2949 | | myparms ',' myparm | |
2950 | { push_parm_decl ($3); } | |
2951 | ; | |
2952 | ||
2953 | /* A single parameter declaration or parameter type name, | |
2954 | as found in a parmlist. DOES NOT ALLOW AN INITIALIZER OR ASMSPEC */ | |
2955 | ||
2956 | myparm: | |
f6999fed RK |
2957 | parm_declarator maybe_attribute |
2958 | { $$ = build_tree_list (build_tree_list (current_declspecs, | |
2959 | $1), | |
4b01f8d8 | 2960 | chainon ($2, all_prefix_attributes)); } |
f6999fed RK |
2961 | | notype_declarator maybe_attribute |
2962 | { $$ = build_tree_list (build_tree_list (current_declspecs, | |
2963 | $1), | |
4b01f8d8 | 2964 | chainon ($2, all_prefix_attributes)); } |
25d78ace JM |
2965 | | absdcl_maybe_attribute |
2966 | { $$ = $1; } | |
028299c6 RS |
2967 | ; |
2968 | ||
2969 | optparmlist: | |
2970 | /* empty */ | |
2971 | { | |
c14bc6db | 2972 | $$ = NULL_TREE; |
028299c6 RS |
2973 | } |
2974 | | ',' ELLIPSIS | |
2975 | { | |
2976 | /* oh what a kludge! */ | |
bcdb1106 | 2977 | $$ = objc_ellipsis_node; |
028299c6 RS |
2978 | } |
2979 | | ',' | |
2980 | { | |
f75fbaf7 | 2981 | push_scope (); |
028299c6 RS |
2982 | } |
2983 | parmlist_2 | |
2984 | { | |
c14bc6db | 2985 | /* returns a tree list node generated by get_parm_info */ |
028299c6 | 2986 | $$ = $3; |
f75fbaf7 | 2987 | pop_scope (); |
028299c6 RS |
2988 | } |
2989 | ; | |
2990 | ||
2991 | unaryselector: | |
2992 | selector | |
2993 | ; | |
2994 | ||
2995 | keywordselector: | |
2996 | keyworddecl | |
2997 | ||
2998 | | keywordselector keyworddecl | |
2999 | { | |
3000 | $$ = chainon ($1, $2); | |
3001 | } | |
3002 | ; | |
3003 | ||
3004 | selector: | |
3005 | IDENTIFIER | |
f2e6e530 ZL |
3006 | | TYPENAME |
3007 | | CLASSNAME | |
3008 | | OBJECTNAME | |
028299c6 RS |
3009 | | reservedwords |
3010 | ; | |
3011 | ||
3012 | reservedwords: | |
0e5921e8 ZW |
3013 | ENUM | STRUCT | UNION | IF | ELSE | WHILE | DO | FOR |
3014 | | SWITCH | CASE | DEFAULT | BREAK | CONTINUE | RETURN | |
3015 | | GOTO | ASM_KEYWORD | SIZEOF | TYPEOF | ALIGNOF | |
028299c6 RS |
3016 | | TYPESPEC | TYPE_QUAL |
3017 | ; | |
3018 | ||
3019 | keyworddecl: | |
3020 | selector ':' '(' typename ')' identifier | |
3021 | { | |
3022 | $$ = build_keyword_decl ($1, $4, $6); | |
3023 | } | |
3024 | ||
3025 | | selector ':' identifier | |
3026 | { | |
3027 | $$ = build_keyword_decl ($1, NULL_TREE, $3); | |
3028 | } | |
3029 | ||
3030 | | ':' '(' typename ')' identifier | |
3031 | { | |
3032 | $$ = build_keyword_decl (NULL_TREE, $3, $5); | |
3033 | } | |
3034 | ||
3035 | | ':' identifier | |
3036 | { | |
3037 | $$ = build_keyword_decl (NULL_TREE, NULL_TREE, $2); | |
3038 | } | |
3039 | ; | |
3040 | ||
3041 | messageargs: | |
3042 | selector | |
3043 | | keywordarglist | |
3044 | ; | |
3045 | ||
3046 | keywordarglist: | |
3047 | keywordarg | |
3048 | | keywordarglist keywordarg | |
3049 | { | |
3050 | $$ = chainon ($1, $2); | |
3051 | } | |
3052 | ; | |
3053 | ||
3054 | ||
3055 | keywordexpr: | |
3056 | nonnull_exprlist | |
3057 | { | |
3058 | if (TREE_CHAIN ($1) == NULL_TREE) | |
3059 | /* just return the expr., remove a level of indirection */ | |
3060 | $$ = TREE_VALUE ($1); | |
3061 | else | |
3062 | /* we have a comma expr., we will collapse later */ | |
3063 | $$ = $1; | |
3064 | } | |
3065 | ; | |
3066 | ||
3067 | keywordarg: | |
3068 | selector ':' keywordexpr | |
3069 | { | |
3070 | $$ = build_tree_list ($1, $3); | |
3071 | } | |
3072 | | ':' keywordexpr | |
3073 | { | |
3074 | $$ = build_tree_list (NULL_TREE, $2); | |
3075 | } | |
3076 | ; | |
3077 | ||
3078 | receiver: | |
3079 | expr | |
3080 | | CLASSNAME | |
3081 | { | |
3082 | $$ = get_class_reference ($1); | |
3083 | } | |
264fa2db ZL |
3084 | | TYPENAME |
3085 | { | |
3086 | $$ = get_class_reference ($1); | |
3087 | } | |
028299c6 RS |
3088 | ; |
3089 | ||
3090 | objcmessageexpr: | |
c1c5187c ZL |
3091 | '[' receiver messageargs ']' |
3092 | { $$ = build_tree_list ($2, $3); } | |
028299c6 RS |
3093 | ; |
3094 | ||
3095 | selectorarg: | |
3096 | selector | |
3097 | | keywordnamelist | |
3098 | ; | |
3099 | ||
3100 | keywordnamelist: | |
3101 | keywordname | |
3102 | | keywordnamelist keywordname | |
3103 | { | |
3104 | $$ = chainon ($1, $2); | |
3105 | } | |
3106 | ; | |
3107 | ||
3108 | keywordname: | |
3109 | selector ':' | |
3110 | { | |
3111 | $$ = build_tree_list ($1, NULL_TREE); | |
3112 | } | |
3113 | | ':' | |
3114 | { | |
3115 | $$ = build_tree_list (NULL_TREE, NULL_TREE); | |
3116 | } | |
3117 | ; | |
3118 | ||
3119 | objcselectorexpr: | |
f2b5cf97 | 3120 | AT_SELECTOR '(' selectorarg ')' |
028299c6 RS |
3121 | { |
3122 | $$ = $3; | |
3123 | } | |
3124 | ; | |
3125 | ||
e31c7eec | 3126 | objcprotocolexpr: |
f2b5cf97 | 3127 | AT_PROTOCOL '(' identifier ')' |
e31c7eec TW |
3128 | { |
3129 | $$ = $3; | |
3130 | } | |
3131 | ; | |
3132 | ||
028299c6 RS |
3133 | /* extension to support C-structures in the archiver */ |
3134 | ||
3135 | objcencodeexpr: | |
f2b5cf97 | 3136 | AT_ENCODE '(' typename ')' |
028299c6 RS |
3137 | { |
3138 | $$ = groktypename ($3); | |
3139 | } | |
3140 | ; | |
3141 | ||
264fa2db | 3142 | @@end_ifobjc |
028299c6 | 3143 | %% |
0e5921e8 ZW |
3144 | |
3145 | /* yylex() is a thin wrapper around c_lex(), all it does is translate | |
3146 | cpplib.h's token codes into yacc's token codes. */ | |
0e5921e8 ZW |
3147 | |
3148 | static enum cpp_ttype last_token; | |
0e5921e8 ZW |
3149 | |
3150 | /* The reserved keyword table. */ | |
3151 | struct resword | |
3152 | { | |
3153 | const char *word; | |
3154 | ENUM_BITFIELD(rid) rid : 16; | |
3155 | unsigned int disable : 16; | |
3156 | }; | |
3157 | ||
3158 | /* Disable mask. Keywords are disabled if (reswords[i].disable & mask) is | |
3159 | _true_. */ | |
f458d1d5 ZW |
3160 | #define D_C89 0x01 /* not in C89 */ |
3161 | #define D_EXT 0x02 /* GCC extension */ | |
3162 | #define D_EXT89 0x04 /* GCC extension incorporated in C99 */ | |
3163 | #define D_OBJC 0x08 /* Objective C only */ | |
0e5921e8 ZW |
3164 | |
3165 | static const struct resword reswords[] = | |
3166 | { | |
19552aa5 | 3167 | { "_Bool", RID_BOOL, 0 }, |
d9dbd9b1 | 3168 | { "_Complex", RID_COMPLEX, 0 }, |
0ba8a114 NS |
3169 | { "__FUNCTION__", RID_FUNCTION_NAME, 0 }, |
3170 | { "__PRETTY_FUNCTION__", RID_PRETTY_FUNCTION_NAME, 0 }, | |
0e5921e8 ZW |
3171 | { "__alignof", RID_ALIGNOF, 0 }, |
3172 | { "__alignof__", RID_ALIGNOF, 0 }, | |
3173 | { "__asm", RID_ASM, 0 }, | |
3174 | { "__asm__", RID_ASM, 0 }, | |
3175 | { "__attribute", RID_ATTRIBUTE, 0 }, | |
3176 | { "__attribute__", RID_ATTRIBUTE, 0 }, | |
ecbcf7b3 | 3177 | { "__builtin_choose_expr", RID_CHOOSE_EXPR, 0 }, |
7a3ea201 | 3178 | { "__builtin_offsetof", RID_OFFSETOF, 0 }, |
ecbcf7b3 | 3179 | { "__builtin_types_compatible_p", RID_TYPES_COMPATIBLE_P, 0 }, |
0e5921e8 ZW |
3180 | { "__builtin_va_arg", RID_VA_ARG, 0 }, |
3181 | { "__complex", RID_COMPLEX, 0 }, | |
3182 | { "__complex__", RID_COMPLEX, 0 }, | |
3183 | { "__const", RID_CONST, 0 }, | |
3184 | { "__const__", RID_CONST, 0 }, | |
3185 | { "__extension__", RID_EXTENSION, 0 }, | |
0ba8a114 | 3186 | { "__func__", RID_C99_FUNCTION_NAME, 0 }, |
0e5921e8 ZW |
3187 | { "__imag", RID_IMAGPART, 0 }, |
3188 | { "__imag__", RID_IMAGPART, 0 }, | |
3189 | { "__inline", RID_INLINE, 0 }, | |
3190 | { "__inline__", RID_INLINE, 0 }, | |
3191 | { "__label__", RID_LABEL, 0 }, | |
3192 | { "__ptrbase", RID_PTRBASE, 0 }, | |
3193 | { "__ptrbase__", RID_PTRBASE, 0 }, | |
3194 | { "__ptrextent", RID_PTREXTENT, 0 }, | |
3195 | { "__ptrextent__", RID_PTREXTENT, 0 }, | |
3196 | { "__ptrvalue", RID_PTRVALUE, 0 }, | |
3197 | { "__ptrvalue__", RID_PTRVALUE, 0 }, | |
3198 | { "__real", RID_REALPART, 0 }, | |
3199 | { "__real__", RID_REALPART, 0 }, | |
3200 | { "__restrict", RID_RESTRICT, 0 }, | |
3201 | { "__restrict__", RID_RESTRICT, 0 }, | |
3202 | { "__signed", RID_SIGNED, 0 }, | |
3203 | { "__signed__", RID_SIGNED, 0 }, | |
3d78f2e9 | 3204 | { "__thread", RID_THREAD, 0 }, |
0e5921e8 ZW |
3205 | { "__typeof", RID_TYPEOF, 0 }, |
3206 | { "__typeof__", RID_TYPEOF, 0 }, | |
0e5921e8 ZW |
3207 | { "__volatile", RID_VOLATILE, 0 }, |
3208 | { "__volatile__", RID_VOLATILE, 0 }, | |
3209 | { "asm", RID_ASM, D_EXT }, | |
3210 | { "auto", RID_AUTO, 0 }, | |
3211 | { "break", RID_BREAK, 0 }, | |
3212 | { "case", RID_CASE, 0 }, | |
3213 | { "char", RID_CHAR, 0 }, | |
f458d1d5 | 3214 | { "const", RID_CONST, 0 }, |
0e5921e8 ZW |
3215 | { "continue", RID_CONTINUE, 0 }, |
3216 | { "default", RID_DEFAULT, 0 }, | |
3217 | { "do", RID_DO, 0 }, | |
3218 | { "double", RID_DOUBLE, 0 }, | |
3219 | { "else", RID_ELSE, 0 }, | |
3220 | { "enum", RID_ENUM, 0 }, | |
3221 | { "extern", RID_EXTERN, 0 }, | |
3222 | { "float", RID_FLOAT, 0 }, | |
3223 | { "for", RID_FOR, 0 }, | |
3224 | { "goto", RID_GOTO, 0 }, | |
3225 | { "if", RID_IF, 0 }, | |
f458d1d5 | 3226 | { "inline", RID_INLINE, D_EXT89 }, |
0e5921e8 ZW |
3227 | { "int", RID_INT, 0 }, |
3228 | { "long", RID_LONG, 0 }, | |
3229 | { "register", RID_REGISTER, 0 }, | |
f458d1d5 | 3230 | { "restrict", RID_RESTRICT, D_C89 }, |
0e5921e8 ZW |
3231 | { "return", RID_RETURN, 0 }, |
3232 | { "short", RID_SHORT, 0 }, | |
f458d1d5 | 3233 | { "signed", RID_SIGNED, 0 }, |
0e5921e8 ZW |
3234 | { "sizeof", RID_SIZEOF, 0 }, |
3235 | { "static", RID_STATIC, 0 }, | |
3236 | { "struct", RID_STRUCT, 0 }, | |
3237 | { "switch", RID_SWITCH, 0 }, | |
3238 | { "typedef", RID_TYPEDEF, 0 }, | |
f458d1d5 | 3239 | { "typeof", RID_TYPEOF, D_EXT }, |
0e5921e8 ZW |
3240 | { "union", RID_UNION, 0 }, |
3241 | { "unsigned", RID_UNSIGNED, 0 }, | |
3242 | { "void", RID_VOID, 0 }, | |
f458d1d5 | 3243 | { "volatile", RID_VOLATILE, 0 }, |
0e5921e8 | 3244 | { "while", RID_WHILE, 0 }, |
264fa2db | 3245 | @@ifobjc |
0e5921e8 | 3246 | { "id", RID_ID, D_OBJC }, |
b8363a24 ZW |
3247 | |
3248 | /* These objc keywords are recognized only immediately after | |
3249 | an '@'. */ | |
3250 | { "class", RID_AT_CLASS, D_OBJC }, | |
3251 | { "compatibility_alias", RID_AT_ALIAS, D_OBJC }, | |
3252 | { "defs", RID_AT_DEFS, D_OBJC }, | |
3253 | { "encode", RID_AT_ENCODE, D_OBJC }, | |
3254 | { "end", RID_AT_END, D_OBJC }, | |
3255 | { "implementation", RID_AT_IMPLEMENTATION, D_OBJC }, | |
3256 | { "interface", RID_AT_INTERFACE, D_OBJC }, | |
3257 | { "private", RID_AT_PRIVATE, D_OBJC }, | |
3258 | { "protected", RID_AT_PROTECTED, D_OBJC }, | |
3259 | { "protocol", RID_AT_PROTOCOL, D_OBJC }, | |
3260 | { "public", RID_AT_PUBLIC, D_OBJC }, | |
3261 | { "selector", RID_AT_SELECTOR, D_OBJC }, | |
264fa2db ZL |
3262 | { "throw", RID_AT_THROW, D_OBJC }, |
3263 | { "try", RID_AT_TRY, D_OBJC }, | |
3264 | { "catch", RID_AT_CATCH, D_OBJC }, | |
3265 | { "finally", RID_AT_FINALLY, D_OBJC }, | |
3266 | { "synchronized", RID_AT_SYNCHRONIZED, D_OBJC }, | |
b8363a24 ZW |
3267 | /* These are recognized only in protocol-qualifier context |
3268 | (see above) */ | |
71b7be38 ZW |
3269 | { "bycopy", RID_BYCOPY, D_OBJC }, |
3270 | { "byref", RID_BYREF, D_OBJC }, | |
3271 | { "in", RID_IN, D_OBJC }, | |
3272 | { "inout", RID_INOUT, D_OBJC }, | |
3273 | { "oneway", RID_ONEWAY, D_OBJC }, | |
3274 | { "out", RID_OUT, D_OBJC }, | |
264fa2db | 3275 | @@end_ifobjc |
0e5921e8 ZW |
3276 | }; |
3277 | #define N_reswords (sizeof reswords / sizeof (struct resword)) | |
3278 | ||
3279 | /* Table mapping from RID_* constants to yacc token numbers. | |
3280 | Unfortunately we have to have entries for all the keywords in all | |
3281 | three languages. */ | |
3282 | static const short rid_to_yy[RID_MAX] = | |
3283 | { | |
f79f2651 | 3284 | /* RID_STATIC */ STATIC, |
0e5921e8 ZW |
3285 | /* RID_UNSIGNED */ TYPESPEC, |
3286 | /* RID_LONG */ TYPESPEC, | |
3287 | /* RID_CONST */ TYPE_QUAL, | |
3288 | /* RID_EXTERN */ SCSPEC, | |
3289 | /* RID_REGISTER */ SCSPEC, | |
3290 | /* RID_TYPEDEF */ SCSPEC, | |
3291 | /* RID_SHORT */ TYPESPEC, | |
3292 | /* RID_INLINE */ SCSPEC, | |
3293 | /* RID_VOLATILE */ TYPE_QUAL, | |
3294 | /* RID_SIGNED */ TYPESPEC, | |
3295 | /* RID_AUTO */ SCSPEC, | |
3296 | /* RID_RESTRICT */ TYPE_QUAL, | |
3297 | ||
3298 | /* C extensions */ | |
0e5921e8 | 3299 | /* RID_COMPLEX */ TYPESPEC, |
3d78f2e9 | 3300 | /* RID_THREAD */ SCSPEC, |
0e5921e8 ZW |
3301 | |
3302 | /* C++ */ | |
3303 | /* RID_FRIEND */ 0, | |
3304 | /* RID_VIRTUAL */ 0, | |
3305 | /* RID_EXPLICIT */ 0, | |
3306 | /* RID_EXPORT */ 0, | |
3307 | /* RID_MUTABLE */ 0, | |
3308 | ||
3309 | /* ObjC */ | |
3310 | /* RID_IN */ TYPE_QUAL, | |
3311 | /* RID_OUT */ TYPE_QUAL, | |
3312 | /* RID_INOUT */ TYPE_QUAL, | |
3313 | /* RID_BYCOPY */ TYPE_QUAL, | |
3314 | /* RID_BYREF */ TYPE_QUAL, | |
3315 | /* RID_ONEWAY */ TYPE_QUAL, | |
84d901be | 3316 | |
0e5921e8 ZW |
3317 | /* C */ |
3318 | /* RID_INT */ TYPESPEC, | |
3319 | /* RID_CHAR */ TYPESPEC, | |
3320 | /* RID_FLOAT */ TYPESPEC, | |
3321 | /* RID_DOUBLE */ TYPESPEC, | |
3322 | /* RID_VOID */ TYPESPEC, | |
3323 | /* RID_ENUM */ ENUM, | |
3324 | /* RID_STRUCT */ STRUCT, | |
3325 | /* RID_UNION */ UNION, | |
3326 | /* RID_IF */ IF, | |
3327 | /* RID_ELSE */ ELSE, | |
3328 | /* RID_WHILE */ WHILE, | |
3329 | /* RID_DO */ DO, | |
3330 | /* RID_FOR */ FOR, | |
3331 | /* RID_SWITCH */ SWITCH, | |
3332 | /* RID_CASE */ CASE, | |
3333 | /* RID_DEFAULT */ DEFAULT, | |
3334 | /* RID_BREAK */ BREAK, | |
3335 | /* RID_CONTINUE */ CONTINUE, | |
3336 | /* RID_RETURN */ RETURN, | |
3337 | /* RID_GOTO */ GOTO, | |
3338 | /* RID_SIZEOF */ SIZEOF, | |
3339 | ||
3340 | /* C extensions */ | |
3341 | /* RID_ASM */ ASM_KEYWORD, | |
3342 | /* RID_TYPEOF */ TYPEOF, | |
3343 | /* RID_ALIGNOF */ ALIGNOF, | |
3344 | /* RID_ATTRIBUTE */ ATTRIBUTE, | |
3345 | /* RID_VA_ARG */ VA_ARG, | |
3346 | /* RID_EXTENSION */ EXTENSION, | |
3347 | /* RID_IMAGPART */ IMAGPART, | |
3348 | /* RID_REALPART */ REALPART, | |
3349 | /* RID_LABEL */ LABEL, | |
3350 | /* RID_PTRBASE */ PTR_BASE, | |
3351 | /* RID_PTREXTENT */ PTR_EXTENT, | |
3352 | /* RID_PTRVALUE */ PTR_VALUE, | |
3353 | ||
ecbcf7b3 AH |
3354 | /* RID_CHOOSE_EXPR */ CHOOSE_EXPR, |
3355 | /* RID_TYPES_COMPATIBLE_P */ TYPES_COMPATIBLE_P, | |
3356 | ||
e6cc3a24 ZW |
3357 | /* RID_FUNCTION_NAME */ FUNC_NAME, |
3358 | /* RID_PRETTY_FUNCTION_NAME */ FUNC_NAME, | |
3359 | /* RID_C99_FUNCTION_NAME */ FUNC_NAME, | |
0ba8a114 | 3360 | |
0e5921e8 | 3361 | /* C++ */ |
19552aa5 | 3362 | /* RID_BOOL */ TYPESPEC, |
0e5921e8 ZW |
3363 | /* RID_WCHAR */ 0, |
3364 | /* RID_CLASS */ 0, | |
3365 | /* RID_PUBLIC */ 0, | |
3366 | /* RID_PRIVATE */ 0, | |
3367 | /* RID_PROTECTED */ 0, | |
3368 | /* RID_TEMPLATE */ 0, | |
3369 | /* RID_NULL */ 0, | |
3370 | /* RID_CATCH */ 0, | |
3371 | /* RID_DELETE */ 0, | |
3372 | /* RID_FALSE */ 0, | |
3373 | /* RID_NAMESPACE */ 0, | |
3374 | /* RID_NEW */ 0, | |
7a3ea201 | 3375 | /* RID_OFFSETOF */ OFFSETOF, |
0e5921e8 ZW |
3376 | /* RID_OPERATOR */ 0, |
3377 | /* RID_THIS */ 0, | |
3378 | /* RID_THROW */ 0, | |
3379 | /* RID_TRUE */ 0, | |
3380 | /* RID_TRY */ 0, | |
3381 | /* RID_TYPENAME */ 0, | |
3382 | /* RID_TYPEID */ 0, | |
3383 | /* RID_USING */ 0, | |
3384 | ||
3385 | /* casts */ | |
3386 | /* RID_CONSTCAST */ 0, | |
3387 | /* RID_DYNCAST */ 0, | |
3388 | /* RID_REINTCAST */ 0, | |
3389 | /* RID_STATCAST */ 0, | |
3390 | ||
0e5921e8 ZW |
3391 | /* Objective C */ |
3392 | /* RID_ID */ OBJECTNAME, | |
f2b5cf97 DA |
3393 | /* RID_AT_ENCODE */ AT_ENCODE, |
3394 | /* RID_AT_END */ AT_END, | |
3395 | /* RID_AT_CLASS */ AT_CLASS, | |
3396 | /* RID_AT_ALIAS */ AT_ALIAS, | |
3397 | /* RID_AT_DEFS */ AT_DEFS, | |
3398 | /* RID_AT_PRIVATE */ AT_PRIVATE, | |
3399 | /* RID_AT_PROTECTED */ AT_PROTECTED, | |
3400 | /* RID_AT_PUBLIC */ AT_PUBLIC, | |
3401 | /* RID_AT_PROTOCOL */ AT_PROTOCOL, | |
3402 | /* RID_AT_SELECTOR */ AT_SELECTOR, | |
264fa2db ZL |
3403 | /* RID_AT_THROW */ AT_THROW, |
3404 | /* RID_AT_TRY */ AT_TRY, | |
3405 | /* RID_AT_CATCH */ AT_CATCH, | |
3406 | /* RID_AT_FINALLY */ AT_FINALLY, | |
3407 | /* RID_AT_SYNCHRONIZED */ AT_SYNCHRONIZED, | |
f2b5cf97 DA |
3408 | /* RID_AT_INTERFACE */ AT_INTERFACE, |
3409 | /* RID_AT_IMPLEMENTATION */ AT_IMPLEMENTATION | |
0e5921e8 ZW |
3410 | }; |
3411 | ||
3412 | static void | |
f55ade6e | 3413 | init_reswords (void) |
0e5921e8 ZW |
3414 | { |
3415 | unsigned int i; | |
3416 | tree id; | |
a3eaca15 | 3417 | int mask = (flag_isoc99 ? 0 : D_C89) |
a3eaca15 NB |
3418 | | (flag_no_asm ? (flag_isoc99 ? D_EXT : D_EXT|D_EXT89) : 0); |
3419 | ||
37fa72e9 | 3420 | if (!c_dialect_objc ()) |
a3eaca15 | 3421 | mask |= D_OBJC; |
0e5921e8 | 3422 | |
703ad42b | 3423 | ridpointers = ggc_calloc ((int) RID_MAX, sizeof (tree)); |
0e5921e8 ZW |
3424 | for (i = 0; i < N_reswords; i++) |
3425 | { | |
aac02f4e RH |
3426 | /* If a keyword is disabled, do not enter it into the table |
3427 | and so create a canonical spelling that isn't a keyword. */ | |
3428 | if (reswords[i].disable & mask) | |
3429 | continue; | |
3430 | ||
0e5921e8 ZW |
3431 | id = get_identifier (reswords[i].word); |
3432 | C_RID_CODE (id) = reswords[i].rid; | |
71b7be38 | 3433 | C_IS_RESERVED_WORD (id) = 1; |
0e5921e8 | 3434 | ridpointers [(int) reswords[i].rid] = id; |
0e5921e8 ZW |
3435 | } |
3436 | } | |
3437 | ||
0e5921e8 | 3438 | #define NAME(type) cpp_type2name (type) |
0e5921e8 ZW |
3439 | |
3440 | static void | |
f55ade6e | 3441 | yyerror (const char *msgid) |
0e5921e8 | 3442 | { |
4bb8ca28 | 3443 | c_parse_error (msgid, last_token, yylval.ttype); |
0e5921e8 ZW |
3444 | } |
3445 | ||
cc937581 | 3446 | static int |
f55ade6e | 3447 | yylexname (void) |
cc937581 ZW |
3448 | { |
3449 | tree decl; | |
84d901be | 3450 | |
264fa2db | 3451 | @@ifobjc |
f2e6e530 ZL |
3452 | int objc_force_identifier = objc_need_raw_identifier; |
3453 | OBJC_NEED_RAW_IDENTIFIER (0); | |
264fa2db | 3454 | @@end_ifobjc |
84d901be | 3455 | |
cc937581 ZW |
3456 | if (C_IS_RESERVED_WORD (yylval.ttype)) |
3457 | { | |
3458 | enum rid rid_code = C_RID_CODE (yylval.ttype); | |
0ba8a114 | 3459 | |
264fa2db | 3460 | @@ifobjc |
f2e6e530 ZL |
3461 | /* Turn non-typedefed refs to "id" into plain identifiers; this |
3462 | allows constructs like "void foo(id id);" to work. */ | |
3463 | if (rid_code == RID_ID) | |
3464 | { | |
3465 | decl = lookup_name (yylval.ttype); | |
3466 | if (decl == NULL_TREE || TREE_CODE (decl) != TYPE_DECL) | |
3467 | return IDENTIFIER; | |
3468 | } | |
3469 | ||
b8363a24 ZW |
3470 | if (!OBJC_IS_AT_KEYWORD (rid_code) |
3471 | && (!OBJC_IS_PQ_KEYWORD (rid_code) || objc_pq_context)) | |
264fa2db | 3472 | @@end_ifobjc |
4c521bad | 3473 | { |
4c521bad NB |
3474 | /* Return the canonical spelling for this keyword. */ |
3475 | yylval.ttype = ridpointers[(int) rid_code]; | |
e6cc3a24 | 3476 | return rid_to_yy[(int) rid_code]; |
4c521bad | 3477 | } |
cc937581 ZW |
3478 | } |
3479 | ||
3480 | decl = lookup_name (yylval.ttype); | |
3481 | if (decl) | |
3482 | { | |
3483 | if (TREE_CODE (decl) == TYPE_DECL) | |
3484 | return TYPENAME; | |
cc937581 | 3485 | } |
264fa2db | 3486 | @@ifobjc |
a3eaca15 | 3487 | else |
cc937581 ZW |
3488 | { |
3489 | tree objc_interface_decl = is_class_name (yylval.ttype); | |
f2e6e530 ZL |
3490 | /* ObjC class names are in the same namespace as variables and |
3491 | typedefs, and hence are shadowed by local declarations. */ | |
84d901be AD |
3492 | if (objc_interface_decl |
3493 | && (global_bindings_p () | |
f2e6e530 | 3494 | || (!objc_force_identifier && !decl))) |
cc937581 ZW |
3495 | { |
3496 | yylval.ttype = objc_interface_decl; | |
3497 | return CLASSNAME; | |
3498 | } | |
3499 | } | |
264fa2db | 3500 | @@end_ifobjc |
cc937581 ZW |
3501 | |
3502 | return IDENTIFIER; | |
3503 | } | |
3504 | ||
0e5921e8 | 3505 | static inline int |
f55ade6e | 3506 | _yylex (void) |
0e5921e8 | 3507 | { |
cc937581 | 3508 | get_next: |
0e5921e8 | 3509 | last_token = c_lex (&yylval.ttype); |
0e5921e8 ZW |
3510 | switch (last_token) |
3511 | { | |
3512 | case CPP_EQ: return '='; | |
3513 | case CPP_NOT: return '!'; | |
3514 | case CPP_GREATER: yylval.code = GT_EXPR; return ARITHCOMPARE; | |
3515 | case CPP_LESS: yylval.code = LT_EXPR; return ARITHCOMPARE; | |
3516 | case CPP_PLUS: yylval.code = PLUS_EXPR; return '+'; | |
3517 | case CPP_MINUS: yylval.code = MINUS_EXPR; return '-'; | |
3518 | case CPP_MULT: yylval.code = MULT_EXPR; return '*'; | |
3519 | case CPP_DIV: yylval.code = TRUNC_DIV_EXPR; return '/'; | |
3520 | case CPP_MOD: yylval.code = TRUNC_MOD_EXPR; return '%'; | |
3521 | case CPP_AND: yylval.code = BIT_AND_EXPR; return '&'; | |
3522 | case CPP_OR: yylval.code = BIT_IOR_EXPR; return '|'; | |
3523 | case CPP_XOR: yylval.code = BIT_XOR_EXPR; return '^'; | |
3524 | case CPP_RSHIFT: yylval.code = RSHIFT_EXPR; return RSHIFT; | |
3525 | case CPP_LSHIFT: yylval.code = LSHIFT_EXPR; return LSHIFT; | |
3526 | ||
3527 | case CPP_COMPL: return '~'; | |
3528 | case CPP_AND_AND: return ANDAND; | |
3529 | case CPP_OR_OR: return OROR; | |
3530 | case CPP_QUERY: return '?'; | |
0e5921e8 | 3531 | case CPP_OPEN_PAREN: return '('; |
0e5921e8 ZW |
3532 | case CPP_EQ_EQ: yylval.code = EQ_EXPR; return EQCOMPARE; |
3533 | case CPP_NOT_EQ: yylval.code = NE_EXPR; return EQCOMPARE; | |
3534 | case CPP_GREATER_EQ:yylval.code = GE_EXPR; return ARITHCOMPARE; | |
3535 | case CPP_LESS_EQ: yylval.code = LE_EXPR; return ARITHCOMPARE; | |
3536 | ||
3537 | case CPP_PLUS_EQ: yylval.code = PLUS_EXPR; return ASSIGN; | |
3538 | case CPP_MINUS_EQ: yylval.code = MINUS_EXPR; return ASSIGN; | |
3539 | case CPP_MULT_EQ: yylval.code = MULT_EXPR; return ASSIGN; | |
3540 | case CPP_DIV_EQ: yylval.code = TRUNC_DIV_EXPR; return ASSIGN; | |
3541 | case CPP_MOD_EQ: yylval.code = TRUNC_MOD_EXPR; return ASSIGN; | |
3542 | case CPP_AND_EQ: yylval.code = BIT_AND_EXPR; return ASSIGN; | |
3543 | case CPP_OR_EQ: yylval.code = BIT_IOR_EXPR; return ASSIGN; | |
3544 | case CPP_XOR_EQ: yylval.code = BIT_XOR_EXPR; return ASSIGN; | |
3545 | case CPP_RSHIFT_EQ: yylval.code = RSHIFT_EXPR; return ASSIGN; | |
3546 | case CPP_LSHIFT_EQ: yylval.code = LSHIFT_EXPR; return ASSIGN; | |
3547 | ||
3548 | case CPP_OPEN_SQUARE: return '['; | |
3549 | case CPP_CLOSE_SQUARE: return ']'; | |
3550 | case CPP_OPEN_BRACE: return '{'; | |
3551 | case CPP_CLOSE_BRACE: return '}'; | |
0e5921e8 ZW |
3552 | case CPP_ELLIPSIS: return ELLIPSIS; |
3553 | ||
3554 | case CPP_PLUS_PLUS: return PLUSPLUS; | |
3555 | case CPP_MINUS_MINUS: return MINUSMINUS; | |
3556 | case CPP_DEREF: return POINTSAT; | |
3557 | case CPP_DOT: return '.'; | |
3558 | ||
f2e6e530 ZL |
3559 | /* The following tokens may affect the interpretation of any |
3560 | identifiers following, if doing Objective-C. */ | |
3561 | case CPP_COLON: OBJC_NEED_RAW_IDENTIFIER (0); return ':'; | |
3562 | case CPP_COMMA: OBJC_NEED_RAW_IDENTIFIER (0); return ','; | |
3563 | case CPP_CLOSE_PAREN: OBJC_NEED_RAW_IDENTIFIER (0); return ')'; | |
3564 | case CPP_SEMICOLON: OBJC_NEED_RAW_IDENTIFIER (0); return ';'; | |
3565 | ||
0e5921e8 | 3566 | case CPP_EOF: |
ef6e958a | 3567 | return 0; |
0e5921e8 ZW |
3568 | |
3569 | case CPP_NAME: | |
e6cc3a24 ZW |
3570 | return yylexname (); |
3571 | ||
3572 | case CPP_AT_NAME: | |
3573 | /* This only happens in Objective-C; it must be a keyword. */ | |
3574 | return rid_to_yy [(int) C_RID_CODE (yylval.ttype)]; | |
0e5921e8 | 3575 | |
0e5921e8 ZW |
3576 | case CPP_NUMBER: |
3577 | case CPP_CHAR: | |
3578 | case CPP_WCHAR: | |
3579 | return CONSTANT; | |
3580 | ||
3581 | case CPP_STRING: | |
3582 | case CPP_WSTRING: | |
e6cc3a24 | 3583 | return STRING; |
e13e48e7 | 3584 | |
e6cc3a24 ZW |
3585 | case CPP_OBJC_STRING: |
3586 | return OBJC_STRING; | |
b8363a24 | 3587 | |
0e5921e8 ZW |
3588 | /* These tokens are C++ specific (and will not be generated |
3589 | in C mode, but let's be cautious). */ | |
3590 | case CPP_SCOPE: | |
3591 | case CPP_DEREF_STAR: | |
3592 | case CPP_DOT_STAR: | |
3593 | case CPP_MIN_EQ: | |
3594 | case CPP_MAX_EQ: | |
3595 | case CPP_MIN: | |
3596 | case CPP_MAX: | |
3597 | /* These tokens should not survive translation phase 4. */ | |
3598 | case CPP_HASH: | |
3599 | case CPP_PASTE: | |
cc937581 ZW |
3600 | error ("syntax error at '%s' token", NAME(last_token)); |
3601 | goto get_next; | |
0e5921e8 ZW |
3602 | |
3603 | default: | |
3604 | abort (); | |
3605 | } | |
0e5921e8 ZW |
3606 | /* NOTREACHED */ |
3607 | } | |
3608 | ||
3609 | static int | |
f55ade6e | 3610 | yylex (void) |
0e5921e8 ZW |
3611 | { |
3612 | int r; | |
3613 | timevar_push (TV_LEX); | |
3614 | r = _yylex(); | |
3615 | timevar_pop (TV_LEX); | |
3616 | return r; | |
3617 | } | |
3618 | ||
0e5921e8 ZW |
3619 | /* Function used when yydebug is set, to print a token in more detail. */ |
3620 | ||
3621 | static void | |
f55ade6e | 3622 | yyprint (FILE *file, int yychar, YYSTYPE yyl) |
0e5921e8 ZW |
3623 | { |
3624 | tree t = yyl.ttype; | |
3625 | ||
3626 | fprintf (file, " [%s]", NAME(last_token)); | |
84d901be | 3627 | |
0e5921e8 ZW |
3628 | switch (yychar) |
3629 | { | |
3630 | case IDENTIFIER: | |
3631 | case TYPENAME: | |
3632 | case OBJECTNAME: | |
3633 | case TYPESPEC: | |
3634 | case TYPE_QUAL: | |
3635 | case SCSPEC: | |
f79f2651 | 3636 | case STATIC: |
0e5921e8 ZW |
3637 | if (IDENTIFIER_POINTER (t)) |
3638 | fprintf (file, " `%s'", IDENTIFIER_POINTER (t)); | |
3639 | break; | |
3640 | ||
3641 | case CONSTANT: | |
3642 | fprintf (file, " %s", GET_MODE_NAME (TYPE_MODE (TREE_TYPE (t)))); | |
3643 | if (TREE_CODE (t) == INTEGER_CST) | |
c14bc6db AJ |
3644 | { |
3645 | fputs (" ", file); | |
3646 | fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX, | |
3647 | TREE_INT_CST_HIGH (t), TREE_INT_CST_LOW (t)); | |
3648 | } | |
0e5921e8 ZW |
3649 | break; |
3650 | } | |
3651 | } | |
3652 | \f | |
f75fbaf7 ZW |
3653 | /* This is not the ideal place to put this, but we have to get it out |
3654 | of c-lex.c because cp/lex.c has its own version. */ | |
0e5921e8 | 3655 | |
d1bd0ded GK |
3656 | /* Parse the file. */ |
3657 | void | |
3658 | c_parse_file (void) | |
3659 | { | |
3660 | yyparse (); | |
d1bd0ded | 3661 | |
94a50397 RH |
3662 | if (malloced_yyss) |
3663 | { | |
3664 | free (malloced_yyss); | |
3665 | free (malloced_yyvs); | |
d1bd0ded | 3666 | malloced_yyss = 0; |
94a50397 RH |
3667 | } |
3668 | } | |
e2500fed GK |
3669 | |
3670 | #include "gt-c-parse.h" |