* except.c (expand_throw): Add static attribute to match
[official-gcc.git] / gcc / cp / parse.y
blobde8b450272b1664d01548df6ebc6ddfdf58aa0ae
1 /* YACC parser for C++ syntax.
2 Copyright (C) 1988, 89, 93-98, 1999 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 "system.h"
37 #include "tree.h"
38 #include "input.h"
39 #include "flags.h"
40 #include "lex.h"
41 #include "cp-tree.h"
42 #include "output.h"
43 #include "except.h"
44 #include "toplev.h"
45 #include "ggc.h"
47 /* Since parsers are distinct for each language, put the language string
48 definition here. (fnf) */
49 const char * const language_string = "GNU C++";
51 extern struct obstack permanent_obstack;
53 extern int end_of_file;
55 /* Like YYERROR but do call yyerror. */
56 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
58 #define OP0(NODE) (TREE_OPERAND (NODE, 0))
59 #define OP1(NODE) (TREE_OPERAND (NODE, 1))
61 /* Contains the statement keyword (if/while/do) to include in an
62 error message if the user supplies an empty conditional expression. */
63 static const char *cond_stmt_keyword;
65 static tree empty_parms PROTO((void));
66 static void parse_decl PROTO((tree, tree, tree, int, tree *));
68 /* Nonzero if we have an `extern "C"' acting as an extern specifier. */
69 int have_extern_spec;
70 int used_extern_spec;
72 /* Cons up an empty parameter list. */
73 static inline tree
74 empty_parms ()
76 tree parms;
78 if (strict_prototype
79 || current_class_type != NULL)
80 parms = void_list_node;
81 else
82 parms = NULL_TREE;
83 return parms;
88 %start program
90 %union {
91 long itype;
92 tree ttype;
93 char *strtype;
94 enum tree_code code;
95 flagged_type_tree ftype;
96 struct pending_inline *pi;
99 /* All identifiers that are not reserved words
100 and are not declared typedefs in the current block */
101 %token IDENTIFIER
103 /* All identifiers that are declared typedefs in the current block.
104 In some contexts, they are treated just like IDENTIFIER,
105 but they can also serve as typespecs in declarations. */
106 %token TYPENAME
107 %token SELFNAME
109 /* A template function. */
110 %token PFUNCNAME
112 /* Reserved words that specify storage class.
113 yylval contains an IDENTIFIER_NODE which indicates which one. */
114 %token SCSPEC
116 /* Reserved words that specify type.
117 yylval contains an IDENTIFIER_NODE which indicates which one. */
118 %token TYPESPEC
120 /* Reserved words that qualify type: "const" or "volatile".
121 yylval contains an IDENTIFIER_NODE which indicates which one. */
122 %token CV_QUALIFIER
124 /* Character or numeric constants.
125 yylval is the node for the constant. */
126 %token CONSTANT
128 /* String constants in raw form.
129 yylval is a STRING_CST node. */
130 %token STRING
132 /* "...", used for functions with variable arglists. */
133 %token ELLIPSIS
135 /* the reserved words */
136 /* SCO include files test "ASM", so use something else. */
137 %token SIZEOF ENUM /* STRUCT UNION */ IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
138 %token BREAK CONTINUE RETURN_KEYWORD GOTO ASM_KEYWORD TYPEOF ALIGNOF
139 %token SIGOF
140 %token ATTRIBUTE EXTENSION LABEL
141 %token REALPART IMAGPART VA_ARG
143 /* the reserved words... C++ extensions */
144 %token <ttype> AGGR
145 %token <ttype> VISSPEC
146 %token DELETE NEW THIS OPERATOR CXX_TRUE CXX_FALSE
147 %token NAMESPACE TYPENAME_KEYWORD USING
148 %token LEFT_RIGHT TEMPLATE
149 %token TYPEID DYNAMIC_CAST STATIC_CAST REINTERPRET_CAST CONST_CAST
150 %token <itype> SCOPE
152 /* Define the operator tokens and their precedences.
153 The value is an integer because, if used, it is the tree code
154 to use in the expression made from the operator. */
156 %left EMPTY /* used to resolve s/r with epsilon */
158 %left error
160 /* Add precedence rules to solve dangling else s/r conflict */
161 %nonassoc IF
162 %nonassoc ELSE
164 %left IDENTIFIER PFUNCNAME TYPENAME SELFNAME PTYPENAME SCSPEC TYPESPEC CV_QUALIFIER ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD
166 %left '{' ',' ';'
168 %nonassoc THROW
169 %right <code> ':'
170 %right <code> ASSIGN '='
171 %right <code> '?'
172 %left <code> OROR
173 %left <code> ANDAND
174 %left <code> '|'
175 %left <code> '^'
176 %left <code> '&'
177 %left <code> MIN_MAX
178 %left <code> EQCOMPARE
179 %left <code> ARITHCOMPARE '<' '>'
180 %left <code> LSHIFT RSHIFT
181 %left <code> '+' '-'
182 %left <code> '*' '/' '%'
183 %left <code> POINTSAT_STAR DOT_STAR
184 %right <code> UNARY PLUSPLUS MINUSMINUS '~'
185 %left HYPERUNARY
186 %left <ttype> LEFT_RIGHT
187 %left <code> POINTSAT '.' '(' '['
189 %right SCOPE /* C++ extension */
190 %nonassoc NEW DELETE TRY CATCH
192 %type <code> unop
194 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist
195 %type <ttype> PFUNCNAME maybe_identifier
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 <ttype> init initlist maybeasm maybe_init defarg defarg1
203 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
204 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
205 %type <ttype> any_word
207 %type <ttype> compstmt implicitly_scoped_stmt
209 %type <ttype> declarator notype_declarator after_type_declarator
210 %type <ttype> notype_declarator_intern absdcl_intern
211 %type <ttype> after_type_declarator_intern
212 %type <ttype> direct_notype_declarator direct_after_type_declarator
213 %type <itype> components notype_components
214 %type <ttype> component_decl component_decl_1
215 %type <ttype> component_declarator component_declarator0
216 %type <ttype> notype_component_declarator notype_component_declarator0
217 %type <ttype> after_type_component_declarator after_type_component_declarator0
218 %type <ttype> absdcl cv_qualifiers
219 %type <ttype> direct_abstract_declarator conversion_declarator
220 %type <ttype> new_declarator direct_new_declarator
221 %type <ttype> xexpr parmlist parms bad_parm
222 %type <ttype> identifiers_or_typenames
223 %type <ttype> fcast_or_absdcl regcast_or_absdcl
224 %type <ttype> expr_or_declarator expr_or_declarator_intern
225 %type <ttype> complex_notype_declarator
226 %type <ttype> notype_unqualified_id unqualified_id qualified_id
227 %type <ttype> template_id do_id object_template_id notype_template_declarator
228 %type <ttype> overqualified_id notype_qualified_id any_id
229 %type <ttype> complex_direct_notype_declarator functional_cast
230 %type <ttype> complex_parmlist parms_comma
231 %type <ttype> namespace_qualifier namespace_using_decl
233 %type <ftype> type_id new_type_id typed_typespecs typespec typed_declspecs
234 %type <ftype> typed_declspecs1 type_specifier_seq nonempty_cv_qualifiers
235 %type <ftype> structsp typespecqual_reserved parm named_parm full_parm
237 %type <itype> extension
239 /* C++ extensions */
240 %token <ttype> PTYPENAME
241 %token <ttype> EXTERN_LANG_STRING ALL
242 %token <ttype> PRE_PARSED_CLASS_DECL DEFARG DEFARG_MARKER
243 %token <pi> PRE_PARSED_FUNCTION_DECL
244 %type <ttype> component_constructor_declarator
245 %type <ttype> fn.def2 return_id constructor_declarator
246 %type <pi> fn.defpen
247 %type <itype> ctor_initializer_opt function_try_block
248 %type <ttype> named_class_head_sans_basetype
249 %type <ftype> class_head named_class_head
250 %type <ftype> named_complex_class_head_sans_basetype
251 %type <ttype> unnamed_class_head
252 %type <ttype> base_class_list
253 %type <ttype> base_class_access_list
254 %type <ttype> base_class maybe_base_class_list base_class.1
255 %type <ttype> exception_specification_opt ansi_raise_identifier ansi_raise_identifiers
256 %type <ttype> operator_name
257 %type <ttype> object aggr
258 %type <itype> new delete
259 /* %type <ttype> primary_no_id */
260 %type <ttype> maybe_parmlist
261 %type <itype> member_init_list
262 %type <ttype> template_header template_parm_list template_parm
263 %type <ttype> template_type_parm template_template_parm
264 %type <code> template_close_bracket
265 %type <ttype> apparent_template_type
266 %type <ttype> template_type template_arg_list template_arg_list_opt
267 %type <ttype> template_arg
268 %type <ttype> condition xcond paren_cond_or_null
269 %type <ttype> type_name nested_name_specifier nested_type ptr_to_mem
270 %type <ttype> complete_type_name notype_identifier nonnested_type
271 %type <ttype> complex_type_name nested_name_specifier_1
272 %type <ttype> new_initializer new_placement
273 %type <ttype> using_decl
274 %type <ttype> typename_sub typename_sub0 typename_sub1 typename_sub2
275 %type <ttype> explicit_template_type
276 /* in order to recognize aggr tags as defining and thus shadowing. */
277 %token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN
278 %type <ttype> named_class_head_sans_basetype_defn
279 %type <ttype> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN
280 %type <ttype> handler_args
281 %type <ttype> self_template_type .finish_template_type
283 %token NSNAME
284 %type <ttype> NSNAME
286 /* Used in lex.c for parsing pragmas. */
287 %token END_OF_LINE
289 /* lex.c and pt.c depend on this being the last token. Define
290 any new tokens before this one! */
291 %token END_OF_SAVED_INPUT
294 /* List of types and structure classes of the current declaration. */
295 static tree current_declspecs;
297 /* List of prefix attributes in effect.
298 Prefix attributes are parsed by the reserved_declspecs and declmods
299 rules. They create a list that contains *both* declspecs and attrs. */
300 /* ??? It is not clear yet that all cases where an attribute can now appear in
301 a declspec list have been updated. */
302 static tree prefix_attributes;
304 /* When defining an aggregate, this is the kind of the most recent one
305 being defined. (For example, this might be class_type_node.) */
306 static tree current_aggr;
308 /* When defining an enumeration, this is the type of the enumeration. */
309 static tree current_enum_type;
311 /* Tell yyparse how to print a token's value, if yydebug is set. */
313 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
314 extern void yyprint PROTO((FILE *, int, YYSTYPE));
315 extern tree combine_strings PROTO((tree));
317 static void
318 parse_decl (declarator, specs_attrs, attributes, initialized, decl)
319 tree declarator;
320 tree specs_attrs;
321 tree attributes;
322 int initialized;
323 tree* decl;
325 split_specs_attrs (specs_attrs, &current_declspecs, &prefix_attributes);
326 if (current_declspecs
327 && TREE_CODE (current_declspecs) != TREE_LIST)
328 current_declspecs = build_decl_list (NULL_TREE, current_declspecs);
329 if (have_extern_spec && !used_extern_spec)
331 current_declspecs = decl_tree_cons (NULL_TREE,
332 get_identifier ("extern"),
333 current_declspecs);
334 used_extern_spec = 1;
336 *decl = start_decl (declarator, current_declspecs, initialized,
337 attributes, prefix_attributes);
340 void
341 cp_parse_init ()
343 ggc_add_tree_root (&current_declspecs, 1);
344 ggc_add_tree_root (&prefix_attributes, 1);
345 ggc_add_tree_root (&current_aggr, 1);
346 ggc_add_tree_root (&current_enum_type, 1);
351 program:
352 /* empty */
353 | extdefs
354 { finish_translation_unit (); }
357 /* the reason for the strange actions in this rule
358 is so that notype_initdecls when reached via datadef
359 can find a valid list of type and sc specs in $0. */
361 extdefs:
362 { $<ttype>$ = NULL_TREE; }
363 lang_extdef
364 { $<ttype>$ = NULL_TREE; }
365 | extdefs lang_extdef
366 { $<ttype>$ = NULL_TREE; }
369 extdefs_opt:
370 extdefs
371 | /* empty */
374 .hush_warning:
375 { have_extern_spec = 1;
376 used_extern_spec = 0;
377 $<ttype>$ = NULL_TREE; }
379 .warning_ok:
380 { have_extern_spec = 0; }
383 extension:
384 EXTENSION
385 { $$ = pedantic;
386 pedantic = 0; }
389 asm_keyword:
390 ASM_KEYWORD
393 lang_extdef:
394 { if (pending_lang_change) do_pending_lang_change(); }
395 extdef
396 { if (! toplevel_bindings_p ())
397 pop_everything (); }
400 extdef:
401 fndef eat_saved_input
402 { if (pending_inlines) do_pending_inlines (); }
403 | datadef
404 { if (pending_inlines) do_pending_inlines (); }
405 | template_def
406 { if (pending_inlines) do_pending_inlines (); }
407 | asm_keyword '(' string ')' ';'
408 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
409 assemble_asm ($3); }
410 | extern_lang_string '{' extdefs_opt '}'
411 { pop_lang_context (); }
412 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
413 { if (pending_inlines) do_pending_inlines ();
414 pop_lang_context (); }
415 | extern_lang_string .hush_warning datadef .warning_ok
416 { if (pending_inlines) do_pending_inlines ();
417 pop_lang_context (); }
418 | NAMESPACE identifier '{'
419 { push_namespace ($2); }
420 extdefs_opt '}'
421 { pop_namespace (); }
422 | NAMESPACE '{'
423 { push_namespace (NULL_TREE); }
424 extdefs_opt '}'
425 { pop_namespace (); }
426 | namespace_alias
427 | using_decl ';'
428 { do_toplevel_using_decl ($1); }
429 | using_directive
430 | extension extdef
431 { pedantic = $1; }
434 namespace_alias:
435 NAMESPACE identifier '='
436 { begin_only_namespace_names (); }
437 any_id ';'
439 end_only_namespace_names ();
440 if (lastiddecl)
441 $5 = lastiddecl;
442 do_namespace_alias ($2, $5);
446 using_decl:
447 USING qualified_id
448 { $$ = $2; }
449 | USING global_scope qualified_id
450 { $$ = $3; }
451 | USING global_scope unqualified_id
452 { $$ = $3; }
455 namespace_using_decl:
456 USING namespace_qualifier identifier
457 { $$ = build_parse_node (SCOPE_REF, $2, $3); }
458 | USING global_scope identifier
459 { $$ = build_parse_node (SCOPE_REF, global_namespace, $3); }
460 | USING global_scope namespace_qualifier identifier
461 { $$ = build_parse_node (SCOPE_REF, $3, $4); }
464 using_directive:
465 USING NAMESPACE
466 { begin_only_namespace_names (); }
467 any_id ';'
469 end_only_namespace_names ();
470 /* If no declaration was found, the using-directive is
471 invalid. Since that was not reported, we need the
472 identifier for the error message. */
473 if (TREE_CODE ($4) == IDENTIFIER_NODE && lastiddecl)
474 $4 = lastiddecl;
475 do_using_directive ($4);
479 namespace_qualifier:
480 NSNAME SCOPE
482 if (TREE_CODE ($$) == IDENTIFIER_NODE)
483 $$ = lastiddecl;
484 got_scope = $$;
486 | namespace_qualifier NSNAME SCOPE
488 $$ = $2;
489 if (TREE_CODE ($$) == IDENTIFIER_NODE)
490 $$ = lastiddecl;
491 got_scope = $$;
494 any_id:
495 unqualified_id
496 | qualified_id
497 | global_scope qualified_id
498 { $$ = $2; }
499 | global_scope unqualified_id
500 { $$ = $2; }
503 extern_lang_string:
504 EXTERN_LANG_STRING
505 { push_lang_context ($1); }
506 | extern_lang_string EXTERN_LANG_STRING
507 { if (current_lang_name != $2)
508 cp_error ("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name);
509 pop_lang_context (); push_lang_context ($2); }
512 template_header:
513 TEMPLATE '<'
514 { begin_template_parm_list (); }
515 template_parm_list '>'
516 { $$ = end_template_parm_list ($4); }
517 | TEMPLATE '<' '>'
518 { begin_specialization();
519 $$ = NULL_TREE; }
522 template_parm_list:
523 template_parm
524 { $$ = process_template_parm (NULL_TREE, $1); }
525 | template_parm_list ',' template_parm
526 { $$ = process_template_parm ($1, $3); }
529 maybe_identifier:
530 identifier
531 { $$ = $1; }
532 | /* empty */
533 { $$ = NULL_TREE; }
535 template_type_parm:
536 aggr maybe_identifier
537 { $$ = finish_template_type_parm ($1, $2); }
538 | TYPENAME_KEYWORD maybe_identifier
539 { $$ = finish_template_type_parm (class_type_node, $2); }
542 template_template_parm:
543 template_header aggr maybe_identifier
544 { $$ = finish_template_template_parm ($2, $3); }
547 template_parm:
548 /* The following rules introduce a new reduce/reduce
549 conflict on the ',' and '>' input tokens: they are valid
550 prefixes for a `structsp', which means they could match a
551 nameless parameter. See 14.6, paragraph 3.
552 By putting them before the `parm' rule, we get
553 their match before considering them nameless parameter
554 declarations. */
555 template_type_parm
556 { $$ = build_tree_list (NULL_TREE, $1); }
557 | template_type_parm '=' type_id
558 { $$ = build_tree_list (groktypename ($3.t), $1); }
559 | parm
560 { $$ = build_tree_list (NULL_TREE, $1.t); }
561 | parm '=' expr_no_commas %prec ARITHCOMPARE
562 { $$ = build_tree_list ($3, $1.t); }
563 | template_template_parm
564 { $$ = build_tree_list (NULL_TREE, $1); }
565 | template_template_parm '=' template_arg
567 if (TREE_CODE ($3) != TEMPLATE_DECL
568 && TREE_CODE ($3) != TEMPLATE_TEMPLATE_PARM
569 && TREE_CODE ($3) != TYPE_DECL)
571 error ("invalid default template argument");
572 $3 = error_mark_node;
574 $$ = build_tree_list ($3, $1);
578 template_def:
579 template_header template_extdef
580 { finish_template_decl ($1); }
581 | template_header error %prec EMPTY
582 { finish_template_decl ($1); }
585 template_extdef:
586 fndef eat_saved_input
587 { if (pending_inlines) do_pending_inlines (); }
588 | template_datadef
589 { if (pending_inlines) do_pending_inlines (); }
590 | template_def
591 { if (pending_inlines) do_pending_inlines (); }
592 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
593 { if (pending_inlines) do_pending_inlines ();
594 pop_lang_context (); }
595 | extern_lang_string .hush_warning template_datadef .warning_ok
596 { if (pending_inlines) do_pending_inlines ();
597 pop_lang_context (); }
598 | extension template_extdef
599 { pedantic = $1; }
602 template_datadef:
603 nomods_initdecls ';'
604 | declmods notype_initdecls ';'
606 | typed_declspecs initdecls ';'
607 { note_list_got_semicolon ($1.t); }
608 | structsp ';'
609 { maybe_process_partial_specialization ($1.t);
610 note_got_semicolon ($1.t); }
613 datadef:
614 nomods_initdecls ';'
615 | declmods notype_initdecls ';'
617 | typed_declspecs initdecls ';'
618 { note_list_got_semicolon ($1.t); }
619 | declmods ';'
620 { pedwarn ("empty declaration"); }
621 | explicit_instantiation ';'
622 | typed_declspecs ';'
624 tree t, attrs;
625 split_specs_attrs ($1.t, &t, &attrs);
626 shadow_tag (t);
627 note_list_got_semicolon ($1.t);
629 | error ';'
630 | error '}'
631 | ';'
634 ctor_initializer_opt:
635 nodecls
636 { $$ = 0; }
637 | base_init
638 { $$ = 1; }
641 maybe_return_init:
642 /* empty */
643 | return_init
644 | return_init ';'
647 eat_saved_input:
648 /* empty */
649 | END_OF_SAVED_INPUT
652 fndef:
653 fn.def1 maybe_return_init ctor_initializer_opt compstmt_or_error
654 { expand_body (finish_function (lineno, (int)$3)); }
655 | fn.def1 maybe_return_init function_try_block
656 { expand_body (finish_function (lineno, (int)$3)); }
657 | fn.def1 maybe_return_init error
661 constructor_declarator:
662 nested_name_specifier SELFNAME '('
663 { $$ = begin_constructor_declarator ($1, $2); }
664 parmlist ')' cv_qualifiers exception_specification_opt
665 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
666 | nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
667 { $$ = begin_constructor_declarator ($1, $2);
668 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
670 | global_scope nested_name_specifier SELFNAME '('
671 { $$ = begin_constructor_declarator ($2, $3); }
672 parmlist ')' cv_qualifiers exception_specification_opt
673 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
674 | global_scope nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
675 { $$ = begin_constructor_declarator ($2, $3);
676 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
678 | nested_name_specifier self_template_type '('
679 { $$ = begin_constructor_declarator ($1, $2); }
680 parmlist ')' cv_qualifiers exception_specification_opt
681 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
682 | nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
683 { $$ = begin_constructor_declarator ($1, $2);
684 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
686 | global_scope nested_name_specifier self_template_type '('
687 { $$ = begin_constructor_declarator ($2, $3); }
688 parmlist ')' cv_qualifiers exception_specification_opt
689 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
690 | global_scope nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
691 { $$ = begin_constructor_declarator ($2, $3);
692 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
696 fn.def1:
697 typed_declspecs declarator
698 { if (!begin_function_definition ($1.t, $2))
699 YYERROR1; }
700 | declmods notype_declarator
701 { if (!begin_function_definition ($1, $2))
702 YYERROR1; }
703 | notype_declarator
704 { if (!begin_function_definition (NULL_TREE, $1))
705 YYERROR1; }
706 | declmods constructor_declarator
707 { if (!begin_function_definition ($1, $2))
708 YYERROR1; }
709 | constructor_declarator
710 { if (!begin_function_definition (NULL_TREE, $1))
711 YYERROR1; }
714 component_constructor_declarator:
715 SELFNAME '(' parmlist ')' cv_qualifiers exception_specification_opt
716 { $$ = make_call_declarator ($1, $3, $5, $6); }
717 | SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
718 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
719 | self_template_type '(' parmlist ')' cv_qualifiers exception_specification_opt
720 { $$ = make_call_declarator ($1, $3, $5, $6); }
721 | self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
722 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
725 /* more C++ complexity. See component_decl for a comment on the
726 reduce/reduce conflict introduced by these rules. */
727 fn.def2:
728 declmods component_constructor_declarator
729 { tree specs, attrs;
730 split_specs_attrs ($1, &specs, &attrs);
731 attrs = build_tree_list (attrs, NULL_TREE);
732 $$ = start_method (specs, $2, attrs);
733 rest_of_mdef:
734 if (! $$)
735 YYERROR1;
736 if (yychar == YYEMPTY)
737 yychar = YYLEX;
738 reinit_parse_for_method (yychar, $$); }
739 | component_constructor_declarator
740 { $$ = start_method (NULL_TREE, $1, NULL_TREE);
741 goto rest_of_mdef; }
742 | typed_declspecs declarator
743 { tree specs, attrs;
744 split_specs_attrs ($1.t, &specs, &attrs);
745 attrs = build_tree_list (attrs, NULL_TREE);
746 $$ = start_method (specs, $2, attrs); goto rest_of_mdef; }
747 | declmods notype_declarator
748 { tree specs, attrs;
749 split_specs_attrs ($1, &specs, &attrs);
750 attrs = build_tree_list (attrs, NULL_TREE);
751 $$ = start_method (specs, $2, attrs); goto rest_of_mdef; }
752 | notype_declarator
753 { $$ = start_method (NULL_TREE, $$, NULL_TREE);
754 goto rest_of_mdef; }
755 | declmods constructor_declarator
756 { tree specs, attrs;
757 split_specs_attrs ($1, &specs, &attrs);
758 attrs = build_tree_list (attrs, NULL_TREE);
759 $$ = start_method (specs, $2, attrs); goto rest_of_mdef; }
760 | constructor_declarator
761 { $$ = start_method (NULL_TREE, $$, NULL_TREE);
762 goto rest_of_mdef; }
765 return_id:
766 RETURN_KEYWORD IDENTIFIER
768 if (! current_function_parms_stored)
769 store_parm_decls ();
770 $$ = $2;
774 return_init:
775 return_id maybe_init
776 { finish_named_return_value ($<ttype>$, $2); }
777 | return_id '(' nonnull_exprlist ')'
778 { finish_named_return_value ($<ttype>$, $3); }
779 | return_id LEFT_RIGHT
780 { finish_named_return_value ($<ttype>$, NULL_TREE); }
783 base_init:
784 ':' .set_base_init member_init_list
786 if ($3 == 0)
787 error ("no base initializers given following ':'");
788 setup_vtbl_ptr ();
792 .set_base_init:
793 /* empty */
795 if (! current_function_parms_stored)
796 store_parm_decls ();
798 if (DECL_CONSTRUCTOR_P (current_function_decl))
799 /* Make a contour for the initializer list. */
800 do_pushlevel ();
801 else if (current_class_type == NULL_TREE)
802 error ("base initializers not allowed for non-member functions");
803 else if (! DECL_CONSTRUCTOR_P (current_function_decl))
804 error ("only constructors take base initializers");
808 member_init_list:
809 /* empty */
810 { $$ = 0; }
811 | member_init
812 { $$ = 1; }
813 | member_init_list ',' member_init
814 | member_init_list error
817 member_init:
818 '(' nonnull_exprlist ')'
820 if (current_class_name)
821 pedwarn ("anachronistic old style base class initializer");
822 expand_member_init (current_class_ref, NULL_TREE, $2);
824 | LEFT_RIGHT
826 if (current_class_name)
827 pedwarn ("anachronistic old style base class initializer");
828 expand_member_init (current_class_ref, NULL_TREE, void_type_node);
830 | notype_identifier '(' nonnull_exprlist ')'
831 { expand_member_init (current_class_ref, $1, $3); }
832 | notype_identifier LEFT_RIGHT
833 { expand_member_init (current_class_ref, $1, void_type_node); }
834 | nonnested_type '(' nonnull_exprlist ')'
835 { expand_member_init (current_class_ref, $1, $3); }
836 | nonnested_type LEFT_RIGHT
837 { expand_member_init (current_class_ref, $1, void_type_node); }
838 | typename_sub '(' nonnull_exprlist ')'
839 { expand_member_init (current_class_ref, TYPE_MAIN_DECL ($1),
840 $3); }
841 | typename_sub LEFT_RIGHT
842 { expand_member_init (current_class_ref, TYPE_MAIN_DECL ($1),
843 void_type_node); }
844 | error
847 identifier:
848 IDENTIFIER
849 | TYPENAME
850 | SELFNAME
851 | PTYPENAME
852 | NSNAME
855 notype_identifier:
856 IDENTIFIER
857 | PTYPENAME
858 | NSNAME %prec EMPTY
861 identifier_defn:
862 IDENTIFIER_DEFN
863 | TYPENAME_DEFN
864 | PTYPENAME_DEFN
867 explicit_instantiation:
868 TEMPLATE begin_explicit_instantiation typespec ';'
869 { do_type_instantiation ($3.t, NULL_TREE);
870 yyungetc (';', 1); }
871 end_explicit_instantiation
872 | TEMPLATE begin_explicit_instantiation typed_declspecs declarator
873 { tree specs = strip_attrs ($3.t);
874 do_decl_instantiation (specs, $4, NULL_TREE); }
875 end_explicit_instantiation
876 | TEMPLATE begin_explicit_instantiation notype_declarator
877 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
878 end_explicit_instantiation
879 | TEMPLATE begin_explicit_instantiation constructor_declarator
880 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
881 end_explicit_instantiation
882 | SCSPEC TEMPLATE begin_explicit_instantiation typespec ';'
883 { do_type_instantiation ($4.t, $1);
884 yyungetc (';', 1); }
885 end_explicit_instantiation
886 | SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
887 declarator
888 { tree specs = strip_attrs ($4.t);
889 do_decl_instantiation (specs, $5, $1); }
890 end_explicit_instantiation
891 | SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
892 { do_decl_instantiation (NULL_TREE, $4, $1); }
893 end_explicit_instantiation
894 | SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
895 { do_decl_instantiation (NULL_TREE, $4, $1); }
896 end_explicit_instantiation
899 begin_explicit_instantiation:
900 { begin_explicit_instantiation(); }
902 end_explicit_instantiation:
903 { end_explicit_instantiation(); }
905 /* The TYPENAME expansions are to deal with use of a template class name as
906 a template within the class itself, where the template decl is hidden by
907 a type decl. Got all that? */
909 template_type:
910 PTYPENAME '<' template_arg_list_opt template_close_bracket
911 .finish_template_type
912 { $$ = $5; }
913 | TYPENAME '<' template_arg_list_opt template_close_bracket
914 .finish_template_type
915 { $$ = $5; }
916 | self_template_type
919 apparent_template_type:
920 template_type
921 | identifier '<' template_arg_list_opt '>'
922 .finish_template_type
923 { $$ = $5; }
925 self_template_type:
926 SELFNAME '<' template_arg_list_opt template_close_bracket
927 .finish_template_type
928 { $$ = $5; }
931 .finish_template_type:
933 if (yychar == YYEMPTY)
934 yychar = YYLEX;
936 $$ = finish_template_type ($<ttype>-3, $<ttype>-1,
937 yychar == SCOPE);
940 template_close_bracket:
942 | RSHIFT
944 /* Handle `Class<Class<Type>>' without space in the `>>' */
945 pedwarn ("`>>' should be `> >' in template class name");
946 yyungetc ('>', 1);
950 template_arg_list_opt:
951 /* empty */
952 { $$ = NULL_TREE; }
953 | template_arg_list
956 template_arg_list:
957 template_arg
958 { $$ = build_tree_list (NULL_TREE, $$); }
959 | template_arg_list ',' template_arg
960 { $$ = chainon ($$, build_tree_list (NULL_TREE, $3)); }
963 template_arg:
964 type_id
965 { $$ = groktypename ($1.t); }
966 | PTYPENAME
967 { $$ = lastiddecl; }
968 | expr_no_commas %prec ARITHCOMPARE
971 unop:
973 { $$ = NEGATE_EXPR; }
974 | '+'
975 { $$ = CONVERT_EXPR; }
976 | PLUSPLUS
977 { $$ = PREINCREMENT_EXPR; }
978 | MINUSMINUS
979 { $$ = PREDECREMENT_EXPR; }
980 | '!'
981 { $$ = TRUTH_NOT_EXPR; }
984 expr:
985 nontrivial_exprlist
986 { $$ = build_x_compound_expr ($$); }
987 | expr_no_commas
990 paren_expr_or_null:
991 LEFT_RIGHT
992 { error ("ANSI C++ forbids an empty condition for `%s'",
993 cond_stmt_keyword);
994 $$ = integer_zero_node; }
995 | '(' expr ')'
996 { $$ = $2; }
999 paren_cond_or_null:
1000 LEFT_RIGHT
1001 { error ("ANSI C++ forbids an empty condition for `%s'",
1002 cond_stmt_keyword);
1003 $$ = integer_zero_node; }
1004 | '(' condition ')'
1005 { $$ = $2; }
1008 xcond:
1009 /* empty */
1010 { $$ = NULL_TREE; }
1011 | condition
1012 | error
1013 { $$ = NULL_TREE; }
1016 condition:
1017 type_specifier_seq declarator maybeasm maybe_attribute '='
1019 tree d;
1020 for (d = getdecls (); d; d = TREE_CHAIN (d))
1021 if (TREE_CODE (d) == TYPE_DECL) {
1022 tree s = TREE_TYPE (d);
1023 if (TREE_CODE (s) == RECORD_TYPE)
1024 cp_error ("definition of class `%T' in condition", s);
1025 else if (TREE_CODE (s) == ENUMERAL_TYPE)
1026 cp_error ("definition of enum `%T' in condition", s);
1029 current_declspecs = $1.t;
1030 $<ttype>$ = start_decl ($<ttype>2, current_declspecs, 1,
1031 $4, /*prefix_attributes*/ NULL_TREE);
1033 init
1035 cp_finish_decl ($<ttype>6, $7, $4, LOOKUP_ONLYCONVERTING);
1036 $$ = convert_from_reference ($<ttype>6);
1037 if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
1038 cp_error ("definition of array `%#D' in condition", $$);
1040 | expr
1043 compstmtend:
1045 | maybe_label_decls stmts '}'
1046 | maybe_label_decls stmts error '}'
1047 | maybe_label_decls error '}'
1050 already_scoped_stmt:
1052 { $<ttype>$ = begin_compound_stmt (1); }
1053 compstmtend
1054 { finish_compound_stmt (1, $<ttype>2); }
1055 | simple_stmt
1059 nontrivial_exprlist:
1060 expr_no_commas ',' expr_no_commas
1061 { $$ = tree_cons (NULL_TREE, $$,
1062 build_expr_list (NULL_TREE, $3)); }
1063 | expr_no_commas ',' error
1064 { $$ = tree_cons (NULL_TREE, $$,
1065 build_expr_list (NULL_TREE, error_mark_node)); }
1066 | nontrivial_exprlist ',' expr_no_commas
1067 { chainon ($$, build_expr_list (NULL_TREE, $3)); }
1068 | nontrivial_exprlist ',' error
1069 { chainon ($$, build_expr_list (NULL_TREE, error_mark_node)); }
1072 nonnull_exprlist:
1073 expr_no_commas
1074 { $$ = build_expr_list (NULL_TREE, $$); }
1075 | nontrivial_exprlist
1078 unary_expr:
1079 primary %prec UNARY
1080 { $$ = $1; }
1081 /* __extension__ turns off -pedantic for following primary. */
1082 | extension cast_expr %prec UNARY
1083 { $$ = $2;
1084 pedantic = $1; }
1085 | '*' cast_expr %prec UNARY
1086 { $$ = build_x_indirect_ref ($2, "unary *"); }
1087 | '&' cast_expr %prec UNARY
1088 { $$ = build_x_unary_op (ADDR_EXPR, $2); }
1089 | '~' cast_expr
1090 { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); }
1091 | unop cast_expr %prec UNARY
1092 { $$ = finish_unary_op_expr ($1, $2); }
1093 /* Refer to the address of a label as a pointer. */
1094 | ANDAND identifier
1095 { if (pedantic)
1096 pedwarn ("ANSI C++ forbids `&&'");
1097 $$ = finish_label_address_expr ($2); }
1098 | SIZEOF unary_expr %prec UNARY
1099 { $$ = expr_sizeof ($2); }
1100 | SIZEOF '(' type_id ')' %prec HYPERUNARY
1101 { $$ = c_sizeof (groktypename ($3.t));
1102 check_for_new_type ("sizeof", $3); }
1103 | ALIGNOF unary_expr %prec UNARY
1104 { $$ = grok_alignof ($2); }
1105 | ALIGNOF '(' type_id ')' %prec HYPERUNARY
1106 { $$ = c_alignof (groktypename ($3.t));
1107 check_for_new_type ("alignof", $3); }
1109 /* The %prec EMPTY's here are required by the = init initializer
1110 syntax extension; see below. */
1111 | new new_type_id %prec EMPTY
1112 { $$ = build_new (NULL_TREE, $2.t, NULL_TREE, $1);
1113 check_for_new_type ("new", $2); }
1114 | new new_type_id new_initializer
1115 { $$ = build_new (NULL_TREE, $2.t, $3, $1);
1116 check_for_new_type ("new", $2); }
1117 | new new_placement new_type_id %prec EMPTY
1118 { $$ = build_new ($2, $3.t, NULL_TREE, $1);
1119 check_for_new_type ("new", $3); }
1120 | new new_placement new_type_id new_initializer
1121 { $$ = build_new ($2, $3.t, $4, $1);
1122 check_for_new_type ("new", $3); }
1123 | new '(' type_id ')'
1124 %prec EMPTY
1125 { $$ = build_new (NULL_TREE, groktypename($3.t),
1126 NULL_TREE, $1);
1127 check_for_new_type ("new", $3); }
1128 | new '(' type_id ')' new_initializer
1129 { $$ = build_new (NULL_TREE, groktypename($3.t), $5, $1);
1130 check_for_new_type ("new", $3); }
1131 | new new_placement '(' type_id ')' %prec EMPTY
1132 { $$ = build_new ($2, groktypename($4.t), NULL_TREE, $1);
1133 check_for_new_type ("new", $4); }
1134 | new new_placement '(' type_id ')' new_initializer
1135 { $$ = build_new ($2, groktypename($4.t), $6, $1);
1136 check_for_new_type ("new", $4); }
1138 | delete cast_expr %prec UNARY
1139 { $$ = delete_sanity ($2, NULL_TREE, 0, $1); }
1140 | delete '[' ']' cast_expr %prec UNARY
1141 { $$ = delete_sanity ($4, NULL_TREE, 1, $1);
1142 if (yychar == YYEMPTY)
1143 yychar = YYLEX; }
1144 | delete '[' expr ']' cast_expr %prec UNARY
1145 { $$ = delete_sanity ($5, $3, 2, $1);
1146 if (yychar == YYEMPTY)
1147 yychar = YYLEX; }
1148 | REALPART cast_expr %prec UNARY
1149 { $$ = build_x_unary_op (REALPART_EXPR, $2); }
1150 | IMAGPART cast_expr %prec UNARY
1151 { $$ = build_x_unary_op (IMAGPART_EXPR, $2); }
1152 | VA_ARG '(' expr_no_commas ',' type_id ')'
1153 { $$ = build_x_va_arg ($3, groktypename ($5.t));
1154 check_for_new_type ("__builtin_va_arg", $5); }
1157 new_placement:
1158 '(' nonnull_exprlist ')'
1159 { $$ = $2; }
1160 | '{' nonnull_exprlist '}'
1161 { cp_pedwarn ("old style placement syntax, use () instead");
1162 $$ = $2; }
1165 new_initializer:
1166 '(' nonnull_exprlist ')'
1167 { $$ = $2; }
1168 | LEFT_RIGHT
1169 { $$ = NULL_TREE; }
1170 | '(' typespec ')'
1172 cp_error ("`%T' is not a valid expression", $2.t);
1173 $$ = error_mark_node;
1175 /* GNU extension so people can use initializer lists. Note that
1176 this alters the meaning of `new int = 1', which was previously
1177 syntactically valid but semantically invalid. */
1178 | '=' init
1180 if (pedantic)
1181 pedwarn ("ANSI C++ forbids initialization of new expression with `='");
1182 if (TREE_CODE ($2) != TREE_LIST
1183 && TREE_CODE ($2) != CONSTRUCTOR)
1184 $$ = build_expr_list (NULL_TREE, $2);
1185 else
1186 $$ = $2;
1190 /* This is necessary to postpone reduction of `int ((int)(int)(int))'. */
1191 regcast_or_absdcl:
1192 '(' type_id ')' %prec EMPTY
1193 { $2.t = finish_parmlist (build_tree_list (NULL_TREE, $2.t), 0);
1194 $$ = make_call_declarator (NULL_TREE, $2.t, NULL_TREE, NULL_TREE);
1195 check_for_new_type ("cast", $2); }
1196 | regcast_or_absdcl '(' type_id ')' %prec EMPTY
1197 { $3.t = finish_parmlist (build_tree_list (NULL_TREE, $3.t), 0);
1198 $$ = make_call_declarator ($$, $3.t, NULL_TREE, NULL_TREE);
1199 check_for_new_type ("cast", $3); }
1202 cast_expr:
1203 unary_expr
1204 | regcast_or_absdcl unary_expr %prec UNARY
1205 { $$ = reparse_absdcl_as_casts ($$, $2); }
1206 | regcast_or_absdcl '{' initlist maybecomma '}' %prec UNARY
1208 tree init = build_nt (CONSTRUCTOR, NULL_TREE,
1209 nreverse ($3));
1210 if (pedantic)
1211 pedwarn ("ANSI C++ forbids constructor-expressions");
1212 /* Indicate that this was a GNU C constructor expression. */
1213 TREE_HAS_CONSTRUCTOR (init) = 1;
1215 $$ = reparse_absdcl_as_casts ($$, init);
1219 expr_no_commas:
1220 cast_expr
1221 /* Handle general members. */
1222 | expr_no_commas POINTSAT_STAR expr_no_commas
1223 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1224 | expr_no_commas DOT_STAR expr_no_commas
1225 { $$ = build_m_component_ref ($$, $3); }
1226 | expr_no_commas '+' expr_no_commas
1227 { $$ = build_x_binary_op ($2, $$, $3); }
1228 | expr_no_commas '-' expr_no_commas
1229 { $$ = build_x_binary_op ($2, $$, $3); }
1230 | expr_no_commas '*' expr_no_commas
1231 { $$ = build_x_binary_op ($2, $$, $3); }
1232 | expr_no_commas '/' expr_no_commas
1233 { $$ = build_x_binary_op ($2, $$, $3); }
1234 | expr_no_commas '%' expr_no_commas
1235 { $$ = build_x_binary_op ($2, $$, $3); }
1236 | expr_no_commas LSHIFT expr_no_commas
1237 { $$ = build_x_binary_op ($2, $$, $3); }
1238 | expr_no_commas RSHIFT expr_no_commas
1239 { $$ = build_x_binary_op ($2, $$, $3); }
1240 | expr_no_commas ARITHCOMPARE expr_no_commas
1241 { $$ = build_x_binary_op ($2, $$, $3); }
1242 | expr_no_commas '<' expr_no_commas
1243 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1244 | expr_no_commas '>' expr_no_commas
1245 { $$ = build_x_binary_op (GT_EXPR, $$, $3); }
1246 | expr_no_commas EQCOMPARE expr_no_commas
1247 { $$ = build_x_binary_op ($2, $$, $3); }
1248 | expr_no_commas MIN_MAX expr_no_commas
1249 { $$ = build_x_binary_op ($2, $$, $3); }
1250 | expr_no_commas '&' expr_no_commas
1251 { $$ = build_x_binary_op ($2, $$, $3); }
1252 | expr_no_commas '|' expr_no_commas
1253 { $$ = build_x_binary_op ($2, $$, $3); }
1254 | expr_no_commas '^' expr_no_commas
1255 { $$ = build_x_binary_op ($2, $$, $3); }
1256 | expr_no_commas ANDAND expr_no_commas
1257 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1258 | expr_no_commas OROR expr_no_commas
1259 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1260 | expr_no_commas '?' xexpr ':' expr_no_commas
1261 { $$ = build_x_conditional_expr ($$, $3, $5); }
1262 | expr_no_commas '=' expr_no_commas
1263 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1264 if ($$ != error_mark_node)
1265 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1266 | expr_no_commas ASSIGN expr_no_commas
1267 { $$ = build_x_modify_expr ($$, $2, $3); }
1268 | THROW
1269 { $$ = build_throw (NULL_TREE); }
1270 | THROW expr_no_commas
1271 { $$ = build_throw ($2); }
1272 /* These extensions are not defined. The second arg to build_m_component_ref
1273 is old, build_m_component_ref now does an implicit
1274 build_indirect_ref (x, NULL_PTR) on the second argument.
1275 | object '&' expr_no_commas %prec UNARY
1276 { $$ = build_m_component_ref ($$, build_x_unary_op (ADDR_EXPR, $3)); }
1277 | object unop expr_no_commas %prec UNARY
1278 { $$ = build_m_component_ref ($$, build_x_unary_op ($2, $3)); }
1279 | object '(' type_id ')' expr_no_commas %prec UNARY
1280 { tree type = groktypename ($3.t);
1281 $$ = build_m_component_ref ($$, build_c_cast (type, $5)); }
1282 | object primary_no_id %prec UNARY
1283 { $$ = build_m_component_ref ($$, $2); }
1287 notype_unqualified_id:
1288 '~' see_typename identifier
1289 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1290 | '~' see_typename template_type
1291 { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
1292 | template_id
1293 | operator_name
1294 | IDENTIFIER
1295 | PTYPENAME
1296 | NSNAME %prec EMPTY
1299 do_id:
1301 /* If lastiddecl is a TREE_LIST, it's a baselink, which
1302 means that we're in an expression like S::f<int>, so
1303 don't do_identifier; we only do that for unqualified
1304 identifiers. */
1305 if (lastiddecl && TREE_CODE (lastiddecl) != TREE_LIST)
1306 $$ = do_identifier ($<ttype>-1, 1, NULL_TREE);
1307 else
1308 $$ = $<ttype>-1;
1311 template_id:
1312 PFUNCNAME '<' do_id template_arg_list_opt template_close_bracket
1313 { $$ = lookup_template_function ($3, $4); }
1314 | operator_name '<' do_id template_arg_list_opt template_close_bracket
1315 { $$ = lookup_template_function ($3, $4); }
1318 object_template_id:
1319 TEMPLATE identifier '<' template_arg_list_opt template_close_bracket
1320 { $$ = lookup_template_function ($2, $4); }
1321 | TEMPLATE PFUNCNAME '<' template_arg_list_opt template_close_bracket
1322 { $$ = lookup_template_function ($2, $4); }
1323 | TEMPLATE operator_name '<' template_arg_list_opt
1324 template_close_bracket
1325 { $$ = lookup_template_function ($2, $4); }
1328 unqualified_id:
1329 notype_unqualified_id
1330 | TYPENAME
1331 | SELFNAME
1334 expr_or_declarator_intern:
1335 expr_or_declarator
1336 | attributes expr_or_declarator
1338 /* Provide support for '(' attributes '*' declarator ')'
1339 etc */
1340 $$ = decl_tree_cons ($1, $2, NULL_TREE);
1344 expr_or_declarator:
1345 notype_unqualified_id
1346 | '*' expr_or_declarator_intern %prec UNARY
1347 { $$ = build_parse_node (INDIRECT_REF, $2); }
1348 | '&' expr_or_declarator_intern %prec UNARY
1349 { $$ = build_parse_node (ADDR_EXPR, $2); }
1350 | '(' expr_or_declarator_intern ')'
1351 { $$ = $2; }
1354 notype_template_declarator:
1355 IDENTIFIER '<' template_arg_list_opt template_close_bracket
1356 { $$ = lookup_template_function ($1, $3); }
1357 | NSNAME '<' template_arg_list template_close_bracket
1358 { $$ = lookup_template_function ($1, $3); }
1361 direct_notype_declarator:
1362 complex_direct_notype_declarator
1363 /* This precedence declaration is to prefer this reduce
1364 to the Koenig lookup shift in primary, below. I hate yacc. */
1365 | notype_unqualified_id %prec '('
1366 | notype_template_declarator
1367 | '(' expr_or_declarator_intern ')'
1368 { $$ = finish_decl_parsing ($2); }
1371 primary:
1372 notype_unqualified_id
1374 if (TREE_CODE ($1) == BIT_NOT_EXPR)
1375 $$ = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND ($1, 0));
1376 else
1377 $$ = finish_id_expr ($1);
1379 | CONSTANT
1380 | boolean.literal
1381 | string
1383 $$ = combine_strings ($$);
1384 /* combine_strings doesn't set up TYPE_MAIN_VARIANT of
1385 a const array the way we want, so fix it. */
1386 if (flag_const_strings)
1387 TREE_TYPE ($$) = build_cplus_array_type
1388 (TREE_TYPE (TREE_TYPE ($$)),
1389 TYPE_DOMAIN (TREE_TYPE ($$)));
1391 | '(' expr ')'
1392 { $$ = finish_parenthesized_expr ($2); }
1393 | '(' expr_or_declarator_intern ')'
1394 { $2 = reparse_decl_as_expr (NULL_TREE, $2);
1395 $$ = finish_parenthesized_expr ($2); }
1396 | '(' error ')'
1397 { $$ = error_mark_node; }
1398 | '('
1399 { tree scope = current_scope ();
1400 if (!scope || TREE_CODE (scope) != FUNCTION_DECL)
1402 error ("braced-group within expression allowed only inside a function");
1403 YYERROR;
1405 if (pedantic)
1406 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1407 $<ttype>$ = begin_stmt_expr ();
1409 compstmt ')'
1410 { $$ = finish_stmt_expr ($<ttype>2); }
1411 /* Koenig lookup support
1412 We could store lastiddecl in $1 to avoid another lookup,
1413 but that would result in many additional reduce/reduce conflicts. */
1414 | notype_unqualified_id '(' nonnull_exprlist ')'
1415 { $$ = finish_call_expr ($1, $3, 1); }
1416 | notype_unqualified_id LEFT_RIGHT
1417 { $$ = finish_call_expr ($1, NULL_TREE, 1); }
1418 | primary '(' nonnull_exprlist ')'
1419 { $$ = finish_call_expr ($1, $3, 0); }
1420 | primary LEFT_RIGHT
1421 { $$ = finish_call_expr ($1, NULL_TREE, 0); }
1422 | primary '[' expr ']'
1423 { $$ = grok_array_decl ($$, $3); }
1424 | primary PLUSPLUS
1425 { $$ = finish_increment_expr ($1, POSTINCREMENT_EXPR); }
1426 | primary MINUSMINUS
1427 { $$ = finish_increment_expr ($1, POSTDECREMENT_EXPR); }
1428 /* C++ extensions */
1429 | THIS
1430 { $$ = finish_this_expr (); }
1431 | CV_QUALIFIER '(' nonnull_exprlist ')'
1433 /* This is a C cast in C++'s `functional' notation
1434 using the "implicit int" extension so that:
1435 `const (3)' is equivalent to `const int (3)'. */
1436 tree type;
1438 type = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
1439 type = groktypename (build_decl_list (type, NULL_TREE));
1440 $$ = build_functional_cast (type, $3);
1442 | functional_cast
1443 | DYNAMIC_CAST '<' type_id '>' '(' expr ')'
1444 { tree type = groktypename ($3.t);
1445 check_for_new_type ("dynamic_cast", $3);
1446 $$ = build_dynamic_cast (type, $6); }
1447 | STATIC_CAST '<' type_id '>' '(' expr ')'
1448 { tree type = groktypename ($3.t);
1449 check_for_new_type ("static_cast", $3);
1450 $$ = build_static_cast (type, $6); }
1451 | REINTERPRET_CAST '<' type_id '>' '(' expr ')'
1452 { tree type = groktypename ($3.t);
1453 check_for_new_type ("reinterpret_cast", $3);
1454 $$ = build_reinterpret_cast (type, $6); }
1455 | CONST_CAST '<' type_id '>' '(' expr ')'
1456 { tree type = groktypename ($3.t);
1457 check_for_new_type ("const_cast", $3);
1458 $$ = build_const_cast (type, $6); }
1459 | TYPEID '(' expr ')'
1460 { $$ = build_x_typeid ($3); }
1461 | TYPEID '(' type_id ')'
1462 { tree type = groktypename ($3.t);
1463 check_for_new_type ("typeid", $3);
1464 $$ = get_typeid (TYPE_MAIN_VARIANT (type)); }
1465 | global_scope IDENTIFIER
1466 { $$ = do_scoped_id ($2, 1); }
1467 | global_scope template_id
1468 { $$ = $2; }
1469 | global_scope operator_name
1471 got_scope = NULL_TREE;
1472 if (TREE_CODE ($2) == IDENTIFIER_NODE)
1473 $$ = do_scoped_id ($2, 1);
1474 else
1475 $$ = $2;
1477 | overqualified_id %prec HYPERUNARY
1478 { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); }
1479 | overqualified_id '(' nonnull_exprlist ')'
1480 { $$ = finish_qualified_call_expr ($1, $3); }
1481 | overqualified_id LEFT_RIGHT
1482 { $$ = finish_qualified_call_expr ($1, NULL_TREE); }
1483 | object object_template_id %prec UNARY
1485 $$ = build_x_component_ref ($$, $2, NULL_TREE, 1);
1487 | object object_template_id '(' nonnull_exprlist ')'
1488 { $$ = finish_object_call_expr ($2, $1, $4); }
1489 | object object_template_id LEFT_RIGHT
1490 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1491 | object unqualified_id %prec UNARY
1492 { $$ = build_x_component_ref ($$, $2, NULL_TREE, 1); }
1493 | object overqualified_id %prec UNARY
1494 { if (processing_template_decl)
1495 $$ = build_min_nt (COMPONENT_REF, $1, $2);
1496 else
1497 $$ = build_object_ref ($$, OP0 ($2), OP1 ($2)); }
1498 | object unqualified_id '(' nonnull_exprlist ')'
1499 { $$ = finish_object_call_expr ($2, $1, $4); }
1500 | object unqualified_id LEFT_RIGHT
1501 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1502 | object overqualified_id '(' nonnull_exprlist ')'
1503 { $$ = finish_qualified_object_call_expr ($2, $1, $4); }
1504 | object overqualified_id LEFT_RIGHT
1505 { $$ = finish_qualified_object_call_expr ($2, $1, NULL_TREE); }
1506 /* p->int::~int() is valid -- 12.4 */
1507 | object '~' TYPESPEC LEFT_RIGHT
1508 { $$ = finish_pseudo_destructor_call_expr ($1, NULL_TREE, $3); }
1509 | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT
1510 { $$ = finish_pseudo_destructor_call_expr ($1, $2, $5); }
1511 | object error
1513 $$ = error_mark_node;
1517 /* Not needed for now.
1519 primary_no_id:
1520 '(' expr ')'
1521 { $$ = $2; }
1522 | '(' error ')'
1523 { $$ = error_mark_node; }
1524 | '('
1525 { if (current_function_decl == 0)
1527 error ("braced-group within expression allowed only inside a function");
1528 YYERROR;
1530 $<ttype>$ = expand_start_stmt_expr (); }
1531 compstmt ')'
1532 { if (pedantic)
1533 pedwarn ("ANSI C++ forbids braced-groups within expressions");
1534 $$ = expand_end_stmt_expr ($<ttype>2); }
1535 | primary_no_id '(' nonnull_exprlist ')'
1536 { $$ = build_x_function_call ($$, $3, current_class_ref); }
1537 | primary_no_id LEFT_RIGHT
1538 { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); }
1539 | primary_no_id '[' expr ']'
1540 { goto do_array; }
1541 | primary_no_id PLUSPLUS
1542 { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1543 | primary_no_id MINUSMINUS
1544 { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1545 | SCOPE IDENTIFIER
1546 { goto do_scoped_id; }
1547 | SCOPE operator_name
1548 { if (TREE_CODE ($2) == IDENTIFIER_NODE)
1549 goto do_scoped_id;
1550 goto do_scoped_operator;
1555 new:
1557 { $$ = 0; }
1558 | global_scope NEW
1559 { got_scope = NULL_TREE; $$ = 1; }
1562 delete:
1563 DELETE
1564 { $$ = 0; }
1565 | global_scope delete
1566 { got_scope = NULL_TREE; $$ = 1; }
1569 boolean.literal:
1570 CXX_TRUE
1571 { $$ = boolean_true_node; }
1572 | CXX_FALSE
1573 { $$ = boolean_false_node; }
1576 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
1577 string:
1578 STRING
1579 | string STRING
1580 { $$ = chainon ($$, $2); }
1583 nodecls:
1584 /* empty */
1586 if (! current_function_parms_stored)
1587 store_parm_decls ();
1588 setup_vtbl_ptr ();
1592 object:
1593 primary '.'
1594 { got_object = TREE_TYPE ($$); }
1595 | primary POINTSAT
1597 $$ = build_x_arrow ($$);
1598 got_object = TREE_TYPE ($$);
1602 decl:
1603 typespec initdecls ';'
1605 if ($1.t && IS_AGGR_TYPE_CODE (TREE_CODE ($1.t)))
1606 note_got_semicolon ($1.t);
1608 | typed_declspecs initdecls ';'
1610 note_list_got_semicolon ($1.t);
1612 | declmods notype_initdecls ';'
1614 | typed_declspecs ';'
1616 shadow_tag ($1.t);
1617 note_list_got_semicolon ($1.t);
1619 | declmods ';'
1620 { warning ("empty declaration"); }
1621 | extension decl
1622 { pedantic = $1; }
1625 /* Any kind of declarator (thus, all declarators allowed
1626 after an explicit typespec). */
1628 declarator:
1629 after_type_declarator %prec EMPTY
1630 | notype_declarator %prec EMPTY
1633 /* This is necessary to postpone reduction of `int()()()()'. */
1634 fcast_or_absdcl:
1635 LEFT_RIGHT %prec EMPTY
1636 { $$ = make_call_declarator (NULL_TREE, empty_parms (),
1637 NULL_TREE, NULL_TREE); }
1638 | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
1639 { $$ = make_call_declarator ($$, empty_parms (), NULL_TREE,
1640 NULL_TREE); }
1643 /* ANSI type-id (8.1) */
1644 type_id:
1645 typed_typespecs absdcl
1646 { $$.t = build_decl_list ($1.t, $2);
1647 $$.new_type_flag = $1.new_type_flag; }
1648 | nonempty_cv_qualifiers absdcl
1649 { $$.t = build_decl_list ($1.t, $2);
1650 $$.new_type_flag = $1.new_type_flag; }
1651 | typespec absdcl
1652 { $$.t = build_decl_list (build_decl_list (NULL_TREE, $1.t),
1653 $2);
1654 $$.new_type_flag = $1.new_type_flag; }
1655 | typed_typespecs %prec EMPTY
1656 { $$.t = build_decl_list ($1.t, NULL_TREE);
1657 $$.new_type_flag = $1.new_type_flag; }
1658 | nonempty_cv_qualifiers %prec EMPTY
1659 { $$.t = build_decl_list ($1.t, NULL_TREE);
1660 $$.new_type_flag = $1.new_type_flag; }
1663 /* Declspecs which contain at least one type specifier or typedef name.
1664 (Just `const' or `volatile' is not enough.)
1665 A typedef'd name following these is taken as a name to be declared.
1666 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1668 typed_declspecs:
1669 typed_typespecs %prec EMPTY
1670 | typed_declspecs1
1673 typed_declspecs1:
1674 declmods typespec
1675 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1);
1676 $$.new_type_flag = $2.new_type_flag; }
1677 | typespec reserved_declspecs %prec HYPERUNARY
1678 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1679 $$.new_type_flag = $1.new_type_flag; }
1680 | typespec reserved_typespecquals reserved_declspecs
1681 { $$.t = decl_tree_cons (NULL_TREE, $1.t, chainon ($2, $3));
1682 $$.new_type_flag = $1.new_type_flag; }
1683 | declmods typespec reserved_declspecs
1684 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1685 $$.new_type_flag = $2.new_type_flag; }
1686 | declmods typespec reserved_typespecquals
1687 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1));
1688 $$.new_type_flag = $2.new_type_flag; }
1689 | declmods typespec reserved_typespecquals reserved_declspecs
1690 { $$.t = decl_tree_cons (NULL_TREE, $2.t,
1691 chainon ($3, chainon ($4, $1)));
1692 $$.new_type_flag = $2.new_type_flag; }
1695 reserved_declspecs:
1696 SCSPEC
1697 { if (extra_warnings)
1698 warning ("`%s' is not at beginning of declaration",
1699 IDENTIFIER_POINTER ($$));
1700 $$ = build_decl_list (NULL_TREE, $$); }
1701 | reserved_declspecs typespecqual_reserved
1702 { $$ = decl_tree_cons (NULL_TREE, $2.t, $$); }
1703 | reserved_declspecs SCSPEC
1704 { if (extra_warnings)
1705 warning ("`%s' is not at beginning of declaration",
1706 IDENTIFIER_POINTER ($2));
1707 $$ = decl_tree_cons (NULL_TREE, $2, $$); }
1708 | reserved_declspecs attributes
1709 { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
1710 | attributes
1711 { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
1714 /* List of just storage classes and type modifiers.
1715 A declaration can start with just this, but then it cannot be used
1716 to redeclare a typedef-name.
1717 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1719 /* We use hash_tree_cons for lists of typeless declspecs so that they end
1720 up on a persistent obstack. Otherwise, they could appear at the
1721 beginning of something like
1723 static const struct { int foo () { } } b;
1725 and would be discarded after we finish compiling foo. We don't need to
1726 worry once we see a type. */
1728 declmods:
1729 nonempty_cv_qualifiers %prec EMPTY
1730 { $$ = $1.t; TREE_STATIC ($$) = 1; }
1731 | SCSPEC
1732 { $$ = hash_tree_cons (NULL_TREE, $$, NULL_TREE); }
1733 | declmods CV_QUALIFIER
1734 { $$ = hash_tree_cons (NULL_TREE, $2, $$);
1735 TREE_STATIC ($$) = 1; }
1736 | declmods SCSPEC
1737 { if (extra_warnings && TREE_STATIC ($$))
1738 warning ("`%s' is not at beginning of declaration",
1739 IDENTIFIER_POINTER ($2));
1740 $$ = hash_tree_cons (NULL_TREE, $2, $$);
1741 TREE_STATIC ($$) = TREE_STATIC ($1); }
1742 | declmods attributes
1743 { $$ = hash_tree_cons ($2, NULL_TREE, $1); }
1744 | attributes %prec EMPTY
1745 { $$ = hash_tree_cons ($1, NULL_TREE, NULL_TREE); }
1748 /* Used instead of declspecs where storage classes are not allowed
1749 (that is, for typenames and structure components).
1751 C++ can takes storage classes for structure components.
1752 Don't accept a typedef-name if anything but a modifier precedes it. */
1754 typed_typespecs:
1755 typespec %prec EMPTY
1756 { $$.t = build_decl_list (NULL_TREE, $1.t);
1757 $$.new_type_flag = $1.new_type_flag; }
1758 | nonempty_cv_qualifiers typespec
1759 { $$.t = decl_tree_cons (NULL_TREE, $2.t, $1.t);
1760 $$.new_type_flag = $2.new_type_flag; }
1761 | typespec reserved_typespecquals
1762 { $$.t = decl_tree_cons (NULL_TREE, $1.t, $2);
1763 $$.new_type_flag = $1.new_type_flag; }
1764 | nonempty_cv_qualifiers typespec reserved_typespecquals
1765 { $$.t = decl_tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1766 $$.new_type_flag = $1.new_type_flag; }
1769 reserved_typespecquals:
1770 typespecqual_reserved
1771 { $$ = build_decl_list (NULL_TREE, $1.t); }
1772 | reserved_typespecquals typespecqual_reserved
1773 { $$ = decl_tree_cons (NULL_TREE, $2.t, $1); }
1776 /* A typespec (but not a type qualifier).
1777 Once we have seen one of these in a declaration,
1778 if a typedef name appears then it is being redeclared. */
1780 typespec:
1781 structsp
1782 | TYPESPEC %prec EMPTY
1783 { $$.t = $1; $$.new_type_flag = 0; }
1784 | complete_type_name
1785 { $$.t = $1; $$.new_type_flag = 0; }
1786 | TYPEOF '(' expr ')'
1787 { $$.t = finish_typeof ($3);
1788 $$.new_type_flag = 0; }
1789 | TYPEOF '(' type_id ')'
1790 { $$.t = groktypename ($3.t);
1791 $$.new_type_flag = 0; }
1792 | SIGOF '(' expr ')'
1793 { tree type = TREE_TYPE ($3);
1795 $$.new_type_flag = 0;
1796 if (IS_AGGR_TYPE (type))
1798 sorry ("sigof type specifier");
1799 $$.t = type;
1801 else
1803 error ("`sigof' applied to non-aggregate expression");
1804 $$.t = error_mark_node;
1807 | SIGOF '(' type_id ')'
1808 { tree type = groktypename ($3.t);
1810 $$.new_type_flag = 0;
1811 if (IS_AGGR_TYPE (type))
1813 sorry ("sigof type specifier");
1814 $$.t = type;
1816 else
1818 error("`sigof' applied to non-aggregate type");
1819 $$.t = error_mark_node;
1824 /* A typespec that is a reserved word, or a type qualifier. */
1826 typespecqual_reserved:
1827 TYPESPEC
1828 { $$.t = $1; $$.new_type_flag = 0; }
1829 | CV_QUALIFIER
1830 { $$.t = $1; $$.new_type_flag = 0; }
1831 | structsp
1834 initdecls:
1835 initdcl0
1836 | initdecls ',' initdcl
1837 { check_multiple_declarators (); }
1840 notype_initdecls:
1841 notype_initdcl0
1842 | notype_initdecls ',' initdcl
1843 { check_multiple_declarators (); }
1846 nomods_initdecls:
1847 nomods_initdcl0
1848 | nomods_initdecls ',' initdcl
1849 { check_multiple_declarators (); }
1852 maybeasm:
1853 /* empty */
1854 { $$ = NULL_TREE; }
1855 | asm_keyword '(' string ')'
1856 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); $$ = $3; }
1859 initdcl:
1860 declarator maybeasm maybe_attribute '='
1861 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1,
1862 $3, prefix_attributes); }
1863 init
1864 /* Note how the declaration of the variable is in effect while its init is parsed! */
1865 { cp_finish_decl ($<ttype>5, $6, $2, LOOKUP_ONLYCONVERTING); }
1866 | declarator maybeasm maybe_attribute
1867 { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 0,
1868 $3, prefix_attributes);
1869 cp_finish_decl ($<ttype>$, NULL_TREE, $2, 0); }
1872 /* This rule assumes a certain configuration of the parser stack.
1873 In particular, $0, the element directly before the beginning of
1874 this rule on the stack, must be a maybeasm. $-1 must be a
1875 declarator or notype_declarator. And $-2 must be some declmods
1876 or declspecs. We can't move the maybeasm into this rule because
1877 we need that reduce so we prefer fn.def1 when appropriate. */
1878 initdcl0_innards:
1879 maybe_attribute '='
1880 { parse_decl ($<ttype>-1, $<ttype>-2, $1, 1, &$<ttype>$); }
1881 /* Note how the declaration of the variable is in effect
1882 while its init is parsed! */
1883 init
1884 { cp_finish_decl ($<ttype>3, $4, $<ttype>0,
1885 LOOKUP_ONLYCONVERTING); }
1886 | maybe_attribute
1887 { tree d;
1888 parse_decl ($<ttype>-1, $<ttype>-2, $1, 0, &d);
1889 cp_finish_decl (d, NULL_TREE, $<ttype>0, 0); }
1892 initdcl0:
1893 declarator maybeasm initdcl0_innards
1897 notype_initdcl0:
1898 notype_declarator maybeasm initdcl0_innards
1902 nomods_initdcl0:
1903 notype_declarator maybeasm
1904 { /* Set things up as initdcl0_innards expects. */
1905 $<ttype>2 = $1;
1906 $1 = NULL_TREE; }
1907 initdcl0_innards
1909 | constructor_declarator maybeasm maybe_attribute
1910 { tree d;
1911 parse_decl($1, NULL_TREE, $3, 0, &d);
1912 cp_finish_decl (d, NULL_TREE, $2, 0); }
1915 /* the * rules are dummies to accept the Apollo extended syntax
1916 so that the header files compile. */
1917 maybe_attribute:
1918 /* empty */
1919 { $$ = NULL_TREE; }
1920 | attributes
1921 { $$ = $1; }
1924 attributes:
1925 attribute
1926 { $$ = $1; }
1927 | attributes attribute
1928 { $$ = chainon ($1, $2); }
1931 attribute:
1932 ATTRIBUTE '(' '(' attribute_list ')' ')'
1933 { $$ = $4; }
1936 attribute_list:
1937 attrib
1938 { $$ = $1; }
1939 | attribute_list ',' attrib
1940 { $$ = chainon ($1, $3); }
1943 attrib:
1944 /* empty */
1945 { $$ = NULL_TREE; }
1946 | any_word
1947 { $$ = build_tree_list ($1, NULL_TREE); }
1948 | any_word '(' IDENTIFIER ')'
1949 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
1950 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
1951 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
1952 | any_word '(' nonnull_exprlist ')'
1953 { $$ = build_tree_list ($1, $3); }
1956 /* This still leaves out most reserved keywords,
1957 shouldn't we include them? */
1959 any_word:
1960 identifier
1961 | SCSPEC
1962 | TYPESPEC
1963 | CV_QUALIFIER
1966 /* A nonempty list of identifiers, including typenames. */
1967 identifiers_or_typenames:
1968 identifier
1969 { $$ = build_tree_list (NULL_TREE, $1); }
1970 | identifiers_or_typenames ',' identifier
1971 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
1974 maybe_init:
1975 /* empty */ %prec EMPTY
1976 { $$ = NULL_TREE; }
1977 | '=' init
1978 { $$ = $2; }
1980 /* If we are processing a template, we don't want to expand this
1981 initializer yet. */
1983 init:
1984 expr_no_commas %prec '='
1985 | '{' '}'
1986 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
1987 TREE_HAS_CONSTRUCTOR ($$) = 1; }
1988 | '{' initlist '}'
1989 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
1990 TREE_HAS_CONSTRUCTOR ($$) = 1; }
1991 | '{' initlist ',' '}'
1992 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
1993 TREE_HAS_CONSTRUCTOR ($$) = 1; }
1994 | error
1995 { $$ = NULL_TREE; }
1998 /* This chain is built in reverse order,
1999 and put in forward order where initlist is used. */
2000 initlist:
2001 init
2002 { $$ = build_tree_list (NULL_TREE, $$); }
2003 | initlist ',' init
2004 { $$ = tree_cons (NULL_TREE, $3, $$); }
2005 /* These are for labeled elements. */
2006 | '[' expr_no_commas ']' init
2007 { $$ = build_expr_list ($2, $4); }
2008 | identifier ':' init
2009 { $$ = build_expr_list ($$, $3); }
2010 | initlist ',' identifier ':' init
2011 { $$ = tree_cons ($3, $5, $$); }
2014 fn.defpen:
2015 PRE_PARSED_FUNCTION_DECL
2016 { start_function (NULL_TREE, $1->fndecl, NULL_TREE,
2017 (SF_DEFAULT | SF_PRE_PARSED
2018 | SF_INCLASS_INLINE));
2019 reinit_parse_for_function (); }
2021 pending_inline:
2022 fn.defpen maybe_return_init ctor_initializer_opt compstmt_or_error
2024 expand_body (finish_function (lineno, (int)$3 | 2));
2025 process_next_inline ($1);
2027 | fn.defpen maybe_return_init function_try_block
2029 expand_body (finish_function (lineno, (int)$3 | 2));
2030 process_next_inline ($1);
2032 | fn.defpen maybe_return_init error
2034 finish_function (lineno, 2);
2035 process_next_inline ($1); }
2038 pending_inlines:
2039 /* empty */
2040 | pending_inlines pending_inline eat_saved_input
2043 /* A regurgitated default argument. The value of DEFARG_MARKER will be
2044 the TREE_LIST node for the parameter in question. */
2045 defarg_again:
2046 DEFARG_MARKER expr_no_commas END_OF_SAVED_INPUT
2047 { replace_defarg ($1, $2); }
2048 | DEFARG_MARKER error END_OF_SAVED_INPUT
2049 { replace_defarg ($1, error_mark_node); }
2051 pending_defargs:
2052 /* empty */ %prec EMPTY
2053 | pending_defargs defarg_again
2054 { do_pending_defargs (); }
2055 | pending_defargs error
2056 { do_pending_defargs (); }
2059 structsp:
2060 ENUM identifier '{'
2061 { $<ttype>$ = current_enum_type;
2062 current_enum_type = start_enum ($2); }
2063 enumlist_opt '}'
2064 { $$.t = finish_enum (current_enum_type);
2065 $$.new_type_flag = 1;
2066 current_enum_type = $<ttype>4;
2067 check_for_missing_semicolon ($$.t); }
2068 | ENUM '{'
2069 { $<ttype>$ = current_enum_type;
2070 current_enum_type = start_enum (make_anon_name ()); }
2071 enumlist_opt '}'
2072 { $$.t = finish_enum (current_enum_type);
2073 $$.new_type_flag = 1;
2074 current_enum_type = $<ttype>3;
2075 check_for_missing_semicolon ($$.t); }
2076 | ENUM identifier
2077 { $$.t = xref_tag (enum_type_node, $2, 1);
2078 $$.new_type_flag = 0; }
2079 | ENUM complex_type_name
2080 { $$.t = xref_tag (enum_type_node, $2, 1);
2081 $$.new_type_flag = 0; }
2082 | TYPENAME_KEYWORD typename_sub
2083 { $$.t = $2;
2084 $$.new_type_flag = 0;
2085 if (!processing_template_decl)
2086 cp_pedwarn ("using `typename' outside of template"); }
2087 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2088 | class_head '{'
2089 { $1.t = begin_class_definition ($1.t); }
2090 opt.component_decl_list '}' maybe_attribute
2092 int semi;
2094 if (yychar == YYEMPTY)
2095 yychar = YYLEX;
2096 semi = yychar == ';';
2098 $<ttype>$ = finish_class_definition ($1.t, $6, semi,
2099 $1.new_type_flag);
2101 pending_defargs
2103 begin_inline_definitions ();
2105 pending_inlines
2107 finish_inline_definitions ();
2108 $$.t = $<ttype>7;
2109 $$.new_type_flag = 1;
2111 | class_head %prec EMPTY
2113 if ($1.new_type_flag && $1.t != error_mark_node)
2114 pop_scope (CP_DECL_CONTEXT (TYPE_MAIN_DECL ($1.t)));
2115 $$.new_type_flag = 0;
2116 if ($1.t == error_mark_node)
2117 $$.t = $1.t;
2118 else if (TYPE_BINFO ($1.t) == NULL_TREE)
2120 cp_error ("%T is not a class type", $1.t);
2121 $$.t = error_mark_node;
2123 else
2125 $$.t = $1.t;
2126 /* struct B: public A; is not accepted by the WP grammar. */
2127 if (TYPE_BINFO_BASETYPES ($$.t) && !TYPE_SIZE ($$.t)
2128 && ! TYPE_BEING_DEFINED ($$.t))
2129 cp_error ("base clause without member specification for `%#T'",
2130 $$.t);
2135 maybecomma:
2136 /* empty */
2137 | ','
2140 maybecomma_warn:
2141 /* empty */
2142 | ','
2143 { if (pedantic && !in_system_header)
2144 pedwarn ("comma at end of enumerator list"); }
2147 aggr:
2148 AGGR
2149 | aggr SCSPEC
2150 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2151 | aggr TYPESPEC
2152 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2153 | aggr CV_QUALIFIER
2154 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2155 | aggr AGGR
2156 { error ("no body nor ';' separates two class, struct or union declarations"); }
2157 | aggr attributes
2158 { $$ = build_decl_list ($2, $1); }
2161 named_class_head_sans_basetype:
2162 aggr identifier
2164 current_aggr = $1;
2165 $$ = $2;
2169 named_class_head_sans_basetype_defn:
2170 aggr identifier_defn %prec EMPTY
2171 { current_aggr = $$; $$ = $2; }
2172 | named_class_head_sans_basetype '{'
2173 { yyungetc ('{', 1); }
2174 | named_class_head_sans_basetype ':'
2175 { yyungetc (':', 1); }
2178 named_complex_class_head_sans_basetype:
2179 aggr nested_name_specifier identifier
2181 current_aggr = $1;
2182 $$.t = handle_class_head ($1, $2, $3);
2183 $$.new_type_flag = 1;
2185 | aggr global_scope nested_name_specifier identifier
2187 current_aggr = $1;
2188 $$.t = handle_class_head ($1, $3, $4);
2189 $$.new_type_flag = 1;
2191 | aggr global_scope identifier
2193 current_aggr = $1;
2194 $$.t = handle_class_head ($1, NULL_TREE, $3);
2195 $$.new_type_flag = 1;
2197 | aggr apparent_template_type
2199 current_aggr = $1;
2200 $$.t = $2;
2201 $$.new_type_flag = 0;
2203 | aggr nested_name_specifier apparent_template_type
2205 current_aggr = $1;
2206 $$.t = $3;
2207 if (CP_DECL_CONTEXT ($$.t))
2208 push_scope (CP_DECL_CONTEXT ($$.t));
2209 $$.new_type_flag = 1;
2213 named_class_head:
2214 named_class_head_sans_basetype %prec EMPTY
2216 $$.t = xref_tag (current_aggr, $1, 1);
2217 $$.new_type_flag = 0;
2219 | named_class_head_sans_basetype_defn
2220 { $<ttype>$ = xref_tag (current_aggr, $1, 0); }
2221 /* Class name is unqualified, so we look for base classes
2222 in the current scope. */
2223 maybe_base_class_list %prec EMPTY
2225 $$.t = $<ttype>2;
2226 $$.new_type_flag = 0;
2227 if ($3)
2228 xref_basetypes (current_aggr, $1, $<ttype>2, $3);
2230 | named_complex_class_head_sans_basetype
2231 maybe_base_class_list
2233 if ($1.t != error_mark_node)
2235 $$.t = TREE_TYPE ($1.t);
2236 $$.new_type_flag = $1.new_type_flag;
2237 if (current_aggr == union_type_node
2238 && TREE_CODE ($$.t) != UNION_TYPE)
2239 cp_pedwarn ("`union' tag used in declaring `%#T'",
2240 $$.t);
2241 else if (TREE_CODE ($$.t) == UNION_TYPE
2242 && current_aggr != union_type_node)
2243 cp_pedwarn ("non-`union' tag used in declaring `%#T'", $$);
2244 else if (TREE_CODE ($$.t) == RECORD_TYPE)
2245 /* We might be specializing a template with a different
2246 class-key; deal. */
2247 CLASSTYPE_DECLARED_CLASS ($$.t)
2248 = (current_aggr == class_type_node);
2249 if ($2)
2251 maybe_process_partial_specialization ($$.t);
2252 xref_basetypes (current_aggr, $1.t, $$.t, $2);
2258 unnamed_class_head:
2259 aggr '{'
2260 { $$ = xref_tag ($$, make_anon_name (), 0);
2261 yyungetc ('{', 1); }
2264 /* The tree output of this nonterminal a declarationf or the type
2265 named. If NEW_TYPE_FLAG is set, then the name used in this
2266 class-head was explicitly qualified, e.g.: `struct X::Y'. We have
2267 already called push_scope for X. */
2268 class_head:
2269 unnamed_class_head
2271 $$.t = $1;
2272 $$.new_type_flag = 0;
2274 | named_class_head
2277 maybe_base_class_list:
2278 /* empty */ %prec EMPTY
2279 { $$ = NULL_TREE; }
2280 | ':' see_typename %prec EMPTY
2281 { yyungetc(':', 1); $$ = NULL_TREE; }
2282 | ':' see_typename base_class_list %prec EMPTY
2283 { $$ = $3; }
2286 base_class_list:
2287 base_class
2288 | base_class_list ',' see_typename base_class
2289 { $$ = chainon ($$, $4); }
2292 base_class:
2293 base_class.1
2294 { $$ = finish_base_specifier (access_default_node, $1); }
2295 | base_class_access_list see_typename base_class.1
2296 { $$ = finish_base_specifier ($1, $3); }
2299 base_class.1:
2300 typename_sub
2301 { if ($$ != error_mark_node) $$ = TYPE_MAIN_DECL ($1); }
2302 | nonnested_type
2305 base_class_access_list:
2306 VISSPEC see_typename
2307 | SCSPEC see_typename
2308 { if ($1 != ridpointers[(int)RID_VIRTUAL])
2309 cp_error ("`%D' access", $1);
2310 $$ = access_default_virtual_node; }
2311 | base_class_access_list VISSPEC see_typename
2313 if ($1 != access_default_virtual_node)
2314 error ("multiple access specifiers");
2315 else if ($2 == access_public_node)
2316 $$ = access_public_virtual_node;
2317 else if ($2 == access_protected_node)
2318 $$ = access_protected_virtual_node;
2319 else /* $2 == access_private_node */
2320 $$ = access_private_virtual_node;
2322 | base_class_access_list SCSPEC see_typename
2323 { if ($2 != ridpointers[(int)RID_VIRTUAL])
2324 cp_error ("`%D' access", $2);
2325 else if ($$ == access_public_node)
2326 $$ = access_public_virtual_node;
2327 else if ($$ == access_protected_node)
2328 $$ = access_protected_virtual_node;
2329 else if ($$ == access_private_node)
2330 $$ = access_private_virtual_node;
2331 else
2332 error ("multiple `virtual' specifiers");
2336 opt.component_decl_list:
2337 | component_decl_list
2338 | opt.component_decl_list access_specifier component_decl_list
2339 | opt.component_decl_list access_specifier
2342 access_specifier:
2343 VISSPEC ':'
2345 current_access_specifier = $1;
2349 /* Note: we no longer warn about the semicolon after a component_decl_list.
2350 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2351 component_decl_list:
2352 component_decl
2354 finish_member_declaration ($1);
2356 | component_decl_list component_decl
2358 finish_member_declaration ($2);
2362 component_decl:
2363 component_decl_1 ';'
2364 | component_decl_1 '}'
2365 { error ("missing ';' before right brace");
2366 yyungetc ('}', 0); }
2367 /* C++: handle constructors, destructors and inline functions */
2368 /* note that INLINE is like a TYPESPEC */
2369 | fn.def2 ':' /* base_init compstmt */
2370 { $$ = finish_method ($$); }
2371 | fn.def2 TRY /* base_init compstmt */
2372 { $$ = finish_method ($$); }
2373 | fn.def2 RETURN_KEYWORD /* base_init compstmt */
2374 { $$ = finish_method ($$); }
2375 | fn.def2 '{' /* nodecls compstmt */
2376 { $$ = finish_method ($$); }
2377 | ';'
2378 { $$ = NULL_TREE; }
2379 | extension component_decl
2380 { $$ = $2;
2381 pedantic = $1; }
2382 | template_header component_decl
2384 if ($2)
2385 $$ = finish_member_template_decl ($2);
2386 else
2387 /* The component was already processed. */
2388 $$ = NULL_TREE;
2390 finish_template_decl ($1);
2392 | template_header typed_declspecs ';'
2394 $$ = finish_member_class_template ($2.t);
2395 finish_template_decl ($1);
2399 component_decl_1:
2400 /* Do not add a "typed_declspecs declarator" rule here for
2401 speed; we need to call grok_x_components for enums, so the
2402 speedup would be insignificant. */
2403 typed_declspecs components
2405 /* Most of the productions for component_decl only
2406 allow the creation of one new member, so we call
2407 finish_member_declaration in component_decl_list.
2408 For this rule and the next, however, there can be
2409 more than one member, e.g.:
2411 int i, j;
2413 and we need the first member to be fully
2414 registered before the second is processed.
2415 Therefore, the rules for components take care of
2416 this processing. To avoid registering the
2417 components more than once, we send NULL_TREE up
2418 here; that lets finish_member_declaration know
2419 that there is nothing to do. */
2420 if (!$2)
2421 grok_x_components ($1.t);
2422 $$ = NULL_TREE;
2424 | declmods notype_components
2426 if (!$2)
2427 grok_x_components ($1);
2428 $$ = NULL_TREE;
2430 | notype_declarator maybeasm maybe_attribute maybe_init
2431 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2432 build_tree_list ($3, NULL_TREE)); }
2433 | constructor_declarator maybeasm maybe_attribute maybe_init
2434 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2435 build_tree_list ($3, NULL_TREE)); }
2436 | ':' expr_no_commas
2437 { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
2438 | error
2439 { $$ = NULL_TREE; }
2441 /* These rules introduce a reduce/reduce conflict; in
2442 typedef int foo, bar;
2443 class A {
2444 foo (bar);
2446 should "A::foo" be declared as a function or "A::bar" as a data
2447 member? In other words, is "bar" an after_type_declarator or a
2448 parmlist? */
2449 | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2450 { tree specs, attrs;
2451 split_specs_attrs ($1, &specs, &attrs);
2452 $$ = grokfield ($2, specs, $5, $3,
2453 build_tree_list ($4, attrs)); }
2454 | component_constructor_declarator maybeasm maybe_attribute maybe_init
2455 { $$ = grokfield ($$, NULL_TREE, $4, $2,
2456 build_tree_list ($3, NULL_TREE)); }
2457 | using_decl
2458 { $$ = do_class_using_decl ($1); }
2460 /* The case of exactly one component is handled directly by component_decl. */
2461 /* ??? Huh? ^^^ */
2462 components:
2463 /* empty: possibly anonymous */
2464 { $$ = 0; }
2465 | component_declarator0
2467 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2468 $1 = finish_member_template_decl ($1);
2469 finish_member_declaration ($1);
2470 $$ = 1;
2472 | components ',' component_declarator
2474 check_multiple_declarators ();
2475 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2476 $3 = finish_member_template_decl ($3);
2477 finish_member_declaration ($3);
2478 $$ = 2;
2482 notype_components:
2483 /* empty: possibly anonymous */
2484 { $$ = 0; }
2485 | notype_component_declarator0
2487 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2488 $1 = finish_member_template_decl ($1);
2489 finish_member_declaration ($1);
2490 $$ = 1;
2492 | notype_components ',' notype_component_declarator
2494 check_multiple_declarators ();
2495 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2496 $3 = finish_member_template_decl ($3);
2497 finish_member_declaration ($3);
2498 $$ = 2;
2502 component_declarator0:
2503 after_type_component_declarator0
2504 | notype_component_declarator0
2507 component_declarator:
2508 after_type_component_declarator
2509 | notype_component_declarator
2512 after_type_component_declarator0:
2513 after_type_declarator maybeasm maybe_attribute maybe_init
2514 { split_specs_attrs ($<ttype>0, &current_declspecs,
2515 &prefix_attributes);
2516 $<ttype>0 = current_declspecs;
2517 $$ = grokfield ($$, current_declspecs, $4, $2,
2518 build_tree_list ($3, prefix_attributes)); }
2519 | TYPENAME ':' expr_no_commas maybe_attribute
2520 { split_specs_attrs ($<ttype>0, &current_declspecs,
2521 &prefix_attributes);
2522 $<ttype>0 = current_declspecs;
2523 $$ = grokbitfield ($$, current_declspecs, $3);
2524 cplus_decl_attributes ($$, $4, prefix_attributes); }
2527 notype_component_declarator0:
2528 notype_declarator maybeasm maybe_attribute maybe_init
2529 { split_specs_attrs ($<ttype>0, &current_declspecs,
2530 &prefix_attributes);
2531 $<ttype>0 = current_declspecs;
2532 $$ = grokfield ($$, current_declspecs, $4, $2,
2533 build_tree_list ($3, prefix_attributes)); }
2534 | constructor_declarator maybeasm maybe_attribute maybe_init
2535 { split_specs_attrs ($<ttype>0, &current_declspecs,
2536 &prefix_attributes);
2537 $<ttype>0 = current_declspecs;
2538 $$ = grokfield ($$, current_declspecs, $4, $2,
2539 build_tree_list ($3, prefix_attributes)); }
2540 | IDENTIFIER ':' expr_no_commas maybe_attribute
2541 { split_specs_attrs ($<ttype>0, &current_declspecs,
2542 &prefix_attributes);
2543 $<ttype>0 = current_declspecs;
2544 $$ = grokbitfield ($$, current_declspecs, $3);
2545 cplus_decl_attributes ($$, $4, prefix_attributes); }
2546 | ':' expr_no_commas maybe_attribute
2547 { split_specs_attrs ($<ttype>0, &current_declspecs,
2548 &prefix_attributes);
2549 $<ttype>0 = current_declspecs;
2550 $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2551 cplus_decl_attributes ($$, $3, prefix_attributes); }
2554 after_type_component_declarator:
2555 after_type_declarator maybeasm maybe_attribute maybe_init
2556 { $$ = grokfield ($$, current_declspecs, $4, $2,
2557 build_tree_list ($3, prefix_attributes)); }
2558 | TYPENAME ':' expr_no_commas maybe_attribute
2559 { $$ = grokbitfield ($$, current_declspecs, $3);
2560 cplus_decl_attributes ($$, $4, prefix_attributes); }
2563 notype_component_declarator:
2564 notype_declarator maybeasm maybe_attribute maybe_init
2565 { $$ = grokfield ($$, current_declspecs, $4, $2,
2566 build_tree_list ($3, prefix_attributes)); }
2567 | IDENTIFIER ':' expr_no_commas maybe_attribute
2568 { $$ = grokbitfield ($$, current_declspecs, $3);
2569 cplus_decl_attributes ($$, $4, prefix_attributes); }
2570 | ':' expr_no_commas maybe_attribute
2571 { $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
2572 cplus_decl_attributes ($$, $3, prefix_attributes); }
2575 enumlist_opt:
2576 enumlist maybecomma_warn
2577 | maybecomma_warn
2580 /* We chain the enumerators in reverse order.
2581 Because of the way enums are built, the order is
2582 insignificant. Take advantage of this fact. */
2584 enumlist:
2585 enumerator
2586 | enumlist ',' enumerator
2589 enumerator:
2590 identifier
2591 { build_enumerator ($1, NULL_TREE, current_enum_type); }
2592 | identifier '=' expr_no_commas
2593 { build_enumerator ($1, $3, current_enum_type); }
2596 /* ANSI new-type-id (5.3.4) */
2597 new_type_id:
2598 type_specifier_seq new_declarator
2599 { $$.t = build_decl_list ($1.t, $2);
2600 $$.new_type_flag = $1.new_type_flag; }
2601 | type_specifier_seq %prec EMPTY
2602 { $$.t = build_decl_list ($1.t, NULL_TREE);
2603 $$.new_type_flag = $1.new_type_flag; }
2604 /* GNU extension to allow arrays of arbitrary types with
2605 non-constant dimension. */
2606 | '(' type_id ')' '[' expr ']'
2608 if (pedantic)
2609 pedwarn ("ANSI C++ forbids array dimensions with parenthesized type in new");
2610 $$.t = build_parse_node (ARRAY_REF, TREE_VALUE ($2.t), $5);
2611 $$.t = build_decl_list (TREE_PURPOSE ($2.t), $$.t);
2612 $$.new_type_flag = $2.new_type_flag;
2616 cv_qualifiers:
2617 /* empty */ %prec EMPTY
2618 { $$ = NULL_TREE; }
2619 | cv_qualifiers CV_QUALIFIER
2620 { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
2623 nonempty_cv_qualifiers:
2624 CV_QUALIFIER
2625 { $$.t = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
2626 $$.new_type_flag = 0; }
2627 | nonempty_cv_qualifiers CV_QUALIFIER
2628 { $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
2629 $$.new_type_flag = $1.new_type_flag; }
2632 /* These rules must follow the rules for function declarations
2633 and component declarations. That way, longer rules are preferred. */
2635 /* An expression which will not live on the momentary obstack. */
2636 maybe_parmlist:
2637 '(' nonnull_exprlist ')'
2638 { $$ = $2; }
2639 | '(' parmlist ')'
2640 { $$ = $2; }
2641 | LEFT_RIGHT
2642 { $$ = empty_parms (); }
2643 | '(' error ')'
2644 { $$ = NULL_TREE; }
2647 /* A declarator that is allowed only after an explicit typespec. */
2649 after_type_declarator_intern:
2650 after_type_declarator
2651 | attributes after_type_declarator
2653 /* Provide support for '(' attributes '*' declarator ')'
2654 etc */
2655 $$ = decl_tree_cons ($1, $2, NULL_TREE);
2659 /* may all be followed by prec '.' */
2660 after_type_declarator:
2661 '*' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2662 { $$ = make_pointer_declarator ($2.t, $3); }
2663 | '&' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2664 { $$ = make_reference_declarator ($2.t, $3); }
2665 | '*' after_type_declarator_intern %prec UNARY
2666 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2667 | '&' after_type_declarator_intern %prec UNARY
2668 { $$ = make_reference_declarator (NULL_TREE, $2); }
2669 | ptr_to_mem cv_qualifiers after_type_declarator_intern
2670 { tree arg = make_pointer_declarator ($2, $3);
2671 $$ = build_parse_node (SCOPE_REF, $1, arg);
2673 | direct_after_type_declarator
2676 direct_after_type_declarator:
2677 direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2678 { $$ = make_call_declarator ($$, $2, $3, $4); }
2679 | direct_after_type_declarator '[' expr ']'
2680 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2681 | direct_after_type_declarator '[' ']'
2682 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2683 | '(' after_type_declarator_intern ')'
2684 { $$ = $2; }
2685 | nested_name_specifier type_name %prec EMPTY
2686 { push_nested_class ($1, 3);
2687 $$ = build_parse_node (SCOPE_REF, $$, $2);
2688 TREE_COMPLEXITY ($$) = current_class_depth; }
2689 | type_name %prec EMPTY
2692 nonnested_type:
2693 type_name %prec EMPTY
2695 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2697 $$ = lookup_name ($1, 1);
2698 maybe_note_name_used_in_class ($1, $$);
2700 else
2701 $$ = $1;
2703 | global_scope type_name
2705 if (TREE_CODE ($2) == IDENTIFIER_NODE)
2706 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
2707 else
2708 $$ = $2;
2709 got_scope = NULL_TREE;
2713 complete_type_name:
2714 nonnested_type
2715 | nested_type
2716 | global_scope nested_type
2717 { $$ = $2; }
2720 nested_type:
2721 nested_name_specifier type_name %prec EMPTY
2722 { $$ = get_type_decl ($2); }
2725 /* A declarator allowed whether or not there has been
2726 an explicit typespec. These cannot redeclare a typedef-name. */
2728 notype_declarator_intern:
2729 notype_declarator
2730 | attributes notype_declarator
2732 /* Provide support for '(' attributes '*' declarator ')'
2733 etc */
2734 $$ = decl_tree_cons ($1, $2, NULL_TREE);
2738 notype_declarator:
2739 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2740 { $$ = make_pointer_declarator ($2.t, $3); }
2741 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2742 { $$ = make_reference_declarator ($2.t, $3); }
2743 | '*' notype_declarator_intern %prec UNARY
2744 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2745 | '&' notype_declarator_intern %prec UNARY
2746 { $$ = make_reference_declarator (NULL_TREE, $2); }
2747 | ptr_to_mem cv_qualifiers notype_declarator_intern
2748 { tree arg = make_pointer_declarator ($2, $3);
2749 $$ = build_parse_node (SCOPE_REF, $1, arg);
2751 | direct_notype_declarator
2754 complex_notype_declarator:
2755 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2756 { $$ = make_pointer_declarator ($2.t, $3); }
2757 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2758 { $$ = make_reference_declarator ($2.t, $3); }
2759 | '*' complex_notype_declarator %prec UNARY
2760 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2761 | '&' complex_notype_declarator %prec UNARY
2762 { $$ = make_reference_declarator (NULL_TREE, $2); }
2763 | ptr_to_mem cv_qualifiers notype_declarator_intern
2764 { tree arg = make_pointer_declarator ($2, $3);
2765 $$ = build_parse_node (SCOPE_REF, $1, arg);
2767 | complex_direct_notype_declarator
2770 complex_direct_notype_declarator:
2771 direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2772 { $$ = make_call_declarator ($$, $2, $3, $4); }
2773 | '(' complex_notype_declarator ')'
2774 { $$ = $2; }
2775 | direct_notype_declarator '[' expr ']'
2776 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
2777 | direct_notype_declarator '[' ']'
2778 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
2779 | notype_qualified_id
2780 { enter_scope_of ($1); }
2781 | nested_name_specifier notype_template_declarator
2782 { got_scope = NULL_TREE;
2783 $$ = build_parse_node (SCOPE_REF, $1, $2);
2784 enter_scope_of ($$);
2788 qualified_id:
2789 nested_name_specifier unqualified_id
2790 { got_scope = NULL_TREE;
2791 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2792 | nested_name_specifier object_template_id
2793 { got_scope = NULL_TREE;
2794 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2797 notype_qualified_id:
2798 nested_name_specifier notype_unqualified_id
2799 { got_scope = NULL_TREE;
2800 $$ = build_parse_node (SCOPE_REF, $$, $2); }
2801 | nested_name_specifier object_template_id
2802 { got_scope = NULL_TREE;
2803 $$ = build_parse_node (SCOPE_REF, $1, $2); }
2806 overqualified_id:
2807 notype_qualified_id
2808 | global_scope notype_qualified_id
2809 { $$ = $2; }
2812 functional_cast:
2813 typespec '(' nonnull_exprlist ')'
2814 { $$ = build_functional_cast ($1.t, $3); }
2815 | typespec '(' expr_or_declarator_intern ')'
2816 { $$ = reparse_decl_as_expr ($1.t, $3); }
2817 | typespec fcast_or_absdcl %prec EMPTY
2818 { $$ = reparse_absdcl_as_expr ($1.t, $2); }
2820 type_name:
2821 TYPENAME
2822 | SELFNAME
2823 | template_type %prec EMPTY
2826 nested_name_specifier:
2827 nested_name_specifier_1
2828 | nested_name_specifier nested_name_specifier_1
2829 { $$ = $2; }
2830 | nested_name_specifier TEMPLATE explicit_template_type SCOPE
2831 { got_scope = $$
2832 = make_typename_type ($1, $3, /*complain=*/1); }
2835 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
2836 inline here?!? (jason) */
2837 nested_name_specifier_1:
2838 TYPENAME SCOPE
2840 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2842 $$ = lastiddecl;
2843 maybe_note_name_used_in_class ($1, $$);
2845 got_scope = $$ =
2846 complete_type (TYPE_MAIN_VARIANT (TREE_TYPE ($$)));
2848 | SELFNAME SCOPE
2850 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2851 $$ = lastiddecl;
2852 got_scope = $$ = TREE_TYPE ($$);
2854 | NSNAME SCOPE
2856 if (TREE_CODE ($$) == IDENTIFIER_NODE)
2857 $$ = lastiddecl;
2858 got_scope = $$;
2860 | template_type SCOPE
2861 { got_scope = $$ = complete_type (TREE_TYPE ($1)); }
2862 /* These break 'const i;'
2863 | IDENTIFIER SCOPE
2865 failed_scope:
2866 cp_error ("`%D' is not an aggregate typedef",
2867 lastiddecl ? lastiddecl : $$);
2868 $$ = error_mark_node;
2870 | PTYPENAME SCOPE
2871 { goto failed_scope; } */
2874 typename_sub:
2875 typename_sub0
2876 | global_scope typename_sub0
2877 { $$ = $2; }
2880 typename_sub0:
2881 typename_sub1 identifier %prec EMPTY
2883 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
2884 $$ = make_typename_type ($1, $2, /*complain=*/1);
2885 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
2886 cp_error ("`%T' is not a class or namespace", $2);
2887 else
2889 $$ = $2;
2890 if (TREE_CODE ($$) == TYPE_DECL)
2891 $$ = TREE_TYPE ($$);
2894 | typename_sub1 template_type %prec EMPTY
2895 { $$ = TREE_TYPE ($2); }
2896 | typename_sub1 explicit_template_type %prec EMPTY
2897 { $$ = make_typename_type ($1, $2, /*complain=*/1); }
2898 | typename_sub1 TEMPLATE explicit_template_type %prec EMPTY
2899 { $$ = make_typename_type ($1, $3, /*complain=*/1); }
2902 typename_sub1:
2903 typename_sub2
2905 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2906 cp_error ("`%T' is not a class or namespace", $1);
2908 | typename_sub1 typename_sub2
2910 if (TREE_CODE_CLASS (TREE_CODE ($1)) == 't')
2911 $$ = make_typename_type ($1, $2, /*complain=*/1);
2912 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
2913 cp_error ("`%T' is not a class or namespace", $2);
2914 else
2916 $$ = $2;
2917 if (TREE_CODE ($$) == TYPE_DECL)
2918 $$ = TREE_TYPE ($$);
2921 | typename_sub1 explicit_template_type SCOPE
2922 { got_scope = $$
2923 = make_typename_type ($1, $2, /*complain=*/1); }
2924 | typename_sub1 TEMPLATE explicit_template_type SCOPE
2925 { got_scope = $$
2926 = make_typename_type ($1, $3, /*complain=*/1); }
2929 typename_sub2:
2930 TYPENAME SCOPE
2932 if (TREE_CODE ($1) != IDENTIFIER_NODE)
2933 $1 = lastiddecl;
2935 /* Retrieve the type for the identifier, which might involve
2936 some computation. */
2937 got_scope = $$ = complete_type (IDENTIFIER_TYPE_VALUE ($1));
2939 if ($$ == error_mark_node)
2940 cp_error ("`%T' is not a class or namespace", $1);
2942 | SELFNAME SCOPE
2944 if (TREE_CODE ($1) != IDENTIFIER_NODE)
2945 $$ = lastiddecl;
2946 got_scope = $$ = complete_type (TREE_TYPE ($$));
2948 | template_type SCOPE
2949 { got_scope = $$ = complete_type (TREE_TYPE ($$)); }
2950 | PTYPENAME SCOPE
2951 | IDENTIFIER SCOPE
2952 | NSNAME SCOPE
2954 if (TREE_CODE ($$) == IDENTIFIER_NODE)
2955 $$ = lastiddecl;
2956 got_scope = $$;
2960 explicit_template_type:
2961 identifier '<' template_arg_list_opt template_close_bracket
2962 { $$ = build_min_nt (TEMPLATE_ID_EXPR, $1, $3); }
2965 complex_type_name:
2966 global_scope type_name
2968 if (TREE_CODE ($2) == IDENTIFIER_NODE)
2969 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
2970 else
2971 $$ = $2;
2972 got_scope = NULL_TREE;
2974 | nested_type
2975 | global_scope nested_type
2976 { $$ = $2; }
2979 ptr_to_mem:
2980 nested_name_specifier '*'
2981 { got_scope = NULL_TREE; }
2982 | global_scope nested_name_specifier '*'
2983 { $$ = $2; got_scope = NULL_TREE; }
2986 /* All uses of explicit global scope must go through this nonterminal so
2987 that got_scope will be set before yylex is called to get the next token. */
2988 global_scope:
2989 SCOPE
2990 { got_scope = void_type_node; }
2993 /* ANSI new-declarator (5.3.4) */
2994 new_declarator:
2995 '*' cv_qualifiers new_declarator
2996 { $$ = make_pointer_declarator ($2, $3); }
2997 | '*' cv_qualifiers %prec EMPTY
2998 { $$ = make_pointer_declarator ($2, NULL_TREE); }
2999 | '&' cv_qualifiers new_declarator %prec EMPTY
3000 { $$ = make_reference_declarator ($2, $3); }
3001 | '&' cv_qualifiers %prec EMPTY
3002 { $$ = make_reference_declarator ($2, NULL_TREE); }
3003 | ptr_to_mem cv_qualifiers %prec EMPTY
3004 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3005 $$ = build_parse_node (SCOPE_REF, $1, arg);
3007 | ptr_to_mem cv_qualifiers new_declarator
3008 { tree arg = make_pointer_declarator ($2, $3);
3009 $$ = build_parse_node (SCOPE_REF, $1, arg);
3011 | direct_new_declarator %prec EMPTY
3014 /* ANSI direct-new-declarator (5.3.4) */
3015 direct_new_declarator:
3016 '[' expr ']'
3017 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3018 | direct_new_declarator '[' expr ']'
3019 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3022 absdcl_intern:
3023 absdcl
3024 | attributes absdcl
3026 /* Provide support for '(' attributes '*' declarator ')'
3027 etc */
3028 $$ = decl_tree_cons ($1, $2, NULL_TREE);
3032 /* ANSI abstract-declarator (8.1) */
3033 absdcl:
3034 '*' nonempty_cv_qualifiers absdcl_intern
3035 { $$ = make_pointer_declarator ($2.t, $3); }
3036 | '*' absdcl_intern
3037 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3038 | '*' nonempty_cv_qualifiers %prec EMPTY
3039 { $$ = make_pointer_declarator ($2.t, NULL_TREE); }
3040 | '*' %prec EMPTY
3041 { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
3042 | '&' nonempty_cv_qualifiers absdcl_intern
3043 { $$ = make_reference_declarator ($2.t, $3); }
3044 | '&' absdcl_intern
3045 { $$ = make_reference_declarator (NULL_TREE, $2); }
3046 | '&' nonempty_cv_qualifiers %prec EMPTY
3047 { $$ = make_reference_declarator ($2.t, NULL_TREE); }
3048 | '&' %prec EMPTY
3049 { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
3050 | ptr_to_mem cv_qualifiers %prec EMPTY
3051 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3052 $$ = build_parse_node (SCOPE_REF, $1, arg);
3054 | ptr_to_mem cv_qualifiers absdcl_intern
3055 { tree arg = make_pointer_declarator ($2, $3);
3056 $$ = build_parse_node (SCOPE_REF, $1, arg);
3058 | direct_abstract_declarator %prec EMPTY
3061 /* ANSI direct-abstract-declarator (8.1) */
3062 direct_abstract_declarator:
3063 '(' absdcl_intern ')'
3064 { $$ = $2; }
3065 /* `(typedef)1' is `int'. */
3066 | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3067 { $$ = make_call_declarator ($$, $3, $5, $6); }
3068 | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
3069 { $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
3070 | direct_abstract_declarator '[' expr ']' %prec '.'
3071 { $$ = build_parse_node (ARRAY_REF, $$, $3); }
3072 | direct_abstract_declarator '[' ']' %prec '.'
3073 { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
3074 | '(' complex_parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3075 { $$ = make_call_declarator (NULL_TREE, $2, $4, $5); }
3076 | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3077 { set_quals_and_spec ($$, $2, $3); }
3078 | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3079 { set_quals_and_spec ($$, $2, $3); }
3080 | '[' expr ']' %prec '.'
3081 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
3082 | '[' ']' %prec '.'
3083 { $$ = build_parse_node (ARRAY_REF, NULL_TREE, NULL_TREE); }
3086 /* For C++, decls and stmts can be intermixed, so we don't need to
3087 have a special rule that won't start parsing the stmt section
3088 until we have a stmt that parses without errors. */
3090 stmts:
3091 stmt
3092 | errstmt
3093 | stmts stmt
3094 | stmts errstmt
3097 errstmt:
3098 error ';'
3101 /* Read zero or more forward-declarations for labels
3102 that nested functions can jump to. */
3103 maybe_label_decls:
3104 /* empty */
3105 | label_decls
3106 { if (pedantic)
3107 pedwarn ("ANSI C++ forbids label declarations"); }
3110 label_decls:
3111 label_decl
3112 | label_decls label_decl
3115 label_decl:
3116 LABEL identifiers_or_typenames ';'
3118 while ($2)
3120 finish_label_decl (TREE_VALUE ($2));
3121 $2 = TREE_CHAIN ($2);
3126 /* This is the body of a function definition.
3127 It causes syntax errors to ignore to the next openbrace. */
3128 compstmt_or_error:
3129 compstmt
3131 | error compstmt
3134 compstmt:
3136 { $<ttype>$ = begin_compound_stmt (0); }
3137 compstmtend
3138 { $$ = finish_compound_stmt (0, $<ttype>2); }
3141 simple_if:
3144 $<ttype>$ = begin_if_stmt ();
3145 cond_stmt_keyword = "if";
3147 paren_cond_or_null
3148 { finish_if_stmt_cond ($3, $<ttype>2); }
3149 implicitly_scoped_stmt
3150 { $<ttype>$ = finish_then_clause ($<ttype>2); }
3153 implicitly_scoped_stmt:
3154 compstmt
3155 | { $<ttype>$ = begin_compound_stmt (0); }
3156 simple_stmt
3157 { $$ = finish_compound_stmt (0, $<ttype>1); }
3160 stmt:
3161 compstmt
3163 | simple_stmt
3166 simple_stmt:
3167 decl
3168 { finish_stmt (); }
3169 | expr ';'
3170 { finish_expr_stmt ($1); }
3171 | simple_if ELSE
3172 { begin_else_clause (); }
3173 implicitly_scoped_stmt
3175 finish_else_clause ($<ttype>1);
3176 finish_if_stmt ();
3178 | simple_if %prec IF
3179 { finish_if_stmt (); }
3180 | WHILE
3182 $<ttype>$ = begin_while_stmt ();
3183 cond_stmt_keyword = "while";
3185 paren_cond_or_null
3186 { finish_while_stmt_cond ($3, $<ttype>2); }
3187 already_scoped_stmt
3188 { finish_while_stmt ($<ttype>2); }
3189 | DO
3190 { $<ttype>$ = begin_do_stmt (); }
3191 implicitly_scoped_stmt WHILE
3193 finish_do_body ($<ttype>2);
3194 cond_stmt_keyword = "do";
3196 paren_expr_or_null ';'
3197 { finish_do_stmt ($6, $<ttype>2); }
3198 | FOR
3199 { $<ttype>$ = begin_for_stmt (); }
3200 '(' for.init.statement
3201 { finish_for_init_stmt ($<ttype>2); }
3202 xcond ';'
3203 { finish_for_cond ($6, $<ttype>2); }
3204 xexpr ')'
3205 { finish_for_expr ($9, $<ttype>2); }
3206 already_scoped_stmt
3207 { finish_for_stmt ($9, $<ttype>2); }
3208 | SWITCH
3209 { $<ttype>$ = begin_switch_stmt (); }
3210 '(' condition ')'
3211 { finish_switch_cond ($4, $<ttype>2); }
3212 implicitly_scoped_stmt
3213 { finish_switch_stmt ($4, $<ttype>2); }
3214 | CASE expr_no_commas ':'
3215 { finish_case_label ($2, NULL_TREE); }
3216 stmt
3217 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
3218 { finish_case_label ($2, $4); }
3219 stmt
3220 | DEFAULT ':'
3221 { finish_case_label (NULL_TREE, NULL_TREE); }
3222 stmt
3223 | BREAK ';'
3224 { finish_break_stmt (); }
3225 | CONTINUE ';'
3226 { finish_continue_stmt (); }
3227 | RETURN_KEYWORD ';'
3228 { finish_return_stmt (NULL_TREE); }
3229 | RETURN_KEYWORD expr ';'
3230 { finish_return_stmt ($2); }
3231 | asm_keyword maybe_cv_qualifier '(' string ')' ';'
3233 finish_asm_stmt ($2, $4, NULL_TREE, NULL_TREE,
3234 NULL_TREE);
3236 /* This is the case with just output operands. */
3237 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ')' ';'
3239 finish_asm_stmt ($2, $4, $6, NULL_TREE,
3240 NULL_TREE);
3242 /* This is the case with input operands as well. */
3243 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':' asm_operands ')' ';'
3244 { finish_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
3245 /* This is the case with clobbered registers as well. */
3246 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':'
3247 asm_operands ':' asm_clobbers ')' ';'
3248 { finish_asm_stmt ($2, $4, $6, $8, $10); }
3249 | GOTO '*' expr ';'
3251 if (pedantic)
3252 pedwarn ("ANSI C++ forbids computed gotos");
3253 finish_goto_stmt ($3);
3255 | GOTO identifier ';'
3256 { finish_goto_stmt ($2); }
3257 | label_colon stmt
3258 | label_colon '}'
3259 { error ("label must be followed by statement");
3260 yyungetc ('}', 0); }
3261 | ';'
3262 { finish_stmt (); }
3263 | try_block
3264 | using_directive
3265 | namespace_using_decl
3266 { do_local_using_decl ($1); }
3267 | namespace_alias
3270 function_try_block:
3272 { $<ttype>$ = begin_function_try_block (); }
3273 ctor_initializer_opt compstmt
3274 { finish_function_try_block ($<ttype>2); }
3275 handler_seq
3277 finish_function_handler_sequence ($<ttype>2);
3278 $$ = $3;
3282 try_block:
3284 { $<ttype>$ = begin_try_block (); }
3285 compstmt
3286 { finish_try_block ($<ttype>2); }
3287 handler_seq
3288 { finish_handler_sequence ($<ttype>2); }
3291 handler_seq:
3292 handler
3293 | handler_seq handler
3296 handler:
3297 CATCH
3298 { $<ttype>$ = begin_handler(); }
3299 handler_args
3300 { $<ttype>$ = finish_handler_parms ($3, $<ttype>2); }
3301 compstmt
3302 { finish_handler ($<ttype>4, $<ttype>2); }
3305 type_specifier_seq:
3306 typed_typespecs %prec EMPTY
3307 | nonempty_cv_qualifiers %prec EMPTY
3310 handler_args:
3311 '(' ELLIPSIS ')'
3312 { $$ = NULL_TREE; }
3313 /* This doesn't allow reference parameters, the below does.
3314 | '(' type_specifier_seq absdcl ')'
3315 { check_for_new_type ("inside exception declarations", $2);
3316 expand_start_catch_block ($2.t, $3); }
3317 | '(' type_specifier_seq ')'
3318 { check_for_new_type ("inside exception declarations", $2);
3319 expand_start_catch_block ($2.t, NULL_TREE); }
3320 | '(' type_specifier_seq notype_declarator ')'
3321 { check_for_new_type ("inside exception declarations", $2);
3322 expand_start_catch_block ($2.t, $3); }
3323 | '(' typed_typespecs after_type_declarator ')'
3324 { check_for_new_type ("inside exception declarations", $2);
3325 expand_start_catch_block ($2.t, $3); }
3326 This allows reference parameters... */
3327 | '(' parm ')'
3329 check_for_new_type ("inside exception declarations", $2);
3330 $$ = start_handler_parms (TREE_PURPOSE ($2.t),
3331 TREE_VALUE ($2.t));
3335 label_colon:
3336 IDENTIFIER ':'
3337 { finish_label_stmt ($1); }
3338 | PTYPENAME ':'
3339 { finish_label_stmt ($1); }
3340 | TYPENAME ':'
3341 { finish_label_stmt ($1); }
3342 | SELFNAME ':'
3343 { finish_label_stmt ($1); }
3346 for.init.statement:
3347 xexpr ';'
3348 { finish_expr_stmt ($1); }
3349 | decl
3350 | '{' compstmtend
3351 { if (pedantic)
3352 pedwarn ("ANSI C++ forbids compound statements inside for initializations");
3356 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
3358 maybe_cv_qualifier:
3359 /* empty */
3360 { emit_line_note (input_filename, lineno);
3361 $$ = NULL_TREE; }
3362 | CV_QUALIFIER
3363 { emit_line_note (input_filename, lineno); }
3366 xexpr:
3367 /* empty */
3368 { $$ = NULL_TREE; }
3369 | expr
3370 | error
3371 { $$ = NULL_TREE; }
3374 /* These are the operands other than the first string and colon
3375 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
3376 asm_operands:
3377 /* empty */
3378 { $$ = NULL_TREE; }
3379 | nonnull_asm_operands
3382 nonnull_asm_operands:
3383 asm_operand
3384 | nonnull_asm_operands ',' asm_operand
3385 { $$ = chainon ($$, $3); }
3388 asm_operand:
3389 STRING '(' expr ')'
3390 { $$ = build_tree_list ($$, $3); }
3393 asm_clobbers:
3394 STRING
3395 { $$ = tree_cons (NULL_TREE, $$, NULL_TREE); }
3396 | asm_clobbers ',' STRING
3397 { $$ = tree_cons (NULL_TREE, $3, $$); }
3400 /* This is what appears inside the parens in a function declarator.
3401 Its value is represented in the format that grokdeclarator expects.
3403 In C++, declaring a function with no parameters
3404 means that that function takes *no* parameters. */
3406 parmlist:
3407 /* empty */
3409 $$ = empty_parms();
3411 | complex_parmlist
3412 | type_id
3413 { $$ = finish_parmlist (build_tree_list (NULL_TREE, $1.t), 0);
3414 check_for_new_type ("inside parameter list", $1); }
3417 /* This nonterminal does not include the common sequence '(' type_id ')',
3418 as it is ambiguous and must be disambiguated elsewhere. */
3419 complex_parmlist:
3420 parms
3421 { $$ = finish_parmlist ($$, 0); }
3422 | parms_comma ELLIPSIS
3423 { $$ = finish_parmlist ($1, 1); }
3424 /* C++ allows an ellipsis without a separating ',' */
3425 | parms ELLIPSIS
3426 { $$ = finish_parmlist ($1, 1); }
3427 | type_id ELLIPSIS
3428 { $$ = finish_parmlist (build_tree_list (NULL_TREE,
3429 $1.t), 1); }
3430 | ELLIPSIS
3431 { $$ = finish_parmlist (NULL_TREE, 1); }
3432 | parms ':'
3434 /* This helps us recover from really nasty
3435 parse errors, for example, a missing right
3436 parenthesis. */
3437 yyerror ("possibly missing ')'");
3438 $$ = finish_parmlist ($1, 0);
3439 yyungetc (':', 0);
3440 yychar = ')';
3442 | type_id ':'
3444 /* This helps us recover from really nasty
3445 parse errors, for example, a missing right
3446 parenthesis. */
3447 yyerror ("possibly missing ')'");
3448 $$ = finish_parmlist (build_tree_list (NULL_TREE,
3449 $1.t), 0);
3450 yyungetc (':', 0);
3451 yychar = ')';
3455 /* A default argument to a */
3456 defarg:
3458 { maybe_snarf_defarg (); }
3459 defarg1
3460 { $$ = $3; }
3463 defarg1:
3464 DEFARG
3465 | init
3468 /* A nonempty list of parameter declarations or type names. */
3469 parms:
3470 named_parm
3471 { check_for_new_type ("in a parameter list", $1);
3472 $$ = build_tree_list (NULL_TREE, $1.t); }
3473 | parm defarg
3474 { check_for_new_type ("in a parameter list", $1);
3475 $$ = build_tree_list ($2, $1.t); }
3476 | parms_comma full_parm
3477 { check_for_new_type ("in a parameter list", $2);
3478 $$ = chainon ($$, $2.t); }
3479 | parms_comma bad_parm
3480 { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
3481 | parms_comma bad_parm '=' init
3482 { $$ = chainon ($$, build_tree_list ($4, $2)); }
3485 parms_comma:
3486 parms ','
3487 | type_id ','
3488 { check_for_new_type ("in a parameter list", $1);
3489 $$ = build_tree_list (NULL_TREE, $1.t); }
3492 /* A single parameter declaration or parameter type name,
3493 as found in a parmlist. */
3494 named_parm:
3495 /* Here we expand typed_declspecs inline to avoid mis-parsing of
3496 TYPESPEC IDENTIFIER. */
3497 typed_declspecs1 declarator
3498 { tree specs = strip_attrs ($1.t);
3499 $$.new_type_flag = $1.new_type_flag;
3500 $$.t = build_tree_list (specs, $2); }
3501 | typed_typespecs declarator
3502 { $$.t = build_tree_list ($1.t, $2);
3503 $$.new_type_flag = $1.new_type_flag; }
3504 | typespec declarator
3505 { $$.t = build_tree_list (build_decl_list (NULL_TREE, $1.t),
3506 $2);
3507 $$.new_type_flag = $1.new_type_flag; }
3508 | typed_declspecs1 absdcl
3509 { tree specs = strip_attrs ($1.t);
3510 $$.t = build_tree_list (specs, $2);
3511 $$.new_type_flag = $1.new_type_flag; }
3512 | typed_declspecs1 %prec EMPTY
3513 { tree specs = strip_attrs ($1.t);
3514 $$.t = build_tree_list (specs, NULL_TREE);
3515 $$.new_type_flag = $1.new_type_flag; }
3516 | declmods notype_declarator
3517 { tree specs = strip_attrs ($1);
3518 $$.t = build_tree_list (specs, $2);
3519 $$.new_type_flag = 0; }
3522 full_parm:
3523 parm
3524 { $$.t = build_tree_list (NULL_TREE, $1.t);
3525 $$.new_type_flag = $1.new_type_flag; }
3526 | parm defarg
3527 { $$.t = build_tree_list ($2, $1.t);
3528 $$.new_type_flag = $1.new_type_flag; }
3531 parm:
3532 named_parm
3533 | type_id
3536 see_typename:
3537 /* empty */ %prec EMPTY
3538 { see_typename (); }
3541 bad_parm:
3542 /* empty */ %prec EMPTY
3544 error ("type specifier omitted for parameter");
3545 $$ = build_tree_list (integer_type_node, NULL_TREE);
3547 | notype_declarator
3549 error ("type specifier omitted for parameter");
3550 if (TREE_CODE ($$) == SCOPE_REF
3551 && (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
3552 || TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TEMPLATE_PARM))
3553 cp_error (" perhaps you want `typename %E' to make it a type", $$);
3554 $$ = build_tree_list (integer_type_node, $$);
3558 exception_specification_opt:
3559 /* empty */ %prec EMPTY
3560 { $$ = NULL_TREE; }
3561 | THROW '(' ansi_raise_identifiers ')' %prec EMPTY
3562 { $$ = $3; }
3563 | THROW LEFT_RIGHT %prec EMPTY
3564 { $$ = empty_except_spec; }
3567 ansi_raise_identifier:
3568 type_id
3570 check_for_new_type ("exception specifier", $1);
3571 $$ = groktypename ($1.t);
3575 ansi_raise_identifiers:
3576 ansi_raise_identifier
3577 { $$ = add_exception_specifier (NULL_TREE, $1, 1); }
3578 | ansi_raise_identifiers ',' ansi_raise_identifier
3579 { $$ = add_exception_specifier ($1, $3, 1); }
3582 conversion_declarator:
3583 /* empty */ %prec EMPTY
3584 { $$ = NULL_TREE; }
3585 | '*' cv_qualifiers conversion_declarator
3586 { $$ = make_pointer_declarator ($2, $3); }
3587 | '&' cv_qualifiers conversion_declarator
3588 { $$ = make_reference_declarator ($2, $3); }
3589 | ptr_to_mem cv_qualifiers conversion_declarator
3590 { tree arg = make_pointer_declarator ($2, $3);
3591 $$ = build_parse_node (SCOPE_REF, $1, arg);
3595 operator:
3596 OPERATOR
3597 { got_scope = NULL_TREE; }
3600 operator_name:
3601 operator '*'
3602 { $$ = ansi_opname[MULT_EXPR]; }
3603 | operator '/'
3604 { $$ = ansi_opname[TRUNC_DIV_EXPR]; }
3605 | operator '%'
3606 { $$ = ansi_opname[TRUNC_MOD_EXPR]; }
3607 | operator '+'
3608 { $$ = ansi_opname[PLUS_EXPR]; }
3609 | operator '-'
3610 { $$ = ansi_opname[MINUS_EXPR]; }
3611 | operator '&'
3612 { $$ = ansi_opname[BIT_AND_EXPR]; }
3613 | operator '|'
3614 { $$ = ansi_opname[BIT_IOR_EXPR]; }
3615 | operator '^'
3616 { $$ = ansi_opname[BIT_XOR_EXPR]; }
3617 | operator '~'
3618 { $$ = ansi_opname[BIT_NOT_EXPR]; }
3619 | operator ','
3620 { $$ = ansi_opname[COMPOUND_EXPR]; }
3621 | operator ARITHCOMPARE
3622 { $$ = ansi_opname[$2]; }
3623 | operator '<'
3624 { $$ = ansi_opname[LT_EXPR]; }
3625 | operator '>'
3626 { $$ = ansi_opname[GT_EXPR]; }
3627 | operator EQCOMPARE
3628 { $$ = ansi_opname[$2]; }
3629 | operator ASSIGN
3630 { $$ = ansi_assopname[$2]; }
3631 | operator '='
3632 { $$ = ansi_opname [MODIFY_EXPR]; }
3633 | operator LSHIFT
3634 { $$ = ansi_opname[$2]; }
3635 | operator RSHIFT
3636 { $$ = ansi_opname[$2]; }
3637 | operator PLUSPLUS
3638 { $$ = ansi_opname[POSTINCREMENT_EXPR]; }
3639 | operator MINUSMINUS
3640 { $$ = ansi_opname[PREDECREMENT_EXPR]; }
3641 | operator ANDAND
3642 { $$ = ansi_opname[TRUTH_ANDIF_EXPR]; }
3643 | operator OROR
3644 { $$ = ansi_opname[TRUTH_ORIF_EXPR]; }
3645 | operator '!'
3646 { $$ = ansi_opname[TRUTH_NOT_EXPR]; }
3647 | operator '?' ':'
3648 { $$ = ansi_opname[COND_EXPR]; }
3649 | operator MIN_MAX
3650 { $$ = ansi_opname[$2]; }
3651 | operator POINTSAT %prec EMPTY
3652 { $$ = ansi_opname[COMPONENT_REF]; }
3653 | operator POINTSAT_STAR %prec EMPTY
3654 { $$ = ansi_opname[MEMBER_REF]; }
3655 | operator LEFT_RIGHT
3656 { $$ = ansi_opname[CALL_EXPR]; }
3657 | operator '[' ']'
3658 { $$ = ansi_opname[ARRAY_REF]; }
3659 | operator NEW %prec EMPTY
3660 { $$ = ansi_opname[NEW_EXPR]; }
3661 | operator DELETE %prec EMPTY
3662 { $$ = ansi_opname[DELETE_EXPR]; }
3663 | operator NEW '[' ']'
3664 { $$ = ansi_opname[VEC_NEW_EXPR]; }
3665 | operator DELETE '[' ']'
3666 { $$ = ansi_opname[VEC_DELETE_EXPR]; }
3667 /* Names here should be looked up in class scope ALSO. */
3668 | operator type_specifier_seq conversion_declarator
3669 { $$ = grokoptypename ($2.t, $3); }
3670 | operator error
3671 { $$ = ansi_opname[ERROR_MARK]; }
3676 #ifdef SPEW_DEBUG
3677 const char *
3678 debug_yytranslate (value)
3679 int value;
3681 return yytname[YYTRANSLATE (value)];
3684 #endif