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