]>
Commit | Line | Data |
---|---|---|
8d08fdba | 1 | /* YACC parser for C++ syntax. |
357a4089 | 2 | Copyright (C) 1988, 89, 93, 94, 95, 1996 Free Software Foundation, Inc. |
8d08fdba MS |
3 | Hacked by Michael Tiemann (tiemann@cygnus.com) |
4 | ||
5 | This file is part of GNU CC. | |
6 | ||
7 | GNU CC is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2, or (at your option) | |
10 | any later version. | |
11 | ||
12 | GNU CC is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with GNU CC; see the file COPYING. If not, write to | |
e9fa0c7c RK |
19 | the Free Software Foundation, 59 Temple Place - Suite 330, |
20 | Boston, MA 02111-1307, USA. */ | |
8d08fdba MS |
21 | |
22 | ||
23 | /* This grammar is based on the GNU CC grammar. */ | |
24 | ||
25 | /* Note: Bison automatically applies a default action of "$$ = $1" for | |
26 | all derivations; this is applied before the explicit action, if one | |
27 | is given. Keep this in mind when reading the actions. */ | |
28 | ||
8d08fdba | 29 | %{ |
8926095f | 30 | /* Cause the `yydebug' variable to be defined. */ |
8d08fdba | 31 | #define YYDEBUG 1 |
8d08fdba MS |
32 | |
33 | #include "config.h" | |
34 | ||
35 | #include <stdio.h> | |
36 | #include <errno.h> | |
37 | ||
38 | #include "tree.h" | |
39 | #include "input.h" | |
40 | #include "flags.h" | |
41 | #include "lex.h" | |
42 | #include "cp-tree.h" | |
e8abc66f | 43 | #include "output.h" |
8d08fdba MS |
44 | |
45 | /* Since parsers are distinct for each language, put the language string | |
46 | definition here. (fnf) */ | |
47 | char *language_string = "GNU C++"; | |
48 | ||
49 | extern tree void_list_node; | |
50 | extern struct obstack permanent_obstack; | |
51 | ||
52 | #ifndef errno | |
53 | extern int errno; | |
54 | #endif | |
55 | ||
56 | extern int end_of_file; | |
a28e3c7f | 57 | extern int current_class_depth; |
5566b478 | 58 | extern tree last_tree; |
8d08fdba | 59 | |
37539f4f MS |
60 | /* FSF LOCAL dje prefix attributes */ |
61 | extern tree strip_attrs PROTO((tree)); | |
62 | /* END FSF LOCAL */ | |
63 | ||
8d08fdba MS |
64 | void yyerror (); |
65 | ||
66 | /* Like YYERROR but do call yyerror. */ | |
67 | #define YYERROR1 { yyerror ("syntax error"); YYERROR; } | |
68 | ||
a28e3c7f MS |
69 | #define OP0(NODE) (TREE_OPERAND (NODE, 0)) |
70 | #define OP1(NODE) (TREE_OPERAND (NODE, 1)) | |
71 | ||
8d08fdba MS |
72 | /* Contains the statement keyword (if/while/do) to include in an |
73 | error message if the user supplies an empty conditional expression. */ | |
74 | static char *cond_stmt_keyword; | |
75 | ||
76 | /* Nonzero if we have an `extern "C"' acting as an extern specifier. */ | |
77 | int have_extern_spec; | |
78 | int used_extern_spec; | |
79 | ||
80 | void yyhook (); | |
81 | ||
82 | /* Cons up an empty parameter list. */ | |
83 | #ifdef __GNUC__ | |
84 | __inline | |
85 | #endif | |
86 | static tree | |
87 | empty_parms () | |
88 | { | |
89 | tree parms; | |
90 | ||
67d743fe MS |
91 | if (strict_prototype |
92 | || current_class_type != NULL) | |
8d08fdba MS |
93 | parms = void_list_node; |
94 | else | |
95 | parms = NULL_TREE; | |
96 | return parms; | |
97 | } | |
98 | %} | |
99 | ||
100 | %start program | |
101 | ||
46b02c6d | 102 | %union {long itype; tree ttype; char *strtype; enum tree_code code; flagged_type_tree ftype; } |
8d08fdba MS |
103 | |
104 | /* All identifiers that are not reserved words | |
105 | and are not declared typedefs in the current block */ | |
106 | %token IDENTIFIER | |
107 | ||
108 | /* All identifiers that are declared typedefs in the current block. | |
109 | In some contexts, they are treated just like IDENTIFIER, | |
110 | but they can also serve as typespecs in declarations. */ | |
111 | %token TYPENAME | |
a80e4195 | 112 | %token SELFNAME |
8d08fdba | 113 | |
8d08fdba MS |
114 | /* Reserved words that specify storage class. |
115 | yylval contains an IDENTIFIER_NODE which indicates which one. */ | |
116 | %token SCSPEC | |
117 | ||
118 | /* Reserved words that specify type. | |
119 | yylval contains an IDENTIFIER_NODE which indicates which one. */ | |
120 | %token TYPESPEC | |
121 | ||
122 | /* Reserved words that qualify type: "const" or "volatile". | |
123 | yylval contains an IDENTIFIER_NODE which indicates which one. */ | |
124 | %token TYPE_QUAL | |
125 | ||
126 | /* Character or numeric constants. | |
127 | yylval is the node for the constant. */ | |
128 | %token CONSTANT | |
129 | ||
130 | /* String constants in raw form. | |
131 | yylval is a STRING_CST node. */ | |
132 | %token STRING | |
133 | ||
134 | /* "...", used for functions with variable arglists. */ | |
135 | %token ELLIPSIS | |
136 | ||
137 | /* the reserved words */ | |
e92cc029 | 138 | /* SCO include files test "ASM", so use something else. */ |
8d08fdba MS |
139 | %token SIZEOF ENUM /* STRUCT UNION */ IF ELSE WHILE DO FOR SWITCH CASE DEFAULT |
140 | %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD GCC_ASM_KEYWORD TYPEOF ALIGNOF | |
f30432d7 | 141 | %token SIGOF |
8d08fdba MS |
142 | %token ATTRIBUTE EXTENSION LABEL |
143 | ||
144 | /* the reserved words... C++ extensions */ | |
145 | %token <ttype> AGGR | |
be99da77 | 146 | %token <ttype> VISSPEC |
2986ae00 | 147 | %token DELETE NEW OVERLOAD THIS OPERATOR CXX_TRUE CXX_FALSE |
db5ae43f | 148 | %token NAMESPACE TYPENAME_KEYWORD USING |
8d08fdba | 149 | %token LEFT_RIGHT TEMPLATE |
a4443a08 | 150 | %token TYPEID DYNAMIC_CAST STATIC_CAST REINTERPRET_CAST CONST_CAST |
8d08fdba MS |
151 | %token <itype> SCOPE |
152 | ||
8d08fdba MS |
153 | /* Define the operator tokens and their precedences. |
154 | The value is an integer because, if used, it is the tree code | |
155 | to use in the expression made from the operator. */ | |
156 | ||
157 | %left EMPTY /* used to resolve s/r with epsilon */ | |
158 | ||
159 | %left error | |
160 | ||
161 | /* Add precedence rules to solve dangling else s/r conflict */ | |
162 | %nonassoc IF | |
163 | %nonassoc ELSE | |
164 | ||
a80e4195 | 165 | %left IDENTIFIER TYPENAME SELFNAME PTYPENAME SCSPEC TYPESPEC TYPE_QUAL ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD |
8d08fdba MS |
166 | |
167 | %left '{' ',' ';' | |
168 | ||
db5ae43f | 169 | %nonassoc THROW |
6060a796 | 170 | %right <code> ':' |
8d08fdba | 171 | %right <code> ASSIGN '=' |
6060a796 | 172 | %right <code> '?' |
8d08fdba MS |
173 | %left <code> OROR |
174 | %left <code> ANDAND | |
175 | %left <code> '|' | |
176 | %left <code> '^' | |
177 | %left <code> '&' | |
178 | %left <code> MIN_MAX | |
179 | %left <code> EQCOMPARE | |
180 | %left <code> ARITHCOMPARE '<' '>' | |
181 | %left <code> LSHIFT RSHIFT | |
182 | %left <code> '+' '-' | |
183 | %left <code> '*' '/' '%' | |
51c184be MS |
184 | %left <code> POINTSAT_STAR DOT_STAR |
185 | %right <code> UNARY PLUSPLUS MINUSMINUS '~' | |
8d08fdba MS |
186 | %left HYPERUNARY |
187 | %left <ttype> PAREN_STAR_PAREN LEFT_RIGHT | |
51c184be | 188 | %left <code> POINTSAT '.' '(' '[' |
8d08fdba MS |
189 | |
190 | %right SCOPE /* C++ extension */ | |
db5ae43f | 191 | %nonassoc NEW DELETE TRY CATCH |
8d08fdba MS |
192 | |
193 | %type <code> unop | |
194 | ||
195 | %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist | |
a80e4195 | 196 | %type <ttype> paren_expr_or_null nontrivial_exprlist SELFNAME |
8d08fdba | 197 | %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING |
46b02c6d MS |
198 | %type <ttype> reserved_declspecs boolean.literal |
199 | %type <ttype> reserved_typespecquals | |
200 | %type <ttype> declmods | |
201 | %type <ttype> SCSPEC TYPESPEC TYPE_QUAL maybe_type_qual | |
8d08fdba | 202 | %type <itype> initdecls notype_initdecls initdcl /* C++ modification */ |
e3417fcd | 203 | %type <ttype> init initlist maybeasm maybe_init |
8d08fdba | 204 | %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers |
2986ae00 MS |
205 | %type <ttype> maybe_attribute attributes attribute attribute_list attrib |
206 | %type <ttype> any_word | |
8d08fdba | 207 | |
8d2733ca | 208 | %type <ttype> compstmt implicitly_scoped_stmt |
8d08fdba MS |
209 | |
210 | %type <ttype> declarator notype_declarator after_type_declarator | |
51c184be | 211 | %type <ttype> direct_notype_declarator direct_after_type_declarator |
8d08fdba | 212 | |
46b02c6d | 213 | %type <ttype> opt.component_decl_list component_decl_list |
f30432d7 | 214 | %type <ttype> component_decl component_decl_1 components notype_components |
c91a56d2 | 215 | %type <ttype> component_declarator component_declarator0 self_reference |
f30432d7 | 216 | %type <ttype> notype_component_declarator notype_component_declarator0 |
51c184be | 217 | %type <ttype> after_type_component_declarator after_type_component_declarator0 |
8d08fdba | 218 | %type <ttype> enumlist enumerator |
46b02c6d | 219 | %type <ttype> absdcl type_quals |
51c184be | 220 | %type <ttype> direct_abstract_declarator conversion_declarator |
46b02c6d MS |
221 | %type <ttype> new_declarator direct_new_declarator |
222 | %type <ttype> xexpr parmlist parms bad_parm | |
8d08fdba | 223 | %type <ttype> identifiers_or_typenames |
f30432d7 | 224 | %type <ttype> fcast_or_absdcl regcast_or_absdcl |
a28e3c7f MS |
225 | %type <ttype> expr_or_declarator complex_notype_declarator |
226 | %type <ttype> notype_unqualified_id unqualified_id qualified_id | |
6060a796 | 227 | %type <ttype> overqualified_id notype_qualified_id any_id |
51c184be | 228 | %type <ttype> complex_direct_notype_declarator functional_cast |
46b02c6d MS |
229 | %type <ttype> complex_parmlist parms_comma |
230 | ||
231 | %type <ftype> type_id new_type_id typed_typespecs typespec typed_declspecs | |
232 | %type <ftype> typed_declspecs1 type_specifier_seq nonempty_type_quals | |
233 | %type <ftype> structsp typespecqual_reserved parm named_parm full_parm | |
8d08fdba MS |
234 | |
235 | /* C++ extensions */ | |
a28e3c7f | 236 | %token <ttype> TYPENAME_ELLIPSIS PTYPENAME |
8d08fdba MS |
237 | %token <ttype> PRE_PARSED_FUNCTION_DECL EXTERN_LANG_STRING ALL |
238 | %token <ttype> PRE_PARSED_CLASS_DECL | |
a80e4195 | 239 | %type <ttype> fn.def1 /* Not really! */ component_constructor_declarator |
c91a56d2 | 240 | %type <ttype> fn.def2 return_id fn.defpen constructor_declarator |
f30432d7 | 241 | %type <itype> ctor_initializer_opt |
8d08fdba | 242 | %type <ttype> named_class_head named_class_head_sans_basetype |
07674418 | 243 | %type <ttype> named_complex_class_head_sans_basetype |
8d08fdba MS |
244 | %type <ttype> unnamed_class_head |
245 | %type <ttype> class_head base_class_list | |
be99da77 | 246 | %type <ttype> base_class_access_list |
8d08fdba | 247 | %type <ttype> base_class maybe_base_class_list base_class.1 |
e3417fcd | 248 | %type <ttype> exception_specification_opt ansi_raise_identifier ansi_raise_identifiers |
863adfc0 | 249 | %type <ttype> operator_name |
39211cd5 MS |
250 | %type <ttype> object aggr |
251 | %type <itype> new delete | |
8d08fdba | 252 | /* %type <ttype> primary_no_id */ |
a5894242 | 253 | %type <ttype> nonmomentary_expr maybe_parmlist |
863adfc0 | 254 | %type <itype> initdcl0 notype_initdcl0 member_init_list |
8d08fdba | 255 | %type <ttype> template_header template_parm_list template_parm |
a292b002 | 256 | %type <ttype> template_type_parm |
5566b478 | 257 | %type <code> template_close_bracket |
8d08fdba | 258 | %type <ttype> template_type template_arg_list template_arg |
8d08fdba | 259 | /* %type <itype> try_for_typename */ |
8d2733ca | 260 | %type <ttype> condition xcond paren_cond_or_null |
a28e3c7f | 261 | %type <ttype> type_name nested_name_specifier nested_type ptr_to_mem |
cffa8729 | 262 | %type <ttype> complete_type_name notype_identifier |
a28e3c7f MS |
263 | %type <ttype> complex_type_name nested_name_specifier_1 |
264 | %type <itype> nomods_initdecls nomods_initdcl0 | |
46b02c6d | 265 | %type <ttype> new_initializer new_placement |
863adfc0 | 266 | %type <ttype> using_decl .poplevel |
8d08fdba | 267 | |
e92cc029 | 268 | /* in order to recognize aggr tags as defining and thus shadowing. */ |
8d08fdba | 269 | %token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN |
5566b478 | 270 | %type <ttype> named_class_head_sans_basetype_defn |
8d08fdba MS |
271 | %type <ttype> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN |
272 | ||
67d743fe MS |
273 | %type <ttype> self_template_type |
274 | ||
6060a796 MS |
275 | %token NSNAME |
276 | %type <ttype> NSNAME | |
277 | ||
d18c083e MS |
278 | /* Used in lex.c for parsing pragmas. */ |
279 | %token END_OF_LINE | |
280 | ||
5566b478 | 281 | /* lex.c and pt.c depend on this being the last token. Define |
8d08fdba MS |
282 | any new tokens before this one! */ |
283 | %token END_OF_SAVED_INPUT | |
284 | \f | |
285 | %{ | |
286 | /* List of types and structure classes of the current declaration. */ | |
287 | static tree current_declspecs; | |
f30432d7 MS |
288 | /* List of prefix attributes in effect. |
289 | Prefix attributes are parsed by the reserved_declspecs and declmods | |
290 | rules. They create a list that contains *both* declspecs and attrs. */ | |
291 | /* ??? It is not clear yet that all cases where an attribute can now appear in | |
292 | a declspec list have been updated. */ | |
293 | static tree prefix_attributes; | |
8d08fdba MS |
294 | |
295 | /* When defining an aggregate, this is the most recent one being defined. */ | |
296 | static tree current_aggr; | |
297 | ||
298 | /* Tell yyparse how to print a token's value, if yydebug is set. */ | |
299 | ||
300 | #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL) | |
301 | extern void yyprint (); | |
302 | extern tree combine_strings PROTO((tree)); | |
8d08fdba MS |
303 | %} |
304 | \f | |
305 | %% | |
306 | program: /* empty */ | |
307 | | extdefs | |
308 | { | |
309 | /* In case there were missing closebraces, | |
310 | get us back to the global binding level. */ | |
311 | while (! global_bindings_p ()) | |
312 | poplevel (0, 0, 0); | |
313 | finish_file (); | |
314 | } | |
315 | ; | |
316 | ||
317 | /* the reason for the strange actions in this rule | |
318 | is so that notype_initdecls when reached via datadef | |
e92cc029 | 319 | can find a valid list of type and sc specs in $0. */ |
8d08fdba MS |
320 | |
321 | extdefs: | |
322 | { $<ttype>$ = NULL_TREE; } lang_extdef | |
323 | { $<ttype>$ = NULL_TREE; } | |
324 | | extdefs lang_extdef | |
325 | { $<ttype>$ = NULL_TREE; } | |
326 | ; | |
327 | ||
6060a796 MS |
328 | extdefs_opt: |
329 | extdefs | |
330 | | /* empty */ | |
331 | ; | |
332 | ||
8d08fdba MS |
333 | .hush_warning: |
334 | { have_extern_spec = 1; | |
335 | used_extern_spec = 0; | |
336 | $<ttype>$ = NULL_TREE; } | |
337 | ; | |
338 | .warning_ok: | |
339 | { have_extern_spec = 0; } | |
340 | ; | |
341 | ||
342 | asm_keyword: | |
2986ae00 | 343 | ASM_KEYWORD |
8d08fdba MS |
344 | | GCC_ASM_KEYWORD |
345 | ; | |
346 | ||
347 | lang_extdef: | |
348 | { if (pending_lang_change) do_pending_lang_change(); } | |
349 | extdef | |
a9aedbc2 | 350 | { if (! toplevel_bindings_p () && ! pseudo_global_level_p()) |
f30432d7 | 351 | pop_everything (); } |
8d08fdba MS |
352 | ; |
353 | ||
354 | extdef: | |
355 | fndef | |
356 | { if (pending_inlines) do_pending_inlines (); } | |
357 | | datadef | |
358 | { if (pending_inlines) do_pending_inlines (); } | |
359 | | template_def | |
360 | { if (pending_inlines) do_pending_inlines (); } | |
361 | | overloaddef | |
362 | | asm_keyword '(' string ')' ';' | |
363 | { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); | |
364 | assemble_asm ($3); } | |
6060a796 | 365 | | extern_lang_string '{' extdefs_opt '}' |
8d08fdba MS |
366 | { pop_lang_context (); } |
367 | | extern_lang_string .hush_warning fndef .warning_ok | |
368 | { if (pending_inlines) do_pending_inlines (); | |
369 | pop_lang_context (); } | |
370 | | extern_lang_string .hush_warning datadef .warning_ok | |
371 | { if (pending_inlines) do_pending_inlines (); | |
372 | pop_lang_context (); } | |
6060a796 MS |
373 | | NAMESPACE identifier '{' |
374 | { push_namespace ($2); } | |
375 | extdefs_opt '}' | |
376 | { pop_namespace (); } | |
377 | | NAMESPACE '{' | |
378 | { push_namespace (NULL_TREE); } | |
379 | extdefs_opt '}' | |
380 | { pop_namespace (); } | |
381 | | NAMESPACE identifier '=' any_id ';' | |
382 | { do_namespace_alias ($2, $4); } | |
383 | | using_decl ';' | |
a9aedbc2 | 384 | { do_toplevel_using_decl ($1); } |
6060a796 MS |
385 | | USING NAMESPACE any_id ';' |
386 | { do_using_directive ($3); } | |
387 | ; | |
388 | ||
389 | using_decl: | |
390 | USING qualified_id | |
a9aedbc2 | 391 | { $$ = $2; } |
6060a796 | 392 | | USING global_scope qualified_id |
a9aedbc2 | 393 | { $$ = $3; } |
6060a796 | 394 | | USING global_scope unqualified_id |
a9aedbc2 | 395 | { $$ = $3; } |
6060a796 MS |
396 | ; |
397 | ||
398 | any_id: | |
399 | unqualified_id | |
400 | | qualified_id | |
401 | | global_scope qualified_id | |
402 | { $$ = $2; } | |
403 | | global_scope unqualified_id | |
404 | { $$ = $2; } | |
8d08fdba MS |
405 | ; |
406 | ||
407 | extern_lang_string: | |
28cbf42c | 408 | EXTERN_LANG_STRING |
8d08fdba | 409 | { push_lang_context ($1); } |
28cbf42c MS |
410 | | extern_lang_string EXTERN_LANG_STRING |
411 | { if (current_lang_name != $2) | |
412 | cp_error ("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name); | |
413 | pop_lang_context (); push_lang_context ($2); } | |
8d08fdba MS |
414 | ; |
415 | ||
416 | template_header: | |
417 | TEMPLATE '<' | |
418 | { begin_template_parm_list (); } | |
419 | template_parm_list '>' | |
420 | { $$ = end_template_parm_list ($4); } | |
73aad9b9 JM |
421 | | TEMPLATE '<' '>' |
422 | { $$ = NULL_TREE; } | |
8d08fdba MS |
423 | ; |
424 | ||
425 | template_parm_list: | |
426 | template_parm | |
427 | { $$ = process_template_parm (NULL_TREE, $1); } | |
428 | | template_parm_list ',' template_parm | |
429 | { $$ = process_template_parm ($1, $3); } | |
430 | ; | |
431 | ||
a292b002 MS |
432 | template_type_parm: |
433 | aggr | |
434 | { | |
435 | $$ = build_tree_list ($1, NULL_TREE); | |
436 | ttpa: | |
437 | if (TREE_PURPOSE ($$) == signature_type_node) | |
438 | sorry ("signature as template type parameter"); | |
439 | else if (TREE_PURPOSE ($$) != class_type_node) | |
ec255269 MS |
440 | { |
441 | pedwarn ("template type parameters must use the keyword `class'"); | |
442 | TREE_PURPOSE ($$) = class_type_node; | |
443 | } | |
a292b002 MS |
444 | } |
445 | | aggr identifier | |
446 | { $$ = build_tree_list ($1, $2); goto ttpa; } | |
f30432d7 MS |
447 | | TYPENAME_KEYWORD |
448 | { $$ = build_tree_list (class_type_node, NULL_TREE); } | |
449 | | TYPENAME_KEYWORD identifier | |
450 | { $$ = build_tree_list (class_type_node, $2); } | |
a292b002 MS |
451 | ; |
452 | ||
8d08fdba MS |
453 | template_parm: |
454 | /* The following rules introduce a new reduce/reduce | |
51c184be MS |
455 | conflict on the ',' and '>' input tokens: they are valid |
456 | prefixes for a `structsp', which means they could match a | |
457 | nameless parameter. See 14.6, paragraph 3. | |
8d08fdba MS |
458 | By putting them before the `parm' rule, we get |
459 | their match before considering them nameless parameter | |
460 | declarations. */ | |
a292b002 | 461 | template_type_parm |
5566b478 MS |
462 | { $$ = build_tree_list (NULL_TREE, $1); } |
463 | | template_type_parm '=' type_id | |
46b02c6d | 464 | { $$ = build_tree_list (groktypename ($3.t), $1); } |
5566b478 | 465 | | parm |
46b02c6d | 466 | { $$ = build_tree_list (NULL_TREE, $1.t); } |
5566b478 | 467 | | parm '=' expr_no_commas %prec ARITHCOMPARE |
46b02c6d | 468 | { $$ = build_tree_list ($3, $1.t); } |
8d08fdba MS |
469 | ; |
470 | ||
471 | overloaddef: | |
472 | OVERLOAD ov_identifiers ';' | |
473 | { warning ("use of `overload' is an anachronism"); } | |
474 | ; | |
475 | ||
476 | ov_identifiers: IDENTIFIER | |
477 | { declare_overloaded ($1); } | |
478 | | ov_identifiers ',' IDENTIFIER | |
479 | { declare_overloaded ($3); } | |
480 | ; | |
8d08fdba | 481 | |
5566b478 MS |
482 | template_def: |
483 | template_header | |
484 | extdef | |
485 | { end_template_decl (); } | |
486 | | template_header | |
487 | error %prec EMPTY | |
488 | { end_template_decl (); } | |
8d08fdba MS |
489 | ; |
490 | ||
491 | datadef: | |
a28e3c7f MS |
492 | nomods_initdecls ';' |
493 | {} | |
8d08fdba MS |
494 | | declmods notype_initdecls ';' |
495 | {} | |
51c184be MS |
496 | /* Normal case to make fast: "const i;". */ |
497 | | declmods notype_declarator ';' | |
f30432d7 MS |
498 | { tree d, specs, attrs; |
499 | split_specs_attrs ($1, &specs, &attrs); | |
500 | d = start_decl ($<ttype>2, specs, 0, NULL_TREE); | |
501 | cplus_decl_attributes (d, NULL_TREE, attrs); | |
9e9ff709 | 502 | cp_finish_decl (d, NULL_TREE, NULL_TREE, 1, 0); |
8d08fdba MS |
503 | } |
504 | | typed_declspecs initdecls ';' | |
505 | { | |
46b02c6d | 506 | note_list_got_semicolon ($1.t); |
8d08fdba MS |
507 | } |
508 | /* Normal case: make this fast. */ | |
509 | | typed_declspecs declarator ';' | |
f30432d7 | 510 | { tree d, specs, attrs; |
46b02c6d | 511 | split_specs_attrs ($1.t, &specs, &attrs); |
fc378698 | 512 | note_list_got_semicolon (specs); |
46b02c6d | 513 | d = start_decl ($2, specs, 0, NULL_TREE); |
f30432d7 | 514 | cplus_decl_attributes (d, NULL_TREE, attrs); |
9e9ff709 | 515 | cp_finish_decl (d, NULL_TREE, NULL_TREE, 1, 0); |
8d08fdba MS |
516 | } |
517 | | declmods ';' | |
518 | { pedwarn ("empty declaration"); } | |
519 | | explicit_instantiation ';' | |
520 | | typed_declspecs ';' | |
521 | { | |
f30432d7 | 522 | tree t, attrs; |
46b02c6d | 523 | split_specs_attrs ($1.t, &t, &attrs); |
8d08fdba | 524 | shadow_tag (t); |
46b02c6d | 525 | note_list_got_semicolon ($1.t); |
8d08fdba MS |
526 | } |
527 | | error ';' | |
528 | | error '}' | |
529 | | ';' | |
530 | ; | |
531 | ||
f30432d7 MS |
532 | ctor_initializer_opt: |
533 | nodecls | |
534 | { $$ = 0; } | |
535 | | base_init | |
536 | { $$ = 1; } | |
537 | ; | |
8d08fdba | 538 | |
f30432d7 MS |
539 | maybe_return_init: |
540 | /* empty */ | |
541 | | return_init | |
542 | | return_init ';' | |
543 | ; | |
8d08fdba | 544 | |
f30432d7 MS |
545 | eat_saved_input: |
546 | /* empty */ | |
547 | | END_OF_SAVED_INPUT | |
548 | ; | |
549 | ||
550 | fndef: | |
551 | fn.def1 maybe_return_init ctor_initializer_opt compstmt_or_error | |
5566b478 | 552 | { finish_function (lineno, (int)$3, 0); } |
f30432d7 | 553 | | fn.def1 maybe_return_init function_try_block |
5566b478 | 554 | { if ($<ttype>$) process_next_inline ($<ttype>$); } |
f30432d7 | 555 | eat_saved_input |
8d08fdba MS |
556 | | typed_declspecs declarator error |
557 | {} | |
558 | | declmods notype_declarator error | |
559 | {} | |
560 | | notype_declarator error | |
561 | {} | |
562 | ; | |
563 | ||
c91a56d2 | 564 | constructor_declarator: |
a80e4195 | 565 | nested_name_specifier SELFNAME '(' |
c91a56d2 MS |
566 | { |
567 | $$ = build_parse_node (SCOPE_REF, $1, $2); | |
568 | if ($1 != current_class_type) | |
569 | { | |
570 | push_nested_class ($1, 3); | |
571 | TREE_COMPLEXITY ($$) = current_class_depth; | |
572 | } | |
573 | } | |
574 | parmlist ')' type_quals | |
575 | { $$ = build_parse_node (CALL_EXPR, $<ttype>4, $5, $7); } | |
a80e4195 | 576 | | nested_name_specifier SELFNAME LEFT_RIGHT type_quals |
c91a56d2 MS |
577 | { |
578 | $$ = build_parse_node (SCOPE_REF, $1, $2); | |
579 | if ($1 != current_class_type) | |
580 | { | |
581 | push_nested_class ($1, 3); | |
582 | TREE_COMPLEXITY ($$) = current_class_depth; | |
583 | } | |
584 | $$ = build_parse_node (CALL_EXPR, $$, empty_parms (), $4); | |
585 | } | |
a80e4195 | 586 | | global_scope nested_name_specifier SELFNAME '(' |
c91a56d2 MS |
587 | { |
588 | $$ = build_parse_node (SCOPE_REF, $2, $3); | |
589 | if ($2 != current_class_type) | |
590 | { | |
591 | push_nested_class ($2, 3); | |
592 | TREE_COMPLEXITY ($$) = current_class_depth; | |
593 | } | |
594 | } | |
595 | parmlist ')' type_quals | |
596 | { $$ = build_parse_node (CALL_EXPR, $<ttype>5, $6, $8); } | |
a80e4195 | 597 | | global_scope nested_name_specifier SELFNAME LEFT_RIGHT type_quals |
c91a56d2 MS |
598 | { |
599 | $$ = build_parse_node (SCOPE_REF, $2, $3); | |
600 | if ($2 != current_class_type) | |
601 | { | |
602 | push_nested_class ($2, 3); | |
603 | TREE_COMPLEXITY ($$) = current_class_depth; | |
604 | } | |
605 | $$ = build_parse_node (CALL_EXPR, $$, empty_parms (), $5); | |
606 | } | |
67d743fe MS |
607 | | nested_name_specifier self_template_type '(' |
608 | { | |
609 | $$ = build_parse_node (SCOPE_REF, $1, $2); | |
610 | if ($1 != current_class_type) | |
611 | { | |
612 | push_nested_class ($1, 3); | |
613 | TREE_COMPLEXITY ($$) = current_class_depth; | |
614 | } | |
615 | } | |
616 | parmlist ')' type_quals | |
617 | { $$ = build_parse_node (CALL_EXPR, $<ttype>4, $5, $7); } | |
618 | | nested_name_specifier self_template_type LEFT_RIGHT type_quals | |
619 | { | |
620 | $$ = build_parse_node (SCOPE_REF, $1, $2); | |
621 | if ($1 != current_class_type) | |
622 | { | |
623 | push_nested_class ($1, 3); | |
624 | TREE_COMPLEXITY ($$) = current_class_depth; | |
625 | } | |
626 | $$ = build_parse_node (CALL_EXPR, $$, empty_parms (), $4); | |
627 | } | |
628 | | global_scope nested_name_specifier self_template_type '(' | |
629 | { | |
630 | $$ = build_parse_node (SCOPE_REF, $2, $3); | |
631 | if ($2 != current_class_type) | |
632 | { | |
633 | push_nested_class ($2, 3); | |
634 | TREE_COMPLEXITY ($$) = current_class_depth; | |
635 | } | |
636 | } | |
637 | parmlist ')' type_quals | |
638 | { $$ = build_parse_node (CALL_EXPR, $<ttype>5, $6, $8); } | |
639 | | global_scope nested_name_specifier self_template_type LEFT_RIGHT type_quals | |
640 | { | |
641 | $$ = build_parse_node (SCOPE_REF, $2, $3); | |
642 | if ($2 != current_class_type) | |
643 | { | |
644 | push_nested_class ($2, 3); | |
645 | TREE_COMPLEXITY ($$) = current_class_depth; | |
646 | } | |
647 | $$ = build_parse_node (CALL_EXPR, $$, empty_parms (), $5); | |
648 | } | |
c91a56d2 MS |
649 | ; |
650 | ||
8d08fdba | 651 | fn.def1: |
e3417fcd | 652 | typed_declspecs declarator exception_specification_opt |
f30432d7 | 653 | { tree specs, attrs; |
46b02c6d | 654 | split_specs_attrs ($1.t, &specs, &attrs); |
f30432d7 | 655 | if (! start_function (specs, $2, $3, attrs, 0)) |
8d08fdba MS |
656 | YYERROR1; |
657 | reinit_parse_for_function (); | |
658 | $$ = NULL_TREE; } | |
e3417fcd | 659 | | declmods notype_declarator exception_specification_opt |
72b7eeff MS |
660 | { tree specs, attrs; |
661 | split_specs_attrs ($1, &specs, &attrs); | |
662 | if (! start_function (specs, $2, $3, attrs, 0)) | |
8d08fdba MS |
663 | YYERROR1; |
664 | reinit_parse_for_function (); | |
665 | $$ = NULL_TREE; } | |
e3417fcd | 666 | | notype_declarator exception_specification_opt |
f30432d7 | 667 | { if (! start_function (NULL_TREE, $$, $2, NULL_TREE, 0)) |
8d08fdba MS |
668 | YYERROR1; |
669 | reinit_parse_for_function (); | |
670 | $$ = NULL_TREE; } | |
c91a56d2 MS |
671 | | declmods constructor_declarator exception_specification_opt |
672 | { tree specs, attrs; | |
673 | split_specs_attrs ($1, &specs, &attrs); | |
674 | if (! start_function (specs, $2, $3, attrs, 0)) | |
675 | YYERROR1; | |
676 | reinit_parse_for_function (); | |
677 | $$ = NULL_TREE; } | |
678 | | constructor_declarator exception_specification_opt | |
679 | { if (! start_function (NULL_TREE, $$, $2, NULL_TREE, 0)) | |
680 | YYERROR1; | |
681 | reinit_parse_for_function (); | |
682 | $$ = NULL_TREE; } | |
8d08fdba MS |
683 | ; |
684 | ||
a80e4195 MS |
685 | component_constructor_declarator: |
686 | SELFNAME '(' parmlist ')' type_quals | |
687 | { $$ = build_parse_node (CALL_EXPR, $1, $3, $5); } | |
688 | | SELFNAME LEFT_RIGHT type_quals | |
689 | { $$ = build_parse_node (CALL_EXPR, $1, empty_parms (), $3); } | |
67d743fe MS |
690 | | self_template_type '(' parmlist ')' type_quals |
691 | { $$ = build_parse_node (CALL_EXPR, $1, $3, $5); } | |
692 | | self_template_type LEFT_RIGHT type_quals | |
693 | { $$ = build_parse_node (CALL_EXPR, $1, empty_parms (), $3); } | |
a80e4195 MS |
694 | ; |
695 | ||
51c184be MS |
696 | /* more C++ complexity. See component_decl for a comment on the |
697 | reduce/reduce conflict introduced by these rules. */ | |
8d08fdba | 698 | fn.def2: |
a80e4195 | 699 | declmods component_constructor_declarator exception_specification_opt |
f30432d7 | 700 | { tree specs = strip_attrs ($1); |
a80e4195 | 701 | $$ = start_method (specs, $2, $3); |
a28e3c7f | 702 | rest_of_mdef: |
8d08fdba MS |
703 | if (! $$) |
704 | YYERROR1; | |
705 | if (yychar == YYEMPTY) | |
706 | yychar = YYLEX; | |
707 | reinit_parse_for_method (yychar, $$); } | |
a80e4195 MS |
708 | | component_constructor_declarator exception_specification_opt |
709 | { $$ = start_method (NULL_TREE, $1, $2); goto rest_of_mdef; } | |
e3417fcd | 710 | | typed_declspecs declarator exception_specification_opt |
46b02c6d | 711 | { tree specs = strip_attrs ($1.t); |
f30432d7 | 712 | $$ = start_method (specs, $2, $3); goto rest_of_mdef; } |
e3417fcd | 713 | | declmods notype_declarator exception_specification_opt |
f30432d7 MS |
714 | { tree specs = strip_attrs ($1); |
715 | $$ = start_method (specs, $2, $3); goto rest_of_mdef; } | |
e3417fcd | 716 | | notype_declarator exception_specification_opt |
a28e3c7f | 717 | { $$ = start_method (NULL_TREE, $$, $2); goto rest_of_mdef; } |
c91a56d2 MS |
718 | | declmods constructor_declarator exception_specification_opt |
719 | { tree specs = strip_attrs ($1); | |
720 | $$ = start_method (specs, $2, $3); goto rest_of_mdef; } | |
721 | | constructor_declarator exception_specification_opt | |
722 | { $$ = start_method (NULL_TREE, $$, $2); goto rest_of_mdef; } | |
8d08fdba MS |
723 | ; |
724 | ||
725 | return_id: RETURN IDENTIFIER | |
726 | { | |
727 | if (! current_function_parms_stored) | |
728 | store_parm_decls (); | |
729 | $$ = $2; | |
730 | } | |
731 | ; | |
732 | ||
e3417fcd MS |
733 | return_init: return_id maybe_init |
734 | { store_return_init ($<ttype>$, $2); } | |
8d08fdba MS |
735 | | return_id '(' nonnull_exprlist ')' |
736 | { store_return_init ($<ttype>$, $3); } | |
737 | | return_id LEFT_RIGHT | |
738 | { store_return_init ($<ttype>$, NULL_TREE); } | |
739 | ; | |
740 | ||
741 | base_init: | |
742 | ':' .set_base_init member_init_list | |
743 | { | |
744 | if ($3 == 0) | |
745 | error ("no base initializers given following ':'"); | |
746 | setup_vtbl_ptr (); | |
747 | /* Always keep the BLOCK node associated with the outermost | |
748 | pair of curley braces of a function. These are needed | |
749 | for correct operation of dwarfout.c. */ | |
750 | keep_next_level (); | |
751 | } | |
752 | ; | |
753 | ||
754 | .set_base_init: | |
755 | /* empty */ | |
756 | { | |
757 | if (! current_function_parms_stored) | |
758 | store_parm_decls (); | |
759 | ||
8d08fdba MS |
760 | if (DECL_CONSTRUCTOR_P (current_function_decl)) |
761 | { | |
762 | /* Make a contour for the initializer list. */ | |
763 | pushlevel (0); | |
764 | clear_last_expr (); | |
765 | expand_start_bindings (0); | |
766 | } | |
767 | else if (current_class_type == NULL_TREE) | |
768 | error ("base initializers not allowed for non-member functions"); | |
769 | else if (! DECL_CONSTRUCTOR_P (current_function_decl)) | |
770 | error ("only constructors take base initializers"); | |
771 | } | |
772 | ; | |
773 | ||
774 | member_init_list: | |
775 | /* empty */ | |
776 | { $$ = 0; } | |
777 | | member_init | |
778 | { $$ = 1; } | |
779 | | member_init_list ',' member_init | |
780 | | member_init_list error | |
781 | ; | |
782 | ||
783 | member_init: '(' nonnull_exprlist ')' | |
784 | { | |
785 | if (current_class_name && !flag_traditional) | |
786 | pedwarn ("anachronistic old style base class initializer"); | |
4ac14744 | 787 | expand_member_init (current_class_ref, NULL_TREE, $2); |
8d08fdba MS |
788 | } |
789 | | LEFT_RIGHT | |
790 | { | |
791 | if (current_class_name && !flag_traditional) | |
792 | pedwarn ("anachronistic old style base class initializer"); | |
4ac14744 | 793 | expand_member_init (current_class_ref, NULL_TREE, void_type_node); |
8d08fdba | 794 | } |
a28e3c7f | 795 | | notype_identifier '(' nonnull_exprlist ')' |
4ac14744 | 796 | { expand_member_init (current_class_ref, $1, $3); } |
a28e3c7f | 797 | | notype_identifier LEFT_RIGHT |
4ac14744 | 798 | { expand_member_init (current_class_ref, $1, void_type_node); } |
a28e3c7f | 799 | | complete_type_name '(' nonnull_exprlist ')' |
4ac14744 | 800 | { expand_member_init (current_class_ref, $1, $3); } |
a28e3c7f | 801 | | complete_type_name LEFT_RIGHT |
4ac14744 | 802 | { expand_member_init (current_class_ref, $1, void_type_node); } |
a28e3c7f MS |
803 | /* GNU extension */ |
804 | | notype_qualified_id '(' nonnull_exprlist ')' | |
8d08fdba | 805 | { |
a28e3c7f | 806 | do_member_init (OP0 ($1), OP1 ($1), $3); |
8d08fdba | 807 | } |
a28e3c7f | 808 | | notype_qualified_id LEFT_RIGHT |
8d08fdba | 809 | { |
a28e3c7f | 810 | do_member_init (OP0 ($1), OP1 ($1), void_type_node); |
8d08fdba MS |
811 | } |
812 | ; | |
813 | ||
814 | identifier: | |
815 | IDENTIFIER | |
816 | | TYPENAME | |
a80e4195 | 817 | | SELFNAME |
8d08fdba | 818 | | PTYPENAME |
6060a796 | 819 | | NSNAME |
8d08fdba MS |
820 | ; |
821 | ||
a28e3c7f MS |
822 | notype_identifier: |
823 | IDENTIFIER | |
6060a796 MS |
824 | | PTYPENAME |
825 | | NSNAME %prec EMPTY | |
a28e3c7f MS |
826 | ; |
827 | ||
8d08fdba MS |
828 | identifier_defn: |
829 | IDENTIFIER_DEFN | |
830 | | TYPENAME_DEFN | |
831 | | PTYPENAME_DEFN | |
832 | ; | |
833 | ||
8d08fdba | 834 | explicit_instantiation: |
5566b478 MS |
835 | TEMPLATE aggr template_type |
836 | { do_type_instantiation ($3, NULL_TREE); } | |
a4443a08 | 837 | | TEMPLATE typed_declspecs declarator |
46b02c6d | 838 | { tree specs = strip_attrs ($2.t); |
f30432d7 | 839 | do_function_instantiation (specs, $3, NULL_TREE); } |
07674418 MS |
840 | | TEMPLATE notype_declarator |
841 | { do_function_instantiation (NULL_TREE, $2, NULL_TREE); } | |
c91a56d2 MS |
842 | | TEMPLATE constructor_declarator |
843 | { do_function_instantiation (NULL_TREE, $2, NULL_TREE); } | |
5566b478 MS |
844 | | SCSPEC TEMPLATE aggr template_type |
845 | { do_type_instantiation ($4, $1); } | |
f0e01782 | 846 | | SCSPEC TEMPLATE typed_declspecs declarator |
46b02c6d | 847 | { tree specs = strip_attrs ($3.t); |
f30432d7 | 848 | do_function_instantiation (specs, $4, $1); } |
07674418 MS |
849 | | SCSPEC TEMPLATE notype_declarator |
850 | { do_function_instantiation (NULL_TREE, $3, $1); } | |
c91a56d2 MS |
851 | | SCSPEC TEMPLATE constructor_declarator |
852 | { do_function_instantiation (NULL_TREE, $3, $1); } | |
8d08fdba MS |
853 | ; |
854 | ||
5566b478 MS |
855 | /* The TYPENAME expansions are to deal with use of a template class name as |
856 | a template within the class itself, where the template decl is hidden by | |
857 | a type decl. Got all that? */ | |
8d08fdba | 858 | |
5566b478 MS |
859 | template_type: |
860 | PTYPENAME '<' template_arg_list template_close_bracket | |
861 | { | |
862 | $$ = lookup_template_class ($1, $3, NULL_TREE); | |
863 | if ($$ != error_mark_node) | |
864 | $$ = TYPE_STUB_DECL ($$); | |
865 | } | |
866 | | PTYPENAME '<' template_close_bracket | |
867 | { | |
868 | $$ = lookup_template_class ($1, NULL_TREE, NULL_TREE); | |
869 | if ($$ != error_mark_node) | |
870 | $$ = TYPE_STUB_DECL ($$); | |
871 | } | |
872 | | TYPENAME '<' template_arg_list template_close_bracket | |
873 | { | |
874 | $$ = lookup_template_class ($1, $3, NULL_TREE); | |
875 | if ($$ != error_mark_node) | |
876 | $$ = TYPE_STUB_DECL ($$); | |
877 | } | |
878 | | TYPENAME '<' template_close_bracket | |
879 | { | |
880 | $$ = lookup_template_class ($1, NULL_TREE, NULL_TREE); | |
881 | if ($$ != error_mark_node) | |
882 | $$ = TYPE_STUB_DECL ($$); | |
883 | } | |
67d743fe MS |
884 | | self_template_type |
885 | ; | |
886 | ||
887 | self_template_type: | |
888 | SELFNAME '<' template_arg_list template_close_bracket | |
a80e4195 MS |
889 | { |
890 | $$ = lookup_template_class ($1, $3, NULL_TREE); | |
891 | if ($$ != error_mark_node) | |
892 | $$ = TYPE_STUB_DECL ($$); | |
893 | } | |
894 | | SELFNAME '<' template_close_bracket | |
895 | { | |
896 | $$ = lookup_template_class ($1, NULL_TREE, NULL_TREE); | |
897 | if ($$ != error_mark_node) | |
898 | $$ = TYPE_STUB_DECL ($$); | |
899 | } | |
8d08fdba MS |
900 | ; |
901 | ||
5566b478 MS |
902 | template_close_bracket: |
903 | '>' | |
904 | | RSHIFT | |
905 | { | |
906 | /* Handle `Class<Class<Type>>' without space in the `>>' */ | |
907 | pedwarn ("`>>' should be `> >' in template class name"); | |
908 | yyungetc ('>', 1); | |
909 | } | |
8d08fdba MS |
910 | ; |
911 | ||
912 | template_arg_list: | |
913 | template_arg | |
914 | { $$ = build_tree_list (NULL_TREE, $$); } | |
915 | | template_arg_list ',' template_arg | |
916 | { $$ = chainon ($$, build_tree_list (NULL_TREE, $3)); } | |
917 | ; | |
918 | ||
919 | template_arg: | |
51c184be | 920 | type_id |
46b02c6d | 921 | { $$ = groktypename ($1.t); } |
5566b478 | 922 | | expr_no_commas %prec ARITHCOMPARE |
8d08fdba MS |
923 | ; |
924 | ||
8d08fdba MS |
925 | unop: '-' |
926 | { $$ = NEGATE_EXPR; } | |
927 | | '+' | |
928 | { $$ = CONVERT_EXPR; } | |
929 | | PLUSPLUS | |
930 | { $$ = PREINCREMENT_EXPR; } | |
931 | | MINUSMINUS | |
932 | { $$ = PREDECREMENT_EXPR; } | |
933 | | '!' | |
934 | { $$ = TRUTH_NOT_EXPR; } | |
935 | ; | |
936 | ||
51c184be | 937 | expr: nontrivial_exprlist |
8d08fdba | 938 | { $$ = build_x_compound_expr ($$); } |
8d08fdba MS |
939 | | expr_no_commas |
940 | ; | |
941 | ||
942 | paren_expr_or_null: | |
943 | LEFT_RIGHT | |
944 | { error ("ANSI C++ forbids an empty condition for `%s'", | |
945 | cond_stmt_keyword); | |
946 | $$ = integer_zero_node; } | |
947 | | '(' expr ')' | |
8ccc31eb | 948 | { $$ = condition_conversion ($2); } |
8d08fdba MS |
949 | ; |
950 | ||
951 | paren_cond_or_null: | |
952 | LEFT_RIGHT | |
953 | { error ("ANSI C++ forbids an empty condition for `%s'", | |
954 | cond_stmt_keyword); | |
955 | $$ = integer_zero_node; } | |
956 | | '(' condition ')' | |
8ccc31eb | 957 | { $$ = condition_conversion ($2); } |
8d08fdba MS |
958 | ; |
959 | ||
960 | xcond: | |
961 | /* empty */ | |
962 | { $$ = NULL_TREE; } | |
963 | | condition | |
8ccc31eb | 964 | { $$ = condition_conversion ($$); } |
8d08fdba MS |
965 | | error |
966 | { $$ = NULL_TREE; } | |
967 | ; | |
968 | ||
969 | condition: | |
e3417fcd | 970 | type_specifier_seq declarator exception_specification_opt maybeasm maybe_attribute '=' |
8d08fdba MS |
971 | { { |
972 | tree d; | |
973 | for (d = getdecls (); d; d = TREE_CHAIN (d)) | |
974 | if (TREE_CODE (d) == TYPE_DECL) { | |
975 | tree s = TREE_TYPE (d); | |
976 | if (TREE_CODE (s) == RECORD_TYPE) | |
977 | cp_error ("definition of class `%T' in condition", s); | |
978 | else if (TREE_CODE (s) == ENUMERAL_TYPE) | |
979 | cp_error ("definition of enum `%T' in condition", s); | |
980 | } | |
981 | } | |
46b02c6d | 982 | current_declspecs = $1.t; |
8d08fdba MS |
983 | $<itype>6 = suspend_momentary (); |
984 | $<ttype>$ = start_decl ($<ttype>2, current_declspecs, 1, $3); | |
f30432d7 MS |
985 | cplus_decl_attributes ($<ttype>$, $5, |
986 | /*prefix_attributes*/ NULL_TREE); | |
8d08fdba MS |
987 | } |
988 | init | |
989 | { | |
9e9ff709 | 990 | cp_finish_decl ($<ttype>7, $8, $5, 1, LOOKUP_ONLYCONVERTING); |
8d08fdba MS |
991 | resume_momentary ($<itype>6); |
992 | $$ = $<ttype>7; | |
993 | if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE) | |
994 | cp_error ("definition of array `%#D' in condition", $$); | |
995 | } | |
996 | | expr | |
997 | ; | |
998 | ||
863adfc0 MS |
999 | compstmtend: |
1000 | '}' | |
1001 | | maybe_label_decls stmts '}' | |
1002 | | maybe_label_decls stmts error '}' | |
1003 | | maybe_label_decls error '}' | |
1004 | ; | |
1005 | ||
a4443a08 | 1006 | already_scoped_stmt: |
5566b478 MS |
1007 | '{' |
1008 | { | |
1009 | if (current_template_parms) | |
1010 | { | |
1011 | $<ttype>$ = build_min_nt (COMPOUND_STMT, NULL_TREE); | |
1012 | COMPOUND_STMT_NO_SCOPE ($<ttype>$) = 1; | |
1013 | add_tree ($<ttype>$); | |
1014 | } | |
1015 | } | |
1016 | compstmtend | |
1017 | { | |
1018 | if (current_template_parms) | |
1019 | { | |
1020 | TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2); | |
1021 | TREE_CHAIN ($<ttype>2) = NULL_TREE; | |
1022 | last_tree = $<ttype>2; | |
1023 | } | |
1024 | finish_stmt (); | |
1025 | } | |
a4443a08 MS |
1026 | | simple_stmt |
1027 | ; | |
1028 | ||
1029 | ||
51c184be MS |
1030 | nontrivial_exprlist: |
1031 | expr_no_commas ',' expr_no_commas | |
1032 | { $$ = tree_cons (NULL_TREE, $$, | |
1033 | build_tree_list (NULL_TREE, $3)); } | |
1034 | | expr_no_commas ',' error | |
1035 | { $$ = tree_cons (NULL_TREE, $$, | |
1036 | build_tree_list (NULL_TREE, error_mark_node)); } | |
1037 | | nontrivial_exprlist ',' expr_no_commas | |
1038 | { chainon ($$, build_tree_list (NULL_TREE, $3)); } | |
1039 | | nontrivial_exprlist ',' error | |
1040 | { chainon ($$, build_tree_list (NULL_TREE, error_mark_node)); } | |
1041 | ; | |
1042 | ||
8d08fdba MS |
1043 | nonnull_exprlist: |
1044 | expr_no_commas | |
1045 | { $$ = build_tree_list (NULL_TREE, $$); } | |
51c184be | 1046 | | nontrivial_exprlist |
8d08fdba MS |
1047 | ; |
1048 | ||
1049 | unary_expr: | |
1050 | primary %prec UNARY | |
4ac14744 | 1051 | { $$ = $1; } |
8d08fdba MS |
1052 | /* __extension__ turns off -pedantic for following primary. */ |
1053 | | EXTENSION | |
1054 | { $<itype>1 = pedantic; | |
1055 | pedantic = 0; } | |
1056 | cast_expr %prec UNARY | |
1057 | { $$ = $3; | |
1058 | pedantic = $<itype>1; } | |
1059 | | '*' cast_expr %prec UNARY | |
1060 | { $$ = build_x_indirect_ref ($2, "unary *"); } | |
1061 | | '&' cast_expr %prec UNARY | |
1062 | { $$ = build_x_unary_op (ADDR_EXPR, $2); } | |
51c184be | 1063 | | '~' cast_expr |
8d08fdba MS |
1064 | { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); } |
1065 | | unop cast_expr %prec UNARY | |
39211cd5 | 1066 | { $$ = build_x_unary_op ($1, $2); |
8d08fdba MS |
1067 | if ($1 == NEGATE_EXPR && TREE_CODE ($2) == INTEGER_CST) |
1068 | TREE_NEGATED_INT ($$) = 1; | |
1069 | overflow_warning ($$); | |
1070 | } | |
1071 | /* Refer to the address of a label as a pointer. */ | |
1072 | | ANDAND identifier | |
1073 | { tree label = lookup_label ($2); | |
1074 | if (label == NULL_TREE) | |
1075 | $$ = null_pointer_node; | |
1076 | else | |
1077 | { | |
1078 | TREE_USED (label) = 1; | |
1079 | $$ = build1 (ADDR_EXPR, ptr_type_node, label); | |
1080 | TREE_CONSTANT ($$) = 1; | |
1081 | } | |
1082 | } | |
1083 | | SIZEOF unary_expr %prec UNARY | |
5566b478 | 1084 | { $$ = expr_sizeof ($2); } |
51c184be | 1085 | | SIZEOF '(' type_id ')' %prec HYPERUNARY |
46b02c6d | 1086 | { $$ = c_sizeof (groktypename ($3.t)); } |
8d08fdba MS |
1087 | | ALIGNOF unary_expr %prec UNARY |
1088 | { $$ = grok_alignof ($2); } | |
51c184be | 1089 | | ALIGNOF '(' type_id ')' %prec HYPERUNARY |
46b02c6d MS |
1090 | { $$ = c_alignof (groktypename ($3.t)); |
1091 | check_for_new_type ("alignof", $3); } | |
8d08fdba | 1092 | |
39211cd5 MS |
1093 | /* The %prec EMPTY's here are required by the = init initializer |
1094 | syntax extension; see below. */ | |
1095 | | new new_type_id %prec EMPTY | |
46b02c6d MS |
1096 | { $$ = build_new (NULL_TREE, $2.t, NULL_TREE, $1); |
1097 | check_for_new_type ("new", $2); } | |
39211cd5 | 1098 | | new new_type_id new_initializer |
46b02c6d MS |
1099 | { $$ = build_new (NULL_TREE, $2.t, $3, $1); |
1100 | check_for_new_type ("new", $2); } | |
39211cd5 | 1101 | | new new_placement new_type_id %prec EMPTY |
46b02c6d MS |
1102 | { $$ = build_new ($2, $3.t, NULL_TREE, $1); |
1103 | check_for_new_type ("new", $3); } | |
39211cd5 | 1104 | | new new_placement new_type_id new_initializer |
46b02c6d MS |
1105 | { $$ = build_new ($2, $3.t, $4, $1); |
1106 | check_for_new_type ("new", $3); } | |
39211cd5 | 1107 | | new '(' type_id ')' %prec EMPTY |
46b02c6d MS |
1108 | { $$ = build_new (NULL_TREE, groktypename($3.t), |
1109 | NULL_TREE, $1); | |
1110 | check_for_new_type ("new", $3); } | |
39211cd5 | 1111 | | new '(' type_id ')' new_initializer |
46b02c6d MS |
1112 | { $$ = build_new (NULL_TREE, groktypename($3.t), $5, $1); |
1113 | check_for_new_type ("new", $3); } | |
39211cd5 | 1114 | | new new_placement '(' type_id ')' %prec EMPTY |
46b02c6d MS |
1115 | { $$ = build_new ($2, groktypename($4.t), NULL_TREE, $1); |
1116 | check_for_new_type ("new", $4); } | |
39211cd5 | 1117 | | new new_placement '(' type_id ')' new_initializer |
46b02c6d MS |
1118 | { $$ = build_new ($2, groktypename($4.t), $6, $1); |
1119 | check_for_new_type ("new", $4); } | |
8d08fdba MS |
1120 | |
1121 | | delete cast_expr %prec UNARY | |
a28e3c7f | 1122 | { $$ = delete_sanity ($2, NULL_TREE, 0, $1); } |
8d08fdba | 1123 | | delete '[' ']' cast_expr %prec UNARY |
a28e3c7f | 1124 | { $$ = delete_sanity ($4, NULL_TREE, 1, $1); |
8d08fdba MS |
1125 | if (yychar == YYEMPTY) |
1126 | yychar = YYLEX; } | |
1127 | | delete '[' expr ']' cast_expr %prec UNARY | |
a28e3c7f | 1128 | { $$ = delete_sanity ($5, $3, 2, $1); |
8d08fdba MS |
1129 | if (yychar == YYEMPTY) |
1130 | yychar = YYLEX; } | |
1131 | ; | |
1132 | ||
39211cd5 MS |
1133 | new_placement: |
1134 | '(' nonnull_exprlist ')' | |
1135 | { $$ = $2; } | |
1136 | | '{' nonnull_exprlist '}' | |
1137 | { | |
1138 | $$ = $2; | |
1139 | pedwarn ("old style placement syntax, use () instead"); | |
1140 | } | |
1141 | ; | |
1142 | ||
1143 | new_initializer: | |
1144 | '(' nonnull_exprlist ')' | |
1145 | { $$ = $2; } | |
1146 | | LEFT_RIGHT | |
1147 | { $$ = NULL_TREE; } | |
1148 | | '(' typespec ')' | |
1149 | { | |
46b02c6d | 1150 | cp_error ("`%T' is not a valid expression", $2.t); |
39211cd5 MS |
1151 | $$ = error_mark_node; |
1152 | } | |
1153 | /* GNU extension so people can use initializer lists. Note that | |
1154 | this alters the meaning of `new int = 1', which was previously | |
1155 | syntactically valid but semantically invalid. */ | |
1156 | | '=' init | |
1157 | { | |
b7484fbe | 1158 | if (pedantic) |
39211cd5 MS |
1159 | pedwarn ("ANSI C++ forbids initialization of new expression with `='"); |
1160 | $$ = $2; | |
1161 | } | |
1162 | ; | |
1163 | ||
51c184be MS |
1164 | /* This is necessary to postpone reduction of `int ((int)(int)(int))'. */ |
1165 | regcast_or_absdcl: | |
1166 | '(' type_id ')' %prec EMPTY | |
46b02c6d MS |
1167 | { $2.t = tree_cons (NULL_TREE, $2.t, void_list_node); |
1168 | TREE_PARMLIST ($2.t) = 1; | |
1169 | $$ = build_parse_node (CALL_EXPR, NULL_TREE, $2.t, | |
1170 | NULL_TREE); | |
1171 | check_for_new_type ("cast", $2); } | |
51c184be | 1172 | | regcast_or_absdcl '(' type_id ')' %prec EMPTY |
46b02c6d MS |
1173 | { $3.t = tree_cons (NULL_TREE, $3.t, void_list_node); |
1174 | TREE_PARMLIST ($3.t) = 1; | |
1175 | $$ = build_parse_node (CALL_EXPR, $$, $3.t, NULL_TREE); | |
1176 | check_for_new_type ("cast", $3); } | |
51c184be MS |
1177 | ; |
1178 | ||
8d08fdba | 1179 | cast_expr: |
f30432d7 MS |
1180 | unary_expr |
1181 | | regcast_or_absdcl unary_expr %prec UNARY | |
51c184be MS |
1182 | { $$ = reparse_absdcl_as_casts ($$, $2); } |
1183 | | regcast_or_absdcl '{' initlist maybecomma '}' %prec UNARY | |
1184 | { | |
1185 | tree init = build_nt (CONSTRUCTOR, NULL_TREE, | |
1186 | nreverse ($3)); | |
b7484fbe | 1187 | if (pedantic) |
51c184be MS |
1188 | pedwarn ("ANSI C++ forbids constructor-expressions"); |
1189 | /* Indicate that this was a GNU C constructor expression. */ | |
1190 | TREE_HAS_CONSTRUCTOR (init) = 1; | |
8d08fdba | 1191 | |
51c184be | 1192 | $$ = reparse_absdcl_as_casts ($$, init); |
8d08fdba | 1193 | } |
51c184be MS |
1194 | ; |
1195 | ||
8d08fdba MS |
1196 | expr_no_commas: |
1197 | cast_expr | |
51c184be MS |
1198 | /* Handle general members. */ |
1199 | | expr_no_commas POINTSAT_STAR expr_no_commas | |
1200 | { $$ = build_x_binary_op (MEMBER_REF, $$, $3); } | |
1201 | | expr_no_commas DOT_STAR expr_no_commas | |
1202 | { $$ = build_m_component_ref ($$, $3); } | |
8d08fdba MS |
1203 | | expr_no_commas '+' expr_no_commas |
1204 | { $$ = build_x_binary_op ($2, $$, $3); } | |
1205 | | expr_no_commas '-' expr_no_commas | |
1206 | { $$ = build_x_binary_op ($2, $$, $3); } | |
1207 | | expr_no_commas '*' expr_no_commas | |
1208 | { $$ = build_x_binary_op ($2, $$, $3); } | |
1209 | | expr_no_commas '/' expr_no_commas | |
1210 | { $$ = build_x_binary_op ($2, $$, $3); } | |
1211 | | expr_no_commas '%' expr_no_commas | |
1212 | { $$ = build_x_binary_op ($2, $$, $3); } | |
1213 | | expr_no_commas LSHIFT expr_no_commas | |
1214 | { $$ = build_x_binary_op ($2, $$, $3); } | |
1215 | | expr_no_commas RSHIFT expr_no_commas | |
1216 | { $$ = build_x_binary_op ($2, $$, $3); } | |
1217 | | expr_no_commas ARITHCOMPARE expr_no_commas | |
1218 | { $$ = build_x_binary_op ($2, $$, $3); } | |
1219 | | expr_no_commas '<' expr_no_commas | |
1220 | { $$ = build_x_binary_op (LT_EXPR, $$, $3); } | |
1221 | | expr_no_commas '>' expr_no_commas | |
1222 | { $$ = build_x_binary_op (GT_EXPR, $$, $3); } | |
1223 | | expr_no_commas EQCOMPARE expr_no_commas | |
1224 | { $$ = build_x_binary_op ($2, $$, $3); } | |
1225 | | expr_no_commas MIN_MAX expr_no_commas | |
1226 | { $$ = build_x_binary_op ($2, $$, $3); } | |
1227 | | expr_no_commas '&' expr_no_commas | |
1228 | { $$ = build_x_binary_op ($2, $$, $3); } | |
1229 | | expr_no_commas '|' expr_no_commas | |
1230 | { $$ = build_x_binary_op ($2, $$, $3); } | |
1231 | | expr_no_commas '^' expr_no_commas | |
1232 | { $$ = build_x_binary_op ($2, $$, $3); } | |
1233 | | expr_no_commas ANDAND expr_no_commas | |
1234 | { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); } | |
1235 | | expr_no_commas OROR expr_no_commas | |
1236 | { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); } | |
1237 | | expr_no_commas '?' xexpr ':' expr_no_commas | |
1238 | { $$ = build_x_conditional_expr ($$, $3, $5); } | |
1239 | | expr_no_commas '=' expr_no_commas | |
5566b478 | 1240 | { $$ = build_x_modify_expr ($$, NOP_EXPR, $3); |
e1cd6e56 | 1241 | C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); } |
8d08fdba | 1242 | | expr_no_commas ASSIGN expr_no_commas |
5566b478 | 1243 | { $$ = build_x_modify_expr ($$, $2, $3); } |
8d2733ca MS |
1244 | | THROW |
1245 | { $$ = build_throw (NULL_TREE); } | |
1246 | | THROW expr_no_commas | |
1247 | { $$ = build_throw ($2); } | |
8d08fdba MS |
1248 | /* These extensions are not defined. The second arg to build_m_component_ref |
1249 | is old, build_m_component_ref now does an implicit | |
1250 | build_indirect_ref (x, NULL_PTR) on the second argument. | |
1251 | | object '&' expr_no_commas %prec UNARY | |
1252 | { $$ = build_m_component_ref ($$, build_x_unary_op (ADDR_EXPR, $3)); } | |
1253 | | object unop expr_no_commas %prec UNARY | |
1254 | { $$ = build_m_component_ref ($$, build_x_unary_op ($2, $3)); } | |
51c184be | 1255 | | object '(' type_id ')' expr_no_commas %prec UNARY |
46b02c6d | 1256 | { tree type = groktypename ($3.t); |
6060a796 | 1257 | $$ = build_m_component_ref ($$, build_c_cast (type, $5, 0)); } |
8d08fdba MS |
1258 | | object primary_no_id %prec UNARY |
1259 | { $$ = build_m_component_ref ($$, $2); } | |
1260 | */ | |
1261 | ; | |
1262 | ||
51c184be | 1263 | notype_unqualified_id: |
a28e3c7f MS |
1264 | '~' see_typename identifier |
1265 | { $$ = build_parse_node (BIT_NOT_EXPR, $3); } | |
8d08fdba | 1266 | | operator_name |
51c184be | 1267 | | IDENTIFIER |
6060a796 MS |
1268 | | PTYPENAME |
1269 | | NSNAME %prec EMPTY | |
51c184be MS |
1270 | ; |
1271 | ||
a28e3c7f MS |
1272 | unqualified_id: |
1273 | notype_unqualified_id | |
1274 | | TYPENAME | |
a80e4195 | 1275 | | SELFNAME |
a28e3c7f MS |
1276 | ; |
1277 | ||
51c184be | 1278 | expr_or_declarator: |
a28e3c7f | 1279 | notype_unqualified_id |
a28e3c7f | 1280 | | '*' expr_or_declarator %prec UNARY |
51c184be MS |
1281 | { $$ = build_parse_node (INDIRECT_REF, $2); } |
1282 | | '&' expr_or_declarator %prec UNARY | |
1283 | { $$ = build_parse_node (ADDR_EXPR, $2); } | |
4cabb798 JM |
1284 | | '(' expr_or_declarator ')' |
1285 | { $$ = $2; } | |
51c184be MS |
1286 | ; |
1287 | ||
1288 | direct_notype_declarator: | |
1289 | complex_direct_notype_declarator | |
1290 | | notype_unqualified_id | |
4cabb798 JM |
1291 | | '(' expr_or_declarator ')' |
1292 | { $$ = finish_decl_parsing ($2); } | |
51c184be MS |
1293 | ; |
1294 | ||
1295 | primary: | |
1296 | notype_unqualified_id | |
8d08fdba | 1297 | { |
51c184be MS |
1298 | if (TREE_CODE ($$) == BIT_NOT_EXPR) |
1299 | $$ = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND ($$, 0)); | |
51c184be | 1300 | else |
5566b478 | 1301 | $$ = do_identifier ($$, 1); |
51c184be | 1302 | } |
8d08fdba | 1303 | | CONSTANT |
2986ae00 | 1304 | | boolean.literal |
8d08fdba | 1305 | | string |
5566b478 MS |
1306 | { |
1307 | if (current_template_parms) | |
1308 | push_obstacks (&permanent_obstack, &permanent_obstack); | |
1309 | $$ = combine_strings ($$); | |
1310 | if (current_template_parms) | |
1311 | pop_obstacks (); | |
1312 | } | |
8d08fdba | 1313 | | '(' expr ')' |
e3417fcd MS |
1314 | { char class; |
1315 | $$ = $2; | |
1316 | class = TREE_CODE_CLASS (TREE_CODE ($$)); | |
1317 | if (class == 'e' || class == '1' | |
1318 | || class == '2' || class == '<') | |
e92cc029 | 1319 | /* This inhibits warnings in truthvalue_conversion. */ |
e3417fcd MS |
1320 | C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); } |
1321 | | '(' expr_or_declarator ')' | |
1322 | { char class; | |
1323 | $$ = reparse_decl_as_expr (NULL_TREE, $2); | |
1324 | class = TREE_CODE_CLASS (TREE_CODE ($$)); | |
e1cd6e56 MS |
1325 | if (class == 'e' || class == '1' |
1326 | || class == '2' || class == '<') | |
e92cc029 | 1327 | /* This inhibits warnings in truthvalue_conversion. */ |
e3417fcd | 1328 | C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); } |
8d08fdba MS |
1329 | | '(' error ')' |
1330 | { $$ = error_mark_node; } | |
1331 | | '(' | |
1332 | { if (current_function_decl == 0) | |
1333 | { | |
1334 | error ("braced-group within expression allowed only inside a function"); | |
1335 | YYERROR; | |
1336 | } | |
1337 | keep_next_level (); | |
1338 | $<ttype>$ = expand_start_stmt_expr (); } | |
1339 | compstmt ')' | |
1340 | { tree rtl_exp; | |
b7484fbe | 1341 | if (pedantic) |
8d08fdba MS |
1342 | pedwarn ("ANSI C++ forbids braced-groups within expressions"); |
1343 | rtl_exp = expand_end_stmt_expr ($<ttype>2); | |
1344 | /* The statements have side effects, so the group does. */ | |
1345 | TREE_SIDE_EFFECTS (rtl_exp) = 1; | |
1346 | ||
1347 | if (TREE_CODE ($3) == BLOCK) | |
1348 | { | |
1349 | /* Make a BIND_EXPR for the BLOCK already made. */ | |
1350 | $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp), | |
1351 | NULL_TREE, rtl_exp, $3); | |
1352 | /* Remove the block from the tree at this point. | |
1353 | It gets put back at the proper place | |
1354 | when the BIND_EXPR is expanded. */ | |
1355 | delete_block ($3); | |
1356 | } | |
1357 | else | |
1358 | $$ = $3; | |
1359 | } | |
1360 | | primary '(' nonnull_exprlist ')' | |
5566b478 | 1361 | { |
4ac14744 | 1362 | $$ = build_x_function_call ($1, $3, current_class_ref); |
5566b478 MS |
1363 | if (TREE_CODE ($$) == CALL_EXPR |
1364 | && TREE_TYPE ($$) != void_type_node) | |
1365 | $$ = require_complete_type ($$); | |
8d08fdba MS |
1366 | } |
1367 | | primary LEFT_RIGHT | |
1368 | { | |
4ac14744 | 1369 | $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); |
8d08fdba MS |
1370 | if (TREE_CODE ($$) == CALL_EXPR |
1371 | && TREE_TYPE ($$) != void_type_node) | |
1372 | $$ = require_complete_type ($$); | |
1373 | } | |
1374 | | primary '[' expr ']' | |
8926095f | 1375 | { $$ = grok_array_decl ($$, $3); } |
8d08fdba MS |
1376 | | primary PLUSPLUS |
1377 | { /* If we get an OFFSET_REF, turn it into what it really | |
1378 | means (e.g., a COMPONENT_REF). This way if we've got, | |
1379 | say, a reference to a static member that's being operated | |
1380 | on, we don't end up trying to find a member operator for | |
1381 | the class it's in. */ | |
1382 | if (TREE_CODE ($$) == OFFSET_REF) | |
1383 | $$ = resolve_offset_ref ($$); | |
1384 | $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); } | |
1385 | | primary MINUSMINUS | |
1386 | { if (TREE_CODE ($$) == OFFSET_REF) | |
1387 | $$ = resolve_offset_ref ($$); | |
1388 | $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); } | |
1389 | /* C++ extensions */ | |
1390 | | THIS | |
4ac14744 | 1391 | { if (current_class_ptr) |
8d08fdba MS |
1392 | { |
1393 | #ifdef WARNING_ABOUT_CCD | |
4ac14744 | 1394 | TREE_USED (current_class_ptr) = 1; |
8d08fdba | 1395 | #endif |
4ac14744 | 1396 | $$ = current_class_ptr; |
8d08fdba MS |
1397 | } |
1398 | else if (current_function_decl | |
1399 | && DECL_STATIC_FUNCTION_P (current_function_decl)) | |
1400 | { | |
1401 | error ("`this' is unavailable for static member functions"); | |
1402 | $$ = error_mark_node; | |
1403 | } | |
1404 | else | |
1405 | { | |
1406 | if (current_function_decl) | |
1407 | error ("invalid use of `this' in non-member function"); | |
1408 | else | |
1409 | error ("invalid use of `this' at top level"); | |
1410 | $$ = error_mark_node; | |
1411 | } | |
1412 | } | |
1413 | | TYPE_QUAL '(' nonnull_exprlist ')' | |
1414 | { | |
1415 | tree type; | |
1416 | tree id = $$; | |
1417 | ||
1418 | /* This is a C cast in C++'s `functional' notation. */ | |
1419 | if ($3 == error_mark_node) | |
1420 | { | |
1421 | $$ = error_mark_node; | |
1422 | break; | |
1423 | } | |
1424 | #if 0 | |
1425 | if ($3 == NULL_TREE) | |
1426 | { | |
1427 | error ("cannot cast null list to type `%s'", | |
1428 | IDENTIFIER_POINTER (TYPE_NAME (id))); | |
1429 | $$ = error_mark_node; | |
1430 | break; | |
1431 | } | |
1432 | #endif | |
1433 | #if 0 | |
1434 | /* type is not set! (mrs) */ | |
1435 | if (type == error_mark_node) | |
1436 | $$ = error_mark_node; | |
1437 | else | |
1438 | #endif | |
1439 | { | |
1440 | if (id == ridpointers[(int) RID_CONST]) | |
1441 | type = build_type_variant (integer_type_node, 1, 0); | |
1442 | else if (id == ridpointers[(int) RID_VOLATILE]) | |
1443 | type = build_type_variant (integer_type_node, 0, 1); | |
1444 | #if 0 | |
1445 | /* should not be able to get here (mrs) */ | |
1446 | else if (id == ridpointers[(int) RID_FRIEND]) | |
1447 | { | |
1448 | error ("cannot cast expression to `friend' type"); | |
1449 | $$ = error_mark_node; | |
1450 | break; | |
1451 | } | |
1452 | #endif | |
1453 | else my_friendly_abort (79); | |
6060a796 | 1454 | $$ = build_c_cast (type, build_compound_expr ($3), 1); |
8d08fdba MS |
1455 | } |
1456 | } | |
51c184be | 1457 | | functional_cast |
46b02c6d MS |
1458 | | DYNAMIC_CAST '<' type_id '>' '(' expr ')' |
1459 | { tree type = groktypename ($3.t); | |
1460 | check_for_new_type ("dynamic_cast", $3); | |
1461 | $$ = build_dynamic_cast (type, $6); } | |
1462 | | STATIC_CAST '<' type_id '>' '(' expr ')' | |
1463 | { tree type = groktypename ($3.t); | |
1464 | check_for_new_type ("static_cast", $3); | |
1465 | $$ = build_static_cast (type, $6); } | |
1466 | | REINTERPRET_CAST '<' type_id '>' '(' expr ')' | |
1467 | { tree type = groktypename ($3.t); | |
1468 | check_for_new_type ("reinterpret_cast", $3); | |
1469 | $$ = build_reinterpret_cast (type, $6); } | |
1470 | | CONST_CAST '<' type_id '>' '(' expr ')' | |
1471 | { tree type = groktypename ($3.t); | |
1472 | check_for_new_type ("const_cast", $3); | |
1473 | $$ = build_const_cast (type, $6); } | |
8d08fdba MS |
1474 | | TYPEID '(' expr ')' |
1475 | { $$ = build_typeid ($3); } | |
51c184be | 1476 | | TYPEID '(' type_id ')' |
46b02c6d MS |
1477 | { tree type = groktypename ($3.t); |
1478 | check_for_new_type ("typeid", $3); | |
8145f082 | 1479 | $$ = get_typeid (TYPE_MAIN_VARIANT (type)); } |
a28e3c7f | 1480 | | global_scope IDENTIFIER |
5566b478 | 1481 | { $$ = do_scoped_id ($2, 1); } |
a28e3c7f | 1482 | | global_scope operator_name |
8d08fdba | 1483 | { |
a28e3c7f | 1484 | got_scope = NULL_TREE; |
8d08fdba | 1485 | if (TREE_CODE ($2) == IDENTIFIER_NODE) |
5566b478 MS |
1486 | $$ = do_scoped_id ($2, 1); |
1487 | else | |
1488 | $$ = $2; | |
8d08fdba | 1489 | } |
a28e3c7f MS |
1490 | | overqualified_id %prec HYPERUNARY |
1491 | { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); } | |
1492 | | overqualified_id '(' nonnull_exprlist ')' | |
5566b478 | 1493 | { if (current_template_parms) |
4dabb379 | 1494 | $$ = build_min_nt (CALL_EXPR, copy_to_permanent ($1), $3, NULL_TREE); |
5566b478 MS |
1495 | else |
1496 | $$ = build_member_call (OP0 ($$), OP1 ($$), $3); } | |
a28e3c7f | 1497 | | overqualified_id LEFT_RIGHT |
5566b478 MS |
1498 | { if (current_template_parms) |
1499 | $$ = build_min_nt (CALL_EXPR, copy_to_permanent ($1), | |
4dabb379 | 1500 | NULL_TREE, NULL_TREE); |
5566b478 MS |
1501 | else |
1502 | $$ = build_member_call (OP0 ($$), OP1 ($$), NULL_TREE); } | |
a28e3c7f | 1503 | | object unqualified_id %prec UNARY |
5566b478 | 1504 | { $$ = build_component_ref ($$, $2, NULL_TREE, 1); } |
b7484fbe | 1505 | | object overqualified_id %prec UNARY |
5566b478 MS |
1506 | { if (current_template_parms) |
1507 | $$ = build_min_nt (COMPONENT_REF, $1, copy_to_permanent ($2)); | |
1508 | else | |
1509 | $$ = build_object_ref ($$, OP0 ($2), OP1 ($2)); } | |
a28e3c7f | 1510 | | object unqualified_id '(' nonnull_exprlist ')' |
8d08fdba MS |
1511 | { |
1512 | #if 0 | |
1513 | /* This is a future direction of this code, but because | |
1514 | build_x_function_call cannot always undo what is done | |
e92cc029 | 1515 | in build_component_ref entirely yet, we cannot do this. */ |
4ac14744 | 1516 | $$ = build_x_function_call (build_component_ref ($$, $2, NULL_TREE, 1), $4, current_class_ref); |
8d08fdba MS |
1517 | if (TREE_CODE ($$) == CALL_EXPR |
1518 | && TREE_TYPE ($$) != void_type_node) | |
1519 | $$ = require_complete_type ($$); | |
1520 | #else | |
1521 | $$ = build_method_call ($$, $2, $4, NULL_TREE, | |
4ac14744 | 1522 | LOOKUP_NORMAL); |
8d08fdba MS |
1523 | #endif |
1524 | } | |
a28e3c7f | 1525 | | object unqualified_id LEFT_RIGHT |
8d08fdba MS |
1526 | { |
1527 | #if 0 | |
1528 | /* This is a future direction of this code, but because | |
1529 | build_x_function_call cannot always undo what is done | |
e92cc029 | 1530 | in build_component_ref entirely yet, we cannot do this. */ |
4ac14744 | 1531 | $$ = build_x_function_call (build_component_ref ($$, $2, NULL_TREE, 1), NULL_TREE, current_class_ref); |
8d08fdba MS |
1532 | if (TREE_CODE ($$) == CALL_EXPR |
1533 | && TREE_TYPE ($$) != void_type_node) | |
1534 | $$ = require_complete_type ($$); | |
1535 | #else | |
1536 | $$ = build_method_call ($$, $2, NULL_TREE, NULL_TREE, | |
4ac14744 | 1537 | LOOKUP_NORMAL); |
8d08fdba MS |
1538 | #endif |
1539 | } | |
b7484fbe | 1540 | | object overqualified_id '(' nonnull_exprlist ')' |
8d08fdba | 1541 | { |
be99da77 | 1542 | if (IS_SIGNATURE (OP0 ($2))) |
8d08fdba MS |
1543 | { |
1544 | warning ("signature name in scope resolution ignored"); | |
a28e3c7f | 1545 | $$ = build_method_call ($$, OP1 ($2), $4, NULL_TREE, |
4ac14744 | 1546 | LOOKUP_NORMAL); |
8d08fdba MS |
1547 | } |
1548 | else | |
a28e3c7f | 1549 | $$ = build_scoped_method_call ($$, OP0 ($2), OP1 ($2), $4); |
8d08fdba | 1550 | } |
b7484fbe | 1551 | | object overqualified_id LEFT_RIGHT |
8d08fdba | 1552 | { |
be99da77 | 1553 | if (IS_SIGNATURE (OP0 ($2))) |
8d08fdba MS |
1554 | { |
1555 | warning ("signature name in scope resolution ignored"); | |
a28e3c7f | 1556 | $$ = build_method_call ($$, OP1 ($2), NULL_TREE, NULL_TREE, |
4ac14744 | 1557 | LOOKUP_NORMAL); |
8d08fdba MS |
1558 | } |
1559 | else | |
a28e3c7f | 1560 | $$ = build_scoped_method_call ($$, OP0 ($2), OP1 ($2), NULL_TREE); |
8d08fdba MS |
1561 | } |
1562 | /* p->int::~int() is valid -- 12.4 */ | |
1563 | | object '~' TYPESPEC LEFT_RIGHT | |
e1cd6e56 | 1564 | { |
b7484fbe MS |
1565 | if (IDENTIFIER_GLOBAL_VALUE ($3) |
1566 | && (TREE_CODE (TREE_TYPE ($1)) | |
1567 | != TREE_CODE (TREE_TYPE (IDENTIFIER_GLOBAL_VALUE ($3))))) | |
8d08fdba | 1568 | cp_error ("`%E' is not of type `%T'", $1, $3); |
00595019 | 1569 | $$ = convert (void_type_node, $1); |
8d08fdba MS |
1570 | } |
1571 | | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT | |
e1cd6e56 | 1572 | { |
8d08fdba MS |
1573 | if ($2 != $5) |
1574 | cp_error ("destructor specifier `%T::~%T()' must have matching names", $2, $5); | |
1575 | if (TREE_CODE (TREE_TYPE ($1)) | |
1576 | != TREE_CODE (TREE_TYPE (IDENTIFIER_GLOBAL_VALUE ($2)))) | |
1577 | cp_error ("`%E' is not of type `%T'", $1, $2); | |
00595019 | 1578 | $$ = convert (void_type_node, $1); |
8d08fdba | 1579 | } |
e1cd6e56 MS |
1580 | | object error |
1581 | { | |
e1cd6e56 MS |
1582 | $$ = error_mark_node; |
1583 | } | |
8d08fdba MS |
1584 | ; |
1585 | ||
1586 | /* Not needed for now. | |
1587 | ||
1588 | primary_no_id: | |
1589 | '(' expr ')' | |
1590 | { $$ = $2; } | |
1591 | | '(' error ')' | |
1592 | { $$ = error_mark_node; } | |
1593 | | '(' | |
1594 | { if (current_function_decl == 0) | |
1595 | { | |
1596 | error ("braced-group within expression allowed only inside a function"); | |
1597 | YYERROR; | |
1598 | } | |
1599 | $<ttype>$ = expand_start_stmt_expr (); } | |
1600 | compstmt ')' | |
b7484fbe | 1601 | { if (pedantic) |
8d08fdba MS |
1602 | pedwarn ("ANSI C++ forbids braced-groups within expressions"); |
1603 | $$ = expand_end_stmt_expr ($<ttype>2); } | |
1604 | | primary_no_id '(' nonnull_exprlist ')' | |
4ac14744 | 1605 | { $$ = build_x_function_call ($$, $3, current_class_ref); } |
8d08fdba | 1606 | | primary_no_id LEFT_RIGHT |
4ac14744 | 1607 | { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); } |
8d08fdba MS |
1608 | | primary_no_id '[' expr ']' |
1609 | { goto do_array; } | |
1610 | | primary_no_id PLUSPLUS | |
1611 | { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); } | |
1612 | | primary_no_id MINUSMINUS | |
1613 | { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); } | |
1614 | | SCOPE IDENTIFIER | |
1615 | { goto do_scoped_id; } | |
1616 | | SCOPE operator_name | |
1617 | { if (TREE_CODE ($2) == IDENTIFIER_NODE) | |
1618 | goto do_scoped_id; | |
1619 | goto do_scoped_operator; | |
1620 | } | |
1621 | ; | |
1622 | */ | |
1623 | ||
1624 | new: NEW | |
8d08fdba | 1625 | { $$ = 0; } |
39211cd5 | 1626 | | global_scope NEW |
a28e3c7f | 1627 | { got_scope = NULL_TREE; $$ = 1; } |
8d08fdba MS |
1628 | ; |
1629 | ||
1630 | delete: DELETE | |
a28e3c7f MS |
1631 | { $$ = 0; } |
1632 | | global_scope delete | |
1633 | { got_scope = NULL_TREE; $$ = 1; } | |
8d08fdba MS |
1634 | ; |
1635 | ||
2986ae00 MS |
1636 | boolean.literal: |
1637 | CXX_TRUE | |
255512c1 | 1638 | { $$ = boolean_true_node; } |
2986ae00 | 1639 | | CXX_FALSE |
255512c1 | 1640 | { $$ = boolean_false_node; } |
2986ae00 MS |
1641 | ; |
1642 | ||
8d08fdba MS |
1643 | /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */ |
1644 | string: | |
1645 | STRING | |
1646 | | string STRING | |
1647 | { $$ = chainon ($$, $2); } | |
1648 | ; | |
1649 | ||
1650 | nodecls: | |
1651 | /* empty */ | |
1652 | { | |
1653 | if (! current_function_parms_stored) | |
1654 | store_parm_decls (); | |
1655 | setup_vtbl_ptr (); | |
1656 | /* Always keep the BLOCK node associated with the outermost | |
1657 | pair of curley braces of a function. These are needed | |
1658 | for correct operation of dwarfout.c. */ | |
1659 | keep_next_level (); | |
1660 | } | |
1661 | ; | |
1662 | ||
1663 | object: primary '.' | |
e1cd6e56 | 1664 | { got_object = TREE_TYPE ($$); } |
8d08fdba MS |
1665 | | primary POINTSAT |
1666 | { | |
e1cd6e56 MS |
1667 | $$ = build_x_arrow ($$); |
1668 | got_object = TREE_TYPE ($$); | |
8d08fdba MS |
1669 | } |
1670 | ; | |
1671 | ||
8d08fdba | 1672 | decl: |
a28e3c7f MS |
1673 | /* Normal case: make this fast. */ |
1674 | typespec declarator ';' | |
46b02c6d | 1675 | { tree d = get_decl_list ($1.t); |
a28e3c7f MS |
1676 | int yes = suspend_momentary (); |
1677 | d = start_decl ($2, d, 0, NULL_TREE); | |
9e9ff709 | 1678 | cp_finish_decl (d, NULL_TREE, NULL_TREE, 1, 0); |
a28e3c7f | 1679 | resume_momentary (yes); |
46b02c6d MS |
1680 | if (IS_AGGR_TYPE_CODE (TREE_CODE ($1.t))) |
1681 | note_got_semicolon ($1.t); | |
8d08fdba | 1682 | } |
8d08fdba | 1683 | | typed_declspecs declarator ';' |
f30432d7 MS |
1684 | { tree d, specs, attrs; |
1685 | int yes; | |
46b02c6d | 1686 | split_specs_attrs ($1.t, &specs, &attrs); |
f30432d7 MS |
1687 | yes = suspend_momentary (); |
1688 | d = start_decl ($2, specs, 0, NULL_TREE); | |
1689 | cplus_decl_attributes (d, NULL_TREE, attrs); | |
9e9ff709 | 1690 | cp_finish_decl (d, NULL_TREE, NULL_TREE, 1, 0); |
8d08fdba | 1691 | resume_momentary (yes); |
46b02c6d | 1692 | note_list_got_semicolon ($1.t); |
51c184be | 1693 | } |
a28e3c7f MS |
1694 | | typespec initdecls ';' |
1695 | { | |
1696 | resume_momentary ($2); | |
46b02c6d MS |
1697 | if (IS_AGGR_TYPE_CODE (TREE_CODE ($1.t))) |
1698 | note_got_semicolon ($1.t); | |
8d08fdba | 1699 | } |
a28e3c7f MS |
1700 | | typed_declspecs initdecls ';' |
1701 | { | |
1702 | resume_momentary ($2); | |
46b02c6d | 1703 | note_list_got_semicolon ($1.t); |
8d08fdba | 1704 | } |
a28e3c7f MS |
1705 | | declmods notype_initdecls ';' |
1706 | { resume_momentary ($2); } | |
8d08fdba MS |
1707 | | typed_declspecs ';' |
1708 | { | |
46b02c6d MS |
1709 | shadow_tag ($1.t); |
1710 | note_list_got_semicolon ($1.t); | |
8d08fdba MS |
1711 | } |
1712 | | declmods ';' | |
1713 | { warning ("empty declaration"); } | |
1714 | ; | |
1715 | ||
1716 | /* Any kind of declarator (thus, all declarators allowed | |
1717 | after an explicit typespec). */ | |
1718 | ||
1719 | declarator: | |
51c184be MS |
1720 | after_type_declarator %prec EMPTY |
1721 | | notype_declarator %prec EMPTY | |
1722 | ; | |
1723 | ||
1724 | /* This is necessary to postpone reduction of `int()()()()'. */ | |
1725 | fcast_or_absdcl: | |
1726 | LEFT_RIGHT %prec EMPTY | |
1727 | { $$ = build_parse_node (CALL_EXPR, NULL_TREE, empty_parms (), | |
1728 | NULL_TREE); } | |
1729 | | fcast_or_absdcl LEFT_RIGHT %prec EMPTY | |
1730 | { $$ = build_parse_node (CALL_EXPR, $$, empty_parms (), | |
1731 | NULL_TREE); } | |
1732 | ; | |
1733 | ||
1734 | /* ANSI type-id (8.1) */ | |
1735 | type_id: | |
1736 | typed_typespecs absdcl | |
46b02c6d MS |
1737 | { $$.t = build_decl_list ($1.t, $2); |
1738 | $$.new_type_flag = $1.new_type_flag; } | |
51c184be | 1739 | | nonempty_type_quals absdcl |
46b02c6d MS |
1740 | { $$.t = build_decl_list ($1.t, $2); |
1741 | $$.new_type_flag = $1.new_type_flag; } | |
51c184be | 1742 | | typespec absdcl |
46b02c6d MS |
1743 | { $$.t = build_decl_list (get_decl_list ($1.t), $2); |
1744 | $$.new_type_flag = $1.new_type_flag; } | |
51c184be | 1745 | | typed_typespecs %prec EMPTY |
46b02c6d MS |
1746 | { $$.t = build_decl_list ($1.t, NULL_TREE); |
1747 | $$.new_type_flag = $1.new_type_flag; } | |
51c184be | 1748 | | nonempty_type_quals %prec EMPTY |
46b02c6d MS |
1749 | { $$.t = build_decl_list ($1.t, NULL_TREE); |
1750 | $$.new_type_flag = $1.new_type_flag; } | |
8d08fdba MS |
1751 | ; |
1752 | ||
1753 | /* Declspecs which contain at least one type specifier or typedef name. | |
1754 | (Just `const' or `volatile' is not enough.) | |
f30432d7 MS |
1755 | A typedef'd name following these is taken as a name to be declared. |
1756 | In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */ | |
8d08fdba MS |
1757 | |
1758 | typed_declspecs: | |
51c184be MS |
1759 | typed_typespecs %prec EMPTY |
1760 | | typed_declspecs1 | |
8ccc31eb | 1761 | ; |
51c184be MS |
1762 | |
1763 | typed_declspecs1: | |
1764 | declmods typespec | |
46b02c6d MS |
1765 | { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1); |
1766 | $$.new_type_flag = $2.new_type_flag; } | |
8d08fdba | 1767 | | typespec reserved_declspecs %prec HYPERUNARY |
46b02c6d MS |
1768 | { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2); |
1769 | $$.new_type_flag = $1.new_type_flag; } | |
b7484fbe | 1770 | | typespec reserved_typespecquals reserved_declspecs |
46b02c6d MS |
1771 | { $$.t = decl_tree_cons (NULL_TREE, $1.t, chainon ($2, $3)); |
1772 | $$.new_type_flag = $1.new_type_flag; } | |
8d08fdba | 1773 | | declmods typespec reserved_declspecs |
46b02c6d MS |
1774 | { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1)); |
1775 | $$.new_type_flag = $2.new_type_flag; } | |
8d2733ca | 1776 | | declmods typespec reserved_typespecquals |
46b02c6d MS |
1777 | { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1)); |
1778 | $$.new_type_flag = $2.new_type_flag; } | |
8d2733ca | 1779 | | declmods typespec reserved_typespecquals reserved_declspecs |
46b02c6d MS |
1780 | { $$.t = decl_tree_cons (NULL_TREE, $2.t, |
1781 | chainon ($3, chainon ($4, $1))); | |
1782 | $$.new_type_flag = $2.new_type_flag; } | |
8d08fdba MS |
1783 | ; |
1784 | ||
51c184be MS |
1785 | reserved_declspecs: |
1786 | SCSPEC | |
8d08fdba MS |
1787 | { if (extra_warnings) |
1788 | warning ("`%s' is not at beginning of declaration", | |
1789 | IDENTIFIER_POINTER ($$)); | |
1790 | $$ = build_decl_list (NULL_TREE, $$); } | |
1791 | | reserved_declspecs typespecqual_reserved | |
46b02c6d | 1792 | { $$ = decl_tree_cons (NULL_TREE, $2.t, $$); } |
8d08fdba MS |
1793 | | reserved_declspecs SCSPEC |
1794 | { if (extra_warnings) | |
1795 | warning ("`%s' is not at beginning of declaration", | |
1796 | IDENTIFIER_POINTER ($2)); | |
1797 | $$ = decl_tree_cons (NULL_TREE, $2, $$); } | |
f30432d7 MS |
1798 | | reserved_declspecs attributes |
1799 | { $$ = decl_tree_cons ($2, NULL_TREE, $1); } | |
1800 | | attributes | |
1801 | { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); } | |
8d08fdba MS |
1802 | ; |
1803 | ||
1804 | /* List of just storage classes and type modifiers. | |
1805 | A declaration can start with just this, but then it cannot be used | |
f30432d7 MS |
1806 | to redeclare a typedef-name. |
1807 | In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */ | |
8d08fdba MS |
1808 | |
1809 | declmods: | |
51c184be | 1810 | nonempty_type_quals %prec EMPTY |
46b02c6d | 1811 | { $$ = $1.t; TREE_STATIC ($$) = 1; } |
8d08fdba MS |
1812 | | SCSPEC |
1813 | { $$ = IDENTIFIER_AS_LIST ($$); } | |
1814 | | declmods TYPE_QUAL | |
51c184be | 1815 | { $$ = decl_tree_cons (NULL_TREE, $2, $$); |
8d08fdba MS |
1816 | TREE_STATIC ($$) = 1; } |
1817 | | declmods SCSPEC | |
1818 | { if (extra_warnings && TREE_STATIC ($$)) | |
1819 | warning ("`%s' is not at beginning of declaration", | |
1820 | IDENTIFIER_POINTER ($2)); | |
51c184be | 1821 | $$ = decl_tree_cons (NULL_TREE, $2, $$); |
8d08fdba | 1822 | TREE_STATIC ($$) = TREE_STATIC ($1); } |
f30432d7 MS |
1823 | | declmods attributes |
1824 | { $$ = decl_tree_cons ($2, NULL_TREE, $1); } | |
1825 | | attributes | |
1826 | { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); } | |
8d08fdba MS |
1827 | ; |
1828 | ||
8d08fdba MS |
1829 | /* Used instead of declspecs where storage classes are not allowed |
1830 | (that is, for typenames and structure components). | |
1831 | ||
1832 | C++ can takes storage classes for structure components. | |
1833 | Don't accept a typedef-name if anything but a modifier precedes it. */ | |
1834 | ||
1835 | typed_typespecs: | |
1836 | typespec %prec EMPTY | |
46b02c6d MS |
1837 | { $$.t = get_decl_list ($1.t); |
1838 | $$.new_type_flag = $1.new_type_flag; } | |
8d08fdba | 1839 | | nonempty_type_quals typespec |
46b02c6d MS |
1840 | { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1.t); |
1841 | $$.new_type_flag = $2.new_type_flag; } | |
8d08fdba | 1842 | | typespec reserved_typespecquals |
46b02c6d MS |
1843 | { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2); |
1844 | $$.new_type_flag = $1.new_type_flag; } | |
8d08fdba | 1845 | | nonempty_type_quals typespec reserved_typespecquals |
46b02c6d MS |
1846 | { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t)); |
1847 | $$.new_type_flag = $1.new_type_flag; } | |
8d08fdba MS |
1848 | ; |
1849 | ||
1850 | reserved_typespecquals: | |
1851 | typespecqual_reserved | |
46b02c6d | 1852 | { $$ = build_decl_list (NULL_TREE, $1.t); } |
8d08fdba | 1853 | | reserved_typespecquals typespecqual_reserved |
46b02c6d | 1854 | { $$ = decl_tree_cons (NULL_TREE, $2.t, $1); } |
8d08fdba MS |
1855 | ; |
1856 | ||
1857 | /* A typespec (but not a type qualifier). | |
1858 | Once we have seen one of these in a declaration, | |
1859 | if a typedef name appears then it is being redeclared. */ | |
1860 | ||
1861 | typespec: structsp | |
1862 | | TYPESPEC %prec EMPTY | |
46b02c6d | 1863 | { $$.t = $1; $$.new_type_flag = 0; } |
a28e3c7f | 1864 | | complete_type_name |
46b02c6d | 1865 | { $$.t = $1; $$.new_type_flag = 0; } |
8d08fdba | 1866 | | TYPEOF '(' expr ')' |
46b02c6d MS |
1867 | { $$.t = TREE_TYPE ($3); |
1868 | $$.new_type_flag = 0; | |
f30432d7 | 1869 | if (pedantic && !in_system_header) |
8d08fdba | 1870 | pedwarn ("ANSI C++ forbids `typeof'"); } |
51c184be | 1871 | | TYPEOF '(' type_id ')' |
46b02c6d | 1872 | { $$.t = groktypename ($3.t); |
f30432d7 | 1873 | if (pedantic && !in_system_header) |
46b02c6d MS |
1874 | pedwarn ("ANSI C++ forbids `typeof'"); |
1875 | $$.new_type_flag = 0; } | |
8d08fdba MS |
1876 | | SIGOF '(' expr ')' |
1877 | { tree type = TREE_TYPE ($3); | |
1878 | ||
46b02c6d | 1879 | $$.new_type_flag = 0; |
8d08fdba MS |
1880 | if (IS_AGGR_TYPE (type)) |
1881 | { | |
1882 | sorry ("sigof type specifier"); | |
46b02c6d | 1883 | $$.t = type; |
8d08fdba MS |
1884 | } |
1885 | else | |
1886 | { | |
1887 | error ("`sigof' applied to non-aggregate expression"); | |
46b02c6d | 1888 | $$.t = error_mark_node; |
8d08fdba MS |
1889 | } |
1890 | } | |
51c184be | 1891 | | SIGOF '(' type_id ')' |
46b02c6d | 1892 | { tree type = groktypename ($3.t); |
8d08fdba | 1893 | |
46b02c6d | 1894 | $$.new_type_flag = 0; |
8d08fdba MS |
1895 | if (IS_AGGR_TYPE (type)) |
1896 | { | |
1897 | sorry ("sigof type specifier"); | |
46b02c6d | 1898 | $$.t = type; |
8d08fdba MS |
1899 | } |
1900 | else | |
1901 | { | |
8d2733ca | 1902 | error("`sigof' applied to non-aggregate type"); |
46b02c6d | 1903 | $$.t = error_mark_node; |
8d08fdba MS |
1904 | } |
1905 | } | |
8d08fdba MS |
1906 | ; |
1907 | ||
1908 | /* A typespec that is a reserved word, or a type qualifier. */ | |
1909 | ||
1910 | typespecqual_reserved: TYPESPEC | |
46b02c6d | 1911 | { $$.t = $1; $$.new_type_flag = 0; } |
8d08fdba | 1912 | | TYPE_QUAL |
46b02c6d | 1913 | { $$.t = $1; $$.new_type_flag = 0; } |
8d08fdba MS |
1914 | | structsp |
1915 | ; | |
1916 | ||
1917 | initdecls: | |
1918 | initdcl0 | |
1919 | | initdecls ',' initdcl | |
1920 | ; | |
1921 | ||
1922 | notype_initdecls: | |
1923 | notype_initdcl0 | |
1924 | | notype_initdecls ',' initdcl | |
1925 | ; | |
1926 | ||
a28e3c7f MS |
1927 | nomods_initdecls: |
1928 | nomods_initdcl0 | |
1929 | | nomods_initdecls ',' initdcl | |
1930 | ; | |
1931 | ||
8d08fdba MS |
1932 | maybeasm: |
1933 | /* empty */ | |
1934 | { $$ = NULL_TREE; } | |
1935 | | asm_keyword '(' string ')' | |
1936 | { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); $$ = $3; } | |
1937 | ; | |
1938 | ||
1939 | initdcl0: | |
e3417fcd | 1940 | declarator exception_specification_opt maybeasm maybe_attribute '=' |
f30432d7 MS |
1941 | { split_specs_attrs ($<ttype>0, ¤t_declspecs, |
1942 | &prefix_attributes); | |
51c184be MS |
1943 | if (TREE_CODE (current_declspecs) != TREE_LIST) |
1944 | current_declspecs = get_decl_list (current_declspecs); | |
8926095f MS |
1945 | if (have_extern_spec && !used_extern_spec) |
1946 | { | |
1947 | current_declspecs = decl_tree_cons | |
1948 | (NULL_TREE, get_identifier ("extern"), | |
1949 | current_declspecs); | |
1950 | used_extern_spec = 1; | |
1951 | } | |
8d08fdba MS |
1952 | $<itype>5 = suspend_momentary (); |
1953 | $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1, $2); | |
f6abb50a | 1954 | cplus_decl_attributes ($<ttype>$, $4, prefix_attributes); } |
8d08fdba MS |
1955 | init |
1956 | /* Note how the declaration of the variable is in effect while its init is parsed! */ | |
9e9ff709 | 1957 | { cp_finish_decl ($<ttype>6, $7, $3, 1, LOOKUP_ONLYCONVERTING); |
8d08fdba | 1958 | $$ = $<itype>5; } |
e3417fcd | 1959 | | declarator exception_specification_opt maybeasm maybe_attribute |
8d08fdba | 1960 | { tree d; |
f30432d7 MS |
1961 | split_specs_attrs ($<ttype>0, ¤t_declspecs, |
1962 | &prefix_attributes); | |
51c184be MS |
1963 | if (TREE_CODE (current_declspecs) != TREE_LIST) |
1964 | current_declspecs = get_decl_list (current_declspecs); | |
8926095f MS |
1965 | if (have_extern_spec && !used_extern_spec) |
1966 | { | |
1967 | current_declspecs = decl_tree_cons | |
1968 | (NULL_TREE, get_identifier ("extern"), | |
1969 | current_declspecs); | |
1970 | used_extern_spec = 1; | |
1971 | } | |
8d08fdba MS |
1972 | $$ = suspend_momentary (); |
1973 | d = start_decl ($<ttype>1, current_declspecs, 0, $2); | |
f6abb50a | 1974 | cplus_decl_attributes (d, $4, prefix_attributes); |
9e9ff709 | 1975 | cp_finish_decl (d, NULL_TREE, $3, 1, 0); } |
8d08fdba MS |
1976 | ; |
1977 | ||
1978 | initdcl: | |
e3417fcd | 1979 | declarator exception_specification_opt maybeasm maybe_attribute '=' |
8d08fdba | 1980 | { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1, $2); |
f6abb50a | 1981 | cplus_decl_attributes ($<ttype>$, $4, prefix_attributes); } |
8d08fdba MS |
1982 | init |
1983 | /* Note how the declaration of the variable is in effect while its init is parsed! */ | |
9e9ff709 | 1984 | { cp_finish_decl ($<ttype>6, $7, $3, 1, LOOKUP_ONLYCONVERTING); } |
e3417fcd | 1985 | | declarator exception_specification_opt maybeasm maybe_attribute |
2986ae00 | 1986 | { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 0, $2); |
f6abb50a | 1987 | cplus_decl_attributes ($<ttype>$, $4, prefix_attributes); |
9e9ff709 | 1988 | cp_finish_decl ($<ttype>$, NULL_TREE, $3, 1, 0); } |
8d08fdba MS |
1989 | ; |
1990 | ||
1991 | notype_initdcl0: | |
e3417fcd | 1992 | notype_declarator exception_specification_opt maybeasm maybe_attribute '=' |
f30432d7 MS |
1993 | { split_specs_attrs ($<ttype>0, ¤t_declspecs, |
1994 | &prefix_attributes); | |
8d08fdba MS |
1995 | $<itype>5 = suspend_momentary (); |
1996 | $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1, $2); | |
f6abb50a | 1997 | cplus_decl_attributes ($<ttype>$, $4, prefix_attributes); } |
8d08fdba MS |
1998 | init |
1999 | /* Note how the declaration of the variable is in effect while its init is parsed! */ | |
9e9ff709 | 2000 | { cp_finish_decl ($<ttype>6, $7, $3, 1, LOOKUP_ONLYCONVERTING); |
8d08fdba | 2001 | $$ = $<itype>5; } |
e3417fcd | 2002 | | notype_declarator exception_specification_opt maybeasm maybe_attribute |
8d08fdba | 2003 | { tree d; |
f30432d7 MS |
2004 | split_specs_attrs ($<ttype>0, ¤t_declspecs, |
2005 | &prefix_attributes); | |
8d08fdba MS |
2006 | $$ = suspend_momentary (); |
2007 | d = start_decl ($<ttype>1, current_declspecs, 0, $2); | |
f6abb50a | 2008 | cplus_decl_attributes (d, $4, prefix_attributes); |
9e9ff709 | 2009 | cp_finish_decl (d, NULL_TREE, $3, 1, 0); } |
8d08fdba MS |
2010 | ; |
2011 | ||
a28e3c7f | 2012 | nomods_initdcl0: |
e3417fcd | 2013 | notype_declarator exception_specification_opt maybeasm maybe_attribute '=' |
a28e3c7f | 2014 | { current_declspecs = NULL_TREE; |
f30432d7 | 2015 | prefix_attributes = NULL_TREE; |
a28e3c7f MS |
2016 | $<itype>5 = suspend_momentary (); |
2017 | $<ttype>$ = start_decl ($1, current_declspecs, 1, $2); | |
f6abb50a | 2018 | cplus_decl_attributes ($<ttype>$, $4, prefix_attributes); } |
a28e3c7f MS |
2019 | init |
2020 | /* Note how the declaration of the variable is in effect while its init is parsed! */ | |
9e9ff709 | 2021 | { cp_finish_decl ($<ttype>6, $7, $3, 1, LOOKUP_ONLYCONVERTING); |
a28e3c7f | 2022 | $$ = $<itype>5; } |
e3417fcd | 2023 | | notype_declarator exception_specification_opt maybeasm maybe_attribute |
a28e3c7f MS |
2024 | { tree d; |
2025 | current_declspecs = NULL_TREE; | |
f30432d7 | 2026 | prefix_attributes = NULL_TREE; |
a28e3c7f MS |
2027 | $$ = suspend_momentary (); |
2028 | d = start_decl ($1, current_declspecs, 0, $2); | |
f6abb50a | 2029 | cplus_decl_attributes (d, $4, prefix_attributes); |
9e9ff709 | 2030 | cp_finish_decl (d, NULL_TREE, $3, 1, 0); } |
a28e3c7f MS |
2031 | ; |
2032 | ||
8d08fdba | 2033 | /* the * rules are dummies to accept the Apollo extended syntax |
e92cc029 | 2034 | so that the header files compile. */ |
8d08fdba | 2035 | maybe_attribute: |
2986ae00 MS |
2036 | /* empty */ |
2037 | { $$ = NULL_TREE; } | |
2038 | | attributes | |
2039 | { $$ = $1; } | |
2040 | ; | |
2041 | ||
2042 | attributes: | |
2043 | attribute | |
2044 | { $$ = $1; } | |
2045 | | attributes attribute | |
2046 | { $$ = chainon ($1, $2); } | |
2047 | ; | |
2048 | ||
2049 | attribute: | |
2050 | ATTRIBUTE '(' '(' attribute_list ')' ')' | |
2051 | { $$ = $4; } | |
2052 | ; | |
2053 | ||
2054 | attribute_list: | |
2055 | attrib | |
44a8d0b3 | 2056 | { $$ = $1; } |
2986ae00 | 2057 | | attribute_list ',' attrib |
44a8d0b3 | 2058 | { $$ = chainon ($1, $3); } |
2986ae00 MS |
2059 | ; |
2060 | ||
2061 | attrib: | |
8d08fdba | 2062 | /* empty */ |
2986ae00 MS |
2063 | { $$ = NULL_TREE; } |
2064 | | any_word | |
44a8d0b3 | 2065 | { $$ = build_tree_list ($1, NULL_TREE); } |
2986ae00 | 2066 | | any_word '(' IDENTIFIER ')' |
44a8d0b3 | 2067 | { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); } |
2986ae00 | 2068 | | any_word '(' IDENTIFIER ',' nonnull_exprlist ')' |
44a8d0b3 | 2069 | { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); } |
2986ae00 | 2070 | | any_word '(' nonnull_exprlist ')' |
44a8d0b3 | 2071 | { $$ = build_tree_list ($1, $3); } |
2986ae00 MS |
2072 | ; |
2073 | ||
2074 | /* This still leaves out most reserved keywords, | |
2075 | shouldn't we include them? */ | |
2076 | ||
2077 | any_word: | |
2078 | identifier | |
2079 | | SCSPEC | |
2080 | | TYPESPEC | |
2081 | | TYPE_QUAL | |
2082 | ; | |
8d08fdba MS |
2083 | |
2084 | /* A nonempty list of identifiers, including typenames. */ | |
2085 | identifiers_or_typenames: | |
2086 | identifier | |
2087 | { $$ = build_tree_list (NULL_TREE, $1); } | |
2088 | | identifiers_or_typenames ',' identifier | |
2089 | { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); } | |
2090 | ; | |
2091 | ||
e3417fcd MS |
2092 | maybe_init: |
2093 | %prec EMPTY /* empty */ | |
2094 | { $$ = NULL_TREE; } | |
2095 | | '=' init | |
2096 | { $$ = $2; } | |
2097 | ||
5566b478 MS |
2098 | /* If we are processing a template, we don't want to expand this |
2099 | initializer yet. */ | |
2100 | ||
8d08fdba MS |
2101 | init: |
2102 | expr_no_commas %prec '=' | |
2103 | | '{' '}' | |
2104 | { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE); | |
9a0e77ba | 2105 | TREE_HAS_CONSTRUCTOR ($$) = 1; } |
8d08fdba MS |
2106 | | '{' initlist '}' |
2107 | { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2)); | |
2108 | TREE_HAS_CONSTRUCTOR ($$) = 1; } | |
2109 | | '{' initlist ',' '}' | |
2110 | { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2)); | |
2111 | TREE_HAS_CONSTRUCTOR ($$) = 1; } | |
2112 | | error | |
2113 | { $$ = NULL_TREE; } | |
2114 | ; | |
2115 | ||
2116 | /* This chain is built in reverse order, | |
2117 | and put in forward order where initlist is used. */ | |
2118 | initlist: | |
2119 | init | |
2120 | { $$ = build_tree_list (NULL_TREE, $$); } | |
2121 | | initlist ',' init | |
2122 | { $$ = tree_cons (NULL_TREE, $3, $$); } | |
2123 | /* These are for labeled elements. */ | |
2124 | | '[' expr_no_commas ']' init | |
2125 | { $$ = build_tree_list ($2, $4); } | |
2126 | | initlist ',' CASE expr_no_commas ':' init | |
2127 | { $$ = tree_cons ($4, $6, $$); } | |
2128 | | identifier ':' init | |
2129 | { $$ = build_tree_list ($$, $3); } | |
2130 | | initlist ',' identifier ':' init | |
2131 | { $$ = tree_cons ($3, $5, $$); } | |
2132 | ; | |
2133 | ||
5566b478 MS |
2134 | fn.defpen: |
2135 | PRE_PARSED_FUNCTION_DECL | |
2136 | { start_function (NULL_TREE, TREE_VALUE ($1), | |
2137 | NULL_TREE, NULL_TREE, 1); | |
2138 | reinit_parse_for_function (); } | |
2139 | ||
2140 | pending_inlines: | |
2141 | /* empty */ | |
2142 | | pending_inlines fn.defpen maybe_return_init ctor_initializer_opt | |
2143 | compstmt_or_error | |
2144 | { | |
fc378698 MS |
2145 | int nested = (hack_decl_function_context |
2146 | (current_function_decl) != NULL_TREE); | |
2147 | finish_function (lineno, (int)$4, nested); | |
5566b478 MS |
2148 | process_next_inline ($2); |
2149 | } | |
2150 | | pending_inlines fn.defpen maybe_return_init function_try_block | |
2151 | { process_next_inline ($2); } | |
2152 | eat_saved_input | |
2153 | ; | |
2154 | ||
8d08fdba MS |
2155 | structsp: |
2156 | ENUM identifier '{' | |
2157 | { $<itype>3 = suspend_momentary (); | |
46b02c6d | 2158 | $<ttype>$ = start_enum ($2); } |
8d08fdba | 2159 | enumlist maybecomma_warn '}' |
46b02c6d MS |
2160 | { $$.t = finish_enum ($<ttype>4, $5); |
2161 | $$.new_type_flag = 1; | |
8d08fdba MS |
2162 | resume_momentary ((int) $<itype>3); |
2163 | check_for_missing_semicolon ($<ttype>4); } | |
2164 | | ENUM identifier '{' '}' | |
46b02c6d MS |
2165 | { $$.t = finish_enum (start_enum ($2), NULL_TREE); |
2166 | $$.new_type_flag = 1; | |
2167 | check_for_missing_semicolon ($$.t); } | |
8d08fdba MS |
2168 | | ENUM '{' |
2169 | { $<itype>2 = suspend_momentary (); | |
46b02c6d | 2170 | $<ttype>$ = start_enum (make_anon_name ()); } |
8d08fdba | 2171 | enumlist maybecomma_warn '}' |
46b02c6d | 2172 | { $$.t = finish_enum ($<ttype>3, $4); |
8d08fdba | 2173 | resume_momentary ((int) $<itype>1); |
46b02c6d MS |
2174 | check_for_missing_semicolon ($<ttype>3); |
2175 | $$.new_type_flag = 1; } | |
8d08fdba | 2176 | | ENUM '{' '}' |
46b02c6d MS |
2177 | { $$.t = finish_enum (start_enum (make_anon_name()), NULL_TREE); |
2178 | $$.new_type_flag = 1; | |
2179 | check_for_missing_semicolon ($$.t); } | |
8d08fdba | 2180 | | ENUM identifier |
46b02c6d MS |
2181 | { $$.t = xref_tag (enum_type_node, $2, NULL_TREE, 1); |
2182 | $$.new_type_flag = 0; } | |
a28e3c7f | 2183 | | ENUM complex_type_name |
46b02c6d MS |
2184 | { $$.t = xref_tag (enum_type_node, $2, NULL_TREE, 1); |
2185 | $$.new_type_flag = 0; } | |
5566b478 | 2186 | | TYPENAME_KEYWORD nested_name_specifier identifier |
46b02c6d MS |
2187 | { $$.t = make_typename_type ($2, $3); |
2188 | $$.new_type_flag = 0; } | |
5566b478 | 2189 | | TYPENAME_KEYWORD global_scope nested_name_specifier identifier |
46b02c6d MS |
2190 | { $$.t = make_typename_type ($3, $4); |
2191 | $$.new_type_flag = 0; } | |
8d08fdba | 2192 | /* C++ extensions, merged with C to avoid shift/reduce conflicts */ |
2ee887f2 | 2193 | | class_head left_curly opt.component_decl_list '}' maybe_attribute |
8d08fdba MS |
2194 | { |
2195 | int semi; | |
2196 | tree id; | |
2197 | ||
46b02c6d | 2198 | $<ttype>$ = $1; |
8d08fdba MS |
2199 | #if 0 |
2200 | /* Need to rework class nesting in the | |
2201 | presence of nested classes, etc. */ | |
5566b478 | 2202 | shadow_tag (CLASSTYPE_AS_LIST ($1)); */ |
8d08fdba MS |
2203 | #endif |
2204 | if (yychar == YYEMPTY) | |
2205 | yychar = YYLEX; | |
2206 | semi = yychar == ';'; | |
2207 | /* finish_struct nukes this anyway; if | |
e92cc029 | 2208 | finish_exception does too, then it can go. */ |
8d08fdba | 2209 | if (semi) |
5566b478 | 2210 | note_got_semicolon ($1); |
8d08fdba | 2211 | |
5566b478 MS |
2212 | if (TREE_CODE ($1) == ENUMERAL_TYPE) |
2213 | ; | |
8d08fdba MS |
2214 | else |
2215 | { | |
5566b478 MS |
2216 | $<ttype>$ = finish_struct ($1, $3, $5, semi); |
2217 | if (semi) note_got_semicolon ($<ttype>$); | |
8d08fdba MS |
2218 | } |
2219 | ||
2220 | pop_obstacks (); | |
2221 | ||
8d08fdba | 2222 | if (! semi) |
5566b478 MS |
2223 | check_for_missing_semicolon ($1); |
2224 | if (pending_inlines | |
2225 | && current_scope () == current_function_decl) | |
2226 | do_pending_inlines (); | |
2227 | } | |
2228 | pending_inlines | |
46b02c6d MS |
2229 | { $$.t = $<ttype>6; |
2230 | $$.new_type_flag = 1; } | |
8d08fdba MS |
2231 | | class_head %prec EMPTY |
2232 | { | |
46b02c6d MS |
2233 | $$.t = $1; |
2234 | $$.new_type_flag = 0; | |
8ccc31eb | 2235 | /* struct B: public A; is not accepted by the WP grammar. */ |
46b02c6d MS |
2236 | if (TYPE_BINFO_BASETYPES ($$.t) && !TYPE_SIZE ($$.t) |
2237 | && ! TYPE_BEING_DEFINED ($$.t)) | |
8ccc31eb | 2238 | cp_error ("base clause without member specification for `%#T'", |
46b02c6d | 2239 | $$.t); |
8d08fdba MS |
2240 | } |
2241 | ; | |
2242 | ||
2243 | maybecomma: | |
2244 | /* empty */ | |
2245 | | ',' | |
2246 | ; | |
2247 | ||
2248 | maybecomma_warn: | |
2249 | /* empty */ | |
2250 | | ',' | |
594740f3 MS |
2251 | { if (pedantic && !in_system_header) |
2252 | pedwarn ("comma at end of enumerator list"); } | |
8d08fdba MS |
2253 | ; |
2254 | ||
2255 | aggr: AGGR | |
2256 | | aggr SCSPEC | |
2257 | { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); } | |
2258 | | aggr TYPESPEC | |
2259 | { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); } | |
2260 | | aggr TYPE_QUAL | |
2261 | { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); } | |
2262 | | aggr AGGR | |
2263 | { error ("no body nor ';' separates two class, struct or union declarations"); } | |
2264 | ; | |
2265 | ||
2266 | named_class_head_sans_basetype: | |
2267 | aggr identifier | |
8d08fdba | 2268 | { current_aggr = $$; $$ = $2; } |
8ccc31eb MS |
2269 | ; |
2270 | ||
2271 | named_class_head_sans_basetype_defn: | |
2272 | aggr identifier_defn %prec EMPTY | |
2273 | { current_aggr = $$; $$ = $2; } | |
8d08fdba MS |
2274 | ; |
2275 | ||
07674418 MS |
2276 | named_complex_class_head_sans_basetype: |
2277 | aggr nested_name_specifier identifier | |
fc378698 MS |
2278 | { |
2279 | current_aggr = $1; | |
2280 | if (TREE_CODE ($3) == TYPE_DECL) | |
2281 | $$ = $3; | |
2282 | else | |
2283 | { | |
2284 | cp_error ("`%T' does not have a nested type named `%D'", | |
2285 | $2, $3); | |
2286 | $$ = xref_tag | |
2287 | (current_aggr, make_anon_name (), NULL_TREE, 1); | |
2288 | $$ = TYPE_MAIN_DECL ($$); | |
2289 | } | |
2290 | } | |
5566b478 | 2291 | | aggr template_type |
07674418 | 2292 | { current_aggr = $$; $$ = $2; } |
5566b478 MS |
2293 | | aggr nested_name_specifier template_type |
2294 | { current_aggr = $$; $$ = $3; } | |
07674418 MS |
2295 | ; |
2296 | ||
51c184be | 2297 | do_xref_defn: /* empty */ %prec EMPTY |
8ccc31eb MS |
2298 | { $<ttype>$ = xref_tag (current_aggr, $<ttype>0, NULL_TREE, 0); } |
2299 | ; | |
51c184be | 2300 | |
8d08fdba | 2301 | named_class_head: |
8ccc31eb MS |
2302 | named_class_head_sans_basetype %prec EMPTY |
2303 | { $$ = xref_tag (current_aggr, $1, NULL_TREE, 1); } | |
2304 | | named_class_head_sans_basetype_defn do_xref_defn | |
2305 | maybe_base_class_list %prec EMPTY | |
2306 | { | |
2307 | $$ = $<ttype>2; | |
8d08fdba | 2308 | if ($3) |
8ccc31eb | 2309 | xref_basetypes (current_aggr, $1, $<ttype>2, $3); |
8d08fdba | 2310 | } |
07674418 MS |
2311 | | named_complex_class_head_sans_basetype maybe_base_class_list |
2312 | { | |
2313 | $$ = TREE_TYPE ($1); | |
ec255269 MS |
2314 | if (TREE_INT_CST_LOW (current_aggr) == union_type |
2315 | && TREE_CODE ($$) != UNION_TYPE) | |
2316 | cp_pedwarn ("`union' tag used in declaring `%#T'", $$); | |
2317 | else if (TREE_CODE ($$) == UNION_TYPE | |
2318 | && TREE_INT_CST_LOW (current_aggr) != union_type) | |
2319 | cp_pedwarn ("non-`union' tag used in declaring `%#T'", $$); | |
07674418 | 2320 | if ($2) |
ec255269 MS |
2321 | { |
2322 | if (IS_AGGR_TYPE ($$) && CLASSTYPE_USE_TEMPLATE ($$)) | |
2323 | { | |
2324 | if (CLASSTYPE_IMPLICIT_INSTANTIATION ($$) | |
2325 | && TYPE_SIZE ($$) == NULL_TREE) | |
73aad9b9 JM |
2326 | { |
2327 | SET_CLASSTYPE_TEMPLATE_SPECIALIZATION ($$); | |
2328 | if (current_template_parms) | |
2329 | push_template_decl (TYPE_MAIN_DECL ($$)); | |
2330 | } | |
ec255269 MS |
2331 | else if (CLASSTYPE_TEMPLATE_INSTANTIATION ($$)) |
2332 | cp_error ("specialization after instantiation of `%T'", $$); | |
2333 | } | |
2334 | xref_basetypes (current_aggr, $1, $$, $2); | |
2335 | } | |
07674418 | 2336 | } |
8d08fdba MS |
2337 | ; |
2338 | ||
2339 | unnamed_class_head: aggr '{' | |
2340 | { $$ = xref_tag ($$, make_anon_name (), NULL_TREE, 0); | |
2341 | yyungetc ('{', 1); } | |
2342 | ; | |
2343 | ||
2344 | class_head: unnamed_class_head | named_class_head ; | |
2345 | ||
2346 | maybe_base_class_list: | |
2347 | %prec EMPTY /* empty */ | |
2348 | { $$ = NULL_TREE; } | |
f30432d7 | 2349 | | ':' see_typename %prec EMPTY |
8d08fdba | 2350 | { yyungetc(':', 1); $$ = NULL_TREE; } |
f30432d7 MS |
2351 | | ':' see_typename base_class_list %prec EMPTY |
2352 | { $$ = $3; } | |
8d08fdba MS |
2353 | ; |
2354 | ||
2355 | base_class_list: | |
2356 | base_class | |
f30432d7 MS |
2357 | | base_class_list ',' see_typename base_class |
2358 | { $$ = chainon ($$, $4); } | |
8d08fdba MS |
2359 | ; |
2360 | ||
2361 | base_class: | |
2362 | base_class.1 | |
2363 | { | |
45537677 | 2364 | tree type = TREE_TYPE ($1); |
be99da77 | 2365 | if (! is_aggr_type (type, 1)) |
8d08fdba MS |
2366 | $$ = NULL_TREE; |
2367 | else if (current_aggr == signature_type_node | |
2368 | && (! type) && (! IS_SIGNATURE (type))) | |
2369 | { | |
2370 | error ("class name not allowed as base signature"); | |
2371 | $$ = NULL_TREE; | |
2372 | } | |
2373 | else if (current_aggr == signature_type_node) | |
2374 | { | |
2375 | sorry ("signature inheritance, base type `%s' ignored", | |
2376 | IDENTIFIER_POINTER ($$)); | |
45537677 | 2377 | $$ = build_tree_list (access_public_node, type); |
8d08fdba MS |
2378 | } |
2379 | else if (type && IS_SIGNATURE (type)) | |
2380 | { | |
2381 | error ("signature name not allowed as base class"); | |
2382 | $$ = NULL_TREE; | |
2383 | } | |
2384 | else | |
45537677 | 2385 | $$ = build_tree_list (access_default_node, type); |
8d08fdba | 2386 | } |
f30432d7 | 2387 | | base_class_access_list see_typename base_class.1 |
8d08fdba | 2388 | { |
45537677 | 2389 | tree type = TREE_TYPE ($3); |
8d08fdba MS |
2390 | if (current_aggr == signature_type_node) |
2391 | error ("access and source specifiers not allowed in signature"); | |
be99da77 | 2392 | if (! IS_AGGR_TYPE (type)) |
8d08fdba MS |
2393 | $$ = NULL_TREE; |
2394 | else if (current_aggr == signature_type_node | |
2395 | && (! type) && (! IS_SIGNATURE (type))) | |
2396 | { | |
2397 | error ("class name not allowed as base signature"); | |
2398 | $$ = NULL_TREE; | |
2399 | } | |
2400 | else if (current_aggr == signature_type_node) | |
2401 | { | |
2402 | sorry ("signature inheritance, base type `%s' ignored", | |
2403 | IDENTIFIER_POINTER ($$)); | |
45537677 | 2404 | $$ = build_tree_list (access_public_node, type); |
8d08fdba MS |
2405 | } |
2406 | else if (type && IS_SIGNATURE (type)) | |
2407 | { | |
2408 | error ("signature name not allowed as base class"); | |
2409 | $$ = NULL_TREE; | |
2410 | } | |
2411 | else | |
45537677 | 2412 | $$ = build_tree_list ($$, type); |
8d08fdba | 2413 | } |
8d08fdba MS |
2414 | ; |
2415 | ||
8d08fdba | 2416 | base_class.1: |
a28e3c7f | 2417 | complete_type_name |
a80e4195 MS |
2418 | | TYPENAME_KEYWORD nested_name_specifier identifier |
2419 | { $$ = TYPE_MAIN_DECL (make_typename_type ($2, $3)); } | |
2420 | | TYPENAME_KEYWORD global_scope nested_name_specifier identifier | |
2421 | { $$ = TYPE_MAIN_DECL (make_typename_type ($3, $4)); } | |
8d08fdba MS |
2422 | | SIGOF '(' expr ')' |
2423 | { | |
2424 | if (current_aggr == signature_type_node) | |
2425 | { | |
2426 | if (IS_AGGR_TYPE (TREE_TYPE ($3))) | |
2427 | { | |
2428 | sorry ("`sigof' as base signature specifier"); | |
be99da77 | 2429 | $$ = TREE_TYPE ($3); |
8d08fdba MS |
2430 | } |
2431 | else | |
2432 | { | |
2433 | error ("`sigof' applied to non-aggregate expression"); | |
2434 | $$ = error_mark_node; | |
2435 | } | |
2436 | } | |
2437 | else | |
2438 | { | |
2439 | error ("`sigof' in struct or class declaration"); | |
2440 | $$ = error_mark_node; | |
2441 | } | |
2442 | } | |
51c184be | 2443 | | SIGOF '(' type_id ')' |
8d08fdba MS |
2444 | { |
2445 | if (current_aggr == signature_type_node) | |
2446 | { | |
46b02c6d | 2447 | if (IS_AGGR_TYPE (groktypename ($3.t))) |
8d08fdba MS |
2448 | { |
2449 | sorry ("`sigof' as base signature specifier"); | |
46b02c6d | 2450 | $$ = groktypename ($3.t); |
8d08fdba MS |
2451 | } |
2452 | else | |
2453 | { | |
2454 | error ("`sigof' applied to non-aggregate expression"); | |
2455 | $$ = error_mark_node; | |
2456 | } | |
2457 | } | |
2458 | else | |
2459 | { | |
2460 | error ("`sigof' in struct or class declaration"); | |
2461 | $$ = error_mark_node; | |
2462 | } | |
2463 | } | |
2464 | ; | |
2465 | ||
2466 | base_class_access_list: | |
f30432d7 MS |
2467 | VISSPEC see_typename |
2468 | | SCSPEC see_typename | |
8d08fdba MS |
2469 | { if ($<ttype>$ != ridpointers[(int)RID_VIRTUAL]) |
2470 | sorry ("non-virtual access"); | |
be99da77 | 2471 | $$ = access_default_virtual_node; } |
f30432d7 | 2472 | | base_class_access_list VISSPEC see_typename |
8d08fdba | 2473 | { int err = 0; |
be99da77 | 2474 | if ($2 == access_protected_node) |
8d08fdba MS |
2475 | { |
2476 | warning ("`protected' access not implemented"); | |
be99da77 | 2477 | $2 = access_public_node; |
8d08fdba MS |
2478 | err++; |
2479 | } | |
be99da77 | 2480 | else if ($2 == access_public_node) |
8d08fdba | 2481 | { |
be99da77 | 2482 | if ($1 == access_private_node) |
8d08fdba MS |
2483 | { |
2484 | mixed: | |
2485 | error ("base class cannot be public and private"); | |
2486 | } | |
be99da77 MS |
2487 | else if ($1 == access_default_virtual_node) |
2488 | $$ = access_public_virtual_node; | |
8d08fdba | 2489 | } |
be99da77 | 2490 | else /* $2 == access_private_node */ |
8d08fdba | 2491 | { |
be99da77 | 2492 | if ($1 == access_public_node) |
8d08fdba | 2493 | goto mixed; |
be99da77 MS |
2494 | else if ($1 == access_default_virtual_node) |
2495 | $$ = access_private_virtual_node; | |
8d08fdba MS |
2496 | } |
2497 | } | |
f30432d7 | 2498 | | base_class_access_list SCSPEC see_typename |
8d08fdba MS |
2499 | { if ($2 != ridpointers[(int)RID_VIRTUAL]) |
2500 | sorry ("non-virtual access"); | |
be99da77 MS |
2501 | if ($$ == access_public_node) |
2502 | $$ = access_public_virtual_node; | |
2503 | else if ($$ == access_private_node) | |
2504 | $$ = access_private_virtual_node; } | |
8d08fdba MS |
2505 | ; |
2506 | ||
2507 | left_curly: '{' | |
00595019 | 2508 | { tree t = $<ttype>0; |
8d08fdba MS |
2509 | push_obstacks_nochange (); |
2510 | end_temporary_allocation (); | |
2511 | ||
00595019 | 2512 | if (! IS_AGGR_TYPE (t)) |
8d08fdba | 2513 | { |
00595019 MS |
2514 | t = $<ttype>0 = make_lang_type (RECORD_TYPE); |
2515 | TYPE_NAME (t) = get_identifier ("erroneous type"); | |
8d08fdba | 2516 | } |
00595019 MS |
2517 | if (TYPE_SIZE (t)) |
2518 | duplicate_tag_error (t); | |
2519 | if (TYPE_SIZE (t) || TYPE_BEING_DEFINED (t)) | |
8d08fdba | 2520 | { |
00595019 | 2521 | t = make_lang_type (TREE_CODE (t)); |
8d08fdba MS |
2522 | pushtag (TYPE_IDENTIFIER ($<ttype>0), t, 0); |
2523 | $<ttype>0 = t; | |
2524 | } | |
5566b478 MS |
2525 | if (current_template_parms && TYPE_CONTEXT (t) |
2526 | && ! current_class_type) | |
2527 | push_template_decl (TYPE_STUB_DECL (t)); | |
00595019 MS |
2528 | pushclass (t, 0); |
2529 | TYPE_BEING_DEFINED (t) = 1; | |
5566b478 MS |
2530 | if (IS_AGGR_TYPE (t) && CLASSTYPE_USE_TEMPLATE (t)) |
2531 | { | |
2532 | if (CLASSTYPE_IMPLICIT_INSTANTIATION (t) | |
2533 | && TYPE_SIZE (t) == NULL_TREE) | |
73aad9b9 JM |
2534 | { |
2535 | SET_CLASSTYPE_TEMPLATE_SPECIALIZATION (t); | |
2536 | if (current_template_parms) | |
2537 | push_template_decl (TYPE_MAIN_DECL (t)); | |
2538 | } | |
5566b478 MS |
2539 | else if (CLASSTYPE_TEMPLATE_INSTANTIATION (t)) |
2540 | cp_error ("specialization after instantiation of `%T'", t); | |
2541 | } | |
00595019 MS |
2542 | /* Reset the interface data, at the earliest possible |
2543 | moment, as it might have been set via a class foo; | |
2544 | before. */ | |
2545 | /* Don't change signatures. */ | |
2546 | if (! IS_SIGNATURE (t)) | |
2547 | { | |
2548 | extern tree pending_vtables; | |
2549 | int needs_writing; | |
2550 | tree name = TYPE_IDENTIFIER (t); | |
2551 | ||
db5ae43f MS |
2552 | if (! ANON_AGGRNAME_P (name)) |
2553 | { | |
2554 | CLASSTYPE_INTERFACE_ONLY (t) = interface_only; | |
2555 | SET_CLASSTYPE_INTERFACE_UNKNOWN_X | |
2556 | (t, interface_unknown); | |
2557 | } | |
00595019 MS |
2558 | |
2559 | /* Record how to set the access of this class's | |
2560 | virtual functions. If write_virtuals == 2 or 3, then | |
2561 | inline virtuals are ``extern inline''. */ | |
2562 | switch (write_virtuals) | |
2563 | { | |
2564 | case 0: | |
2565 | case 1: | |
2566 | needs_writing = 1; | |
2567 | break; | |
2568 | case 2: | |
2569 | needs_writing = !! value_member (name, pending_vtables); | |
2570 | break; | |
2571 | case 3: | |
2572 | needs_writing = ! CLASSTYPE_INTERFACE_ONLY (t) | |
2573 | && CLASSTYPE_INTERFACE_KNOWN (t); | |
2574 | break; | |
2575 | default: | |
2576 | needs_writing = 0; | |
2577 | } | |
2578 | CLASSTYPE_VTABLE_NEEDS_WRITING (t) = needs_writing; | |
2579 | } | |
a28e3c7f | 2580 | #if 0 |
8d08fdba MS |
2581 | t = TYPE_IDENTIFIER ($<ttype>0); |
2582 | if (t && IDENTIFIER_TEMPLATE (t)) | |
2583 | overload_template_name (t, 1); | |
a28e3c7f | 2584 | #endif |
8d08fdba MS |
2585 | } |
2586 | ; | |
2587 | ||
c91a56d2 MS |
2588 | self_reference: |
2589 | /* empty */ | |
2590 | { | |
2591 | if (CLASSTYPE_TEMPLATE_INFO (current_class_type)) | |
2592 | $$ = NULL_TREE; | |
2593 | else | |
2594 | $$ = build_self_reference (); | |
2595 | } | |
2596 | ; | |
2597 | ||
8d08fdba | 2598 | opt.component_decl_list: |
c91a56d2 MS |
2599 | self_reference |
2600 | { if ($$) $$ = build_tree_list (access_public_node, $$); } | |
2601 | | self_reference component_decl_list | |
8d08fdba MS |
2602 | { |
2603 | if (current_aggr == signature_type_node) | |
c91a56d2 | 2604 | $$ = build_tree_list (access_public_node, $2); |
8d08fdba | 2605 | else |
c91a56d2 MS |
2606 | $$ = build_tree_list (access_default_node, $2); |
2607 | if ($1) $$ = tree_cons (access_public_node, $1, $$); | |
8d08fdba MS |
2608 | } |
2609 | | opt.component_decl_list VISSPEC ':' component_decl_list | |
2610 | { | |
be99da77 | 2611 | tree visspec = $2; |
8d08fdba MS |
2612 | |
2613 | if (current_aggr == signature_type_node) | |
2614 | { | |
2615 | error ("access specifier not allowed in signature"); | |
be99da77 | 2616 | visspec = access_public_node; |
8d08fdba MS |
2617 | } |
2618 | $$ = chainon ($$, build_tree_list (visspec, $4)); | |
2619 | } | |
2620 | | opt.component_decl_list VISSPEC ':' | |
2621 | { | |
2622 | if (current_aggr == signature_type_node) | |
2623 | error ("access specifier not allowed in signature"); | |
2624 | } | |
2625 | ; | |
2626 | ||
2627 | /* Note: we no longer warn about the semicolon after a component_decl_list. | |
2628 | ARM $9.2 says that the semicolon is optional, and therefore allowed. */ | |
2629 | component_decl_list: | |
2630 | component_decl | |
2631 | { if ($$ == void_type_node) $$ = NULL_TREE; | |
2632 | } | |
2633 | | component_decl_list component_decl | |
2634 | { /* In pushdecl, we created a reverse list of names | |
2635 | in this binding level. Make sure that the chain | |
2636 | of what we're trying to add isn't the item itself | |
2637 | (which can happen with what pushdecl's doing). */ | |
2638 | if ($2 != NULL_TREE && $2 != void_type_node) | |
2639 | { | |
2640 | if (TREE_CHAIN ($2) != $$) | |
2641 | $$ = chainon ($$, $2); | |
2642 | else | |
2643 | $$ = $2; | |
2644 | } | |
2645 | } | |
8d08fdba MS |
2646 | ; |
2647 | ||
2648 | component_decl: | |
a28e3c7f | 2649 | component_decl_1 ';' |
f30432d7 | 2650 | { } |
a28e3c7f MS |
2651 | | component_decl_1 '}' |
2652 | { error ("missing ';' before right brace"); | |
2653 | yyungetc ('}', 0); } | |
2654 | /* C++: handle constructors, destructors and inline functions */ | |
2655 | /* note that INLINE is like a TYPESPEC */ | |
2656 | | fn.def2 ':' /* base_init compstmt */ | |
2657 | { $$ = finish_method ($$); } | |
f30432d7 MS |
2658 | | fn.def2 TRY /* base_init compstmt */ |
2659 | { $$ = finish_method ($$); } | |
2660 | | fn.def2 RETURN /* base_init compstmt */ | |
2661 | { $$ = finish_method ($$); } | |
a28e3c7f MS |
2662 | | fn.def2 '{' /* nodecls compstmt */ |
2663 | { $$ = finish_method ($$); } | |
a5894242 MS |
2664 | | ';' |
2665 | { $$ = NULL_TREE; } | |
a28e3c7f MS |
2666 | ; |
2667 | ||
2668 | component_decl_1: | |
2669 | /* Do not add a "typed_declspecs declarator" rule here for | |
51c184be MS |
2670 | speed; we need to call grok_x_components for enums, so the |
2671 | speedup would be insignificant. */ | |
a28e3c7f | 2672 | typed_declspecs components |
46b02c6d | 2673 | { $$ = grok_x_components ($1.t, $2); } |
a28e3c7f | 2674 | | declmods notype_components |
f30432d7 | 2675 | { $$ = grok_x_components ($1, $2); } |
e3417fcd | 2676 | | notype_declarator exception_specification_opt maybeasm maybe_attribute maybe_init |
f30432d7 MS |
2677 | { $$ = grokfield ($$, NULL_TREE, $2, $5, $3, |
2678 | build_tree_list ($4, NULL_TREE)); } | |
c91a56d2 MS |
2679 | | constructor_declarator exception_specification_opt maybeasm maybe_attribute maybe_init |
2680 | { $$ = grokfield ($$, NULL_TREE, $2, $5, $3, | |
2681 | build_tree_list ($4, NULL_TREE)); } | |
a28e3c7f | 2682 | | ':' expr_no_commas |
8d08fdba | 2683 | { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); } |
8d08fdba MS |
2684 | | error |
2685 | { $$ = NULL_TREE; } | |
2686 | ||
a28e3c7f MS |
2687 | /* These rules introduce a reduce/reduce conflict; in |
2688 | typedef int foo, bar; | |
2689 | class A { | |
2690 | foo (bar); | |
2691 | }; | |
2692 | should "A::foo" be declared as a function or "A::bar" as a data | |
2693 | member? In other words, is "bar" an after_type_declarator or a | |
2694 | parmlist? */ | |
a80e4195 | 2695 | | declmods component_constructor_declarator exception_specification_opt maybeasm maybe_attribute maybe_init |
f30432d7 MS |
2696 | { tree specs, attrs; |
2697 | split_specs_attrs ($1, &specs, &attrs); | |
a80e4195 MS |
2698 | $$ = grokfield ($2, specs, $3, $6, $4, |
2699 | build_tree_list ($5, attrs)); } | |
2700 | | component_constructor_declarator exception_specification_opt maybeasm maybe_attribute maybe_init | |
2701 | { $$ = grokfield ($$, NULL_TREE, $2, $5, $3, $4); } | |
6060a796 | 2702 | | using_decl |
a9aedbc2 | 2703 | { $$ = do_class_using_decl ($1); } |
8d08fdba MS |
2704 | ; |
2705 | ||
e92cc029 | 2706 | /* The case of exactly one component is handled directly by component_decl. */ |
f30432d7 | 2707 | /* ??? Huh? ^^^ */ |
8d08fdba MS |
2708 | components: |
2709 | /* empty: possibly anonymous */ | |
2710 | { $$ = NULL_TREE; } | |
2711 | | component_declarator0 | |
2712 | | components ',' component_declarator | |
2713 | { | |
2714 | /* In this context, void_type_node encodes | |
2715 | friends. They have been recorded elsewhere. */ | |
2716 | if ($$ == void_type_node) | |
2717 | $$ = $3; | |
2718 | else | |
2719 | $$ = chainon ($$, $3); | |
2720 | } | |
2721 | ; | |
2722 | ||
51c184be MS |
2723 | notype_components: |
2724 | /* empty: possibly anonymous */ | |
2725 | { $$ = NULL_TREE; } | |
2726 | | notype_component_declarator0 | |
2727 | | notype_components ',' notype_component_declarator | |
2728 | { | |
2729 | /* In this context, void_type_node encodes | |
2730 | friends. They have been recorded elsewhere. */ | |
2731 | if ($$ == void_type_node) | |
2732 | $$ = $3; | |
2733 | else | |
2734 | $$ = chainon ($$, $3); | |
2735 | } | |
2736 | ; | |
2737 | ||
8d08fdba | 2738 | component_declarator0: |
51c184be MS |
2739 | after_type_component_declarator0 |
2740 | | notype_component_declarator0 | |
2741 | ; | |
2742 | ||
2743 | component_declarator: | |
2744 | after_type_component_declarator | |
2745 | | notype_component_declarator | |
2746 | ; | |
2747 | ||
2748 | after_type_component_declarator0: | |
e3417fcd | 2749 | after_type_declarator exception_specification_opt maybeasm maybe_attribute maybe_init |
f30432d7 MS |
2750 | { split_specs_attrs ($<ttype>0, ¤t_declspecs, |
2751 | &prefix_attributes); | |
2752 | $<ttype>0 = current_declspecs; | |
2753 | $$ = grokfield ($$, current_declspecs, $2, $5, $3, | |
2754 | build_tree_list ($4, prefix_attributes)); } | |
51c184be | 2755 | | TYPENAME ':' expr_no_commas maybe_attribute |
f30432d7 MS |
2756 | { split_specs_attrs ($<ttype>0, ¤t_declspecs, |
2757 | &prefix_attributes); | |
2758 | $<ttype>0 = current_declspecs; | |
8d08fdba | 2759 | $$ = grokbitfield ($$, current_declspecs, $3); |
f6abb50a | 2760 | cplus_decl_attributes ($$, $4, prefix_attributes); } |
51c184be MS |
2761 | ; |
2762 | ||
2763 | notype_component_declarator0: | |
e3417fcd | 2764 | notype_declarator exception_specification_opt maybeasm maybe_attribute maybe_init |
f30432d7 MS |
2765 | { split_specs_attrs ($<ttype>0, ¤t_declspecs, |
2766 | &prefix_attributes); | |
2767 | $<ttype>0 = current_declspecs; | |
2768 | $$ = grokfield ($$, current_declspecs, $2, $5, $3, | |
2769 | build_tree_list ($4, prefix_attributes)); } | |
c91a56d2 MS |
2770 | | constructor_declarator exception_specification_opt maybeasm maybe_attribute maybe_init |
2771 | { split_specs_attrs ($<ttype>0, ¤t_declspecs, | |
2772 | &prefix_attributes); | |
2773 | $<ttype>0 = current_declspecs; | |
2774 | $$ = grokfield ($$, current_declspecs, $2, $5, $3, | |
2775 | build_tree_list ($4, prefix_attributes)); } | |
51c184be | 2776 | | IDENTIFIER ':' expr_no_commas maybe_attribute |
f30432d7 MS |
2777 | { split_specs_attrs ($<ttype>0, ¤t_declspecs, |
2778 | &prefix_attributes); | |
2779 | $<ttype>0 = current_declspecs; | |
8d08fdba | 2780 | $$ = grokbitfield ($$, current_declspecs, $3); |
f6abb50a | 2781 | cplus_decl_attributes ($$, $4, prefix_attributes); } |
8d08fdba | 2782 | | ':' expr_no_commas maybe_attribute |
f30432d7 MS |
2783 | { split_specs_attrs ($<ttype>0, ¤t_declspecs, |
2784 | &prefix_attributes); | |
2785 | $<ttype>0 = current_declspecs; | |
39211cd5 | 2786 | $$ = grokbitfield (NULL_TREE, current_declspecs, $2); |
f6abb50a | 2787 | cplus_decl_attributes ($$, $3, prefix_attributes); } |
8d08fdba MS |
2788 | ; |
2789 | ||
51c184be | 2790 | after_type_component_declarator: |
e3417fcd | 2791 | after_type_declarator exception_specification_opt maybeasm maybe_attribute maybe_init |
f30432d7 MS |
2792 | { $$ = grokfield ($$, current_declspecs, $2, $5, $3, |
2793 | build_tree_list ($4, prefix_attributes)); } | |
51c184be | 2794 | | TYPENAME ':' expr_no_commas maybe_attribute |
8d08fdba | 2795 | { $$ = grokbitfield ($$, current_declspecs, $3); |
f6abb50a | 2796 | cplus_decl_attributes ($$, $4, prefix_attributes); } |
51c184be MS |
2797 | ; |
2798 | ||
2799 | notype_component_declarator: | |
e3417fcd | 2800 | notype_declarator exception_specification_opt maybeasm maybe_attribute maybe_init |
f30432d7 MS |
2801 | { $$ = grokfield ($$, current_declspecs, $2, $5, $3, |
2802 | build_tree_list ($4, prefix_attributes)); } | |
51c184be | 2803 | | IDENTIFIER ':' expr_no_commas maybe_attribute |
8d08fdba | 2804 | { $$ = grokbitfield ($$, current_declspecs, $3); |
f6abb50a | 2805 | cplus_decl_attributes ($$, $4, prefix_attributes); } |
8d08fdba | 2806 | | ':' expr_no_commas maybe_attribute |
39211cd5 | 2807 | { $$ = grokbitfield (NULL_TREE, current_declspecs, $2); |
f6abb50a | 2808 | cplus_decl_attributes ($$, $3, prefix_attributes); } |
8d08fdba MS |
2809 | ; |
2810 | ||
2811 | /* We chain the enumerators in reverse order. | |
2812 | Because of the way enums are built, the order is | |
2813 | insignificant. Take advantage of this fact. */ | |
2814 | ||
2815 | enumlist: | |
2816 | enumerator | |
2817 | | enumlist ',' enumerator | |
2818 | { TREE_CHAIN ($3) = $$; $$ = $3; } | |
2819 | ; | |
2820 | ||
2821 | enumerator: | |
2822 | identifier | |
2823 | { $$ = build_enumerator ($$, NULL_TREE); } | |
2824 | | identifier '=' expr_no_commas | |
2825 | { $$ = build_enumerator ($$, $3); } | |
2826 | ; | |
2827 | ||
51c184be MS |
2828 | /* ANSI new-type-id (5.3.4) */ |
2829 | new_type_id: | |
a4443a08 | 2830 | type_specifier_seq new_declarator |
46b02c6d MS |
2831 | { $$.t = build_decl_list ($1.t, $2); |
2832 | $$.new_type_flag = $1.new_type_flag; } | |
a4443a08 | 2833 | | type_specifier_seq %prec EMPTY |
46b02c6d MS |
2834 | { $$.t = build_decl_list ($1.t, NULL_TREE); |
2835 | $$.new_type_flag = $1.new_type_flag; } | |
39211cd5 MS |
2836 | /* GNU extension to allow arrays of arbitrary types with |
2837 | non-constant dimension. */ | |
2838 | | '(' type_id ')' '[' expr ']' | |
2839 | { | |
b7484fbe | 2840 | if (pedantic) |
39211cd5 | 2841 | pedwarn ("ANSI C++ forbids array dimensions with parenthesized type in new"); |
46b02c6d MS |
2842 | $$.t = build_parse_node (ARRAY_REF, TREE_VALUE ($2.t), $5); |
2843 | $$.t = build_decl_list (TREE_PURPOSE ($2.t), $$.t); | |
2844 | $$.new_type_flag = $2.new_type_flag; | |
39211cd5 | 2845 | } |
8d08fdba MS |
2846 | ; |
2847 | ||
51c184be MS |
2848 | type_quals: |
2849 | /* empty */ %prec EMPTY | |
2850 | { $$ = NULL_TREE; } | |
2851 | | type_quals TYPE_QUAL | |
2852 | { $$ = decl_tree_cons (NULL_TREE, $2, $$); } | |
2853 | ; | |
2854 | ||
8d08fdba MS |
2855 | nonempty_type_quals: |
2856 | TYPE_QUAL | |
46b02c6d MS |
2857 | { $$.t = IDENTIFIER_AS_LIST ($1); |
2858 | $$.new_type_flag = 0; } | |
8d08fdba | 2859 | | nonempty_type_quals TYPE_QUAL |
46b02c6d MS |
2860 | { $$.t = decl_tree_cons (NULL_TREE, $2, $1.t); |
2861 | $$.new_type_flag = $1.new_type_flag; } | |
8d08fdba MS |
2862 | ; |
2863 | ||
8d08fdba MS |
2864 | /* These rules must follow the rules for function declarations |
2865 | and component declarations. That way, longer rules are preferred. */ | |
2866 | ||
a5894242 MS |
2867 | suspend_mom: |
2868 | { $<itype>$ = suspend_momentary (); } | |
2869 | ||
8d08fdba MS |
2870 | /* An expression which will not live on the momentary obstack. */ |
2871 | nonmomentary_expr: | |
a5894242 | 2872 | suspend_mom expr |
8d08fdba | 2873 | { resume_momentary ((int) $<itype>1); $$ = $2; } |
51c184be | 2874 | ; |
8d08fdba | 2875 | |
a5894242 MS |
2876 | /* An expression which will not live on the momentary obstack. */ |
2877 | maybe_parmlist: | |
2878 | suspend_mom '(' nonnull_exprlist ')' | |
2879 | { resume_momentary ((int) $<itype>1); $$ = $3; } | |
2880 | | suspend_mom '(' parmlist ')' | |
2881 | { resume_momentary ((int) $<itype>1); $$ = $3; } | |
2882 | | suspend_mom LEFT_RIGHT | |
2883 | { resume_momentary ((int) $<itype>1); $$ = empty_parms (); } | |
2884 | | suspend_mom '(' error ')' | |
2885 | { resume_momentary ((int) $<itype>1); $$ = NULL_TREE; } | |
2886 | ; | |
2887 | ||
8d08fdba MS |
2888 | /* A declarator that is allowed only after an explicit typespec. */ |
2889 | /* may all be followed by prec '.' */ | |
2890 | after_type_declarator: | |
a28e3c7f | 2891 | '*' nonempty_type_quals after_type_declarator %prec UNARY |
46b02c6d | 2892 | { $$ = make_pointer_declarator ($2.t, $3); } |
a28e3c7f | 2893 | | '&' nonempty_type_quals after_type_declarator %prec UNARY |
46b02c6d | 2894 | { $$ = make_reference_declarator ($2.t, $3); } |
a28e3c7f | 2895 | | '*' after_type_declarator %prec UNARY |
51c184be | 2896 | { $$ = make_pointer_declarator (NULL_TREE, $2); } |
a28e3c7f | 2897 | | '&' after_type_declarator %prec UNARY |
51c184be | 2898 | { $$ = make_reference_declarator (NULL_TREE, $2); } |
a28e3c7f MS |
2899 | | ptr_to_mem type_quals after_type_declarator |
2900 | { tree arg = make_pointer_declarator ($2, $3); | |
2901 | $$ = build_parse_node (SCOPE_REF, $1, arg); | |
51c184be MS |
2902 | } |
2903 | | direct_after_type_declarator | |
8d08fdba MS |
2904 | ; |
2905 | ||
cffa8729 | 2906 | complete_type_name: |
a28e3c7f | 2907 | type_name %prec EMPTY |
8d2733ca | 2908 | { |
cffa8729 MS |
2909 | if (TREE_CODE ($1) == IDENTIFIER_NODE) |
2910 | { | |
2911 | if (current_class_type | |
2912 | && TYPE_BEING_DEFINED (current_class_type) | |
cffa8729 MS |
2913 | && ! IDENTIFIER_CLASS_VALUE ($1)) |
2914 | { | |
2915 | /* Be sure to get an inherited typedef. */ | |
2916 | $$ = lookup_name ($1, 1); | |
2917 | /* Remember that this name has been used in the class | |
2918 | definition, as per [class.scope0] */ | |
2919 | pushdecl_class_level ($$); | |
2920 | } | |
2921 | else | |
2922 | $$ = identifier_typedecl_value ($1); | |
2923 | } | |
2924 | else | |
2925 | $$ = $1; | |
2926 | } | |
2927 | | global_scope type_name | |
2928 | { | |
2929 | if (TREE_CODE ($2) == IDENTIFIER_NODE) | |
a80e4195 | 2930 | $$ = identifier_typedecl_value ($2); |
cffa8729 MS |
2931 | else |
2932 | $$ = $2; | |
2933 | got_scope = NULL_TREE; | |
8d2733ca | 2934 | } |
a28e3c7f | 2935 | | nested_type |
cffa8729 MS |
2936 | | global_scope nested_type |
2937 | { $$ = $2; } | |
a28e3c7f MS |
2938 | ; |
2939 | ||
2940 | nested_type: | |
2941 | nested_name_specifier type_name %prec EMPTY | |
5566b478 | 2942 | { $$ = get_type_decl ($2); } |
a28e3c7f MS |
2943 | ; |
2944 | ||
51c184be | 2945 | direct_after_type_declarator: |
a5894242 MS |
2946 | direct_after_type_declarator maybe_parmlist type_quals %prec '.' |
2947 | { $$ = build_parse_node (CALL_EXPR, $$, $2, $3); } | |
51c184be | 2948 | | direct_after_type_declarator '[' nonmomentary_expr ']' |
8d08fdba | 2949 | { $$ = build_parse_node (ARRAY_REF, $$, $3); } |
51c184be | 2950 | | direct_after_type_declarator '[' ']' |
8d08fdba | 2951 | { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); } |
a28e3c7f | 2952 | | '(' after_type_declarator ')' |
8d08fdba | 2953 | { $$ = $2; } |
a28e3c7f | 2954 | | nested_name_specifier type_name %prec EMPTY |
c91a56d2 | 2955 | { push_nested_class ($1, 3); |
a28e3c7f MS |
2956 | $$ = build_parse_node (SCOPE_REF, $$, $2); |
2957 | TREE_COMPLEXITY ($$) = current_class_depth; } | |
2958 | | type_name %prec EMPTY | |
8d08fdba MS |
2959 | ; |
2960 | ||
2961 | /* A declarator allowed whether or not there has been | |
2962 | an explicit typespec. These cannot redeclare a typedef-name. */ | |
2963 | ||
2964 | notype_declarator: | |
a28e3c7f | 2965 | '*' nonempty_type_quals notype_declarator %prec UNARY |
46b02c6d | 2966 | { $$ = make_pointer_declarator ($2.t, $3); } |
a28e3c7f | 2967 | | '&' nonempty_type_quals notype_declarator %prec UNARY |
46b02c6d | 2968 | { $$ = make_reference_declarator ($2.t, $3); } |
a28e3c7f | 2969 | | '*' notype_declarator %prec UNARY |
51c184be | 2970 | { $$ = make_pointer_declarator (NULL_TREE, $2); } |
a28e3c7f | 2971 | | '&' notype_declarator %prec UNARY |
51c184be | 2972 | { $$ = make_reference_declarator (NULL_TREE, $2); } |
a28e3c7f MS |
2973 | | ptr_to_mem type_quals notype_declarator |
2974 | { tree arg = make_pointer_declarator ($2, $3); | |
2975 | $$ = build_parse_node (SCOPE_REF, $1, arg); | |
51c184be MS |
2976 | } |
2977 | | direct_notype_declarator | |
2978 | ; | |
2979 | ||
a28e3c7f MS |
2980 | complex_notype_declarator: |
2981 | '*' nonempty_type_quals notype_declarator %prec UNARY | |
46b02c6d | 2982 | { $$ = make_pointer_declarator ($2.t, $3); } |
a28e3c7f | 2983 | | '&' nonempty_type_quals notype_declarator %prec UNARY |
46b02c6d | 2984 | { $$ = make_reference_declarator ($2.t, $3); } |
a28e3c7f | 2985 | | '*' complex_notype_declarator %prec UNARY |
51c184be | 2986 | { $$ = make_pointer_declarator (NULL_TREE, $2); } |
a28e3c7f | 2987 | | '&' complex_notype_declarator %prec UNARY |
51c184be | 2988 | { $$ = make_reference_declarator (NULL_TREE, $2); } |
a28e3c7f MS |
2989 | | ptr_to_mem type_quals notype_declarator |
2990 | { tree arg = make_pointer_declarator ($2, $3); | |
2991 | $$ = build_parse_node (SCOPE_REF, $1, arg); | |
51c184be MS |
2992 | } |
2993 | | complex_direct_notype_declarator | |
2994 | ; | |
2995 | ||
2996 | complex_direct_notype_declarator: | |
a5894242 MS |
2997 | direct_notype_declarator maybe_parmlist type_quals %prec '.' |
2998 | { $$ = build_parse_node (CALL_EXPR, $$, $2, $3); } | |
a28e3c7f | 2999 | | '(' complex_notype_declarator ')' |
8d08fdba | 3000 | { $$ = $2; } |
51c184be | 3001 | | direct_notype_declarator '[' nonmomentary_expr ']' |
8d08fdba | 3002 | { $$ = build_parse_node (ARRAY_REF, $$, $3); } |
51c184be | 3003 | | direct_notype_declarator '[' ']' |
8d08fdba | 3004 | { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); } |
b7484fbe | 3005 | | notype_qualified_id |
be99da77 | 3006 | { if (OP0 ($$) != current_class_type) |
f30432d7 | 3007 | { |
be99da77 | 3008 | push_nested_class (OP0 ($$), 3); |
f30432d7 MS |
3009 | TREE_COMPLEXITY ($$) = current_class_depth; |
3010 | } | |
3011 | } | |
a28e3c7f | 3012 | ; |
8d08fdba | 3013 | |
a28e3c7f MS |
3014 | qualified_id: |
3015 | nested_name_specifier unqualified_id | |
3016 | { got_scope = NULL_TREE; | |
3017 | $$ = build_parse_node (SCOPE_REF, $$, $2); } | |
3018 | ; | |
51c184be | 3019 | |
a28e3c7f MS |
3020 | notype_qualified_id: |
3021 | nested_name_specifier notype_unqualified_id | |
3022 | { got_scope = NULL_TREE; | |
3023 | $$ = build_parse_node (SCOPE_REF, $$, $2); } | |
3024 | ; | |
3025 | ||
3026 | overqualified_id: | |
3027 | notype_qualified_id | |
3028 | | global_scope notype_qualified_id | |
3029 | { $$ = $2; } | |
51c184be MS |
3030 | ; |
3031 | ||
3032 | functional_cast: | |
3033 | typespec '(' nonnull_exprlist ')' | |
46b02c6d | 3034 | { $$ = build_functional_cast ($1.t, $3); } |
51c184be | 3035 | | typespec '(' expr_or_declarator ')' |
46b02c6d | 3036 | { $$ = reparse_decl_as_expr ($1.t, $3); } |
51c184be | 3037 | | typespec fcast_or_absdcl %prec EMPTY |
46b02c6d | 3038 | { $$ = reparse_absdcl_as_expr ($1.t, $2); } |
8d08fdba MS |
3039 | ; |
3040 | ||
a28e3c7f MS |
3041 | type_name: |
3042 | TYPENAME | |
a80e4195 | 3043 | | SELFNAME |
a28e3c7f MS |
3044 | | template_type %prec EMPTY |
3045 | ; | |
8d08fdba | 3046 | |
a28e3c7f MS |
3047 | nested_name_specifier: |
3048 | nested_name_specifier_1 | |
3049 | | nested_name_specifier nested_name_specifier_1 | |
3050 | { $$ = $2; } | |
3051 | ; | |
3052 | ||
3053 | /* Why the @#$%^& do type_name and notype_identifier need to be expanded | |
3054 | inline here?!? (jason) */ | |
3055 | nested_name_specifier_1: | |
3056 | TYPENAME SCOPE | |
45537677 | 3057 | { |
a80e4195 MS |
3058 | if (TREE_CODE ($1) == IDENTIFIER_NODE) |
3059 | { | |
3060 | $$ = lastiddecl; | |
3061 | /* Remember that this name has been used in the class | |
3062 | definition, as per [class.scope0] */ | |
3063 | if (current_class_type | |
3064 | && TYPE_BEING_DEFINED (current_class_type) | |
3065 | && ! IDENTIFIER_CLASS_VALUE ($1)) | |
3066 | pushdecl_class_level ($$); | |
3067 | } | |
3068 | got_scope = $$ = TREE_TYPE ($$); | |
3069 | } | |
3070 | | SELFNAME SCOPE | |
3071 | { | |
3072 | if (TREE_CODE ($1) == IDENTIFIER_NODE) | |
3073 | $$ = lastiddecl; | |
45537677 MS |
3074 | got_scope = $$ = TREE_TYPE ($$); |
3075 | } | |
6060a796 | 3076 | | NSNAME SCOPE |
be99da77 | 3077 | { got_scope = $$ = $1; } |
a28e3c7f | 3078 | | template_type SCOPE |
5566b478 | 3079 | { got_scope = $$ = complete_type (TREE_TYPE ($1)); } |
a28e3c7f | 3080 | /* These break 'const i;' |
8d08fdba | 3081 | | IDENTIFIER SCOPE |
8d08fdba | 3082 | { |
a28e3c7f MS |
3083 | failed_scope: |
3084 | cp_error ("`%D' is not an aggregate typedef", | |
3085 | lastiddecl ? lastiddecl : $$); | |
3086 | $$ = error_mark_node; | |
8d08fdba | 3087 | } |
a28e3c7f MS |
3088 | | PTYPENAME SCOPE |
3089 | { goto failed_scope; } */ | |
8d08fdba MS |
3090 | ; |
3091 | ||
a28e3c7f | 3092 | complex_type_name: |
cffa8729 MS |
3093 | global_scope type_name |
3094 | { | |
3095 | if (TREE_CODE ($2) == IDENTIFIER_NODE) | |
a80e4195 | 3096 | $$ = identifier_typedecl_value ($2); |
cffa8729 MS |
3097 | else |
3098 | $$ = $2; | |
3099 | got_scope = NULL_TREE; | |
3100 | } | |
3101 | | nested_type | |
3102 | | global_scope nested_type | |
a28e3c7f MS |
3103 | { $$ = $2; } |
3104 | ; | |
3105 | ||
3106 | ptr_to_mem: | |
3107 | nested_name_specifier '*' | |
3108 | { got_scope = NULL_TREE; } | |
3109 | | global_scope nested_name_specifier '*' | |
3110 | { $$ = $2; got_scope = NULL_TREE; } | |
3111 | ; | |
3112 | ||
3113 | /* All uses of explicit global scope must go through this nonterminal so | |
e92cc029 | 3114 | that got_scope will be set before yylex is called to get the next token. */ |
a28e3c7f MS |
3115 | global_scope: |
3116 | SCOPE | |
3117 | { got_scope = void_type_node; } | |
8d08fdba MS |
3118 | ; |
3119 | ||
51c184be MS |
3120 | /* ANSI new-declarator (5.3.4) */ |
3121 | new_declarator: | |
3122 | '*' type_quals new_declarator | |
8d08fdba MS |
3123 | { $$ = make_pointer_declarator ($2, $3); } |
3124 | | '*' type_quals %prec EMPTY | |
3125 | { $$ = make_pointer_declarator ($2, NULL_TREE); } | |
51c184be MS |
3126 | | '&' type_quals new_declarator %prec EMPTY |
3127 | { $$ = make_reference_declarator ($2, $3); } | |
3128 | | '&' type_quals %prec EMPTY | |
3129 | { $$ = make_reference_declarator ($2, NULL_TREE); } | |
a28e3c7f MS |
3130 | | ptr_to_mem type_quals %prec EMPTY |
3131 | { tree arg = make_pointer_declarator ($2, NULL_TREE); | |
3132 | $$ = build_parse_node (SCOPE_REF, $1, arg); | |
51c184be | 3133 | } |
a28e3c7f MS |
3134 | | ptr_to_mem type_quals new_declarator |
3135 | { tree arg = make_pointer_declarator ($2, $3); | |
3136 | $$ = build_parse_node (SCOPE_REF, $1, arg); | |
51c184be MS |
3137 | } |
3138 | | direct_new_declarator %prec EMPTY | |
3139 | ; | |
3140 | ||
3141 | /* ANSI direct-new-declarator (5.3.4) */ | |
3142 | direct_new_declarator: | |
3143 | '[' expr ']' | |
3144 | { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); } | |
3145 | | direct_new_declarator '[' nonmomentary_expr ']' | |
3146 | { $$ = build_parse_node (ARRAY_REF, $$, $3); } | |
3147 | ; | |
3148 | ||
3149 | /* ANSI abstract-declarator (8.1) */ | |
a28e3c7f MS |
3150 | absdcl: |
3151 | '*' nonempty_type_quals absdcl | |
46b02c6d | 3152 | { $$ = make_pointer_declarator ($2.t, $3); } |
a28e3c7f | 3153 | | '*' absdcl |
51c184be | 3154 | { $$ = make_pointer_declarator (NULL_TREE, $2); } |
a0a33927 | 3155 | | '*' nonempty_type_quals %prec EMPTY |
46b02c6d | 3156 | { $$ = make_pointer_declarator ($2.t, NULL_TREE); } |
a0a33927 MS |
3157 | | '*' %prec EMPTY |
3158 | { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); } | |
a28e3c7f | 3159 | | '&' nonempty_type_quals absdcl |
46b02c6d | 3160 | { $$ = make_reference_declarator ($2.t, $3); } |
a28e3c7f | 3161 | | '&' absdcl |
51c184be | 3162 | { $$ = make_reference_declarator (NULL_TREE, $2); } |
a0a33927 | 3163 | | '&' nonempty_type_quals %prec EMPTY |
46b02c6d | 3164 | { $$ = make_reference_declarator ($2.t, NULL_TREE); } |
a0a33927 MS |
3165 | | '&' %prec EMPTY |
3166 | { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); } | |
a28e3c7f MS |
3167 | | ptr_to_mem type_quals %prec EMPTY |
3168 | { tree arg = make_pointer_declarator ($2, NULL_TREE); | |
3169 | $$ = build_parse_node (SCOPE_REF, $1, arg); | |
51c184be | 3170 | } |
a28e3c7f MS |
3171 | | ptr_to_mem type_quals absdcl |
3172 | { tree arg = make_pointer_declarator ($2, $3); | |
3173 | $$ = build_parse_node (SCOPE_REF, $1, arg); | |
51c184be MS |
3174 | } |
3175 | | direct_abstract_declarator %prec EMPTY | |
3176 | ; | |
3177 | ||
3178 | /* ANSI direct-abstract-declarator (8.1) */ | |
3179 | direct_abstract_declarator: | |
a28e3c7f MS |
3180 | '(' absdcl ')' |
3181 | { $$ = $2; } | |
51c184be MS |
3182 | /* `(typedef)1' is `int'. */ |
3183 | | PAREN_STAR_PAREN | |
51c184be | 3184 | | direct_abstract_declarator '(' parmlist ')' type_quals %prec '.' |
8d08fdba | 3185 | { $$ = build_parse_node (CALL_EXPR, $$, $3, $5); } |
51c184be | 3186 | | direct_abstract_declarator LEFT_RIGHT type_quals %prec '.' |
8d08fdba | 3187 | { $$ = build_parse_node (CALL_EXPR, $$, empty_parms (), $3); } |
51c184be | 3188 | | direct_abstract_declarator '[' nonmomentary_expr ']' %prec '.' |
8d08fdba | 3189 | { $$ = build_parse_node (ARRAY_REF, $$, $3); } |
51c184be | 3190 | | direct_abstract_declarator '[' ']' %prec '.' |
8d08fdba | 3191 | { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); } |
51c184be | 3192 | | '(' complex_parmlist ')' type_quals %prec '.' |
8d08fdba | 3193 | { $$ = build_parse_node (CALL_EXPR, NULL_TREE, $2, $4); } |
51c184be MS |
3194 | | regcast_or_absdcl type_quals %prec '.' |
3195 | { TREE_OPERAND ($$, 2) = $2; } | |
3196 | | fcast_or_absdcl type_quals %prec '.' | |
3197 | { TREE_OPERAND ($$, 2) = $2; } | |
8d08fdba MS |
3198 | | '[' nonmomentary_expr ']' %prec '.' |
3199 | { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); } | |
3200 | | '[' ']' %prec '.' | |
3201 | { $$ = build_parse_node (ARRAY_REF, NULL_TREE, NULL_TREE); } | |
3202 | ; | |
3203 | ||
8d08fdba MS |
3204 | /* For C++, decls and stmts can be intermixed, so we don't need to |
3205 | have a special rule that won't start parsing the stmt section | |
3206 | until we have a stmt that parses without errors. */ | |
3207 | ||
3208 | stmts: | |
3209 | stmt | |
3210 | | errstmt | |
3211 | | stmts stmt | |
3212 | | stmts errstmt | |
3213 | ; | |
3214 | ||
3215 | errstmt: error ';' | |
3216 | ; | |
3217 | ||
3218 | /* build the LET_STMT node before parsing its contents, | |
3219 | so that any LET_STMTs within the context can have their display pointers | |
3220 | set up to point at this one. */ | |
3221 | ||
3222 | .pushlevel: /* empty */ | |
5566b478 | 3223 | { do_pushlevel (); } |
8d08fdba MS |
3224 | ; |
3225 | ||
863adfc0 | 3226 | .poplevel: /* empty */ |
5566b478 | 3227 | { $$ = do_poplevel (); } |
863adfc0 MS |
3228 | ; |
3229 | ||
8d08fdba MS |
3230 | /* Read zero or more forward-declarations for labels |
3231 | that nested functions can jump to. */ | |
3232 | maybe_label_decls: | |
3233 | /* empty */ | |
3234 | | label_decls | |
b7484fbe | 3235 | { if (pedantic) |
8d08fdba MS |
3236 | pedwarn ("ANSI C++ forbids label declarations"); } |
3237 | ; | |
3238 | ||
3239 | label_decls: | |
3240 | label_decl | |
3241 | | label_decls label_decl | |
3242 | ; | |
3243 | ||
3244 | label_decl: | |
3245 | LABEL identifiers_or_typenames ';' | |
3246 | { tree link; | |
3247 | for (link = $2; link; link = TREE_CHAIN (link)) | |
3248 | { | |
3249 | tree label = shadow_label (TREE_VALUE (link)); | |
3250 | C_DECLARED_LABEL_FLAG (label) = 1; | |
3251 | declare_nonlocal_label (label); | |
3252 | } | |
3253 | } | |
3254 | ; | |
3255 | ||
3256 | /* This is the body of a function definition. | |
3257 | It causes syntax errors to ignore to the next openbrace. */ | |
3258 | compstmt_or_error: | |
3259 | compstmt | |
3260 | {} | |
3261 | | error compstmt | |
3262 | ; | |
3263 | ||
5566b478 MS |
3264 | compstmt: '{' |
3265 | { | |
3266 | if (current_template_parms) | |
3267 | { | |
3268 | $<ttype>$ = build_min_nt (COMPOUND_STMT, NULL_TREE); | |
3269 | add_tree ($<ttype>$); | |
3270 | } | |
3271 | } | |
3272 | .pushlevel compstmtend .poplevel | |
3273 | { | |
3274 | if (current_template_parms) | |
3275 | { | |
3276 | TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2); | |
3277 | TREE_CHAIN ($<ttype>2) = NULL_TREE; | |
3278 | last_tree = $<ttype>2; | |
3279 | } | |
3280 | $$ = $5; | |
3281 | } | |
8d08fdba MS |
3282 | ; |
3283 | ||
3284 | simple_if: | |
3285 | IF | |
5566b478 MS |
3286 | { |
3287 | if (current_template_parms) | |
3288 | { | |
3289 | $<ttype>$ = build_min_nt (IF_STMT, NULL_TREE, NULL_TREE, | |
3290 | NULL_TREE); | |
3291 | add_tree ($<ttype>$); | |
3292 | } | |
3293 | cond_stmt_keyword = "if"; | |
3294 | } | |
8d08fdba | 3295 | .pushlevel paren_cond_or_null |
5566b478 MS |
3296 | { |
3297 | if (current_template_parms) | |
3298 | { | |
3299 | if (last_tree != $<ttype>2) | |
3300 | { | |
3301 | TREE_OPERAND ($<ttype>2, 0) = last_tree; | |
3302 | TREE_CHAIN ($<ttype>2) = NULL_TREE; | |
3303 | last_tree = $<ttype>2; | |
3304 | } | |
3305 | else | |
3306 | TREE_OPERAND ($<ttype>2, 0) = $4; | |
3307 | } | |
3308 | else | |
3309 | { | |
3310 | emit_line_note (input_filename, lineno); | |
3311 | expand_start_cond ($4, 0); | |
3312 | } | |
3313 | } | |
8d2733ca | 3314 | implicitly_scoped_stmt |
5566b478 MS |
3315 | { |
3316 | if (current_template_parms) | |
3317 | { | |
3318 | TREE_OPERAND ($<ttype>2, 1) = TREE_CHAIN ($<ttype>2); | |
3319 | TREE_CHAIN ($<ttype>2) = NULL_TREE; | |
3320 | $<ttype>$ = last_tree = $<ttype>2; | |
3321 | } | |
3322 | } | |
8d08fdba MS |
3323 | ; |
3324 | ||
3325 | implicitly_scoped_stmt: | |
3326 | compstmt | |
3327 | { finish_stmt (); } | |
5566b478 MS |
3328 | | .pushlevel |
3329 | { | |
3330 | if (current_template_parms) | |
3331 | { | |
3332 | $<ttype>$ = build_min_nt (COMPOUND_STMT, NULL_TREE); | |
3333 | add_tree ($<ttype>$); | |
3334 | } | |
3335 | } | |
3336 | simple_stmt .poplevel | |
3337 | { | |
3338 | if (current_template_parms) | |
3339 | { | |
3340 | TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2); | |
3341 | TREE_CHAIN ($<ttype>2) = NULL_TREE; | |
3342 | last_tree = $<ttype>2; | |
3343 | } | |
3344 | $$ = $4; | |
3345 | } | |
8d08fdba MS |
3346 | ; |
3347 | ||
3348 | stmt: | |
3349 | compstmt | |
3350 | { finish_stmt (); } | |
3351 | | simple_stmt | |
3352 | ; | |
3353 | ||
3354 | simple_stmt: | |
3355 | decl | |
f30432d7 | 3356 | { finish_stmt (); } |
8d08fdba MS |
3357 | | expr ';' |
3358 | { | |
8d2733ca | 3359 | tree expr = $1; |
5566b478 MS |
3360 | if (! current_template_parms) |
3361 | { | |
3362 | emit_line_note (input_filename, lineno); | |
3363 | /* Do default conversion if safe and possibly important, | |
3364 | in case within ({...}). */ | |
3365 | if ((TREE_CODE (TREE_TYPE (expr)) == ARRAY_TYPE | |
3366 | && lvalue_p (expr)) | |
3367 | || TREE_CODE (TREE_TYPE (expr)) == FUNCTION_TYPE) | |
3368 | expr = default_conversion (expr); | |
3369 | } | |
8d08fdba MS |
3370 | cplus_expand_expr_stmt (expr); |
3371 | clear_momentary (); | |
3372 | finish_stmt (); } | |
3373 | | simple_if ELSE | |
5566b478 | 3374 | { if (! current_template_parms) expand_start_else (); } |
8d2733ca | 3375 | implicitly_scoped_stmt |
5566b478 MS |
3376 | { |
3377 | if (current_template_parms) | |
3378 | { | |
3379 | TREE_OPERAND ($<ttype>1, 2) = TREE_CHAIN ($<ttype>1); | |
3380 | TREE_CHAIN ($<ttype>1) = NULL_TREE; | |
3381 | last_tree = $<ttype>1; | |
3382 | } | |
3383 | else | |
3384 | expand_end_cond (); | |
3385 | } | |
863adfc0 MS |
3386 | .poplevel |
3387 | { finish_stmt (); } | |
8d08fdba | 3388 | | simple_if %prec IF |
5566b478 | 3389 | { if (! current_template_parms) expand_end_cond (); |
8d08fdba MS |
3390 | expand_end_bindings (getdecls (), kept_level_p (), 1); |
3391 | poplevel (kept_level_p (), 1, 0); | |
3392 | pop_momentary (); | |
3393 | finish_stmt (); } | |
3394 | | WHILE | |
5566b478 MS |
3395 | { |
3396 | if (current_template_parms) | |
3397 | { | |
3398 | $<ttype>$ = build_min_nt (WHILE_STMT, NULL_TREE, NULL_TREE); | |
3399 | add_tree ($<ttype>$); | |
3400 | } | |
3401 | else | |
3402 | { | |
3403 | emit_nop (); | |
3404 | emit_line_note (input_filename, lineno); | |
3405 | expand_start_loop (1); | |
3406 | } | |
3407 | cond_stmt_keyword = "while"; | |
3408 | } | |
8d08fdba | 3409 | .pushlevel paren_cond_or_null |
5566b478 MS |
3410 | { |
3411 | if (current_template_parms) | |
3412 | { | |
3413 | if (last_tree != $<ttype>2) | |
3414 | { | |
3415 | TREE_OPERAND ($<ttype>2, 0) = last_tree; | |
3416 | TREE_CHAIN ($<ttype>2) = NULL_TREE; | |
3417 | last_tree = $<ttype>2; | |
3418 | } | |
3419 | else | |
3420 | TREE_OPERAND ($<ttype>2, 0) = $4; | |
3421 | } | |
3422 | else | |
3423 | { | |
3424 | emit_line_note (input_filename, lineno); | |
3425 | expand_exit_loop_if_false (0, $4); | |
3426 | } | |
3427 | } | |
863adfc0 | 3428 | already_scoped_stmt .poplevel |
5566b478 MS |
3429 | { |
3430 | if (current_template_parms) | |
3431 | { | |
3432 | TREE_OPERAND ($<ttype>2, 1) = TREE_CHAIN ($<ttype>2); | |
3433 | TREE_CHAIN ($<ttype>2) = NULL_TREE; | |
3434 | last_tree = $<ttype>2; | |
3435 | } | |
3436 | else | |
3437 | expand_end_loop (); | |
3438 | finish_stmt (); | |
3439 | } | |
8d08fdba | 3440 | | DO |
5566b478 MS |
3441 | { |
3442 | if (current_template_parms) | |
3443 | { | |
3444 | $<ttype>$ = build_min_nt (DO_STMT, NULL_TREE, NULL_TREE); | |
3445 | add_tree ($<ttype>$); | |
3446 | } | |
3447 | else | |
3448 | { | |
3449 | emit_nop (); | |
3450 | emit_line_note (input_filename, lineno); | |
3451 | expand_start_loop_continue_elsewhere (1); | |
3452 | } | |
3453 | } | |
8d08fdba | 3454 | implicitly_scoped_stmt WHILE |
5566b478 MS |
3455 | { |
3456 | if (current_template_parms) | |
3457 | { | |
3458 | TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2); | |
3459 | TREE_CHAIN ($<ttype>2) = NULL_TREE; | |
3460 | last_tree = $<ttype>2; | |
3461 | } | |
3462 | else | |
3463 | { | |
3464 | expand_loop_continue_here (); | |
3465 | cond_stmt_keyword = "do"; | |
3466 | } | |
3467 | } | |
8d08fdba | 3468 | paren_expr_or_null ';' |
5566b478 MS |
3469 | { |
3470 | if (current_template_parms) | |
3471 | TREE_OPERAND ($<ttype>2, 1) = $6; | |
3472 | else | |
3473 | { | |
3474 | emit_line_note (input_filename, lineno); | |
3475 | expand_exit_loop_if_false (0, $6); | |
3476 | expand_end_loop (); | |
3477 | } | |
8d08fdba | 3478 | clear_momentary (); |
5566b478 MS |
3479 | finish_stmt (); |
3480 | } | |
863adfc0 | 3481 | | FOR |
5566b478 MS |
3482 | { if (current_template_parms) |
3483 | { | |
3484 | $<ttype>$ = build_min_nt (FOR_STMT, NULL_TREE, NULL_TREE, | |
3485 | NULL_TREE, NULL_TREE); | |
3486 | add_tree ($<ttype>$); | |
3487 | } | |
3488 | else | |
3489 | emit_line_note (input_filename, lineno); | |
c7fdde6d | 3490 | if (flag_new_for_scope > 0) |
863adfc0 MS |
3491 | { |
3492 | /* Conditionalize .pushlevel */ | |
3493 | pushlevel (0); | |
c7fdde6d | 3494 | note_level_for_for (); |
863adfc0 MS |
3495 | clear_last_expr (); |
3496 | push_momentary (); | |
3497 | expand_start_bindings (0); | |
3498 | } | |
3499 | } | |
3500 | '(' for.init.statement | |
5566b478 MS |
3501 | { |
3502 | if (current_template_parms) | |
3503 | { | |
3504 | if (last_tree != $<ttype>2) | |
3505 | { | |
e76a2646 | 3506 | TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2); |
5566b478 MS |
3507 | TREE_CHAIN ($<ttype>2) = NULL_TREE; |
3508 | last_tree = $<ttype>2; | |
3509 | } | |
3510 | } | |
3511 | else | |
3512 | { | |
3513 | emit_nop (); | |
3514 | emit_line_note (input_filename, lineno); | |
3515 | expand_start_loop_continue_elsewhere (1); | |
3516 | } | |
3517 | } | |
8d08fdba | 3518 | .pushlevel xcond ';' |
5566b478 MS |
3519 | { |
3520 | if (current_template_parms) | |
3521 | { | |
3522 | if (last_tree != $<ttype>2) | |
3523 | { | |
3524 | TREE_OPERAND ($<ttype>2, 1) = last_tree; | |
3525 | TREE_CHAIN ($<ttype>2) = NULL_TREE; | |
3526 | last_tree = $<ttype>2; | |
3527 | } | |
3528 | else | |
3529 | TREE_OPERAND ($<ttype>2, 1) = $7; | |
3530 | } | |
3531 | else | |
3532 | { | |
3533 | emit_line_note (input_filename, lineno); | |
3534 | if ($7) expand_exit_loop_if_false (0, $7); | |
3535 | } | |
3536 | } | |
8d08fdba | 3537 | xexpr ')' |
863adfc0 | 3538 | /* Don't let the tree nodes for $10 be discarded |
8d08fdba | 3539 | by clear_momentary during the parsing of the next stmt. */ |
5566b478 MS |
3540 | { |
3541 | if (current_template_parms) | |
3542 | TREE_OPERAND ($<ttype>2, 2) = $10; | |
3543 | push_momentary (); | |
3544 | } | |
863adfc0 | 3545 | already_scoped_stmt .poplevel |
5566b478 MS |
3546 | { |
3547 | if (current_template_parms) | |
3548 | { | |
3549 | TREE_OPERAND ($<ttype>2, 3) = TREE_CHAIN ($<ttype>2); | |
3550 | TREE_CHAIN ($<ttype>2) = NULL_TREE; | |
3551 | last_tree = $<ttype>2; | |
3552 | } | |
3553 | else | |
3554 | { | |
3555 | emit_line_note (input_filename, lineno); | |
3556 | expand_loop_continue_here (); | |
3557 | if ($10) cplus_expand_expr_stmt ($10); | |
3558 | expand_end_loop (); | |
3559 | } | |
a4443a08 | 3560 | pop_momentary (); |
c7fdde6d | 3561 | if (flag_new_for_scope > 0) |
863adfc0 MS |
3562 | { |
3563 | expand_end_bindings (getdecls (), kept_level_p (), 1); | |
3564 | poplevel (kept_level_p (), 1, 0); | |
3565 | pop_momentary (); | |
3566 | } | |
8d08fdba | 3567 | finish_stmt (); } |
8d08fdba | 3568 | | SWITCH .pushlevel '(' condition ')' |
5566b478 MS |
3569 | { |
3570 | if (current_template_parms) | |
3571 | { | |
3572 | $<ttype>$ = build_min_nt (SWITCH_STMT, $4, NULL_TREE); | |
3573 | add_tree ($<ttype>$); | |
3574 | } | |
3575 | else | |
3576 | { | |
3577 | emit_line_note (input_filename, lineno); | |
3578 | c_expand_start_case ($4); | |
3579 | } | |
a5894242 | 3580 | push_switch (); |
8d08fdba MS |
3581 | /* Don't let the tree nodes for $4 be discarded by |
3582 | clear_momentary during the parsing of the next stmt. */ | |
5566b478 MS |
3583 | push_momentary (); |
3584 | } | |
8d2733ca | 3585 | implicitly_scoped_stmt |
5566b478 MS |
3586 | { |
3587 | if (current_template_parms) | |
3588 | { | |
3589 | TREE_OPERAND ($<ttype>6, 1) = TREE_CHAIN ($<ttype>6); | |
3590 | TREE_CHAIN ($<ttype>6) = NULL_TREE; | |
3591 | last_tree = $<ttype>6; | |
3592 | } | |
3593 | else | |
3594 | expand_end_case ($4); | |
8d08fdba | 3595 | pop_momentary (); |
5566b478 MS |
3596 | pop_switch (); |
3597 | } | |
863adfc0 MS |
3598 | .poplevel |
3599 | { finish_stmt (); } | |
8d08fdba | 3600 | | CASE expr_no_commas ':' |
5566b478 | 3601 | { do_case ($2, NULL_TREE); } |
8d08fdba | 3602 | stmt |
f0e01782 | 3603 | | CASE expr_no_commas ELLIPSIS expr_no_commas ':' |
5566b478 | 3604 | { do_case ($2, $4); } |
8d08fdba MS |
3605 | stmt |
3606 | | DEFAULT ':' | |
5566b478 | 3607 | { do_case (NULL_TREE, NULL_TREE); } |
8d08fdba MS |
3608 | stmt |
3609 | | BREAK ';' | |
3610 | { emit_line_note (input_filename, lineno); | |
5566b478 MS |
3611 | if (current_template_parms) |
3612 | add_tree (build_min_nt (BREAK_STMT)); | |
3613 | else if ( ! expand_exit_something ()) | |
8d08fdba MS |
3614 | error ("break statement not within loop or switch"); } |
3615 | | CONTINUE ';' | |
3616 | { emit_line_note (input_filename, lineno); | |
5566b478 MS |
3617 | if (current_template_parms) |
3618 | add_tree (build_min_nt (CONTINUE_STMT)); | |
3619 | else if (! expand_continue_loop (0)) | |
8d08fdba MS |
3620 | error ("continue statement not within a loop"); } |
3621 | | RETURN ';' | |
3622 | { emit_line_note (input_filename, lineno); | |
3623 | c_expand_return (NULL_TREE); } | |
3624 | | RETURN expr ';' | |
3625 | { emit_line_note (input_filename, lineno); | |
3626 | c_expand_return ($2); | |
3627 | finish_stmt (); | |
3628 | } | |
3629 | | asm_keyword maybe_type_qual '(' string ')' ';' | |
3630 | { if (TREE_CHAIN ($4)) $4 = combine_strings ($4); | |
3631 | emit_line_note (input_filename, lineno); | |
3632 | expand_asm ($4); | |
3633 | finish_stmt (); | |
3634 | } | |
3635 | /* This is the case with just output operands. */ | |
3636 | | asm_keyword maybe_type_qual '(' string ':' asm_operands ')' ';' | |
3637 | { if (TREE_CHAIN ($4)) $4 = combine_strings ($4); | |
3638 | emit_line_note (input_filename, lineno); | |
3639 | c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE, | |
3640 | $2 == ridpointers[(int)RID_VOLATILE], | |
3641 | input_filename, lineno); | |
3642 | finish_stmt (); | |
3643 | } | |
3644 | /* This is the case with input operands as well. */ | |
3645 | | asm_keyword maybe_type_qual '(' string ':' asm_operands ':' asm_operands ')' ';' | |
3646 | { if (TREE_CHAIN ($4)) $4 = combine_strings ($4); | |
3647 | emit_line_note (input_filename, lineno); | |
3648 | c_expand_asm_operands ($4, $6, $8, NULL_TREE, | |
3649 | $2 == ridpointers[(int)RID_VOLATILE], | |
3650 | input_filename, lineno); | |
3651 | finish_stmt (); | |
3652 | } | |
3653 | /* This is the case with clobbered registers as well. */ | |
3654 | | asm_keyword maybe_type_qual '(' string ':' asm_operands ':' | |
8d2733ca | 3655 | asm_operands ':' asm_clobbers ')' ';' |
8d08fdba MS |
3656 | { if (TREE_CHAIN ($4)) $4 = combine_strings ($4); |
3657 | emit_line_note (input_filename, lineno); | |
3658 | c_expand_asm_operands ($4, $6, $8, $10, | |
3659 | $2 == ridpointers[(int)RID_VOLATILE], | |
3660 | input_filename, lineno); | |
3661 | finish_stmt (); | |
3662 | } | |
3663 | | GOTO '*' expr ';' | |
5566b478 MS |
3664 | { |
3665 | if (current_template_parms) | |
3666 | add_tree (build_min_nt (GOTO_STMT, $3)); | |
3667 | else | |
3668 | { emit_line_note (input_filename, lineno); | |
3669 | expand_computed_goto ($3); } | |
3670 | } | |
8d08fdba | 3671 | | GOTO identifier ';' |
5566b478 MS |
3672 | { |
3673 | if (current_template_parms) | |
3674 | add_tree (build_min_nt (GOTO_STMT, $2)); | |
3675 | else | |
3676 | { | |
3677 | tree decl; | |
3678 | emit_line_note (input_filename, lineno); | |
3679 | decl = lookup_label ($2); | |
3680 | TREE_USED (decl) = 1; | |
3681 | expand_goto (decl); | |
3682 | } | |
3683 | } | |
8d08fdba MS |
3684 | | label_colon stmt |
3685 | { finish_stmt (); } | |
3686 | | label_colon '}' | |
3687 | { error ("label must be followed by statement"); | |
3688 | yyungetc ('}', 0); | |
3689 | finish_stmt (); } | |
3690 | | ';' | |
3691 | { finish_stmt (); } | |
8d2733ca | 3692 | | try_block |
8d08fdba MS |
3693 | ; |
3694 | ||
f30432d7 MS |
3695 | function_try_block: |
3696 | TRY | |
3697 | { | |
3698 | if (! current_function_parms_stored) | |
3699 | store_parm_decls (); | |
3700 | expand_start_early_try_stmts (); | |
3701 | } | |
3702 | ctor_initializer_opt compstmt_or_error | |
3703 | { expand_end_try_stmts (); | |
3704 | expand_start_all_catch (); } | |
3705 | handler_seq | |
3706 | { | |
fc378698 MS |
3707 | int nested = (hack_decl_function_context |
3708 | (current_function_decl) != NULL_TREE); | |
f30432d7 | 3709 | expand_end_all_catch (); |
fc378698 | 3710 | finish_function (lineno, (int)$3, nested); |
f30432d7 MS |
3711 | } |
3712 | ; | |
3713 | ||
8d2733ca | 3714 | try_block: |
863adfc0 | 3715 | TRY |
8d2733ca | 3716 | { expand_start_try_stmts (); } |
863adfc0 | 3717 | compstmt |
8d2733ca MS |
3718 | { expand_end_try_stmts (); |
3719 | expand_start_all_catch (); } | |
3720 | handler_seq | |
3721 | { expand_end_all_catch (); } | |
8d08fdba MS |
3722 | ; |
3723 | ||
8d2733ca | 3724 | handler_seq: |
8d08fdba | 3725 | /* empty */ |
46b02c6d | 3726 | | handler_seq CATCH .pushlevel handler_args compstmt |
863adfc0 MS |
3727 | { expand_end_catch_block (); } |
3728 | .poplevel | |
8d2733ca | 3729 | ; |
8d08fdba | 3730 | |
a4443a08 MS |
3731 | type_specifier_seq: |
3732 | typed_typespecs %prec EMPTY | |
3733 | | nonempty_type_quals %prec EMPTY | |
3734 | ; | |
3735 | ||
8d2733ca MS |
3736 | handler_args: |
3737 | '(' ELLIPSIS ')' | |
3738 | { expand_start_catch_block (NULL_TREE, NULL_TREE); } | |
a3b49ccd | 3739 | /* This doesn't allow reference parameters, the below does. |
a4443a08 | 3740 | | '(' type_specifier_seq absdcl ')' |
46b02c6d MS |
3741 | { check_for_new_type ("inside exception declarations", $2); |
3742 | expand_start_catch_block ($2.t, $3); } | |
a4443a08 | 3743 | | '(' type_specifier_seq ')' |
46b02c6d MS |
3744 | { check_for_new_type ("inside exception declarations", $2); |
3745 | expand_start_catch_block ($2.t, NULL_TREE); } | |
a4443a08 | 3746 | | '(' type_specifier_seq notype_declarator ')' |
46b02c6d MS |
3747 | { check_for_new_type ("inside exception declarations", $2); |
3748 | expand_start_catch_block ($2.t, $3); } | |
a4443a08 | 3749 | | '(' typed_typespecs after_type_declarator ')' |
46b02c6d MS |
3750 | { check_for_new_type ("inside exception declarations", $2); |
3751 | expand_start_catch_block ($2.t, $3); } | |
e92cc029 | 3752 | This allows reference parameters... */ |
a3b49ccd | 3753 | | '(' parm ')' |
46b02c6d MS |
3754 | { check_for_new_type ("inside exception declarations", $2); |
3755 | expand_start_catch_block (TREE_PURPOSE ($2.t), | |
3756 | TREE_VALUE ($2.t)); } | |
8d2733ca | 3757 | ; |
8d08fdba | 3758 | |
8d2733ca MS |
3759 | label_colon: |
3760 | IDENTIFIER ':' | |
3761 | { tree label; | |
3762 | do_label: | |
3763 | label = define_label (input_filename, lineno, $1); | |
5566b478 | 3764 | if (label && ! minimal_parse_mode) |
8d2733ca | 3765 | expand_label (label); |
8d08fdba | 3766 | } |
8d2733ca MS |
3767 | | PTYPENAME ':' |
3768 | { goto do_label; } | |
f376e137 MS |
3769 | | TYPENAME ':' |
3770 | { goto do_label; } | |
a80e4195 MS |
3771 | | SELFNAME ':' |
3772 | { goto do_label; } | |
8d08fdba MS |
3773 | ; |
3774 | ||
863adfc0 MS |
3775 | for.init.statement: |
3776 | xexpr ';' | |
3777 | { if ($1) cplus_expand_expr_stmt ($1); } | |
3778 | | decl | |
3779 | | '{' compstmtend | |
72b7eeff MS |
3780 | { if (pedantic) |
3781 | pedwarn ("ANSI C++ forbids compound statements inside for initializations"); | |
3782 | } | |
8d08fdba MS |
3783 | ; |
3784 | ||
3785 | /* Either a type-qualifier or nothing. First thing in an `asm' statement. */ | |
3786 | ||
3787 | maybe_type_qual: | |
3788 | /* empty */ | |
3789 | { emit_line_note (input_filename, lineno); | |
3790 | $$ = NULL_TREE; } | |
3791 | | TYPE_QUAL | |
3792 | { emit_line_note (input_filename, lineno); } | |
3793 | ; | |
3794 | ||
3795 | xexpr: | |
3796 | /* empty */ | |
3797 | { $$ = NULL_TREE; } | |
3798 | | expr | |
3799 | | error | |
3800 | { $$ = NULL_TREE; } | |
3801 | ; | |
3802 | ||
3803 | /* These are the operands other than the first string and colon | |
3804 | in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */ | |
3805 | asm_operands: /* empty */ | |
3806 | { $$ = NULL_TREE; } | |
3807 | | nonnull_asm_operands | |
3808 | ; | |
3809 | ||
3810 | nonnull_asm_operands: | |
3811 | asm_operand | |
3812 | | nonnull_asm_operands ',' asm_operand | |
3813 | { $$ = chainon ($$, $3); } | |
3814 | ; | |
3815 | ||
3816 | asm_operand: | |
3817 | STRING '(' expr ')' | |
3818 | { $$ = build_tree_list ($$, $3); } | |
3819 | ; | |
3820 | ||
3821 | asm_clobbers: | |
3822 | STRING | |
3823 | { $$ = tree_cons (NULL_TREE, $$, NULL_TREE); } | |
3824 | | asm_clobbers ',' STRING | |
3825 | { $$ = tree_cons (NULL_TREE, $3, $$); } | |
3826 | ; | |
3827 | ||
3828 | /* This is what appears inside the parens in a function declarator. | |
3829 | Its value is represented in the format that grokdeclarator expects. | |
3830 | ||
3831 | In C++, declaring a function with no parameters | |
3832 | means that that function takes *no* parameters. */ | |
51c184be | 3833 | |
8d08fdba MS |
3834 | parmlist: /* empty */ |
3835 | { | |
46b02c6d | 3836 | $$ = empty_parms(); |
8d08fdba | 3837 | } |
51c184be MS |
3838 | | complex_parmlist |
3839 | | type_id | |
46b02c6d MS |
3840 | { $$ = tree_cons (NULL_TREE, $1.t, void_list_node); |
3841 | TREE_PARMLIST ($$) = 1; | |
3842 | check_for_new_type ("inside parameter list", $1); } | |
51c184be MS |
3843 | ; |
3844 | ||
3845 | /* This nonterminal does not include the common sequence '(' type_id ')', | |
3846 | as it is ambiguous and must be disambiguated elsewhere. */ | |
3847 | complex_parmlist: | |
3848 | parms | |
8d2733ca | 3849 | { |
8d08fdba MS |
3850 | $$ = chainon ($$, void_list_node); |
3851 | TREE_PARMLIST ($$) = 1; | |
3852 | } | |
51c184be | 3853 | | parms_comma ELLIPSIS |
8d08fdba MS |
3854 | { |
3855 | TREE_PARMLIST ($$) = 1; | |
3856 | } | |
3857 | /* C++ allows an ellipsis without a separating ',' */ | |
3858 | | parms ELLIPSIS | |
3859 | { | |
3860 | TREE_PARMLIST ($$) = 1; | |
3861 | } | |
51c184be MS |
3862 | | type_id ELLIPSIS |
3863 | { | |
46b02c6d | 3864 | $$ = build_tree_list (NULL_TREE, $1.t); |
51c184be MS |
3865 | TREE_PARMLIST ($$) = 1; |
3866 | } | |
8d08fdba MS |
3867 | | ELLIPSIS |
3868 | { | |
8d08fdba MS |
3869 | $$ = NULL_TREE; |
3870 | } | |
3871 | | TYPENAME_ELLIPSIS | |
3872 | { | |
3873 | TREE_PARMLIST ($$) = 1; | |
3874 | } | |
3875 | | parms TYPENAME_ELLIPSIS | |
3876 | { | |
3877 | TREE_PARMLIST ($$) = 1; | |
3878 | } | |
51c184be MS |
3879 | | type_id TYPENAME_ELLIPSIS |
3880 | { | |
46b02c6d | 3881 | $$ = build_tree_list (NULL_TREE, $1.t); |
51c184be MS |
3882 | TREE_PARMLIST ($$) = 1; |
3883 | } | |
8d08fdba MS |
3884 | | parms ':' |
3885 | { | |
3886 | /* This helps us recover from really nasty | |
3887 | parse errors, for example, a missing right | |
3888 | parenthesis. */ | |
3889 | yyerror ("possibly missing ')'"); | |
3890 | $$ = chainon ($$, void_list_node); | |
3891 | TREE_PARMLIST ($$) = 1; | |
3892 | yyungetc (':', 0); | |
3893 | yychar = ')'; | |
3894 | } | |
51c184be MS |
3895 | | type_id ':' |
3896 | { | |
3897 | /* This helps us recover from really nasty | |
3898 | parse errors, for example, a missing right | |
3899 | parenthesis. */ | |
3900 | yyerror ("possibly missing ')'"); | |
46b02c6d | 3901 | $$ = tree_cons (NULL_TREE, $1.t, void_list_node); |
51c184be MS |
3902 | TREE_PARMLIST ($$) = 1; |
3903 | yyungetc (':', 0); | |
3904 | yychar = ')'; | |
3905 | } | |
8d08fdba MS |
3906 | ; |
3907 | ||
3908 | /* A nonempty list of parameter declarations or type names. */ | |
3909 | parms: | |
51c184be | 3910 | named_parm |
46b02c6d MS |
3911 | { check_for_new_type ("in a parameter list", $1); |
3912 | $$ = build_tree_list (NULL_TREE, $1.t); } | |
8d08fdba | 3913 | | parm '=' init |
46b02c6d MS |
3914 | { check_for_new_type ("in a parameter list", $1); |
3915 | $$ = build_tree_list ($3, $1.t); } | |
a292b002 | 3916 | | parms_comma full_parm |
46b02c6d MS |
3917 | { check_for_new_type ("in a parameter list", $2); |
3918 | $$ = chainon ($$, $2.t); } | |
51c184be MS |
3919 | | parms_comma bad_parm |
3920 | { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); } | |
3921 | | parms_comma bad_parm '=' init | |
3922 | { $$ = chainon ($$, build_tree_list ($4, $2)); } | |
3923 | ; | |
3924 | ||
3925 | parms_comma: | |
3926 | parms ',' | |
3927 | | type_id ',' | |
46b02c6d MS |
3928 | { check_for_new_type ("in a parameter list", $1); |
3929 | $$ = build_tree_list (NULL_TREE, $1.t); } | |
8d08fdba MS |
3930 | ; |
3931 | ||
3932 | /* A single parameter declaration or parameter type name, | |
3933 | as found in a parmlist. The first four cases make up for 10% | |
3934 | of the time spent parsing C++. We cannot use them because | |
3935 | of `int id[]' which won't get parsed properly. */ | |
51c184be | 3936 | named_parm: |
8d08fdba MS |
3937 | /* |
3938 | typed_declspecs dont_see_typename '*' IDENTIFIER | |
46b02c6d MS |
3939 | { tree specs = strip_attrs ($1.t); |
3940 | $$.t = build_tree_list (specs, build_parse_node (INDIRECT_REF, $4)); | |
3941 | $$.new_type_flag = $1.new_type_flag; | |
8d08fdba MS |
3942 | see_typename (); } |
3943 | | typed_declspecs dont_see_typename '&' IDENTIFIER | |
46b02c6d MS |
3944 | { tree specs = strip_attrs ($1.t); |
3945 | $$.t = build_tree_list (specs, build_parse_node (ADDR_EXPR, $4)); | |
3946 | $$.new_type_flag = $1.new_type_flag; | |
8d08fdba MS |
3947 | see_typename (); } |
3948 | | TYPENAME IDENTIFIER | |
46b02c6d MS |
3949 | { $$.t = build_tree_list (get_decl_list ($$), $2); |
3950 | $$.new_type_flag = 0; } | |
8d08fdba | 3951 | | TYPESPEC IDENTIFIER |
46b02c6d MS |
3952 | { $$.t = build_tree_list (get_decl_list ($$), $2); |
3953 | $$.new_type_flag = 0; } | |
8d08fdba | 3954 | | */ |
51c184be MS |
3955 | /* Here we expand typed_declspecs inline to avoid mis-parsing of |
3956 | TYPESPEC IDENTIFIER. */ | |
3957 | typed_declspecs1 declarator | |
46b02c6d MS |
3958 | { tree specs = strip_attrs ($1.t); |
3959 | $$.new_type_flag = $1.new_type_flag; | |
3960 | $$.t = build_tree_list (specs, $2); } | |
51c184be | 3961 | | typed_typespecs declarator |
46b02c6d MS |
3962 | { $$.t = build_tree_list ($1.t, $2); |
3963 | $$.new_type_flag = $1.new_type_flag; } | |
51c184be | 3964 | | typespec declarator |
46b02c6d MS |
3965 | { $$.t = build_tree_list (get_decl_list ($1.t), $2); |
3966 | $$.new_type_flag = $1.new_type_flag; } | |
51c184be | 3967 | | typed_declspecs1 absdcl |
46b02c6d MS |
3968 | { tree specs = strip_attrs ($1.t); |
3969 | $$.t = build_tree_list (specs, $2); | |
3970 | $$.new_type_flag = $1.new_type_flag; } | |
51c184be | 3971 | | typed_declspecs1 %prec EMPTY |
46b02c6d MS |
3972 | { tree specs = strip_attrs ($1.t); |
3973 | $$.t = build_tree_list (specs, NULL_TREE); | |
3974 | $$.new_type_flag = $1.new_type_flag; } | |
51c184be | 3975 | | declmods notype_declarator |
f30432d7 | 3976 | { tree specs = strip_attrs ($1); |
46b02c6d MS |
3977 | $$.t = build_tree_list (specs, $2); |
3978 | $$.new_type_flag = 0; } | |
8d08fdba MS |
3979 | ; |
3980 | ||
a292b002 | 3981 | full_parm: |
e3417fcd | 3982 | parm maybe_init |
46b02c6d MS |
3983 | { $$.t = build_tree_list ($2, $1.t); |
3984 | $$.new_type_flag = $1.new_type_flag; } | |
a292b002 MS |
3985 | ; |
3986 | ||
51c184be MS |
3987 | parm: |
3988 | named_parm | |
3989 | | type_id | |
8d08fdba MS |
3990 | ; |
3991 | ||
51c184be | 3992 | see_typename: %prec EMPTY |
8d08fdba MS |
3993 | { see_typename (); } |
3994 | ; | |
3995 | ||
51c184be MS |
3996 | /* |
3997 | dont_see_typename: %prec EMPTY | |
8d08fdba | 3998 | { dont_see_typename (); } |
51c184be | 3999 | ; |
8d08fdba | 4000 | |
8d08fdba MS |
4001 | try_for_typename: |
4002 | { | |
4003 | if ($<ttype>-1 == error_mark_node) | |
4004 | $$ = 0; | |
4005 | else | |
4006 | { | |
4007 | $$ = 1; | |
4008 | pushclass ($<ttype>-1, 1); | |
4009 | } | |
4010 | } | |
4011 | ; | |
4012 | */ | |
4013 | ||
4014 | bad_parm: | |
51c184be MS |
4015 | /* empty */ %prec EMPTY |
4016 | { | |
6060a796 MS |
4017 | error ("type specifier omitted for parameter"); |
4018 | $$ = build_tree_list (integer_type_node, NULL_TREE); | |
51c184be MS |
4019 | } |
4020 | | notype_declarator | |
8d08fdba | 4021 | { |
6060a796 | 4022 | error ("type specifier omitted for parameter"); |
fc378698 MS |
4023 | if (TREE_CODE ($$) == SCOPE_REF |
4024 | && TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM) | |
4025 | cp_error (" perhaps you want `typename %E' to make it a type", $$); | |
6060a796 | 4026 | $$ = build_tree_list (integer_type_node, $$); |
8d08fdba MS |
4027 | } |
4028 | ; | |
4029 | ||
e3417fcd | 4030 | exception_specification_opt: |
8d08fdba MS |
4031 | %prec EMPTY /* empty */ |
4032 | { $$ = NULL_TREE; } | |
8d2733ca | 4033 | | THROW '(' ansi_raise_identifiers ')' %prec EMPTY |
8d08fdba | 4034 | { $$ = $3; } |
6060a796 MS |
4035 | | THROW LEFT_RIGHT %prec EMPTY |
4036 | { $$ = build_decl_list (NULL_TREE, NULL_TREE); } | |
8d08fdba MS |
4037 | ; |
4038 | ||
8d08fdba | 4039 | ansi_raise_identifier: |
51c184be | 4040 | type_id |
46b02c6d | 4041 | { $$ = build_decl_list (NULL_TREE, groktypename($1.t)); } |
8d08fdba MS |
4042 | ; |
4043 | ||
8d08fdba MS |
4044 | ansi_raise_identifiers: |
4045 | ansi_raise_identifier | |
4046 | | ansi_raise_identifiers ',' ansi_raise_identifier | |
4047 | { | |
8d2733ca | 4048 | TREE_CHAIN ($3) = $$; |
8d08fdba MS |
4049 | $$ = $3; |
4050 | } | |
4051 | ; | |
4052 | ||
51c184be MS |
4053 | conversion_declarator: |
4054 | /* empty */ %prec EMPTY | |
4055 | { $$ = NULL_TREE; } | |
4056 | | '*' type_quals conversion_declarator | |
4057 | { $$ = make_pointer_declarator ($2, $3); } | |
4058 | | '&' type_quals conversion_declarator | |
4059 | { $$ = make_reference_declarator ($2, $3); } | |
a28e3c7f MS |
4060 | | ptr_to_mem type_quals conversion_declarator |
4061 | { tree arg = make_pointer_declarator ($2, $3); | |
4062 | $$ = build_parse_node (SCOPE_REF, $1, arg); | |
51c184be MS |
4063 | } |
4064 | ; | |
4065 | ||
a28e3c7f MS |
4066 | operator: OPERATOR |
4067 | { got_scope = NULL_TREE; } | |
4068 | ; | |
4069 | ||
8d08fdba | 4070 | operator_name: |
a28e3c7f | 4071 | operator '*' |
8d08fdba | 4072 | { $$ = ansi_opname[MULT_EXPR]; } |
a28e3c7f | 4073 | | operator '/' |
8d08fdba | 4074 | { $$ = ansi_opname[TRUNC_DIV_EXPR]; } |
a28e3c7f | 4075 | | operator '%' |
8d08fdba | 4076 | { $$ = ansi_opname[TRUNC_MOD_EXPR]; } |
a28e3c7f | 4077 | | operator '+' |
8d08fdba | 4078 | { $$ = ansi_opname[PLUS_EXPR]; } |
a28e3c7f | 4079 | | operator '-' |
8d08fdba | 4080 | { $$ = ansi_opname[MINUS_EXPR]; } |
a28e3c7f | 4081 | | operator '&' |
8d08fdba | 4082 | { $$ = ansi_opname[BIT_AND_EXPR]; } |
a28e3c7f | 4083 | | operator '|' |
8d08fdba | 4084 | { $$ = ansi_opname[BIT_IOR_EXPR]; } |
a28e3c7f | 4085 | | operator '^' |
8d08fdba | 4086 | { $$ = ansi_opname[BIT_XOR_EXPR]; } |
a28e3c7f | 4087 | | operator '~' |
8d08fdba | 4088 | { $$ = ansi_opname[BIT_NOT_EXPR]; } |
a28e3c7f | 4089 | | operator ',' |
8d08fdba | 4090 | { $$ = ansi_opname[COMPOUND_EXPR]; } |
a28e3c7f | 4091 | | operator ARITHCOMPARE |
8d08fdba | 4092 | { $$ = ansi_opname[$2]; } |
a28e3c7f | 4093 | | operator '<' |
8d08fdba | 4094 | { $$ = ansi_opname[LT_EXPR]; } |
a28e3c7f | 4095 | | operator '>' |
8d08fdba | 4096 | { $$ = ansi_opname[GT_EXPR]; } |
a28e3c7f | 4097 | | operator EQCOMPARE |
8d08fdba | 4098 | { $$ = ansi_opname[$2]; } |
a28e3c7f | 4099 | | operator ASSIGN |
8d08fdba | 4100 | { $$ = ansi_assopname[$2]; } |
a28e3c7f | 4101 | | operator '=' |
8d08fdba | 4102 | { $$ = ansi_opname [MODIFY_EXPR]; } |
a28e3c7f | 4103 | | operator LSHIFT |
8d08fdba | 4104 | { $$ = ansi_opname[$2]; } |
a28e3c7f | 4105 | | operator RSHIFT |
8d08fdba | 4106 | { $$ = ansi_opname[$2]; } |
a28e3c7f | 4107 | | operator PLUSPLUS |
8d08fdba | 4108 | { $$ = ansi_opname[POSTINCREMENT_EXPR]; } |
a28e3c7f | 4109 | | operator MINUSMINUS |
8d08fdba | 4110 | { $$ = ansi_opname[PREDECREMENT_EXPR]; } |
a28e3c7f | 4111 | | operator ANDAND |
8d08fdba | 4112 | { $$ = ansi_opname[TRUTH_ANDIF_EXPR]; } |
a28e3c7f | 4113 | | operator OROR |
8d08fdba | 4114 | { $$ = ansi_opname[TRUTH_ORIF_EXPR]; } |
a28e3c7f | 4115 | | operator '!' |
8d08fdba | 4116 | { $$ = ansi_opname[TRUTH_NOT_EXPR]; } |
a28e3c7f | 4117 | | operator '?' ':' |
8d08fdba | 4118 | { $$ = ansi_opname[COND_EXPR]; } |
a28e3c7f | 4119 | | operator MIN_MAX |
8d08fdba | 4120 | { $$ = ansi_opname[$2]; } |
a28e3c7f | 4121 | | operator POINTSAT %prec EMPTY |
8d08fdba | 4122 | { $$ = ansi_opname[COMPONENT_REF]; } |
a28e3c7f | 4123 | | operator POINTSAT_STAR %prec EMPTY |
8d08fdba | 4124 | { $$ = ansi_opname[MEMBER_REF]; } |
a28e3c7f | 4125 | | operator LEFT_RIGHT |
8d08fdba | 4126 | { $$ = ansi_opname[CALL_EXPR]; } |
a28e3c7f | 4127 | | operator '[' ']' |
8d08fdba | 4128 | { $$ = ansi_opname[ARRAY_REF]; } |
a28e3c7f | 4129 | | operator NEW %prec EMPTY |
8d08fdba | 4130 | { $$ = ansi_opname[NEW_EXPR]; } |
a28e3c7f | 4131 | | operator DELETE %prec EMPTY |
8d08fdba | 4132 | { $$ = ansi_opname[DELETE_EXPR]; } |
a28e3c7f | 4133 | | operator NEW '[' ']' |
51c184be | 4134 | { $$ = ansi_opname[VEC_NEW_EXPR]; } |
a28e3c7f MS |
4135 | | operator DELETE '[' ']' |
4136 | { $$ = ansi_opname[VEC_DELETE_EXPR]; } | |
700f8a87 | 4137 | /* Names here should be looked up in class scope ALSO. */ |
a4443a08 | 4138 | | operator type_specifier_seq conversion_declarator |
46b02c6d | 4139 | { $$ = grokoptypename ($2.t, $3); } |
a28e3c7f | 4140 | | operator error |
8d08fdba MS |
4141 | { $$ = ansi_opname[ERROR_MARK]; } |
4142 | ; | |
4143 | ||
4144 | %% | |
00595019 MS |
4145 | |
4146 | #ifdef SPEW_DEBUG | |
4147 | const char * | |
4148 | debug_yytranslate (value) | |
4149 | int value; | |
4150 | { | |
4151 | return yytname[YYTRANSLATE (value)]; | |
4152 | } | |
4153 | ||
4154 | #endif |