(TARGET_FILE_SWITCHING): Define.
[official-gcc.git] / gcc / cp / parse.y
blob720c041eef4e58a3bc1b55cc9394b731ff4e5199
1 /* YACC parser for C++ syntax.
2 Copyright (C) 1988, 89, 93, 94, 95, 1996 Free Software Foundation, Inc.
3 Hacked by Michael Tiemann (tiemann@cygnus.com)
5 This file is part of GNU CC.
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.
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.
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. */
23 /* This grammar is based on the GNU CC grammar. */
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. */
30 /* Cause the `yydebug' variable to be defined. */
31 #define YYDEBUG 1
33 #include "config.h"
35 #include <stdio.h>
36 #include <errno.h>
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"
45 /* Since parsers are distinct for each language, put the language string
46 definition here. (fnf) */
47 char *language_string = "GNU C++";
49 extern tree void_list_node;
50 extern struct obstack permanent_obstack;
52 #ifndef errno
53 extern int errno;
54 #endif
56 extern int end_of_file;
57 extern int current_class_depth;
58 extern tree last_tree;
60 /* FSF LOCAL dje prefix attributes */
61 extern tree strip_attrs PROTO((tree));
62 /* END FSF LOCAL */
64 void yyerror ();
66 /* Like YYERROR but do call yyerror. */
67 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
69 #define OP0(NODE) (TREE_OPERAND (NODE, 0))
70 #define OP1(NODE) (TREE_OPERAND (NODE, 1))
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;
76 /* Nonzero if we have an `extern "C"' acting as an extern specifier. */
77 int have_extern_spec;
78 int used_extern_spec;
80 void yyhook ();
82 /* Cons up an empty parameter list. */
83 #ifdef __GNUC__
84 __inline
85 #endif
86 static tree
87 empty_parms ()
89 tree parms;
91 if (strict_prototype
92 || current_class_type != NULL)
93 parms = void_list_node;
94 else
95 parms = NULL_TREE;
96 return parms;
100 %start program
102 %union {long itype; tree ttype; char *strtype; enum tree_code code; flagged_type_tree ftype; }
104 /* All identifiers that are not reserved words
105 and are not declared typedefs in the current block */
106 %token IDENTIFIER
108 /* All identifiers that are declared typedefs in the current block.
109 In some contexts, they are treated just like IDENTIFIER,
110 but they can also serve as typespecs in declarations. */
111 %token TYPENAME
112 %token SELFNAME
114 /* Reserved words that specify storage class.
115 yylval contains an IDENTIFIER_NODE which indicates which one. */
116 %token SCSPEC
118 /* Reserved words that specify type.
119 yylval contains an IDENTIFIER_NODE which indicates which one. */
120 %token TYPESPEC
122 /* Reserved words that qualify type: "const" or "volatile".
123 yylval contains an IDENTIFIER_NODE which indicates which one. */
124 %token CV_QUALIFIER
126 /* Character or numeric constants.
127 yylval is the node for the constant. */
128 %token CONSTANT
130 /* String constants in raw form.
131 yylval is a STRING_CST node. */
132 %token STRING
134 /* "...", used for functions with variable arglists. */
135 %token ELLIPSIS
137 /* the reserved words */
138 /* SCO include files test "ASM", so use something else. */
139 %token SIZEOF ENUM /* STRUCT UNION */ IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
140 %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD GCC_ASM_KEYWORD TYPEOF ALIGNOF
141 %token SIGOF
142 %token ATTRIBUTE EXTENSION LABEL
144 /* the reserved words... C++ extensions */
145 %token <ttype> AGGR
146 %token <ttype> VISSPEC
147 %token DELETE NEW THIS OPERATOR CXX_TRUE CXX_FALSE
148 %token NAMESPACE TYPENAME_KEYWORD USING
149 %token LEFT_RIGHT TEMPLATE
150 %token TYPEID DYNAMIC_CAST STATIC_CAST REINTERPRET_CAST CONST_CAST
151 %token <itype> SCOPE
153 /* Define the operator tokens and their precedences.
154 The value is an integer because, if used, it is the tree code
155 to use in the expression made from the operator. */
157 %left EMPTY /* used to resolve s/r with epsilon */
159 %left error
161 /* Add precedence rules to solve dangling else s/r conflict */
162 %nonassoc IF
163 %nonassoc ELSE
165 %left IDENTIFIER TYPENAME SELFNAME PTYPENAME SCSPEC TYPESPEC CV_QUALIFIER ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD
167 %left '{' ',' ';'
169 %nonassoc THROW
170 %right <code> ':'
171 %right <code> ASSIGN '='
172 %right <code> '?'
173 %left <code> OROR
174 %left <code> ANDAND
175 %left <code> '|'
176 %left <code> '^'
177 %left <code> '&'
178 %left <code> MIN_MAX
179 %left <code> EQCOMPARE
180 %left <code> ARITHCOMPARE '<' '>'
181 %left <code> LSHIFT RSHIFT
182 %left <code> '+' '-'
183 %left <code> '*' '/' '%'
184 %left <code> POINTSAT_STAR DOT_STAR
185 %right <code> UNARY PLUSPLUS MINUSMINUS '~'
186 %left HYPERUNARY
187 %left <ttype> PAREN_STAR_PAREN LEFT_RIGHT
188 %left <code> POINTSAT '.' '(' '['
190 %right SCOPE /* C++ extension */
191 %nonassoc NEW DELETE TRY CATCH
193 %type <code> unop
195 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist
196 %type <ttype> paren_expr_or_null nontrivial_exprlist SELFNAME
197 %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
198 %type <ttype> reserved_declspecs boolean.literal
199 %type <ttype> reserved_typespecquals
200 %type <ttype> declmods
201 %type <ttype> SCSPEC TYPESPEC CV_QUALIFIER maybe_cv_qualifier
202 %type <itype> initdecls notype_initdecls initdcl /* C++ modification */
203 %type <ttype> init initlist maybeasm maybe_init
204 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
205 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
206 %type <ttype> any_word
208 %type <ttype> compstmt implicitly_scoped_stmt
210 %type <ttype> declarator notype_declarator after_type_declarator
211 %type <ttype> direct_notype_declarator direct_after_type_declarator
213 %type <ttype> opt.component_decl_list component_decl_list
214 %type <ttype> component_decl component_decl_1 components notype_components
215 %type <ttype> component_declarator component_declarator0 self_reference
216 %type <ttype> notype_component_declarator notype_component_declarator0
217 %type <ttype> after_type_component_declarator after_type_component_declarator0
218 %type <ttype> enumlist enumerator
219 %type <ttype> absdcl cv_qualifiers
220 %type <ttype> direct_abstract_declarator conversion_declarator
221 %type <ttype> new_declarator direct_new_declarator
222 %type <ttype> xexpr parmlist parms bad_parm
223 %type <ttype> identifiers_or_typenames
224 %type <ttype> fcast_or_absdcl regcast_or_absdcl
225 %type <ttype> expr_or_declarator complex_notype_declarator
226 %type <ttype> notype_unqualified_id unqualified_id qualified_id
227 %type <ttype> overqualified_id notype_qualified_id any_id
228 %type <ttype> complex_direct_notype_declarator functional_cast
229 %type <ttype> complex_parmlist parms_comma
231 %type <ftype> type_id new_type_id typed_typespecs typespec typed_declspecs
232 %type <ftype> typed_declspecs1 type_specifier_seq nonempty_cv_qualifiers
233 %type <ftype> structsp typespecqual_reserved parm named_parm full_parm
235 /* C++ extensions */
236 %token <ttype> TYPENAME_ELLIPSIS PTYPENAME
237 %token <ttype> PRE_PARSED_FUNCTION_DECL EXTERN_LANG_STRING ALL
238 %token <ttype> PRE_PARSED_CLASS_DECL
239 %type <ttype> fn.def1 /* Not really! */ component_constructor_declarator
240 %type <ttype> fn.def2 return_id fn.defpen constructor_declarator
241 %type <itype> ctor_initializer_opt
242 %type <ttype> named_class_head named_class_head_sans_basetype
243 %type <ttype> named_complex_class_head_sans_basetype
244 %type <ttype> unnamed_class_head
245 %type <ttype> class_head base_class_list
246 %type <ttype> base_class_access_list
247 %type <ttype> base_class maybe_base_class_list base_class.1
248 %type <ttype> exception_specification_opt ansi_raise_identifier ansi_raise_identifiers
249 %type <ttype> operator_name
250 %type <ttype> object aggr
251 %type <itype> new delete
252 /* %type <ttype> primary_no_id */
253 %type <ttype> nonmomentary_expr maybe_parmlist
254 %type <itype> initdcl0 notype_initdcl0 member_init_list
255 %type <ttype> template_header template_parm_list template_parm
256 %type <ttype> template_type_parm
257 %type <code> template_close_bracket
258 %type <ttype> template_type template_arg_list template_arg
259 %type <ttype> condition xcond paren_cond_or_null
260 %type <ttype> type_name nested_name_specifier nested_type ptr_to_mem
261 %type <ttype> complete_type_name notype_identifier
262 %type <ttype> complex_type_name nested_name_specifier_1
263 %type <itype> nomods_initdecls nomods_initdcl0
264 %type <ttype> new_initializer new_placement
265 %type <ttype> using_decl .poplevel
267 /* in order to recognize aggr tags as defining and thus shadowing. */
268 %token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN
269 %type <ttype> named_class_head_sans_basetype_defn
270 %type <ttype> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN
272 %type <ttype> self_template_type
274 %token NSNAME
275 %type <ttype> NSNAME
277 /* Used in lex.c for parsing pragmas. */
278 %token END_OF_LINE
280 /* lex.c and pt.c depend on this being the last token. Define
281 any new tokens before this one! */
282 %token END_OF_SAVED_INPUT
285 /* List of types and structure classes of the current declaration. */
286 static tree current_declspecs;
287 /* List of prefix attributes in effect.
288 Prefix attributes are parsed by the reserved_declspecs and declmods
289 rules. They create a list that contains *both* declspecs and attrs. */
290 /* ??? It is not clear yet that all cases where an attribute can now appear in
291 a declspec list have been updated. */
292 static tree prefix_attributes;
294 /* When defining an aggregate, this is the most recent one being defined. */
295 static tree current_aggr;
297 /* Tell yyparse how to print a token's value, if yydebug is set. */
299 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
300 extern void yyprint ();
301 extern tree combine_strings PROTO((tree));
305 program:
306 /* empty */
307 | extdefs
309 /* In case there were missing closebraces,
310 get us back to the global binding level. */
311 while (! global_bindings_p ())
312 poplevel (0, 0, 0);
313 finish_file ();
317 /* the reason for the strange actions in this rule
318 is so that notype_initdecls when reached via datadef
319 can find a valid list of type and sc specs in $0. */
321 extdefs:
322 { $<ttype>$ = NULL_TREE; }
323 lang_extdef
324 { $<ttype>$ = NULL_TREE; }
325 | extdefs lang_extdef
326 { $<ttype>$ = NULL_TREE; }
329 extdefs_opt:
330 extdefs
331 | /* empty */
334 .hush_warning:
335 { have_extern_spec = 1;
336 used_extern_spec = 0;
337 $<ttype>$ = NULL_TREE; }
339 .warning_ok:
340 { have_extern_spec = 0; }
343 extension:
344 EXTENSION
345 { $<itype>$ = pedantic;
346 pedantic = 0; }
349 asm_keyword:
350 ASM_KEYWORD
351 | GCC_ASM_KEYWORD
354 lang_extdef:
355 { if (pending_lang_change) do_pending_lang_change(); }
356 extdef
357 { if (! toplevel_bindings_p () && ! pseudo_global_level_p())
358 pop_everything (); }
361 extdef:
362 fndef
363 { if (pending_inlines) do_pending_inlines (); }
364 | datadef
365 { if (pending_inlines) do_pending_inlines (); }
366 | template_def
367 { if (pending_inlines) do_pending_inlines (); }
368 | asm_keyword '(' string ')' ';'
369 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
370 assemble_asm ($3); }
371 | extern_lang_string '{' extdefs_opt '}'
372 { pop_lang_context (); }
373 | extern_lang_string .hush_warning fndef .warning_ok
374 { if (pending_inlines) do_pending_inlines ();
375 pop_lang_context (); }
376 | extern_lang_string .hush_warning datadef .warning_ok
377 { if (pending_inlines) do_pending_inlines ();
378 pop_lang_context (); }
379 | NAMESPACE identifier '{'
380 { push_namespace ($2); }
381 extdefs_opt '}'
382 { pop_namespace (); }
383 | NAMESPACE '{'
384 { push_namespace (NULL_TREE); }
385 extdefs_opt '}'
386 { pop_namespace (); }
387 | NAMESPACE identifier '=' any_id ';'
388 { do_namespace_alias ($2, $4); }
389 | using_decl ';'
390 { do_toplevel_using_decl ($1); }
391 | USING NAMESPACE any_id ';'
392 { do_using_directive ($3); }
393 | extension extdef
394 { pedantic = $<itype>1; }
397 using_decl:
398 USING qualified_id
399 { $$ = $2; }
400 | USING global_scope qualified_id
401 { $$ = $3; }
402 | USING global_scope unqualified_id
403 { $$ = $3; }
406 any_id:
407 unqualified_id
408 | qualified_id
409 | global_scope qualified_id
410 { $$ = $2; }
411 | global_scope unqualified_id
412 { $$ = $2; }
415 extern_lang_string:
416 EXTERN_LANG_STRING
417 { push_lang_context ($1); }
418 | extern_lang_string EXTERN_LANG_STRING
419 { if (current_lang_name != $2)
420 cp_error ("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name);
421 pop_lang_context (); push_lang_context ($2); }
424 template_header:
425 TEMPLATE '<'
426 { begin_template_parm_list (); }
427 template_parm_list '>'
428 { $$ = end_template_parm_list ($4); }
429 | TEMPLATE '<' '>'
430 { $$ = NULL_TREE; }
433 template_parm_list:
434 template_parm
435 { $$ = process_template_parm (NULL_TREE, $1); }
436 | template_parm_list ',' template_parm
437 { $$ = process_template_parm ($1, $3); }
440 template_type_parm:
441 aggr
443 $$ = build_tree_list ($1, NULL_TREE);
444 ttpa:
445 if (TREE_PURPOSE ($$) == signature_type_node)
446 sorry ("signature as template type parameter");
447 else if (TREE_PURPOSE ($$) != class_type_node)
449 pedwarn ("template type parameters must use the keyword `class'");
450 TREE_PURPOSE ($$) = class_type_node;
453 | aggr identifier
454 { $$ = build_tree_list ($1, $2); goto ttpa; }
455 | TYPENAME_KEYWORD
456 { $$ = build_tree_list (class_type_node, NULL_TREE); }
457 | TYPENAME_KEYWORD identifier
458 { $$ = build_tree_list (class_type_node, $2); }
461 template_parm:
462 /* The following rules introduce a new reduce/reduce
463 conflict on the ',' and '>' input tokens: they are valid
464 prefixes for a `structsp', which means they could match a
465 nameless parameter. See 14.6, paragraph 3.
466 By putting them before the `parm' rule, we get
467 their match before considering them nameless parameter
468 declarations. */
469 template_type_parm
470 { $$ = build_tree_list (NULL_TREE, $1); }
471 | template_type_parm '=' type_id
472 { $$ = build_tree_list (groktypename ($3.t), $1); }
473 | parm
474 { $$ = build_tree_list (NULL_TREE, $1.t); }
475 | parm '=' expr_no_commas %prec ARITHCOMPARE
476 { $$ = build_tree_list ($3, $1.t); }
479 template_def:
480 template_header
481 extdef
482 { end_template_decl (); }
483 | template_header
484 error %prec EMPTY
485 { end_template_decl (); }
488 datadef:
489 nomods_initdecls ';'
491 | declmods notype_initdecls ';'
493 | typed_declspecs initdecls ';'
495 note_list_got_semicolon ($1.t);
497 | declmods ';'
498 { pedwarn ("empty declaration"); }
499 | explicit_instantiation ';'
500 | typed_declspecs ';'
502 tree t, attrs;
503 split_specs_attrs ($1.t, &t, &attrs);
504 shadow_tag (t);
505 note_list_got_semicolon ($1.t);
507 | error ';'
508 | error '}'
509 | ';'
512 ctor_initializer_opt:
513 nodecls
514 { $$ = 0; }
515 | base_init
516 { $$ = 1; }
519 maybe_return_init:
520 /* empty */
521 | return_init
522 | return_init ';'
525 eat_saved_input:
526 /* empty */
527 | END_OF_SAVED_INPUT
530 fndef:
531 fn.def1 maybe_return_init ctor_initializer_opt compstmt_or_error
532 { finish_function (lineno, (int)$3, 0); }
533 | fn.def1 maybe_return_init function_try_block
534 { if ($<ttype>$) process_next_inline ($<ttype>$); }
535 eat_saved_input
538 constructor_declarator:
539 nested_name_specifier SELFNAME '('
541 $$ = build_parse_node (SCOPE_REF, $1, $2);
542 if ($1 != current_class_type)
544 push_nested_class ($1, 3);
545 TREE_COMPLEXITY ($$) = current_class_depth;
548 parmlist ')' cv_qualifiers exception_specification_opt
549 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
550 | nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
552 $$ = build_parse_node (SCOPE_REF, $1, $2);
553 if ($1 != current_class_type)
555 push_nested_class ($1, 3);
556 TREE_COMPLEXITY ($$) = current_class_depth;
558 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
560 | global_scope nested_name_specifier SELFNAME '('
562 $$ = build_parse_node (SCOPE_REF, $2, $3);
563 if ($2 != current_class_type)
565 push_nested_class ($2, 3);
566 TREE_COMPLEXITY ($$) = current_class_depth;
569 parmlist ')' cv_qualifiers exception_specification_opt
570 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
571 | global_scope nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
573 $$ = build_parse_node (SCOPE_REF, $2, $3);
574 if ($2 != current_class_type)
576 push_nested_class ($2, 3);
577 TREE_COMPLEXITY ($$) = current_class_depth;
579 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
581 | nested_name_specifier self_template_type '('
583 $$ = build_parse_node (SCOPE_REF, $1, $2);
584 if ($1 != current_class_type)
586 push_nested_class ($1, 3);
587 TREE_COMPLEXITY ($$) = current_class_depth;
590 parmlist ')' cv_qualifiers exception_specification_opt
591 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
592 | nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
594 $$ = build_parse_node (SCOPE_REF, $1, $2);
595 if ($1 != current_class_type)
597 push_nested_class ($1, 3);
598 TREE_COMPLEXITY ($$) = current_class_depth;
600 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
602 | global_scope nested_name_specifier self_template_type '('
604 $$ = build_parse_node (SCOPE_REF, $2, $3);
605 if ($2 != current_class_type)
607 push_nested_class ($2, 3);
608 TREE_COMPLEXITY ($$) = current_class_depth;
611 parmlist ')' cv_qualifiers exception_specification_opt
612 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
613 | global_scope nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
615 $$ = build_parse_node (SCOPE_REF, $2, $3);
616 if ($2 != current_class_type)
618 push_nested_class ($2, 3);
619 TREE_COMPLEXITY ($$) = current_class_depth;
621 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
625 fn.def1:
626 typed_declspecs declarator
627 { tree specs, attrs;
628 split_specs_attrs ($1.t, &specs, &attrs);
629 if (! start_function (specs, $2, attrs, 0))
630 YYERROR1;
631 reinit_parse_for_function ();
632 $$ = NULL_TREE; }
633 | declmods notype_declarator
634 { tree specs, attrs;
635 split_specs_attrs ($1, &specs, &attrs);
636 if (! start_function (specs, $2, attrs, 0))
637 YYERROR1;
638 reinit_parse_for_function ();
639 $$ = NULL_TREE; }
640 | notype_declarator
641 { if (! start_function (NULL_TREE, $$, NULL_TREE, 0))
642 YYERROR1;
643 reinit_parse_for_function ();
644 $$ = NULL_TREE; }
645 | declmods constructor_declarator
646 { tree specs, attrs;
647 split_specs_attrs ($1, &specs, &attrs);
648 if (! start_function (specs, $2, attrs, 0))
649 YYERROR1;
650 reinit_parse_for_function ();
651 $$ = NULL_TREE; }
652 | constructor_declarator
653 { if (! start_function (NULL_TREE, $$, NULL_TREE, 0))
654 YYERROR1;
655 reinit_parse_for_function ();
656 $$ = NULL_TREE; }
659 component_constructor_declarator:
660 SELFNAME '(' parmlist ')' cv_qualifiers exception_specification_opt
661 { $$ = make_call_declarator ($1, $3, $5, $6); }
662 | SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
663 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
664 | self_template_type '(' parmlist ')' cv_qualifiers exception_specification_opt
665 { $$ = make_call_declarator ($1, $3, $5, $6); }
666 | self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
667 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
670 /* more C++ complexity. See component_decl for a comment on the
671 reduce/reduce conflict introduced by these rules. */
672 fn.def2:
673 declmods component_constructor_declarator
674 { tree specs = strip_attrs ($1);
675 $$ = start_method (specs, $2);
676 rest_of_mdef:
677 if (! $$)
678 YYERROR1;
679 if (yychar == YYEMPTY)
680 yychar = YYLEX;
681 reinit_parse_for_method (yychar, $$); }
682 | component_constructor_declarator
683 { $$ = start_method (NULL_TREE, $1); goto rest_of_mdef; }
684 | typed_declspecs declarator
685 { tree specs = strip_attrs ($1.t);
686 $$ = start_method (specs, $2); goto rest_of_mdef; }
687 | declmods notype_declarator
688 { tree specs = strip_attrs ($1);
689 $$ = start_method (specs, $2); goto rest_of_mdef; }
690 | notype_declarator
691 { $$ = start_method (NULL_TREE, $$); goto rest_of_mdef; }
692 | declmods constructor_declarator
693 { tree specs = strip_attrs ($1);
694 $$ = start_method (specs, $2); goto rest_of_mdef; }
695 | constructor_declarator
696 { $$ = start_method (NULL_TREE, $$); goto rest_of_mdef; }
699 return_id:
700 RETURN IDENTIFIER
702 if (! current_function_parms_stored)
703 store_parm_decls ();
704 $$ = $2;
708 return_init:
709 return_id maybe_init
710 { store_return_init ($<ttype>$, $2); }
711 | return_id '(' nonnull_exprlist ')'
712 { store_return_init ($<ttype>$, $3); }
713 | return_id LEFT_RIGHT
714 { store_return_init ($<ttype>$, NULL_TREE); }
717 base_init:
718 ':' .set_base_init member_init_list
720 if ($3 == 0)
721 error ("no base initializers given following ':'");
722 setup_vtbl_ptr ();
723 /* Always keep the BLOCK node associated with the outermost
724 pair of curley braces of a function. These are needed
725 for correct operation of dwarfout.c. */
726 keep_next_level ();
730 .set_base_init:
731 /* empty */
733 if (! current_function_parms_stored)
734 store_parm_decls ();
736 if (DECL_CONSTRUCTOR_P (current_function_decl))
738 /* Make a contour for the initializer list. */
739 pushlevel (0);
740 clear_last_expr ();
741 expand_start_bindings (0);
743 else if (current_class_type == NULL_TREE)
744 error ("base initializers not allowed for non-member functions");
745 else if (! DECL_CONSTRUCTOR_P (current_function_decl))
746 error ("only constructors take base initializers");
750 member_init_list:
751 /* empty */
752 { $$ = 0; }
753 | member_init
754 { $$ = 1; }
755 | member_init_list ',' member_init
756 | member_init_list error
759 member_init:
760 '(' nonnull_exprlist ')'
762 if (current_class_name)
763 pedwarn ("anachronistic old style base class initializer");
764 expand_member_init (current_class_ref, NULL_TREE, $2);
766 | LEFT_RIGHT
768 if (current_class_name)
769 pedwarn ("anachronistic old style base class initializer");
770 expand_member_init (current_class_ref, NULL_TREE, void_type_node);
772 | notype_identifier '(' nonnull_exprlist ')'
773 { expand_member_init (current_class_ref, $1, $3); }
774 | notype_identifier LEFT_RIGHT
775 { expand_member_init (current_class_ref, $1, void_type_node); }
776 | complete_type_name '(' nonnull_exprlist ')'
777 { expand_member_init (current_class_ref, $1, $3); }
778 | complete_type_name LEFT_RIGHT
779 { expand_member_init (current_class_ref, $1, void_type_node); }
780 /* GNU extension */
781 | notype_qualified_id '(' nonnull_exprlist ')'
783 do_member_init (OP0 ($1), OP1 ($1), $3);
785 | notype_qualified_id LEFT_RIGHT
787 do_member_init (OP0 ($1), OP1 ($1), void_type_node);
791 identifier:
792 IDENTIFIER
793 | TYPENAME
794 | SELFNAME
795 | PTYPENAME
796 | NSNAME
799 notype_identifier:
800 IDENTIFIER
801 | PTYPENAME
802 | NSNAME %prec EMPTY
805 identifier_defn:
806 IDENTIFIER_DEFN
807 | TYPENAME_DEFN
808 | PTYPENAME_DEFN
811 explicit_instantiation:
812 TEMPLATE aggr template_type
813 { do_type_instantiation ($3, NULL_TREE); }
814 | TEMPLATE typed_declspecs declarator
815 { tree specs = strip_attrs ($2.t);
816 do_function_instantiation (specs, $3, NULL_TREE); }
817 | TEMPLATE notype_declarator
818 { do_function_instantiation (NULL_TREE, $2, NULL_TREE); }
819 | TEMPLATE constructor_declarator
820 { do_function_instantiation (NULL_TREE, $2, NULL_TREE); }
821 | SCSPEC TEMPLATE aggr template_type
822 { do_type_instantiation ($4, $1); }
823 | SCSPEC TEMPLATE typed_declspecs declarator
824 { tree specs = strip_attrs ($3.t);
825 do_function_instantiation (specs, $4, $1); }
826 | SCSPEC TEMPLATE notype_declarator
827 { do_function_instantiation (NULL_TREE, $3, $1); }
828 | SCSPEC TEMPLATE constructor_declarator
829 { do_function_instantiation (NULL_TREE, $3, $1); }
832 /* The TYPENAME expansions are to deal with use of a template class name as
833 a template within the class itself, where the template decl is hidden by
834 a type decl. Got all that? */
836 template_type:
837 PTYPENAME '<' template_arg_list template_close_bracket
839 $$ = lookup_template_class ($1, $3, NULL_TREE);
840 if ($$ != error_mark_node)
841 $$ = TYPE_STUB_DECL ($$);
843 | PTYPENAME '<' template_close_bracket
845 $$ = lookup_template_class ($1, NULL_TREE, NULL_TREE);
846 if ($$ != error_mark_node)
847 $$ = TYPE_STUB_DECL ($$);
849 | TYPENAME '<' template_arg_list template_close_bracket
851 $$ = lookup_template_class ($1, $3, NULL_TREE);
852 if ($$ != error_mark_node)
853 $$ = TYPE_STUB_DECL ($$);
855 | TYPENAME '<' template_close_bracket
857 $$ = lookup_template_class ($1, NULL_TREE, NULL_TREE);
858 if ($$ != error_mark_node)
859 $$ = TYPE_STUB_DECL ($$);
861 | self_template_type
864 self_template_type:
865 SELFNAME '<' template_arg_list template_close_bracket
867 $$ = lookup_template_class ($1, $3, NULL_TREE);
868 if ($$ != error_mark_node)
869 $$ = TYPE_STUB_DECL ($$);
871 | SELFNAME '<' template_close_bracket
873 $$ = lookup_template_class ($1, NULL_TREE, NULL_TREE);
874 if ($$ != error_mark_node)
875 $$ = TYPE_STUB_DECL ($$);
879 template_close_bracket:
881 | RSHIFT
883 /* Handle `Class<Class<Type>>' without space in the `>>' */
884 pedwarn ("`>>' should be `> >' in template class name");
885 yyungetc ('>', 1);
889 template_arg_list:
890 template_arg
891 { $$ = build_tree_list (NULL_TREE, $$); }
892 | template_arg_list ',' template_arg
893 { $$ = chainon ($$, build_tree_list (NULL_TREE, $3)); }
896 template_arg:
897 type_id
898 { $$ = groktypename ($1.t); }
899 | expr_no_commas %prec ARITHCOMPARE
902 unop:
904 { $$ = NEGATE_EXPR; }
905 | '+'
906 { $$ = CONVERT_EXPR; }
907 | PLUSPLUS
908 { $$ = PREINCREMENT_EXPR; }
909 | MINUSMINUS
910 { $$ = PREDECREMENT_EXPR; }
911 | '!'
912 { $$ = TRUTH_NOT_EXPR; }
915 expr:
916 nontrivial_exprlist
917 { $$ = build_x_compound_expr ($$); }
918 | expr_no_commas
921 paren_expr_or_null:
922 LEFT_RIGHT
923 { error ("ANSI C++ forbids an empty condition for `%s'",
924 cond_stmt_keyword);
925 $$ = integer_zero_node; }
926 | '(' expr ')'
927 { $$ = condition_conversion ($2); }
930 paren_cond_or_null:
931 LEFT_RIGHT
932 { error ("ANSI C++ forbids an empty condition for `%s'",
933 cond_stmt_keyword);
934 $$ = integer_zero_node; }
935 | '(' condition ')'
936 { $$ = condition_conversion ($2); }
939 xcond:
940 /* empty */
941 { $$ = NULL_TREE; }
942 | condition
943 { $$ = condition_conversion ($$); }
944 | error
945 { $$ = NULL_TREE; }
948 condition:
949 type_specifier_seq declarator maybeasm maybe_attribute '='
951 tree d;
952 for (d = getdecls (); d; d = TREE_CHAIN (d))
953 if (TREE_CODE (d) == TYPE_DECL) {
954 tree s = TREE_TYPE (d);
955 if (TREE_CODE (s) == RECORD_TYPE)
956 cp_error ("definition of class `%T' in condition", s);
957 else if (TREE_CODE (s) == ENUMERAL_TYPE)
958 cp_error ("definition of enum `%T' in condition", s);
961 current_declspecs = $1.t;
962 $<itype>5 = suspend_momentary ();
963 $<ttype>$ = start_decl ($<ttype>2, current_declspecs, 1);
964 cplus_decl_attributes ($<ttype>$, $4,
965 /*prefix_attributes*/ NULL_TREE);
967 init
969 cp_finish_decl ($<ttype>6, $7, $4, 1, LOOKUP_ONLYCONVERTING);
970 resume_momentary ($<itype>5);
971 $$ = $<ttype>6;
972 if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
973 cp_error ("definition of array `%#D' in condition", $$);
975 | expr
978 compstmtend:
980 | maybe_label_decls stmts '}'
981 | maybe_label_decls stmts error '}'
982 | maybe_label_decls error '}'
985 already_scoped_stmt:
988 if (processing_template_decl)
990 $<ttype>$ = build_min_nt (COMPOUND_STMT, NULL_TREE);
991 COMPOUND_STMT_NO_SCOPE ($<ttype>$) = 1;
992 add_tree ($<ttype>$);
995 compstmtend
997 if (processing_template_decl)
999 TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2);
1000 TREE_CHAIN ($<ttype>2) = NULL_TREE;
1001 last_tree = $<ttype>2;
1003 finish_stmt ();
1005 | simple_stmt
1009 nontrivial_exprlist:
1010 expr_no_commas ',' expr_no_commas
1011 { $$ = tree_cons (NULL_TREE, $$,
1012 build_tree_list (NULL_TREE, $3)); }
1013 | expr_no_commas ',' error
1014 { $$ = tree_cons (NULL_TREE, $$,
1015 build_tree_list (NULL_TREE, error_mark_node)); }
1016 | nontrivial_exprlist ',' expr_no_commas
1017 { chainon ($$, build_tree_list (NULL_TREE, $3)); }
1018 | nontrivial_exprlist ',' error
1019 { chainon ($$, build_tree_list (NULL_TREE, error_mark_node)); }
1022 nonnull_exprlist:
1023 expr_no_commas
1024 { $$ = build_tree_list (NULL_TREE, $$); }
1025 | nontrivial_exprlist
1028 unary_expr:
1029 primary %prec UNARY
1030 { $$ = $1; }
1031 /* __extension__ turns off -pedantic for following primary. */
1032 | extension cast_expr %prec UNARY
1033 { $$ = $2;
1034 pedantic = $<itype>1; }
1035 | '*' cast_expr %prec UNARY
1036 { $$ = build_x_indirect_ref ($2, "unary *"); }
1037 | '&' cast_expr %prec UNARY
1038 { $$ = build_x_unary_op (ADDR_EXPR, $2); }
1039 | '~' cast_expr
1040 { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); }
1041 | unop cast_expr %prec UNARY
1042 { $$ = build_x_unary_op ($1, $2);
1043 if ($1 == NEGATE_EXPR && TREE_CODE ($2) == INTEGER_CST)
1044 TREE_NEGATED_INT ($$) = 1;
1045 overflow_warning ($$);
1047 /* Refer to the address of a label as a pointer. */
1048 | ANDAND identifier
1049 { tree label = lookup_label ($2);
1050 if (label == NULL_TREE)
1051 $$ = null_pointer_node;
1052 else
1054 TREE_USED (label) = 1;
1055 $$ = build1 (ADDR_EXPR, ptr_type_node, label);
1056 TREE_CONSTANT ($$) = 1;
1059 | SIZEOF unary_expr %prec UNARY
1060 { $$ = expr_sizeof ($2); }
1061 | SIZEOF '(' type_id ')' %prec HYPERUNARY
1062 { $$ = c_sizeof (groktypename ($3.t)); }
1063 | ALIGNOF unary_expr %prec UNARY
1064 { $$ = grok_alignof ($2); }
1065 | ALIGNOF '(' type_id ')' %prec HYPERUNARY
1066 { $$ = c_alignof (groktypename ($3.t));
1067 check_for_new_type ("alignof", $3); }
1069 /* The %prec EMPTY's here are required by the = init initializer
1070 syntax extension; see below. */
1071 | new new_type_id %prec EMPTY
1072 { $$ = build_new (NULL_TREE, $2.t, NULL_TREE, $1);
1073 check_for_new_type ("new", $2); }
1074 | new new_type_id new_initializer
1075 { $$ = build_new (NULL_TREE, $2.t, $3, $1);
1076 check_for_new_type ("new", $2); }
1077 | new new_placement new_type_id %prec EMPTY
1078 { $$ = build_new ($2, $3.t, NULL_TREE, $1);
1079 check_for_new_type ("new", $3); }
1080 | new new_placement new_type_id new_initializer
1081 { $$ = build_new ($2, $3.t, $4, $1);
1082 check_for_new_type ("new", $3); }
1083 | new '(' type_id ')' %prec EMPTY
1084 { $$ = build_new (NULL_TREE, groktypename($3.t),
1085 NULL_TREE, $1);
1086 check_for_new_type ("new", $3); }
1087 | new '(' type_id ')' new_initializer
1088 { $$ = build_new (NULL_TREE, groktypename($3.t), $5, $1);
1089 check_for_new_type ("new", $3); }
1090 | new new_placement '(' type_id ')' %prec EMPTY
1091 { $$ = build_new ($2, groktypename($4.t), NULL_TREE, $1);
1092 check_for_new_type ("new", $4); }
1093 | new new_placement '(' type_id ')' new_initializer
1094 { $$ = build_new ($2, groktypename($4.t), $6, $1);
1095 check_for_new_type ("new", $4); }
1097 | delete cast_expr %prec UNARY
1098 { $$ = delete_sanity ($2, NULL_TREE, 0, $1); }
1099 | delete '[' ']' cast_expr %prec UNARY
1100 { $$ = delete_sanity ($4, NULL_TREE, 1, $1);
1101 if (yychar == YYEMPTY)
1102 yychar = YYLEX; }
1103 | delete '[' expr ']' cast_expr %prec UNARY
1104 { $$ = delete_sanity ($5, $3, 2, $1);
1105 if (yychar == YYEMPTY)
1106 yychar = YYLEX; }
1109 new_placement:
1110 '(' nonnull_exprlist ')'
1111 { $$ = $2; }
1112 | '{' nonnull_exprlist '}'
1114 $$ = $2;
1115 pedwarn ("old style placement syntax, use () instead");
1119 new_initializer:
1120 '(' nonnull_exprlist ')'
1121 { $$ = $2; }
1122 | LEFT_RIGHT
1123 { $$ = NULL_TREE; }
1124 | '(' typespec ')'
1126 cp_error ("`%T' is not a valid expression", $2.t);
1127 $$ = error_mark_node;
1129 /* GNU extension so people can use initializer lists. Note that
1130 this alters the meaning of `new int = 1', which was previously
1131 syntactically valid but semantically invalid. */
1132 | '=' init
1134 if (pedantic)
1135 pedwarn ("ANSI C++ forbids initialization of new expression with `='");
1136 $$ = $2;
1140 /* This is necessary to postpone reduction of `int ((int)(int)(int))'. */
1141 regcast_or_absdcl:
1142 '(' type_id ')' %prec EMPTY
1143 { $2.t = tree_cons (NULL_TREE, $2.t, void_list_node);
1144 TREE_PARMLIST ($2.t) = 1;
1145 $$ = make_call_declarator (NULL_TREE, $2.t, NULL_TREE, NULL_TREE);
1146 check_for_new_type ("cast", $2); }
1147 | regcast_or_absdcl '(' type_id ')' %prec EMPTY
1148 { $3.t = tree_cons (NULL_TREE, $3.t, void_list_node);
1149 TREE_PARMLIST ($3.t) = 1;
1150 $$ = make_call_declarator ($$, $3.t, NULL_TREE, NULL_TREE);
1151 check_for_new_type ("cast", $3); }
1154 cast_expr:
1155 unary_expr
1156 | regcast_or_absdcl unary_expr %prec UNARY
1157 { $$ = reparse_absdcl_as_casts ($$, $2); }
1158 | regcast_or_absdcl '{' initlist maybecomma '}' %prec UNARY
1160 tree init = build_nt (CONSTRUCTOR, NULL_TREE,
1161 nreverse ($3));
1162 if (pedantic)
1163 pedwarn ("ANSI C++ forbids constructor-expressions");
1164 /* Indicate that this was a GNU C constructor expression. */
1165 TREE_HAS_CONSTRUCTOR (init) = 1;
1167 $$ = reparse_absdcl_as_casts ($$, init);
1171 expr_no_commas:
1172 cast_expr
1173 /* Handle general members. */
1174 | expr_no_commas POINTSAT_STAR expr_no_commas
1175 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1176 | expr_no_commas DOT_STAR expr_no_commas
1177 { $$ = build_m_component_ref ($$, $3); }
1178 | expr_no_commas '+' expr_no_commas
1179 { $$ = build_x_binary_op ($2, $$, $3); }
1180 | expr_no_commas '-' expr_no_commas
1181 { $$ = build_x_binary_op ($2, $$, $3); }
1182 | expr_no_commas '*' expr_no_commas
1183 { $$ = build_x_binary_op ($2, $$, $3); }
1184 | expr_no_commas '/' expr_no_commas
1185 { $$ = build_x_binary_op ($2, $$, $3); }
1186 | expr_no_commas '%' expr_no_commas
1187 { $$ = build_x_binary_op ($2, $$, $3); }
1188 | expr_no_commas LSHIFT expr_no_commas
1189 { $$ = build_x_binary_op ($2, $$, $3); }
1190 | expr_no_commas RSHIFT expr_no_commas
1191 { $$ = build_x_binary_op ($2, $$, $3); }
1192 | expr_no_commas ARITHCOMPARE expr_no_commas
1193 { $$ = build_x_binary_op ($2, $$, $3); }
1194 | expr_no_commas '<' expr_no_commas
1195 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1196 | expr_no_commas '>' expr_no_commas
1197 { $$ = build_x_binary_op (GT_EXPR, $$, $3); }
1198 | expr_no_commas EQCOMPARE expr_no_commas
1199 { $$ = build_x_binary_op ($2, $$, $3); }
1200 | expr_no_commas MIN_MAX expr_no_commas
1201 { $$ = build_x_binary_op ($2, $$, $3); }
1202 | expr_no_commas '&' expr_no_commas
1203 { $$ = build_x_binary_op ($2, $$, $3); }
1204 | expr_no_commas '|' expr_no_commas
1205 { $$ = build_x_binary_op ($2, $$, $3); }
1206 | expr_no_commas '^' expr_no_commas
1207 { $$ = build_x_binary_op ($2, $$, $3); }
1208 | expr_no_commas ANDAND expr_no_commas
1209 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1210 | expr_no_commas OROR expr_no_commas
1211 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1212 | expr_no_commas '?' xexpr ':' expr_no_commas
1213 { $$ = build_x_conditional_expr ($$, $3, $5); }
1214 | expr_no_commas '=' expr_no_commas
1215 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1216 if ($$ != error_mark_node)
1217 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1218 | expr_no_commas ASSIGN expr_no_commas
1219 { $$ = build_x_modify_expr ($$, $2, $3); }
1220 | THROW
1221 { $$ = build_throw (NULL_TREE); }
1222 | THROW expr_no_commas
1223 { $$ = build_throw ($2); }
1224 /* These extensions are not defined. The second arg to build_m_component_ref
1225 is old, build_m_component_ref now does an implicit
1226 build_indirect_ref (x, NULL_PTR) on the second argument.
1227 | object '&' expr_no_commas %prec UNARY
1228 { $$ = build_m_component_ref ($$, build_x_unary_op (ADDR_EXPR, $3)); }
1229 | object unop expr_no_commas %prec UNARY
1230 { $$ = build_m_component_ref ($$, build_x_unary_op ($2, $3)); }
1231 | object '(' type_id ')' expr_no_commas %prec UNARY
1232 { tree type = groktypename ($3.t);
1233 $$ = build_m_component_ref ($$, build_c_cast (type, $5)); }
1234 | object primary_no_id %prec UNARY
1235 { $$ = build_m_component_ref ($$, $2); }
1239 notype_unqualified_id:
1240 '~' see_typename identifier
1241 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1242 | operator_name
1243 | IDENTIFIER
1244 | PTYPENAME
1245 | NSNAME %prec EMPTY
1248 unqualified_id:
1249 notype_unqualified_id
1250 | TYPENAME
1251 | SELFNAME
1254 expr_or_declarator:
1255 notype_unqualified_id
1256 | '*' expr_or_declarator %prec UNARY
1257 { $$ = build_parse_node (INDIRECT_REF, $2); }
1258 | '&' expr_or_declarator %prec UNARY
1259 { $$ = build_parse_node (ADDR_EXPR, $2); }
1260 | '(' expr_or_declarator ')'
1261 { $$ = $2; }
1264 direct_notype_declarator:
1265 complex_direct_notype_declarator
1266 | notype_unqualified_id
1267 | '(' expr_or_declarator ')'
1268 { $$ = finish_decl_parsing ($2); }
1271 primary:
1272 notype_unqualified_id
1274 if (TREE_CODE ($$) == BIT_NOT_EXPR)
1275 $$ = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND ($$, 0));
1276 else
1277 $$ = do_identifier ($$, 1);
1279 | CONSTANT
1280 | boolean.literal
1281 | string
1283 if (processing_template_decl)
1284 push_obstacks (&permanent_obstack, &permanent_obstack);
1285 $$ = combine_strings ($$);
1286 if (processing_template_decl)
1287 pop_obstacks ();
1289 | '(' expr ')'
1290 { char class;
1291 $$ = $2;
1292 class = TREE_CODE_CLASS (TREE_CODE ($$));
1293 if (class == 'e' || class == '1'
1294 || class == '2' || class == '<')
1295 /* This inhibits warnings in truthvalue_conversion. */
1296 C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); }
1297 | '(' expr_or_declarator ')'
1298 { char class;
1299 $$ = reparse_decl_as_expr (NULL_TREE, $2);
1300 class = TREE_CODE_CLASS (TREE_CODE ($$));
1301 if (class == 'e' || class == '1'
1302 || class == '2' || class == '<')
1303 /* This inhibits warnings in truthvalue_conversion. */
1304 C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); }
1305 | '(' error ')'
1306 { $$ = error_mark_node; }
1307 | '('
1308 { if (current_function_decl == 0)
1310 error ("braced-group within expression allowed only inside a function");
1311 YYERROR;
1313 keep_next_level ();
1314 $<ttype>$ = expand_start_stmt_expr (); }
1315 compstmt ')'
1316 { tree rtl_exp;
1317 if (pedantic)
1318 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1319 rtl_exp = expand_end_stmt_expr ($<ttype>2);
1320 /* The statements have side effects, so the group does. */
1321 TREE_SIDE_EFFECTS (rtl_exp) = 1;
1323 if (TREE_CODE ($3) == BLOCK)
1325 /* Make a BIND_EXPR for the BLOCK already made. */
1326 $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
1327 NULL_TREE, rtl_exp, $3);
1328 /* Remove the block from the tree at this point.
1329 It gets put back at the proper place
1330 when the BIND_EXPR is expanded. */
1331 delete_block ($3);
1333 else
1334 $$ = $3;
1336 | primary '(' nonnull_exprlist ')'
1338 $$ = build_x_function_call ($1, $3, current_class_ref);
1339 if (TREE_CODE ($$) == CALL_EXPR
1340 && TREE_TYPE ($$) != void_type_node)
1341 $$ = require_complete_type ($$);
1343 | primary LEFT_RIGHT
1345 $$ = build_x_function_call ($$, NULL_TREE, current_class_ref);
1346 if (TREE_CODE ($$) == CALL_EXPR
1347 && TREE_TYPE ($$) != void_type_node)
1348 $$ = require_complete_type ($$);
1350 | primary '[' expr ']'
1351 { $$ = grok_array_decl ($$, $3); }
1352 | primary PLUSPLUS
1353 { /* If we get an OFFSET_REF, turn it into what it really
1354 means (e.g., a COMPONENT_REF). This way if we've got,
1355 say, a reference to a static member that's being operated
1356 on, we don't end up trying to find a member operator for
1357 the class it's in. */
1358 if (TREE_CODE ($$) == OFFSET_REF)
1359 $$ = resolve_offset_ref ($$);
1360 $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1361 | primary MINUSMINUS
1362 { if (TREE_CODE ($$) == OFFSET_REF)
1363 $$ = resolve_offset_ref ($$);
1364 $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1365 /* C++ extensions */
1366 | THIS
1367 { if (current_class_ptr)
1369 #ifdef WARNING_ABOUT_CCD
1370 TREE_USED (current_class_ptr) = 1;
1371 #endif
1372 $$ = current_class_ptr;
1374 else if (current_function_decl
1375 && DECL_STATIC_FUNCTION_P (current_function_decl))
1377 error ("`this' is unavailable for static member functions");
1378 $$ = error_mark_node;
1380 else
1382 if (current_function_decl)
1383 error ("invalid use of `this' in non-member function");
1384 else
1385 error ("invalid use of `this' at top level");
1386 $$ = error_mark_node;
1389 | CV_QUALIFIER '(' nonnull_exprlist ')'
1391 tree type;
1392 tree id = $$;
1394 /* This is a C cast in C++'s `functional' notation. */
1395 if ($3 == error_mark_node)
1397 $$ = error_mark_node;
1398 break;
1400 #if 0
1401 if ($3 == NULL_TREE)
1403 error ("cannot cast null list to type `%s'",
1404 IDENTIFIER_POINTER (TYPE_NAME (id)));
1405 $$ = error_mark_node;
1406 break;
1408 #endif
1409 #if 0
1410 /* type is not set! (mrs) */
1411 if (type == error_mark_node)
1412 $$ = error_mark_node;
1413 else
1414 #endif
1416 if (id == ridpointers[(int) RID_CONST])
1417 type = build_type_variant (integer_type_node, 1, 0);
1418 else if (id == ridpointers[(int) RID_VOLATILE])
1419 type = build_type_variant (integer_type_node, 0, 1);
1420 #if 0
1421 /* should not be able to get here (mrs) */
1422 else if (id == ridpointers[(int) RID_FRIEND])
1424 error ("cannot cast expression to `friend' type");
1425 $$ = error_mark_node;
1426 break;
1428 #endif
1429 else my_friendly_abort (79);
1430 $$ = build_c_cast (type, build_compound_expr ($3));
1433 | functional_cast
1434 | DYNAMIC_CAST '<' type_id '>' '(' expr ')'
1435 { tree type = groktypename ($3.t);
1436 check_for_new_type ("dynamic_cast", $3);
1437 $$ = build_dynamic_cast (type, $6); }
1438 | STATIC_CAST '<' type_id '>' '(' expr ')'
1439 { tree type = groktypename ($3.t);
1440 check_for_new_type ("static_cast", $3);
1441 $$ = build_static_cast (type, $6); }
1442 | REINTERPRET_CAST '<' type_id '>' '(' expr ')'
1443 { tree type = groktypename ($3.t);
1444 check_for_new_type ("reinterpret_cast", $3);
1445 $$ = build_reinterpret_cast (type, $6); }
1446 | CONST_CAST '<' type_id '>' '(' expr ')'
1447 { tree type = groktypename ($3.t);
1448 check_for_new_type ("const_cast", $3);
1449 $$ = build_const_cast (type, $6); }
1450 | TYPEID '(' expr ')'
1451 { $$ = build_x_typeid ($3); }
1452 | TYPEID '(' type_id ')'
1453 { tree type = groktypename ($3.t);
1454 check_for_new_type ("typeid", $3);
1455 $$ = get_typeid (TYPE_MAIN_VARIANT (type)); }
1456 | global_scope IDENTIFIER
1457 { $$ = do_scoped_id ($2, 1); }
1458 | global_scope operator_name
1460 got_scope = NULL_TREE;
1461 if (TREE_CODE ($2) == IDENTIFIER_NODE)
1462 $$ = do_scoped_id ($2, 1);
1463 else
1464 $$ = $2;
1466 | overqualified_id %prec HYPERUNARY
1467 { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); }
1468 | overqualified_id '(' nonnull_exprlist ')'
1469 { if (processing_template_decl)
1470 $$ = build_min_nt (CALL_EXPR, copy_to_permanent ($1), $3, NULL_TREE);
1471 else
1472 $$ = build_member_call (OP0 ($$), OP1 ($$), $3); }
1473 | overqualified_id LEFT_RIGHT
1474 { if (processing_template_decl)
1475 $$ = build_min_nt (CALL_EXPR, copy_to_permanent ($1),
1476 NULL_TREE, NULL_TREE);
1477 else
1478 $$ = build_member_call (OP0 ($$), OP1 ($$), NULL_TREE); }
1479 | object unqualified_id %prec UNARY
1480 { $$ = build_x_component_ref ($$, $2, NULL_TREE, 1); }
1481 | object overqualified_id %prec UNARY
1482 { if (processing_template_decl)
1483 $$ = build_min_nt (COMPONENT_REF, $1, copy_to_permanent ($2));
1484 else
1485 $$ = build_object_ref ($$, OP0 ($2), OP1 ($2)); }
1486 | object unqualified_id '(' nonnull_exprlist ')'
1488 #if 0
1489 /* This is a future direction of this code, but because
1490 build_x_function_call cannot always undo what is done
1491 in build_component_ref entirely yet, we cannot do this. */
1492 $$ = build_x_function_call (build_component_ref ($$, $2, NULL_TREE, 1), $4, current_class_ref);
1493 if (TREE_CODE ($$) == CALL_EXPR
1494 && TREE_TYPE ($$) != void_type_node)
1495 $$ = require_complete_type ($$);
1496 #else
1497 $$ = build_method_call ($$, $2, $4, NULL_TREE,
1498 LOOKUP_NORMAL);
1499 #endif
1501 | object unqualified_id LEFT_RIGHT
1503 #if 0
1504 /* This is a future direction of this code, but because
1505 build_x_function_call cannot always undo what is done
1506 in build_component_ref entirely yet, we cannot do this. */
1507 $$ = build_x_function_call (build_component_ref ($$, $2, NULL_TREE, 1), NULL_TREE, current_class_ref);
1508 if (TREE_CODE ($$) == CALL_EXPR
1509 && TREE_TYPE ($$) != void_type_node)
1510 $$ = require_complete_type ($$);
1511 #else
1512 $$ = build_method_call ($$, $2, NULL_TREE, NULL_TREE,
1513 LOOKUP_NORMAL);
1514 #endif
1516 | object overqualified_id '(' nonnull_exprlist ')'
1518 if (IS_SIGNATURE (OP0 ($2)))
1520 warning ("signature name in scope resolution ignored");
1521 $$ = build_method_call ($$, OP1 ($2), $4, NULL_TREE,
1522 LOOKUP_NORMAL);
1524 else
1525 $$ = build_scoped_method_call ($$, OP0 ($2), OP1 ($2), $4);
1527 | object overqualified_id LEFT_RIGHT
1529 if (IS_SIGNATURE (OP0 ($2)))
1531 warning ("signature name in scope resolution ignored");
1532 $$ = build_method_call ($$, OP1 ($2), NULL_TREE, NULL_TREE,
1533 LOOKUP_NORMAL);
1535 else
1536 $$ = build_scoped_method_call ($$, OP0 ($2), OP1 ($2), NULL_TREE);
1538 /* p->int::~int() is valid -- 12.4 */
1539 | object '~' TYPESPEC LEFT_RIGHT
1541 if (IDENTIFIER_GLOBAL_VALUE ($3)
1542 && (TREE_CODE (TREE_TYPE ($1))
1543 != TREE_CODE (TREE_TYPE (IDENTIFIER_GLOBAL_VALUE ($3)))))
1544 cp_error ("`%E' is not of type `%T'", $1, $3);
1545 $$ = convert (void_type_node, $1);
1547 | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT
1549 if ($2 != $5)
1550 cp_error ("destructor specifier `%T::~%T()' must have matching names", $2, $5);
1551 if (TREE_CODE (TREE_TYPE ($1))
1552 != TREE_CODE (TREE_TYPE (IDENTIFIER_GLOBAL_VALUE ($2))))
1553 cp_error ("`%E' is not of type `%T'", $1, $2);
1554 $$ = convert (void_type_node, $1);
1556 | object error
1558 $$ = error_mark_node;
1562 /* Not needed for now.
1564 primary_no_id:
1565 '(' expr ')'
1566 { $$ = $2; }
1567 | '(' error ')'
1568 { $$ = error_mark_node; }
1569 | '('
1570 { if (current_function_decl == 0)
1572 error ("braced-group within expression allowed only inside a function");
1573 YYERROR;
1575 $<ttype>$ = expand_start_stmt_expr (); }
1576 compstmt ')'
1577 { if (pedantic)
1578 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1579 $$ = expand_end_stmt_expr ($<ttype>2); }
1580 | primary_no_id '(' nonnull_exprlist ')'
1581 { $$ = build_x_function_call ($$, $3, current_class_ref); }
1582 | primary_no_id LEFT_RIGHT
1583 { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); }
1584 | primary_no_id '[' expr ']'
1585 { goto do_array; }
1586 | primary_no_id PLUSPLUS
1587 { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1588 | primary_no_id MINUSMINUS
1589 { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1590 | SCOPE IDENTIFIER
1591 { goto do_scoped_id; }
1592 | SCOPE operator_name
1593 { if (TREE_CODE ($2) == IDENTIFIER_NODE)
1594 goto do_scoped_id;
1595 goto do_scoped_operator;
1600 new:
1602 { $$ = 0; }
1603 | global_scope NEW
1604 { got_scope = NULL_TREE; $$ = 1; }
1607 delete:
1608 DELETE
1609 { $$ = 0; }
1610 | global_scope delete
1611 { got_scope = NULL_TREE; $$ = 1; }
1614 boolean.literal:
1615 CXX_TRUE
1616 { $$ = boolean_true_node; }
1617 | CXX_FALSE
1618 { $$ = boolean_false_node; }
1621 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
1622 string:
1623 STRING
1624 | string STRING
1625 { $$ = chainon ($$, $2); }
1628 nodecls:
1629 /* empty */
1631 if (! current_function_parms_stored)
1632 store_parm_decls ();
1633 setup_vtbl_ptr ();
1634 /* Always keep the BLOCK node associated with the outermost
1635 pair of curley braces of a function. These are needed
1636 for correct operation of dwarfout.c. */
1637 keep_next_level ();
1641 object:
1642 primary '.'
1643 { got_object = TREE_TYPE ($$); }
1644 | primary POINTSAT
1646 $$ = build_x_arrow ($$);
1647 got_object = TREE_TYPE ($$);
1651 decl:
1652 typespec initdecls ';'
1654 resume_momentary ($2);
1655 if (IS_AGGR_TYPE_CODE (TREE_CODE ($1.t)))
1656 note_got_semicolon ($1.t);
1658 | typed_declspecs initdecls ';'
1660 resume_momentary ($2);
1661 note_list_got_semicolon ($1.t);
1663 | declmods notype_initdecls ';'
1664 { resume_momentary ($2); }
1665 | typed_declspecs ';'
1667 shadow_tag ($1.t);
1668 note_list_got_semicolon ($1.t);
1670 | declmods ';'
1671 { warning ("empty declaration"); }
1672 | extension decl
1673 { pedantic = $<itype>1; }
1676 /* Any kind of declarator (thus, all declarators allowed
1677 after an explicit typespec). */
1679 declarator:
1680 after_type_declarator %prec EMPTY
1681 | notype_declarator %prec EMPTY
1684 /* This is necessary to postpone reduction of `int()()()()'. */
1685 fcast_or_absdcl:
1686 LEFT_RIGHT %prec EMPTY
1687 { $$ = make_call_declarator (NULL_TREE, empty_parms (),
1688 NULL_TREE, NULL_TREE); }
1689 | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
1690 { $$ = make_call_declarator ($$, empty_parms (), NULL_TREE,
1691 NULL_TREE); }
1694 /* ANSI type-id (8.1) */
1695 type_id:
1696 typed_typespecs absdcl
1697 { $$.t = build_decl_list ($1.t, $2);
1698 $$.new_type_flag = $1.new_type_flag; }
1699 | nonempty_cv_qualifiers absdcl
1700 { $$.t = build_decl_list ($1.t, $2);
1701 $$.new_type_flag = $1.new_type_flag; }
1702 | typespec absdcl
1703 { $$.t = build_decl_list (get_decl_list ($1.t), $2);
1704 $$.new_type_flag = $1.new_type_flag; }
1705 | typed_typespecs %prec EMPTY
1706 { $$.t = build_decl_list ($1.t, NULL_TREE);
1707 $$.new_type_flag = $1.new_type_flag; }
1708 | nonempty_cv_qualifiers %prec EMPTY
1709 { $$.t = build_decl_list ($1.t, NULL_TREE);
1710 $$.new_type_flag = $1.new_type_flag; }
1713 /* Declspecs which contain at least one type specifier or typedef name.
1714 (Just `const' or `volatile' is not enough.)
1715 A typedef'd name following these is taken as a name to be declared.
1716 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1718 typed_declspecs:
1719 typed_typespecs %prec EMPTY
1720 | typed_declspecs1
1723 typed_declspecs1:
1724 declmods typespec
1725 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1);
1726 $$.new_type_flag = $2.new_type_flag; }
1727 | typespec reserved_declspecs %prec HYPERUNARY
1728 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1729 $$.new_type_flag = $1.new_type_flag; }
1730 | typespec reserved_typespecquals reserved_declspecs
1731 { $$.t = decl_tree_cons (NULL_TREE, $1.t, chainon ($2, $3));
1732 $$.new_type_flag = $1.new_type_flag; }
1733 | declmods typespec reserved_declspecs
1734 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1735 $$.new_type_flag = $2.new_type_flag; }
1736 | declmods typespec reserved_typespecquals
1737 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1738 $$.new_type_flag = $2.new_type_flag; }
1739 | declmods typespec reserved_typespecquals reserved_declspecs
1740 { $$.t = decl_tree_cons (NULL_TREE, $2.t,
1741 chainon ($3, chainon ($4, $1)));
1742 $$.new_type_flag = $2.new_type_flag; }
1745 reserved_declspecs:
1746 SCSPEC
1747 { if (extra_warnings)
1748 warning ("`%s' is not at beginning of declaration",
1749 IDENTIFIER_POINTER ($$));
1750 $$ = build_decl_list (NULL_TREE, $$); }
1751 | reserved_declspecs typespecqual_reserved
1752 { $$ = decl_tree_cons (NULL_TREE, $2.t, $$); }
1753 | reserved_declspecs SCSPEC
1754 { if (extra_warnings)
1755 warning ("`%s' is not at beginning of declaration",
1756 IDENTIFIER_POINTER ($2));
1757 $$ = decl_tree_cons (NULL_TREE, $2, $$); }
1758 | reserved_declspecs attributes
1759 { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
1760 | attributes
1761 { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
1764 /* List of just storage classes and type modifiers.
1765 A declaration can start with just this, but then it cannot be used
1766 to redeclare a typedef-name.
1767 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1769 declmods:
1770 nonempty_cv_qualifiers %prec EMPTY
1771 { $$ = $1.t; TREE_STATIC ($$) = 1; }
1772 | SCSPEC
1773 { $$ = IDENTIFIER_AS_LIST ($$); }
1774 | declmods CV_QUALIFIER
1775 { $$ = decl_tree_cons (NULL_TREE, $2, $$);
1776 TREE_STATIC ($$) = 1; }
1777 | declmods SCSPEC
1778 { if (extra_warnings && TREE_STATIC ($$))
1779 warning ("`%s' is not at beginning of declaration",
1780 IDENTIFIER_POINTER ($2));
1781 $$ = decl_tree_cons (NULL_TREE, $2, $$);
1782 TREE_STATIC ($$) = TREE_STATIC ($1); }
1783 | declmods attributes
1784 { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
1785 | attributes
1786 { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
1789 /* Used instead of declspecs where storage classes are not allowed
1790 (that is, for typenames and structure components).
1792 C++ can takes storage classes for structure components.
1793 Don't accept a typedef-name if anything but a modifier precedes it. */
1795 typed_typespecs:
1796 typespec %prec EMPTY
1797 { $$.t = get_decl_list ($1.t);
1798 $$.new_type_flag = $1.new_type_flag; }
1799 | nonempty_cv_qualifiers typespec
1800 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1.t);
1801 $$.new_type_flag = $2.new_type_flag; }
1802 | typespec reserved_typespecquals
1803 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1804 $$.new_type_flag = $1.new_type_flag; }
1805 | nonempty_cv_qualifiers typespec reserved_typespecquals
1806 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1807 $$.new_type_flag = $1.new_type_flag; }
1810 reserved_typespecquals:
1811 typespecqual_reserved
1812 { $$ = build_decl_list (NULL_TREE, $1.t); }
1813 | reserved_typespecquals typespecqual_reserved
1814 { $$ = decl_tree_cons (NULL_TREE, $2.t, $1); }
1817 /* A typespec (but not a type qualifier).
1818 Once we have seen one of these in a declaration,
1819 if a typedef name appears then it is being redeclared. */
1821 typespec:
1822 structsp
1823 | TYPESPEC %prec EMPTY
1824 { $$.t = $1; $$.new_type_flag = 0; }
1825 | complete_type_name
1826 { $$.t = $1; $$.new_type_flag = 0; }
1827 | TYPEOF '(' expr ')'
1828 { $$.t = TREE_TYPE ($3);
1829 $$.new_type_flag = 0;
1830 if (pedantic && !in_system_header)
1831 pedwarn ("ANSI C++ forbids `typeof'"); }
1832 | TYPEOF '(' type_id ')'
1833 { $$.t = groktypename ($3.t);
1834 if (pedantic && !in_system_header)
1835 pedwarn ("ANSI C++ forbids `typeof'");
1836 $$.new_type_flag = 0; }
1837 | SIGOF '(' expr ')'
1838 { tree type = TREE_TYPE ($3);
1840 $$.new_type_flag = 0;
1841 if (IS_AGGR_TYPE (type))
1843 sorry ("sigof type specifier");
1844 $$.t = type;
1846 else
1848 error ("`sigof' applied to non-aggregate expression");
1849 $$.t = error_mark_node;
1852 | SIGOF '(' type_id ')'
1853 { tree type = groktypename ($3.t);
1855 $$.new_type_flag = 0;
1856 if (IS_AGGR_TYPE (type))
1858 sorry ("sigof type specifier");
1859 $$.t = type;
1861 else
1863 error("`sigof' applied to non-aggregate type");
1864 $$.t = error_mark_node;
1869 /* A typespec that is a reserved word, or a type qualifier. */
1871 typespecqual_reserved:
1872 TYPESPEC
1873 { $$.t = $1; $$.new_type_flag = 0; }
1874 | CV_QUALIFIER
1875 { $$.t = $1; $$.new_type_flag = 0; }
1876 | structsp
1879 initdecls:
1880 initdcl0
1881 | initdecls ',' initdcl
1884 notype_initdecls:
1885 notype_initdcl0
1886 | notype_initdecls ',' initdcl
1889 nomods_initdecls:
1890 nomods_initdcl0
1891 | nomods_initdecls ',' initdcl
1894 maybeasm:
1895 /* empty */
1896 { $$ = NULL_TREE; }
1897 | asm_keyword '(' string ')'
1898 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); $$ = $3; }
1901 initdcl0:
1902 declarator maybeasm maybe_attribute '='
1903 { split_specs_attrs ($<ttype>0, &current_declspecs,
1904 &prefix_attributes);
1905 if (TREE_CODE (current_declspecs) != TREE_LIST)
1906 current_declspecs = get_decl_list (current_declspecs);
1907 if (have_extern_spec && !used_extern_spec)
1909 current_declspecs = decl_tree_cons
1910 (NULL_TREE, get_identifier ("extern"),
1911 current_declspecs);
1912 used_extern_spec = 1;
1914 $<itype>4 = suspend_momentary ();
1915 $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1);
1916 cplus_decl_attributes ($<ttype>$, $3, prefix_attributes); }
1917 init
1918 /* Note how the declaration of the variable is in effect while its init is parsed! */
1919 { cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING);
1920 $$ = $<itype>4; }
1921 | declarator maybeasm maybe_attribute
1922 { tree d;
1923 split_specs_attrs ($<ttype>0, &current_declspecs,
1924 &prefix_attributes);
1925 if (TREE_CODE (current_declspecs) != TREE_LIST)
1926 current_declspecs = get_decl_list (current_declspecs);
1927 if (have_extern_spec && !used_extern_spec)
1929 current_declspecs = decl_tree_cons
1930 (NULL_TREE, get_identifier ("extern"),
1931 current_declspecs);
1932 used_extern_spec = 1;
1934 $$ = suspend_momentary ();
1935 d = start_decl ($<ttype>1, current_declspecs, 0);
1936 cplus_decl_attributes (d, $3, prefix_attributes);
1937 cp_finish_decl (d, NULL_TREE, $2, 1, 0); }
1940 initdcl:
1941 declarator maybeasm maybe_attribute '='
1942 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1);
1943 cplus_decl_attributes ($<ttype>$, $3, prefix_attributes); }
1944 init
1945 /* Note how the declaration of the variable is in effect while its init is parsed! */
1946 { cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING); }
1947 | declarator maybeasm maybe_attribute
1948 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 0);
1949 cplus_decl_attributes ($<ttype>$, $3, prefix_attributes);
1950 cp_finish_decl ($<ttype>$, NULL_TREE, $2, 1, 0); }
1953 notype_initdcl0:
1954 notype_declarator maybeasm maybe_attribute '='
1955 { split_specs_attrs ($<ttype>0, &current_declspecs,
1956 &prefix_attributes);
1957 $<itype>4 = suspend_momentary ();
1958 $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1);
1959 cplus_decl_attributes ($<ttype>$, $3, prefix_attributes); }
1960 init
1961 /* Note how the declaration of the variable is in effect while its init is parsed! */
1962 { cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING);
1963 $$ = $<itype>4; }
1964 | notype_declarator maybeasm maybe_attribute
1965 { tree d;
1966 split_specs_attrs ($<ttype>0, &current_declspecs,
1967 &prefix_attributes);
1968 $$ = suspend_momentary ();
1969 d = start_decl ($<ttype>1, current_declspecs, 0);
1970 cplus_decl_attributes (d, $3, prefix_attributes);
1971 cp_finish_decl (d, NULL_TREE, $2, 1, 0); }
1974 nomods_initdcl0:
1975 notype_declarator maybeasm maybe_attribute '='
1976 { current_declspecs = NULL_TREE;
1977 prefix_attributes = NULL_TREE;
1978 $<itype>4 = suspend_momentary ();
1979 $<ttype>$ = start_decl ($1, current_declspecs, 1);
1980 cplus_decl_attributes ($<ttype>$, $3, prefix_attributes); }
1981 init
1982 /* Note how the declaration of the variable is in effect while its init is parsed! */
1983 { cp_finish_decl ($<ttype>5, $6, $2, 1, LOOKUP_ONLYCONVERTING);
1984 $$ = $<itype>4; }
1985 | notype_declarator maybeasm maybe_attribute
1986 { tree d;
1987 current_declspecs = NULL_TREE;
1988 prefix_attributes = NULL_TREE;
1989 $$ = suspend_momentary ();
1990 d = start_decl ($1, current_declspecs, 0);
1991 cplus_decl_attributes (d, $3, prefix_attributes);
1992 cp_finish_decl (d, NULL_TREE, $2, 1, 0); }
1995 /* the * rules are dummies to accept the Apollo extended syntax
1996 so that the header files compile. */
1997 maybe_attribute:
1998 /* empty */
1999 { $$ = NULL_TREE; }
2000 | attributes
2001 { $$ = $1; }
2004 attributes:
2005 attribute
2006 { $$ = $1; }
2007 | attributes attribute
2008 { $$ = chainon ($1, $2); }
2011 attribute:
2012 ATTRIBUTE '(' '(' attribute_list ')' ')'
2013 { $$ = $4; }
2016 attribute_list:
2017 attrib
2018 { $$ = $1; }
2019 | attribute_list ',' attrib
2020 { $$ = chainon ($1, $3); }
2023 attrib:
2024 /* empty */
2025 { $$ = NULL_TREE; }
2026 | any_word
2027 { $$ = build_tree_list ($1, NULL_TREE); }
2028 | any_word '(' IDENTIFIER ')'
2029 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
2030 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
2031 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
2032 | any_word '(' nonnull_exprlist ')'
2033 { $$ = build_tree_list ($1, $3); }
2036 /* This still leaves out most reserved keywords,
2037 shouldn't we include them? */
2039 any_word:
2040 identifier
2041 | SCSPEC
2042 | TYPESPEC
2043 | CV_QUALIFIER
2046 /* A nonempty list of identifiers, including typenames. */
2047 identifiers_or_typenames:
2048 identifier
2049 { $$ = build_tree_list (NULL_TREE, $1); }
2050 | identifiers_or_typenames ',' identifier
2051 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2054 maybe_init:
2055 /* empty */ %prec EMPTY
2056 { $$ = NULL_TREE; }
2057 | '=' init
2058 { $$ = $2; }
2060 /* If we are processing a template, we don't want to expand this
2061 initializer yet. */
2063 init:
2064 expr_no_commas %prec '='
2065 | '{' '}'
2066 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
2067 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2068 | '{' initlist '}'
2069 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2070 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2071 | '{' initlist ',' '}'
2072 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2073 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2074 | error
2075 { $$ = NULL_TREE; }
2078 /* This chain is built in reverse order,
2079 and put in forward order where initlist is used. */
2080 initlist:
2081 init
2082 { $$ = build_tree_list (NULL_TREE, $$); }
2083 | initlist ',' init
2084 { $$ = tree_cons (NULL_TREE, $3, $$); }
2085 /* These are for labeled elements. */
2086 | '[' expr_no_commas ']' init
2087 { $$ = build_tree_list ($2, $4); }
2088 | initlist ',' CASE expr_no_commas ':' init
2089 { $$ = tree_cons ($4, $6, $$); }
2090 | identifier ':' init
2091 { $$ = build_tree_list ($$, $3); }
2092 | initlist ',' identifier ':' init
2093 { $$ = tree_cons ($3, $5, $$); }
2096 fn.defpen:
2097 PRE_PARSED_FUNCTION_DECL
2098 { start_function (NULL_TREE, TREE_VALUE ($1),
2099 NULL_TREE, 1);
2100 reinit_parse_for_function (); }
2102 pending_inlines:
2103 /* empty */
2104 | pending_inlines fn.defpen maybe_return_init ctor_initializer_opt
2105 compstmt_or_error
2107 int nested = (hack_decl_function_context
2108 (current_function_decl) != NULL_TREE);
2109 finish_function (lineno, (int)$4, nested);
2110 process_next_inline ($2);
2112 | pending_inlines fn.defpen maybe_return_init function_try_block
2113 { process_next_inline ($2); }
2114 eat_saved_input
2117 structsp:
2118 ENUM identifier '{'
2119 { $<itype>3 = suspend_momentary ();
2120 $<ttype>$ = start_enum ($2); }
2121 enumlist maybecomma_warn '}'
2122 { $$.t = finish_enum ($<ttype>4, $5);
2123 $$.new_type_flag = 1;
2124 resume_momentary ((int) $<itype>3);
2125 check_for_missing_semicolon ($<ttype>4); }
2126 | ENUM identifier '{' '}'
2127 { $$.t = finish_enum (start_enum ($2), NULL_TREE);
2128 $$.new_type_flag = 1;
2129 check_for_missing_semicolon ($$.t); }
2130 | ENUM '{'
2131 { $<itype>2 = suspend_momentary ();
2132 $<ttype>$ = start_enum (make_anon_name ()); }
2133 enumlist maybecomma_warn '}'
2134 { $$.t = finish_enum ($<ttype>3, $4);
2135 resume_momentary ((int) $<itype>1);
2136 check_for_missing_semicolon ($<ttype>3);
2137 $$.new_type_flag = 1; }
2138 | ENUM '{' '}'
2139 { $$.t = finish_enum (start_enum (make_anon_name()), NULL_TREE);
2140 $$.new_type_flag = 1;
2141 check_for_missing_semicolon ($$.t); }
2142 | ENUM identifier
2143 { $$.t = xref_tag (enum_type_node, $2, NULL_TREE, 1);
2144 $$.new_type_flag = 0; }
2145 | ENUM complex_type_name
2146 { $$.t = xref_tag (enum_type_node, $2, NULL_TREE, 1);
2147 $$.new_type_flag = 0; }
2148 | TYPENAME_KEYWORD nested_name_specifier identifier
2149 { $$.t = make_typename_type ($2, $3);
2150 $$.new_type_flag = 0; }
2151 | TYPENAME_KEYWORD global_scope nested_name_specifier identifier
2152 { $$.t = make_typename_type ($3, $4);
2153 $$.new_type_flag = 0; }
2154 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2155 | class_head left_curly opt.component_decl_list '}' maybe_attribute
2157 int semi;
2158 tree id;
2160 $<ttype>$ = $1;
2161 #if 0
2162 /* Need to rework class nesting in the
2163 presence of nested classes, etc. */
2164 shadow_tag (CLASSTYPE_AS_LIST ($1)); */
2165 #endif
2166 if (yychar == YYEMPTY)
2167 yychar = YYLEX;
2168 semi = yychar == ';';
2169 /* finish_struct nukes this anyway; if
2170 finish_exception does too, then it can go. */
2171 if (semi)
2172 note_got_semicolon ($1);
2174 if (TREE_CODE ($1) == ENUMERAL_TYPE)
2176 else
2178 $<ttype>$ = finish_struct ($1, $3, $5, semi);
2179 if (semi) note_got_semicolon ($<ttype>$);
2182 pop_obstacks ();
2184 if (! semi)
2185 check_for_missing_semicolon ($1);
2186 if (pending_inlines
2187 && current_scope () == current_function_decl)
2188 do_pending_inlines ();
2190 pending_inlines
2191 { $$.t = $<ttype>6;
2192 $$.new_type_flag = 1; }
2193 | class_head %prec EMPTY
2195 $$.t = $1;
2196 $$.new_type_flag = 0;
2197 /* struct B: public A; is not accepted by the WP grammar. */
2198 if (TYPE_BINFO_BASETYPES ($$.t) && !TYPE_SIZE ($$.t)
2199 && ! TYPE_BEING_DEFINED ($$.t))
2200 cp_error ("base clause without member specification for `%#T'",
2201 $$.t);
2205 maybecomma:
2206 /* empty */
2207 | ','
2210 maybecomma_warn:
2211 /* empty */
2212 | ','
2213 { if (pedantic && !in_system_header)
2214 pedwarn ("comma at end of enumerator list"); }
2217 aggr:
2218 AGGR
2219 | aggr SCSPEC
2220 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2221 | aggr TYPESPEC
2222 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2223 | aggr CV_QUALIFIER
2224 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2225 | aggr AGGR
2226 { error ("no body nor ';' separates two class, struct or union declarations"); }
2229 named_class_head_sans_basetype:
2230 aggr identifier
2231 { current_aggr = $$; $$ = $2; }
2234 named_class_head_sans_basetype_defn:
2235 aggr identifier_defn %prec EMPTY
2236 { current_aggr = $$; $$ = $2; }
2239 named_complex_class_head_sans_basetype:
2240 aggr nested_name_specifier identifier
2242 current_aggr = $1;
2243 if (TREE_CODE ($3) == TYPE_DECL)
2244 $$ = $3;
2245 else
2247 cp_error ("`%T' does not have a nested type named `%D'",
2248 $2, $3);
2249 $$ = xref_tag
2250 (current_aggr, make_anon_name (), NULL_TREE, 1);
2251 $$ = TYPE_MAIN_DECL ($$);
2254 | aggr template_type
2255 { current_aggr = $$; $$ = $2; }
2256 | aggr nested_name_specifier template_type
2257 { current_aggr = $$; $$ = $3; }
2260 do_xref_defn:
2261 /* empty */ %prec EMPTY
2262 { $<ttype>$ = xref_tag (current_aggr, $<ttype>0, NULL_TREE, 0); }
2265 named_class_head:
2266 named_class_head_sans_basetype %prec EMPTY
2267 { $$ = xref_tag (current_aggr, $1, NULL_TREE, 1); }
2268 | named_class_head_sans_basetype_defn do_xref_defn
2269 maybe_base_class_list %prec EMPTY
2271 $$ = $<ttype>2;
2272 if ($3)
2273 xref_basetypes (current_aggr, $1, $<ttype>2, $3);
2275 | named_complex_class_head_sans_basetype maybe_base_class_list
2277 $$ = TREE_TYPE ($1);
2278 if (TREE_INT_CST_LOW (current_aggr) == union_type
2279 && TREE_CODE ($$) != UNION_TYPE)
2280 cp_pedwarn ("`union' tag used in declaring `%#T'", $$);
2281 else if (TREE_CODE ($$) == UNION_TYPE
2282 && TREE_INT_CST_LOW (current_aggr) != union_type)
2283 cp_pedwarn ("non-`union' tag used in declaring `%#T'", $$);
2284 if ($2)
2286 if (IS_AGGR_TYPE ($$) && CLASSTYPE_USE_TEMPLATE ($$))
2288 if (CLASSTYPE_IMPLICIT_INSTANTIATION ($$)
2289 && TYPE_SIZE ($$) == NULL_TREE)
2291 SET_CLASSTYPE_TEMPLATE_SPECIALIZATION ($$);
2292 if (processing_template_decl)
2293 push_template_decl (TYPE_MAIN_DECL ($$));
2295 else if (CLASSTYPE_TEMPLATE_INSTANTIATION ($$))
2296 cp_error ("specialization after instantiation of `%T'", $$);
2298 xref_basetypes (current_aggr, $1, $$, $2);
2303 unnamed_class_head:
2304 aggr '{'
2305 { $$ = xref_tag ($$, make_anon_name (), NULL_TREE, 0);
2306 yyungetc ('{', 1); }
2309 class_head:
2310 unnamed_class_head
2311 | named_class_head
2314 maybe_base_class_list:
2315 /* empty */ %prec EMPTY
2316 { $$ = NULL_TREE; }
2317 | ':' see_typename %prec EMPTY
2318 { yyungetc(':', 1); $$ = NULL_TREE; }
2319 | ':' see_typename base_class_list %prec EMPTY
2320 { $$ = $3; }
2323 base_class_list:
2324 base_class
2325 | base_class_list ',' see_typename base_class
2326 { $$ = chainon ($$, $4); }
2329 base_class:
2330 base_class.1
2332 tree type = TREE_TYPE ($1);
2333 if (! is_aggr_type (type, 1))
2334 $$ = NULL_TREE;
2335 else if (current_aggr == signature_type_node
2336 && (! type) && (! IS_SIGNATURE (type)))
2338 error ("class name not allowed as base signature");
2339 $$ = NULL_TREE;
2341 else if (current_aggr == signature_type_node)
2343 sorry ("signature inheritance, base type `%s' ignored",
2344 IDENTIFIER_POINTER ($$));
2345 $$ = build_tree_list (access_public_node, type);
2347 else if (type && IS_SIGNATURE (type))
2349 error ("signature name not allowed as base class");
2350 $$ = NULL_TREE;
2352 else
2353 $$ = build_tree_list (access_default_node, type);
2355 | base_class_access_list see_typename base_class.1
2357 tree type = TREE_TYPE ($3);
2358 if (current_aggr == signature_type_node)
2359 error ("access and source specifiers not allowed in signature");
2360 if (! IS_AGGR_TYPE (type))
2361 $$ = NULL_TREE;
2362 else if (current_aggr == signature_type_node
2363 && (! type) && (! IS_SIGNATURE (type)))
2365 error ("class name not allowed as base signature");
2366 $$ = NULL_TREE;
2368 else if (current_aggr == signature_type_node)
2370 sorry ("signature inheritance, base type `%s' ignored",
2371 IDENTIFIER_POINTER ($$));
2372 $$ = build_tree_list (access_public_node, type);
2374 else if (type && IS_SIGNATURE (type))
2376 error ("signature name not allowed as base class");
2377 $$ = NULL_TREE;
2379 else
2380 $$ = build_tree_list ($$, type);
2384 base_class.1:
2385 complete_type_name
2386 | TYPENAME_KEYWORD nested_name_specifier identifier
2387 { $$ = TYPE_MAIN_DECL (make_typename_type ($2, $3)); }
2388 | TYPENAME_KEYWORD global_scope nested_name_specifier identifier
2389 { $$ = TYPE_MAIN_DECL (make_typename_type ($3, $4)); }
2390 | SIGOF '(' expr ')'
2392 if (current_aggr == signature_type_node)
2394 if (IS_AGGR_TYPE (TREE_TYPE ($3)))
2396 sorry ("`sigof' as base signature specifier");
2397 $$ = TREE_TYPE ($3);
2399 else
2401 error ("`sigof' applied to non-aggregate expression");
2402 $$ = error_mark_node;
2405 else
2407 error ("`sigof' in struct or class declaration");
2408 $$ = error_mark_node;
2411 | SIGOF '(' type_id ')'
2413 if (current_aggr == signature_type_node)
2415 if (IS_AGGR_TYPE (groktypename ($3.t)))
2417 sorry ("`sigof' as base signature specifier");
2418 $$ = groktypename ($3.t);
2420 else
2422 error ("`sigof' applied to non-aggregate expression");
2423 $$ = error_mark_node;
2426 else
2428 error ("`sigof' in struct or class declaration");
2429 $$ = error_mark_node;
2434 base_class_access_list:
2435 VISSPEC see_typename
2436 | SCSPEC see_typename
2437 { if ($<ttype>$ != ridpointers[(int)RID_VIRTUAL])
2438 sorry ("non-virtual access");
2439 $$ = access_default_virtual_node; }
2440 | base_class_access_list VISSPEC see_typename
2441 { int err = 0;
2442 if ($2 == access_protected_node)
2444 warning ("`protected' access not implemented");
2445 $2 = access_public_node;
2446 err++;
2448 else if ($2 == access_public_node)
2450 if ($1 == access_private_node)
2452 mixed:
2453 error ("base class cannot be public and private");
2455 else if ($1 == access_default_virtual_node)
2456 $$ = access_public_virtual_node;
2458 else /* $2 == access_private_node */
2460 if ($1 == access_public_node)
2461 goto mixed;
2462 else if ($1 == access_default_virtual_node)
2463 $$ = access_private_virtual_node;
2466 | base_class_access_list SCSPEC see_typename
2467 { if ($2 != ridpointers[(int)RID_VIRTUAL])
2468 sorry ("non-virtual access");
2469 if ($$ == access_public_node)
2470 $$ = access_public_virtual_node;
2471 else if ($$ == access_private_node)
2472 $$ = access_private_virtual_node; }
2475 left_curly:
2477 { tree t = $<ttype>0;
2478 push_obstacks_nochange ();
2479 end_temporary_allocation ();
2481 if (t == error_mark_node
2482 || ! IS_AGGR_TYPE (t))
2484 t = $<ttype>0 = make_lang_type (RECORD_TYPE);
2485 pushtag (make_anon_name (), t, 0);
2487 if (TYPE_SIZE (t))
2488 duplicate_tag_error (t);
2489 if (TYPE_SIZE (t) || TYPE_BEING_DEFINED (t))
2491 t = make_lang_type (TREE_CODE (t));
2492 pushtag (TYPE_IDENTIFIER ($<ttype>0), t, 0);
2493 $<ttype>0 = t;
2495 if (processing_template_decl && TYPE_CONTEXT (t)
2496 && ! current_class_type)
2497 push_template_decl (TYPE_STUB_DECL (t));
2498 pushclass (t, 0);
2499 TYPE_BEING_DEFINED (t) = 1;
2500 if (IS_AGGR_TYPE (t) && CLASSTYPE_USE_TEMPLATE (t))
2502 if (CLASSTYPE_IMPLICIT_INSTANTIATION (t)
2503 && TYPE_SIZE (t) == NULL_TREE)
2505 SET_CLASSTYPE_TEMPLATE_SPECIALIZATION (t);
2506 if (processing_template_decl)
2507 push_template_decl (TYPE_MAIN_DECL (t));
2509 else if (CLASSTYPE_TEMPLATE_INSTANTIATION (t))
2510 cp_error ("specialization after instantiation of `%T'", t);
2512 /* Reset the interface data, at the earliest possible
2513 moment, as it might have been set via a class foo;
2514 before. */
2515 /* Don't change signatures. */
2516 if (! IS_SIGNATURE (t))
2518 extern tree pending_vtables;
2519 int needs_writing;
2520 tree name = TYPE_IDENTIFIER (t);
2522 if (! ANON_AGGRNAME_P (name))
2524 CLASSTYPE_INTERFACE_ONLY (t) = interface_only;
2525 SET_CLASSTYPE_INTERFACE_UNKNOWN_X
2526 (t, interface_unknown);
2529 /* Record how to set the access of this class's
2530 virtual functions. If write_virtuals == 2 or 3, then
2531 inline virtuals are ``extern inline''. */
2532 switch (write_virtuals)
2534 case 0:
2535 case 1:
2536 needs_writing = 1;
2537 break;
2538 case 2:
2539 needs_writing = !! value_member (name, pending_vtables);
2540 break;
2541 case 3:
2542 needs_writing = ! CLASSTYPE_INTERFACE_ONLY (t)
2543 && CLASSTYPE_INTERFACE_KNOWN (t);
2544 break;
2545 default:
2546 needs_writing = 0;
2548 CLASSTYPE_VTABLE_NEEDS_WRITING (t) = needs_writing;
2550 #if 0
2551 t = TYPE_IDENTIFIER ($<ttype>0);
2552 if (t && IDENTIFIER_TEMPLATE (t))
2553 overload_template_name (t, 1);
2554 #endif
2558 self_reference:
2559 /* empty */
2561 if (CLASSTYPE_TEMPLATE_INFO (current_class_type))
2562 $$ = NULL_TREE;
2563 else
2564 $$ = build_self_reference ();
2568 opt.component_decl_list:
2569 self_reference
2570 { if ($$) $$ = build_tree_list (access_public_node, $$); }
2571 | self_reference component_decl_list
2573 if (current_aggr == signature_type_node)
2574 $$ = build_tree_list (access_public_node, $2);
2575 else
2576 $$ = build_tree_list (access_default_node, $2);
2577 if ($1) $$ = tree_cons (access_public_node, $1, $$);
2579 | opt.component_decl_list VISSPEC ':' component_decl_list
2581 tree visspec = $2;
2583 if (current_aggr == signature_type_node)
2585 error ("access specifier not allowed in signature");
2586 visspec = access_public_node;
2588 $$ = chainon ($$, build_tree_list (visspec, $4));
2590 | opt.component_decl_list VISSPEC ':'
2592 if (current_aggr == signature_type_node)
2593 error ("access specifier not allowed in signature");
2597 /* Note: we no longer warn about the semicolon after a component_decl_list.
2598 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2599 component_decl_list:
2600 component_decl
2601 { if ($$ == void_type_node) $$ = NULL_TREE;
2603 | component_decl_list component_decl
2604 { /* In pushdecl, we created a reverse list of names
2605 in this binding level. Make sure that the chain
2606 of what we're trying to add isn't the item itself
2607 (which can happen with what pushdecl's doing). */
2608 if ($2 != NULL_TREE && $2 != void_type_node)
2610 if (TREE_CHAIN ($2) != $$)
2611 $$ = chainon ($$, $2);
2612 else
2613 $$ = $2;
2618 component_decl:
2619 component_decl_1 ';'
2621 | component_decl_1 '}'
2622 { error ("missing ';' before right brace");
2623 yyungetc ('}', 0); }
2624 /* C++: handle constructors, destructors and inline functions */
2625 /* note that INLINE is like a TYPESPEC */
2626 | fn.def2 ':' /* base_init compstmt */
2627 { $$ = finish_method ($$); }
2628 | fn.def2 TRY /* base_init compstmt */
2629 { $$ = finish_method ($$); }
2630 | fn.def2 RETURN /* base_init compstmt */
2631 { $$ = finish_method ($$); }
2632 | fn.def2 '{' /* nodecls compstmt */
2633 { $$ = finish_method ($$); }
2634 | ';'
2635 { $$ = NULL_TREE; }
2636 | extension component_decl
2637 { $$ = $2;
2638 pedantic = $<itype>1; }
2641 component_decl_1:
2642 /* Do not add a "typed_declspecs declarator" rule here for
2643 speed; we need to call grok_x_components for enums, so the
2644 speedup would be insignificant. */
2645 typed_declspecs components
2646 { $$ = grok_x_components ($1.t, $2); }
2647 | declmods notype_components
2648 { $$ = grok_x_components ($1, $2); }
2649 | notype_declarator maybeasm maybe_attribute maybe_init
2650 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2651 build_tree_list ($3, NULL_TREE)); }
2652 | constructor_declarator maybeasm maybe_attribute maybe_init
2653 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2654 build_tree_list ($3, NULL_TREE)); }
2655 | ':' expr_no_commas
2656 { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
2657 | error
2658 { $$ = NULL_TREE; }
2660 /* These rules introduce a reduce/reduce conflict; in
2661 typedef int foo, bar;
2662 class A {
2663 foo (bar);
2665 should "A::foo" be declared as a function or "A::bar" as a data
2666 member? In other words, is "bar" an after_type_declarator or a
2667 parmlist? */
2668 | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2669 { tree specs, attrs;
2670 split_specs_attrs ($1, &specs, &attrs);
2671 $$ = grokfield ($2, specs, $5, $3,
2672 build_tree_list ($4, attrs)); }
2673 | component_constructor_declarator maybeasm maybe_attribute maybe_init
2674 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2675 build_tree_list ($3, NULL_TREE)); }
2676 | using_decl
2677 { $$ = do_class_using_decl ($1); }
2680 /* The case of exactly one component is handled directly by component_decl. */
2681 /* ??? Huh? ^^^ */
2682 components:
2683 /* empty: possibly anonymous */
2684 { $$ = NULL_TREE; }
2685 | component_declarator0
2686 | components ',' component_declarator
2688 /* In this context, void_type_node encodes
2689 friends. They have been recorded elsewhere. */
2690 if ($$ == void_type_node)
2691 $$ = $3;
2692 else
2693 $$ = chainon ($$, $3);
2697 notype_components:
2698 /* empty: possibly anonymous */
2699 { $$ = NULL_TREE; }
2700 | notype_component_declarator0
2701 | notype_components ',' notype_component_declarator
2703 /* In this context, void_type_node encodes
2704 friends. They have been recorded elsewhere. */
2705 if ($$ == void_type_node)
2706 $$ = $3;
2707 else
2708 $$ = chainon ($$, $3);
2712 component_declarator0:
2713 after_type_component_declarator0
2714 | notype_component_declarator0
2717 component_declarator:
2718 after_type_component_declarator
2719 | notype_component_declarator
2722 after_type_component_declarator0:
2723 after_type_declarator maybeasm maybe_attribute maybe_init
2724 { split_specs_attrs ($<ttype>0, &current_declspecs,
2725 &prefix_attributes);
2726 $<ttype>0 = current_declspecs;
2727 $$ = grokfield ($$, current_declspecs, $4, $2,
2728 build_tree_list ($3, prefix_attributes)); }
2729 | TYPENAME ':' expr_no_commas maybe_attribute
2730 { split_specs_attrs ($<ttype>0, &current_declspecs,
2731 &prefix_attributes);
2732 $<ttype>0 = current_declspecs;
2733 $$ = grokbitfield ($$, current_declspecs, $3);
2734 cplus_decl_attributes ($$, $4, prefix_attributes); }
2737 notype_component_declarator0:
2738 notype_declarator maybeasm maybe_attribute maybe_init
2739 { split_specs_attrs ($<ttype>0, &current_declspecs,
2740 &prefix_attributes);
2741 $<ttype>0 = current_declspecs;
2742 $$ = grokfield ($$, current_declspecs, $4, $2,
2743 build_tree_list ($3, prefix_attributes)); }
2744 | constructor_declarator maybeasm maybe_attribute maybe_init
2745 { split_specs_attrs ($<ttype>0, &current_declspecs,
2746 &prefix_attributes);
2747 $<ttype>0 = current_declspecs;
2748 $$ = grokfield ($$, current_declspecs, $4, $2,
2749 build_tree_list ($3, prefix_attributes)); }
2750 | IDENTIFIER ':' expr_no_commas maybe_attribute
2751 { split_specs_attrs ($<ttype>0, &current_declspecs,
2752 &prefix_attributes);
2753 $<ttype>0 = current_declspecs;
2754 $$ = grokbitfield ($$, current_declspecs, $3);
2755 cplus_decl_attributes ($$, $4, prefix_attributes); }
2756 | ':' expr_no_commas maybe_attribute
2757 { split_specs_attrs ($<ttype>0, &current_declspecs,
2758 &prefix_attributes);
2759 $<ttype>0 = current_declspecs;
2760 $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2761 cplus_decl_attributes ($$, $3, prefix_attributes); }
2764 after_type_component_declarator:
2765 after_type_declarator maybeasm maybe_attribute maybe_init
2766 { $$ = grokfield ($$, current_declspecs, $4, $2,
2767 build_tree_list ($3, prefix_attributes)); }
2768 | TYPENAME ':' expr_no_commas maybe_attribute
2769 { $$ = grokbitfield ($$, current_declspecs, $3);
2770 cplus_decl_attributes ($$, $4, prefix_attributes); }
2773 notype_component_declarator:
2774 notype_declarator maybeasm maybe_attribute maybe_init
2775 { $$ = grokfield ($$, current_declspecs, $4, $2,
2776 build_tree_list ($3, prefix_attributes)); }
2777 | IDENTIFIER ':' expr_no_commas maybe_attribute
2778 { $$ = grokbitfield ($$, current_declspecs, $3);
2779 cplus_decl_attributes ($$, $4, prefix_attributes); }
2780 | ':' expr_no_commas maybe_attribute
2781 { $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2782 cplus_decl_attributes ($$, $3, prefix_attributes); }
2785 /* We chain the enumerators in reverse order.
2786 Because of the way enums are built, the order is
2787 insignificant. Take advantage of this fact. */
2789 enumlist:
2790 enumerator
2791 | enumlist ',' enumerator
2792 { TREE_CHAIN ($3) = $$; $$ = $3; }
2795 enumerator:
2796 identifier
2797 { $$ = build_enumerator ($$, NULL_TREE); }
2798 | identifier '=' expr_no_commas
2799 { $$ = build_enumerator ($$, $3); }
2802 /* ANSI new-type-id (5.3.4) */
2803 new_type_id:
2804 type_specifier_seq new_declarator
2805 { $$.t = build_decl_list ($1.t, $2);
2806 $$.new_type_flag = $1.new_type_flag; }
2807 | type_specifier_seq %prec EMPTY
2808 { $$.t = build_decl_list ($1.t, NULL_TREE);
2809 $$.new_type_flag = $1.new_type_flag; }
2810 /* GNU extension to allow arrays of arbitrary types with
2811 non-constant dimension. */
2812 | '(' type_id ')' '[' expr ']'
2814 if (pedantic)
2815 pedwarn ("ANSI C++ forbids array dimensions with parenthesized type in new");
2816 $$.t = build_parse_node (ARRAY_REF, TREE_VALUE ($2.t), $5);
2817 $$.t = build_decl_list (TREE_PURPOSE ($2.t), $$.t);
2818 $$.new_type_flag = $2.new_type_flag;
2822 cv_qualifiers:
2823 /* empty */ %prec EMPTY
2824 { $$ = NULL_TREE; }
2825 | cv_qualifiers CV_QUALIFIER
2826 { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
2829 nonempty_cv_qualifiers:
2830 CV_QUALIFIER
2831 { $$.t = IDENTIFIER_AS_LIST ($1);
2832 $$.new_type_flag = 0; }
2833 | nonempty_cv_qualifiers CV_QUALIFIER
2834 { $$.t = decl_tree_cons (NULL_TREE, $2, $1.t);
2835 $$.new_type_flag = $1.new_type_flag; }
2838 /* These rules must follow the rules for function declarations
2839 and component declarations. That way, longer rules are preferred. */
2841 suspend_mom:
2842 /* empty */
2843 { $<itype>$ = suspend_momentary (); }
2845 /* An expression which will not live on the momentary obstack. */
2846 nonmomentary_expr:
2847 suspend_mom expr
2848 { resume_momentary ((int) $<itype>1); $$ = $2; }
2851 /* An expression which will not live on the momentary obstack. */
2852 maybe_parmlist:
2853 suspend_mom '(' nonnull_exprlist ')'
2854 { resume_momentary ((int) $<itype>1); $$ = $3; }
2855 | suspend_mom '(' parmlist ')'
2856 { resume_momentary ((int) $<itype>1); $$ = $3; }
2857 | suspend_mom LEFT_RIGHT
2858 { resume_momentary ((int) $<itype>1); $$ = empty_parms (); }
2859 | suspend_mom '(' error ')'
2860 { resume_momentary ((int) $<itype>1); $$ = NULL_TREE; }
2863 /* A declarator that is allowed only after an explicit typespec. */
2864 /* may all be followed by prec '.' */
2865 after_type_declarator:
2866 '*' nonempty_cv_qualifiers after_type_declarator %prec UNARY
2867 { $$ = make_pointer_declarator ($2.t, $3); }
2868 | '&' nonempty_cv_qualifiers after_type_declarator %prec UNARY
2869 { $$ = make_reference_declarator ($2.t, $3); }
2870 | '*' after_type_declarator %prec UNARY
2871 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2872 | '&' after_type_declarator %prec UNARY
2873 { $$ = make_reference_declarator (NULL_TREE, $2); }
2874 | ptr_to_mem cv_qualifiers after_type_declarator
2875 { tree arg = make_pointer_declarator ($2, $3);
2876 $$ = build_parse_node (SCOPE_REF, $1, arg);
2878 | direct_after_type_declarator
2881 complete_type_name:
2882 type_name %prec EMPTY
2884 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2886 if (current_class_type
2887 && TYPE_BEING_DEFINED (current_class_type)
2888 && ! IDENTIFIER_CLASS_VALUE ($1))
2890 /* Be sure to get an inherited typedef. */
2891 $$ = lookup_name ($1, 1);
2892 /* Remember that this name has been used in the class
2893 definition, as per [class.scope0] */
2894 pushdecl_class_level ($$);
2896 else
2897 $$ = identifier_typedecl_value ($1);
2899 else
2900 $$ = $1;
2902 | global_scope type_name
2904 if (TREE_CODE ($2) == IDENTIFIER_NODE)
2905 $$ = identifier_typedecl_value ($2);
2906 else
2907 $$ = $2;
2908 got_scope = NULL_TREE;
2910 | nested_type
2911 | global_scope nested_type
2912 { $$ = $2; }
2915 nested_type:
2916 nested_name_specifier type_name %prec EMPTY
2917 { $$ = get_type_decl ($2); }
2920 direct_after_type_declarator:
2921 direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2922 { $$ = make_call_declarator ($$, $2, $3, $4); }
2923 | direct_after_type_declarator '[' nonmomentary_expr ']'
2924 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2925 | direct_after_type_declarator '[' ']'
2926 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2927 | '(' after_type_declarator ')'
2928 { $$ = $2; }
2929 | nested_name_specifier type_name %prec EMPTY
2930 { push_nested_class ($1, 3);
2931 $$ = build_parse_node (SCOPE_REF, $$, $2);
2932 TREE_COMPLEXITY ($$) = current_class_depth; }
2933 | type_name %prec EMPTY
2936 /* A declarator allowed whether or not there has been
2937 an explicit typespec. These cannot redeclare a typedef-name. */
2939 notype_declarator:
2940 '*' nonempty_cv_qualifiers notype_declarator %prec UNARY
2941 { $$ = make_pointer_declarator ($2.t, $3); }
2942 | '&' nonempty_cv_qualifiers notype_declarator %prec UNARY
2943 { $$ = make_reference_declarator ($2.t, $3); }
2944 | '*' notype_declarator %prec UNARY
2945 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2946 | '&' notype_declarator %prec UNARY
2947 { $$ = make_reference_declarator (NULL_TREE, $2); }
2948 | ptr_to_mem cv_qualifiers notype_declarator
2949 { tree arg = make_pointer_declarator ($2, $3);
2950 $$ = build_parse_node (SCOPE_REF, $1, arg);
2952 | direct_notype_declarator
2955 complex_notype_declarator:
2956 '*' nonempty_cv_qualifiers notype_declarator %prec UNARY
2957 { $$ = make_pointer_declarator ($2.t, $3); }
2958 | '&' nonempty_cv_qualifiers notype_declarator %prec UNARY
2959 { $$ = make_reference_declarator ($2.t, $3); }
2960 | '*' complex_notype_declarator %prec UNARY
2961 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2962 | '&' complex_notype_declarator %prec UNARY
2963 { $$ = make_reference_declarator (NULL_TREE, $2); }
2964 | ptr_to_mem cv_qualifiers notype_declarator
2965 { tree arg = make_pointer_declarator ($2, $3);
2966 $$ = build_parse_node (SCOPE_REF, $1, arg);
2968 | complex_direct_notype_declarator
2971 complex_direct_notype_declarator:
2972 direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2973 { $$ = make_call_declarator ($$, $2, $3, $4); }
2974 | '(' complex_notype_declarator ')'
2975 { $$ = $2; }
2976 | direct_notype_declarator '[' nonmomentary_expr ']'
2977 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2978 | direct_notype_declarator '[' ']'
2979 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2980 | notype_qualified_id
2981 { if (OP0 ($$) != current_class_type)
2983 push_nested_class (OP0 ($$), 3);
2984 TREE_COMPLEXITY ($$) = current_class_depth;
2989 qualified_id:
2990 nested_name_specifier unqualified_id
2991 { got_scope = NULL_TREE;
2992 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2995 notype_qualified_id:
2996 nested_name_specifier notype_unqualified_id
2997 { got_scope = NULL_TREE;
2998 $$ = build_parse_node (SCOPE_REF, $$, $2); }
3001 overqualified_id:
3002 notype_qualified_id
3003 | global_scope notype_qualified_id
3004 { $$ = $2; }
3007 functional_cast:
3008 typespec '(' nonnull_exprlist ')'
3009 { $$ = build_functional_cast ($1.t, $3); }
3010 | typespec '(' expr_or_declarator ')'
3011 { $$ = reparse_decl_as_expr ($1.t, $3); }
3012 | typespec fcast_or_absdcl %prec EMPTY
3013 { $$ = reparse_absdcl_as_expr ($1.t, $2); }
3016 type_name:
3017 TYPENAME
3018 | SELFNAME
3019 | template_type %prec EMPTY
3022 nested_name_specifier:
3023 nested_name_specifier_1
3024 | nested_name_specifier nested_name_specifier_1
3025 { $$ = $2; }
3028 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
3029 inline here?!? (jason) */
3030 nested_name_specifier_1:
3031 TYPENAME SCOPE
3033 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3035 $$ = lastiddecl;
3036 /* Remember that this name has been used in the class
3037 definition, as per [class.scope0] */
3038 if (current_class_type
3039 && TYPE_BEING_DEFINED (current_class_type)
3040 && ! IDENTIFIER_CLASS_VALUE ($1))
3041 pushdecl_class_level ($$);
3043 got_scope = $$ = TREE_TYPE ($$);
3045 | SELFNAME SCOPE
3047 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3048 $$ = lastiddecl;
3049 got_scope = $$ = TREE_TYPE ($$);
3051 | NSNAME SCOPE
3052 { got_scope = $$ = $1; }
3053 | template_type SCOPE
3054 { got_scope = $$ = complete_type (TREE_TYPE ($1)); }
3055 /* These break 'const i;'
3056 | IDENTIFIER SCOPE
3058 failed_scope:
3059 cp_error ("`%D' is not an aggregate typedef",
3060 lastiddecl ? lastiddecl : $$);
3061 $$ = error_mark_node;
3063 | PTYPENAME SCOPE
3064 { goto failed_scope; } */
3067 complex_type_name:
3068 global_scope type_name
3070 if (TREE_CODE ($2) == IDENTIFIER_NODE)
3071 $$ = identifier_typedecl_value ($2);
3072 else
3073 $$ = $2;
3074 got_scope = NULL_TREE;
3076 | nested_type
3077 | global_scope nested_type
3078 { $$ = $2; }
3081 ptr_to_mem:
3082 nested_name_specifier '*'
3083 { got_scope = NULL_TREE; }
3084 | global_scope nested_name_specifier '*'
3085 { $$ = $2; got_scope = NULL_TREE; }
3088 /* All uses of explicit global scope must go through this nonterminal so
3089 that got_scope will be set before yylex is called to get the next token. */
3090 global_scope:
3091 SCOPE
3092 { got_scope = void_type_node; }
3095 /* ANSI new-declarator (5.3.4) */
3096 new_declarator:
3097 '*' cv_qualifiers new_declarator
3098 { $$ = make_pointer_declarator ($2, $3); }
3099 | '*' cv_qualifiers %prec EMPTY
3100 { $$ = make_pointer_declarator ($2, NULL_TREE); }
3101 | '&' cv_qualifiers new_declarator %prec EMPTY
3102 { $$ = make_reference_declarator ($2, $3); }
3103 | '&' cv_qualifiers %prec EMPTY
3104 { $$ = make_reference_declarator ($2, NULL_TREE); }
3105 | ptr_to_mem cv_qualifiers %prec EMPTY
3106 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3107 $$ = build_parse_node (SCOPE_REF, $1, arg);
3109 | ptr_to_mem cv_qualifiers new_declarator
3110 { tree arg = make_pointer_declarator ($2, $3);
3111 $$ = build_parse_node (SCOPE_REF, $1, arg);
3113 | direct_new_declarator %prec EMPTY
3116 /* ANSI direct-new-declarator (5.3.4) */
3117 direct_new_declarator:
3118 '[' expr ']'
3119 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3120 | direct_new_declarator '[' nonmomentary_expr ']'
3121 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3124 /* ANSI abstract-declarator (8.1) */
3125 absdcl:
3126 '*' nonempty_cv_qualifiers absdcl
3127 { $$ = make_pointer_declarator ($2.t, $3); }
3128 | '*' absdcl
3129 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3130 | '*' nonempty_cv_qualifiers %prec EMPTY
3131 { $$ = make_pointer_declarator ($2.t, NULL_TREE); }
3132 | '*' %prec EMPTY
3133 { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
3134 | '&' nonempty_cv_qualifiers absdcl
3135 { $$ = make_reference_declarator ($2.t, $3); }
3136 | '&' absdcl
3137 { $$ = make_reference_declarator (NULL_TREE, $2); }
3138 | '&' nonempty_cv_qualifiers %prec EMPTY
3139 { $$ = make_reference_declarator ($2.t, NULL_TREE); }
3140 | '&' %prec EMPTY
3141 { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
3142 | ptr_to_mem cv_qualifiers %prec EMPTY
3143 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3144 $$ = build_parse_node (SCOPE_REF, $1, arg);
3146 | ptr_to_mem cv_qualifiers absdcl
3147 { tree arg = make_pointer_declarator ($2, $3);
3148 $$ = build_parse_node (SCOPE_REF, $1, arg);
3150 | direct_abstract_declarator %prec EMPTY
3153 /* ANSI direct-abstract-declarator (8.1) */
3154 direct_abstract_declarator:
3155 '(' absdcl ')'
3156 { $$ = $2; }
3157 /* `(typedef)1' is `int'. */
3158 | PAREN_STAR_PAREN
3159 | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3160 { $$ = make_call_declarator ($$, $3, $5, $6); }
3161 | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
3162 { $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
3163 | direct_abstract_declarator '[' nonmomentary_expr ']' %prec '.'
3164 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3165 | direct_abstract_declarator '[' ']' %prec '.'
3166 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
3167 | '(' complex_parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3168 { $$ = make_call_declarator (NULL_TREE, $2, $4, $5); }
3169 | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3170 { set_quals_and_spec ($$, $2, $3); }
3171 | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3172 { set_quals_and_spec ($$, $2, $3); }
3173 | '[' nonmomentary_expr ']' %prec '.'
3174 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3175 | '[' ']' %prec '.'
3176 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, NULL_TREE); }
3179 /* For C++, decls and stmts can be intermixed, so we don't need to
3180 have a special rule that won't start parsing the stmt section
3181 until we have a stmt that parses without errors. */
3183 stmts:
3184 stmt
3185 | errstmt
3186 | stmts stmt
3187 | stmts errstmt
3190 errstmt:
3191 error ';'
3194 /* build the LET_STMT node before parsing its contents,
3195 so that any LET_STMTs within the context can have their display pointers
3196 set up to point at this one. */
3198 .pushlevel:
3199 /* empty */
3200 { do_pushlevel (); }
3203 .poplevel:
3204 /* empty */
3205 { $$ = do_poplevel (); }
3208 /* Read zero or more forward-declarations for labels
3209 that nested functions can jump to. */
3210 maybe_label_decls:
3211 /* empty */
3212 | label_decls
3213 { if (pedantic)
3214 pedwarn ("ANSI C++ forbids label declarations"); }
3217 label_decls:
3218 label_decl
3219 | label_decls label_decl
3222 label_decl:
3223 LABEL identifiers_or_typenames ';'
3224 { tree link;
3225 for (link = $2; link; link = TREE_CHAIN (link))
3227 tree label = shadow_label (TREE_VALUE (link));
3228 C_DECLARED_LABEL_FLAG (label) = 1;
3229 declare_nonlocal_label (label);
3234 /* This is the body of a function definition.
3235 It causes syntax errors to ignore to the next openbrace. */
3236 compstmt_or_error:
3237 compstmt
3239 | error compstmt
3242 compstmt:
3245 if (processing_template_decl)
3247 $<ttype>$ = build_min_nt (COMPOUND_STMT, NULL_TREE);
3248 add_tree ($<ttype>$);
3251 .pushlevel compstmtend .poplevel
3253 if (processing_template_decl)
3255 TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2);
3256 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3257 last_tree = $<ttype>2;
3259 $$ = $5;
3263 simple_if:
3266 if (processing_template_decl)
3268 $<ttype>$ = build_min_nt (IF_STMT, NULL_TREE, NULL_TREE,
3269 NULL_TREE);
3270 add_tree ($<ttype>$);
3272 cond_stmt_keyword = "if";
3274 .pushlevel paren_cond_or_null
3276 if (processing_template_decl)
3278 if (last_tree != $<ttype>2)
3280 TREE_OPERAND ($<ttype>2, 0) = last_tree;
3281 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3282 last_tree = $<ttype>2;
3284 else
3285 TREE_OPERAND ($<ttype>2, 0) = $4;
3287 else
3289 emit_line_note (input_filename, lineno);
3290 expand_start_cond ($4, 0);
3293 implicitly_scoped_stmt
3295 if (processing_template_decl)
3297 TREE_OPERAND ($<ttype>2, 1) = TREE_CHAIN ($<ttype>2);
3298 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3299 $<ttype>$ = last_tree = $<ttype>2;
3304 implicitly_scoped_stmt:
3305 compstmt
3306 { finish_stmt (); }
3307 | .pushlevel
3309 if (processing_template_decl)
3311 $<ttype>$ = build_min_nt (COMPOUND_STMT, NULL_TREE);
3312 add_tree ($<ttype>$);
3315 simple_stmt .poplevel
3317 if (processing_template_decl)
3319 TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2);
3320 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3321 last_tree = $<ttype>2;
3323 $$ = $4;
3327 stmt:
3328 compstmt
3329 { finish_stmt (); }
3330 | simple_stmt
3333 simple_stmt:
3334 decl
3335 { finish_stmt (); }
3336 | expr ';'
3338 tree expr = $1;
3339 if (! processing_template_decl)
3341 emit_line_note (input_filename, lineno);
3342 /* Do default conversion if safe and possibly important,
3343 in case within ({...}). */
3344 if ((TREE_CODE (TREE_TYPE (expr)) == ARRAY_TYPE
3345 && lvalue_p (expr))
3346 || TREE_CODE (TREE_TYPE (expr)) == FUNCTION_TYPE)
3347 expr = default_conversion (expr);
3349 cplus_expand_expr_stmt (expr);
3350 clear_momentary ();
3351 finish_stmt (); }
3352 | simple_if ELSE
3353 { if (! processing_template_decl) expand_start_else (); }
3354 implicitly_scoped_stmt
3356 if (processing_template_decl)
3358 TREE_OPERAND ($<ttype>1, 2) = TREE_CHAIN ($<ttype>1);
3359 TREE_CHAIN ($<ttype>1) = NULL_TREE;
3360 last_tree = $<ttype>1;
3362 else
3363 expand_end_cond ();
3365 .poplevel
3366 { finish_stmt (); }
3367 | simple_if %prec IF
3368 { if (! processing_template_decl) expand_end_cond ();
3369 do_poplevel ();
3370 finish_stmt (); }
3371 | WHILE
3373 if (processing_template_decl)
3375 $<ttype>$ = build_min_nt (WHILE_STMT, NULL_TREE, NULL_TREE);
3376 add_tree ($<ttype>$);
3378 else
3380 emit_nop ();
3381 emit_line_note (input_filename, lineno);
3382 expand_start_loop (1);
3384 cond_stmt_keyword = "while";
3386 .pushlevel paren_cond_or_null
3388 if (processing_template_decl)
3390 if (last_tree != $<ttype>2)
3392 TREE_OPERAND ($<ttype>2, 0) = last_tree;
3393 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3394 last_tree = $<ttype>2;
3396 else
3397 TREE_OPERAND ($<ttype>2, 0) = $4;
3399 else
3401 emit_line_note (input_filename, lineno);
3402 expand_exit_loop_if_false (0, $4);
3405 already_scoped_stmt .poplevel
3407 if (processing_template_decl)
3409 TREE_OPERAND ($<ttype>2, 1) = TREE_CHAIN ($<ttype>2);
3410 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3411 last_tree = $<ttype>2;
3413 else
3414 expand_end_loop ();
3415 finish_stmt ();
3417 | DO
3419 if (processing_template_decl)
3421 $<ttype>$ = build_min_nt (DO_STMT, NULL_TREE, NULL_TREE);
3422 add_tree ($<ttype>$);
3424 else
3426 emit_nop ();
3427 emit_line_note (input_filename, lineno);
3428 expand_start_loop_continue_elsewhere (1);
3431 implicitly_scoped_stmt WHILE
3433 if (processing_template_decl)
3435 TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2);
3436 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3437 last_tree = $<ttype>2;
3439 else
3441 expand_loop_continue_here ();
3442 cond_stmt_keyword = "do";
3445 paren_expr_or_null ';'
3447 if (processing_template_decl)
3448 TREE_OPERAND ($<ttype>2, 1) = $6;
3449 else
3451 emit_line_note (input_filename, lineno);
3452 expand_exit_loop_if_false (0, $6);
3453 expand_end_loop ();
3455 clear_momentary ();
3456 finish_stmt ();
3458 | FOR
3459 { if (processing_template_decl)
3461 $<ttype>$ = build_min_nt (FOR_STMT, NULL_TREE, NULL_TREE,
3462 NULL_TREE, NULL_TREE);
3463 add_tree ($<ttype>$);
3465 else
3466 emit_line_note (input_filename, lineno);
3467 if (flag_new_for_scope > 0)
3469 /* Conditionalize .pushlevel */
3470 pushlevel (0);
3471 note_level_for_for ();
3472 clear_last_expr ();
3473 push_momentary ();
3474 expand_start_bindings (0);
3477 '(' for.init.statement
3479 if (processing_template_decl)
3481 if (last_tree != $<ttype>2)
3483 TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2);
3484 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3485 last_tree = $<ttype>2;
3488 else
3490 emit_nop ();
3491 emit_line_note (input_filename, lineno);
3492 expand_start_loop_continue_elsewhere (1);
3495 .pushlevel xcond ';'
3497 if (processing_template_decl)
3499 if (last_tree != $<ttype>2)
3501 TREE_OPERAND ($<ttype>2, 1) = last_tree;
3502 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3503 last_tree = $<ttype>2;
3505 else
3506 TREE_OPERAND ($<ttype>2, 1) = $7;
3508 else
3510 emit_line_note (input_filename, lineno);
3511 if ($7) expand_exit_loop_if_false (0, $7);
3514 xexpr ')'
3515 /* Don't let the tree nodes for $10 be discarded
3516 by clear_momentary during the parsing of the next stmt. */
3518 if (processing_template_decl)
3519 TREE_OPERAND ($<ttype>2, 2) = $10;
3520 push_momentary ();
3522 already_scoped_stmt .poplevel
3524 if (processing_template_decl)
3526 TREE_OPERAND ($<ttype>2, 3) = TREE_CHAIN ($<ttype>2);
3527 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3528 last_tree = $<ttype>2;
3530 else
3532 emit_line_note (input_filename, lineno);
3533 expand_loop_continue_here ();
3534 if ($10) cplus_expand_expr_stmt ($10);
3535 expand_end_loop ();
3537 pop_momentary ();
3538 if (flag_new_for_scope > 0)
3540 do_poplevel ();
3542 finish_stmt (); }
3543 | SWITCH .pushlevel '(' condition ')'
3545 if (processing_template_decl)
3547 $<ttype>$ = build_min_nt (SWITCH_STMT, $4, NULL_TREE);
3548 add_tree ($<ttype>$);
3550 else
3552 emit_line_note (input_filename, lineno);
3553 c_expand_start_case ($4);
3555 push_switch ();
3556 /* Don't let the tree nodes for $4 be discarded by
3557 clear_momentary during the parsing of the next stmt. */
3558 push_momentary ();
3560 implicitly_scoped_stmt
3562 if (processing_template_decl)
3564 TREE_OPERAND ($<ttype>6, 1) = TREE_CHAIN ($<ttype>6);
3565 TREE_CHAIN ($<ttype>6) = NULL_TREE;
3566 last_tree = $<ttype>6;
3568 else
3569 expand_end_case ($4);
3570 pop_momentary ();
3571 pop_switch ();
3573 .poplevel
3574 { finish_stmt (); }
3575 | CASE expr_no_commas ':'
3576 { do_case ($2, NULL_TREE); }
3577 stmt
3578 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
3579 { do_case ($2, $4); }
3580 stmt
3581 | DEFAULT ':'
3582 { do_case (NULL_TREE, NULL_TREE); }
3583 stmt
3584 | BREAK ';'
3585 { emit_line_note (input_filename, lineno);
3586 if (processing_template_decl)
3587 add_tree (build_min_nt (BREAK_STMT));
3588 else if ( ! expand_exit_something ())
3589 error ("break statement not within loop or switch"); }
3590 | CONTINUE ';'
3591 { emit_line_note (input_filename, lineno);
3592 if (processing_template_decl)
3593 add_tree (build_min_nt (CONTINUE_STMT));
3594 else if (! expand_continue_loop (0))
3595 error ("continue statement not within a loop"); }
3596 | RETURN ';'
3597 { emit_line_note (input_filename, lineno);
3598 c_expand_return (NULL_TREE); }
3599 | RETURN expr ';'
3600 { emit_line_note (input_filename, lineno);
3601 c_expand_return ($2);
3602 finish_stmt ();
3604 | asm_keyword maybe_cv_qualifier '(' string ')' ';'
3605 { if (TREE_CHAIN ($4)) $4 = combine_strings ($4);
3606 emit_line_note (input_filename, lineno);
3607 expand_asm ($4);
3608 finish_stmt ();
3610 /* This is the case with just output operands. */
3611 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ')' ';'
3612 { if (TREE_CHAIN ($4)) $4 = combine_strings ($4);
3613 emit_line_note (input_filename, lineno);
3614 c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
3615 $2 == ridpointers[(int)RID_VOLATILE],
3616 input_filename, lineno);
3617 finish_stmt ();
3619 /* This is the case with input operands as well. */
3620 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':' asm_operands ')' ';'
3621 { if (TREE_CHAIN ($4)) $4 = combine_strings ($4);
3622 emit_line_note (input_filename, lineno);
3623 c_expand_asm_operands ($4, $6, $8, NULL_TREE,
3624 $2 == ridpointers[(int)RID_VOLATILE],
3625 input_filename, lineno);
3626 finish_stmt ();
3628 /* This is the case with clobbered registers as well. */
3629 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':'
3630 asm_operands ':' asm_clobbers ')' ';'
3631 { if (TREE_CHAIN ($4)) $4 = combine_strings ($4);
3632 emit_line_note (input_filename, lineno);
3633 c_expand_asm_operands ($4, $6, $8, $10,
3634 $2 == ridpointers[(int)RID_VOLATILE],
3635 input_filename, lineno);
3636 finish_stmt ();
3638 | GOTO '*' expr ';'
3640 if (processing_template_decl)
3641 add_tree (build_min_nt (GOTO_STMT, $3));
3642 else
3643 { emit_line_note (input_filename, lineno);
3644 expand_computed_goto ($3); }
3646 | GOTO identifier ';'
3648 if (processing_template_decl)
3649 add_tree (build_min_nt (GOTO_STMT, $2));
3650 else
3652 tree decl;
3653 emit_line_note (input_filename, lineno);
3654 decl = lookup_label ($2);
3655 TREE_USED (decl) = 1;
3656 expand_goto (decl);
3659 | label_colon stmt
3660 { finish_stmt (); }
3661 | label_colon '}'
3662 { error ("label must be followed by statement");
3663 yyungetc ('}', 0);
3664 finish_stmt (); }
3665 | ';'
3666 { finish_stmt (); }
3667 | try_block
3670 function_try_block:
3673 if (! current_function_parms_stored)
3674 store_parm_decls ();
3675 expand_start_early_try_stmts ();
3677 ctor_initializer_opt compstmt_or_error
3678 { expand_start_all_catch (); }
3679 handler_seq
3681 int nested = (hack_decl_function_context
3682 (current_function_decl) != NULL_TREE);
3683 expand_end_all_catch ();
3684 finish_function (lineno, (int)$3, nested);
3688 try_block:
3691 if (processing_template_decl)
3693 $<ttype>$ = build_min_nt (TRY_BLOCK, NULL_TREE,
3694 NULL_TREE);
3695 add_tree ($<ttype>$);
3697 else
3699 emit_line_note (input_filename, lineno);
3700 expand_start_try_stmts ();
3703 compstmt
3705 if (processing_template_decl)
3707 TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2);
3708 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3709 last_tree = $<ttype>2;
3711 else
3712 expand_start_all_catch ();
3714 handler_seq
3716 if (processing_template_decl)
3718 TREE_OPERAND ($<ttype>2, 1) = TREE_CHAIN ($<ttype>2);
3719 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3720 last_tree = $<ttype>2;
3722 else
3723 expand_end_all_catch ();
3727 handler_seq:
3728 handler
3729 | handler_seq handler
3732 handler:
3733 CATCH
3735 if (processing_template_decl)
3737 $<ttype>$ = build_min_nt (HANDLER, NULL_TREE,
3738 NULL_TREE);
3739 add_tree ($<ttype>$);
3742 .pushlevel handler_args
3744 if (processing_template_decl)
3746 TREE_OPERAND ($<ttype>2, 0) = TREE_CHAIN ($<ttype>2);
3747 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3748 last_tree = $<ttype>2;
3751 compstmt
3753 if (processing_template_decl)
3755 TREE_OPERAND ($<ttype>2, 1) = TREE_CHAIN ($<ttype>2);
3756 TREE_CHAIN ($<ttype>2) = NULL_TREE;
3757 last_tree = $<ttype>2;
3759 else
3760 expand_end_catch_block ();
3762 .poplevel
3765 type_specifier_seq:
3766 typed_typespecs %prec EMPTY
3767 | nonempty_cv_qualifiers %prec EMPTY
3770 handler_args:
3771 '(' ELLIPSIS ')'
3772 { expand_start_catch_block (NULL_TREE, NULL_TREE); }
3773 /* This doesn't allow reference parameters, the below does.
3774 | '(' type_specifier_seq absdcl ')'
3775 { check_for_new_type ("inside exception declarations", $2);
3776 expand_start_catch_block ($2.t, $3); }
3777 | '(' type_specifier_seq ')'
3778 { check_for_new_type ("inside exception declarations", $2);
3779 expand_start_catch_block ($2.t, NULL_TREE); }
3780 | '(' type_specifier_seq notype_declarator ')'
3781 { check_for_new_type ("inside exception declarations", $2);
3782 expand_start_catch_block ($2.t, $3); }
3783 | '(' typed_typespecs after_type_declarator ')'
3784 { check_for_new_type ("inside exception declarations", $2);
3785 expand_start_catch_block ($2.t, $3); }
3786 This allows reference parameters... */
3787 | '(' parm ')'
3788 { check_for_new_type ("inside exception declarations", $2);
3789 expand_start_catch_block (TREE_PURPOSE ($2.t),
3790 TREE_VALUE ($2.t)); }
3793 label_colon:
3794 IDENTIFIER ':'
3795 { tree label;
3796 do_label:
3797 label = define_label (input_filename, lineno, $1);
3798 if (label && ! minimal_parse_mode)
3799 expand_label (label);
3801 | PTYPENAME ':'
3802 { goto do_label; }
3803 | TYPENAME ':'
3804 { goto do_label; }
3805 | SELFNAME ':'
3806 { goto do_label; }
3809 for.init.statement:
3810 xexpr ';'
3811 { if ($1) cplus_expand_expr_stmt ($1); }
3812 | decl
3813 | '{' compstmtend
3814 { if (pedantic)
3815 pedwarn ("ANSI C++ forbids compound statements inside for initializations");
3819 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
3821 maybe_cv_qualifier:
3822 /* empty */
3823 { emit_line_note (input_filename, lineno);
3824 $$ = NULL_TREE; }
3825 | CV_QUALIFIER
3826 { emit_line_note (input_filename, lineno); }
3829 xexpr:
3830 /* empty */
3831 { $$ = NULL_TREE; }
3832 | expr
3833 | error
3834 { $$ = NULL_TREE; }
3837 /* These are the operands other than the first string and colon
3838 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
3839 asm_operands:
3840 /* empty */
3841 { $$ = NULL_TREE; }
3842 | nonnull_asm_operands
3845 nonnull_asm_operands:
3846 asm_operand
3847 | nonnull_asm_operands ',' asm_operand
3848 { $$ = chainon ($$, $3); }
3851 asm_operand:
3852 STRING '(' expr ')'
3853 { $$ = build_tree_list ($$, $3); }
3856 asm_clobbers:
3857 STRING
3858 { $$ = tree_cons (NULL_TREE, $$, NULL_TREE); }
3859 | asm_clobbers ',' STRING
3860 { $$ = tree_cons (NULL_TREE, $3, $$); }
3863 /* This is what appears inside the parens in a function declarator.
3864 Its value is represented in the format that grokdeclarator expects.
3866 In C++, declaring a function with no parameters
3867 means that that function takes *no* parameters. */
3869 parmlist:
3870 /* empty */
3872 $$ = empty_parms();
3874 | complex_parmlist
3875 | type_id
3876 { $$ = tree_cons (NULL_TREE, $1.t, void_list_node);
3877 TREE_PARMLIST ($$) = 1;
3878 check_for_new_type ("inside parameter list", $1); }
3881 /* This nonterminal does not include the common sequence '(' type_id ')',
3882 as it is ambiguous and must be disambiguated elsewhere. */
3883 complex_parmlist:
3884 parms
3886 $$ = chainon ($$, void_list_node);
3887 TREE_PARMLIST ($$) = 1;
3889 | parms_comma ELLIPSIS
3891 TREE_PARMLIST ($$) = 1;
3893 /* C++ allows an ellipsis without a separating ',' */
3894 | parms ELLIPSIS
3896 TREE_PARMLIST ($$) = 1;
3898 | type_id ELLIPSIS
3900 $$ = build_tree_list (NULL_TREE, $1.t);
3901 TREE_PARMLIST ($$) = 1;
3903 | ELLIPSIS
3905 $$ = NULL_TREE;
3907 | TYPENAME_ELLIPSIS
3909 TREE_PARMLIST ($$) = 1;
3911 | parms TYPENAME_ELLIPSIS
3913 TREE_PARMLIST ($$) = 1;
3915 | type_id TYPENAME_ELLIPSIS
3917 $$ = build_tree_list (NULL_TREE, $1.t);
3918 TREE_PARMLIST ($$) = 1;
3920 | parms ':'
3922 /* This helps us recover from really nasty
3923 parse errors, for example, a missing right
3924 parenthesis. */
3925 yyerror ("possibly missing ')'");
3926 $$ = chainon ($$, void_list_node);
3927 TREE_PARMLIST ($$) = 1;
3928 yyungetc (':', 0);
3929 yychar = ')';
3931 | type_id ':'
3933 /* This helps us recover from really nasty
3934 parse errors, for example, a missing right
3935 parenthesis. */
3936 yyerror ("possibly missing ')'");
3937 $$ = tree_cons (NULL_TREE, $1.t, void_list_node);
3938 TREE_PARMLIST ($$) = 1;
3939 yyungetc (':', 0);
3940 yychar = ')';
3944 /* A nonempty list of parameter declarations or type names. */
3945 parms:
3946 named_parm
3947 { check_for_new_type ("in a parameter list", $1);
3948 $$ = build_tree_list (NULL_TREE, $1.t); }
3949 | parm '=' init
3950 { check_for_new_type ("in a parameter list", $1);
3951 $$ = build_tree_list ($3, $1.t); }
3952 | parms_comma full_parm
3953 { check_for_new_type ("in a parameter list", $2);
3954 $$ = chainon ($$, $2.t); }
3955 | parms_comma bad_parm
3956 { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
3957 | parms_comma bad_parm '=' init
3958 { $$ = chainon ($$, build_tree_list ($4, $2)); }
3961 parms_comma:
3962 parms ','
3963 | type_id ','
3964 { check_for_new_type ("in a parameter list", $1);
3965 $$ = build_tree_list (NULL_TREE, $1.t); }
3968 /* A single parameter declaration or parameter type name,
3969 as found in a parmlist. */
3970 named_parm:
3971 /* Here we expand typed_declspecs inline to avoid mis-parsing of
3972 TYPESPEC IDENTIFIER. */
3973 typed_declspecs1 declarator
3974 { tree specs = strip_attrs ($1.t);
3975 $$.new_type_flag = $1.new_type_flag;
3976 $$.t = build_tree_list (specs, $2); }
3977 | typed_typespecs declarator
3978 { $$.t = build_tree_list ($1.t, $2);
3979 $$.new_type_flag = $1.new_type_flag; }
3980 | typespec declarator
3981 { $$.t = build_tree_list (get_decl_list ($1.t), $2);
3982 $$.new_type_flag = $1.new_type_flag; }
3983 | typed_declspecs1 absdcl
3984 { tree specs = strip_attrs ($1.t);
3985 $$.t = build_tree_list (specs, $2);
3986 $$.new_type_flag = $1.new_type_flag; }
3987 | typed_declspecs1 %prec EMPTY
3988 { tree specs = strip_attrs ($1.t);
3989 $$.t = build_tree_list (specs, NULL_TREE);
3990 $$.new_type_flag = $1.new_type_flag; }
3991 | declmods notype_declarator
3992 { tree specs = strip_attrs ($1);
3993 $$.t = build_tree_list (specs, $2);
3994 $$.new_type_flag = 0; }
3997 full_parm:
3998 parm maybe_init
3999 { $$.t = build_tree_list ($2, $1.t);
4000 $$.new_type_flag = $1.new_type_flag; }
4003 parm:
4004 named_parm
4005 | type_id
4008 see_typename:
4009 /* empty */ %prec EMPTY
4010 { see_typename (); }
4013 bad_parm:
4014 /* empty */ %prec EMPTY
4016 error ("type specifier omitted for parameter");
4017 $$ = build_tree_list (integer_type_node, NULL_TREE);
4019 | notype_declarator
4021 error ("type specifier omitted for parameter");
4022 if (TREE_CODE ($$) == SCOPE_REF
4023 && TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM)
4024 cp_error (" perhaps you want `typename %E' to make it a type", $$);
4025 $$ = build_tree_list (integer_type_node, $$);
4029 exception_specification_opt:
4030 /* empty */ %prec EMPTY
4031 { $$ = NULL_TREE; }
4032 | THROW '(' ansi_raise_identifiers ')' %prec EMPTY
4033 { $$ = $3; }
4034 | THROW LEFT_RIGHT %prec EMPTY
4035 { $$ = build_decl_list (NULL_TREE, NULL_TREE); }
4038 ansi_raise_identifier:
4039 type_id
4040 { $$ = build_decl_list (NULL_TREE, groktypename($1.t)); }
4043 ansi_raise_identifiers:
4044 ansi_raise_identifier
4045 | ansi_raise_identifiers ',' ansi_raise_identifier
4047 TREE_CHAIN ($3) = $$;
4048 $$ = $3;
4052 conversion_declarator:
4053 /* empty */ %prec EMPTY
4054 { $$ = NULL_TREE; }
4055 | '*' cv_qualifiers conversion_declarator
4056 { $$ = make_pointer_declarator ($2, $3); }
4057 | '&' cv_qualifiers conversion_declarator
4058 { $$ = make_reference_declarator ($2, $3); }
4059 | ptr_to_mem cv_qualifiers conversion_declarator
4060 { tree arg = make_pointer_declarator ($2, $3);
4061 $$ = build_parse_node (SCOPE_REF, $1, arg);
4065 operator:
4066 OPERATOR
4067 { got_scope = NULL_TREE; }
4070 operator_name:
4071 operator '*'
4072 { $$ = ansi_opname[MULT_EXPR]; }
4073 | operator '/'
4074 { $$ = ansi_opname[TRUNC_DIV_EXPR]; }
4075 | operator '%'
4076 { $$ = ansi_opname[TRUNC_MOD_EXPR]; }
4077 | operator '+'
4078 { $$ = ansi_opname[PLUS_EXPR]; }
4079 | operator '-'
4080 { $$ = ansi_opname[MINUS_EXPR]; }
4081 | operator '&'
4082 { $$ = ansi_opname[BIT_AND_EXPR]; }
4083 | operator '|'
4084 { $$ = ansi_opname[BIT_IOR_EXPR]; }
4085 | operator '^'
4086 { $$ = ansi_opname[BIT_XOR_EXPR]; }
4087 | operator '~'
4088 { $$ = ansi_opname[BIT_NOT_EXPR]; }
4089 | operator ','
4090 { $$ = ansi_opname[COMPOUND_EXPR]; }
4091 | operator ARITHCOMPARE
4092 { $$ = ansi_opname[$2]; }
4093 | operator '<'
4094 { $$ = ansi_opname[LT_EXPR]; }
4095 | operator '>'
4096 { $$ = ansi_opname[GT_EXPR]; }
4097 | operator EQCOMPARE
4098 { $$ = ansi_opname[$2]; }
4099 | operator ASSIGN
4100 { $$ = ansi_assopname[$2]; }
4101 | operator '='
4102 { $$ = ansi_opname [MODIFY_EXPR]; }
4103 | operator LSHIFT
4104 { $$ = ansi_opname[$2]; }
4105 | operator RSHIFT
4106 { $$ = ansi_opname[$2]; }
4107 | operator PLUSPLUS
4108 { $$ = ansi_opname[POSTINCREMENT_EXPR]; }
4109 | operator MINUSMINUS
4110 { $$ = ansi_opname[PREDECREMENT_EXPR]; }
4111 | operator ANDAND
4112 { $$ = ansi_opname[TRUTH_ANDIF_EXPR]; }
4113 | operator OROR
4114 { $$ = ansi_opname[TRUTH_ORIF_EXPR]; }
4115 | operator '!'
4116 { $$ = ansi_opname[TRUTH_NOT_EXPR]; }
4117 | operator '?' ':'
4118 { $$ = ansi_opname[COND_EXPR]; }
4119 | operator MIN_MAX
4120 { $$ = ansi_opname[$2]; }
4121 | operator POINTSAT %prec EMPTY
4122 { $$ = ansi_opname[COMPONENT_REF]; }
4123 | operator POINTSAT_STAR %prec EMPTY
4124 { $$ = ansi_opname[MEMBER_REF]; }
4125 | operator LEFT_RIGHT
4126 { $$ = ansi_opname[CALL_EXPR]; }
4127 | operator '[' ']'
4128 { $$ = ansi_opname[ARRAY_REF]; }
4129 | operator NEW %prec EMPTY
4130 { $$ = ansi_opname[NEW_EXPR]; }
4131 | operator DELETE %prec EMPTY
4132 { $$ = ansi_opname[DELETE_EXPR]; }
4133 | operator NEW '[' ']'
4134 { $$ = ansi_opname[VEC_NEW_EXPR]; }
4135 | operator DELETE '[' ']'
4136 { $$ = ansi_opname[VEC_DELETE_EXPR]; }
4137 /* Names here should be looked up in class scope ALSO. */
4138 | operator type_specifier_seq conversion_declarator
4139 { $$ = grokoptypename ($2.t, $3); }
4140 | operator error
4141 { $$ = ansi_opname[ERROR_MARK]; }
4146 #ifdef SPEW_DEBUG
4147 const char *
4148 debug_yytranslate (value)
4149 int value;
4151 return yytname[YYTRANSLATE (value)];
4154 #endif