* combine.c (simplify_and_const_int): Simplify (AND (PLUS X Y) C)
[official-gcc.git] / gcc / cp / parse.y
blob28a1456663fd00d155ceb351d567f82eb402fc39
1 /* YACC parser for C++ syntax.
2 Copyright (C) 1988, 1989, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001 Free Software Foundation, Inc.
4 Hacked by Michael Tiemann (tiemann@cygnus.com)
6 This file is part of GNU CC.
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
24 /* This grammar is based on the GNU CC grammar. */
26 /* Note: Bison automatically applies a default action of "$$ = $1" for
27 all derivations; this is applied before the explicit action, if one
28 is given. Keep this in mind when reading the actions. */
31 /* Cause the `yydebug' variable to be defined. */
32 #define YYDEBUG 1
34 #include "config.h"
36 #include "system.h"
38 #include "tree.h"
39 #include "input.h"
40 #include "flags.h"
41 #include "cp-tree.h"
42 #include "lex.h"
43 #include "output.h"
44 #include "except.h"
45 #include "toplev.h"
46 #include "ggc.h"
48 extern struct obstack permanent_obstack;
50 /* Like YYERROR but do call yyerror. */
51 #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
53 #define OP0(NODE) (TREE_OPERAND (NODE, 0))
54 #define OP1(NODE) (TREE_OPERAND (NODE, 1))
56 /* Contains the statement keyword (if/while/do) to include in an
57 error message if the user supplies an empty conditional expression. */
58 static const char *cond_stmt_keyword;
60 /* Nonzero if we have an `extern "C"' acting as an extern specifier. */
61 int have_extern_spec;
62 int used_extern_spec;
64 /* List of types and structure classes of the current declaration. */
65 static tree current_declspecs;
67 /* List of prefix attributes in effect.
68 Prefix attributes are parsed by the reserved_declspecs and declmods
69 rules. They create a list that contains *both* declspecs and attrs. */
70 /* ??? It is not clear yet that all cases where an attribute can now appear in
71 a declspec list have been updated. */
72 static tree prefix_attributes;
74 /* When defining an enumeration, this is the type of the enumeration. */
75 static tree current_enum_type;
77 /* When parsing a conversion operator name, this is the scope of the
78 operator itself. */
79 static tree saved_scopes;
81 static tree empty_parms PARAMS ((void));
82 static tree parse_decl0 PARAMS ((tree, tree, tree, tree, int));
83 static tree parse_decl PARAMS ((tree, tree, int));
84 static void parse_end_decl PARAMS ((tree, tree, tree));
85 static tree parse_field0 PARAMS ((tree, tree, tree, tree, tree, tree));
86 static tree parse_field PARAMS ((tree, tree, tree, tree));
87 static tree parse_bitfield0 PARAMS ((tree, tree, tree, tree, tree));
88 static tree parse_bitfield PARAMS ((tree, tree, tree));
89 static tree parse_method PARAMS ((tree, tree, tree));
90 static void frob_specs PARAMS ((tree, tree));
92 /* Cons up an empty parameter list. */
93 static inline tree
94 empty_parms ()
96 tree parms;
98 #ifndef NO_IMPLICIT_EXTERN_C
99 if (in_system_header && current_class_type == NULL
100 && current_lang_name == lang_name_c)
101 parms = NULL_TREE;
102 else
103 #endif
104 parms = void_list_node;
105 return parms;
108 /* Record the decl-specifiers, attributes and type lookups from the
109 decl-specifier-seq in a declaration. */
111 static void
112 frob_specs (specs_attrs, lookups)
113 tree specs_attrs, lookups;
115 save_type_access_control (lookups);
116 split_specs_attrs (specs_attrs, &current_declspecs, &prefix_attributes);
117 if (current_declspecs
118 && TREE_CODE (current_declspecs) != TREE_LIST)
119 current_declspecs = build_tree_list (NULL_TREE, current_declspecs);
120 if (have_extern_spec && !used_extern_spec)
122 /* We have to indicate that there is an "extern", but that it
123 was part of a language specifier. For instance,
125 extern "C" typedef int (*Ptr) ();
127 is well formed. */
128 current_declspecs = tree_cons (error_mark_node,
129 get_identifier ("extern"),
130 current_declspecs);
131 used_extern_spec = 1;
135 static tree
136 parse_decl (declarator, attributes, initialized)
137 tree declarator, attributes;
138 int initialized;
140 return start_decl (declarator, current_declspecs, initialized,
141 attributes, prefix_attributes);
144 static tree
145 parse_decl0 (declarator, specs_attrs, lookups, attributes, initialized)
146 tree declarator, specs_attrs, lookups, attributes;
147 int initialized;
149 frob_specs (specs_attrs, lookups);
150 return parse_decl (declarator, attributes, initialized);
153 static void
154 parse_end_decl (decl, init, asmspec)
155 tree decl, init, asmspec;
157 /* If decl is NULL_TREE, then this was a variable declaration using
158 () syntax for the initializer, so we handled it in grokdeclarator. */
159 if (decl)
160 decl_type_access_control (decl);
161 cp_finish_decl (decl, init, asmspec, init ? LOOKUP_ONLYCONVERTING : 0);
164 static tree
165 parse_field (declarator, attributes, asmspec, init)
166 tree declarator, attributes, asmspec, init;
168 tree d = grokfield (declarator, current_declspecs, init, asmspec,
169 chainon (attributes, prefix_attributes));
170 decl_type_access_control (d);
171 return d;
174 static tree
175 parse_field0 (declarator, specs_attrs, lookups, attributes, asmspec, init)
176 tree declarator, specs_attrs, lookups, attributes, asmspec, init;
178 frob_specs (specs_attrs, lookups);
179 return parse_field (declarator, attributes, asmspec, init);
182 static tree
183 parse_bitfield (declarator, attributes, width)
184 tree declarator, attributes, width;
186 tree d = grokbitfield (declarator, current_declspecs, width);
187 cplus_decl_attributes (&d, chainon (attributes, prefix_attributes), 0);
188 decl_type_access_control (d);
189 return d;
192 static tree
193 parse_bitfield0 (declarator, specs_attrs, lookups, attributes, width)
194 tree declarator, specs_attrs, lookups, attributes, width;
196 frob_specs (specs_attrs, lookups);
197 return parse_bitfield (declarator, attributes, width);
200 static tree
201 parse_method (declarator, specs_attrs, lookups)
202 tree declarator, specs_attrs, lookups;
204 tree d;
205 frob_specs (specs_attrs, lookups);
206 d = start_method (current_declspecs, declarator, prefix_attributes);
207 decl_type_access_control (d);
208 return d;
211 void
212 cp_parse_init ()
214 ggc_add_tree_root (&current_declspecs, 1);
215 ggc_add_tree_root (&prefix_attributes, 1);
216 ggc_add_tree_root (&current_enum_type, 1);
217 ggc_add_tree_root (&saved_scopes, 1);
220 /* Rename the "yyparse" function so that we can override it elsewhere. */
221 #define yyparse yyparse_1
224 %start program
226 %union {
227 long itype;
228 tree ttype;
229 char *strtype;
230 enum tree_code code;
231 flagged_type_tree ftype;
232 struct unparsed_text *pi;
235 /* All identifiers that are not reserved words
236 and are not declared typedefs in the current block */
237 %token IDENTIFIER
239 /* All identifiers that are declared typedefs in the current block.
240 In some contexts, they are treated just like IDENTIFIER,
241 but they can also serve as typespecs in declarations. */
242 %token TYPENAME
243 %token SELFNAME
245 /* A template function. */
246 %token PFUNCNAME
248 /* Reserved words that specify storage class.
249 yylval contains an IDENTIFIER_NODE which indicates which one. */
250 %token SCSPEC
252 /* Reserved words that specify type.
253 yylval contains an IDENTIFIER_NODE which indicates which one. */
254 %token TYPESPEC
256 /* Reserved words that qualify type: "const" or "volatile".
257 yylval contains an IDENTIFIER_NODE which indicates which one. */
258 %token CV_QUALIFIER
260 /* Character or numeric constants.
261 yylval is the node for the constant. */
262 %token CONSTANT
264 /* __func__, __FUNCTION__ or __PRETTY_FUNCTION__.
265 yylval contains an IDENTIFIER_NODE which indicates which one. */
266 %token VAR_FUNC_NAME
268 /* String constants in raw form.
269 yylval is a STRING_CST node. */
270 %token STRING
272 /* "...", used for functions with variable arglists. */
273 %token ELLIPSIS
275 /* the reserved words */
276 /* SCO include files test "ASM", so use something else. */
277 %token SIZEOF ENUM /* STRUCT UNION */ IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
278 %token BREAK CONTINUE RETURN_KEYWORD GOTO ASM_KEYWORD TYPEOF ALIGNOF
279 %token SIGOF
280 %token ATTRIBUTE EXTENSION LABEL
281 %token REALPART IMAGPART VA_ARG
283 /* the reserved words... C++ extensions */
284 %token <ttype> AGGR
285 %token <ttype> VISSPEC
286 %token DELETE NEW THIS OPERATOR CXX_TRUE CXX_FALSE
287 %token NAMESPACE TYPENAME_KEYWORD USING
288 %token LEFT_RIGHT TEMPLATE
289 %token TYPEID DYNAMIC_CAST STATIC_CAST REINTERPRET_CAST CONST_CAST
290 %token SCOPE EXPORT
292 /* Define the operator tokens and their precedences.
293 The value is an integer because, if used, it is the tree code
294 to use in the expression made from the operator. */
296 %left EMPTY /* used to resolve s/r with epsilon */
298 %left error
300 /* Add precedence rules to solve dangling else s/r conflict */
301 %nonassoc IF
302 %nonassoc ELSE
304 %left IDENTIFIER PFUNCNAME TYPENAME SELFNAME PTYPENAME SCSPEC TYPESPEC CV_QUALIFIER ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD
306 %left '{' ',' ';'
308 %nonassoc THROW
309 %right <code> ':'
310 %right <code> ASSIGN '='
311 %right <code> '?'
312 %left <code> OROR
313 %left <code> ANDAND
314 %left <code> '|'
315 %left <code> '^'
316 %left <code> '&'
317 %left <code> MIN_MAX
318 %left <code> EQCOMPARE
319 %left <code> ARITHCOMPARE '<' '>'
320 %left <code> LSHIFT RSHIFT
321 %left <code> '+' '-'
322 %left <code> '*' '/' '%'
323 %left <code> POINTSAT_STAR DOT_STAR
324 %right <code> UNARY PLUSPLUS MINUSMINUS '~'
325 %left HYPERUNARY
326 %left <ttype> LEFT_RIGHT
327 %left <code> POINTSAT '.' '(' '['
329 %right SCOPE /* C++ extension */
330 %nonassoc NEW DELETE TRY CATCH
332 %type <code> unop
334 %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist
335 %type <ttype> PFUNCNAME maybe_identifier
336 %type <ttype> paren_expr_or_null nontrivial_exprlist SELFNAME
337 %type <ttype> expr_no_commas expr_no_comma_rangle
338 %type <ttype> cast_expr unary_expr primary string STRING
339 %type <ttype> reserved_declspecs boolean.literal
340 %type <ttype> reserved_typespecquals
341 %type <ttype> SCSPEC TYPESPEC CV_QUALIFIER maybe_cv_qualifier
342 %type <ttype> init initlist maybeasm maybe_init defarg defarg1
343 %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
344 %type <ttype> maybe_attribute attributes attribute attribute_list attrib
345 %type <ttype> any_word
347 %type <itype> save_lineno
348 %type <ttype> simple_stmt simple_if
350 %type <ttype> declarator notype_declarator after_type_declarator
351 %type <ttype> notype_declarator_intern absdcl_intern
352 %type <ttype> after_type_declarator_intern
353 %type <ttype> direct_notype_declarator direct_after_type_declarator
354 %type <itype> components notype_components
355 %type <ttype> component_decl component_decl_1
356 %type <ttype> component_declarator component_declarator0
357 %type <ttype> notype_component_declarator notype_component_declarator0
358 %type <ttype> after_type_component_declarator after_type_component_declarator0
359 %type <ttype> absdcl cv_qualifiers
360 %type <ttype> direct_abstract_declarator conversion_declarator
361 %type <ttype> new_declarator direct_new_declarator
362 %type <ttype> xexpr parmlist parms bad_parm
363 %type <ttype> identifiers_or_typenames
364 %type <ttype> fcast_or_absdcl regcast_or_absdcl
365 %type <ttype> expr_or_declarator expr_or_declarator_intern
366 %type <ttype> complex_notype_declarator
367 %type <ttype> notype_unqualified_id unqualified_id qualified_id
368 %type <ttype> template_id do_id object_template_id notype_template_declarator
369 %type <ttype> overqualified_id notype_qualified_id any_id
370 %type <ttype> complex_direct_notype_declarator functional_cast
371 %type <ttype> complex_parmlist parms_comma
372 %type <ttype> namespace_qualifier namespace_using_decl
374 %type <ftype> type_id new_type_id typed_typespecs typespec typed_declspecs
375 %type <ftype> typed_declspecs1 type_specifier_seq nonempty_cv_qualifiers
376 %type <ftype> structsp typespecqual_reserved parm named_parm full_parm
377 %type <ftype> declmods
379 %type <itype> extension
381 /* C++ extensions */
382 %token <ttype> PTYPENAME
383 %token <ttype> EXTERN_LANG_STRING ALL
384 %token <ttype> PRE_PARSED_CLASS_DECL DEFARG DEFARG_MARKER
385 %token <pi> PRE_PARSED_FUNCTION_DECL
386 %type <ttype> component_constructor_declarator
387 %type <ttype> fn.def2 return_id constructor_declarator
388 %type <itype> ctor_initializer_opt function_try_block
389 %type <ttype> named_class_head_sans_basetype
390 %type <ftype> class_head named_class_head
391 %type <ftype> named_complex_class_head_sans_basetype
392 %type <ttype> unnamed_class_head
393 %type <ttype> base_class_list
394 %type <ttype> base_class_access_list
395 %type <ttype> base_class maybe_base_class_list base_class.1
396 %type <ttype> exception_specification_opt ansi_raise_identifier ansi_raise_identifiers
397 %type <ttype> operator_name
398 %type <ttype> object aggr
399 %type <itype> new delete
400 /* %type <ttype> primary_no_id */
401 %type <ttype> maybe_parmlist
402 %type <ttype> member_init
403 %type <ftype> member_init_list
404 %type <ttype> template_parm_header template_spec_header template_header
405 %type <ttype> template_parm_list template_parm
406 %type <ttype> template_type_parm template_template_parm
407 %type <code> template_close_bracket
408 %type <ttype> apparent_template_type
409 %type <ttype> template_type template_arg_list template_arg_list_opt
410 %type <ttype> template_arg
411 %type <ttype> condition xcond paren_cond_or_null
412 %type <ttype> type_name nested_name_specifier nested_type ptr_to_mem
413 %type <ttype> complete_type_name notype_identifier nonnested_type
414 %type <ttype> complex_type_name nested_name_specifier_1
415 %type <ttype> new_initializer new_placement
416 %type <ttype> using_decl
417 %type <ttype> typename_sub typename_sub0 typename_sub1 typename_sub2
418 %type <ttype> explicit_template_type
419 /* in order to recognize aggr tags as defining and thus shadowing. */
420 %token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN
421 %type <ttype> named_class_head_sans_basetype_defn
422 %type <ttype> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN
423 %type <ttype> handler_args
424 %type <ttype> self_template_type .finish_template_type
426 %token NSNAME
427 %type <ttype> NSNAME
429 /* Used in lex.c for parsing pragmas. */
430 %token END_OF_LINE
432 /* lex.c and pt.c depend on this being the last token. Define
433 any new tokens before this one! */
434 %token END_OF_SAVED_INPUT
437 /* Tell yyparse how to print a token's value, if yydebug is set. */
438 #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
439 extern void yyprint PARAMS ((FILE *, int, YYSTYPE));
443 program:
444 /* empty */
445 { finish_translation_unit (); }
446 | extdefs
447 { finish_translation_unit (); }
450 /* the reason for the strange actions in this rule
451 is so that notype_initdecls when reached via datadef
452 can find a valid list of type and sc specs in $0. */
454 extdefs:
455 { $<ttype>$ = NULL_TREE; }
456 lang_extdef
457 { $<ttype>$ = NULL_TREE; ggc_collect (); }
458 | extdefs lang_extdef
459 { $<ttype>$ = NULL_TREE; ggc_collect (); }
462 extdefs_opt:
463 extdefs
464 | /* empty */
467 .hush_warning:
468 { have_extern_spec = 1;
469 used_extern_spec = 0;
470 $<ttype>$ = NULL_TREE; }
472 .warning_ok:
473 { have_extern_spec = 0; }
476 extension:
477 EXTENSION
478 { $$ = pedantic;
479 pedantic = 0; }
482 asm_keyword:
483 ASM_KEYWORD
486 lang_extdef:
487 { if (pending_lang_change) do_pending_lang_change();
488 type_lookups = NULL_TREE; }
489 extdef
490 { if (! toplevel_bindings_p ())
491 pop_everything (); }
494 extdef:
495 fndef eat_saved_input
496 { do_pending_inlines (); }
497 | datadef
498 { do_pending_inlines (); }
500 | EXPORT
501 { cp_warning ("keyword `export' not implemented, and will be ignored"); }
502 template_def
503 { do_pending_inlines (); }
504 | template_def
505 { do_pending_inlines (); }
506 | asm_keyword '(' string ')' ';'
507 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
508 assemble_asm ($3); }
509 | extern_lang_string '{' extdefs_opt '}'
510 { pop_lang_context (); }
511 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
512 { do_pending_inlines (); pop_lang_context (); }
513 | extern_lang_string .hush_warning datadef .warning_ok
514 { do_pending_inlines (); pop_lang_context (); }
515 | NAMESPACE identifier '{'
516 { push_namespace ($2); }
517 extdefs_opt '}'
518 { pop_namespace (); }
519 | NAMESPACE '{'
520 { push_namespace (NULL_TREE); }
521 extdefs_opt '}'
522 { pop_namespace (); }
523 | namespace_alias
524 | using_decl ';'
525 { do_toplevel_using_decl ($1); }
526 | using_directive
527 | extension extdef
528 { pedantic = $1; }
531 namespace_alias:
532 NAMESPACE identifier '='
533 { begin_only_namespace_names (); }
534 any_id ';'
536 end_only_namespace_names ();
537 if (lastiddecl)
538 $5 = lastiddecl;
539 do_namespace_alias ($2, $5);
543 using_decl:
544 USING qualified_id
545 { $$ = $2; }
546 | USING global_scope qualified_id
547 { $$ = $3; }
548 | USING global_scope unqualified_id
549 { $$ = $3; }
552 namespace_using_decl:
553 USING namespace_qualifier identifier
554 { $$ = build_nt (SCOPE_REF, $2, $3); }
555 | USING global_scope identifier
556 { $$ = build_nt (SCOPE_REF, global_namespace, $3); }
557 | USING global_scope namespace_qualifier identifier
558 { $$ = build_nt (SCOPE_REF, $3, $4); }
561 using_directive:
562 USING NAMESPACE
563 { begin_only_namespace_names (); }
564 any_id ';'
566 end_only_namespace_names ();
567 /* If no declaration was found, the using-directive is
568 invalid. Since that was not reported, we need the
569 identifier for the error message. */
570 if (TREE_CODE ($4) == IDENTIFIER_NODE && lastiddecl)
571 $4 = lastiddecl;
572 do_using_directive ($4);
576 namespace_qualifier:
577 NSNAME SCOPE
579 if (TREE_CODE ($$) == IDENTIFIER_NODE)
580 $$ = lastiddecl;
581 got_scope = $$;
583 | namespace_qualifier NSNAME SCOPE
585 $$ = $2;
586 if (TREE_CODE ($$) == IDENTIFIER_NODE)
587 $$ = lastiddecl;
588 got_scope = $$;
591 any_id:
592 unqualified_id
593 | qualified_id
594 | global_scope qualified_id
595 { $$ = $2; }
596 | global_scope unqualified_id
597 { $$ = $2; }
600 extern_lang_string:
601 EXTERN_LANG_STRING
602 { push_lang_context ($1); }
603 | extern_lang_string EXTERN_LANG_STRING
604 { if (current_lang_name != $2)
605 cp_error ("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name);
606 pop_lang_context (); push_lang_context ($2); }
609 template_parm_header:
610 TEMPLATE '<'
611 { begin_template_parm_list (); }
612 template_parm_list '>'
613 { $$ = end_template_parm_list ($4); }
616 template_spec_header:
617 TEMPLATE '<' '>'
618 { begin_specialization();
619 $$ = NULL_TREE; }
622 template_header:
623 template_parm_header
624 | template_spec_header
627 template_parm_list:
628 template_parm
629 { $$ = process_template_parm (NULL_TREE, $1); }
630 | template_parm_list ',' template_parm
631 { $$ = process_template_parm ($1, $3); }
634 maybe_identifier:
635 identifier
636 { $$ = $1; }
637 | /* empty */
638 { $$ = NULL_TREE; }
640 template_type_parm:
641 aggr maybe_identifier
642 { $$ = finish_template_type_parm ($1, $2); }
643 | TYPENAME_KEYWORD maybe_identifier
644 { $$ = finish_template_type_parm (class_type_node, $2); }
647 template_template_parm:
648 template_parm_header aggr maybe_identifier
649 { $$ = finish_template_template_parm ($2, $3); }
652 template_parm:
653 /* The following rules introduce a new reduce/reduce
654 conflict on the ',' and '>' input tokens: they are valid
655 prefixes for a `structsp', which means they could match a
656 nameless parameter. See 14.6, paragraph 3.
657 By putting them before the `parm' rule, we get
658 their match before considering them nameless parameter
659 declarations. */
660 template_type_parm
661 { $$ = build_tree_list (NULL_TREE, $1); }
662 | template_type_parm '=' type_id
663 { $$ = build_tree_list (groktypename ($3.t), $1); }
664 | parm
665 { $$ = build_tree_list (NULL_TREE, $1.t); }
666 | parm '=' expr_no_comma_rangle
667 { $$ = build_tree_list ($3, $1.t); }
668 | template_template_parm
669 { $$ = build_tree_list (NULL_TREE, $1); }
670 | template_template_parm '=' template_arg
672 if (TREE_CODE ($3) != TEMPLATE_DECL
673 && TREE_CODE ($3) != TEMPLATE_TEMPLATE_PARM
674 && TREE_CODE ($3) != TYPE_DECL
675 && TREE_CODE ($3) != UNBOUND_CLASS_TEMPLATE)
677 error ("invalid default template argument");
678 $3 = error_mark_node;
680 $$ = build_tree_list ($3, $1);
684 template_def:
685 template_header template_extdef
686 { finish_template_decl ($1); }
687 | template_header error %prec EMPTY
688 { finish_template_decl ($1); }
691 template_extdef:
692 fndef eat_saved_input
693 { do_pending_inlines (); }
694 | template_datadef
695 { do_pending_inlines (); }
696 | template_def
697 { do_pending_inlines (); }
698 | extern_lang_string .hush_warning fndef .warning_ok eat_saved_input
699 { do_pending_inlines ();
700 pop_lang_context (); }
701 | extern_lang_string .hush_warning template_datadef .warning_ok
702 { do_pending_inlines ();
703 pop_lang_context (); }
704 | extension template_extdef
705 { pedantic = $1; }
708 template_datadef:
709 nomods_initdecls ';'
710 | declmods notype_initdecls ';'
712 | typed_declspecs initdecls ';'
713 { note_list_got_semicolon ($1.t); }
714 | structsp ';'
716 if ($1.t != error_mark_node)
718 maybe_process_partial_specialization ($1.t);
719 note_got_semicolon ($1.t);
724 datadef:
725 nomods_initdecls ';'
726 | declmods notype_initdecls ';'
728 | typed_declspecs initdecls ';'
729 { note_list_got_semicolon ($1.t); }
730 | declmods ';'
731 { pedwarn ("empty declaration"); }
732 | explicit_instantiation ';'
733 | typed_declspecs ';'
735 tree t, attrs;
736 split_specs_attrs ($1.t, &t, &attrs);
737 shadow_tag (t);
738 note_list_got_semicolon ($1.t);
740 | error ';'
741 | error '}'
742 | error END_OF_SAVED_INPUT
743 { end_input (); }
744 | ';'
745 | bad_decl
748 ctor_initializer_opt:
749 nodecls
750 { $$ = 0; }
751 | base_init
752 { $$ = 1; }
755 maybe_return_init:
756 /* empty */
757 | return_init
758 | return_init ';'
761 eat_saved_input:
762 /* empty */
763 | END_OF_SAVED_INPUT
766 fndef:
767 fn.def1 maybe_return_init ctor_initializer_opt compstmt_or_error
768 { expand_body (finish_function ((int)$3)); }
769 | fn.def1 maybe_return_init function_try_block
770 { expand_body (finish_function ((int)$3)); }
771 | fn.def1 maybe_return_init error
775 constructor_declarator:
776 nested_name_specifier SELFNAME '('
777 { $$ = begin_constructor_declarator ($1, $2); }
778 parmlist ')' cv_qualifiers exception_specification_opt
779 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
780 | nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
781 { $$ = begin_constructor_declarator ($1, $2);
782 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
784 | global_scope nested_name_specifier SELFNAME '('
785 { $$ = begin_constructor_declarator ($2, $3); }
786 parmlist ')' cv_qualifiers exception_specification_opt
787 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
788 | global_scope nested_name_specifier SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
789 { $$ = begin_constructor_declarator ($2, $3);
790 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
792 | nested_name_specifier self_template_type '('
793 { $$ = begin_constructor_declarator ($1, $2); }
794 parmlist ')' cv_qualifiers exception_specification_opt
795 { $$ = make_call_declarator ($<ttype>4, $5, $7, $8); }
796 | nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
797 { $$ = begin_constructor_declarator ($1, $2);
798 $$ = make_call_declarator ($$, empty_parms (), $4, $5);
800 | global_scope nested_name_specifier self_template_type '('
801 { $$ = begin_constructor_declarator ($2, $3); }
802 parmlist ')' cv_qualifiers exception_specification_opt
803 { $$ = make_call_declarator ($<ttype>5, $6, $8, $9); }
804 | global_scope nested_name_specifier self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
805 { $$ = begin_constructor_declarator ($2, $3);
806 $$ = make_call_declarator ($$, empty_parms (), $5, $6);
810 fn.def1:
811 typed_declspecs declarator
812 { check_for_new_type ("return type", $1);
813 if (!begin_function_definition ($1.t, $2))
814 YYERROR1; }
815 | declmods notype_declarator
816 { if (!begin_function_definition ($1.t, $2))
817 YYERROR1; }
818 | notype_declarator
819 { if (!begin_function_definition (NULL_TREE, $1))
820 YYERROR1; }
821 | declmods constructor_declarator
822 { if (!begin_function_definition ($1.t, $2))
823 YYERROR1; }
824 | constructor_declarator
825 { if (!begin_function_definition (NULL_TREE, $1))
826 YYERROR1; }
829 /* ANSI allows optional parentheses around constructor class names.
830 See ISO/IEC 14882:1998(E) 12.1. */
832 component_constructor_declarator:
833 SELFNAME '(' parmlist ')' cv_qualifiers exception_specification_opt
834 { $$ = make_call_declarator ($1, $3, $5, $6); }
835 | '(' SELFNAME ')' '(' parmlist ')' cv_qualifiers
836 exception_specification_opt
837 { $$ = make_call_declarator ($2, $5, $7, $8); }
838 | SELFNAME LEFT_RIGHT cv_qualifiers exception_specification_opt
839 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
840 | '(' SELFNAME ')' LEFT_RIGHT cv_qualifiers exception_specification_opt
841 { $$ = make_call_declarator ($2, empty_parms (), $5, $6); }
842 | self_template_type '(' parmlist ')' cv_qualifiers exception_specification_opt
843 { $$ = make_call_declarator ($1, $3, $5, $6); }
844 | self_template_type LEFT_RIGHT cv_qualifiers exception_specification_opt
845 { $$ = make_call_declarator ($1, empty_parms (), $3, $4); }
848 /* more C++ complexity. See component_decl for a comment on the
849 reduce/reduce conflict introduced by these rules. */
850 fn.def2:
851 declmods component_constructor_declarator
852 { $$ = parse_method ($2, $1.t, $1.lookups);
853 rest_of_mdef:
854 if (! $$)
855 YYERROR1;
856 if (yychar == YYEMPTY)
857 yychar = YYLEX;
858 snarf_method ($$); }
859 | component_constructor_declarator
860 { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
861 goto rest_of_mdef; }
862 | typed_declspecs declarator
863 { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
864 | declmods notype_declarator
865 { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
866 | notype_declarator
867 { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
868 goto rest_of_mdef; }
869 | declmods constructor_declarator
870 { $$ = parse_method ($2, $1.t, $1.lookups); goto rest_of_mdef;}
871 | constructor_declarator
872 { $$ = parse_method ($1, NULL_TREE, NULL_TREE);
873 goto rest_of_mdef; }
876 return_id:
877 RETURN_KEYWORD IDENTIFIER
879 $$ = $2;
883 return_init:
884 return_id maybe_init
885 { finish_named_return_value ($<ttype>$, $2); }
886 | return_id '(' nonnull_exprlist ')'
887 { finish_named_return_value ($<ttype>$, $3); }
888 | return_id LEFT_RIGHT
889 { finish_named_return_value ($<ttype>$, NULL_TREE); }
892 base_init:
893 ':' .set_base_init member_init_list
895 if ($3.new_type_flag == 0)
896 error ("no base or member initializers given following ':'");
898 finish_mem_initializers ($3.t);
902 .set_base_init:
903 /* empty */
905 if (DECL_CONSTRUCTOR_P (current_function_decl))
906 /* Make a contour for the initializer list. */
907 do_pushlevel ();
908 else if (current_class_type == NULL_TREE)
909 error ("base initializers not allowed for non-member functions");
910 else if (! DECL_CONSTRUCTOR_P (current_function_decl))
911 error ("only constructors take base initializers");
915 member_init_list:
916 /* empty */
918 $$.new_type_flag = 0;
919 $$.t = NULL_TREE;
921 | member_init
923 $$.new_type_flag = 1;
924 $$.t = $1;
926 | member_init_list ',' member_init
928 if ($3)
930 $$.new_type_flag = 1;
931 TREE_CHAIN ($3) = $1.t;
932 $$.t = $3;
934 else
935 $$ = $1;
937 | member_init_list error
940 member_init:
941 '(' nonnull_exprlist ')'
943 if (current_class_name)
944 pedwarn ("anachronistic old style base class initializer");
945 $$ = expand_member_init (current_class_ref, NULL_TREE, $2);
947 | LEFT_RIGHT
949 if (current_class_name)
950 pedwarn ("anachronistic old style base class initializer");
951 $$ = expand_member_init (current_class_ref,
952 NULL_TREE,
953 void_type_node);
955 | notype_identifier '(' nonnull_exprlist ')'
956 { $$ = expand_member_init (current_class_ref, $1, $3); }
957 | notype_identifier LEFT_RIGHT
958 { $$ = expand_member_init (current_class_ref, $1,
959 void_type_node); }
960 | nonnested_type '(' nonnull_exprlist ')'
961 { $$ = expand_member_init (current_class_ref, $1, $3); }
962 | nonnested_type LEFT_RIGHT
963 { $$ = expand_member_init (current_class_ref, $1,
964 void_type_node); }
965 | typename_sub '(' nonnull_exprlist ')'
966 { $$ = expand_member_init (current_class_ref, $1, $3); }
967 | typename_sub LEFT_RIGHT
968 { $$ = expand_member_init (current_class_ref, $1,
969 void_type_node); }
970 | error
971 { $$ = NULL_TREE; }
974 identifier:
975 IDENTIFIER
976 | TYPENAME
977 | SELFNAME
978 | PTYPENAME
979 | NSNAME
982 notype_identifier:
983 IDENTIFIER
984 | PTYPENAME
985 | NSNAME %prec EMPTY
988 identifier_defn:
989 IDENTIFIER_DEFN
990 | TYPENAME_DEFN
991 | PTYPENAME_DEFN
994 explicit_instantiation:
995 TEMPLATE begin_explicit_instantiation typespec ';'
996 { do_type_instantiation ($3.t, NULL_TREE, 1);
997 yyungetc (';', 1); }
998 end_explicit_instantiation
999 | TEMPLATE begin_explicit_instantiation typed_declspecs declarator
1000 { tree specs = strip_attrs ($3.t);
1001 do_decl_instantiation (specs, $4, NULL_TREE); }
1002 end_explicit_instantiation
1003 | TEMPLATE begin_explicit_instantiation notype_declarator
1004 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
1005 end_explicit_instantiation
1006 | TEMPLATE begin_explicit_instantiation constructor_declarator
1007 { do_decl_instantiation (NULL_TREE, $3, NULL_TREE); }
1008 end_explicit_instantiation
1009 | SCSPEC TEMPLATE begin_explicit_instantiation typespec ';'
1010 { do_type_instantiation ($4.t, $1, 1);
1011 yyungetc (';', 1); }
1012 end_explicit_instantiation
1013 | SCSPEC TEMPLATE begin_explicit_instantiation typed_declspecs
1014 declarator
1015 { tree specs = strip_attrs ($4.t);
1016 do_decl_instantiation (specs, $5, $1); }
1017 end_explicit_instantiation
1018 | SCSPEC TEMPLATE begin_explicit_instantiation notype_declarator
1019 { do_decl_instantiation (NULL_TREE, $4, $1); }
1020 end_explicit_instantiation
1021 | SCSPEC TEMPLATE begin_explicit_instantiation constructor_declarator
1022 { do_decl_instantiation (NULL_TREE, $4, $1); }
1023 end_explicit_instantiation
1026 begin_explicit_instantiation:
1027 { begin_explicit_instantiation(); }
1029 end_explicit_instantiation:
1030 { end_explicit_instantiation(); }
1032 /* The TYPENAME expansions are to deal with use of a template class name as
1033 a template within the class itself, where the template decl is hidden by
1034 a type decl. Got all that? */
1036 template_type:
1037 PTYPENAME '<' template_arg_list_opt template_close_bracket
1038 .finish_template_type
1039 { $$ = $5; }
1040 | TYPENAME '<' template_arg_list_opt template_close_bracket
1041 .finish_template_type
1042 { $$ = $5; }
1043 | self_template_type
1046 apparent_template_type:
1047 template_type
1048 | identifier '<' template_arg_list_opt '>'
1049 .finish_template_type
1050 { $$ = $5; }
1052 self_template_type:
1053 SELFNAME '<' template_arg_list_opt template_close_bracket
1054 .finish_template_type
1055 { $$ = $5; }
1058 .finish_template_type:
1060 if (yychar == YYEMPTY)
1061 yychar = YYLEX;
1063 $$ = finish_template_type ($<ttype>-3, $<ttype>-1,
1064 yychar == SCOPE);
1067 template_close_bracket:
1069 | RSHIFT
1071 /* Handle `Class<Class<Type>>' without space in the `>>' */
1072 pedwarn ("`>>' should be `> >' in template class name");
1073 yyungetc ('>', 1);
1077 template_arg_list_opt:
1078 /* empty */
1079 { $$ = NULL_TREE; }
1080 | template_arg_list
1083 template_arg_list:
1084 template_arg
1085 { $$ = build_tree_list (NULL_TREE, $$); }
1086 | template_arg_list ',' template_arg
1087 { $$ = chainon ($$, build_tree_list (NULL_TREE, $3)); }
1090 template_arg:
1091 type_id
1092 { $$ = groktypename ($1.t); }
1093 | PTYPENAME
1095 $$ = lastiddecl;
1096 if (DECL_TEMPLATE_TEMPLATE_PARM_P ($$))
1097 $$ = TREE_TYPE ($$);
1099 | global_scope PTYPENAME
1101 $$ = lastiddecl;
1102 if (DECL_TEMPLATE_TEMPLATE_PARM_P ($$))
1103 $$ = TREE_TYPE ($$);
1105 | expr_no_comma_rangle
1106 | nested_name_specifier TEMPLATE identifier
1108 if (!processing_template_decl)
1110 cp_error ("use of template qualifier outside template");
1111 $$ = error_mark_node;
1113 else
1114 $$ = make_unbound_class_template ($1, $3, 1);
1118 unop:
1120 { $$ = NEGATE_EXPR; }
1121 | '+'
1122 { $$ = CONVERT_EXPR; }
1123 | PLUSPLUS
1124 { $$ = PREINCREMENT_EXPR; }
1125 | MINUSMINUS
1126 { $$ = PREDECREMENT_EXPR; }
1127 | '!'
1128 { $$ = TRUTH_NOT_EXPR; }
1131 expr:
1132 nontrivial_exprlist
1133 { $$ = build_x_compound_expr ($$); }
1134 | expr_no_commas
1137 paren_expr_or_null:
1138 LEFT_RIGHT
1139 { error ("ISO C++ forbids an empty condition for `%s'",
1140 cond_stmt_keyword);
1141 $$ = integer_zero_node; }
1142 | '(' expr ')'
1143 { $$ = $2; }
1146 paren_cond_or_null:
1147 LEFT_RIGHT
1148 { error ("ISO C++ forbids an empty condition for `%s'",
1149 cond_stmt_keyword);
1150 $$ = integer_zero_node; }
1151 | '(' condition ')'
1152 { $$ = $2; }
1155 xcond:
1156 /* empty */
1157 { $$ = NULL_TREE; }
1158 | condition
1159 | error
1160 { $$ = NULL_TREE; }
1163 condition:
1164 type_specifier_seq declarator maybeasm maybe_attribute '='
1166 tree d;
1167 for (d = getdecls (); d; d = TREE_CHAIN (d))
1168 if (TREE_CODE (d) == TYPE_DECL) {
1169 tree s = TREE_TYPE (d);
1170 if (TREE_CODE (s) == RECORD_TYPE)
1171 cp_error ("definition of class `%T' in condition", s);
1172 else if (TREE_CODE (s) == ENUMERAL_TYPE)
1173 cp_error ("definition of enum `%T' in condition", s);
1176 current_declspecs = $1.t;
1177 $<ttype>$ = parse_decl ($<ttype>2, $4, 1);
1179 init
1181 parse_end_decl ($<ttype>6, $7, $4);
1182 $$ = convert_from_reference ($<ttype>6);
1183 if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
1184 cp_error ("definition of array `%#D' in condition", $$);
1186 | expr
1189 compstmtend:
1191 | maybe_label_decls stmts '}'
1192 | maybe_label_decls stmts error '}'
1193 | maybe_label_decls error '}'
1196 nontrivial_exprlist:
1197 expr_no_commas ',' expr_no_commas
1198 { $$ = tree_cons (NULL_TREE, $$,
1199 build_tree_list (NULL_TREE, $3)); }
1200 | expr_no_commas ',' error
1201 { $$ = tree_cons (NULL_TREE, $$,
1202 build_tree_list (NULL_TREE, error_mark_node)); }
1203 | nontrivial_exprlist ',' expr_no_commas
1204 { chainon ($$, build_tree_list (NULL_TREE, $3)); }
1205 | nontrivial_exprlist ',' error
1206 { chainon ($$, build_tree_list (NULL_TREE, error_mark_node)); }
1209 nonnull_exprlist:
1210 expr_no_commas
1211 { $$ = build_tree_list (NULL_TREE, $$); }
1212 | nontrivial_exprlist
1215 unary_expr:
1216 primary %prec UNARY
1217 { $$ = $1; }
1218 /* __extension__ turns off -pedantic for following primary. */
1219 | extension cast_expr %prec UNARY
1220 { $$ = $2;
1221 pedantic = $1; }
1222 | '*' cast_expr %prec UNARY
1223 { $$ = build_x_indirect_ref ($2, "unary *"); }
1224 | '&' cast_expr %prec UNARY
1225 { $$ = build_x_unary_op (ADDR_EXPR, $2); }
1226 | '~' cast_expr
1227 { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); }
1228 | unop cast_expr %prec UNARY
1229 { $$ = finish_unary_op_expr ($1, $2); }
1230 /* Refer to the address of a label as a pointer. */
1231 | ANDAND identifier
1232 { $$ = finish_label_address_expr ($2); }
1233 | SIZEOF unary_expr %prec UNARY
1234 { $$ = finish_sizeof ($2); }
1235 | SIZEOF '(' type_id ')' %prec HYPERUNARY
1236 { $$ = finish_sizeof (groktypename ($3.t));
1237 check_for_new_type ("sizeof", $3); }
1238 | ALIGNOF unary_expr %prec UNARY
1239 { $$ = finish_alignof ($2); }
1240 | ALIGNOF '(' type_id ')' %prec HYPERUNARY
1241 { $$ = finish_alignof (groktypename ($3.t));
1242 check_for_new_type ("alignof", $3); }
1244 /* The %prec EMPTY's here are required by the = init initializer
1245 syntax extension; see below. */
1246 | new new_type_id %prec EMPTY
1247 { $$ = build_new (NULL_TREE, $2.t, NULL_TREE, $1);
1248 check_for_new_type ("new", $2); }
1249 | new new_type_id new_initializer
1250 { $$ = build_new (NULL_TREE, $2.t, $3, $1);
1251 check_for_new_type ("new", $2); }
1252 | new new_placement new_type_id %prec EMPTY
1253 { $$ = build_new ($2, $3.t, NULL_TREE, $1);
1254 check_for_new_type ("new", $3); }
1255 | new new_placement new_type_id new_initializer
1256 { $$ = build_new ($2, $3.t, $4, $1);
1257 check_for_new_type ("new", $3); }
1258 | new '(' type_id ')'
1259 %prec EMPTY
1260 { $$ = build_new (NULL_TREE, groktypename($3.t),
1261 NULL_TREE, $1);
1262 check_for_new_type ("new", $3); }
1263 | new '(' type_id ')' new_initializer
1264 { $$ = build_new (NULL_TREE, groktypename($3.t), $5, $1);
1265 check_for_new_type ("new", $3); }
1266 | new new_placement '(' type_id ')' %prec EMPTY
1267 { $$ = build_new ($2, groktypename($4.t), NULL_TREE, $1);
1268 check_for_new_type ("new", $4); }
1269 | new new_placement '(' type_id ')' new_initializer
1270 { $$ = build_new ($2, groktypename($4.t), $6, $1);
1271 check_for_new_type ("new", $4); }
1273 | delete cast_expr %prec UNARY
1274 { $$ = delete_sanity ($2, NULL_TREE, 0, $1); }
1275 | delete '[' ']' cast_expr %prec UNARY
1276 { $$ = delete_sanity ($4, NULL_TREE, 1, $1);
1277 if (yychar == YYEMPTY)
1278 yychar = YYLEX; }
1279 | delete '[' expr ']' cast_expr %prec UNARY
1280 { $$ = delete_sanity ($5, $3, 2, $1);
1281 if (yychar == YYEMPTY)
1282 yychar = YYLEX; }
1283 | REALPART cast_expr %prec UNARY
1284 { $$ = build_x_unary_op (REALPART_EXPR, $2); }
1285 | IMAGPART cast_expr %prec UNARY
1286 { $$ = build_x_unary_op (IMAGPART_EXPR, $2); }
1289 new_placement:
1290 '(' nonnull_exprlist ')'
1291 { $$ = $2; }
1292 | '{' nonnull_exprlist '}'
1293 { cp_pedwarn ("old style placement syntax, use () instead");
1294 $$ = $2; }
1297 new_initializer:
1298 '(' nonnull_exprlist ')'
1299 { $$ = $2; }
1300 | LEFT_RIGHT
1301 { $$ = void_zero_node; }
1302 | '(' typespec ')'
1304 cp_error ("`%T' is not a valid expression", $2.t);
1305 $$ = error_mark_node;
1307 /* GNU extension so people can use initializer lists. Note that
1308 this alters the meaning of `new int = 1', which was previously
1309 syntactically valid but semantically invalid.
1310 This feature is now deprecated and will be removed in a future
1311 release. */
1312 | '=' init
1314 if (pedantic)
1315 pedwarn ("ISO C++ forbids initialization of new expression with `='");
1316 cp_deprecated ("new initializer lists extension");
1317 if (TREE_CODE ($2) != TREE_LIST
1318 && TREE_CODE ($2) != CONSTRUCTOR)
1319 $$ = build_tree_list (NULL_TREE, $2);
1320 else
1321 $$ = $2;
1325 /* This is necessary to postpone reduction of `int ((int)(int)(int))'. */
1326 regcast_or_absdcl:
1327 '(' type_id ')' %prec EMPTY
1328 { $2.t = finish_parmlist (build_tree_list (NULL_TREE, $2.t), 0);
1329 $$ = make_call_declarator (NULL_TREE, $2.t, NULL_TREE, NULL_TREE);
1330 check_for_new_type ("cast", $2); }
1331 | regcast_or_absdcl '(' type_id ')' %prec EMPTY
1332 { $3.t = finish_parmlist (build_tree_list (NULL_TREE, $3.t), 0);
1333 $$ = make_call_declarator ($$, $3.t, NULL_TREE, NULL_TREE);
1334 check_for_new_type ("cast", $3); }
1337 cast_expr:
1338 unary_expr
1339 | regcast_or_absdcl unary_expr %prec UNARY
1340 { $$ = reparse_absdcl_as_casts ($$, $2); }
1341 | regcast_or_absdcl '{' initlist maybecomma '}' %prec UNARY
1343 tree init = build_nt (CONSTRUCTOR, NULL_TREE,
1344 nreverse ($3));
1345 if (pedantic)
1346 pedwarn ("ISO C++ forbids compound literals");
1347 /* Indicate that this was a C99 compound literal. */
1348 TREE_HAS_CONSTRUCTOR (init) = 1;
1350 $$ = reparse_absdcl_as_casts ($$, init);
1354 expr_no_commas:
1355 cast_expr
1356 /* Handle general members. */
1357 | expr_no_commas POINTSAT_STAR expr_no_commas
1358 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1359 | expr_no_commas DOT_STAR expr_no_commas
1360 { $$ = build_m_component_ref ($$, $3); }
1361 | expr_no_commas '+' expr_no_commas
1362 { $$ = build_x_binary_op ($2, $$, $3); }
1363 | expr_no_commas '-' expr_no_commas
1364 { $$ = build_x_binary_op ($2, $$, $3); }
1365 | expr_no_commas '*' expr_no_commas
1366 { $$ = build_x_binary_op ($2, $$, $3); }
1367 | expr_no_commas '/' expr_no_commas
1368 { $$ = build_x_binary_op ($2, $$, $3); }
1369 | expr_no_commas '%' expr_no_commas
1370 { $$ = build_x_binary_op ($2, $$, $3); }
1371 | expr_no_commas LSHIFT expr_no_commas
1372 { $$ = build_x_binary_op ($2, $$, $3); }
1373 | expr_no_commas RSHIFT expr_no_commas
1374 { $$ = build_x_binary_op ($2, $$, $3); }
1375 | expr_no_commas ARITHCOMPARE expr_no_commas
1376 { $$ = build_x_binary_op ($2, $$, $3); }
1377 | expr_no_commas '<' expr_no_commas
1378 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1379 | expr_no_commas '>' expr_no_commas
1380 { $$ = build_x_binary_op (GT_EXPR, $$, $3); }
1381 | expr_no_commas EQCOMPARE expr_no_commas
1382 { $$ = build_x_binary_op ($2, $$, $3); }
1383 | expr_no_commas MIN_MAX expr_no_commas
1384 { $$ = build_x_binary_op ($2, $$, $3); }
1385 | expr_no_commas '&' expr_no_commas
1386 { $$ = build_x_binary_op ($2, $$, $3); }
1387 | expr_no_commas '|' expr_no_commas
1388 { $$ = build_x_binary_op ($2, $$, $3); }
1389 | expr_no_commas '^' expr_no_commas
1390 { $$ = build_x_binary_op ($2, $$, $3); }
1391 | expr_no_commas ANDAND expr_no_commas
1392 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1393 | expr_no_commas OROR expr_no_commas
1394 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1395 | expr_no_commas '?' xexpr ':' expr_no_commas
1396 { $$ = build_x_conditional_expr ($$, $3, $5); }
1397 | expr_no_commas '=' expr_no_commas
1398 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1399 if ($$ != error_mark_node)
1400 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1401 | expr_no_commas ASSIGN expr_no_commas
1402 { $$ = build_x_modify_expr ($$, $2, $3); }
1403 | THROW
1404 { $$ = build_throw (NULL_TREE); }
1405 | THROW expr_no_commas
1406 { $$ = build_throw ($2); }
1409 expr_no_comma_rangle:
1410 cast_expr
1411 /* Handle general members. */
1412 | expr_no_comma_rangle POINTSAT_STAR expr_no_comma_rangle
1413 { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
1414 | expr_no_comma_rangle DOT_STAR expr_no_comma_rangle
1415 { $$ = build_m_component_ref ($$, $3); }
1416 | expr_no_comma_rangle '+' expr_no_comma_rangle
1417 { $$ = build_x_binary_op ($2, $$, $3); }
1418 | expr_no_comma_rangle '-' expr_no_comma_rangle
1419 { $$ = build_x_binary_op ($2, $$, $3); }
1420 | expr_no_comma_rangle '*' expr_no_comma_rangle
1421 { $$ = build_x_binary_op ($2, $$, $3); }
1422 | expr_no_comma_rangle '/' expr_no_comma_rangle
1423 { $$ = build_x_binary_op ($2, $$, $3); }
1424 | expr_no_comma_rangle '%' expr_no_comma_rangle
1425 { $$ = build_x_binary_op ($2, $$, $3); }
1426 | expr_no_comma_rangle LSHIFT expr_no_comma_rangle
1427 { $$ = build_x_binary_op ($2, $$, $3); }
1428 | expr_no_comma_rangle RSHIFT expr_no_comma_rangle
1429 { $$ = build_x_binary_op ($2, $$, $3); }
1430 | expr_no_comma_rangle ARITHCOMPARE expr_no_comma_rangle
1431 { $$ = build_x_binary_op ($2, $$, $3); }
1432 | expr_no_comma_rangle '<' expr_no_comma_rangle
1433 { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
1434 | expr_no_comma_rangle EQCOMPARE expr_no_comma_rangle
1435 { $$ = build_x_binary_op ($2, $$, $3); }
1436 | expr_no_comma_rangle MIN_MAX expr_no_comma_rangle
1437 { $$ = build_x_binary_op ($2, $$, $3); }
1438 | expr_no_comma_rangle '&' expr_no_comma_rangle
1439 { $$ = build_x_binary_op ($2, $$, $3); }
1440 | expr_no_comma_rangle '|' expr_no_comma_rangle
1441 { $$ = build_x_binary_op ($2, $$, $3); }
1442 | expr_no_comma_rangle '^' expr_no_comma_rangle
1443 { $$ = build_x_binary_op ($2, $$, $3); }
1444 | expr_no_comma_rangle ANDAND expr_no_comma_rangle
1445 { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
1446 | expr_no_comma_rangle OROR expr_no_comma_rangle
1447 { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
1448 | expr_no_comma_rangle '?' xexpr ':' expr_no_comma_rangle
1449 { $$ = build_x_conditional_expr ($$, $3, $5); }
1450 | expr_no_comma_rangle '=' expr_no_comma_rangle
1451 { $$ = build_x_modify_expr ($$, NOP_EXPR, $3);
1452 if ($$ != error_mark_node)
1453 C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
1454 | expr_no_comma_rangle ASSIGN expr_no_comma_rangle
1455 { $$ = build_x_modify_expr ($$, $2, $3); }
1456 | THROW
1457 { $$ = build_throw (NULL_TREE); }
1458 | THROW expr_no_comma_rangle
1459 { $$ = build_throw ($2); }
1462 notype_unqualified_id:
1463 '~' see_typename identifier
1464 { $$ = build_nt (BIT_NOT_EXPR, $3); }
1465 | '~' see_typename template_type
1466 { $$ = build_nt (BIT_NOT_EXPR, $3); }
1467 | template_id
1468 | operator_name
1469 | IDENTIFIER
1470 | PTYPENAME
1471 | NSNAME %prec EMPTY
1474 do_id:
1476 /* If lastiddecl is a TREE_LIST, it's a baselink, which
1477 means that we're in an expression like S::f<int>, so
1478 don't do_identifier; we only do that for unqualified
1479 identifiers. */
1480 if (!lastiddecl || TREE_CODE (lastiddecl) != TREE_LIST)
1481 $$ = do_identifier ($<ttype>-1, 1, NULL_TREE);
1482 else
1483 $$ = $<ttype>-1;
1486 template_id:
1487 PFUNCNAME '<' do_id template_arg_list_opt template_close_bracket
1488 { $$ = lookup_template_function ($3, $4); }
1489 | operator_name '<' do_id template_arg_list_opt template_close_bracket
1490 { $$ = lookup_template_function ($3, $4); }
1493 object_template_id:
1494 TEMPLATE identifier '<' template_arg_list_opt template_close_bracket
1495 { $$ = lookup_template_function ($2, $4); }
1496 | TEMPLATE PFUNCNAME '<' template_arg_list_opt template_close_bracket
1497 { $$ = lookup_template_function ($2, $4); }
1498 | TEMPLATE operator_name '<' template_arg_list_opt
1499 template_close_bracket
1500 { $$ = lookup_template_function ($2, $4); }
1503 unqualified_id:
1504 notype_unqualified_id
1505 | TYPENAME
1506 | SELFNAME
1509 expr_or_declarator_intern:
1510 expr_or_declarator
1511 | attributes expr_or_declarator
1513 /* Provide support for '(' attributes '*' declarator ')'
1514 etc */
1515 $$ = tree_cons ($1, $2, NULL_TREE);
1519 expr_or_declarator:
1520 notype_unqualified_id
1521 | '*' expr_or_declarator_intern %prec UNARY
1522 { $$ = build_nt (INDIRECT_REF, $2); }
1523 | '&' expr_or_declarator_intern %prec UNARY
1524 { $$ = build_nt (ADDR_EXPR, $2); }
1525 | '(' expr_or_declarator_intern ')'
1526 { $$ = $2; }
1529 notype_template_declarator:
1530 IDENTIFIER '<' template_arg_list_opt template_close_bracket
1531 { $$ = lookup_template_function ($1, $3); }
1532 | NSNAME '<' template_arg_list template_close_bracket
1533 { $$ = lookup_template_function ($1, $3); }
1536 direct_notype_declarator:
1537 complex_direct_notype_declarator
1538 /* This precedence declaration is to prefer this reduce
1539 to the Koenig lookup shift in primary, below. I hate yacc. */
1540 | notype_unqualified_id %prec '('
1541 | notype_template_declarator
1542 | '(' expr_or_declarator_intern ')'
1543 { $$ = finish_decl_parsing ($2); }
1546 primary:
1547 notype_unqualified_id
1549 if (TREE_CODE ($1) == BIT_NOT_EXPR)
1550 $$ = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND ($1, 0));
1551 else
1552 $$ = finish_id_expr ($1);
1554 | CONSTANT
1555 | boolean.literal
1556 | string
1558 $$ = combine_strings ($$);
1559 /* combine_strings doesn't set up TYPE_MAIN_VARIANT of
1560 a const array the way we want, so fix it. */
1561 if (flag_const_strings)
1562 TREE_TYPE ($$) = build_cplus_array_type
1563 (TREE_TYPE (TREE_TYPE ($$)),
1564 TYPE_DOMAIN (TREE_TYPE ($$)));
1566 | VAR_FUNC_NAME
1568 $$ = fname_decl (C_RID_CODE ($$), $$);
1569 if (processing_template_decl)
1570 $$ = build_min_nt (LOOKUP_EXPR, DECL_NAME ($$));
1572 | '(' expr ')'
1573 { $$ = finish_parenthesized_expr ($2); }
1574 | '(' expr_or_declarator_intern ')'
1575 { $2 = reparse_decl_as_expr (NULL_TREE, $2);
1576 $$ = finish_parenthesized_expr ($2); }
1577 | '(' error ')'
1578 { $$ = error_mark_node; }
1579 | '('
1580 { tree scope = current_scope ();
1581 if (!scope || TREE_CODE (scope) != FUNCTION_DECL)
1583 error ("braced-group within expression allowed only inside a function");
1584 YYERROR;
1586 if (pedantic)
1587 pedwarn ("ISO C++ forbids braced-groups within expressions");
1588 $<ttype>$ = begin_stmt_expr ();
1590 compstmt ')'
1591 { $$ = finish_stmt_expr ($<ttype>2); }
1592 /* Koenig lookup support
1593 We could store lastiddecl in $1 to avoid another lookup,
1594 but that would result in many additional reduce/reduce conflicts. */
1595 | notype_unqualified_id '(' nonnull_exprlist ')'
1596 { $$ = finish_call_expr ($1, $3, 1); }
1597 | notype_unqualified_id LEFT_RIGHT
1598 { $$ = finish_call_expr ($1, NULL_TREE, 1); }
1599 | primary '(' nonnull_exprlist ')'
1600 { $$ = finish_call_expr ($1, $3, 0); }
1601 | primary LEFT_RIGHT
1602 { $$ = finish_call_expr ($1, NULL_TREE, 0); }
1603 | VA_ARG '(' expr_no_commas ',' type_id ')'
1604 { $$ = build_x_va_arg ($3, groktypename ($5.t));
1605 check_for_new_type ("__builtin_va_arg", $5); }
1606 | primary '[' expr ']'
1607 { $$ = grok_array_decl ($$, $3); }
1608 | primary PLUSPLUS
1609 { $$ = finish_increment_expr ($1, POSTINCREMENT_EXPR); }
1610 | primary MINUSMINUS
1611 { $$ = finish_increment_expr ($1, POSTDECREMENT_EXPR); }
1612 /* C++ extensions */
1613 | THIS
1614 { $$ = finish_this_expr (); }
1615 | CV_QUALIFIER '(' nonnull_exprlist ')'
1617 /* This is a C cast in C++'s `functional' notation
1618 using the "implicit int" extension so that:
1619 `const (3)' is equivalent to `const int (3)'. */
1620 tree type;
1622 type = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
1623 type = groktypename (build_tree_list (type, NULL_TREE));
1624 $$ = build_functional_cast (type, $3);
1626 | functional_cast
1627 | DYNAMIC_CAST '<' type_id '>' '(' expr ')'
1628 { tree type = groktypename ($3.t);
1629 check_for_new_type ("dynamic_cast", $3);
1630 $$ = build_dynamic_cast (type, $6); }
1631 | STATIC_CAST '<' type_id '>' '(' expr ')'
1632 { tree type = groktypename ($3.t);
1633 check_for_new_type ("static_cast", $3);
1634 $$ = build_static_cast (type, $6); }
1635 | REINTERPRET_CAST '<' type_id '>' '(' expr ')'
1636 { tree type = groktypename ($3.t);
1637 check_for_new_type ("reinterpret_cast", $3);
1638 $$ = build_reinterpret_cast (type, $6); }
1639 | CONST_CAST '<' type_id '>' '(' expr ')'
1640 { tree type = groktypename ($3.t);
1641 check_for_new_type ("const_cast", $3);
1642 $$ = build_const_cast (type, $6); }
1643 | TYPEID '(' expr ')'
1644 { $$ = build_typeid ($3); }
1645 | TYPEID '(' type_id ')'
1646 { tree type = groktypename ($3.t);
1647 check_for_new_type ("typeid", $3);
1648 $$ = get_typeid (TYPE_MAIN_VARIANT (type)); }
1649 | global_scope IDENTIFIER
1650 { $$ = do_scoped_id ($2, 1); }
1651 | global_scope template_id
1652 { $$ = $2; }
1653 | global_scope operator_name
1655 got_scope = NULL_TREE;
1656 if (TREE_CODE ($2) == IDENTIFIER_NODE)
1657 $$ = do_scoped_id ($2, 1);
1658 else
1659 $$ = $2;
1661 | overqualified_id %prec HYPERUNARY
1662 { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); }
1663 | overqualified_id '(' nonnull_exprlist ')'
1664 { $$ = finish_qualified_call_expr ($1, $3); }
1665 | overqualified_id LEFT_RIGHT
1666 { $$ = finish_qualified_call_expr ($1, NULL_TREE); }
1667 | object object_template_id %prec UNARY
1669 $$ = build_x_component_ref ($$, $2, NULL_TREE, 1);
1671 | object object_template_id '(' nonnull_exprlist ')'
1672 { $$ = finish_object_call_expr ($2, $1, $4); }
1673 | object object_template_id LEFT_RIGHT
1674 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1675 | object unqualified_id %prec UNARY
1676 { $$ = build_x_component_ref ($$, $2, NULL_TREE, 1); }
1677 | object overqualified_id %prec UNARY
1678 { if (processing_template_decl)
1679 $$ = build_min_nt (COMPONENT_REF, $1, $2);
1680 else
1681 $$ = build_object_ref ($$, OP0 ($2), OP1 ($2)); }
1682 | object unqualified_id '(' nonnull_exprlist ')'
1683 { $$ = finish_object_call_expr ($2, $1, $4); }
1684 | object unqualified_id LEFT_RIGHT
1685 { $$ = finish_object_call_expr ($2, $1, NULL_TREE); }
1686 | object overqualified_id '(' nonnull_exprlist ')'
1687 { $$ = finish_qualified_object_call_expr ($2, $1, $4); }
1688 | object overqualified_id LEFT_RIGHT
1689 { $$ = finish_qualified_object_call_expr ($2, $1, NULL_TREE); }
1690 /* p->int::~int() is valid -- 12.4 */
1691 | object '~' TYPESPEC LEFT_RIGHT
1692 { $$ = finish_pseudo_destructor_call_expr ($1, NULL_TREE, $3); }
1693 | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT
1694 { $$ = finish_pseudo_destructor_call_expr ($1, $2, $5); }
1695 | object error
1697 $$ = error_mark_node;
1701 /* Not needed for now.
1703 primary_no_id:
1704 '(' expr ')'
1705 { $$ = $2; }
1706 | '(' error ')'
1707 { $$ = error_mark_node; }
1708 | '('
1709 { if (current_function_decl == 0)
1711 error ("braced-group within expression allowed only inside a function");
1712 YYERROR;
1714 $<ttype>$ = expand_start_stmt_expr (); }
1715 compstmt ')'
1716 { if (pedantic)
1717 pedwarn ("ISO C++ forbids braced-groups within expressions");
1718 $$ = expand_end_stmt_expr ($<ttype>2); }
1719 | primary_no_id '(' nonnull_exprlist ')'
1720 { $$ = build_x_function_call ($$, $3, current_class_ref); }
1721 | primary_no_id LEFT_RIGHT
1722 { $$ = build_x_function_call ($$, NULL_TREE, current_class_ref); }
1723 | primary_no_id '[' expr ']'
1724 { goto do_array; }
1725 | primary_no_id PLUSPLUS
1726 { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
1727 | primary_no_id MINUSMINUS
1728 { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
1729 | SCOPE IDENTIFIER
1730 { goto do_scoped_id; }
1731 | SCOPE operator_name
1732 { if (TREE_CODE ($2) == IDENTIFIER_NODE)
1733 goto do_scoped_id;
1734 goto do_scoped_operator;
1739 new:
1741 { $$ = 0; }
1742 | global_scope NEW
1743 { got_scope = NULL_TREE; $$ = 1; }
1746 delete:
1747 DELETE
1748 { $$ = 0; }
1749 | global_scope delete
1750 { got_scope = NULL_TREE; $$ = 1; }
1753 boolean.literal:
1754 CXX_TRUE
1755 { $$ = boolean_true_node; }
1756 | CXX_FALSE
1757 { $$ = boolean_false_node; }
1760 /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
1761 string:
1762 STRING
1763 | string STRING
1764 { $$ = chainon ($$, $2); }
1767 nodecls:
1768 /* empty */
1770 setup_vtbl_ptr (NULL_TREE, NULL_TREE);
1774 object:
1775 primary '.'
1776 { got_object = TREE_TYPE ($$); }
1777 | primary POINTSAT
1779 $$ = build_x_arrow ($$);
1780 got_object = TREE_TYPE ($$);
1784 decl:
1785 typespec initdecls ';'
1787 if ($1.t && IS_AGGR_TYPE_CODE (TREE_CODE ($1.t)))
1788 note_got_semicolon ($1.t);
1790 | typed_declspecs initdecls ';'
1792 note_list_got_semicolon ($1.t);
1794 | declmods notype_initdecls ';'
1796 | typed_declspecs ';'
1798 shadow_tag ($1.t);
1799 note_list_got_semicolon ($1.t);
1801 | declmods ';'
1802 { warning ("empty declaration"); }
1803 | extension decl
1804 { pedantic = $1; }
1807 /* Any kind of declarator (thus, all declarators allowed
1808 after an explicit typespec). */
1810 declarator:
1811 after_type_declarator %prec EMPTY
1812 | notype_declarator %prec EMPTY
1815 /* This is necessary to postpone reduction of `int()()()()'. */
1816 fcast_or_absdcl:
1817 LEFT_RIGHT %prec EMPTY
1818 { $$ = make_call_declarator (NULL_TREE, empty_parms (),
1819 NULL_TREE, NULL_TREE); }
1820 | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
1821 { $$ = make_call_declarator ($$, empty_parms (), NULL_TREE,
1822 NULL_TREE); }
1825 /* ISO type-id (8.1) */
1826 type_id:
1827 typed_typespecs absdcl
1828 { $$.t = build_tree_list ($1.t, $2);
1829 $$.new_type_flag = $1.new_type_flag; }
1830 | nonempty_cv_qualifiers absdcl
1831 { $$.t = build_tree_list ($1.t, $2);
1832 $$.new_type_flag = $1.new_type_flag; }
1833 | typespec absdcl
1834 { $$.t = build_tree_list (build_tree_list (NULL_TREE, $1.t),
1835 $2);
1836 $$.new_type_flag = $1.new_type_flag; }
1837 | typed_typespecs %prec EMPTY
1838 { $$.t = build_tree_list ($1.t, NULL_TREE);
1839 $$.new_type_flag = $1.new_type_flag; }
1840 | nonempty_cv_qualifiers %prec EMPTY
1841 { $$.t = build_tree_list ($1.t, NULL_TREE);
1842 $$.new_type_flag = $1.new_type_flag; }
1845 /* Declspecs which contain at least one type specifier or typedef name.
1846 (Just `const' or `volatile' is not enough.)
1847 A typedef'd name following these is taken as a name to be declared.
1848 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1850 typed_declspecs:
1851 typed_typespecs %prec EMPTY
1852 { $$.lookups = type_lookups; }
1853 | typed_declspecs1
1854 { $$.lookups = type_lookups; }
1857 typed_declspecs1:
1858 declmods typespec
1859 { $$.t = tree_cons (NULL_TREE, $2.t, $1.t);
1860 $$.new_type_flag = $2.new_type_flag; }
1861 | typespec reserved_declspecs %prec HYPERUNARY
1862 { $$.t = tree_cons (NULL_TREE, $1.t, $2);
1863 $$.new_type_flag = $1.new_type_flag; }
1864 | typespec reserved_typespecquals reserved_declspecs
1865 { $$.t = tree_cons (NULL_TREE, $1.t, chainon ($2, $3));
1866 $$.new_type_flag = $1.new_type_flag; }
1867 | declmods typespec reserved_declspecs
1868 { $$.t = tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1869 $$.new_type_flag = $2.new_type_flag; }
1870 | declmods typespec reserved_typespecquals
1871 { $$.t = tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1872 $$.new_type_flag = $2.new_type_flag; }
1873 | declmods typespec reserved_typespecquals reserved_declspecs
1874 { $$.t = tree_cons (NULL_TREE, $2.t,
1875 chainon ($3, chainon ($4, $1.t)));
1876 $$.new_type_flag = $2.new_type_flag; }
1879 reserved_declspecs:
1880 SCSPEC
1881 { if (extra_warnings)
1882 warning ("`%s' is not at beginning of declaration",
1883 IDENTIFIER_POINTER ($$));
1884 $$ = build_tree_list (NULL_TREE, $$); }
1885 | reserved_declspecs typespecqual_reserved
1886 { $$ = tree_cons (NULL_TREE, $2.t, $$); }
1887 | reserved_declspecs SCSPEC
1888 { if (extra_warnings)
1889 warning ("`%s' is not at beginning of declaration",
1890 IDENTIFIER_POINTER ($2));
1891 $$ = tree_cons (NULL_TREE, $2, $$); }
1892 | reserved_declspecs attributes
1893 { $$ = tree_cons ($2, NULL_TREE, $1); }
1894 | attributes
1895 { $$ = tree_cons ($1, NULL_TREE, NULL_TREE); }
1898 /* List of just storage classes and type modifiers.
1899 A declaration can start with just this, but then it cannot be used
1900 to redeclare a typedef-name.
1901 In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
1903 /* We use hash_tree_cons for lists of typeless declspecs so that they end
1904 up on a persistent obstack. Otherwise, they could appear at the
1905 beginning of something like
1907 static const struct { int foo () { } } b;
1909 and would be discarded after we finish compiling foo. We don't need to
1910 worry once we see a type. */
1912 declmods:
1913 nonempty_cv_qualifiers %prec EMPTY
1914 { $$.lookups = NULL_TREE; TREE_STATIC ($$.t) = 1; }
1915 | SCSPEC
1917 $$.t = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
1918 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
1920 | declmods CV_QUALIFIER
1922 $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
1923 TREE_STATIC ($$.t) = 1;
1925 | declmods SCSPEC
1927 if (extra_warnings && TREE_STATIC ($$.t))
1928 warning ("`%s' is not at beginning of declaration",
1929 IDENTIFIER_POINTER ($2));
1930 $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
1931 TREE_STATIC ($$.t) = TREE_STATIC ($1.t);
1933 | declmods attributes
1934 { $$.t = hash_tree_cons ($2, NULL_TREE, $1.t); }
1935 | attributes %prec EMPTY
1937 $$.t = hash_tree_cons ($1, NULL_TREE, NULL_TREE);
1938 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
1942 /* Used instead of declspecs where storage classes are not allowed
1943 (that is, for typenames and structure components).
1945 C++ can takes storage classes for structure components.
1946 Don't accept a typedef-name if anything but a modifier precedes it. */
1948 typed_typespecs:
1949 typespec %prec EMPTY
1950 { $$.t = build_tree_list (NULL_TREE, $1.t);
1951 $$.new_type_flag = $1.new_type_flag; }
1952 | nonempty_cv_qualifiers typespec
1953 { $$.t = tree_cons (NULL_TREE, $2.t, $1.t);
1954 $$.new_type_flag = $2.new_type_flag; }
1955 | typespec reserved_typespecquals
1956 { $$.t = tree_cons (NULL_TREE, $1.t, $2);
1957 $$.new_type_flag = $1.new_type_flag; }
1958 | nonempty_cv_qualifiers typespec reserved_typespecquals
1959 { $$.t = tree_cons (NULL_TREE, $2.t, chainon ($3, $1.t));
1960 $$.new_type_flag = $2.new_type_flag; }
1963 reserved_typespecquals:
1964 typespecqual_reserved
1965 { $$ = build_tree_list (NULL_TREE, $1.t); }
1966 | reserved_typespecquals typespecqual_reserved
1967 { $$ = tree_cons (NULL_TREE, $2.t, $1); }
1970 /* A typespec (but not a type qualifier).
1971 Once we have seen one of these in a declaration,
1972 if a typedef name appears then it is being redeclared. */
1974 typespec:
1975 structsp
1976 { $$.lookups = NULL_TREE; }
1977 | TYPESPEC %prec EMPTY
1978 { $$.t = $1; $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
1979 | complete_type_name
1980 { $$.t = $1; $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
1981 | TYPEOF '(' expr ')'
1982 { $$.t = finish_typeof ($3);
1983 $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
1984 | TYPEOF '(' type_id ')'
1985 { $$.t = groktypename ($3.t);
1986 $$.new_type_flag = 0; $$.lookups = NULL_TREE; }
1987 | SIGOF '(' expr ')'
1988 { tree type = TREE_TYPE ($3);
1990 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
1991 if (IS_AGGR_TYPE (type))
1993 sorry ("sigof type specifier");
1994 $$.t = type;
1996 else
1998 error ("`sigof' applied to non-aggregate expression");
1999 $$.t = error_mark_node;
2002 | SIGOF '(' type_id ')'
2003 { tree type = groktypename ($3.t);
2005 $$.new_type_flag = 0; $$.lookups = NULL_TREE;
2006 if (IS_AGGR_TYPE (type))
2008 sorry ("sigof type specifier");
2009 $$.t = type;
2011 else
2013 error("`sigof' applied to non-aggregate type");
2014 $$.t = error_mark_node;
2019 /* A typespec that is a reserved word, or a type qualifier. */
2021 typespecqual_reserved:
2022 TYPESPEC
2023 { $$.t = $1; $$.new_type_flag = 0; }
2024 | CV_QUALIFIER
2025 { $$.t = $1; $$.new_type_flag = 0; }
2026 | structsp
2029 initdecls:
2030 initdcl0
2031 | initdecls ',' initdcl
2032 { check_multiple_declarators (); }
2035 notype_initdecls:
2036 notype_initdcl0
2037 | notype_initdecls ',' initdcl
2038 { check_multiple_declarators (); }
2041 nomods_initdecls:
2042 nomods_initdcl0
2043 | nomods_initdecls ',' initdcl
2044 { check_multiple_declarators (); }
2047 maybeasm:
2048 /* empty */
2049 { $$ = NULL_TREE; }
2050 | asm_keyword '(' string ')'
2051 { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); $$ = $3; }
2054 initdcl:
2055 declarator maybeasm maybe_attribute '='
2056 { $<ttype>$ = parse_decl ($<ttype>1, $3, 1); }
2057 init
2058 /* Note how the declaration of the variable is in effect while its init is parsed! */
2059 { parse_end_decl ($<ttype>5, $6, $2); }
2060 | declarator maybeasm maybe_attribute
2062 $<ttype>$ = parse_decl ($<ttype>1, $3, 0);
2063 parse_end_decl ($<ttype>$, NULL_TREE, $2);
2067 /* This rule assumes a certain configuration of the parser stack.
2068 In particular, $0, the element directly before the beginning of
2069 this rule on the stack, must be a maybeasm. $-1 must be a
2070 declarator or notype_declarator. And $-2 must be some declmods
2071 or declspecs. We can't move the maybeasm into this rule because
2072 we need that reduce so we prefer fn.def1 when appropriate. */
2073 initdcl0_innards:
2074 maybe_attribute '='
2075 { $<ttype>$ = parse_decl0 ($<ttype>-1, $<ftype>-2.t,
2076 $<ftype>-2.lookups, $1, 1); }
2077 /* Note how the declaration of the variable is in effect
2078 while its init is parsed! */
2079 init
2080 { parse_end_decl ($<ttype>3, $4, $<ttype>0); }
2081 | maybe_attribute
2082 { tree d = parse_decl0 ($<ttype>-1, $<ftype>-2.t,
2083 $<ftype>-2.lookups, $1, 0);
2084 parse_end_decl (d, NULL_TREE, $<ttype>0); }
2087 initdcl0:
2088 declarator maybeasm initdcl0_innards
2092 notype_initdcl0:
2093 notype_declarator maybeasm initdcl0_innards
2097 nomods_initdcl0:
2098 notype_declarator maybeasm
2099 { /* Set things up as initdcl0_innards expects. */
2100 $<ttype>3 = $2;
2101 $2 = $1;
2102 $<ftype>1.t = NULL_TREE;
2103 $<ftype>1.lookups = NULL_TREE; }
2104 initdcl0_innards
2106 | constructor_declarator maybeasm maybe_attribute
2107 { tree d = parse_decl0 ($1, NULL_TREE, NULL_TREE, $3, 0);
2108 parse_end_decl (d, NULL_TREE, $2); }
2111 /* the * rules are dummies to accept the Apollo extended syntax
2112 so that the header files compile. */
2113 maybe_attribute:
2114 /* empty */
2115 { $$ = NULL_TREE; }
2116 | attributes
2117 { $$ = $1; }
2120 attributes:
2121 attribute
2122 { $$ = $1; }
2123 | attributes attribute
2124 { $$ = chainon ($1, $2); }
2127 attribute:
2128 ATTRIBUTE '(' '(' attribute_list ')' ')'
2129 { $$ = $4; }
2132 attribute_list:
2133 attrib
2134 { $$ = $1; }
2135 | attribute_list ',' attrib
2136 { $$ = chainon ($1, $3); }
2139 attrib:
2140 /* empty */
2141 { $$ = NULL_TREE; }
2142 | any_word
2143 { $$ = build_tree_list ($1, NULL_TREE); }
2144 | any_word '(' IDENTIFIER ')'
2145 { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
2146 | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
2147 { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
2148 | any_word '(' nonnull_exprlist ')'
2149 { $$ = build_tree_list ($1, $3); }
2152 /* This still leaves out most reserved keywords,
2153 shouldn't we include them? */
2155 any_word:
2156 identifier
2157 | SCSPEC
2158 | TYPESPEC
2159 | CV_QUALIFIER
2162 /* A nonempty list of identifiers, including typenames. */
2163 identifiers_or_typenames:
2164 identifier
2165 { $$ = build_tree_list (NULL_TREE, $1); }
2166 | identifiers_or_typenames ',' identifier
2167 { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
2170 maybe_init:
2171 /* empty */ %prec EMPTY
2172 { $$ = NULL_TREE; }
2173 | '=' init
2174 { $$ = $2; }
2176 /* If we are processing a template, we don't want to expand this
2177 initializer yet. */
2179 init:
2180 expr_no_commas %prec '='
2181 | '{' '}'
2182 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
2183 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2184 | '{' initlist '}'
2185 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2186 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2187 | '{' initlist ',' '}'
2188 { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
2189 TREE_HAS_CONSTRUCTOR ($$) = 1; }
2190 | error
2191 { $$ = NULL_TREE; }
2194 /* This chain is built in reverse order,
2195 and put in forward order where initlist is used. */
2196 initlist:
2197 init
2198 { $$ = build_tree_list (NULL_TREE, $$); }
2199 | initlist ',' init
2200 { $$ = tree_cons (NULL_TREE, $3, $$); }
2201 /* These are for labeled elements. */
2202 | '[' expr_no_commas ']' init
2203 { $$ = build_tree_list ($2, $4); }
2204 | identifier ':' init
2205 { $$ = build_tree_list ($$, $3); }
2206 | initlist ',' identifier ':' init
2207 { $$ = tree_cons ($3, $5, $$); }
2210 pending_inline:
2211 PRE_PARSED_FUNCTION_DECL maybe_return_init ctor_initializer_opt compstmt_or_error
2213 expand_body (finish_function ((int)$3 | 2));
2214 process_next_inline ($1);
2216 | PRE_PARSED_FUNCTION_DECL maybe_return_init function_try_block
2218 expand_body (finish_function ((int)$3 | 2));
2219 process_next_inline ($1);
2221 | PRE_PARSED_FUNCTION_DECL maybe_return_init error
2223 finish_function (2);
2224 process_next_inline ($1); }
2227 pending_inlines:
2228 /* empty */
2229 | pending_inlines pending_inline eat_saved_input
2232 /* A regurgitated default argument. The value of DEFARG_MARKER will be
2233 the TREE_LIST node for the parameter in question. */
2234 defarg_again:
2235 DEFARG_MARKER expr_no_commas END_OF_SAVED_INPUT
2236 { replace_defarg ($1, $2); }
2237 | DEFARG_MARKER error END_OF_SAVED_INPUT
2238 { replace_defarg ($1, error_mark_node); }
2240 pending_defargs:
2241 /* empty */ %prec EMPTY
2242 | pending_defargs defarg_again
2243 { do_pending_defargs (); }
2244 | pending_defargs error
2245 { do_pending_defargs (); }
2248 structsp:
2249 ENUM identifier '{'
2250 { $<ttype>$ = current_enum_type;
2251 current_enum_type = start_enum ($2); }
2252 enumlist_opt '}'
2253 { $$.t = current_enum_type;
2254 finish_enum (current_enum_type);
2255 $$.new_type_flag = 1;
2256 current_enum_type = $<ttype>4;
2257 check_for_missing_semicolon ($$.t); }
2258 | ENUM '{'
2259 { $<ttype>$ = current_enum_type;
2260 current_enum_type = start_enum (make_anon_name ()); }
2261 enumlist_opt '}'
2262 { $$.t = current_enum_type;
2263 finish_enum (current_enum_type);
2264 $$.new_type_flag = 1;
2265 current_enum_type = $<ttype>3;
2266 check_for_missing_semicolon ($$.t); }
2267 | ENUM identifier
2268 { $$.t = xref_tag (enum_type_node, $2, 1);
2269 $$.new_type_flag = 0; }
2270 | ENUM complex_type_name
2271 { $$.t = xref_tag (enum_type_node, $2, 1);
2272 $$.new_type_flag = 0; }
2273 | TYPENAME_KEYWORD typename_sub
2274 { $$.t = $2;
2275 $$.new_type_flag = 0;
2276 if (!processing_template_decl)
2277 cp_pedwarn ("using `typename' outside of template"); }
2278 /* C++ extensions, merged with C to avoid shift/reduce conflicts */
2279 | class_head '{'
2280 { $1.t = begin_class_definition ($1.t);
2281 current_aggr = NULL_TREE; }
2282 opt.component_decl_list '}' maybe_attribute
2284 int semi;
2285 tree t;
2287 if (yychar == YYEMPTY)
2288 yychar = YYLEX;
2289 semi = yychar == ';';
2291 t = finish_class_definition ($1.t, $6, semi,
2292 $1.new_type_flag);
2293 $<ttype>$ = t;
2295 /* restore current_aggr */
2296 current_aggr = TREE_CODE (t) != RECORD_TYPE
2297 ? union_type_node
2298 : CLASSTYPE_DECLARED_CLASS (t)
2299 ? class_type_node : record_type_node;
2301 pending_defargs
2303 done_pending_defargs ();
2304 begin_inline_definitions ();
2306 pending_inlines
2308 finish_inline_definitions ();
2309 $$.t = $<ttype>7;
2310 $$.new_type_flag = 1;
2312 | class_head %prec EMPTY
2314 if ($1.new_type_flag && $1.t != error_mark_node)
2315 pop_scope (CP_DECL_CONTEXT (TYPE_MAIN_DECL ($1.t)));
2316 $$.new_type_flag = 0;
2317 if ($1.t == error_mark_node)
2318 $$.t = $1.t;
2319 else if (TYPE_BINFO ($1.t) == NULL_TREE)
2321 cp_error ("%T is not a class type", $1.t);
2322 $$.t = error_mark_node;
2324 else
2326 $$.t = $1.t;
2327 /* struct B: public A; is not accepted by the standard grammar. */
2328 if (CLASS_TYPE_P ($$.t)
2329 && TYPE_BINFO_BASETYPES ($$.t)
2330 && !COMPLETE_TYPE_P ($$.t)
2331 && ! TYPE_BEING_DEFINED ($$.t))
2332 cp_error ("base clause without member specification for `%#T'",
2333 $$.t);
2338 maybecomma:
2339 /* empty */
2340 | ','
2343 maybecomma_warn:
2344 /* empty */
2345 | ','
2346 { if (pedantic && !in_system_header)
2347 pedwarn ("comma at end of enumerator list"); }
2350 aggr:
2351 AGGR
2352 | aggr SCSPEC
2353 { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2354 | aggr TYPESPEC
2355 { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2356 | aggr CV_QUALIFIER
2357 { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
2358 | aggr AGGR
2359 { error ("no body nor ';' separates two class, struct or union declarations"); }
2360 | aggr attributes
2361 { $$ = build_tree_list ($2, $1); }
2364 named_class_head_sans_basetype:
2365 aggr identifier
2367 current_aggr = $1;
2368 $$ = $2;
2372 named_class_head_sans_basetype_defn:
2373 aggr identifier_defn %prec EMPTY
2374 { current_aggr = $$; $$ = $2; }
2375 | named_class_head_sans_basetype '{'
2376 { yyungetc ('{', 1); }
2377 | named_class_head_sans_basetype ':'
2378 { yyungetc (':', 1); }
2381 named_complex_class_head_sans_basetype:
2382 aggr nested_name_specifier identifier
2384 current_aggr = $1;
2385 $$.t = handle_class_head ($1, $2, $3);
2386 $$.new_type_flag = 1;
2388 | aggr global_scope nested_name_specifier identifier
2390 current_aggr = $1;
2391 $$.t = handle_class_head ($1, $3, $4);
2392 $$.new_type_flag = 1;
2394 | aggr global_scope identifier
2396 current_aggr = $1;
2397 $$.t = handle_class_head ($1, NULL_TREE, $3);
2398 $$.new_type_flag = 1;
2400 | aggr apparent_template_type
2402 current_aggr = $1;
2403 $$.t = $2;
2404 $$.new_type_flag = 0;
2406 | aggr nested_name_specifier apparent_template_type
2408 current_aggr = $1;
2409 $$.t = $3;
2410 push_scope (CP_DECL_CONTEXT ($$.t));
2411 $$.new_type_flag = 1;
2413 | aggr global_scope nested_name_specifier apparent_template_type
2415 current_aggr = $1;
2416 $$.t = $4;
2417 push_scope (CP_DECL_CONTEXT ($$.t));
2418 $$.new_type_flag = 1;
2422 named_class_head:
2423 named_class_head_sans_basetype %prec EMPTY
2425 $$.t = xref_tag (current_aggr, $1, 1);
2426 $$.new_type_flag = 0;
2428 | named_class_head_sans_basetype_defn
2429 { $<ttype>$ = xref_tag (current_aggr, $1, 0); }
2430 /* Class name is unqualified, so we look for base classes
2431 in the current scope. */
2432 maybe_base_class_list %prec EMPTY
2434 $$.t = $<ttype>2;
2435 $$.new_type_flag = 0;
2436 if ($3)
2437 xref_basetypes (current_aggr, $1, $<ttype>2, $3);
2439 | named_complex_class_head_sans_basetype
2440 maybe_base_class_list
2442 if ($1.t != error_mark_node)
2444 tree type = TREE_TYPE ($1.t);
2446 $$.t = type;
2447 $$.new_type_flag = $1.new_type_flag;
2448 if ((current_aggr == union_type_node)
2449 != (TREE_CODE (type) == UNION_TYPE))
2450 cp_pedwarn (current_aggr == union_type_node
2451 ? "`union' tag used in declaring `%#T'"
2452 : "non-`union' tag used in declaring `%#T'",
2453 type);
2454 else if (TREE_CODE (type) == RECORD_TYPE)
2455 /* We might be specializing a template with a different
2456 class-key; deal. */
2457 CLASSTYPE_DECLARED_CLASS (type)
2458 = (current_aggr == class_type_node);
2459 if ($2)
2461 if (TREE_CODE (type) == TYPENAME_TYPE)
2462 /* In a definition of a member class template, we
2463 will get here with an implicit typename, a
2464 TYPENAME_TYPE with a type. */
2465 type = TREE_TYPE (type);
2466 maybe_process_partial_specialization (type);
2467 xref_basetypes (current_aggr, $1.t, type, $2);
2473 unnamed_class_head:
2474 aggr '{'
2475 { $$ = xref_tag ($$, make_anon_name (), 0);
2476 yyungetc ('{', 1); }
2479 /* The tree output of this nonterminal a declarationf or the type
2480 named. If NEW_TYPE_FLAG is set, then the name used in this
2481 class-head was explicitly qualified, e.g.: `struct X::Y'. We have
2482 already called push_scope for X. */
2483 class_head:
2484 unnamed_class_head
2486 $$.t = $1;
2487 $$.new_type_flag = 0;
2489 | named_class_head
2492 maybe_base_class_list:
2493 /* empty */ %prec EMPTY
2494 { $$ = NULL_TREE; }
2495 | ':' see_typename %prec EMPTY
2496 { yyungetc(':', 1); $$ = NULL_TREE; }
2497 | ':' see_typename base_class_list %prec EMPTY
2498 { $$ = $3; }
2501 base_class_list:
2502 base_class
2503 | base_class_list ',' see_typename base_class
2504 { $$ = chainon ($$, $4); }
2507 base_class:
2508 base_class.1
2509 { $$ = finish_base_specifier (access_default_node, $1); }
2510 | base_class_access_list see_typename base_class.1
2511 { $$ = finish_base_specifier ($1, $3); }
2514 base_class.1:
2515 typename_sub
2516 { if (!TYPE_P ($$))
2517 $$ = error_mark_node; }
2518 | nonnested_type
2519 { $$ = TREE_TYPE ($$); }
2522 base_class_access_list:
2523 VISSPEC see_typename
2524 | SCSPEC see_typename
2525 { if ($1 != ridpointers[(int)RID_VIRTUAL])
2526 cp_error ("`%D' access", $1);
2527 $$ = access_default_virtual_node; }
2528 | base_class_access_list VISSPEC see_typename
2530 if ($1 != access_default_virtual_node)
2531 error ("multiple access specifiers");
2532 else if ($2 == access_public_node)
2533 $$ = access_public_virtual_node;
2534 else if ($2 == access_protected_node)
2535 $$ = access_protected_virtual_node;
2536 else /* $2 == access_private_node */
2537 $$ = access_private_virtual_node;
2539 | base_class_access_list SCSPEC see_typename
2540 { if ($2 != ridpointers[(int)RID_VIRTUAL])
2541 cp_error ("`%D' access", $2);
2542 else if ($$ == access_public_node)
2543 $$ = access_public_virtual_node;
2544 else if ($$ == access_protected_node)
2545 $$ = access_protected_virtual_node;
2546 else if ($$ == access_private_node)
2547 $$ = access_private_virtual_node;
2548 else
2549 error ("multiple `virtual' specifiers");
2553 opt.component_decl_list:
2554 | component_decl_list
2555 | opt.component_decl_list access_specifier component_decl_list
2556 | opt.component_decl_list access_specifier
2559 access_specifier:
2560 VISSPEC ':'
2562 current_access_specifier = $1;
2566 /* Note: we no longer warn about the semicolon after a component_decl_list.
2567 ARM $9.2 says that the semicolon is optional, and therefore allowed. */
2568 component_decl_list:
2569 component_decl
2571 finish_member_declaration ($1);
2572 current_aggr = NULL_TREE;
2573 reset_type_access_control ();
2575 | component_decl_list component_decl
2577 finish_member_declaration ($2);
2578 current_aggr = NULL_TREE;
2579 reset_type_access_control ();
2583 component_decl:
2584 component_decl_1 ';'
2585 | component_decl_1 '}'
2586 { error ("missing ';' before right brace");
2587 yyungetc ('}', 0); }
2588 /* C++: handle constructors, destructors and inline functions */
2589 /* note that INLINE is like a TYPESPEC */
2590 | fn.def2 ':' /* base_init compstmt */
2591 { $$ = finish_method ($$); }
2592 | fn.def2 TRY /* base_init compstmt */
2593 { $$ = finish_method ($$); }
2594 | fn.def2 RETURN_KEYWORD /* base_init compstmt */
2595 { $$ = finish_method ($$); }
2596 | fn.def2 '{' /* nodecls compstmt */
2597 { $$ = finish_method ($$); }
2598 | ';'
2599 { $$ = NULL_TREE; }
2600 | extension component_decl
2601 { $$ = $2;
2602 pedantic = $1; }
2603 | template_header component_decl
2605 if ($2)
2606 $$ = finish_member_template_decl ($2);
2607 else
2608 /* The component was already processed. */
2609 $$ = NULL_TREE;
2611 finish_template_decl ($1);
2613 | template_header typed_declspecs ';'
2615 $$ = finish_member_class_template ($2.t);
2616 finish_template_decl ($1);
2618 | bad_decl
2619 { $$ = NULL_TREE; }
2622 component_decl_1:
2623 /* Do not add a "typed_declspecs declarator" rule here for
2624 speed; we need to call grok_x_components for enums, so the
2625 speedup would be insignificant. */
2626 typed_declspecs components
2628 /* Most of the productions for component_decl only
2629 allow the creation of one new member, so we call
2630 finish_member_declaration in component_decl_list.
2631 For this rule and the next, however, there can be
2632 more than one member, e.g.:
2634 int i, j;
2636 and we need the first member to be fully
2637 registered before the second is processed.
2638 Therefore, the rules for components take care of
2639 this processing. To avoid registering the
2640 components more than once, we send NULL_TREE up
2641 here; that lets finish_member_declaration know
2642 that there is nothing to do. */
2643 if (!$2)
2644 grok_x_components ($1.t);
2645 $$ = NULL_TREE;
2647 | declmods notype_components
2649 if (!$2)
2650 grok_x_components ($1.t);
2651 $$ = NULL_TREE;
2653 | notype_declarator maybeasm maybe_attribute maybe_init
2654 { $$ = grokfield ($$, NULL_TREE, $4, $2, $3); }
2655 | constructor_declarator maybeasm maybe_attribute maybe_init
2656 { $$ = grokfield ($$, NULL_TREE, $4, $2, $3); }
2657 | ':' expr_no_commas
2658 { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
2659 | error
2660 { $$ = NULL_TREE; }
2662 /* These rules introduce a reduce/reduce conflict; in
2663 typedef int foo, bar;
2664 class A {
2665 foo (bar);
2667 should "A::foo" be declared as a function or "A::bar" as a data
2668 member? In other words, is "bar" an after_type_declarator or a
2669 parmlist? */
2670 | declmods component_constructor_declarator maybeasm maybe_attribute maybe_init
2671 { tree specs, attrs;
2672 split_specs_attrs ($1.t, &specs, &attrs);
2673 $$ = grokfield ($2, specs, $5, $3,
2674 chainon ($4, attrs)); }
2675 | component_constructor_declarator maybeasm maybe_attribute maybe_init
2676 { $$ = grokfield ($$, NULL_TREE, $4, $2, $3); }
2677 | using_decl
2678 { $$ = do_class_using_decl ($1); }
2680 /* The case of exactly one component is handled directly by component_decl. */
2681 /* ??? Huh? ^^^ */
2682 components:
2683 /* empty: possibly anonymous */
2684 { $$ = 0; }
2685 | component_declarator0
2687 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2688 $1 = finish_member_template_decl ($1);
2689 finish_member_declaration ($1);
2690 $$ = 1;
2692 | components ',' component_declarator
2694 check_multiple_declarators ();
2695 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2696 $3 = finish_member_template_decl ($3);
2697 finish_member_declaration ($3);
2698 $$ = 2;
2702 notype_components:
2703 /* empty: possibly anonymous */
2704 { $$ = 0; }
2705 | notype_component_declarator0
2707 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2708 $1 = finish_member_template_decl ($1);
2709 finish_member_declaration ($1);
2710 $$ = 1;
2712 | notype_components ',' notype_component_declarator
2714 check_multiple_declarators ();
2715 if (PROCESSING_REAL_TEMPLATE_DECL_P ())
2716 $3 = finish_member_template_decl ($3);
2717 finish_member_declaration ($3);
2718 $$ = 2;
2722 component_declarator0:
2723 after_type_component_declarator0
2724 | notype_component_declarator0
2727 component_declarator:
2728 after_type_component_declarator
2729 | notype_component_declarator
2732 after_type_component_declarator0:
2733 after_type_declarator maybeasm maybe_attribute maybe_init
2734 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2735 $3, $2, $4); }
2736 | TYPENAME ':' expr_no_commas maybe_attribute
2737 { $$ = parse_bitfield0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2738 $4, $3); }
2741 notype_component_declarator0:
2742 notype_declarator maybeasm maybe_attribute maybe_init
2743 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2744 $3, $2, $4); }
2745 | constructor_declarator maybeasm maybe_attribute maybe_init
2746 { $$ = parse_field0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2747 $3, $2, $4); }
2748 | IDENTIFIER ':' expr_no_commas maybe_attribute
2749 { $$ = parse_bitfield0 ($1, $<ftype>0.t, $<ftype>0.lookups,
2750 $4, $3); }
2751 | ':' expr_no_commas maybe_attribute
2752 { $$ = parse_bitfield0 (NULL_TREE, $<ftype>0.t,
2753 $<ftype>0.lookups, $3, $2); }
2756 after_type_component_declarator:
2757 after_type_declarator maybeasm maybe_attribute maybe_init
2758 { $$ = parse_field ($1, $3, $2, $4); }
2759 | TYPENAME ':' expr_no_commas maybe_attribute
2760 { $$ = parse_bitfield ($1, $4, $3); }
2763 notype_component_declarator:
2764 notype_declarator maybeasm maybe_attribute maybe_init
2765 { $$ = parse_field ($1, $3, $2, $4); }
2766 | IDENTIFIER ':' expr_no_commas maybe_attribute
2767 { $$ = parse_bitfield ($1, $4, $3); }
2768 | ':' expr_no_commas maybe_attribute
2769 { $$ = parse_bitfield (NULL_TREE, $3, $2); }
2772 enumlist_opt:
2773 enumlist maybecomma_warn
2774 | maybecomma_warn
2777 /* We chain the enumerators in reverse order.
2778 Because of the way enums are built, the order is
2779 insignificant. Take advantage of this fact. */
2781 enumlist:
2782 enumerator
2783 | enumlist ',' enumerator
2786 enumerator:
2787 identifier
2788 { build_enumerator ($1, NULL_TREE, current_enum_type); }
2789 | identifier '=' expr_no_commas
2790 { build_enumerator ($1, $3, current_enum_type); }
2793 /* ISO new-type-id (5.3.4) */
2794 new_type_id:
2795 type_specifier_seq new_declarator
2796 { $$.t = build_tree_list ($1.t, $2);
2797 $$.new_type_flag = $1.new_type_flag; }
2798 | type_specifier_seq %prec EMPTY
2799 { $$.t = build_tree_list ($1.t, NULL_TREE);
2800 $$.new_type_flag = $1.new_type_flag; }
2801 /* GNU extension to allow arrays of arbitrary types with
2802 non-constant dimension. */
2803 | '(' type_id ')' '[' expr ']'
2805 if (pedantic)
2806 pedwarn ("ISO C++ forbids array dimensions with parenthesized type in new");
2807 $$.t = build_nt (ARRAY_REF, TREE_VALUE ($2.t), $5);
2808 $$.t = build_tree_list (TREE_PURPOSE ($2.t), $$.t);
2809 $$.new_type_flag = $2.new_type_flag;
2813 cv_qualifiers:
2814 /* empty */ %prec EMPTY
2815 { $$ = NULL_TREE; }
2816 | cv_qualifiers CV_QUALIFIER
2817 { $$ = tree_cons (NULL_TREE, $2, $$); }
2820 nonempty_cv_qualifiers:
2821 CV_QUALIFIER
2822 { $$.t = hash_tree_cons (NULL_TREE, $1, NULL_TREE);
2823 $$.new_type_flag = 0; }
2824 | nonempty_cv_qualifiers CV_QUALIFIER
2825 { $$.t = hash_tree_cons (NULL_TREE, $2, $1.t);
2826 $$.new_type_flag = $1.new_type_flag; }
2829 /* These rules must follow the rules for function declarations
2830 and component declarations. That way, longer rules are preferred. */
2832 /* An expression which will not live on the momentary obstack. */
2833 maybe_parmlist:
2834 '(' nonnull_exprlist ')'
2835 { $$ = $2; }
2836 | '(' parmlist ')'
2837 { $$ = $2; }
2838 | LEFT_RIGHT
2839 { $$ = empty_parms (); }
2840 | '(' error ')'
2841 { $$ = NULL_TREE; }
2844 /* A declarator that is allowed only after an explicit typespec. */
2846 after_type_declarator_intern:
2847 after_type_declarator
2848 | attributes after_type_declarator
2850 /* Provide support for '(' attributes '*' declarator ')'
2851 etc */
2852 $$ = tree_cons ($1, $2, NULL_TREE);
2856 /* may all be followed by prec '.' */
2857 after_type_declarator:
2858 '*' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2859 { $$ = make_pointer_declarator ($2.t, $3); }
2860 | '&' nonempty_cv_qualifiers after_type_declarator_intern %prec UNARY
2861 { $$ = make_reference_declarator ($2.t, $3); }
2862 | '*' after_type_declarator_intern %prec UNARY
2863 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2864 | '&' after_type_declarator_intern %prec UNARY
2865 { $$ = make_reference_declarator (NULL_TREE, $2); }
2866 | ptr_to_mem cv_qualifiers after_type_declarator_intern
2867 { tree arg = make_pointer_declarator ($2, $3);
2868 $$ = build_nt (SCOPE_REF, $1, arg);
2870 | direct_after_type_declarator
2873 direct_after_type_declarator:
2874 direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2875 { $$ = make_call_declarator ($$, $2, $3, $4); }
2876 | direct_after_type_declarator '[' expr ']'
2877 { $$ = build_nt (ARRAY_REF, $$, $3); }
2878 | direct_after_type_declarator '[' ']'
2879 { $$ = build_nt (ARRAY_REF, $$, NULL_TREE); }
2880 | '(' after_type_declarator_intern ')'
2881 { $$ = $2; }
2882 | nested_name_specifier type_name %prec EMPTY
2883 { push_nested_class ($1, 3);
2884 $$ = build_nt (SCOPE_REF, $$, $2);
2885 TREE_COMPLEXITY ($$) = current_class_depth; }
2886 | type_name %prec EMPTY
2889 nonnested_type:
2890 type_name %prec EMPTY
2892 if (TREE_CODE ($1) == IDENTIFIER_NODE)
2894 $$ = lookup_name ($1, 1);
2895 maybe_note_name_used_in_class ($1, $$);
2897 else
2898 $$ = $1;
2900 | global_scope type_name
2902 if (TREE_CODE ($2) == IDENTIFIER_NODE)
2903 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
2904 else
2905 $$ = $2;
2906 got_scope = NULL_TREE;
2910 complete_type_name:
2911 nonnested_type
2912 | nested_type
2913 | global_scope nested_type
2914 { $$ = $2; }
2917 nested_type:
2918 nested_name_specifier type_name %prec EMPTY
2919 { $$ = get_type_decl ($2); }
2922 /* A declarator allowed whether or not there has been
2923 an explicit typespec. These cannot redeclare a typedef-name. */
2925 notype_declarator_intern:
2926 notype_declarator
2927 | attributes notype_declarator
2929 /* Provide support for '(' attributes '*' declarator ')'
2930 etc */
2931 $$ = tree_cons ($1, $2, NULL_TREE);
2935 notype_declarator:
2936 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2937 { $$ = make_pointer_declarator ($2.t, $3); }
2938 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2939 { $$ = make_reference_declarator ($2.t, $3); }
2940 | '*' notype_declarator_intern %prec UNARY
2941 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2942 | '&' notype_declarator_intern %prec UNARY
2943 { $$ = make_reference_declarator (NULL_TREE, $2); }
2944 | ptr_to_mem cv_qualifiers notype_declarator_intern
2945 { tree arg = make_pointer_declarator ($2, $3);
2946 $$ = build_nt (SCOPE_REF, $1, arg);
2948 | direct_notype_declarator
2951 complex_notype_declarator:
2952 '*' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2953 { $$ = make_pointer_declarator ($2.t, $3); }
2954 | '&' nonempty_cv_qualifiers notype_declarator_intern %prec UNARY
2955 { $$ = make_reference_declarator ($2.t, $3); }
2956 | '*' complex_notype_declarator %prec UNARY
2957 { $$ = make_pointer_declarator (NULL_TREE, $2); }
2958 | '&' complex_notype_declarator %prec UNARY
2959 { $$ = make_reference_declarator (NULL_TREE, $2); }
2960 | ptr_to_mem cv_qualifiers notype_declarator_intern
2961 { tree arg = make_pointer_declarator ($2, $3);
2962 $$ = build_nt (SCOPE_REF, $1, arg);
2964 | complex_direct_notype_declarator
2967 complex_direct_notype_declarator:
2968 direct_notype_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
2969 { $$ = make_call_declarator ($$, $2, $3, $4); }
2970 | '(' complex_notype_declarator ')'
2971 { $$ = $2; }
2972 | direct_notype_declarator '[' expr ']'
2973 { $$ = build_nt (ARRAY_REF, $$, $3); }
2974 | direct_notype_declarator '[' ']'
2975 { $$ = build_nt (ARRAY_REF, $$, NULL_TREE); }
2976 | notype_qualified_id
2977 { enter_scope_of ($1); }
2978 | global_scope notype_qualified_id
2979 { enter_scope_of ($2); $$ = $2;}
2980 | global_scope notype_unqualified_id
2981 { $$ = build_nt (SCOPE_REF, global_namespace, $2);
2982 enter_scope_of ($$);
2984 | nested_name_specifier notype_template_declarator
2985 { got_scope = NULL_TREE;
2986 $$ = build_nt (SCOPE_REF, $1, $2);
2987 enter_scope_of ($$);
2991 qualified_id:
2992 nested_name_specifier unqualified_id
2993 { got_scope = NULL_TREE;
2994 $$ = build_nt (SCOPE_REF, $$, $2); }
2995 | nested_name_specifier object_template_id
2996 { got_scope = NULL_TREE;
2997 $$ = build_nt (SCOPE_REF, $1, $2); }
3000 notype_qualified_id:
3001 nested_name_specifier notype_unqualified_id
3002 { got_scope = NULL_TREE;
3003 $$ = build_nt (SCOPE_REF, $$, $2); }
3004 | nested_name_specifier object_template_id
3005 { got_scope = NULL_TREE;
3006 $$ = build_nt (SCOPE_REF, $1, $2); }
3009 overqualified_id:
3010 notype_qualified_id
3011 | global_scope notype_qualified_id
3012 { $$ = $2; }
3015 functional_cast:
3016 typespec '(' nonnull_exprlist ')'
3017 { $$ = build_functional_cast ($1.t, $3); }
3018 | typespec '(' expr_or_declarator_intern ')'
3019 { $$ = reparse_decl_as_expr ($1.t, $3); }
3020 | typespec fcast_or_absdcl %prec EMPTY
3021 { $$ = reparse_absdcl_as_expr ($1.t, $2); }
3024 type_name:
3025 TYPENAME
3026 | SELFNAME
3027 | template_type %prec EMPTY
3030 nested_name_specifier:
3031 nested_name_specifier_1
3032 | nested_name_specifier nested_name_specifier_1
3033 { $$ = $2; }
3034 | nested_name_specifier TEMPLATE explicit_template_type SCOPE
3035 { got_scope = $$
3036 = make_typename_type ($1, $3, /*complain=*/1); }
3037 /* Error handling per Core 125. */
3038 | nested_name_specifier IDENTIFIER SCOPE
3039 { got_scope = $$
3040 = make_typename_type ($1, $2, /*complain=*/1); }
3041 | nested_name_specifier PTYPENAME SCOPE
3042 { got_scope = $$
3043 = make_typename_type ($1, $2, /*complain=*/1); }
3046 /* Why the @#$%^& do type_name and notype_identifier need to be expanded
3047 inline here?!? (jason) */
3048 nested_name_specifier_1:
3049 TYPENAME SCOPE
3051 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3053 $$ = lastiddecl;
3054 maybe_note_name_used_in_class ($1, $$);
3056 got_scope = $$ =
3057 complete_type (TYPE_MAIN_VARIANT (TREE_TYPE ($$)));
3059 | SELFNAME SCOPE
3061 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3062 $$ = lastiddecl;
3063 got_scope = $$ = TREE_TYPE ($$);
3065 | NSNAME SCOPE
3067 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3068 $$ = lastiddecl;
3069 got_scope = $$;
3071 | template_type SCOPE
3072 { got_scope = $$ = complete_type (TREE_TYPE ($1)); }
3075 typename_sub:
3076 typename_sub0
3077 | global_scope typename_sub0
3078 { $$ = $2; }
3081 typename_sub0:
3082 typename_sub1 identifier %prec EMPTY
3084 if (TYPE_P ($1))
3085 $$ = make_typename_type ($1, $2, /*complain=*/1);
3086 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
3087 cp_error ("`%T' is not a class or namespace", $2);
3088 else
3090 $$ = $2;
3091 if (TREE_CODE ($$) == TYPE_DECL)
3092 $$ = TREE_TYPE ($$);
3095 | typename_sub1 template_type %prec EMPTY
3096 { $$ = TREE_TYPE ($2); }
3097 | typename_sub1 explicit_template_type %prec EMPTY
3098 { $$ = make_typename_type ($1, $2, /*complain=*/1); }
3099 | typename_sub1 TEMPLATE explicit_template_type %prec EMPTY
3100 { $$ = make_typename_type ($1, $3, /*complain=*/1); }
3103 typename_sub1:
3104 typename_sub2
3106 if (TREE_CODE ($1) == IDENTIFIER_NODE)
3107 cp_error ("`%T' is not a class or namespace", $1);
3108 else if (TREE_CODE ($1) == TYPE_DECL)
3109 $$ = TREE_TYPE ($1);
3111 | typename_sub1 typename_sub2
3113 if (TYPE_P ($1))
3114 $$ = make_typename_type ($1, $2, /*complain=*/1);
3115 else if (TREE_CODE ($2) == IDENTIFIER_NODE)
3116 cp_error ("`%T' is not a class or namespace", $2);
3117 else
3119 $$ = $2;
3120 if (TREE_CODE ($$) == TYPE_DECL)
3121 $$ = TREE_TYPE ($$);
3124 | typename_sub1 explicit_template_type SCOPE
3125 { got_scope = $$
3126 = make_typename_type ($1, $2, /*complain=*/1); }
3127 | typename_sub1 TEMPLATE explicit_template_type SCOPE
3128 { got_scope = $$
3129 = make_typename_type ($1, $3, /*complain=*/1); }
3132 /* This needs to return a TYPE_DECL for simple names so that we don't
3133 forget what name was used. */
3134 typename_sub2:
3135 TYPENAME SCOPE
3137 if (TREE_CODE ($1) != TYPE_DECL)
3138 $$ = lastiddecl;
3140 /* Retrieve the type for the identifier, which might involve
3141 some computation. */
3142 got_scope = complete_type (TREE_TYPE ($$));
3144 if ($$ == error_mark_node)
3145 cp_error ("`%T' is not a class or namespace", $1);
3147 | SELFNAME SCOPE
3149 if (TREE_CODE ($1) != TYPE_DECL)
3150 $$ = lastiddecl;
3151 got_scope = complete_type (TREE_TYPE ($$));
3153 | template_type SCOPE
3154 { got_scope = $$ = complete_type (TREE_TYPE ($$)); }
3155 | PTYPENAME SCOPE
3156 | IDENTIFIER SCOPE
3157 | NSNAME SCOPE
3159 if (TREE_CODE ($$) == IDENTIFIER_NODE)
3160 $$ = lastiddecl;
3161 got_scope = $$;
3165 explicit_template_type:
3166 identifier '<' template_arg_list_opt template_close_bracket
3167 { $$ = build_min_nt (TEMPLATE_ID_EXPR, $1, $3); }
3170 complex_type_name:
3171 global_scope type_name
3173 if (TREE_CODE ($2) == IDENTIFIER_NODE)
3174 $$ = IDENTIFIER_GLOBAL_VALUE ($2);
3175 else
3176 $$ = $2;
3177 got_scope = NULL_TREE;
3179 | nested_type
3180 | global_scope nested_type
3181 { $$ = $2; }
3184 ptr_to_mem:
3185 nested_name_specifier '*'
3186 { got_scope = NULL_TREE; }
3187 | global_scope nested_name_specifier '*'
3188 { $$ = $2; got_scope = NULL_TREE; }
3191 /* All uses of explicit global scope must go through this nonterminal so
3192 that got_scope will be set before yylex is called to get the next token. */
3193 global_scope:
3194 SCOPE
3195 { got_scope = void_type_node; }
3198 /* ISO new-declarator (5.3.4) */
3199 new_declarator:
3200 '*' cv_qualifiers new_declarator
3201 { $$ = make_pointer_declarator ($2, $3); }
3202 | '*' cv_qualifiers %prec EMPTY
3203 { $$ = make_pointer_declarator ($2, NULL_TREE); }
3204 | '&' cv_qualifiers new_declarator %prec EMPTY
3205 { $$ = make_reference_declarator ($2, $3); }
3206 | '&' cv_qualifiers %prec EMPTY
3207 { $$ = make_reference_declarator ($2, NULL_TREE); }
3208 | ptr_to_mem cv_qualifiers %prec EMPTY
3209 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3210 $$ = build_nt (SCOPE_REF, $1, arg);
3212 | ptr_to_mem cv_qualifiers new_declarator
3213 { tree arg = make_pointer_declarator ($2, $3);
3214 $$ = build_nt (SCOPE_REF, $1, arg);
3216 | direct_new_declarator %prec EMPTY
3219 /* ISO direct-new-declarator (5.3.4) */
3220 direct_new_declarator:
3221 '[' expr ']'
3222 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
3223 | direct_new_declarator '[' expr ']'
3224 { $$ = build_nt (ARRAY_REF, $$, $3); }
3227 absdcl_intern:
3228 absdcl
3229 | attributes absdcl
3231 /* Provide support for '(' attributes '*' declarator ')'
3232 etc */
3233 $$ = tree_cons ($1, $2, NULL_TREE);
3237 /* ISO abstract-declarator (8.1) */
3238 absdcl:
3239 '*' nonempty_cv_qualifiers absdcl_intern
3240 { $$ = make_pointer_declarator ($2.t, $3); }
3241 | '*' absdcl_intern
3242 { $$ = make_pointer_declarator (NULL_TREE, $2); }
3243 | '*' nonempty_cv_qualifiers %prec EMPTY
3244 { $$ = make_pointer_declarator ($2.t, NULL_TREE); }
3245 | '*' %prec EMPTY
3246 { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
3247 | '&' nonempty_cv_qualifiers absdcl_intern
3248 { $$ = make_reference_declarator ($2.t, $3); }
3249 | '&' absdcl_intern
3250 { $$ = make_reference_declarator (NULL_TREE, $2); }
3251 | '&' nonempty_cv_qualifiers %prec EMPTY
3252 { $$ = make_reference_declarator ($2.t, NULL_TREE); }
3253 | '&' %prec EMPTY
3254 { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
3255 | ptr_to_mem cv_qualifiers %prec EMPTY
3256 { tree arg = make_pointer_declarator ($2, NULL_TREE);
3257 $$ = build_nt (SCOPE_REF, $1, arg);
3259 | ptr_to_mem cv_qualifiers absdcl_intern
3260 { tree arg = make_pointer_declarator ($2, $3);
3261 $$ = build_nt (SCOPE_REF, $1, arg);
3263 | direct_abstract_declarator %prec EMPTY
3266 /* ISO direct-abstract-declarator (8.1) */
3267 direct_abstract_declarator:
3268 '(' absdcl_intern ')'
3269 { $$ = $2; }
3270 /* `(typedef)1' is `int'. */
3271 | direct_abstract_declarator '(' parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3272 { $$ = make_call_declarator ($$, $3, $5, $6); }
3273 | direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
3274 { $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
3275 | direct_abstract_declarator '[' expr ']' %prec '.'
3276 { $$ = build_nt (ARRAY_REF, $$, $3); }
3277 | direct_abstract_declarator '[' ']' %prec '.'
3278 { $$ = build_nt (ARRAY_REF, $$, NULL_TREE); }
3279 | '(' complex_parmlist ')' cv_qualifiers exception_specification_opt %prec '.'
3280 { $$ = make_call_declarator (NULL_TREE, $2, $4, $5); }
3281 | regcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3282 { set_quals_and_spec ($$, $2, $3); }
3283 | fcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
3284 { set_quals_and_spec ($$, $2, $3); }
3285 | '[' expr ']' %prec '.'
3286 { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
3287 | '[' ']' %prec '.'
3288 { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
3291 /* For C++, decls and stmts can be intermixed, so we don't need to
3292 have a special rule that won't start parsing the stmt section
3293 until we have a stmt that parses without errors. */
3295 stmts:
3296 stmt
3297 | errstmt
3298 | stmts stmt
3299 | stmts errstmt
3302 errstmt:
3303 error ';'
3306 /* Read zero or more forward-declarations for labels
3307 that nested functions can jump to. */
3308 maybe_label_decls:
3309 /* empty */
3310 | label_decls
3311 { if (pedantic)
3312 pedwarn ("ISO C++ forbids label declarations"); }
3315 label_decls:
3316 label_decl
3317 | label_decls label_decl
3320 label_decl:
3321 LABEL identifiers_or_typenames ';'
3323 while ($2)
3325 finish_label_decl (TREE_VALUE ($2));
3326 $2 = TREE_CHAIN ($2);
3331 /* This is the body of a function definition.
3332 It causes syntax errors to ignore to the next openbrace. */
3333 compstmt_or_error:
3334 compstmt
3335 | error compstmt
3338 compstmt:
3339 save_lineno '{'
3340 { $<ttype>$ = begin_compound_stmt (0); }
3341 compstmtend
3342 { STMT_LINENO ($<ttype>3) = $1;
3343 finish_compound_stmt (0, $<ttype>3); }
3346 simple_if:
3348 { $<ttype>$ = begin_if_stmt ();
3349 cond_stmt_keyword = "if"; }
3350 paren_cond_or_null
3351 { finish_if_stmt_cond ($3, $<ttype>2); }
3352 implicitly_scoped_stmt
3353 { $$ = $<ttype>2;
3354 finish_then_clause ($<ttype>2); }
3357 implicitly_scoped_stmt:
3358 compstmt
3360 { $<ttype>$ = begin_compound_stmt (0); }
3361 save_lineno simple_stmt
3362 { STMT_LINENO ($<ttype>1) = $2;
3363 if ($3) STMT_LINENO ($3) = $2;
3364 finish_compound_stmt (0, $<ttype>1); }
3367 stmt:
3368 compstmt
3369 | save_lineno simple_stmt
3370 { if ($2) STMT_LINENO ($2) = $1; }
3373 simple_stmt:
3374 decl
3375 { finish_stmt ();
3376 $$ = NULL_TREE; }
3377 | expr ';'
3378 { $$ = finish_expr_stmt ($1); }
3379 | simple_if ELSE
3380 { begin_else_clause (); }
3381 implicitly_scoped_stmt
3383 $$ = $1;
3384 finish_else_clause ($1);
3385 finish_if_stmt ();
3387 | simple_if %prec IF
3388 { $$ = $1;
3389 finish_if_stmt (); }
3390 | WHILE
3392 $<ttype>$ = begin_while_stmt ();
3393 cond_stmt_keyword = "while";
3395 paren_cond_or_null
3396 { finish_while_stmt_cond ($3, $<ttype>2); }
3397 implicitly_scoped_stmt
3398 { $$ = $<ttype>2;
3399 finish_while_stmt ($<ttype>2); }
3400 | DO
3401 { $<ttype>$ = begin_do_stmt (); }
3402 implicitly_scoped_stmt WHILE
3404 finish_do_body ($<ttype>2);
3405 cond_stmt_keyword = "do";
3407 paren_expr_or_null ';'
3408 { $$ = $<ttype>2;
3409 finish_do_stmt ($6, $<ttype>2); }
3410 | FOR
3411 { $<ttype>$ = begin_for_stmt (); }
3412 '(' for.init.statement
3413 { finish_for_init_stmt ($<ttype>2); }
3414 xcond ';'
3415 { finish_for_cond ($6, $<ttype>2); }
3416 xexpr ')'
3417 { finish_for_expr ($9, $<ttype>2); }
3418 implicitly_scoped_stmt
3419 { $$ = $<ttype>2;
3420 finish_for_stmt ($<ttype>2); }
3421 | SWITCH
3422 { $<ttype>$ = begin_switch_stmt (); }
3423 '(' condition ')'
3424 { finish_switch_cond ($4, $<ttype>2); }
3425 implicitly_scoped_stmt
3426 { $$ = $<ttype>2;
3427 finish_switch_stmt ($<ttype>2); }
3428 | CASE expr_no_commas ':'
3429 { $<ttype>$ = finish_case_label ($2, NULL_TREE); }
3430 stmt
3431 { $$ = $<ttype>4; }
3432 | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
3433 { $<ttype>$ = finish_case_label ($2, $4); }
3434 stmt
3435 { $$ = $<ttype>6; }
3436 | DEFAULT ':'
3437 { $<ttype>$ = finish_case_label (NULL_TREE, NULL_TREE); }
3438 stmt
3439 { $$ = $<ttype>3; }
3440 | BREAK ';'
3441 { $$ = finish_break_stmt (); }
3442 | CONTINUE ';'
3443 { $$ = finish_continue_stmt (); }
3444 | RETURN_KEYWORD ';'
3445 { $$ = finish_return_stmt (NULL_TREE); }
3446 | RETURN_KEYWORD expr ';'
3447 { $$ = finish_return_stmt ($2); }
3448 | asm_keyword maybe_cv_qualifier '(' string ')' ';'
3449 { $$ = finish_asm_stmt ($2, $4, NULL_TREE, NULL_TREE,
3450 NULL_TREE);
3451 ASM_INPUT_P ($$) = 1; }
3452 /* This is the case with just output operands. */
3453 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ')' ';'
3454 { $$ = finish_asm_stmt ($2, $4, $6, NULL_TREE, NULL_TREE); }
3455 /* This is the case with input operands as well. */
3456 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':'
3457 asm_operands ')' ';'
3458 { $$ = finish_asm_stmt ($2, $4, $6, $8, NULL_TREE); }
3459 | asm_keyword maybe_cv_qualifier '(' string SCOPE asm_operands ')' ';'
3460 { $$ = finish_asm_stmt ($2, $4, NULL_TREE, $6, NULL_TREE); }
3461 /* This is the case with clobbered registers as well. */
3462 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands ':'
3463 asm_operands ':' asm_clobbers ')' ';'
3464 { $$ = finish_asm_stmt ($2, $4, $6, $8, $10); }
3465 | asm_keyword maybe_cv_qualifier '(' string SCOPE asm_operands ':'
3466 asm_clobbers ')' ';'
3467 { $$ = finish_asm_stmt ($2, $4, NULL_TREE, $6, $8); }
3468 | asm_keyword maybe_cv_qualifier '(' string ':' asm_operands SCOPE
3469 asm_clobbers ')' ';'
3470 { $$ = finish_asm_stmt ($2, $4, $6, NULL_TREE, $8); }
3471 | GOTO '*' expr ';'
3473 if (pedantic)
3474 pedwarn ("ISO C++ forbids computed gotos");
3475 $$ = finish_goto_stmt ($3);
3477 | GOTO identifier ';'
3478 { $$ = finish_goto_stmt ($2); }
3479 | label_colon stmt
3480 { $$ = NULL_TREE; }
3481 | label_colon '}'
3482 { error ("label must be followed by statement");
3483 yyungetc ('}', 0);
3484 $$ = NULL_TREE; }
3485 | ';'
3486 { finish_stmt ();
3487 $$ = NULL_TREE; }
3488 | try_block
3489 { $$ = NULL_TREE; }
3490 | using_directive
3491 { $$ = NULL_TREE; }
3492 | namespace_using_decl
3493 { do_local_using_decl ($1);
3494 $$ = NULL_TREE; }
3495 | namespace_alias
3496 { $$ = NULL_TREE; }
3499 function_try_block:
3501 { $<ttype>$ = begin_function_try_block (); }
3502 ctor_initializer_opt compstmt
3503 { finish_function_try_block ($<ttype>2); }
3504 handler_seq
3506 finish_function_handler_sequence ($<ttype>2);
3507 $$ = $3;
3511 try_block:
3513 { $<ttype>$ = begin_try_block (); }
3514 compstmt
3515 { finish_try_block ($<ttype>2); }
3516 handler_seq
3517 { finish_handler_sequence ($<ttype>2); }
3520 handler_seq:
3521 handler
3522 | handler_seq handler
3525 handler:
3526 CATCH
3527 { $<ttype>$ = begin_handler (); }
3528 handler_args
3529 { finish_handler_parms ($3, $<ttype>2); }
3530 compstmt
3531 { finish_handler ($<ttype>2); }
3534 type_specifier_seq:
3535 typed_typespecs %prec EMPTY
3536 | nonempty_cv_qualifiers %prec EMPTY
3539 handler_args:
3540 '(' ELLIPSIS ')'
3541 { $$ = NULL_TREE; }
3542 /* This doesn't allow reference parameters, the below does.
3543 | '(' type_specifier_seq absdcl ')'
3544 { check_for_new_type ("inside exception declarations", $2);
3545 expand_start_catch_block ($2.t, $3); }
3546 | '(' type_specifier_seq ')'
3547 { check_for_new_type ("inside exception declarations", $2);
3548 expand_start_catch_block ($2.t, NULL_TREE); }
3549 | '(' type_specifier_seq notype_declarator ')'
3550 { check_for_new_type ("inside exception declarations", $2);
3551 expand_start_catch_block ($2.t, $3); }
3552 | '(' typed_typespecs after_type_declarator ')'
3553 { check_for_new_type ("inside exception declarations", $2);
3554 expand_start_catch_block ($2.t, $3); }
3555 This allows reference parameters... */
3556 | '(' parm ')'
3558 check_for_new_type ("inside exception declarations", $2);
3559 $$ = start_handler_parms (TREE_PURPOSE ($2.t),
3560 TREE_VALUE ($2.t));
3564 label_colon:
3565 IDENTIFIER ':'
3566 { finish_label_stmt ($1); }
3567 | PTYPENAME ':'
3568 { finish_label_stmt ($1); }
3569 | TYPENAME ':'
3570 { finish_label_stmt ($1); }
3571 | SELFNAME ':'
3572 { finish_label_stmt ($1); }
3575 for.init.statement:
3576 xexpr ';'
3577 { finish_expr_stmt ($1); }
3578 | decl
3579 | '{' compstmtend
3580 { if (pedantic)
3581 pedwarn ("ISO C++ forbids compound statements inside for initializations");
3585 /* Either a type-qualifier or nothing. First thing in an `asm' statement. */
3587 maybe_cv_qualifier:
3588 /* empty */
3589 { $$ = NULL_TREE; }
3590 | CV_QUALIFIER
3593 xexpr:
3594 /* empty */
3595 { $$ = NULL_TREE; }
3596 | expr
3597 | error
3598 { $$ = NULL_TREE; }
3601 /* These are the operands other than the first string and colon
3602 in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
3603 asm_operands:
3604 /* empty */
3605 { $$ = NULL_TREE; }
3606 | nonnull_asm_operands
3609 nonnull_asm_operands:
3610 asm_operand
3611 | nonnull_asm_operands ',' asm_operand
3612 { $$ = chainon ($$, $3); }
3615 asm_operand:
3616 STRING '(' expr ')'
3617 { $$ = build_tree_list (build_tree_list (NULL_TREE, $1), $3); }
3618 | '[' identifier ']' STRING '(' expr ')'
3619 { $$ = build_tree_list (build_tree_list ($2, $4), $6); }
3622 asm_clobbers:
3623 string
3624 { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE);}
3625 | asm_clobbers ',' string
3626 { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
3629 /* This is what appears inside the parens in a function declarator.
3630 Its value is represented in the format that grokdeclarator expects.
3632 In C++, declaring a function with no parameters
3633 means that that function takes *no* parameters. */
3635 parmlist:
3636 /* empty */
3638 $$ = empty_parms();
3640 | complex_parmlist
3641 | type_id
3642 { $$ = finish_parmlist (build_tree_list (NULL_TREE, $1.t), 0);
3643 check_for_new_type ("inside parameter list", $1); }
3646 /* This nonterminal does not include the common sequence '(' type_id ')',
3647 as it is ambiguous and must be disambiguated elsewhere. */
3648 complex_parmlist:
3649 parms
3650 { $$ = finish_parmlist ($$, 0); }
3651 | parms_comma ELLIPSIS
3652 { $$ = finish_parmlist ($1, 1); }
3653 /* C++ allows an ellipsis without a separating ',' */
3654 | parms ELLIPSIS
3655 { $$ = finish_parmlist ($1, 1); }
3656 | type_id ELLIPSIS
3657 { $$ = finish_parmlist (build_tree_list (NULL_TREE,
3658 $1.t), 1); }
3659 | ELLIPSIS
3660 { $$ = finish_parmlist (NULL_TREE, 1); }
3661 | parms ':'
3663 /* This helps us recover from really nasty
3664 parse errors, for example, a missing right
3665 parenthesis. */
3666 yyerror ("possibly missing ')'");
3667 $$ = finish_parmlist ($1, 0);
3668 yyungetc (':', 0);
3669 yychar = ')';
3671 | type_id ':'
3673 /* This helps us recover from really nasty
3674 parse errors, for example, a missing right
3675 parenthesis. */
3676 yyerror ("possibly missing ')'");
3677 $$ = finish_parmlist (build_tree_list (NULL_TREE,
3678 $1.t), 0);
3679 yyungetc (':', 0);
3680 yychar = ')';
3684 /* A default argument to a */
3685 defarg:
3687 { maybe_snarf_defarg (); }
3688 defarg1
3689 { $$ = $3; }
3692 defarg1:
3693 DEFARG
3694 | init
3697 /* A nonempty list of parameter declarations or type names. */
3698 parms:
3699 named_parm
3700 { check_for_new_type ("in a parameter list", $1);
3701 $$ = build_tree_list (NULL_TREE, $1.t); }
3702 | parm defarg
3703 { check_for_new_type ("in a parameter list", $1);
3704 $$ = build_tree_list ($2, $1.t); }
3705 | parms_comma full_parm
3706 { check_for_new_type ("in a parameter list", $2);
3707 $$ = chainon ($$, $2.t); }
3708 | parms_comma bad_parm
3709 { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
3710 | parms_comma bad_parm '=' init
3711 { $$ = chainon ($$, build_tree_list ($4, $2)); }
3714 parms_comma:
3715 parms ','
3716 | type_id ','
3717 { check_for_new_type ("in a parameter list", $1);
3718 $$ = build_tree_list (NULL_TREE, $1.t); }
3721 /* A single parameter declaration or parameter type name,
3722 as found in a parmlist. */
3723 named_parm:
3724 /* Here we expand typed_declspecs inline to avoid mis-parsing of
3725 TYPESPEC IDENTIFIER. */
3726 typed_declspecs1 declarator
3727 { tree specs = strip_attrs ($1.t);
3728 $$.new_type_flag = $1.new_type_flag;
3729 $$.t = build_tree_list (specs, $2); }
3730 | typed_typespecs declarator
3731 { $$.t = build_tree_list ($1.t, $2);
3732 $$.new_type_flag = $1.new_type_flag; }
3733 | typespec declarator
3734 { $$.t = build_tree_list (build_tree_list (NULL_TREE, $1.t),
3735 $2);
3736 $$.new_type_flag = $1.new_type_flag; }
3737 | typed_declspecs1 absdcl
3738 { tree specs = strip_attrs ($1.t);
3739 $$.t = build_tree_list (specs, $2);
3740 $$.new_type_flag = $1.new_type_flag; }
3741 | typed_declspecs1 %prec EMPTY
3742 { tree specs = strip_attrs ($1.t);
3743 $$.t = build_tree_list (specs, NULL_TREE);
3744 $$.new_type_flag = $1.new_type_flag; }
3745 | declmods notype_declarator
3746 { tree specs = strip_attrs ($1.t);
3747 $$.t = build_tree_list (specs, $2);
3748 $$.new_type_flag = 0; }
3751 full_parm:
3752 parm
3753 { $$.t = build_tree_list (NULL_TREE, $1.t);
3754 $$.new_type_flag = $1.new_type_flag; }
3755 | parm defarg
3756 { $$.t = build_tree_list ($2, $1.t);
3757 $$.new_type_flag = $1.new_type_flag; }
3760 parm:
3761 named_parm
3762 | type_id
3765 see_typename:
3766 /* empty */ %prec EMPTY
3767 { see_typename (); }
3770 bad_parm:
3771 /* empty */ %prec EMPTY
3773 error ("type specifier omitted for parameter");
3774 $$ = build_tree_list (integer_type_node, NULL_TREE);
3776 | notype_declarator
3778 error ("type specifier omitted for parameter");
3779 if (TREE_CODE ($$) == SCOPE_REF
3780 && (TREE_CODE (TREE_OPERAND ($$, 0)) == TEMPLATE_TYPE_PARM
3781 || TREE_CODE (TREE_OPERAND ($$, 0)) == BOUND_TEMPLATE_TEMPLATE_PARM))
3782 cp_error (" perhaps you want `typename %E' to make it a type", $$);
3783 $$ = build_tree_list (integer_type_node, $$);
3787 bad_decl:
3788 IDENTIFIER template_arg_list_ignore IDENTIFIER arg_list_ignore ';'
3790 cp_error("'%D' is used as a type, but is not defined as a type.", $1);
3791 $3 = error_mark_node;
3795 template_arg_list_ignore:
3796 '<' template_arg_list_opt template_close_bracket
3798 | /* empty */
3801 arg_list_ignore:
3802 '(' nonnull_exprlist ')'
3804 | /* empty */
3807 exception_specification_opt:
3808 /* empty */ %prec EMPTY
3809 { $$ = NULL_TREE; }
3810 | THROW '(' ansi_raise_identifiers ')' %prec EMPTY
3811 { $$ = $3; }
3812 | THROW LEFT_RIGHT %prec EMPTY
3813 { $$ = empty_except_spec; }
3816 ansi_raise_identifier:
3817 type_id
3819 check_for_new_type ("exception specifier", $1);
3820 $$ = groktypename ($1.t);
3824 ansi_raise_identifiers:
3825 ansi_raise_identifier
3826 { $$ = add_exception_specifier (NULL_TREE, $1, 1); }
3827 | ansi_raise_identifiers ',' ansi_raise_identifier
3828 { $$ = add_exception_specifier ($1, $3, 1); }
3831 conversion_declarator:
3832 /* empty */ %prec EMPTY
3833 { $$ = NULL_TREE; }
3834 | '*' cv_qualifiers conversion_declarator
3835 { $$ = make_pointer_declarator ($2, $3); }
3836 | '&' cv_qualifiers conversion_declarator
3837 { $$ = make_reference_declarator ($2, $3); }
3838 | ptr_to_mem cv_qualifiers conversion_declarator
3839 { tree arg = make_pointer_declarator ($2, $3);
3840 $$ = build_nt (SCOPE_REF, $1, arg);
3844 operator:
3845 OPERATOR
3847 saved_scopes = tree_cons (got_scope, got_object, saved_scopes);
3848 TREE_LANG_FLAG_0 (saved_scopes) = looking_for_typename;
3849 /* We look for conversion-type-id's in both the class and current
3850 scopes, just as for ID in 'ptr->ID::'. */
3851 looking_for_typename = 1;
3852 got_object = got_scope;
3853 got_scope = NULL_TREE;
3857 unoperator:
3858 { got_scope = TREE_PURPOSE (saved_scopes);
3859 got_object = TREE_VALUE (saved_scopes);
3860 looking_for_typename = TREE_LANG_FLAG_0 (saved_scopes);
3861 saved_scopes = TREE_CHAIN (saved_scopes);
3865 operator_name:
3866 operator '*' unoperator
3867 { $$ = frob_opname (ansi_opname (MULT_EXPR)); }
3868 | operator '/' unoperator
3869 { $$ = frob_opname (ansi_opname (TRUNC_DIV_EXPR)); }
3870 | operator '%' unoperator
3871 { $$ = frob_opname (ansi_opname (TRUNC_MOD_EXPR)); }
3872 | operator '+' unoperator
3873 { $$ = frob_opname (ansi_opname (PLUS_EXPR)); }
3874 | operator '-' unoperator
3875 { $$ = frob_opname (ansi_opname (MINUS_EXPR)); }
3876 | operator '&' unoperator
3877 { $$ = frob_opname (ansi_opname (BIT_AND_EXPR)); }
3878 | operator '|' unoperator
3879 { $$ = frob_opname (ansi_opname (BIT_IOR_EXPR)); }
3880 | operator '^' unoperator
3881 { $$ = frob_opname (ansi_opname (BIT_XOR_EXPR)); }
3882 | operator '~' unoperator
3883 { $$ = frob_opname (ansi_opname (BIT_NOT_EXPR)); }
3884 | operator ',' unoperator
3885 { $$ = frob_opname (ansi_opname (COMPOUND_EXPR)); }
3886 | operator ARITHCOMPARE unoperator
3887 { $$ = frob_opname (ansi_opname ($2)); }
3888 | operator '<' unoperator
3889 { $$ = frob_opname (ansi_opname (LT_EXPR)); }
3890 | operator '>' unoperator
3891 { $$ = frob_opname (ansi_opname (GT_EXPR)); }
3892 | operator EQCOMPARE unoperator
3893 { $$ = frob_opname (ansi_opname ($2)); }
3894 | operator ASSIGN unoperator
3895 { $$ = frob_opname (ansi_assopname ($2)); }
3896 | operator '=' unoperator
3897 { $$ = frob_opname (ansi_assopname (NOP_EXPR)); }
3898 | operator LSHIFT unoperator
3899 { $$ = frob_opname (ansi_opname ($2)); }
3900 | operator RSHIFT unoperator
3901 { $$ = frob_opname (ansi_opname ($2)); }
3902 | operator PLUSPLUS unoperator
3903 { $$ = frob_opname (ansi_opname (POSTINCREMENT_EXPR)); }
3904 | operator MINUSMINUS unoperator
3905 { $$ = frob_opname (ansi_opname (PREDECREMENT_EXPR)); }
3906 | operator ANDAND unoperator
3907 { $$ = frob_opname (ansi_opname (TRUTH_ANDIF_EXPR)); }
3908 | operator OROR unoperator
3909 { $$ = frob_opname (ansi_opname (TRUTH_ORIF_EXPR)); }
3910 | operator '!' unoperator
3911 { $$ = frob_opname (ansi_opname (TRUTH_NOT_EXPR)); }
3912 | operator '?' ':' unoperator
3913 { $$ = frob_opname (ansi_opname (COND_EXPR)); }
3914 | operator MIN_MAX unoperator
3915 { $$ = frob_opname (ansi_opname ($2)); }
3916 | operator POINTSAT unoperator %prec EMPTY
3917 { $$ = frob_opname (ansi_opname (COMPONENT_REF)); }
3918 | operator POINTSAT_STAR unoperator %prec EMPTY
3919 { $$ = frob_opname (ansi_opname (MEMBER_REF)); }
3920 | operator LEFT_RIGHT unoperator
3921 { $$ = frob_opname (ansi_opname (CALL_EXPR)); }
3922 | operator '[' ']' unoperator
3923 { $$ = frob_opname (ansi_opname (ARRAY_REF)); }
3924 | operator NEW unoperator %prec EMPTY
3925 { $$ = frob_opname (ansi_opname (NEW_EXPR)); }
3926 | operator DELETE unoperator %prec EMPTY
3927 { $$ = frob_opname (ansi_opname (DELETE_EXPR)); }
3928 | operator NEW '[' ']' unoperator
3929 { $$ = frob_opname (ansi_opname (VEC_NEW_EXPR)); }
3930 | operator DELETE '[' ']' unoperator
3931 { $$ = frob_opname (ansi_opname (VEC_DELETE_EXPR)); }
3932 | operator type_specifier_seq conversion_declarator unoperator
3933 { $$ = frob_opname (grokoptypename ($2.t, $3)); }
3934 | operator error unoperator
3935 { $$ = frob_opname (ansi_opname (ERROR_MARK)); }
3938 /* The forced readahead in here is because we might be at the end of a
3939 line, and lineno won't be bumped until yylex absorbs the first token
3940 on the next line. */
3941 save_lineno:
3942 { if (yychar == YYEMPTY)
3943 yychar = YYLEX;
3944 $$ = lineno; }
3948 #ifdef SPEW_DEBUG
3949 const char *
3950 debug_yytranslate (value)
3951 int value;
3953 return yytname[YYTRANSLATE (value)];
3956 #endif